Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bugfix: Don't show unhelpful renames in hover #6173

Merged
merged 1 commit into from
Feb 29, 2024
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 @@ -119,7 +119,9 @@ trait Signatures { compiler: MetalsGlobal =>
}

def getUsedRenames: Map[Symbol, String] = lookedUpRenames.flatMap { key =>
renames.get(key).map(v => key -> v.toString())
renames.get(key).collect {
case v if key.nameString != v.toString => key -> v.toString()
}
}.toMap

def this(context: Context) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ShortenedNames(
s"type $to = ${from.showName}"
}.toList

def getUsedRenames: Map[Symbol, String] = foundRenames.toMap
def getUsedRenames(using Context): Map[Symbol, String] =
foundRenames.toMap.filter { case (k, v) => k.showName != v }

/**
* Returns a list of shortened names
Expand Down
20 changes: 20 additions & 0 deletions tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,24 @@ class HoverTermSuite extends BaseHoverSuite {
)
)

check(
"import-no-rename",
"""
|import scala.collection
|
|object O {
| <<val ab@@c = collection.Map(1 -> 2)>>
|}
|""".stripMargin,
"""|```scala
|val abc: collection.Map[Int,Int]
|```
|""".stripMargin,
compat = Map(
"3" -> """|```scala
|val abc: scala.collection.Map[Int, Int]
|```
|""".stripMargin
)
)
}
Loading