sudoio
(Joe Hinkle)
1
Is there a way to update a single mode in Swift Syntax that isn’t using the Rewriter class?
akyrtzi
(Argyrios Kyrtzidis)
2
The syntax tree is immutable, you cannot 'update' it. What you can do is get a new tree with your modification applied. All the with* (e.g. withIdentifier()) functions give you a new node with the modification applied and new parent nodes all the way to a new root node.
1 Like
sudoio
(Joe Hinkle)
3
Thanks. Is using that method more or less expensive than using the Swift Rewriter?
akyrtzi
(Argyrios Kyrtzidis)
4
I'm not sure if there is significant difference and whether the difference applies always or it depends on the use pattern. I'd recommend to do some measurements based on the intended pattern of modifications.