@@ -7,7 +7,7 @@ import dotty.tools.dotc.core.CheckRealizable
7
7
import dotty .tools .dotc .core .Decorators .StringInterpolators
8
8
import dotty .tools .dotc .core .Denotations .SingleDenotation
9
9
import dotty .tools .dotc .core .Flags ._
10
- import dotty .tools .dotc .core .Names .{Name , TermName }
10
+ import dotty .tools .dotc .core .Names .{Name , SimpleName , TermName }
11
11
import dotty .tools .dotc .core .NameKinds .SimpleNameKind
12
12
import dotty .tools .dotc .core .NameOps .NameDecorator
13
13
import dotty .tools .dotc .core .Symbols .{defn , NoSymbol , Symbol }
@@ -146,12 +146,8 @@ object Completion {
146
146
* the same `Completion`.
147
147
*/
148
148
def getCompletions (implicit ctx : Context ): List [Completion ] = {
149
- val groupedSymbols = {
150
- val symbols = completions.toListWithNames
151
- val nameToSymbols = symbols.groupBy(_._2.stripModuleClassSuffix.toSimpleName)
152
- nameToSymbols.mapValues(_.map(_._1)).toList
153
- }
154
- groupedSymbols.map { case (name, symbols) =>
149
+ val nameToSymbols = completions.mappings.toList
150
+ nameToSymbols.map { case (name, symbols) =>
155
151
val typesFirst = symbols.sortWith((s1, s2) => s1.isType && ! s2.isType)
156
152
val desc = description(typesFirst)
157
153
Completion (name.toString, desc, typesFirst)
@@ -357,12 +353,16 @@ object Completion {
357
353
sym
358
354
}
359
355
360
- /** Lists the symbols in this scope along with the name associated with them. */
361
- def toListWithNames (implicit ctx : Context ): List [(Symbol , Name )] = {
362
- for {
363
- (name, syms) <- nameToSymbols.toList
364
- sym <- syms
365
- } yield (sym, name)
356
+ /** Get the names that are known in this scope, along with the list of symbols they refer to. */
357
+ def mappings (implicit ctx : Context ): Map [SimpleName , List [Symbol ]] = {
358
+ val symbols =
359
+ for {
360
+ (name, syms) <- nameToSymbols.toList
361
+ sym <- syms
362
+ } yield (sym, name)
363
+ symbols
364
+ .groupBy(_._2.stripModuleClassSuffix.toSimpleName)
365
+ .mapValues(_.map(_._1))
366
366
}
367
367
}
368
368
0 commit comments