File tree 5 files changed +86
-6
lines changed
src/main/dotty/tools/pc/printer
test/dotty/tools/pc/tests
5 files changed +86
-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 @@ -433,6 +433,7 @@ class CompletionKeywordSuite extends BaseCompletionSuite:
433
433
|given
434
434
|extension
435
435
|type
436
+ |opaque type
436
437
|class
437
438
|enum
438
439
|case class
Original file line number Diff line number Diff line change @@ -1136,7 +1136,7 @@ class CompletionSuite extends BaseCompletionSuite:
1136
1136
| scala@@
1137
1137
|}
1138
1138
| """ .stripMargin,
1139
- """ |scala <root>
1139
+ """ |scala ` <root>`
1140
1140
|""" .stripMargin
1141
1141
)
1142
1142
@@ -1726,8 +1726,8 @@ class CompletionSuite extends BaseCompletionSuite:
1726
1726
check(
1727
1727
""" |import @@
1728
1728
|""" .stripMargin,
1729
- """ |java <root>
1730
- |javax <root>
1729
+ """ |java ` <root>`
1730
+ |javax ` <root>`
1731
1731
|""" .stripMargin,
1732
1732
filter = _.startsWith(" java" )
1733
1733
)
@@ -1745,8 +1745,8 @@ class CompletionSuite extends BaseCompletionSuite:
1745
1745
check(
1746
1746
""" |export @@
1747
1747
|""" .stripMargin,
1748
- """ |java <root>
1749
- |javax <root>
1748
+ """ |java ` <root>`
1749
+ |javax ` <root>`
1750
1750
|""" .stripMargin,
1751
1751
filter = _.startsWith(" java" )
1752
1752
)
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 @@ -373,6 +373,7 @@ object Build {
373
373
374
374
// This is used to download nightly builds of the Scala 2 library in `scala2-library-bootstrapped`
375
375
resolvers += " scala-integration" at " https://scala-ci.typesafe.com/artifactory/scala-integration/" ,
376
+ resolvers ++= Resolver .sonatypeOssRepos(" snapshot" ),
376
377
)
377
378
378
379
lazy val disableDocSetting =
@@ -1434,7 +1435,7 @@ object Build {
1434
1435
BuildInfoPlugin .buildInfoDefaultSettings
1435
1436
1436
1437
lazy val presentationCompilerSettings = {
1437
- val mtagsVersion = " 1.3.5 "
1438
+ val mtagsVersion = " 1.4.0+13-e3812b3f-SNAPSHOT "
1438
1439
Seq (
1439
1440
libraryDependencies ++= Seq (
1440
1441
" org.lz4" % " lz4-java" % " 1.8.0" ,
You can’t perform that action at this time.
0 commit comments