Skip to content

Commit 2b67780

Browse files
committed
Highlight inline as a "soft" keyword
1 parent a8dc7e8 commit 2b67780

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,22 @@ object SyntaxHighlighting {
6262
token match {
6363
case _ if literalTokens.contains(token) =>
6464
highlightRange(start, end, LiteralColor)
65+
6566
case STRINGPART =>
6667
// String interpolation parts include `$` but
6768
// we don't highlight it, hence the `-1`
6869
highlightRange(start, end - 1, LiteralColor)
70+
6971
case _ if alphaKeywords.contains(token) =>
7072
highlightRange(start, end, KeywordColor)
73+
74+
case IDENTIFIER if name == nme.INLINEkw =>
75+
// `inline` is a "soft" keyword
76+
highlightRange(start, end, KeywordColor)
77+
7178
case IDENTIFIER if name == nme.??? =>
7279
highlightRange(start, end, Console.RED_B)
80+
7381
case _ =>
7482
}
7583
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,11 @@ class SyntaxHighlightingTests extends DottyTest {
120120
test("val foo @ Foo(x) = bar", ???)
121121
test("x match { case Foo | Bar => 1 }", ???)
122122
}
123+
124+
@Test
125+
def softKeywords = {
126+
test("inline def foo = 1", "<K|inline> <K|def> <V|foo> = <L|1>")
127+
test("@inline def foo = 1", "<T|@inline> <K|def> <V|foo> = <L|1>")
128+
test("class inline", "<K|class> <T|inline>")
129+
}
123130
}

0 commit comments

Comments
 (0)