@@ -134,14 +134,14 @@ object Completion {
134
134
* If several denotations share the same name, the type denotations appear before term denotations inside
135
135
* the same `Completion`.
136
136
*/
137
- private def describeCompletions (completions : Map [ Name , Seq [ SingleDenotation ]] )(using Context ): List [Completion ] = {
137
+ private def describeCompletions (completions : CompletionMap )(using Context ): List [Completion ] = {
138
138
completions
139
139
.toList.groupBy(_._1.toTermName) // don't distinguish between names of terms and types
140
140
.toList.map { (name, namedDenots) =>
141
- val denots = namedDenots.flatMap(_._2)
142
- val typesFirst = denots.sortWith((d1, d2) => d1.isType && ! d2.isType)
143
- val desc = description(typesFirst)
144
- Completion (name.show, desc, typesFirst.map(_.symbol))
141
+ val denots = namedDenots.flatMap(_._2)
142
+ val typesFirst = denots.sortWith((d1, d2) => d1.isType && ! d2.isType)
143
+ val desc = description(typesFirst)
144
+ Completion (name.show, desc, typesFirst.map(_.symbol))
145
145
}
146
146
}
147
147
@@ -188,7 +188,7 @@ object Completion {
188
188
* (even if the import follows it syntactically)
189
189
* - a more deeply nested import shadowing a member or a local definition causes an ambiguity
190
190
*/
191
- def scopeCompletions (using context : Context ): Map [ Name , Seq [ SingleDenotation ]] = {
191
+ def scopeCompletions (using context : Context ): CompletionMap = {
192
192
val mappings = collection.mutable.Map .empty[Name , List [ScopedDenotations ]].withDefaultValue(List .empty)
193
193
def addMapping (name : Name , denots : ScopedDenotations ) =
194
194
mappings(name) = mappings(name) :+ denots
@@ -238,15 +238,15 @@ object Completion {
238
238
* Direct members take priority over members from extensions
239
239
* and so do members from extensions over members from implicit conversions
240
240
*/
241
- def selectionCompletions (qual : Tree )(using Context ): Map [ Name , Seq [ SingleDenotation ]] =
241
+ def selectionCompletions (qual : Tree )(using Context ): CompletionMap =
242
242
implicitConversionMemberCompletions(qual) ++
243
243
extensionCompletions(qual) ++
244
244
directMemberCompletions(qual)
245
245
246
246
/** Completions for members of `qual`'s type.
247
247
* These include inherited definitions but not members added by extensions or implicit conversions
248
248
*/
249
- def directMemberCompletions (qual : Tree )(using Context ): Map [ Name , Seq [ SingleDenotation ]] =
249
+ def directMemberCompletions (qual : Tree )(using Context ): CompletionMap =
250
250
if qual.tpe.widenDealias.isExactlyNothing then
251
251
Map .empty
252
252
else
@@ -255,7 +255,7 @@ object Completion {
255
255
/** Completions introduced by imports directly in this context.
256
256
* Completions from outer contexts are not included.
257
257
*/
258
- private def importedCompletions (using Context ): Map [ Name , Seq [ SingleDenotation ]] = {
258
+ private def importedCompletions (using Context ): CompletionMap = {
259
259
val imp = ctx.importInfo
260
260
261
261
def fromImport (name : Name , nameInScope : Name ): Seq [(Name , SingleDenotation )] =
@@ -293,7 +293,7 @@ object Completion {
293
293
}
294
294
295
295
/** Completions from implicit conversions including old style extensions using implicit classes */
296
- private def implicitConversionMemberCompletions (qual : Tree )(using Context ): Map [ Name , Seq [ SingleDenotation ]] =
296
+ private def implicitConversionMemberCompletions (qual : Tree )(using Context ): CompletionMap =
297
297
if qual.tpe.widenDealias.isExactlyNothing || qual.tpe.isNullType then
298
298
Map .empty
299
299
else
@@ -302,7 +302,7 @@ object Completion {
302
302
membersFromConversion.toSeq.groupByName
303
303
304
304
/** Completions from extension methods */
305
- private def extensionCompletions (qual : Tree )(using Context ): Map [ Name , Seq [ SingleDenotation ]] =
305
+ private def extensionCompletions (qual : Tree )(using Context ): CompletionMap =
306
306
def asDefLikeType (tpe : Type ): Type = tpe match
307
307
case _ : MethodOrPoly => tpe
308
308
case _ => ExprType (tpe)
@@ -424,13 +424,15 @@ object Completion {
424
424
}
425
425
426
426
extension (denotations : Seq [SingleDenotation ])
427
- def groupByName (using Context ): Map [ Name , Seq [ SingleDenotation ]] = denotations.groupBy(_.name)
427
+ def groupByName (using Context ): CompletionMap = denotations.groupBy(_.name)
428
428
429
429
extension [N <: Name ](namedDenotations : Seq [(N , SingleDenotation )])
430
430
@ annotation.targetName(" groupByNameTupled" )
431
- def groupByName : Map [ N , Seq [ SingleDenotation ]] = namedDenotations.groupMap((name, denot) => name)((name, denot) => denot)
431
+ def groupByName : CompletionMap = namedDenotations.groupMap((name, denot) => name)((name, denot) => denot)
432
432
}
433
433
434
+ private type CompletionMap = Map [Name , Seq [SingleDenotation ]]
435
+
434
436
/** Temporary data structure representing denotations with the same name introduced in a given scope
435
437
* as a member of a type, by a local definition or by an import clause
436
438
*/
0 commit comments