-
Notifications
You must be signed in to change notification settings - Fork 440
Use presumed file/line number when printing grouped diagnostics #2501
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
Use presumed file/line number when printing grouped diagnostics #2501
Conversation
For the primary diagnostic, print the presumed file/line number in the same manner as the Swift compiler does. In the actual code listing, keep the line numbers and code from the actual source file that was parsed, because there's no sensible way to map the source from the `#sourceLocation`-named file (which might not exist).
@swift-ci please test |
@swift-ci please test Linux |
@swift-ci please test macOS |
@swift-ci please clean test macOS |
@swift-ci please clean test Linux |
swiftlang/swift-package-manager#7349 @swift-ci please test |
@@ -60,6 +60,31 @@ extension GroupedDiagnostics { | |||
} | |||
|
|||
final class GroupedDiagnosticsFormatterTests: XCTestCase { | |||
func testSourceLocations() { |
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'd be nice to put the actual file's name somewhere as well, but I have no great suggestions as to where to put it.
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.
Could you elaborate a bit? I'm not quite sure I'm following what you mean. :/
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.
With #sourceLocation
we have two "files" - the real file on disk (usually generated in this case) and the "presumed" file (the one noted in #sourceLocation
). After this change, the file noted in the diagnostic is the presumed file, which matches the Swift compiler. That makes sense since #sourceLocation
was added for a reason, but I have found that knowing the underlying file is useful too.
That would have been more clear if I put this comment on the actual #sourceLocation
line :)
For the primary diagnostic, print the presumed file/line number in the same manner as the Swift compiler does. In the actual code listing, keep the line numbers and code from the actual source file that was parsed, because there's no sensible way to map the source from the
#sourceLocation
-named file (which might not exist).