Trait rowan::ast::AstNode

source ·
pub trait AstNode {
    type Language: Language;

    // Required methods
    fn can_cast(kind: <Self::Language as Language>::Kind) -> bool
       where Self: Sized;
    fn cast(node: SyntaxNode<Self::Language>) -> Option<Self>
       where Self: Sized;
    fn syntax(&self) -> &SyntaxNode<Self::Language>;

    // Provided methods
    fn clone_for_update(&self) -> Self
       where Self: Sized { ... }
    fn clone_subtree(&self) -> Self
       where Self: Sized { ... }
}
Expand description

The main trait to go from untyped SyntaxNode to a typed AST. The conversion itself has zero runtime cost: AST and syntax nodes have exactly the same representation: a pointer to the tree root and a pointer to the node itself.

Required Associated Types§

Required Methods§

source

fn can_cast(kind: <Self::Language as Language>::Kind) -> bool
where Self: Sized,

source

fn cast(node: SyntaxNode<Self::Language>) -> Option<Self>
where Self: Sized,

source

fn syntax(&self) -> &SyntaxNode<Self::Language>

Provided Methods§

source

fn clone_for_update(&self) -> Self
where Self: Sized,

source

fn clone_subtree(&self) -> Self
where Self: Sized,

Implementors§