Skip to content

Commit

Permalink
improvement: Update mtags to 1.4.1 and backport remaining changes (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik authored Nov 19, 2024
2 parents 8dd7187 + 366eb01 commit cc4a324
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dotty.tools.pc.printer
import scala.collection.mutable
import scala.meta.internal.jdk.CollectionConverters.*
import scala.meta.internal.metals.ReportContext
import scala.meta.internal.mtags.KeywordWrapper
import scala.meta.pc.SymbolDocumentation
import scala.meta.pc.SymbolSearch

Expand Down Expand Up @@ -64,6 +65,11 @@ class ShortenedTypePrinter(

private val foundRenames = collection.mutable.LinkedHashMap.empty[Symbol, String]

override def nameString(name: Name): String =
val nameStr = super.nameString(name)
if (nameStr.nonEmpty) KeywordWrapper.Scala3Keywords.backtickWrap(nameStr)
else nameStr

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ class CompletionKeywordSuite extends BaseCompletionSuite:
|given
|extension
|type
|opaque type
|class
|enum
|case class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ class CompletionSuite extends BaseCompletionSuite:
| scala@@
|}
|""".stripMargin,
"""|scala <root>
"""|scala `<root>`
|""".stripMargin
)

Expand Down Expand Up @@ -1726,8 +1726,8 @@ class CompletionSuite extends BaseCompletionSuite:
check(
"""|import @@
|""".stripMargin,
"""|java <root>
|javax <root>
"""|java `<root>`
|javax `<root>`
|""".stripMargin,
filter = _.startsWith("java")
)
Expand All @@ -1745,8 +1745,8 @@ class CompletionSuite extends BaseCompletionSuite:
check(
"""|export @@
|""".stripMargin,
"""|java <root>
|javax <root>
"""|java `<root>`
|javax `<root>`
|""".stripMargin,
filter = _.startsWith("java")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,78 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite:
|""".stripMargin
)

@Test def `backticks-4` =
checkEdit(
"""|case class `Foo-Foo`(i: Int)
|object O{
| val <<foo>> = `Foo-Foo`(1)
|}""".stripMargin,
"""|case class `Foo-Foo`(i: Int)
|object O{
| val foo: `Foo-Foo` = `Foo-Foo`(1)
|}
|""".stripMargin
)


@Test def `backticks-5` =
checkEdit(
"""|object A{
| case class `Foo-Foo`(i: Int)
|}
|object O{
| val <<foo>> = A.`Foo-Foo`(1)
|}""".stripMargin,
"""|import A.`Foo-Foo`
|object A{
| case class `Foo-Foo`(i: Int)
|}
|object O{
| val foo: `Foo-Foo` = A.`Foo-Foo`(1)
|}
|""".stripMargin
)


@Test def `backticks-6` =
checkEdit(
"""|object A{
| case class `Foo-Foo`[A](i: A)
|}
|object O{
| val <<foo>> = A.`Foo-Foo`(1)
|}""".stripMargin,
"""|import A.`Foo-Foo`
|object A{
| case class `Foo-Foo`[A](i: A)
|}
|object O{
| val foo: `Foo-Foo`[Int] = A.`Foo-Foo`(1)
|}
|""".stripMargin
)

@Test def `backticks-7` =
checkEdit(
"""|object A{
| class `x-x`
| case class Foo[A](i: A)
|}
|object O{
| val <<foo>> = A.Foo(new A.`x-x`)
|}""".stripMargin,
"""|import A.Foo
|import A.`x-x`
|object A{
| class `x-x`
| case class Foo[A](i: A)
|}
|object O{
| val foo: Foo[`x-x`] = A.Foo(new A.`x-x`)
|}
|""".stripMargin
)

@Test def `literal-types1` =
checkEdit(
"""|object O {
Expand Down
4 changes: 2 additions & 2 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ object Build {
),

// This is used to download nightly builds of the Scala 2 library in `scala2-library-bootstrapped`
resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/",
resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
)

lazy val disableDocSetting =
Expand Down Expand Up @@ -1455,7 +1455,7 @@ object Build {
BuildInfoPlugin.buildInfoDefaultSettings

lazy val presentationCompilerSettings = {
val mtagsVersion = "1.3.5"
val mtagsVersion = "1.4.1"
Seq(
libraryDependencies ++= Seq(
"org.lz4" % "lz4-java" % "1.8.0",
Expand Down

0 comments on commit cc4a324

Please sign in to comment.