Rizin
unix-like reverse engineering framework and cli tools
|
#include "tree_sitter/api.h"
#include "./array.h"
#include "./get_changed_ranges.h"
#include "./subtree.h"
#include "./tree_cursor.h"
#include "./tree.h"
Go to the source code of this file.
Functions | |
TSTree * | ts_tree_new (Subtree root, const TSLanguage *language, const TSRange *included_ranges, unsigned included_range_count) |
TSTree * | ts_tree_copy (const TSTree *self) |
void | ts_tree_delete (TSTree *self) |
TSNode | ts_tree_root_node (const TSTree *self) |
const TSLanguage * | ts_tree_language (const TSTree *self) |
void | ts_tree_edit (TSTree *self, const TSInputEdit *edit) |
TSRange * | ts_tree_get_changed_ranges (const TSTree *self, const TSTree *other, uint32_t *count) |
void | ts_tree_print_dot_graph (const TSTree *self, FILE *file) |
Create a shallow copy of the syntax tree. This is very fast.
You need to copy a syntax tree in order to use it on more than one thread at a time, as syntax trees are not thread safe.
Definition at line 21 of file tree.c.
References ts_subtree_retain(), and ts_tree_new().
void ts_tree_delete | ( | TSTree * | self | ) |
Delete the syntax tree, freeing all of the memory that it used.
Definition at line 26 of file tree.c.
References ts_free, ts_subtree_pool_delete(), ts_subtree_pool_new(), and ts_subtree_release().
Referenced by core_cmd_tsrzcmd(), guess_data_free(), guess_next_autocmplt_token(), rz_type_parse_string_declaration_single(), rz_type_parse_string_single(), substitute_args_do(), substitute_args_fini(), and type_parse_string().
void ts_tree_edit | ( | TSTree * | self, |
const TSInputEdit * | edit | ||
) |
Edit the syntax tree to keep it in sync with source code that has been edited.
You must describe the edit both in terms of byte offsets and in terms of (row, column) coordinates.
Definition at line 44 of file tree.c.
References i, TSInputEdit::new_end_byte, TSInputEdit::new_end_point, TSInputEdit::old_end_byte, TSInputEdit::old_end_point, point_add(), POINT_MAX, point_sub(), capstone::range, ts_subtree_edit(), ts_subtree_pool_delete(), ts_subtree_pool_new(), and UINT32_MAX.
Referenced by ts_tree_edit_wasm().
TSRange* ts_tree_get_changed_ranges | ( | const TSTree * | old_tree, |
const TSTree * | new_tree, | ||
uint32_t * | length | ||
) |
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 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.
Definition at line 78 of file tree.c.
References array_delete, array_new, count, TSTree::included_range_count, TSTree::included_ranges, NULL, TSTree::root, ts_range_array_get_changed_ranges(), ts_subtree_get_changed_ranges(), ts_tree_cursor_init(), and ts_tree_root_node().
Referenced by ts_tree_get_changed_ranges_wasm().
const TSLanguage* ts_tree_language | ( | const TSTree * | self | ) |
TSTree* ts_tree_new | ( | Subtree | root, |
const TSLanguage * | language, | ||
const TSRange * | included_ranges, | ||
unsigned | included_range_count | ||
) |
Definition at line 8 of file tree.c.
References TSTree::included_range_count, TSTree::included_ranges, TSTree::language, memcpy(), TSTree::root, root, ts_calloc, and ts_malloc.
Referenced by ts_parser_parse(), and ts_tree_copy().
Write a DOT graph describing the syntax tree to the given file.
Definition at line 103 of file tree.c.
References ts_subtree_print_dot_graph().
Get the root node of the syntax tree.
Definition at line 36 of file tree.c.
References ts_node_new(), and ts_subtree_padding().
Referenced by core_cmd_tsrzcmd(), guess_next_autocmplt_token(), rz_type_parse_string_declaration_single(), rz_type_parse_string_single(), substitute_args_do(), ts_node_parent(), ts_tree_get_changed_ranges(), ts_tree_root_node_wasm(), and type_parse_string().