Change edit API to be byte-based

This commit is contained in:
Max Brunsfeld 2016-09-13 13:08:52 -07:00
parent cc62fe0375
commit 00528e50ce
11 changed files with 261 additions and 133 deletions

View file

@ -68,7 +68,7 @@ size_t ts_tree_start_column(const TSTree *self);
size_t ts_tree_end_column(const TSTree *self);
void ts_tree_set_children(TSTree *, size_t, TSTree **);
void ts_tree_assign_parents(TSTree *);
void ts_tree_edit(TSTree *, TSInputEdit);
void ts_tree_edit(TSTree *, const TSInputEdit *edit);
char *ts_tree_string(const TSTree *, const TSLanguage *, bool include_all);
void ts_tree_print_dot_graph(const TSTree *, const TSLanguage *, FILE *);
@ -76,10 +76,18 @@ static inline size_t ts_tree_total_chars(const TSTree *self) {
return self->padding.chars + self->size.chars;
}
static inline size_t ts_tree_total_bytes(const TSTree *self) {
return self->padding.bytes + self->size.bytes;
}
static inline TSLength ts_tree_total_size(const TSTree *self) {
return ts_length_add(self->padding, self->size);
}
static inline TSPoint ts_tree_total_extent(const TSTree *self) {
return ts_point_add(self->padding.extent, self->size.extent);
}
static inline bool ts_tree_is_fragile(const TSTree *tree) {
return tree->fragile_left || tree->fragile_right ||
ts_tree_total_chars(tree) == 0;