Replies: 1 comment 1 reply
-
It isn't but nothing stops to use Tree-sitter in a way for what it was also built by calculating expected positions for edits by using initial Tree-sitter's tree after parsing and insert all edits as text right into an input text and in parallel inform Tree-sitter's initial tree about such edits by using
I've described above.
Yes, it makes sense.
I don't know and didn't see such comparisons, if you'd measure it that would be awesome.
How do you imagine to craft a very complex edits with AST modifications? It's a ton of work that would be hard to maintain later due to it's relativity and an indirection in representation. Even in Rust where code generation is very powerful, a lot of this process based on thing that many modifications applied as snippets of code ( |
Beta Was this translation helpful? Give feedback.
-
I want to add a comment to the top of every function I find. When the user saves the file, or even as they finish typing a function.
In:
Out:
What is the point of
tree.edit
. I'm guessing its to track text editor edits (single letter, cut/copy/paste).Can I run
tree.edit
multiple times before reparsing. Does that make sense?tree.edit
be more performant than say using thetypescript
compiler api (maybe with language service) to parse to the full AST, make change, and write back?Would tree-sitter give me more performance than typescript compiler api and language service? I guess a big advantage is that it can support multiple grammars.
But it seems like AST editing should be done with a language-specific tool.
Beta Was this translation helpful? Give feedback.
All reactions