Skip to content

Commit 1762b0e

Browse files
committed
Fix syntax highlighting of soft keywords
1 parent 4aad689 commit 1762b0e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ object SyntaxHighlighting {
5353
val start = scanner.offset
5454
val token = scanner.token
5555
val name = scanner.name
56+
val isSoftModifier = scanner.isSoftModifierInModifierPosition
5657
scanner.nextToken()
5758
val end = scanner.lastOffset
5859

@@ -67,10 +68,7 @@ object SyntaxHighlighting {
6768
// we don't highlight it, hence the `-1`
6869
highlightRange(start, end - 1, LiteralColor)
6970

70-
case _ if alphaKeywords.contains(token) =>
71-
highlightRange(start, end, KeywordColor)
72-
73-
case IDENTIFIER if scanner.isSoftModifierInModifierPosition =>
71+
case _ if alphaKeywords.contains(token) || isSoftModifier =>
7472
highlightRange(start, end, KeywordColor)
7573

7674
case IDENTIFIER if name == nme.??? =>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,8 @@ class SyntaxHighlightingTests extends DottyTest {
125125
test("inline def foo = 1", "<K|inline> <K|def> <V|foo> = <L|1>")
126126
test("@inline def foo = 1", "<T|@inline> <K|def> <V|foo> = <L|1>")
127127
test("class inline", "<K|class> <T|inline>")
128+
test("val inline = 2", "<K|val> <V|inline> = <L|2>")
129+
test("def inline = 2", "<K|def> <V|inline> = <L|2>")
130+
test("def foo(inline: Int) = 2", "<K|def> <V|foo>(<V|inline>: <T|Int>) = <L|2>")
128131
}
129132
}

0 commit comments

Comments
 (0)