diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index 787caf81cd07..f447fe9377ff 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -107,9 +107,11 @@ object SyntaxHighlighting { case tree: ValOrDefDef => highlightAnnotations(tree) highlightPosition(tree.nameSpan, ValDefColor) + highlightPosition(tree.endSpan, ValDefColor) case tree: MemberDef /* ModuleDef | TypeDef */ => highlightAnnotations(tree) highlightPosition(tree.nameSpan, TypeColor) + highlightPosition(tree.endSpan, TypeColor) case tree: Ident if tree.isType => highlightPosition(tree.span, TypeColor) case _: TypeTree => diff --git a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala index 35355fd20828..5796668354cb 100644 --- a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala +++ b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala @@ -138,5 +138,41 @@ class SyntaxHighlightingTests extends DottyTest { test("val inline = 2", " = ") test("def inline = 2", " = ") test("def foo(inline: Int) = 2", " (: ) = ") + test( + """enum Foo: + | case foo + |end Foo""".stripMargin, + """ : + | + | """.stripMargin + ) + test( + """class Foo: + |end Foo""".stripMargin, + """ : + | """.stripMargin + ) + test( + """object Foo: + |end Foo""".stripMargin, + """ : + | """.stripMargin + ) + test( + """def foo = + | () + |end foo""".stripMargin, + """ = + | () + | """.stripMargin + ) + test( + """val foo = + | () + |end foo""".stripMargin, + """ = + | () + | """.stripMargin + ) } }