pub struct Segment {
pub kind: SegmentKind,
pub range: TextRange,
pub lowered_range: TextRange,
pub header_start: Option<TextSize>,
}Expand description
One contiguous slice of the file. Produced by segment_file;
segments tile the file in source order.
Fields§
§kind: SegmentKind§range: TextRangeThe byte range this segment covers, doc-block extension included.
Ranges TILE the file (offset bookkeeping); the text a consumer
should PARSE is lowered_range.
lowered_range: TextRangeThe range to parse for this segment: range extended through the
trailing trivia up to the NEXT segment’s header token (or EOF).
The whole-file parse absorbs the trivia before a knot header —
blank lines, comments, and the next knot’s /// doc block — into
the PRECEDING knot’s node, so a fragment must end at the next
header for its node ranges to match the whole-file tree
byte-for-byte. Where the next boundary carries a doc block, this
makes adjacent lowered_ranges OVERLAP on the doc bytes: the doc
block is trailing trivia to this segment and doc attachment to the
next — both readings are what the whole-file parse does.
header_start: Option<TextSize>The byte offset of the header’s first = token — the position the
whole-file parse gives the corresponding KNOT_HEADER/
STITCH_HEADER node. None for the header segment.