Skip to content

Commit 9348706

Browse files
committed
added testcases, fixed strintliterals with symbols
1 parent a34ff32 commit 9348706

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ object SyntaxHighlighting {
7575
val beforeUnderscore = remaining.takeWhile(c =>
7676
c.isUpper || c.isLower || c.isDigit
7777
)
78-
val suffix = remaining.drop(beforeUnderscore.length) match {
79-
case '_' +: afterUnderscore => '_' +: afterUnderscore.drop(1).takeWhile(opChar)
80-
case _ => Seq.empty
78+
val suffix = if(remaining.drop(beforeUnderscore.length).startsWith("_")) {
79+
'_' +: remaining.drop(beforeUnderscore.length+1).takeWhile(opChar)
80+
} else {
81+
Seq.empty
8182
}
8283
Some(((n +: beforeUnderscore) ++ suffix).mkString)
8384
} else {

compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ class SyntaxHighlightingTests {
5353
test("s\"Hello\"", "s<L|\"Hello\">")
5454
test("s\"Hello $name\"", "s<L|\"Hello <V|$name<L|\">")
5555
test("raw\"Hello\"", "raw<L|\"Hello\">")
56+
test("raw\"\"\"Hello\"\"\"", "raw<L|\"\"\"Hello\"\"\">")
57+
test("sym_+\"\"\"Hello\"\"\"", "sym_+<L|\"\"\"Hello\"\"\">")
58+
test("Big\"Hello\"", "Big<L|\"Hello\">")
59+
test("N3\"Hello\"", "N3<L|\"Hello\">")
60+
test("n3a\"Hello\"", "n3a<L|\"Hello\">")
61+
test("Big_*\"Hello\"", "Big_*<L|\"Hello\">")
5662
}
5763

5864
@Test

0 commit comments

Comments
 (0)