-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Updated diagnostic printing style #30027
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
I've only tested this on macOS so far, let's get some preliminary results on other platforms. @swift-ci please test |
} | ||
|
||
// Describe a fix-it out-of-line. | ||
static void describeFixIt(SourceManager &SM, DiagnosticInfo::FixIt fixIt, |
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 is nice!
@swift-ci please test Windows platform |
1 similar comment
@swift-ci please test Windows platform |
This is a big change, so here's a rough overview of how everything fits together.
Printing each message is a two stage process. First, as the consumer receives diags and associated notes, it builds up an |
Thank you, @owenv! I'll try to take a look asap |
if (shouldDelete != Deleted) { | ||
Out.resetColor(); | ||
if (shouldDelete) { | ||
Out.changeColor(ColoredStream::Colors::RED); |
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.
For accessibility reasons, proposed insertions and deletions shouldn't be distinguished (at least solely) by the colors red and green. This is because red-green colorblindness is the most common form of the condition.
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.
Thanks for bringing this up. I've started to address this by adding a textual description of the fix-it to the end of all messages with fix-its, instead of just notes (e.g. error: argument 'a' must precede argument 'b' [remove ', a: 2' and insert 'a: 2, ']
).
I think there's more that can and should be done here, but I haven't come up with a design I'm happy with yet, so I'll leave this unresolved for now.
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.
/*background*/ false); | ||
++i; | ||
} else { | ||
Out << fixIt.Text[i]; |
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.
It may be helpful to have some other way of indicating that a certain span of text is a proposed fix-it insertion. At present, my first glance impression was that there was some syntax coloring going on, which doesn't immediately make it clear that the text isn't already in the source code.
This new style directly annotates small snippets of code with error messages, highlights and fix-its. It also uses color more effectively to highlight important segments.
…ind separate frontend flags
…cription of fix its
c52c41b
to
3382965
Compare
…ectly when rendering highlights and messages
…eletions in the highlight line
…n-ASCII anchored messages
Kicking off another round of tests to verify the recent changes @swift-ci please smoke test |
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.
Looks great! Thank you, @owenv! You can also split some of the changes, e.g. renaming of the language option for educational notes, into a separate PR so it could be merged sooner.
@xedin Thanks for looking over this! In that case, should I wait to merge this PR? Since this is frontend-only right now, I was planning on improving it on master until I'm ready to add driver support or make it public. |
Since this is under a flag and doesn't affect anything else I think you can go ahead and merge it. |
@xedin sounds good, I'll just make sure this is still passing tests on all three platforms then. |
@swift-ci please test |
@swift-ci please test Windows platform |
This PR adds a new diag printing style behind the
-enable-experimental-diagnostic-formatting
frontend flag. A few notes:-no-color-diagnostics
, but mostly just for testing purposes. When this is supported in the driver, I think it would be better just to fallback to the LLVM style if color is unsupported or disabled.The code/tests aren't the easiest to parse, so here's an example of a program:
Which produces diags that look like this:


