Skip to main content

Module structure

Module structure 

Source
Expand description

v0.37 (ADR 0070): structural ranges — textDocument/foldingRange and textDocument/selectionRange.

Both read the per-file recovered AST (the document-symbols parse path) and share one span visitor (collect): every node contributes its (span, foldable) pair. Folding keeps the multi-line block-like nodes (foldable); selection keeps every span containing the cursor and nests them. Neither touches the binding index or the analysis round — they parse the live document, so they answer even when the project doesn’t check.

Functions§

collect 🔒
Every AST node’s span paired with whether it is a folding candidate (a multi-line block-like construct). Non-candidate spans are still collected — selection chains need the fine-grained leaves. Empty when the file has no recognisable header (recovery returned nothing).
comment_folds 🔒
Multi-line runs of consecutive -- line comments → Comment folds. Spans come from the lexer’s Comment tokens (the trivia table keeps only bodies), grouped while each comment sits on the line immediately after the previous.
fold 🔒
folding_ranges
textDocument/foldingRange — the structural multi-line constructs plus multi-line comment runs. A range is emitted only when it spans more than one line (LSP folds ≥2 lines); duplicate (start, end) line pairs (a decl and its body sharing both lines) collapse to one.
selection_at 🔒
selection_ranges
textDocument/selectionRange — for each position, the chain of enclosing AST node ranges, innermost first (each .parent widens outward to the file). Falls back to an empty range at the cursor when no node contains it (e.g. trailing whitespace) or the file doesn’t parse.
walk_block 🔒
walk_expr 🔒
walk_item 🔒
walk_unit 🔒