Skip to content

Commit f9443e1

Browse files
committed
Return syms grouped by name in RenameAwareScope
1 parent 6ed0ccd commit f9443e1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dotty.tools.dotc.core.CheckRealizable
77
import dotty.tools.dotc.core.Decorators.StringInterpolators
88
import dotty.tools.dotc.core.Denotations.SingleDenotation
99
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}
1111
import dotty.tools.dotc.core.NameKinds.SimpleNameKind
1212
import dotty.tools.dotc.core.NameOps.NameDecorator
1313
import dotty.tools.dotc.core.Symbols.{defn, NoSymbol, Symbol}
@@ -146,12 +146,8 @@ object Completion {
146146
* the same `Completion`.
147147
*/
148148
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) =>
155151
val typesFirst = symbols.sortWith((s1, s2) => s1.isType && !s2.isType)
156152
val desc = description(typesFirst)
157153
Completion(name.toString, desc, typesFirst)
@@ -357,12 +353,16 @@ object Completion {
357353
sym
358354
}
359355

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))
366366
}
367367
}
368368

0 commit comments

Comments
 (0)