diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index e8ee91190415..447021e491f6 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -538,7 +538,7 @@ class PlainPrinter(_ctx: Context) extends Printer { def plain = this protected def keywordStr(text: String): String = coloredStr(text, SyntaxHighlighting.KeywordColor) - protected def valDefStr(text: String): String = coloredStr(text, SyntaxHighlighting.ValDefColor) + protected def valDefText(text: Text): Text = coloredText(text, SyntaxHighlighting.ValDefColor) protected def typeText(text: Text): Text = coloredText(text, SyntaxHighlighting.TypeColor) protected def literalText(text: Text): Text = coloredText(text, SyntaxHighlighting.LiteralColor) protected def stringText(text: Text): Text = coloredText(text, SyntaxHighlighting.StringColor) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index d0d6656a1f56..3088e701959a 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -471,13 +471,13 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { ("(" ~ toTextGlobal(implicits, ", ") ~ ")" provided implicits.nonEmpty) case tree @ ValDef(name, tpt, _) => dclTextOr { - modText(tree.mods, valDefStr(if (tree.mods is Mutable) "var" else "val")) ~~ - nameIdText(tree) ~ optAscription(tpt) ~ + modText(tree.mods, keywordStr(if (tree.mods is Mutable) "var" else "val")) ~~ + valDefText(nameIdText(tree)) ~ optAscription(tpt) ~ withEnclosingDef(tree) { optText(tree.rhs)(" = " ~ _) } } case tree @ DefDef(name, tparams, vparamss, tpt, _) => dclTextOr { - val prefix = modText(tree.mods, valDefStr("def")) ~~ nameIdText(tree) + val prefix = modText(tree.mods, keywordStr("def")) ~~ valDefText(nameIdText(tree)) withEnclosingDef(tree) { addVparamssText(prefix ~ tparamsText(tparams), vparamss) ~ optAscription(tpt) ~ optText(tree.rhs)(" = " ~ _) @@ -590,7 +590,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { t ~ cxBoundToText(cxb) } case PatDef(mods, pats, tpt, rhs) => - modText(mods, valDefStr("val")) ~~ toText(pats, ", ") ~ optAscription(tpt) ~ + modText(mods, keywordStr("val")) ~~ toText(pats, ", ") ~ optAscription(tpt) ~ optText(rhs)(" = " ~ _) case ParsedTry(expr, handler, finalizer) => changePrec(GlobalPrec) {