pub trait NodeTypes {
// Required methods
fn root(&self) -> Option<u16>;
fn is_extra(&self, node_type_id: u16) -> bool;
fn has_field(&self, node_type_id: u16, node_field_id: NonZero<u16>) -> bool;
fn field_cardinality(
&self,
node_type_id: u16,
node_field_id: NonZero<u16>,
) -> Option<Cardinality>;
fn valid_field_types(
&self,
node_type_id: u16,
node_field_id: NonZero<u16>,
) -> &[u16];
fn is_valid_field_type(
&self,
node_type_id: u16,
node_field_id: NonZero<u16>,
child: u16,
) -> bool;
fn children_cardinality(&self, node_type_id: u16) -> Option<Cardinality>;
fn valid_child_types(&self, node_type_id: u16) -> &[u16];
fn is_valid_child_type(&self, node_type_id: u16, child: u16) -> 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.