-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add basic support for colored printers #3526
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
Conversation
cd36bdc
to
9295619
Compare
9295619
to
2e0ea4c
Compare
@@ -346,29 +346,31 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { | |||
case id: Trees.SearchFailureIdent[_] => | |||
tree.typeOpt match { | |||
case reason: Implicits.SearchFailureType => | |||
toText(id.name) ~ "implicitly[" ~ toText(reason.expectedType) ~ "]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A [
disappeared, not sure if it's intentional
case CaseDef(pat, guard, body) => | ||
"case " ~ inPattern(toText(pat)) ~ optText(guard)(" if " ~ _) ~ " => " ~ caseBlockText(body) | ||
keywordStr("case ") ~ inPattern(toText(pat)) ~ optText(guard)(" if " ~ _) ~ " => " ~ caseBlockText(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this if
is not highlighted
@@ -17,6 +17,7 @@ object SyntaxHighlighting { | |||
val KeywordColor = Console.YELLOW | |||
val ValDefColor = Console.CYAN | |||
val LiteralColor = Console.RED | |||
val StringColor = Console.GREEN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space ^^'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nooooo. Shame on me.
!Character.isAlphabetic(c) && !Character.isDigit(c) && | ||
!Character.isMirrored(c) && !Character.isWhitespace(c) | ||
val (token, rest) = | ||
if (head == '\u001b') { // ansi color token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val ansiColorToken = '\u001b'
(also to be used below)
@@ -69,25 +65,21 @@ object DiffUtil { | |||
} | |||
|
|||
val expectedDiff = | |||
if (expected eq EOF) ANSI_EOF + expected + ANSI_DEFAULT | |||
if (expected eq EOF) eof() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are printing less here (expected
is not shown), is it intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string for expected
is in this case "EOF"
. EOF
is a string that has "EOF"
but is also meant to be unique.
With this change, both
dotc -decompile
anddotc -Xprint
get colored outputs.