From d9c666f4d3479497dd0bc9a4939484a431345159 Mon Sep 17 00:00:00 2001 From: ireina7 Date: Thu, 24 Feb 2022 18:39:49 +0800 Subject: [PATCH 1/2] end marker now has same color as definition in repl --- compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala | 2 ++ 1 file changed, 2 insertions(+) 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 => From 1081d6294faa4b6a53111f69874c8d39274c8018 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Mon, 14 Mar 2022 12:23:00 +0100 Subject: [PATCH 2/2] add test for syntax highlight end --- .../printing/SyntaxHighlightingTests.scala | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) 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 + ) } }