Skip to main content

Module trivia

Module trivia 

Source
Expand description

Shared trivia recovery: turns the raw source text of a grammatically-constrained gap (whitespace, comments, and a known fixed sequence of literal tokens) into an ordered sequence of GapPieces, and converts proc_macro2 span positions to byte offsets. Used by cel-parser’s own expression formatter and by adam-lang’s declaration formatter, so both recover comments the same way. See https://github.com/stlab/cel-rs/issues/201.

Enums§

Comment
A recovered ////* */ comment, remembering which delimiter style the source used so a formatter can reproduce it instead of normalizing every comment to one style.
GapPiece
One element of a scanned gap: either a recovered comment or one of the literal tokens the caller declared it expected to find there.

Functions§

line_column_to_byte
Converts a LineColumn (1-based line, 0-based character column) to a byte offset in source, using line_starts (from line_start_byte_offsets).
line_start_byte_offsets
Returns the byte offset of the start of each line in source: result[line - 1] is the start of 1-based line line (matching proc_macro2::LineColumn::line’s convention).
scan_gap
Scans the raw text of a grammatically-constrained gap — whitespace, ////* */ comments, and exactly the literal tokens in expected, in that order — returning every comment found plus every expected token, interleaved in source order. Block comments nest; their inner delimiters and text remain intact apart from per-line whitespace normalization.