Skip to content

Commit feeb420

Browse files
committed
Address review comments
1 parent 2b67780 commit feeb420

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,23 @@ object SyntaxHighlighting {
9191
name == nme.ERROR || name == nme.CONSTRUCTOR
9292
}
9393

94+
def highlightAnnotations(tree: MemberDef): Unit =
95+
for (annotation <- tree.rawMods.annotations)
96+
highlightPosition(annotation.pos, AnnotationColor)
97+
9498
def highlight(trees: List[Tree])(implicit ctx: Context): Unit =
9599
trees.foreach(traverse)
96100

97101
def traverse(tree: Tree)(implicit ctx: Context): Unit = {
98102
tree match {
99103
case tree: NameTree if ignored(tree) =>
100104
()
101-
case tree: MemberDef /* ValOrDefDef | ModuleDef | TypeDef */ =>
102-
for (annotation <- tree.rawMods.annotations)
103-
highlightPosition(annotation.pos, AnnotationColor)
104-
val color = if (tree.isInstanceOf[ValOrDefDef]) ValDefColor else TypeColor
105-
highlightPosition(tree.namePos, color)
105+
case tree: ValOrDefDef =>
106+
highlightAnnotations(tree)
107+
highlightPosition(tree.namePos, ValDefColor)
108+
case tree: MemberDef /* ModuleDef | TypeDef */ =>
109+
highlightAnnotations(tree)
110+
highlightPosition(tree.namePos, TypeColor)
106111
case tree: Ident if tree.isType =>
107112
highlightPosition(tree.pos, TypeColor)
108113
case _: TypTree =>

0 commit comments

Comments
 (0)