Skip to main content

reparse_edits

Function reparse_edits 

Source
pub fn reparse_edits(
    old_root: &SyntaxNode,
    old_text: &str,
    old_diags: &[ParseDiagnostic],
    edits: &[Edit],
    target: &str,
) -> Option<Reparsed>
Expand description

Chain the single-edit reparse over a sequence of edits (each expressed against the text its predecessors produced, in the order Edit::apply would run them). Each step reparses off the previous step’s whole-file tree, so N disjoint edits each reparse their own tight region instead of collapsing into one wide diff_edit span (the whole point of feeding precise LSP edits through — multi-cursor and find-replace).

Returns None unless every step is incrementally reparseable and the fully-applied text equals target. The == target check is the Tenet-4 safety net: an edit sequence that does not actually transform old_text into the current buffer (a coalescing gap, an interleaved disk write, a full-document replacement, a range the text cannot even hold) is rejected here so the caller falls back to the always-correct diff_edit path. A successful result is therefore byte-identical to a full parse of target — the composition of correct single-edit reparses over the true edit sequence.