Skip to main content

reparse

Function reparse 

Source
pub fn reparse(
    prev_text: &str,
    prev_green: &GreenNode,
    prev_diags: &[ParseDiagnostic],
    edit: &Edit,
    new_text: &str,
) -> Option<Reparsed>
Expand description

Attempt an incremental reparse of the previous parse (prev_green, parsed from prev_text with prev_diags) under edit, which transforms prev_text into new_text. Returns None when no incremental strategy applies — the caller must then do a full parse.

In debug builds every successful reparse is checked against a full parse of new_text (Tenet 4): tree fingerprint and diagnostics vector must be identical.

edit is not trusted, for the same reason reparse_edits’s chain is not: one that does not fit prev_text — a stale range, a buffer that moved underneath it — is rejected here rather than applied at offsets that would panic on a slice.