Skip to content

Commit f88ad86

Browse files
committed
Address last review comments
1 parent 8dc5f8f commit f88ad86

File tree

3 files changed

+5
-36
lines changed

3 files changed

+5
-36
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11931193
*/
11941194
def importSelections(imp: Import)(implicit ctx: Context): List[Select] = {
11951195
def imported(sym: Symbol, id: untpd.Ident, rename: Option[untpd.Ident]): List[Select] = {
1196+
// Give a zero-extent position to the qualifier to prevent it from being included several
1197+
// times in results in the language server.
11961198
val noPosExpr = focusPositions(imp.expr)
11971199
val selectTree = Select(noPosExpr, sym.name).withPos(id.pos)
11981200
rename match {

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

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,11 @@ object Interactive {
556556
}
557557

558558
/**
559-
* Is this tree using a renaming introduced by an import statement?
559+
* Is this tree using a renaming introduced by an import statement or an alias for `this`?
560560
*
561561
* @param tree The tree to inspect
562562
* @return True, if this tree's name is different than its symbol's name, indicating that
563-
* it uses a renaming introduced by an import statement.
563+
* it uses a renaming introduced by an import statement or an alias for `this`.
564564
*/
565565
def isRenamed(tree: NameTree)(implicit ctx: Context): Boolean = {
566566
val symbol = tree.symbol
@@ -572,37 +572,4 @@ object Interactive {
572572
n0.stripModuleClassSuffix.toTermName eq n1.stripModuleClassSuffix.toTermName
573573
}
574574

575-
/**
576-
* Is this tree immediately enclosing an import that renames a symbol to `toName`?
577-
*
578-
* @param toName The target name to check
579-
* @param tree The tree to check
580-
* @return True if this tree immediately encloses an import that renames a symbol to `toName`,
581-
* false otherwise.
582-
*/
583-
def immediatelyEnclosesRenaming(toName: Name, inTree: Tree)(implicit ctx: Context): Boolean = {
584-
def isImportRenaming(tree: Tree): Boolean = {
585-
tree match {
586-
case Import(_, selectors) =>
587-
selectors.exists {
588-
case Thicket(_ :: Ident(rename) :: Nil) => sameName(rename, toName)
589-
case _ => false
590-
}
591-
case _ =>
592-
false
593-
}
594-
}
595-
596-
inTree match {
597-
case PackageDef(_, stats) =>
598-
stats.exists(isImportRenaming)
599-
case template: Template =>
600-
template.body.exists(isImportRenaming)
601-
case Block(stats, _) =>
602-
stats.exists(isImportRenaming)
603-
case _ =>
604-
false
605-
}
606-
}
607-
608575
}

language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class DottyLanguageServer extends LanguageServer
415415
val uriTrees = driver.openedTrees(uri)
416416
val path = Interactive.pathTo(uriTrees, pos)
417417
val syms = Interactive.enclosingSourceSymbols(path, pos)
418-
val includes = Include.definitions | Include.references | Include.imports
418+
val includes = Include.all.except(Include.linkedClass)
419419

420420
syms.flatMap { sym =>
421421
val refs = Interactive.findTreesMatching(uriTrees, includes, sym)

0 commit comments

Comments
 (0)