Skip to content
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

bugfix: Inconsistent highlight on class constructor #5909

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mtags/src/main/scala-2/scala/meta/internal/pc/PcCollector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,20 @@ abstract class PcCollector[T](
info.member(sym.getterName),
info.member(sym.setterName),
info.member(sym.localName)
) ++ sym.allOverriddenSymbols.toSet
) ++ constructorParam(sym) ++ sym.allOverriddenSymbols.toSet
} else Set(sym)
all.filter(s => s != NoSymbol && !s.isError)
}

private def constructorParam(
symbol: Symbol
): Set[Symbol] = {
if (symbol.owner.isClass) {
val info = symbol.owner.info.member(nme.CONSTRUCTOR).info
info.paramss.flatten.find(_.name == symbol.name).toSet
} else Set.empty
}

private lazy val namedArgCache = {
val parsedTree = parseTree(unit.source)
parsedTree.collect { case arg @ AssignOrNamedArg(_, rhs) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,4 +1020,28 @@ class DocumentHighlightSuite extends BaseDocumentHighlightSuite {
|}""".stripMargin
)

check(
"extends",
"""
|abstract class Base(foo: Int, bar: Int)
|
|class Test(<<foo>>: Int, bar: Int) extends Base(<<f@@oo>>, bar) {
| def transform = <<foo>> + bar
| val description = s"$<<foo>> & $bar"
|}
|""".stripMargin
)

check(
"extends1",
"""
|abstract class Base(foo: Int, bar: Int)
|
|class Test(<<foo>>: Int, bar: Int) extends Base(<<foo>>, bar) {
| def transform = <<fo@@o>> + bar
| val description = s"$<<foo>> & $bar"
|}
|""".stripMargin
)

}
Loading