pub struct CheckpointTable { /* private fields */ }Expand description
Per-document table of top-level block boundaries.
Built once per source version via CheckpointTable::build; the
LSP rebuilds on every didChange notification. Internally a sorted
Vec<BlockCheckpoint> with byte = 0 and a sentinel at
byte = source.len() as bookends, so Self::snap_to_block_boundaries
is branch-free at the bounds.
Implementations§
Source§impl CheckpointTable
impl CheckpointTable
Sourcepub fn build(source: &str) -> Result<Self, ParseError>
pub fn build(source: &str) -> Result<Self, ParseError>
Walk source once, recording one checkpoint per top-level
block. Cost: one pulldown event stream, one offset translation
per checkpoint, one Vec allocation.
§Errors
Returns ParseError if parser execution cannot safely
recognise the source.
Sourcepub fn build_with_options(
source: &str,
parse_options: ParseOptions,
) -> Result<Self, ParseError>
pub fn build_with_options( source: &str, parse_options: ParseOptions, ) -> Result<Self, ParseError>
Build a checkpoint table under explicit recognition policy.
§Errors
Returns ParseError if parser execution cannot safely
recognise the source under parse_options.
Sourcepub fn from_document(doc: &Document) -> Self
pub fn from_document(doc: &Document) -> Self
Build from an already parsed document.
Sourcepub fn snap_to_block_boundaries(&self, range: Range<u32>) -> Range<u32>
pub fn snap_to_block_boundaries(&self, range: Range<u32>) -> Range<u32>
Smallest [lo, hi) byte range that covers range and starts
and ends on a checkpoint. Always succeeds: empty / out-of-bounds
/ partial-block ranges all resolve to a well-defined slice (the
smallest superset; empty when the request is wholly past the
source end).