Skip to content

Commit

Permalink
add test for rename with un-compiled build target
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Mar 26, 2024
1 parent 8db6722 commit 363234b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,8 @@ final class ReferenceProvider(
input = Input.String(text)
pos <- position.toMeta(input)
tree <- trees.get(path)
token <- tree.tokens.find { t => t.pos.encloses(pos) }
ident <- token match {
case _: Ident => Some(token)
case _ => None
ident <- tree.tokens.collectFirst {
case t: Ident if t.pos.encloses(pos) => t
}
} yield ident.text

Expand Down
28 changes: 28 additions & 0 deletions tests/unit/src/test/scala/tests/RenameLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,34 @@ class RenameLspSuite extends BaseRenameLspSuite(s"rename") {
expectedError = true,
)

renamed(
"renames-in-related-build-targets",
"""|/a/src/main/scala/a/Main.scala
|package a
|trait <<@@A>>
|/a/src/main/scala/a/B.scala
|package a
|trait B extends <<A>>
|/b/src/main/scala/b/B.scala
|package b
|import a.A
|trait B extends <<A>>
|""".stripMargin,
metalsJson = Some(
s"""|{
| "a" : {
| "scalaVersion": "${BuildInfo.scalaVersion}"
| },
| "b" : {
| "scalaVersion": "${BuildInfo.scalaVersion}",
| "dependsOn": ["a"]
| }
|}""".stripMargin
),
newName = "C",
nonOpened = Set("b/src/main/scala/b/B.scala"),
)

override protected def libraryDependencies: List[String] =
List("org.scalatest::scalatest:3.2.12", "io.circe::circe-generic:0.14.1")

Expand Down

0 comments on commit 363234b

Please sign in to comment.