Skip to content

[Diagnostics] Introduce getLoc and getSourceRange to failure diagnostic #30967

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 6 commits into from
Apr 15, 2020

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Apr 11, 2020

  • Some of the diagnostics have special rules about anchor location,
    let's make getAnchor virtual and allow sub-class to override
    default implementation.

  • Split emitDiagnostic into emitDiagnostic and emitDiagnosticAt,
    where former passes getLoc internally.

  • Refactor existing diagnostics to use new methods and avoid passing
    location when possible.

@xedin
Copy link
Contributor Author

xedin commented Apr 11, 2020

This is still a draft because I need to clean up some things here and there but I'd want to get early opinion on the changes. Please take a look!

@xedin
Copy link
Contributor Author

xedin commented Apr 11, 2020

The idea is that emitDiagnostic wouldn't have to pass location directly, instead each FailureDiagnostic would have to implement getLoc() and/or getSourceRange. This should make it much easier to refactor locators be anchored on decls/type-reprs/patterns.

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Looks great!

xedin added 6 commits April 14, 2020 11:30
…nchor`

Some of the diagnostics have special rules about anchor location,
let's make `getAnchor` virtual and allow sub-class to override
default implementation.
Split `emitDiagnostic` into `emitDiagnostic` and `emitDiagnosticAt`.

Refactor existing diagnostics to use new methods and avoid passing
location when possible.
@xedin xedin force-pushed the add-loc-to-failure-diagnostic branch from faf046a to ce324d3 Compare April 14, 2020 20:54
@xedin
Copy link
Contributor Author

xedin commented Apr 14, 2020

@hamishknight Thanks for the review, I've fixed both problems you have mentioned.

@xedin
Copy link
Contributor Author

xedin commented Apr 14, 2020

@swift-ci please smoke test

@xedin xedin marked this pull request as ready for review April 14, 2020 22:45
@xedin
Copy link
Contributor Author

xedin commented Apr 14, 2020

@swift-ci please smoke test Linux platform

@xedin
Copy link
Contributor Author

xedin commented Apr 15, 2020

Since there is no opposition here I'm going to merge this and next up is removal of Anchor and RawAnchor from FailureDiagnostic.

@xedin xedin merged commit 010520a into swiftlang:master Apr 15, 2020
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