Trait ezno_parser::ASTNode
source · pub trait ASTNode: Sized + Clone + PartialEq + Debug + Sync + Send + 'static {
// Required methods
fn get_position(&self) -> Cow<'_, Span>;
fn from_reader(
reader: &mut impl TokenReader<TSXToken, Span>,
state: &mut ParsingState,
settings: &ParseSettings
) -> ParseResult<Self>;
fn to_string_from_buffer<T: ToString>(
&self,
buf: &mut T,
settings: &ToStringSettingsAndData,
depth: u8
);
// Provided methods
fn from_string(
source: String,
settings: ParseSettings,
source_id: SourceId,
offset: Option<usize>,
cursors: Vec<(usize, EmptyCursorId)>
) -> ParseResult<ParseOutput<Self>> { ... }
fn to_string(&self, settings: &ToStringSettingsAndData) -> 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 settings.
TODO remove partial eq
Required Methods§
sourcefn get_position(&self) -> Cow<'_, Span>
fn get_position(&self) -> Cow<'_, Span>
Returns position of node as span AS IT WAS PARSED. May be none if AST was doesn’t match anything in source
fn from_reader( reader: &mut impl TokenReader<TSXToken, Span>, state: &mut ParsingState, settings: &ParseSettings ) -> ParseResult<Self>
fn to_string_from_buffer<T: ToString>( &self, buf: &mut T, settings: &ToStringSettingsAndData, depth: u8 )
Provided Methods§
sourcefn from_string(
source: String,
settings: ParseSettings,
source_id: SourceId,
offset: Option<usize>,
cursors: Vec<(usize, EmptyCursorId)>
) -> ParseResult<ParseOutput<Self>>
fn from_string( source: String, settings: ParseSettings, source_id: SourceId, offset: Option<usize>, cursors: Vec<(usize, EmptyCursorId)> ) -> ParseResult<ParseOutput<Self>>
From string, with default impl to call abstract method from_reader
sourcefn to_string(&self, settings: &ToStringSettingsAndData) -> String
fn to_string(&self, settings: &ToStringSettingsAndData) -> String
Returns structure as valid string