pub struct ParsedFile { /* private fields */ }Expand description
An owned typed CST together with the source identity and original input.
ParsedFile::from_source selects the Tree-sitter adapter, while
ParsedFile::from_source_native selects the direct precedence parser. After
parsing, callers may mutate Self::cst_mut or use Self::edit, then
project the resulting tree through Self::token_stream,
Self::cell_stream, or Self::to_source.
The original string is retained as an immutable snapshot for diagnostics.
Current emission is normalized by ToTokens; it will become lossless as
trivia ownership is completed in the typed graph.
Implementations§
Source§impl ParsedFile
impl ParsedFile
Sourcepub fn from_source(source: impl Into<String>) -> Result<Self, ParseError>
pub fn from_source(source: impl Into<String>) -> Result<Self, ParseError>
Parses source with the Tree-sitter adapter and a fresh source identity.
Sourcepub fn from_source_with_id(
source: impl Into<String>,
source_id: SourceId,
) -> Result<Self, ParseError>
pub fn from_source_with_id( source: impl Into<String>, source_id: SourceId, ) -> Result<Self, ParseError>
Parses source with the Tree-sitter adapter and an explicit source id.
Sourcepub fn from_source_native(
source: impl Into<String>,
) -> Result<Self, NativeParseError>
pub fn from_source_native( source: impl Into<String>, ) -> Result<Self, NativeParseError>
Parses source with the native precedence parser and a fresh source identity.
Sourcepub fn from_source_native_with_id(
source: impl Into<String>,
source_id: SourceId,
) -> Result<Self, NativeParseError>
pub fn from_source_native_with_id( source: impl Into<String>, source_id: SourceId, ) -> Result<Self, NativeParseError>
Parses source with the native precedence parser and an explicit source id.
Sourcepub fn original_source(&self) -> &str
pub fn original_source(&self) -> &str
Returns the input snapshot exactly as supplied to the parser.
Sourcepub fn cst(&self) -> &SourceFile
pub fn cst(&self) -> &SourceFile
Borrows the generated typed CST root.
Sourcepub fn cst_mut(&mut self) -> &mut SourceFile
pub fn cst_mut(&mut self) -> &mut SourceFile
Mutably borrows the generated typed CST root.
Sourcepub fn edit(self, edit: impl FnOnce(&mut SourceFile)) -> Self
pub fn edit(self, edit: impl FnOnce(&mut SourceFile)) -> Self
Applies an edit and returns the file for further method chaining.
Sourcepub fn into_cst(self) -> SourceFile
pub fn into_cst(self) -> SourceFile
Consumes the facade and returns its generated typed CST.
Sourcepub fn token_stream(&self) -> TokenStream
pub fn token_stream(&self) -> TokenStream
Flattens the current CST into one token stream.
Sourcepub fn cell_stream(&self) -> CellStream
pub fn cell_stream(&self) -> CellStream
Flattens the current CST into its linearly ordered cells.
Sourcepub fn pretty_tokens(&self) -> String
pub fn pretty_tokens(&self) -> String
Formats the current raw token representation as a recursively flattened table with explicit group boundaries.
Sourcepub fn pretty_cst(&self) -> String
pub fn pretty_cst(&self) -> String
Formats the complete generated typed CST as a Unicode tree.
Sourcepub fn pretty_report(&self) -> PrettyReport<'_>
pub fn pretty_report(&self) -> PrettyReport<'_>
Builds a combined source, flat-token, and typed-CST inspection report.
Sourcepub fn print_pretty(&self) -> Result<()>
pub fn print_pretty(&self) -> Result<()>
Prints the combined report to standard output, enabling ANSI styling only when standard output is an interactive terminal.
Trait Implementations§
Source§impl AsMut<SourceFile> for ParsedFile
impl AsMut<SourceFile> for ParsedFile
Source§fn as_mut(&mut self) -> &mut SourceFile
fn as_mut(&mut self) -> &mut SourceFile
Source§impl AsRef<SourceFile> for ParsedFile
impl AsRef<SourceFile> for ParsedFile
Source§fn as_ref(&self) -> &SourceFile
fn as_ref(&self) -> &SourceFile
Source§impl Debug for ParsedFile
impl Debug for ParsedFile
Source§impl Display for ParsedFile
impl Display for ParsedFile
Source§impl ToCells for ParsedFile
impl ToCells for ParsedFile
Source§fn to_cells(&self, output: &mut CellStream)
fn to_cells(&self, output: &mut CellStream)
output.