-
Notifications
You must be signed in to change notification settings - Fork 825
Refactor #line processing - keep the original positions in the AST #18699
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
base: main
Are you sure you want to change the base?
Conversation
❗ Release notes required
|
This is ready for review. See updated PR description. |
@T-Gro |
Sorry for not getting around to responding sooner. We probably do with FSAC QuickFixes or possibly some analyzers but with all changes to FCS, we adapt. It might be enlightening to see what tests fail with a build of this against FSAC or FSharp.Analyzers.SDK/Ionide-Analyzers/GResearch's analyzers. |
Good to hear. Thanks for looking into it. I will try to run the tests and report back. |
Description
Fixes #18553.
Breaking change.
This PR is non-breaking for two of the three #line use cases mentioned in #18553.
It keeps the original ranges in the AST, stores the #line directives in a table and provides a method
range.ApplyLineDirectives()
. This method is applied in the following placesCompilerDiagnostics.FormatDiagnosticLocation
)FSharpDiagnostics.CreateFromException
)This should make sure that all debugging information (in .pdb) and all diagnostics stay unchanged.
The third use case, symbol positions for IDE editors, is more tricky.
FSharpSymbol
has no range field or property that I could apply the transformation to, but just contains (and makes public) the AST items with their original ranges.So, I propose we leave it like this and call
ApplyLineDirectives
in the appropriate places in FSAC / the editors.This will also enable better line directive support in the editors (for some use cases you need the original ranges).
For Ionide / FSAC I found that calling
ApplyLineDirectives
in a single place (in FSAC'sfcsRangeToLspLocation
) will most probably be sufficient to support the current functionality.I don't know what it means for the other editors.
Any thoughts or recommendations here? (@TheAngryByrd @auduchinok @abonie )
List of breaking changes
__LINE__
and__SOURCE_FILE__
show original locations nowFSharpSymbol
points to its original range)Checklist