Skip to content

Commit 2b45c01

Browse files
committed
IDE: Remove unused substring reference search
`Interactive.scala` offered an API to find all references to names given substrings of the names. This feature was unused. This worked by pretty printing the tree and looking whether it contained the substring. This is broken, because the substring may match parts that are not references (what if we look for `if`?) It's gone now.
1 parent aaba401 commit 2b45c01

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,11 @@ object Interactive {
265265
namedTrees(trees, (include & Include.references) != 0, matchSymbol(_, sym, include))
266266

267267
/** Find named trees with a non-empty position whose name contains `nameSubstring` in `trees`.
268-
*
269-
* @param includeReferences If true, include references and not just definitions
270268
*/
271-
def namedTrees(trees: List[SourceTree], includeReferences: Boolean, nameSubstring: String)
269+
def namedTrees(trees: List[SourceTree], nameSubstring: String)
272270
(implicit ctx: Context): List[SourceTree] = {
273-
val predicate: NameTree => Boolean =
274-
if (includeReferences) _.show.contains(nameSubstring)
275-
else _.name.toString.contains(nameSubstring)
276-
namedTrees(trees, includeReferences, predicate)
271+
val predicate: NameTree => Boolean = _.name.toString.contains(nameSubstring)
272+
namedTrees(trees, includeReferences = false, predicate)
277273
}
278274

279275
/** Find named trees with a non-empty position satisfying `treePredicate` in `trees`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class DottyLanguageServer extends LanguageServer
428428
implicit val ctx = driver.currentCtx
429429

430430
val trees = driver.allTrees
431-
val defs = Interactive.namedTrees(trees, includeReferences = false, nameSubstring = query)
431+
val defs = Interactive.namedTrees(trees, nameSubstring = query)
432432
defs.flatMap(d => symbolInfo(d.tree.symbol, d.namePos, positionMapperFor(d.source)))
433433
}.asJava
434434
}

0 commit comments

Comments
 (0)