pub trait NodeTypes {
// Required methods
fn root(&self) -> Option<NodeTypeId>;
fn is_extra(&self, node_type_id: NodeTypeId) -> bool;
fn has_field(
&self,
node_type_id: NodeTypeId,
node_field_id: NodeFieldId,
) -> bool;
fn field_cardinality(
&self,
node_type_id: NodeTypeId,
node_field_id: NodeFieldId,
) -> Option<Cardinality>;
fn valid_field_types(
&self,
node_type_id: NodeTypeId,
node_field_id: NodeFieldId,
) -> &[NodeTypeId] ⓘ;
fn is_valid_field_type(
&self,
node_type_id: NodeTypeId,
node_field_id: NodeFieldId,
child: NodeTypeId,
) -> bool;
fn children_cardinality(
&self,
node_type_id: NodeTypeId,
) -> Option<Cardinality>;
fn valid_child_types(&self, node_type_id: NodeTypeId) -> &[NodeTypeId] ⓘ;
fn is_valid_child_type(
&self,
node_type_id: NodeTypeId,
child: NodeTypeId,
) -> bool;
}Expand description
Trait for node type constraint lookups.
Provides only what tree-sitter’s Language API doesn’t:
- Root node identification
- Extra nodes (comments, whitespace)
- Field constraints per node type
- Children constraints per node type
For name↔ID resolution and supertype info, use Language directly.