Skip to content

Commit cd2f983

Browse files
committed
Look only in source trees in workspace/symbol
We were inspecting all trees on the classpath for every project, which was not efficient and lead to duplicate results. This commit changes the implementation so that the language server inspects only the source trees of every project.
1 parent 2fadaed commit cd2f983

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class DottyLanguageServer extends LanguageServer
470470
drivers.values.toList.flatMap { driver =>
471471
implicit val ctx = driver.currentCtx
472472

473-
val trees = driver.allTrees
473+
val trees = driver.sourceTreesContaining(query)
474474
val defs = Interactive.namedTrees(trees, nameSubstring = query)
475475
defs.flatMap(d => symbolInfo(d.tree.symbol, d.namePos, positionMapperFor(d.source)))
476476
}.asJava

language-server/test/dotty/tools/languageserver/SymbolTest.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,19 @@ class SymbolTest {
3939
.symbol("Foo", (m1 to m2).symInfo("Foo", SymbolKind.Module),
4040
(m3 to m4).symInfo("Foo", SymbolKind.Class))
4141
}
42+
43+
@Test def multipleProjects0: Unit = {
44+
val p0 = Project.withSources(
45+
code"""class ${m1}Foo${m2}"""
46+
)
47+
48+
val p1 = Project.dependingOn(p0).withSources(
49+
code"""class ${m3}Bar${m4} extends Foo"""
50+
)
51+
52+
withProjects(p0, p1)
53+
.symbol("Foo", (m1 to m2).symInfo("Foo", SymbolKind.Class))
54+
55+
56+
}
4257
}

0 commit comments

Comments
 (0)