-
Notifications
You must be signed in to change notification settings - Fork 419
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
Implement tracking of syntax nodes if the syntax tree is edited #2118
Open
ahoppen
wants to merge
9
commits into
swiftlang:main
Choose a base branch
from
ahoppen:ahoppen/node-tracking-in-root
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.
Conversation
This file contains 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
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
August 31, 2023 21:14
3b274ef
to
c41f24c
Compare
@swift-ci Please test |
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
September 1, 2023 20:23
8b7c8f5
to
489827b
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
September 6, 2023 00:47
489827b
to
4cab621
Compare
@swift-ci Please test |
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
September 6, 2023 01:21
4cab621
to
6b1895b
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
September 8, 2023 16:23
6b1895b
to
ba55508
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
@swift-ci Please test macOS |
Passing a `UInt` around has always felt a little unsafe and didn’t give any semantic meaning that describes what the `UInt` represents.
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
August 1, 2024 21:39
ba55508
to
cd65822
Compare
…f structs This will allow us to add more data to `SyntaxData.Info.Root` without increasing the size of `SyntaxData`. It shouldn’t have a big performance impact at the moment since `Root.arena` is never accessed and only exists to keep `arena` a live.
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
August 1, 2024 22:17
cd65822
to
482fa85
Compare
@swift-ci Please test |
ahoppen
force-pushed
the
ahoppen/node-tracking-in-root
branch
from
August 1, 2024 22:17
482fa85
to
31b7eb1
Compare
@swift-ci Please test |
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.
On any syntax tree, you can call
.tracked
. Any tree that is derived from that tracked tree is able to find the original syntax node in the tracked tree. Use cases of this could be to find the original source ranges of syntax nodes that have been re-written in macros or to allow a syntax rewriter to modify a syntax tree while still being able to get the original source locations for any node that was kept.The basic idea is as follows: Every syntax node within the tree already contains an
indexInTree
, which is its index in a depth-first traversal. The node of each tree stores the ranges ofindexInTree
that have been re-used from the original tree and the offset my which theirindexInTree
has been shifted compared to the original tree.For example, if you have the following tree (index in tree in parentheses)
And you construct a new tree a follows
Then the new tree would have a single syntax tracking range of
2...4: -2
. This defines that nodes withindexInTree
2 to 4 occur in the tracked tree and that to receive theindexInTree
within the tracked tree, 2 needs to be subtracted from the node in the derived tree.I still need to investigate the performance implications of this change. My assumption is that
rootInfo.syntaxTracking?.trackedTree != nil
fromtrackedTree != nil
inreplacingChild
)