Skip to content

Commit

Permalink
improvement: Update mtags to 1.4.0 and backport remaining changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Nov 1, 2024
1 parent 31e7359 commit 3899d16
Show file tree
Hide file tree
Showing 5 changed files with 87 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
5 changes: 3 additions & 2 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,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 @@ -1434,7 +1434,7 @@ object Build {
BuildInfoPlugin.buildInfoDefaultSettings

lazy val presentationCompilerSettings = {
val mtagsVersion = "1.3.5"
val mtagsVersion = "1.4.0+13-e3812b3f-SNAPSHOT"
Seq(
libraryDependencies ++= Seq(
"org.lz4" % "lz4-java" % "1.8.0",
Expand All @@ -1444,6 +1444,7 @@ object Build {
.exclude("org.eclipse.lsp4j","org.eclipse.lsp4j.jsonrpc"),
"org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.20.1",
),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
libraryDependencies += ("org.scalameta" % "mtags-shared_2.13.15" % mtagsVersion % SourceDeps),
ivyConfigurations += SourceDeps.hide,
transitiveClassifiers := Seq("sources"),
Expand Down

0 comments on commit 3899d16

Please sign in to comment.