Skip to main content

Module type_query

Module type_query 

Source
Expand description

Position → resolved-type queries backed by mir’s body analysis.

mir’s FileAnalyzer::analyze already resolves a mir_analyzer::Type for every expression it visits and records it as a mir_analyzer::ResolvedSymbol (see DocumentStore::cached_analysis, which retains the result across LSP requests). This module is the thin glue that maps an LSP cursor onto those recorded symbols — replacing the hand-rolled, short-name-only tracker in type_map for the variable/expression-type cases.

§Contract callers must respect

mir symbol spans are end-exclusive and identifier-only: the variable $q at bytes 76..78 is found by symbol_at(76) or symbol_at(77) but not symbol_at(78). Callers must pass a byte offset that lands strictly inside the token of interest — for a variable, word_range_at(..).start (the $) is always inside. The primitive is intentionally dumb: it does no offset fudging, because only the caller has the AST context to pick a correct in-token offset without grabbing an adjacent token.