Refactor #line processing - keep the original positions in the AST #18699
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.
Description
Fixes #18553.
Breaking change.
Work in Progress.
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.I am considering different options here, this is still work in progress. One option is to leave calling ApplyLineDirectives to the user (e.g. FSAC). (To possibly offer both positions to the IDE using PositionLink.)
I am still trying to find my way through FSAC and LSP protocol. I am assuming now that the target location (rather than the original) is needed only for the various go-to requests and some naviation items.
Any thoughts or recommendations here? (@TheAngryByrd @auduchinok @abonie )
List of breaking changes
__LINE__
and__SOURCE_FILE__
show original locations nowChecklist