Implement ts_find_parent_offset_point
This commit is contained in:
parent
8446b657f0
commit
2669933d06
3 changed files with 16 additions and 1 deletions
|
|
@ -74,7 +74,7 @@ static inline TSNode ts_node__prev_sibling(TSNode self, TSNodeType type) {
|
|||
do {
|
||||
size_t index = tree->context.index;
|
||||
offset = ts_length_sub(offset, tree->context.offset);
|
||||
offset_point = ts_find_parent_offset_point(tree, point);
|
||||
offset_point = ts_find_parent_offset_point(tree);
|
||||
tree = tree->context.parent;
|
||||
if (!tree)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,19 @@ void ts_tree_release(TSTree *self) {
|
|||
}
|
||||
}
|
||||
|
||||
TSPoint ts_find_parent_offset_point(const TSTree *self) {
|
||||
TSPoint size_point = self->size_point;
|
||||
const TSTree *parent = self;
|
||||
TSPoint current_offset_point;
|
||||
|
||||
do {
|
||||
parent = parent->context.parent;
|
||||
current_offset_point = parent->context.offset_point;
|
||||
} while (current_offset_point.line == 0);
|
||||
|
||||
return (TSPoint){ .line = size_point.line, .column = current_offset_point.column };
|
||||
}
|
||||
|
||||
TSLength ts_tree_total_size(const TSTree *self) {
|
||||
return ts_length_add(self->padding, self->size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ void ts_tree_release(TSTree *tree);
|
|||
bool ts_tree_eq(const TSTree *tree1, const TSTree *tree2);
|
||||
char *ts_tree_string(const TSTree *tree, const char **names,
|
||||
bool include_anonymous);
|
||||
|
||||
TSPoint ts_find_parent_offset_point(const TSTree *self);
|
||||
TSLength ts_tree_total_size(const TSTree *tree);
|
||||
TSPoint ts_tree_total_size_point(const TSTree *self);
|
||||
void ts_tree_prepend_children(TSTree *, size_t, TSTree **);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue