-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Small improvements to workspace/symbol
#5443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
cd2f983
54656b9
7fd0c1d
1c8eca5
b40313a
8213555
e86b1b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import core._, core.Decorators.{sourcePos => _, _} | |
import Comments._, Constants._, Contexts._, Flags._, Names._, NameOps._, Symbols._, SymDenotations._, Trees._, Types._ | ||
import classpath.ClassPathEntries | ||
import reporting._, reporting.diagnostic.{Message, MessageContainer, messages} | ||
import transform.SymUtils.decorateSymbol | ||
import typer.Typer | ||
import util.{Set => _, _} | ||
import interactive._, interactive.InteractiveDriver._ | ||
|
@@ -456,8 +457,12 @@ class DottyLanguageServer extends LanguageServer | |
implicit val ctx = driver.currentCtx | ||
|
||
val uriTrees = driver.openedTrees(uri) | ||
val predicate = (tree: NameTree) => { | ||
val sym = tree.symbol | ||
sym.exists && !sym.isLocal && !sym.isPrimaryConstructor && !sym.is(Synthetic) | ||
} | ||
|
||
val defs = Interactive.namedTrees(uriTrees, Include.empty, _ => true) | ||
val defs = Interactive.namedTrees(uriTrees, Include.empty, predicate) | ||
(for { | ||
d <- defs if !isWorksheetWrapper(d) | ||
info <- symbolInfo(d.tree.symbol, d.namePos, positionMapperFor(d.source)) | ||
|
@@ -466,12 +471,14 @@ class DottyLanguageServer extends LanguageServer | |
|
||
override def symbol(params: WorkspaceSymbolParams) = computeAsync { cancelToken => | ||
val query = params.getQuery | ||
def predicate(implicit ctx: Context): NameTree => Boolean = | ||
tree => tree.symbol.exists && !tree.symbol.isLocal && tree.name.toString.contains(query) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't symbol and documentSymbol have similar predicates ? I.e., should we also exclude primary constructors and synthetic symbols here ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that makes a lot of sense. I've removed checks that were redundant with those happening in I'm also thinking that |
||
|
||
drivers.values.toList.flatMap { driver => | ||
implicit val ctx = driver.currentCtx | ||
|
||
val trees = driver.allTrees | ||
val defs = Interactive.namedTrees(trees, nameSubstring = query) | ||
val trees = driver.sourceTreesContaining(query) | ||
val defs = Interactive.namedTrees(trees, Include.empty, predicate) | ||
defs.flatMap(d => symbolInfo(d.tree.symbol, d.namePos, positionMapperFor(d.source))) | ||
}.asJava | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.