-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] If diagnostics are 'stale' for a particular snapshot then ignore them and only return the syntactic parser diagnostics #10388
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
… ignore them and only return the syntactic parser diagnostics rdar://32769873
@swift-ci smoke test |
@@ -23,9 +24,14 @@ typedef std::function<void(StringRef DocumentName)> | |||
DocumentUpdateNotificationReceiver; | |||
|
|||
class NotificationCenter { | |||
bool DispatchToMain; |
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.
Tab instead of spaces?
|
||
public: | ||
explicit NotificationCenter(bool dispatchToMain); | ||
~NotificationCenter(); | ||
|
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.
More tabs
sortedParserDiags.reserve(ParserDiags.size()); | ||
sortedParserDiags.insert(sortedParserDiags.end(), ParserDiags.begin(), | ||
ParserDiags.end()); | ||
std::stable_sort(sortedParserDiags.begin(), sortedParserDiags.end(), |
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.
Instead of sorting twice and using binary_search, could you merge and sort all the diagnostics together once then use std::unique to remove the duplicates?
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 considered this but I chose not to because I didn't want to remove duplicates from within the same set of diagnostics (e.g. remove duplicates from the set of typechecked-AST diagnostics). If the compiler emits some duplicate diagnostic it may be desirable or not to remove the duplicate but I prefer that we just funnel-through what the compiler provided without such kind of filtering.
Also note that duplication check will check for location+description, but it may be some case where the compiler emits 2 diagnostics with same description but with different fixit. That would be weird for the compiler to do of course, but as I mentioned I'd prefer we don't try to de-dup within the same set and just provide the diagnostics that the compiler provided.
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.
Okay, makes sense. Could you add a comment that explains that?
@@ -4,7 +4,7 @@ let a = 0; let b = 0 }; unresolved | |||
// Test that offsets of diagnostic ranges and fixits get updated correctly after the edit request | |||
|
|||
// RUN: %sourcekitd-test -req=open %s -- %s == -req=print-diags %s \ | |||
// RUN: == -req=edit -pos=2:1 -replace="_" -length=5 %s -print-raw-response \ | |||
// RUN: == -req=edit -pos=2:1 -replace="_" -length=5 %s == -req=print-diags %s \ |
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.
Can you explain what happened here? I think I understand all the other test changes, but not clear on this one.
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 test was specifically checking the previous behavior, that 'stale' diagnostics still show up, after correctly adjusting their source locations to accommodate for an edit. With this change it essentially switches to testing that after the edit and the document-update notification that we get the 'sema' diagnostics with the expected locations.
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.
Okay, thanks.
Remove tabs and add a comment.
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.
LGTM
@swift-ci smoke test |
… ignore them and only return the syntactic parser diagnostics (#10388) This makes sure that diagnostics returned for a particular state of source buffer are consistent and accurate. rdar://32769873
rdar://32769873