diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index f2ac42c773eb..53e6b9472f5e 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -109,9 +109,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 4dc991a0bfe4..2f35ccb35434 100644 --- a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala +++ b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala @@ -140,5 +140,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 + ) } }