File tree 5 files changed +88
-6
lines changed
src/main/dotty/tools/pc/printer
test/dotty/tools/pc/tests
5 files changed +88
-6
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package dotty.tools.pc.printer
3
3
import scala .collection .mutable
4
4
import scala .meta .internal .jdk .CollectionConverters .*
5
5
import scala .meta .internal .metals .ReportContext
6
+ import scala .meta .internal .mtags .KeywordWrapper
6
7
import scala .meta .pc .SymbolDocumentation
7
8
import scala .meta .pc .SymbolSearch
8
9
@@ -64,6 +65,11 @@ class ShortenedTypePrinter(
64
65
65
66
private val foundRenames = collection.mutable.LinkedHashMap .empty[Symbol , String ]
66
67
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
+
67
73
def getUsedRenames : Map [Symbol , String ] =
68
74
foundRenames.toMap.filter { case (k, v) => k.showName != v }
69
75
Original file line number Diff line number Diff line change @@ -437,6 +437,7 @@ class CompletionKeywordSuite extends BaseCompletionSuite:
437
437
|given
438
438
|extension
439
439
|type
440
+ |opaque type
440
441
|class
441
442
|enum
442
443
|case class
Original file line number Diff line number Diff line change @@ -1135,7 +1135,7 @@ class CompletionSuite extends BaseCompletionSuite:
1135
1135
| scala@@
1136
1136
|}
1137
1137
| """ .stripMargin,
1138
- """ |scala <root>
1138
+ """ |scala ` <root>`
1139
1139
|""" .stripMargin
1140
1140
)
1141
1141
@@ -1725,8 +1725,8 @@ class CompletionSuite extends BaseCompletionSuite:
1725
1725
check(
1726
1726
""" |import @@
1727
1727
|""" .stripMargin,
1728
- """ |java <root>
1729
- |javax <root>
1728
+ """ |java ` <root>`
1729
+ |javax ` <root>`
1730
1730
|""" .stripMargin,
1731
1731
filter = _.startsWith(" java" )
1732
1732
)
@@ -1744,8 +1744,8 @@ class CompletionSuite extends BaseCompletionSuite:
1744
1744
check(
1745
1745
""" |export @@
1746
1746
|""" .stripMargin,
1747
- """ |java <root>
1748
- |javax <root>
1747
+ """ |java ` <root>`
1748
+ |javax ` <root>`
1749
1749
|""" .stripMargin,
1750
1750
filter = _.startsWith(" java" )
1751
1751
)
Original file line number Diff line number Diff line change @@ -597,6 +597,78 @@ class InsertInferredTypeSuite extends BaseCodeActionSuite:
597
597
|""" .stripMargin
598
598
)
599
599
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
+
600
672
@ Test def `literal-types1` =
601
673
checkEdit(
602
674
""" |object O {
Original file line number Diff line number Diff line change @@ -262,6 +262,9 @@ object Build {
262
262
// sbt will complain if we don't exclude them here.
263
263
Keys .scalaSource, Keys .javaSource
264
264
),
265
+
266
+ // This is used to download nightly builds of the Scala 2 library in `scala2-library-bootstrapped`
267
+ resolvers += " scala-integration" at " https://scala-ci.typesafe.com/artifactory/scala-integration/"
265
268
)
266
269
267
270
lazy val disableDocSetting =
@@ -1181,7 +1184,7 @@ object Build {
1181
1184
BuildInfoPlugin .buildInfoDefaultSettings
1182
1185
1183
1186
lazy val presentationCompilerSettings = {
1184
- val mtagsVersion = " 1.3.5 "
1187
+ val mtagsVersion = " 1.4.1 "
1185
1188
Seq (
1186
1189
libraryDependencies ++= Seq (
1187
1190
" org.lz4" % " lz4-java" % " 1.8.0" ,
You can’t perform that action at this time.
0 commit comments