Skip to main content

reparse_or_parse

Function reparse_or_parse 

Source
pub fn reparse_or_parse(
    old_source: &str,
    old_root: Option<&SyntaxNode>,
    edit: &TextEdit,
) -> Option<SyntaxNode>
Expand description

Apply a text edit and reparse incrementally, or fall back to full parse.

Applies edit to old_source to obtain the new source. If old_root is Some, tries reparse; on success returns the new root. On reparse failure or when old_root is None, runs parse on the new source and returns the result. Use in LSP or editors to update the tree after a single range-based change.