-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics][NFCI] Introduce Structured fix-its #26612
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
13e6de8
to
dd3d2cf
Compare
Rebased and moved some of the examples over to CSDiagnostics now that those diags have been ported over 🎉 |
Hi @xedin / @jrose-apple , just wanted to bump this. Totally understand if this change is undesirable, but I have had some success leveraging it to fix type shadowing issues in fix-its by optionally attaching a DeclContext which can be used to determine how a fix-it’s arguments should be formatted (that would be a follow-up PR). |
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 seems reasonable to me, but I'd like @jrose-apple to take a look as well.
4ca0016
to
e69e73c
Compare
Hi @jrose-apple , I'd like to pick this back up if possible. Do you mind taking a look when you have time? |
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.
I like the direction; a lot of fix-its probably do fit into this model. Only small comments.
lib/AST/DiagnosticList.cpp
Outdated
@@ -24,6 +24,11 @@ enum class swift::DiagID : uint32_t { | |||
static_assert(static_cast<uint32_t>(swift::DiagID::invalid_diagnostic) == 0, | |||
"0 is not the invalid diagnostic ID"); | |||
|
|||
enum class swift::FixItID : uint32_t { | |||
#define FIXIT(ID, Text, Signature) ID, | |||
#include "swift/AST/FixIts.def" |
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.
Does it make sense to have fix-its in their own file? I would have thought it'd be simplest to have them next to the diagnostics.
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.
Defining fix-its alongside the other diags complicates the macro usage by a fair amount. I'm starting to think the advantages are outweigh the tradeoffs though, so updated the PR to do this. I only added the definitions to Parse and Sema diags for now, they can be rolled out to the other headers as needed.
e69e73c
to
bc11abd
Compare
624f236
to
1c30c54
Compare
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.
Down to the nitty-gritty.
5687a76
to
873e04d
Compare
Thanks for bearing with me as I fix up these remaining issues! |
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.
Only one more comment, and it's tiny. Thanks, @owenv!
These are defined with macros like errors/warnings/notes, and make use of format strings and diagnostic arguments. The intent is to leverage diagnostic arguments in the future to disambiguate ambiguously spelled types. Ported a few miscellaneous fix-its to the new system
873e04d
to
68e6065
Compare
Welcome to C++. :-) @swift-ci Please smoke test |
These are defined with macros like errors/warnings/notes, and make use of format strings and diagnostic arguments. The intent is to leverage diagnostic arguments in the future to disambiguate ambiguously spelled types.
Ported a few miscellaneous fix-its to the new system.
Some of the rationale for this change is explained here. This change alone isn't enough to fix e.g. SR-8668, but it's a first step towards being able to handle that kind of situation better.
If this seems like a good direction to take, the next steps I had in mind are roughly:
cc @jrose-apple (this builds on some of the argument formatting changes to diags from a few weeks back)
cc @xedin (this may eventually affect many fix-its produced during type checking)