Trait ezno_parser::ASTNode

source ·
pub trait ASTNode: Sized + Clone + PartialEq + Debug + Sync + Send + 'static {
    // Required methods
    fn get_position(&self) -> Span;
    fn from_reader(
        reader: &mut impl TokenReader<TSXToken, TokenStart>,
        state: &mut ParsingState,
        options: &ParseOptions
    ) -> ParseResult<Self>;
    fn to_string_from_buffer<T: ToString>(
        &self,
        buf: &mut T,
        options: &ToStringOptions,
        local: LocalToStringInformation
    );

    // Provided methods
    fn from_string(script: String, options: ParseOptions) -> ParseResult<Self> { ... }
    fn from_string_with_options(
        script: String,
        options: ParseOptions,
        offset: Option<u32>
    ) -> ParseResult<(Self, ParsingState)> { ... }
    fn to_string(&self, options: &ToStringOptions) -> String { ... }
}
Expand description

Defines common methods that would exist on a AST part include position in source, creation from reader and serializing to string from options.

TODO remove partial eq

Required Methods§

source

fn get_position(&self) -> Span

Returns position of node as span AS IT WAS PARSED. May be Span::NULL if AST was doesn’t match anything in source

source

fn from_reader( reader: &mut impl TokenReader<TSXToken, TokenStart>, state: &mut ParsingState, options: &ParseOptions ) -> ParseResult<Self>

source

fn to_string_from_buffer<T: ToString>( &self, buf: &mut T, options: &ToStringOptions, local: LocalToStringInformation )

Provided Methods§

source

fn from_string(script: String, options: ParseOptions) -> ParseResult<Self>

From string, with default impl to call abstract method from_reader

source

fn from_string_with_options( script: String, options: ParseOptions, offset: Option<u32> ) -> ParseResult<(Self, ParsingState)>

source

fn to_string(&self, options: &ToStringOptions) -> String

Returns structure as valid string

Object Safety§

This trait is not object safe.

Implementors§

source§

impl ASTNode for JSXAttribute

source§

impl ASTNode for JSXNode

source§

impl ASTNode for JSXRoot

source§

impl ASTNode for ClassMember

source§

impl ASTNode for Declaration

source§

impl ASTNode for ExportDeclaration

source§

impl ASTNode for ExportPart

source§

impl ASTNode for ImportPart

source§

impl ASTNode for VariableDeclaration

source§

impl ASTNode for BlockOrSingleStatement

source§

impl ASTNode for StatementOrDeclaration

source§

impl ASTNode for VariableField

source§

impl ASTNode for VariableIdentifier

source§

impl ASTNode for ExpressionOrBlock

source§

impl ASTNode for LHSOfAssignment

source§

impl ASTNode for VariableOrPropertyAccess

source§

impl ASTNode for Expression

source§

impl ASTNode for FunctionArgument

source§

impl ASTNode for MultipleExpression

source§

impl ASTNode for ObjectLiteralMember

source§

impl ASTNode for FunctionHeader

source§

impl ASTNode for ForLoopCondition

source§

impl ASTNode for Statement

source§

impl ASTNode for EnumMember

source§

impl ASTNode for InterfaceMember

source§

impl ASTNode for AnnotationWithBinder

source§

impl ASTNode for TypeAnnotation

source§

impl ASTNode for JSXElement

source§

impl ASTNode for JSXFragment

source§

impl ASTNode for ImportDeclaration

source§

impl ASTNode for ObjectLiteral

source§

impl ASTNode for ArrayElement

source§

impl ASTNode for TemplateLiteral

source§

impl ASTNode for FunctionBody

source§

impl ASTNode for IsExpression

source§

impl ASTNode for ConditionalElseStatement

source§

impl ASTNode for DoWhileStatement

source§

impl ASTNode for ForLoopStatement

source§

impl ASTNode for IfStatement

source§

impl ASTNode for SwitchStatement

source§

impl ASTNode for TryCatchStatement

source§

impl ASTNode for UnconditionalElseStatement

source§

impl ASTNode for VarVariableStatement

source§

impl ASTNode for WhileStatement

source§

impl ASTNode for Block

source§

impl ASTNode for Decorator

source§

impl ASTNode for Module

source§

impl ASTNode for DeclareVariableDeclaration

source§

impl ASTNode for EnumDeclaration

source§

impl ASTNode for InterfaceDeclaration

source§

impl ASTNode for Namespace

source§

impl ASTNode for TypeAlias

source§

impl ASTNode for TupleLiteralElement

source§

impl ASTNode for TypeAnnotationFunctionParameters

source§

impl ASTNode for TypeParameter

source§

impl<L, V> ASTNode for FunctionParameters<L, V>

source§

impl<N: ASTNode> ASTNode for Decorated<N>

source§

impl<T: FunctionBased + 'static> ASTNode for FunctionBase<T>

source§

impl<T: ASTNode> ASTNode for WithComment<T>

source§

impl<T: DestructuringFieldInto> ASTNode for ArrayDestructuringField<T>

source§

impl<T: DestructuringFieldInto> ASTNode for ObjectDestructuringField<T>

source§

impl<TExpr: DeclarationExpression + 'static> ASTNode for VariableDeclarationItem<TExpr>

source§

impl<U: PropertyKeyKind> ASTNode for PropertyKey<U>

source§

impl<U: ExpressionOrStatementPosition + Debug + PartialEq + Clone + 'static> ASTNode for ClassDeclaration<U>