Skip to main content

NodeAccess

Trait NodeAccess 

Source
pub trait NodeAccess {
    // Required methods
    fn node_info(&self, index: NodeIndex) -> Option<NodeInfo>;
    fn kind(&self, index: NodeIndex) -> Option<u16>;
    fn pos_end(&self, index: NodeIndex) -> Option<(u32, u32)>;
    fn get_identifier_text(&self, index: NodeIndex) -> Option<&str>;
    fn get_literal_text(&self, index: NodeIndex) -> Option<&str>;
    fn get_children(&self, index: NodeIndex) -> Vec<NodeIndex>;

    // Provided method
    fn exists(&self, index: NodeIndex) -> bool { ... }
}
Expand description

Trait for unified access to AST nodes across different arena implementations. This allows consumers (binder, checker, emitter) to work with either different arena implementations without code changes.

Required Methods§

Source

fn node_info(&self, index: NodeIndex) -> Option<NodeInfo>

Get basic node information by index

Source

fn kind(&self, index: NodeIndex) -> Option<u16>

Get the syntax kind of a node

Source

fn pos_end(&self, index: NodeIndex) -> Option<(u32, u32)>

Get the source position range

Source

fn get_identifier_text(&self, index: NodeIndex) -> Option<&str>

Get identifier text (if this is an identifier node)

Source

fn get_literal_text(&self, index: NodeIndex) -> Option<&str>

Get literal value text (if this is a literal node)

Source

fn get_children(&self, index: NodeIndex) -> Vec<NodeIndex>

Get children of a node (for traversal)

Provided Methods§

Source

fn exists(&self, index: NodeIndex) -> bool

Check if a node exists

Implementors§

Source§

impl NodeAccess for NodeArena

Implementation of NodeAccess for NodeArena