> On Nov 14, 2022, at 7:27 PM, Eli Zaretskii <eliz@gnu.org> wrote: > >> From: Yuan Fu <casouri@gmail.com> >> Date: Mon, 14 Nov 2022 13:57:46 -0800 >> Cc: monnier@iro.umontreal.ca, >> theo@thornhill.no, >> emacs-devel@gnu.org >> >>> Doesn't the call to ts_tree_edit update those nodes? >> >> No. >> >>> That is, aren't >>> those nodes a part of the tree that gets updated by the ts_tree_edit >>> call? >> >> The node stores some information in itself (start_byte, end_byte, inlined >> data, etc), and references the tree for the rest. The information it stores >> needs to be updated separately. > > Can we do that? What are the difficulties? We can update the nodes. (With ts_node_edit, similar to ts_tree_edit.) But, I looked further, and the facility for updating a node is not really what we need/want. I wonât go into details here, because⦠there is a feature perfect for our use case! Tree-sitter can tell you what has changed when you re-parse a tree, thatâs exactly what we need and very easy to use. Itâs foolish for me to overlook this feature. Specifically, when we re-parse a buffer, we can compare the before/after parse tree for differences. Tree-sitter can tell us the ranges in which nodes have changed during that re-parse. The âintâ in the original example would be included in the ranges reported. Iâve pushed a change that utilizes this feature. If you pull the latest commit and open c-ts-mode, error faces should appear and disappear as you type. There is no documentation for now, but basically we now allow users to register âafter-change-functionâs to tree-sitter parsers. The parser will call these functions when with the changed ranges when it re-parses. The new functions are treesit-parser-add-notifier, treesit-parser-notifiers, treesit-parser-remove-notifier. I didnât use treesit-parser-add-after-change-function because that is hideously long. Yuan
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4