Skip to content

Ignore ending $ when looking at end marker names #22798

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

Merged
merged 4 commits into from
Mar 19, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,14 @@ class PcRenameSuite extends BasePcRenameSuite:
|""".stripMargin,
wrap = false
)

@Test def `local-object-with-end-rename` =
check(
"""|def bar =
| object <<fo@@o>>:
| def aaa = ???
| end <<foo>>
| 1
|""".stripMargin,
wrap = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite:
| } = new:
| def <<scalameta>>/*method,definition*/ = "4.0"
| <<V>>/*variable,readonly*/.<<scalameta>>/*method*/
|end StructuralTypes
|end <<StructuralTypes>>/*class,definition*/
|""".stripMargin
)

Expand Down Expand Up @@ -435,4 +435,13 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite:
| <<usage>>/*method*/[<<Option>>/*class,abstract*/[<<Int>>/*class,abstract*/]](<<_>>/*parameter,readonly*/.<<typeArg>>/*method*/[<<Some>>/*class*/[<<Int>>/*class,abstract*/]].<<value>>/*variable,readonly*/.<<inferredTypeArg>>/*method*/[<<String>>/*type*/]("str"))
|}
|""".stripMargin
)
)

@Test def `local-object-with-end-i7246` =
check(
"""|def <<bar>>/*method,definition*/ =
| object <<foo>>/*class*/:
| def <<aaa>>/*method,definition*/ = <<???>>/*method*/
| end <<foo>>/*class,definition*/
|""".stripMargin
)