Refactor #line processing - keep the original positions in the AST #18699
+239
−254
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.
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