pub unsafe extern "C" fn ts_tree_get_changed_ranges(
old_tree: *const TSTree,
new_tree: *const TSTree,
length: *mut u32,
) -> *mut TSRange
Expand description
Compare an old edited syntax tree to a new syntax tree representing the same document, returning an array of ranges whose syntactic structure has changed.
For this to work correctly, the old syntax tree must have been edited such
that its ranges match up to the new tree. Generally, you’ll want to call
this function right after calling one of the ts_parser_parse
functions.
You need to pass the old tree that was passed to parse, as well as the new
tree that was returned from that function.
The returned ranges indicate areas where the hierarchical structure of syntax nodes (from root to leaf) has changed between the old and new trees. Characters outside these ranges have identical ancestor nodes in both trees.
Note that the returned ranges may be slightly larger than the exact changed areas, but Tree-sitter attempts to make them as small as possible.
The returned array is allocated using malloc
and the caller is responsible
for freeing it using free
. The length of the array will be written to the
given length
pointer.