From a50e89b1e96128cdca9d5383cc73f978d9b6d7e0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 13 Mar 2025 18:04:44 +0100 Subject: [PATCH 1/4] Add a test for renaming local objects --- .../dotty/tools/pc/tests/edit/PcRenameSuite.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala index 3226018f88d4..50806322b09e 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala @@ -534,3 +534,14 @@ class PcRenameSuite extends BasePcRenameSuite: |""".stripMargin, wrap = false ) + + @Test def `local-object-with-end-rename` = + check( + """|def bar = + | object <>: + | def aaa = ??? + | end <> + | 1 + |""".stripMargin, + wrap = false + ) From 7f10cf27fd1984e98cee87dc1d59df22b97423f9 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 13 Mar 2025 18:05:12 +0100 Subject: [PATCH 2/4] Drop ending `$` marker when looking for end marker names --- presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala index 1ebfd405768e..f3fd7c8738d5 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala @@ -315,7 +315,7 @@ object EndMarker: def getPosition(df: NamedDefTree, pos: SourcePosition, sourceText: String)( implicit ct: Context ): Option[SourcePosition] = - val name = df.name.toString() + val name = df.name.toString().stripSuffix("$") val endMarkerLine = sourceText.slice(df.span.start, df.span.end).split('\n').last val index = endMarkerLine.length() - name.length() From e2a708c868bdda0799d9736fa9ba5cc013edd075 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 13 Mar 2025 18:12:22 +0100 Subject: [PATCH 3/4] Add test for semantic highlighting `end` marker of local object --- .../tools/pc/tests/tokens/SemanticTokensSuite.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 200f74537591..b77766f76d69 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala @@ -435,4 +435,13 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite: | <>/*method*/[<