pub struct Parse<T> { /* private fields */ }Expand description
The result of parsing: a syntax tree and a collection of errors.
This type is designed to be stored in Salsa databases as it contains
the thread-safe GreenNode instead of the non-thread-safe SyntaxNode.
Implementations§
Source§impl<T> Parse<T>
impl<T> Parse<T>
Sourcepub fn new(green: GreenNode, errors: Vec<String>) -> Parse<T>
pub fn new(green: GreenNode, errors: Vec<String>) -> Parse<T>
Create a new Parse result from a GreenNode and errors
Sourcepub fn new_with_positioned_errors(
green: GreenNode,
errors: Vec<String>,
positioned_errors: Vec<PositionedParseError>,
) -> Parse<T>
pub fn new_with_positioned_errors( green: GreenNode, errors: Vec<String>, positioned_errors: Vec<PositionedParseError>, ) -> Parse<T>
Create a new Parse result from a GreenNode, errors, and positioned errors
Sourcepub fn positioned_errors(&self) -> &[PositionedParseError]
pub fn positioned_errors(&self) -> &[PositionedParseError]
Get parse errors with position information
Sourcepub fn error_messages(&self) -> Vec<String>
pub fn error_messages(&self) -> Vec<String>
Get parse errors as strings (for backward compatibility if needed)
Sourcepub fn to_result(self) -> Result<T, ParseError>
pub fn to_result(self) -> Result<T, ParseError>
Convert to a Result, returning the tree if there are no errors
Sourcepub fn tree(&self) -> T
pub fn tree(&self) -> T
Get the parsed syntax tree
Returns the syntax tree even if there are parse errors.
Use errors() or positioned_errors() to check for errors if needed.
This allows for error-resilient tooling that can work with partial/invalid input.
Sourcepub fn syntax_node(&self) -> SyntaxNode<Lang>
pub fn syntax_node(&self) -> SyntaxNode<Lang>
Get the syntax node
Source§impl Parse<Deb822>
impl Parse<Deb822>
Sourcepub fn parse_deb822(text: &str) -> Parse<Deb822>
pub fn parse_deb822(text: &str) -> Parse<Deb822>
Parse deb822 text, returning a Parse result
Sourcepub fn reparse(&self, new_text: &str, edit: TextRange) -> Parse<Deb822>
pub fn reparse(&self, new_text: &str, edit: TextRange) -> Parse<Deb822>
Incrementally reparse after a text edit.
Given the new full text and the range that was edited (in the new text coordinates after the edit has been applied), this tries to reuse unchanged paragraphs from the previous parse and only reparse the affected region.
Falls back to a full reparse if the edit spans the entire file or if incremental reparsing is not beneficial.