-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Experimentally emit diagnostics from the new Swift parser #62629
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1a3c6d7
[ASTGen] Handle new parser validation in ASTGen.
DougGregor 33589de
Experimentally emit diagnostics from the new Swift parser
DougGregor f8e98ca
[ASTGen] Make sure we handle Fix-Its without a matching note.
DougGregor 4ef35c5
Embrace the swift-syntax notion of Fix-Its as separate notes.
DougGregor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,32 +91,34 @@ func emitDiagnostic( | |
diagnostic: Diagnostic, | ||
messageSuffix: String? = nil | ||
) { | ||
// Collect all of the Fix-It changes based on their Fix-It ID. | ||
var fixItChangesByID: [MessageID : [FixIt.Change]] = [:] | ||
for fixIt in diagnostic.fixIts { | ||
fixItChangesByID[fixIt.message.fixItID, default: []] | ||
.append(contentsOf: fixIt.changes.changes) | ||
} | ||
|
||
// Emit the main diagnostic | ||
emitDiagnosticParts( | ||
diagEnginePtr: diagEnginePtr, | ||
sourceFileBuffer: sourceFileBuffer, | ||
message: diagnostic.diagMessage.message + (messageSuffix ?? ""), | ||
severity: diagnostic.diagMessage.severity, | ||
position: diagnostic.position, | ||
highlights: diagnostic.highlights, | ||
fixItChanges: fixItChangesByID[diagnostic.diagnosticID] ?? [] | ||
highlights: diagnostic.highlights | ||
) | ||
|
||
// Emit Fix-Its. | ||
for fixIt in diagnostic.fixIts { | ||
emitDiagnosticParts( | ||
diagEnginePtr: diagEnginePtr, | ||
sourceFileBuffer: sourceFileBuffer, | ||
message: fixIt.message.message, | ||
severity: .note, position: diagnostic.position, | ||
fixItChanges: fixIt.changes.changes | ||
) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you can just add:
|
||
// Emit any notes as follow-ons. | ||
for note in diagnostic.notes { | ||
emitDiagnosticParts( | ||
diagEnginePtr: diagEnginePtr, | ||
sourceFileBuffer: sourceFileBuffer, | ||
message: note.message, | ||
severity: .note, position: note.position, | ||
fixItChanges: fixItChangesByID[note.noteMessage.fixItID] ?? [] | ||
severity: .note, position: note.position | ||
) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserDiagnostics | ||
|
||
// FIXME: Swift parser is not enabled on Linux CI yet. | ||
// REQUIRES: OS=macosx | ||
// REQUIRES: asserts | ||
|
||
_ = [(Int) -> async throws Int]() | ||
// expected-error@-1{{'async throws' may only occur before '->'}} | ||
// expected-note@-2{{move 'async throws' in front of '->'}}{{15-21=}} {{21-28=}} {{20-21= }} {{12-12=async }} {{12-12=throws }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Similar to my comment on another PR, I think
Swift Swift parser
is confusing. What aboutSwiftParser
orSwiftParser implemented in Swift
?