| 1 |
#ifndef TREE_SITTER_TREE_CURSOR_H_ |
| 2 |
#define TREE_SITTER_TREE_CURSOR_H_ |
| 3 |
|
| 4 |
#include "./subtree.h" |
| 5 |
|
| 6 |
typedef struct { |
| 7 |
const Subtree *subtree; |
| 8 |
Length position; |
| 9 |
uint32_t child_index; |
| 10 |
uint32_t structural_child_index; |
| 11 |
uint32_t descendant_index; |
| 12 |
} TreeCursorEntry; |
| 13 |
|
| 14 |
typedef struct { |
| 15 |
const TSTree *tree; |
| 16 |
Array(TreeCursorEntry) stack; |
| 17 |
TSSymbol root_alias_symbol; |
| 18 |
} TreeCursor; |
| 19 |
|
| 20 |
typedef enum { |
| 21 |
TreeCursorStepNone, |
| 22 |
TreeCursorStepHidden, |
| 23 |
TreeCursorStepVisible, |
| 24 |
} TreeCursorStep; |
| 25 |
|
| 26 |
void ts_tree_cursor_init(TreeCursor *self, TSNode node); |
| 27 |
void ts_tree_cursor_current_status( |
| 28 |
const TSTreeCursor *_self, |
| 29 |
TSFieldId *field_id, |
| 30 |
bool *has_later_siblings, |
| 31 |
bool *has_later_named_siblings, |
| 32 |
bool *can_have_later_siblings_with_this_field, |
| 33 |
TSSymbol *supertypes, |
| 34 |
unsigned *supertype_count |
| 35 |
); |
| 36 |
|
| 37 |
TreeCursorStep ts_tree_cursor_goto_first_child_internal(TSTreeCursor *_self); |
| 38 |
TreeCursorStep ts_tree_cursor_goto_next_sibling_internal(TSTreeCursor *_self); |
| 39 |
|
| 40 |
static inline Subtree ts_tree_cursor_current_subtree(const TSTreeCursor *_self) { |
| 41 |
const TreeCursor *self = (const TreeCursor *)_self; |
| 42 |
TreeCursorEntry *last_entry = array_back(&self->stack); |
| 43 |
return *last_entry->subtree; |
| 44 |
} |
| 45 |
|
| 46 |
TSNode ts_tree_cursor_parent_node(const TSTreeCursor *_self); |
| 47 |
|
| 48 |
#endif // TREE_SITTER_TREE_CURSOR_H_ |