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 →Commentfolds. Spans come from the lexer’sCommenttokens (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.parentwidens 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 🔒