pub struct ParsedDocument { /* private fields */ }Expand description
A parsed .pactole source text, holding the original source, the
tree-sitter concrete syntax tree, and any syntax diagnostics collected
while walking the tree.
Parsing is tolerant: it always succeeds and produces a tree, even for
invalid input. Errors are surfaced as SyntaxDiagnostics rather than
as a Result::Err.
Implementations§
Source§impl ParsedDocument
impl ParsedDocument
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Whether the concrete syntax tree contains any ERROR or MISSING node.
Sourcepub fn diagnostics(&self) -> &[SyntaxDiagnostic]
pub fn diagnostics(&self) -> &[SyntaxDiagnostic]
The syntax diagnostics collected while walking the tree, in document order.
Sourcepub fn into_result(self) -> Result<Self, Vec<SyntaxDiagnostic>>
pub fn into_result(self) -> Result<Self, Vec<SyntaxDiagnostic>>
Converts this parsed document into a strict Result: Ok(self) if
the concrete syntax tree contains no ERROR/MISSING node, or
Err with the collected diagnostics otherwise.
This is a convenience for consumers (such as pactole-storage-fs)
that only want to proceed on a syntactically clean document, without
duplicating the has_errors check themselves.