Skip to content

Commit

Permalink
Merge pull request #14518 from ckipp01/lambdaTypeTreeHighlighting
Browse files Browse the repository at this point in the history
fix(#11202): special case type trees in syntax highlighting
  • Loading branch information
smarter authored Feb 19, 2022
2 parents 72acaef + b1e4267 commit 4f3d767
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 4f3d767

Please sign in to comment.