File tree Expand file tree Collapse file tree 5 files changed +85
-6
lines changed
src/main/dotty/tools/pc/printer
test/dotty/tools/pc/tests Expand file tree Collapse file tree 5 files changed +85
-6
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package dotty.tools.pc.printer
33import scala .collection .mutable
44import scala .meta .internal .jdk .CollectionConverters .*
55import scala .meta .internal .metals .ReportContext
6+ import scala .meta .internal .mtags .KeywordWrapper
67import scala .meta .pc .SymbolDocumentation
78import scala .meta .pc .SymbolSearch
89
@@ -64,6 +65,11 @@ class ShortenedTypePrinter(
6465
6566 private val foundRenames = collection.mutable.LinkedHashMap .empty[Symbol , String ]
6667
68+ override def nameString (name : Name ): String =
69+ val nameStr = super .nameString(name)
70+ if (nameStr.nonEmpty) KeywordWrapper .Scala3Keywords .backtickWrap(nameStr)
71+ else nameStr
72+
6773 def getUsedRenames : Map [Symbol , String ] =
6874 foundRenames.toMap.filter { case (k, v) => k.showName != v }
6975
Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ class CompletionKeywordSuite extends BaseCompletionSuite:
433433 |given
434434 |extension
435435 |type
436+ |opaque type
436437 |class
437438 |enum
438439 |case class
Original file line number Diff line number Diff line change @@ -1136,7 +1136,7 @@ class CompletionSuite extends BaseCompletionSuite:
11361136 | scala@@
11371137 |}
11381138 | """ .stripMargin,
1139- """ |scala <root>
1139+ """ |scala ` <root>`
11401140 |""" .stripMargin
11411141 )
11421142
@@ -1726,8 +1726,8 @@ class CompletionSuite extends BaseCompletionSuite:
17261726 check(
17271727 """ |import @@
17281728 |""" .stripMargin,
1729- """ |java <root>
1730- |javax <root>
1729+ """ |java ` <root>`
1730+ |javax ` <root>`
17311731 |""" .stripMargin,
17321732 filter = _.startsWith(" java" )
17331733 )
@@ -1745,8 +1745,8 @@ class CompletionSuite extends BaseCompletionSuite:
17451745 check(
17461746 """ |export @@
17471747 |""" .stripMargin,
1748- """ |java <root>
1749- |javax <root>
1748+ """ |java ` <root>`
1749+ |javax ` <root>`
17501750 |""" .stripMargin,
17511751 filter = _.startsWith(" java" )
17521752 )
Original file line number Diff line number Diff line change @@ -597,6 +597,78 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite:
597597 |""" .stripMargin
598598 )
599599
600+ @ Test def `backticks-4` =
601+ checkEdit(
602+ """ |case class `Foo-Foo`(i: Int)
603+ |object O{
604+ | val <<foo>> = `Foo-Foo`(1)
605+ |}""" .stripMargin,
606+ """ |case class `Foo-Foo`(i: Int)
607+ |object O{
608+ | val foo: `Foo-Foo` = `Foo-Foo`(1)
609+ |}
610+ |""" .stripMargin
611+ )
612+
613+
614+ @ Test def `backticks-5` =
615+ checkEdit(
616+ """ |object A{
617+ | case class `Foo-Foo`(i: Int)
618+ |}
619+ |object O{
620+ | val <<foo>> = A.`Foo-Foo`(1)
621+ |}""" .stripMargin,
622+ """ |import A.`Foo-Foo`
623+ |object A{
624+ | case class `Foo-Foo`(i: Int)
625+ |}
626+ |object O{
627+ | val foo: `Foo-Foo` = A.`Foo-Foo`(1)
628+ |}
629+ |""" .stripMargin
630+ )
631+
632+
633+ @ Test def `backticks-6` =
634+ checkEdit(
635+ """ |object A{
636+ | case class `Foo-Foo`[A](i: A)
637+ |}
638+ |object O{
639+ | val <<foo>> = A.`Foo-Foo`(1)
640+ |}""" .stripMargin,
641+ """ |import A.`Foo-Foo`
642+ |object A{
643+ | case class `Foo-Foo`[A](i: A)
644+ |}
645+ |object O{
646+ | val foo: `Foo-Foo`[Int] = A.`Foo-Foo`(1)
647+ |}
648+ |""" .stripMargin
649+ )
650+
651+ @ Test def `backticks-7` =
652+ checkEdit(
653+ """ |object A{
654+ | class `x-x`
655+ | case class Foo[A](i: A)
656+ |}
657+ |object O{
658+ | val <<foo>> = A.Foo(new A.`x-x`)
659+ |}""" .stripMargin,
660+ """ |import A.Foo
661+ |import A.`x-x`
662+ |object A{
663+ | class `x-x`
664+ | case class Foo[A](i: A)
665+ |}
666+ |object O{
667+ | val foo: Foo[`x-x`] = A.Foo(new A.`x-x`)
668+ |}
669+ |""" .stripMargin
670+ )
671+
600672 @ Test def `literal-types1` =
601673 checkEdit(
602674 """ |object O {
Original file line number Diff line number Diff line change @@ -1434,7 +1434,7 @@ object Build {
14341434 BuildInfoPlugin .buildInfoDefaultSettings
14351435
14361436 lazy val presentationCompilerSettings = {
1437- val mtagsVersion = " 1.3.5 "
1437+ val mtagsVersion = " 1.4.0 "
14381438 Seq (
14391439 libraryDependencies ++= Seq (
14401440 " org.lz4" % " lz4-java" % " 1.8.0" ,
You can’t perform that action at this time.
0 commit comments