NodeTypes

Trait NodeTypes 

Source
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.

Required Methods§

Source

fn root(&self) -> Option<u16>

Source

fn is_extra(&self, node_type_id: u16) -> bool

Source

fn has_field(&self, node_type_id: u16, node_field_id: NonZero<u16>) -> bool

Source

fn field_cardinality( &self, node_type_id: u16, node_field_id: NonZero<u16>, ) -> Option<Cardinality>

Source

fn valid_field_types( &self, node_type_id: u16, node_field_id: NonZero<u16>, ) -> &[u16]

Source

fn is_valid_field_type( &self, node_type_id: u16, node_field_id: NonZero<u16>, child: u16, ) -> bool

Source

fn children_cardinality(&self, node_type_id: u16) -> Option<Cardinality>

Source

fn valid_child_types(&self, node_type_id: u16) -> &[u16]

Source

fn is_valid_child_type(&self, node_type_id: u16, child: u16) -> bool

Implementations on Foreign Types§

Source§

impl<T> NodeTypes for &T
where T: NodeTypes + ?Sized,

Source§

fn root(&self) -> Option<u16>

Source§

fn is_extra(&self, node_type_id: u16) -> bool

Source§

fn has_field(&self, node_type_id: u16, node_field_id: NonZero<u16>) -> bool

Source§

fn field_cardinality( &self, node_type_id: u16, node_field_id: NonZero<u16>, ) -> Option<Cardinality>

Source§

fn valid_field_types( &self, node_type_id: u16, node_field_id: NonZero<u16>, ) -> &[u16]

Source§

fn is_valid_field_type( &self, node_type_id: u16, node_field_id: NonZero<u16>, child: u16, ) -> bool

Source§

fn children_cardinality(&self, node_type_id: u16) -> Option<Cardinality>

Source§

fn valid_child_types(&self, node_type_id: u16) -> &[u16]

Source§

fn is_valid_child_type(&self, node_type_id: u16, child: u16) -> bool

Implementors§