pub struct Parse { /* private fields */ }Expand description
What came out of parsing a file.
Implementations§
Source§impl Parse
impl Parse
Sourcepub fn syntax(&self) -> Arc<SyntaxNode> ⓘ
pub fn syntax(&self) -> Arc<SyntaxNode> ⓘ
The tree, always present — a file that fails to parse still has one, with its bad ranges as error nodes.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Everything wrong with the input, in source order.
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Whether anything was wrong.
Sourcepub fn prepend_diagnostics(&mut self, diagnostics: Vec<Diagnostic>)
pub fn prepend_diagnostics(&mut self, diagnostics: Vec<Diagnostic>)
Put diagnostics ahead of the ones already there.
For the preprocessor’s, which explain most of what the parser then makes of the result.
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Reconstruct the source. Equals the input byte for byte, whether or not it parsed. Spec §2.2.
Sourcepub fn source_span(&self, tree: Span) -> Span
pub fn source_span(&self, tree: Span) -> Span
A range of the tree as a range of the source the parser read.
The same range for a file parsed with parse, whose tree is the
file byte for byte. Not for parse_preprocessed: the expanded
text puts one space between two tokens and the tree holds the
tokens without it, and a pragma’s text stands after the token it
leads there and before it here. A node’s range in the tree — what
lowering records — is an offset into neither file nor expanded
text until it passes through this.
Each end is moved by the piece of text that holds it; an end past the last piece stays at the end of that piece.