Skip to content

Commit 14518a3

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 755d607 commit 14518a3

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
@@ -425,7 +425,7 @@ class DottyLanguageServer extends LanguageServer
425425
drivers.values.toList.flatMap { driver =>
426426
implicit val ctx = driver.currentCtx
427427

428-
val trees = driver.allTrees
428+
val trees = driver.sourceTreesContaining(query)
429429
val defs = Interactive.namedTrees(trees, nameSubstring = query)
430430
defs.flatMap(d => symbolInfo(d.tree.symbol, d.namePos, positionMapperFor(d.source)))
431431
}.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)