1#ifndef TREE_SITTER_TREE_CURSOR_H_
 2#define TREE_SITTER_TREE_CURSOR_H_
 3
 4#include "./subtree.h"
 5
 6typedef 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
14typedef struct {
15  const TSTree *tree;
16  Array(TreeCursorEntry) stack;
17  TSSymbol root_alias_symbol;
18} TreeCursor;
19
20typedef enum {
21  TreeCursorStepNone,
22  TreeCursorStepHidden,
23  TreeCursorStepVisible,
24} TreeCursorStep;
25
26void ts_tree_cursor_init(TreeCursor *, TSNode);
27void ts_tree_cursor_current_status(
28  const TSTreeCursor *,
29  TSFieldId *,
30  bool *,
31  bool *,
32  bool *,
33  TSSymbol *,
34  unsigned *
35);
36
37TreeCursorStep ts_tree_cursor_goto_first_child_internal(TSTreeCursor *);
38TreeCursorStep ts_tree_cursor_goto_next_sibling_internal(TSTreeCursor *);
39
40static 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
46TSNode ts_tree_cursor_parent_node(const TSTreeCursor *);
47
48#endif  // TREE_SITTER_TREE_CURSOR_H_