You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to edit the AST this way using tree-sitter-node? If yes. How do I do it? Currently, the only way I see is to create a new StatementBlockNode object and then attach it to the tree. In the after case, I don't care about the row and column numbers.
The text was updated successfully, but these errors were encountered:
Himujjal
changed the title
Help: How to a single AST?
Help: How to edit a single AST?
Feb 24, 2021
@Himujjal It's not possible to edit tree-sitter's AST cause it runs counter to tree-sitter abilities like cheap syntax tree edits, recovering after errors and precise nodes position tracking. There only one way is to edit grammar.js file so the tree-sitter would build a different syntax tree by itself.
In a certain use case, I need to edit the AST to enclose a for-loop in a
statment_block
for tree-sitter-javascript:Before:
After:
Is it possible to edit the AST this way using tree-sitter-node? If yes. How do I do it? Currently, the only way I see is to create a new
StatementBlockNode
object and then attach it to the tree. In the after case, I don't care about the row and column numbers.The text was updated successfully, but these errors were encountered: