-
Notifications
You must be signed in to change notification settings - Fork 824
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
Open
Martin521
wants to merge
12
commits into
dotnet:main
Choose a base branch
from
Martin521:line-directives
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+239
−254
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❗ Release notes required
|
This is ready for review. See updated PR description. |
edgarfgp
approved these changes
Jul 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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