Skip to content

Commit b40313a

Browse files
committed
Exclude primary constructors in namedTrees
We never want to match them, so it's easier to exclude them here rather than always add a check in the predicate function.
1 parent 1c8eca5 commit b40313a

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ object Interactive {
338338
val tree = utree.asInstanceOf[tpd.NameTree]
339339
if (tree.symbol.exists
340340
&& !tree.symbol.is(Synthetic)
341+
&& !tree.symbol.isPrimaryConstructor
341342
&& tree.pos.exists
342343
&& !tree.pos.isZeroExtent
343344
&& (include.isReferences || isDefinition(tree))
@@ -373,8 +374,7 @@ object Interactive {
373374
)(implicit ctx: Context): List[SourceTree] = {
374375
val linkedSym = symbol.linkedClass
375376
val fullPredicate: NameTree => Boolean = tree =>
376-
( !tree.symbol.isPrimaryConstructor
377-
&& (includes.isDefinitions || !Interactive.isDefinition(tree))
377+
( (includes.isDefinitions || !Interactive.isDefinition(tree))
378378
&& ( Interactive.matchSymbol(tree, symbol, includes)
379379
|| ( includes.isLinkedClass
380380
&& linkedSym.exists

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,7 @@ class DottyLanguageServer extends LanguageServer
457457
implicit val ctx = driver.currentCtx
458458

459459
val uriTrees = driver.openedTrees(uri)
460-
val predicate = (tree: NameTree) => {
461-
val sym = tree.symbol
462-
!sym.isLocal && !sym.isPrimaryConstructor
463-
}
460+
val predicate = (tree: NameTree) => !tree.symbol.isLocal
464461

465462
val defs = Interactive.namedTrees(uriTrees, Include.empty, predicate)
466463
(for {
@@ -473,7 +470,7 @@ class DottyLanguageServer extends LanguageServer
473470
val query = params.getQuery
474471
def predicate(implicit ctx: Context): NameTree => Boolean = { tree =>
475472
val sym = tree.symbol
476-
!sym.isLocal && !sym.isPrimaryConstructor && tree.name.toString.contains(query)
473+
!sym.isLocal && tree.name.toString.contains(query)
477474
}
478475

479476
drivers.values.toList.flatMap { driver =>

0 commit comments

Comments
 (0)