Rizin
unix-like reverse engineering framework and cli tools
|
#include "tree_sitter/api.h"
#include "./alloc.h"
#include "./tree_cursor.h"
#include "./language.h"
#include "./tree.h"
Go to the source code of this file.
Classes | |
struct | CursorChildIterator |
Macros | |
#define | subtree_symbol(subtree, structural_child_index) |
#define subtree_symbol | ( | subtree, | |
structural_child_index | |||
) |
|
inlinestatic |
Definition at line 37 of file tree_cursor.c.
References length_add(), TreeCursorEntry::subtree, ts_subtree_children, ts_subtree_extra(), ts_subtree_padding(), ts_subtree_size(), and ts_subtree_visible().
Referenced by ts_tree_cursor_goto_first_child(), ts_tree_cursor_goto_first_child_for_byte(), ts_tree_cursor_goto_first_child_for_point(), and ts_tree_cursor_goto_next_sibling().
TSTreeCursor ts_tree_cursor_copy | ( | const TSTreeCursor * | _cursor | ) |
Definition at line 479 of file tree_cursor.c.
References array_init, array_push_all, NULL, and TreeCursor::tree.
TSFieldId ts_tree_cursor_current_field_id | ( | const TSTreeCursor * | _self | ) |
Get the field id of the tree cursor's current node.
This returns zero if the current node doesn't have a field. See also ts_node_child_by_field_id
, ts_language_field_id_for_name
.
Definition at line 431 of file tree_cursor.c.
References i, SubtreeHeapData::production_id, Subtree::ptr, TreeCursorEntry::subtree, ts_language_alias_at(), ts_language_field_map(), ts_subtree_extra(), and ts_subtree_visible().
Referenced by ts_tree_cursor_current_field_id_wasm(), and ts_tree_cursor_current_field_name().
const char* ts_tree_cursor_current_field_name | ( | const TSTreeCursor * | _self | ) |
Get the field name of the tree cursor's current node.
This returns NULL
if the current node doesn't have a field. See also ts_node_child_by_field_name
.
Definition at line 469 of file tree_cursor.c.
References id, NULL, TSTreeCursor::tree, and ts_tree_cursor_current_field_id().
TSNode ts_tree_cursor_current_node | ( | const TSTreeCursor * | _self | ) |
Get the tree cursor's current node.
Definition at line 262 of file tree_cursor.c.
References array_back, TreeCursorEntry::position, SubtreeHeapData::production_id, Subtree::ptr, TreeCursorEntry::structural_child_index, TreeCursorEntry::subtree, ts_language_alias_at(), ts_node_new(), and ts_subtree_extra().
Referenced by ts_node_children_wasm(), ts_node_descendants_of_type_wasm(), ts_node_named_children_wasm(), ts_query_cursor__advance(), ts_tree_cursor_current_node_id_wasm(), ts_tree_cursor_current_node_is_missing_wasm(), ts_tree_cursor_current_node_is_named_wasm(), ts_tree_cursor_current_node_type_id_wasm(), ts_tree_cursor_current_node_wasm(), ts_tree_cursor_end_index_wasm(), ts_tree_cursor_end_position_wasm(), ts_tree_cursor_start_index_wasm(), and ts_tree_cursor_start_position_wasm().
void ts_tree_cursor_current_status | ( | const TSTreeCursor * | _self, |
TSFieldId * | field_id, | ||
bool * | has_later_siblings, | ||
bool * | has_later_named_siblings, | ||
bool * | can_have_later_siblings_with_this_field, | ||
TSSymbol * | supertypes, | ||
unsigned * | supertype_count | ||
) |
Definition at line 284 of file tree_cursor.c.
References SubtreeHeapData::child_count, field_id, i, TSSymbolMetadata::named, SubtreeHeapData::named_child_count, SubtreeHeapData::production_id, Subtree::ptr, TreeCursorEntry::subtree, subtree_symbol, TSSymbolMetadata::supertype, ts_language_alias_sequence(), ts_language_field_map(), ts_language_symbol_metadata(), ts_subtree_children, ts_subtree_extra(), ts_subtree_visible_child_count(), and TSSymbolMetadata::visible.
Referenced by ts_query_cursor__advance().
void ts_tree_cursor_delete | ( | TSTreeCursor * | _self | ) |
Delete a tree cursor, freeing all of the memory that it used.
Definition at line 94 of file tree_cursor.c.
References array_delete.
Referenced by ts_query_cursor_delete(), and ts_tree_cursor_delete_wasm().
bool ts_tree_cursor_goto_first_child | ( | TSTreeCursor * | _self | ) |
Move the cursor to the first child of its current node.
This returns true
if the cursor successfully moved, and returns false
if there were no children.
Definition at line 101 of file tree_cursor.c.
References array_push, ts_subtree_visible_child_count(), ts_tree_cursor_child_iterator_next(), and ts_tree_cursor_iterate_children().
Referenced by ts_node_children_wasm(), ts_node_descendants_of_type_wasm(), ts_node_named_children_wasm(), ts_query_cursor__advance(), ts_tree_cursor_goto_first_child_wasm(), and ts_tree_cursor_goto_next_sibling().
int64_t ts_tree_cursor_goto_first_child_for_byte | ( | TSTreeCursor * | _self, |
uint32_t | goal_byte | ||
) |
Move the cursor to the first child of its current node that extends beyond the given byte offset or point.
This returns the index of the child node if one was found, and returns -1 if no such child was found.
Definition at line 128 of file tree_cursor.c.
References array_push, Length::bytes, ts_subtree_size(), ts_subtree_visible_child_count(), ts_tree_cursor_child_iterator_next(), and ts_tree_cursor_iterate_children().
int64_t ts_tree_cursor_goto_first_child_for_point | ( | TSTreeCursor * | _self, |
TSPoint | goal_point | ||
) |
Definition at line 168 of file tree_cursor.c.
References array_push, Length::extent, point_add(), point_gte(), ts_subtree_size(), ts_subtree_visible_child_count(), ts_tree_cursor_child_iterator_next(), and ts_tree_cursor_iterate_children().
bool ts_tree_cursor_goto_next_sibling | ( | TSTreeCursor * | _self | ) |
Move the cursor to the next sibling of its current node.
This returns true
if the cursor successfully moved, and returns false
if there was no next sibling node.
Definition at line 206 of file tree_cursor.c.
References array_pop, array_push, ts_subtree_visible_child_count(), ts_tree_cursor_child_iterator_next(), ts_tree_cursor_goto_first_child(), and ts_tree_cursor_iterate_children().
Referenced by ts_node_children_wasm(), ts_node_descendants_of_type_wasm(), ts_node_named_children_wasm(), ts_query_cursor__advance(), and ts_tree_cursor_goto_next_sibling_wasm().
bool ts_tree_cursor_goto_parent | ( | TSTreeCursor * | _self | ) |
Move the cursor to the parent of its current node.
This returns true
if the cursor successfully moved, and returns false
if there was no parent node (the cursor was already on the root node).
Definition at line 239 of file tree_cursor.c.
References i, SubtreeHeapData::production_id, Subtree::ptr, entry::size, TreeCursorEntry::subtree, ts_language_alias_at(), ts_subtree_extra(), and ts_subtree_visible().
Referenced by ts_node_descendants_of_type_wasm(), ts_query_cursor__advance(), and ts_tree_cursor_goto_parent_wasm().
void ts_tree_cursor_init | ( | TreeCursor * | self, |
TSNode | node | ||
) |
Definition at line 80 of file tree_cursor.c.
References array_clear, array_push, and TSNode::tree.
Referenced by ts_tree_cursor_new(), ts_tree_cursor_reset(), and ts_tree_get_changed_ranges().
|
inlinestatic |
Definition at line 18 of file tree_cursor.c.
References array_back, length_zero(), NULL, NULL_SUBTREE, TreeCursorEntry::position, SubtreeHeapData::production_id, Subtree::ptr, TreeCursorEntry::subtree, ts_language_alias_sequence(), and ts_subtree_child_count().
Referenced by ts_tree_cursor_goto_first_child(), ts_tree_cursor_goto_first_child_for_byte(), ts_tree_cursor_goto_first_child_for_point(), and ts_tree_cursor_goto_next_sibling().
TSTreeCursor ts_tree_cursor_new | ( | TSNode | node | ) |
Create a new tree cursor starting from the given node.
A tree cursor allows you to walk a syntax tree more efficiently than is possible using the TSNode
functions. It is a mutable object that is always on a certain syntax node, and can be moved imperatively to different nodes.
Definition at line 70 of file tree_cursor.c.
References NULL, and ts_tree_cursor_init().
Referenced by ts_tree_cursor_new_wasm().
TSNode ts_tree_cursor_parent_node | ( | const TSTreeCursor * | _self | ) |
Definition at line 404 of file tree_cursor.c.
References i, length_zero(), NULL, SubtreeHeapData::production_id, Subtree::ptr, TreeCursorEntry::subtree, ts_language_alias_at(), ts_node_new(), and ts_subtree_visible().
Referenced by ts_query_cursor__advance().
void ts_tree_cursor_reset | ( | TSTreeCursor * | _self, |
TSNode | node | ||
) |
Re-initialize a tree cursor to start at a different node.
Definition at line 76 of file tree_cursor.c.
References ts_tree_cursor_init().
Referenced by ts_node_children_wasm(), ts_node_descendants_of_type_wasm(), ts_node_named_children_wasm(), ts_query_cursor_exec(), and ts_tree_cursor_reset_wasm().