Make it clear which field of TSNode can be used as a unique id

This commit is contained in:
Max Brunsfeld 2018-05-16 16:20:33 -07:00
parent e3670be42f
commit 95be6e3bee
2 changed files with 14 additions and 11 deletions

View file

@ -17,7 +17,8 @@ typedef struct {
TSNode ts_node_new(const TSTree *tree, const Subtree *subtree, Length position, TSSymbol alias) {
return (TSNode) {
{position.bytes, position.extent.row, position.extent.column, alias},
{tree, subtree},
subtree,
tree,
};
}
@ -27,14 +28,6 @@ static inline TSNode ts_node__null() {
// TSNode - accessors
static inline const TSTree *ts_node__tree(const TSNode *self) {
return self->ref[0];
}
static inline const Subtree *ts_node__subtree(TSNode self) {
return self.ref[1];
}
static inline uint32_t ts_node__byte(const TSNode *self) {
return self->context[0];
}
@ -47,6 +40,14 @@ static inline uint32_t ts_node__alias(const TSNode *self) {
return self->context[3];
}
static inline const Subtree *ts_node__subtree(TSNode self) {
return self.id;
}
static inline const TSTree *ts_node__tree(const TSNode *self) {
return self->tree;
}
// NodeChildIterator
static inline NodeChildIterator ts_node_child_iterator_begin(const TSNode *node) {