Skip to content

Commit

Permalink
improvement: Always find all references
Browse files Browse the repository at this point in the history
I think we did it previously on purpose, but it seems it's mostly just confusing to users.

Fixes #6776
  • Loading branch information
tgodzik committed Oct 31, 2024
1 parent bcba920 commit e3812b3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ final class ReferenceProvider(

def candidates(check: SymbolInformation => Boolean) = for {
info <- definitionDoc.symbols
if info.symbol != name
if check(info)
} yield info.symbol

Expand All @@ -384,6 +383,7 @@ final class ReferenceProvider(
candidates { info =>
alternatives.isVarSetter(info) ||
alternatives.isCompanionObject(info) ||
alternatives.isCompanionClass(info) ||
alternatives.isCopyOrApplyParam(info) ||
alternatives.isContructorParam(info)
}.toSet
Expand All @@ -408,9 +408,9 @@ final class ReferenceProvider(
if (defPath.isJava)
isCandidate
else if (isSyntheticSymbol)
isCandidate -- nonSyntheticSymbols ++ additionalAlternativesForSynthetic
isCandidate ++ additionalAlternativesForSynthetic
else
isCandidate -- nonSyntheticSymbols
isCandidate
case None => Set.empty
}
}
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/src/test/scala/tests/ReferenceLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,38 @@ class ReferenceLspSuite extends BaseRangesSuite("reference") {
|""".stripMargin,
)

check(
"companion-object",
"""|/Main.scala
|case class <<Rend@@erTile>>(
| lowBits: Int,
| highBits: Int,
| // 2 bits
| attrBits: Int
|)
|
|object <<RenderTile>>{
| val zero = <<RenderTile>>(0, 0, 0)
|}
|""".stripMargin,
)

check(
"companion-class",
"""|/Main.scala
|case class <<RenderTile>>(
| lowBits: Int,
| highBits: Int,
| // 2 bits
| attrBits: Int
|)
|
|object <<Rende@@rTile>>{
| val zero = <<RenderTile>>(0, 0, 0)
|}
|""".stripMargin,
)

test("synthetic") {
cleanWorkspace()
for {
Expand Down

0 comments on commit e3812b3

Please sign in to comment.