-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
internal: Add preliminary SyntaxEditor
functionality
#18032
Conversation
SyntaxEditor
SyntaxEditor
functionality
We should also consider forking rowan in-tree as we will likely start changing things a bunch once we consider dropping mutable syntax trees. (and at some point feed the changes back to main rowan and adopt it into the monorepo) |
Presumably, fixing this would simplify things here? Would be good to check if if thats a requirement we want for our next rowan and whether it has certain requirements on the implementation then |
Thinking about it more, I think we'll still need |
useful for `SourceChangeBuilder` so it can still perform a tree diff without having to store the old root separately
I believe functionality-wise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, looks good to me: I'd like to land this and start moving assists over to this.
@bors r+ |
☀️ Test successful - checks-actions |
Related to #15710
Implements a
SyntaxEditor
interface to abstract over the details of modifying syntax trees, to both simplify creating new code fixes and code actions, as well as start on the path of getting rid of mutable syntax nodes.SyntaxEditor
relies onSyntaxMappingBuilder
s to feed in the correct information to map AST nodes created bymake
constructors, asmake
constructors do not guarantee that node identity is preserved. This is to paper over the fact thatmake
constructors simply re-parse text input instead of building AST nodes from the ground up and re-using the provided syntax nodes.SyntaxAnnotation
s are used to find where syntax elements have ended up after edits are applied. This is primarily useful for theadd_{placeholder,tabstop}
set of methods onSourceChangeBuilder
, as that currently relies on the nodes provided being in the final syntax tree.Eventually, the goal should be to move this into the
rowan
crate when we move away from mutable syntax nodes, but for now it'll stay in thesyntax
crate.Closes #14921 as
SyntaxEditor
ensures that all replace changes are disjointCloses #9649 by implementing
SyntaxAnnotation
s