diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala index f3fd7c8738d5..d145272ba01d 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala @@ -160,7 +160,7 @@ trait PcCollector[T]: def collectEndMarker = EndMarker.getPosition(df, pos, sourceText).map: collect(EndMarker(df.symbol), _) - val annots = collectTrees(df.mods.annotations) + val annots = collectTrees(df.symbol.annotations.map(_.tree)) val traverser = new PcCollector.DeepFolderWithParent[Set[T]]( collectNamesWithParent @@ -215,8 +215,8 @@ trait PcCollector[T]: * @<>("") * def params() = ??? */ - case mdf: MemberDef if mdf.mods.annotations.nonEmpty => - val trees = collectTrees(mdf.mods.annotations) + case mdf: MemberDef if mdf.symbol.annotations.nonEmpty => + val trees = collectTrees(mdf.symbol.annotations.map(_.tree)) val traverser = new PcCollector.DeepFolderWithParent[Set[T]]( collectNamesWithParent diff --git a/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala index 9f8d82020806..aebdf7f6c04e 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala @@ -36,6 +36,24 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite: |""".stripMargin ) + @Test def `metals-6823` = + check( + s"""|package <>/*namespace*/ + | + | @<
>/*class*/ def <>/*method,definition*/(): <>/*class,abstract*/ = + | val <>/*variable,definition,readonly*/ = <>/*class*/(1, 2, 3) + | <>/*method*/(<>/*variable,readonly*/) + | + |@<
>/*class*/ def <>/*method,definition*/(): <>/*class,abstract*/ = + | val <>/*variable,definition,readonly*/ = <>/*class*/(1, 2, 3) + | <>/*method*/(<>/*variable,readonly*/) + | + |@<
>/*class*/ def <>/*method,definition*/(): <>/*class,abstract*/ = + | val <>/*variable,definition,readonly*/ = <>/*class*/(1, 2, 3) + | <>/*method*/(<>/*variable,readonly*/) + |""".stripMargin + ) + @Test def `Comment(Single-Line, Multi-Line)` = check( s"""|package <>/*namespace*/