32 .structural_child_index = 0,
33 .alias_sequence = alias_sequence,
42 if (!self->parent.ptr || self->child_index == self->parent.ptr->child_count)
return false;
46 .position =
self->position,
47 .child_index =
self->child_index,
48 .structural_child_index =
self->structural_child_index,
52 if (!extra && self->alias_sequence) {
53 *visible |=
self->alias_sequence[
self->structural_child_index];
54 self->structural_child_index++;
60 if (self->child_index < self->parent.ptr->child_count) {
81 self->tree = node.
tree;
84 .subtree = (const Subtree *)node.id,
86 ts_node_start_byte(node),
87 ts_node_start_point(node)
90 .structural_child_index = 0,
123 }
while (did_descend);
130 uint32_t initial_size =
self->stack.size;
142 bool at_goal = end_byte >= goal_byte;
148 return visible_child_index;
151 if (visible_child_count > 0) {
156 }
else if (visible) {
157 visible_child_index++;
159 visible_child_index += visible_child_count;
162 }
while (did_descend);
164 self->stack.size = initial_size;
170 uint32_t initial_size =
self->stack.size;
182 bool at_goal =
point_gte(end_point, goal_point);
187 return visible_child_index;
189 if (visible_child_count > 0) {
194 }
else if (visible) {
195 visible_child_index++;
197 visible_child_index += visible_child_count;
200 }
while (did_descend);
202 self->stack.size = initial_size;
208 uint32_t initial_size =
self->stack.size;
210 while (self->stack.size > 1) {
214 iterator.structural_child_index =
entry.structural_child_index;
217 bool visible =
false;
219 if (visible && self->stack.size + 1 < initial_size)
break;
235 self->stack.size = initial_size;
241 for (
unsigned i = self->stack.size - 2;
i + 1 > 0;
i--) {
244 self->stack.
size =
i + 1;
250 self->tree->language,
252 entry->structural_child_index
254 self->stack.size =
i + 1;
267 TreeCursorEntry *parent_entry = &
self->stack.contents[
self->stack.size - 2];
269 self->tree->language,
287 bool *has_later_siblings,
288 bool *has_later_named_siblings,
289 bool *can_have_later_siblings_with_this_field,
291 unsigned *supertype_count
294 unsigned max_supertypes = *supertype_count;
296 *supertype_count = 0;
297 *has_later_siblings =
false;
298 *has_later_named_siblings =
false;
299 *can_have_later_siblings_with_this_field =
false;
303 for (
unsigned i = self->stack.size - 1;
i > 0;
i--) {
308 self->tree->language,
312 #define subtree_symbol(subtree, structural_child_index) \
314 !ts_subtree_extra(subtree) && \
316 alias_sequence[structural_child_index] \
318 alias_sequence[structural_child_index] : \
319 ts_subtree_symbol(subtree))
324 entry->structural_child_index
327 self->tree->language,
330 if (
i != self->stack.size - 1 && entry_metadata.
visible)
break;
333 if (entry_metadata.
supertype && *supertype_count < max_supertypes) {
334 supertypes[*supertype_count] = entry_symbol;
335 (*supertype_count)++;
339 if (!*has_later_siblings) {
341 unsigned structural_child_index =
entry->structural_child_index;
343 for (
unsigned j =
entry->child_index + 1; j < sibling_count; j++) {
346 self->tree->language,
349 if (sibling_metadata.
visible) {
350 *has_later_siblings =
true;
351 if (*has_later_named_siblings)
break;
352 if (sibling_metadata.
named) {
353 *has_later_named_siblings =
true;
357 *has_later_siblings =
true;
358 if (*has_later_named_siblings)
break;
360 *has_later_named_siblings =
true;
368 #undef subtree_symbol
373 self->tree->language,
375 &field_map, &field_map_end
381 if (!
i->inherited &&
i->child_index ==
entry->structural_child_index) {
393 i->child_index >
entry->structural_child_index
395 *can_have_later_siblings_with_this_field =
true;
406 for (
int i = (
int)
self->stack.size - 2;
i >= 0;
i--) {
408 bool is_visible =
true;
413 self->tree->language,
415 entry->structural_child_index
435 for (
unsigned i = self->stack.size - 1;
i > 0;
i--) {
440 if (
i != self->stack.size - 1) {
445 self->tree->language,
447 entry->structural_child_index
456 self->tree->language,
458 &field_map, &field_map_end
461 if (!
i->inherited &&
i->child_index ==
entry->structural_child_index) {
473 return self->
tree->language->field_names[
id];
const MCPhysReg * iterator
#define array_push_all(self, other)
#define array_push(self, element)
#define array_delete(self)
#define array_clear(self)
TSSymbolMetadata ts_language_symbol_metadata(const TSLanguage *self, TSSymbol symbol)
static void ts_language_field_map(const TSLanguage *self, uint32_t production_id, const TSFieldMapEntry **start, const TSFieldMapEntry **end)
static const TSSymbol * ts_language_alias_sequence(const TSLanguage *self, uint32_t production_id)
static TSSymbol ts_language_alias_at(const TSLanguage *self, uint32_t production_id, uint32_t child_index)
static Length length_zero(void)
static Length length_add(Length len1, Length len2)
TSNode ts_node_new(const TSTree *tree, const Subtree *subtree, Length position, TSSymbol alias)
static TSPoint point_add(TSPoint a, TSPoint b)
static bool point_gte(TSPoint a, TSPoint b)
const TSSymbol * alias_sequence
uint32_t structural_child_index
uint32_t named_child_count
uint32_t structural_child_index
#define ts_subtree_children(self)
static bool ts_subtree_visible(Subtree self)
static bool ts_subtree_extra(Subtree self)
static Length ts_subtree_size(Subtree self)
static uint32_t ts_subtree_visible_child_count(Subtree self)
static uint32_t ts_subtree_child_count(Subtree self)
static Length ts_subtree_padding(Subtree self)
int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *_self, TSPoint goal_point)
void ts_tree_cursor_delete(TSTreeCursor *_self)
TSNode ts_tree_cursor_parent_node(const TSTreeCursor *_self)
void ts_tree_cursor_init(TreeCursor *self, TSNode node)
static CursorChildIterator ts_tree_cursor_iterate_children(const TreeCursor *self)
bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *_self)
TSTreeCursor ts_tree_cursor_new(TSNode node)
TSNode ts_tree_cursor_current_node(const TSTreeCursor *_self)
TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *_cursor)
void ts_tree_cursor_reset(TSTreeCursor *_self, TSNode node)
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)
TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *_self)
const char * ts_tree_cursor_current_field_name(const TSTreeCursor *_self)
static bool ts_tree_cursor_child_iterator_next(CursorChildIterator *self, TreeCursorEntry *result, bool *visible)
bool ts_tree_cursor_goto_first_child(TSTreeCursor *_self)
int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *_self, uint32_t goal_byte)
#define subtree_symbol(subtree, structural_child_index)
bool ts_tree_cursor_goto_parent(TSTreeCursor *_self)
const SubtreeHeapData * ptr