Skip to content

Commit 7336594

Browse files
authored
Merge pull request #5137 from dotty-staging/new_highlighter
New highlighter based on tokens and untyped trees
2 parents c17dda0 + feeb420 commit 7336594

File tree

9 files changed

+184
-372
lines changed

9 files changed

+184
-372
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
596596
}
597597
}
598598

599+
abstract class UntypedTreeTraverser extends UntypedTreeAccumulator[Unit] {
600+
def traverse(tree: Tree)(implicit ctx: Context): Unit
601+
def apply(x: Unit, tree: Tree)(implicit ctx: Context) = traverse(tree)
602+
protected def traverseChildren(tree: Tree)(implicit ctx: Context) = foldOver((), tree)
603+
}
604+
599605
/** Fold `f` over all tree nodes, in depth-first, prefix order */
600606
class UntypedDeepFolder[X](f: (X, Tree) => X) extends UntypedTreeAccumulator[X] {
601607
def apply(x: X, tree: Tree)(implicit ctx: Context): X = foldOver(f(x, tree), tree)

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,9 @@ object Parsers {
14931493
}
14941494
}
14951495
if (in.token == LPAREN && (!inClassConstrAnnots || isLegalAnnotArg))
1496-
parArgumentExprss(Apply(fn, parArgumentExprs()))
1496+
parArgumentExprss(
1497+
atPos(startOffset(fn)) { Apply(fn, parArgumentExprs()) }
1498+
)
14971499
else fn
14981500
}
14991501

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ object Formatting {
8383
hl.show
8484
case hb: HighlightBuffer =>
8585
hb.toString
86-
case str: String if ctx.settings.color.value != "never" =>
87-
new String(SyntaxHighlighting(str).toArray)
86+
case str: String =>
87+
SyntaxHighlighting.highlight(str)
8888
case _ => super.showArg(arg)
8989
}
9090
}

0 commit comments

Comments
 (0)