Skip to content
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

improvement: Update mtags to 1.4.0 and backport remaining changes #21859

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -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
Loading