Require that grammars' start rules be visible

This commit is contained in:
Max Brunsfeld 2017-08-04 15:21:53 -07:00
parent 1dca3a0b58
commit 94dc703bfc
12 changed files with 64 additions and 56 deletions

View file

@ -159,10 +159,7 @@ void ts_document_invalidate(TSDocument *self) {
}
TSNode ts_document_root_node(const TSDocument *self) {
TSNode result = ts_node_make(self->tree, 0, 0, 0);
while (result.data && !((Tree *)result.data)->visible)
result = ts_node_named_child(result, 0);
return result;
return ts_node_make(self->tree, 0, 0, 0);
}
uint32_t ts_document_parse_count(const TSDocument *self) {

View file

@ -148,20 +148,11 @@ static Iterator iterator_new(TreePath *path, Tree *tree, const TSLanguage *langu
.child_index = 0,
.structural_child_index = 0,
}));
Iterator self = {
return (Iterator) {
.path = *path,
.language = language,
.visible_depth = 0,
.visible_depth = 1,
};
if (tree->visible) {
self.visible_depth++;
} else {
iterator_descend(&self, length_zero());
}
return self;
}
Length iterator_start_position(Iterator *self) {