diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/PcCollector.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/PcCollector.scala index a5c647169ca..a4e33785e04 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/PcCollector.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/PcCollector.scala @@ -203,6 +203,12 @@ abstract class PcCollector[T]( val realName = arg.name.stripModuleClassSuffix.lastPart if pos.span.start > arg.span.start && pos.span.end < arg.span.point + realName.length then + val length = realName.toString.backticked.length() + val pos = arg.sourcePos.withSpan( + arg.span + .withEnd(arg.span.start + length) + .withPoint(arg.span.start) + ) appl.symbol.paramSymss.flatten.find(_.name == arg.name).map { s => // if it's a case class we need to look for parameters also if caseClassSynthetics(s.owner.name) && s.owner.is(Flags.Synthetic) @@ -214,9 +220,9 @@ abstract class PcCollector[T]( s.owner.owner.info.member(s.name).symbol, ) .filter(_ != NoSymbol), - arg.sourcePos, + pos, ) - else (Set(s), arg.sourcePos) + else (Set(s), pos) } else None end if @@ -521,6 +527,7 @@ abstract class PcCollector[T]( } val named = args.map { arg => val realName = arg.name.stripModuleClassSuffix.lastPart + val length = realName.toString.backticked.length() val sym = apply.symbol.paramSymss.flatten .find(_.name == realName) collect( @@ -528,7 +535,7 @@ abstract class PcCollector[T]( pos .withSpan( arg.span - .withEnd(arg.span.start + realName.length) + .withEnd(arg.span.start + length) .withPoint(arg.span.start) ), sym, diff --git a/tests/cross/src/test/scala/tests/highlight/DocumentHighlightSuite.scala b/tests/cross/src/test/scala/tests/highlight/DocumentHighlightSuite.scala index 3c6bc30c025..2ff93e96386 100644 --- a/tests/cross/src/test/scala/tests/highlight/DocumentHighlightSuite.scala +++ b/tests/cross/src/test/scala/tests/highlight/DocumentHighlightSuite.scala @@ -866,4 +866,15 @@ class DocumentHighlightSuite extends BaseDocumentHighlightSuite { |} |""".stripMargin, ) + + check( + "named-arg-backtick", + """|object Main { + | def foo(<<`type`>>: String): String = <<`type`>> + | val x = foo( + | <<`ty@@pe`>> = "abc" + | ) + |} + |""".stripMargin, + ) } diff --git a/tests/cross/src/test/scala/tests/pc/PcPrepareRenameSuite.scala b/tests/cross/src/test/scala/tests/pc/PcPrepareRenameSuite.scala index 8f2a138af82..ad4e2279139 100644 --- a/tests/cross/src/test/scala/tests/pc/PcPrepareRenameSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/PcPrepareRenameSuite.scala @@ -505,4 +505,17 @@ class PcPrepareRenameSuite extends BasePcRenameSuite { |""".stripMargin, ) + prepare( + "named-arg-backtick", + """|object Main { + | def m() = { + | def foo(`type`: String): String = `type` + | val x = foo( + | <<`ty@@pe`>> = "abc" + | ) + | } + |} + |""".stripMargin, + ) + } diff --git a/tests/cross/src/test/scala/tests/tokens/SemanticTokensSuite.scala b/tests/cross/src/test/scala/tests/tokens/SemanticTokensSuite.scala index d10c2494cf2..56ed4a6b987 100644 --- a/tests/cross/src/test/scala/tests/tokens/SemanticTokensSuite.scala +++ b/tests/cross/src/test/scala/tests/tokens/SemanticTokensSuite.scala @@ -321,4 +321,15 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite { ), ) + check( + "named-arg-backtick", + """|object <
>/*class*/ { + | def <>/*method,definition*/(<<`type`>>/*parameter,declaration,readonly*/: <>/*type*/): <>/*type*/ = <<`type`>>/*parameter,readonly*/ + | val <>/*variable,definition,readonly*/ = <>/*method*/( + | <<`type`>>/*parameter,readonly*/ = "abc" + | ) + |} + |""".stripMargin, + ) + }