[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree sitter support for C-like languages

From: Eli Zaretskii
Subject: Re: Tree sitter support for C-like languages
Date: Mon, 14 Nov 2022 22:10:06 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Mon, 14 Nov 2022 11:51:59 -0800
> Cc: monnier@iro.umontreal.ca,
>  theo@thornhill.no,
>  emacs-devel@gnu.org
> >> Well we update the parse tree and re-parse, but we currently don’t update 
> >> the nodes created from the old tree. Keeping all nodes updated requires us 
> >> to track all live nodes and update them whenever the buffer is edited.
> > 
> > I guess I still don't understand what exactly do you mean by "update
> > the node".  Can you explain that in more detail?
> My bad. So when buffer changes (insert in X, delete from X to Y), we inform 
> tree-sitter of this change by “updating” the tree:
>   const TSInputEdit edit =
>     treesit_prepare_input_edit (start_byte, old_end_byte, new_end_byte);
>   ts_tree_edit (tree, &edit);
> Then when we re-parse, tree-sitter knows which part of the buffer has changed 
> and needs to be re-parsed, and only parses those, hence “incremental 
> parsing”. 
> Tree-sitter nodes needs similar updates, so that it is in sync with the 
> buffer text.

Doesn't the call to ts_tree_edit update those nodes?  That is, aren't
those nodes a part of the tree that gets updated by the ts_tree_edit

reply via email to

[Prev in Thread] Current Thread [Next in Thread]