Skip to main content

AstNode

Trait 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 method
    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_subtree(&self) -> Self
where Self: Sized,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AstNode for Arg

Source§

impl AstNode for ArgList

Source§

impl AstNode for Argument

Source§

impl AstNode for AssignmentExpr

Source§

impl AstNode for BinaryExpr

Source§

impl AstNode for BlockExpr

Source§

impl AstNode for CallExpr

Source§

impl AstNode for CommentLine

Source§

impl AstNode for Conditional

Source§

impl AstNode for arity_parser::dcf::ast::Document

Source§

impl AstNode for arity_parser::rd::ast::Document

Source§

impl AstNode for Field

Source§

impl AstNode for ForExpr

Source§

impl AstNode for FunctionExpr

Source§

impl AstNode for Group

Source§

impl AstNode for IfExpr

Source§

impl AstNode for Macro

Source§

impl AstNode for MalformedLine

Source§

impl AstNode for Option

Source§

impl AstNode for ParenExpr

Source§

impl AstNode for Record

Source§

impl AstNode for RepeatExpr

Source§

impl AstNode for Root

Source§

impl AstNode for RoxygenBlock

Source§

impl AstNode for RoxygenParagraph

Source§

impl AstNode for RoxygenSection

Source§

impl AstNode for RoxygenTag

Source§

impl AstNode for Subset2Expr

Source§

impl AstNode for SubsetExpr

Source§

impl AstNode for UnaryExpr

Source§

impl AstNode for ValueLine

Source§

impl AstNode for WhileExpr