Skip to content

Commit 30ce9a5

Browse files
authored
Merge pull request #14555 from ireina7/marker-color-same-as-def-name
improvement(repl): end marker now has the same color as its definition in repl (fix #14535)
2 parents 83fb072 + 1081d62 commit 30ce9a5

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ object SyntaxHighlighting {
109109
case tree: ValOrDefDef =>
110110
highlightAnnotations(tree)
111111
highlightPosition(tree.nameSpan, ValDefColor)
112+
highlightPosition(tree.endSpan, ValDefColor)
112113
case tree: MemberDef /* ModuleDef | TypeDef */ =>
113114
highlightAnnotations(tree)
114115
highlightPosition(tree.nameSpan, TypeColor)
116+
highlightPosition(tree.endSpan, TypeColor)
115117
case tree: Ident if tree.isType =>
116118
highlightPosition(tree.span, TypeColor)
117119
case _: TypeTree =>

compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,41 @@ class SyntaxHighlightingTests extends DottyTest {
140140
test("val inline = 2", "<K|val> <V|inline> = <L|2>")
141141
test("def inline = 2", "<K|def> <V|inline> = <L|2>")
142142
test("def foo(inline: Int) = 2", "<K|def> <V|foo>(<V|inline>: <T|Int>) = <L|2>")
143+
test(
144+
"""enum Foo:
145+
| case foo
146+
|end Foo""".stripMargin,
147+
"""<K|enum> <T|Foo>:
148+
| <K|case> <T|foo>
149+
|<K|end> <T|Foo>""".stripMargin
150+
)
151+
test(
152+
"""class Foo:
153+
|end Foo""".stripMargin,
154+
"""<K|class> <T|Foo>:
155+
|<K|end> <T|Foo>""".stripMargin
156+
)
157+
test(
158+
"""object Foo:
159+
|end Foo""".stripMargin,
160+
"""<K|object> <T|Foo>:
161+
|<K|end> <T|Foo>""".stripMargin
162+
)
163+
test(
164+
"""def foo =
165+
| ()
166+
|end foo""".stripMargin,
167+
"""<K|def> <V|foo> =
168+
| ()
169+
|<K|end> <V|foo>""".stripMargin
170+
)
171+
test(
172+
"""val foo =
173+
| ()
174+
|end foo""".stripMargin,
175+
"""<K|val> <V|foo> =
176+
| ()
177+
|<K|end> <V|foo>""".stripMargin
178+
)
143179
}
144180
}

0 commit comments

Comments
 (0)