Skip to content

Commit aecb280

Browse files
committed
feat: special case AppliedTypeTree in syntax highlighting
This ensure that instead of the entire `List[Int]` all being one color the `List` is the type color and the `Int` is while the brackets remain with no color.
1 parent 23a9c39 commit aecb280

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ object SyntaxHighlighting {
111111
// the braces
112112
case tree: LambdaTypeTree =>
113113
tree.tparams.foreach(tparam => highlightPosition(tparam.span, TypeColor))
114+
// Also special case these to ensure that each type and arg is
115+
// highlighted without the braces.
116+
case tree: AppliedTypeTree =>
117+
highlightPosition(tree.tpt.span, TypeColor)
118+
tree.args.foreach(arg => highlightPosition(arg.span, TypeColor))
114119
case tree: MemberDef /* ModuleDef | TypeDef */ =>
115120
highlightAnnotations(tree)
116121
highlightPosition(tree.nameSpan, TypeColor)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SyntaxHighlightingTests extends DottyTest {
4444
test("type A = String | Int", "<K|type> <T|A> = <T|String> <T||> <T|Int>")
4545
test("type B = String & Int", "<K|type> <T|B> = <T|String> <T|&> <T|Int>")
4646
test("type Id[A] = A", "<K|type> <T|Id>[<T|A>] = <T|A>")
47-
test("type Foo = [X] =>> List[X]", "<K|type> <T|Foo> = [<T|X>] =>> <T|List[X]>")
47+
test("type Foo = [X] =>> List[X]", "<K|type> <T|Foo> = [<T|X>] =>> <T|List>[<T|X>]")
4848
}
4949

5050
@Test

0 commit comments

Comments
 (0)