Skip to content

fix(#11202): special case type trees in syntax highlighting #14518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object SyntaxHighlighting {
highlightPosition(tree.nameSpan, TypeColor)
case tree: Ident if tree.isType =>
highlightPosition(tree.span, TypeColor)
case _: TypTree =>
case _: TypeTree =>
highlightPosition(tree.span, TypeColor)
case _ =>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class SyntaxHighlightingTests extends DottyTest {

if (expected != highlighted) {
// assertEquals produces weird expected/found message
fail(s"expected: $expected but was: $highlighted")
fail(s"""|
|expected: $expected
|highlighted: $highlighted""".stripMargin)
}
}

Expand All @@ -41,6 +43,8 @@ class SyntaxHighlightingTests extends DottyTest {
test("type Foo = Int", "<K|type> <T|Foo> = <T|Int>")
test("type A = String | Int", "<K|type> <T|A> = <T|String> <T||> <T|Int>")
test("type B = String & Int", "<K|type> <T|B> = <T|String> <T|&> <T|Int>")
test("type Id[A] = A", "<K|type> <T|Id>[<T|A>] = <T|A>")
test("type Foo = [X] =>> List[X]", "<K|type> <T|Foo> = [<T|X>] =>> <T|List>[<T|X>]")
}

@Test
Expand Down Expand Up @@ -88,6 +92,10 @@ class SyntaxHighlightingTests extends DottyTest {
test("val foo", "<K|val> <V|foo>")
test("val foo =", "<K|val> <V|foo> =")
test("val foo = 123", "<K|val> <V|foo> = <L|123>")
test(
"val foo: List[List[Int]] = List(List(1))",
"<K|val> <V|foo>: <T|List>[<T|List>[<T|Int>]] = List(List(<L|1>))"
)

test("var", "<K|var>")
test("var foo", "<K|var> <V|foo>")
Expand All @@ -111,7 +119,7 @@ class SyntaxHighlightingTests extends DottyTest {
test("def f1(x: Int) = 123", "<K|def> <V|f1>(<V|x>: <T|Int>) = <L|123>")
test("def f2[T](x: T) = { 123 }", "<K|def> <V|f2>[<T|T>](<V|x>: <T|T>) = { <L|123> }")

test("def f3[T[_", "<K|def> <V|f3>[<T|T>[<T|_>")
test("def f3[T[_", "<K|def> <V|f3>[<T|T>[_")
}

@Test
Expand Down