Skip to content

Fix #3614: Do not allow the SyntaxFormatter to recolor code #3616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/src/dotty/tools/dotc/printing/Formatting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ object Formatting {
class SyntaxFormatter(sc: StringContext) extends StringFormatter(sc) {
override protected def showArg(arg: Any)(implicit ctx: Context): String =
arg match {
case arg: Showable if ctx.settings.color.value != "never" =>
val highlighted =
SyntaxHighlighting(wrapNonSensical(arg, super.showArg(arg)))
new String(highlighted.toArray)
case hl: Highlight =>
hl.show
case hb: HighlightBuffer =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ object messages {
val msg =
hl"""|${NoColor(msgPrefix)} type arguments for $prettyName$expectedArgString
|expected: $expectedArgString
|actual: $actualArgString""".stripMargin
|actual: ${NoColor(actualArgString)}""".stripMargin

val explanation = {
val tooManyTypeParams =
Expand Down Expand Up @@ -1418,11 +1418,11 @@ object messages {
val msg = hl"$tpe does not take type parameters"

private val ps =
if (params.size == 1) hl"a type parameter ${params.head}"
else hl"type parameters ${params.map(_.show).mkString(", ")}"
if (params.size == 1) s"a type parameter ${params.head}"
else s"type parameters ${params.map(_.show).mkString(", ")}"

val explanation =
i"""You specified $ps for ${hl"$tpe"}, which is not
i"""You specified ${NoColor(ps)} for ${hl"$tpe"}, which is not
|declared to take any.
|"""
}
Expand Down