Skip to content

[SwiftSyntax] Add accessors for source locations and test diagnostic emission #16141

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

Conversation

harlanhaskins
Copy link
Contributor

This patch adds accessors on Syntax for startLocation, endLocation, and sourceRange. They have to take a file URL, because the Syntax tree is independent of a file.

Also add a test in the DiagnosticTest that gets the source locations of a file.

@harlanhaskins harlanhaskins requested a review from nkcsgexi April 25, 2018 00:07
}
override func visit(_ function: FunctionDeclSyntax) {
let startLoc = function.identifier.startLocation(in: url)
engine.diagnose(.badFunction(function.identifier), location: startLoc) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we issue diags to the end of the function decl to test the end location too?

@harlanhaskins
Copy link
Contributor Author

@nkcsgexi 👍

@harlanhaskins
Copy link
Contributor Author

@swift-ci please smoke test

@harlanhaskins
Copy link
Contributor Author

Mutation strikes again.

@swift-ci please smoke test

@harlanhaskins harlanhaskins merged commit 9323d08 into swiftlang:master Apr 26, 2018
maldahleh pushed a commit to maldahleh/swift that referenced this pull request Oct 26, 2020
…emission (swiftlang#16141)

* [SwiftSyntax] Add accessors for source locations and test diagnostic emission

* Add tests for endLocation

* Pre-emptively copy AbsolutePosition to avoid mutating it twice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants