Expand description
v0.25 (ADR 0053): pure queries over the project binding index.
Everything here is a pure function over ProjectIndex + analysed
snapshot texts — the unit-testable core behind textDocument/references
and rename/prepareRename. Transport-side handlers in main.rs only
convert positions and package results.
Rename is validated two ways, both correct-by-construction:
- Collisions — apply the edits to an overlay, re-run
diagnose_project, refuse if a new diagnostic appears (no_new_diagnostics). - Capture/escape — re-analysis alone misses silent re-binding
(declared fns shadow fn-typed locals in call position), so the
re-built index must equal the pre-index modulo the rename
(
index_unchanged_modulo_rename).
Structs§
- Call
Relation - v0.34 (ADR 0067): one end of a call-hierarchy relation — the related
symbol (
key+ its definition site) and the call sites linking it to the queried symbol. For incoming callskeyis a caller andsitesare where it calls the queried symbol; for outgoing,keyis a callee andsitesare where the queried symbol calls it. The sites double as the LSPfromRanges(identical for both directions). - Rename
Plan - A planned rename: every name-segment edit, grouped per file, spans ascending. The definition site is edited along with every reference.
Constants§
- MOD_
DECLARATION 🔒 - MOD_
OPAQUE 🔒 - MOD_
PLATFORM_ 🔒NATIVE - MOD_
REFINED 🔒 - TOK_
LOCAL 🔒 - Legend index of the
variabletoken type (locals; ADR 0064).
Functions§
- apply_
edits - Apply one file’s edits (spans ascending) to its snapshot text.
- code_
lenses - v0.33 (ADR 0066):
codeLens— one reference-count lens per top-level definition inpath, as(def site, reference sites). The count isrefs.len(); the reference sites feed theshowReferencesaction. Sorted by definition position (a stable, top-to-bottom lens order). - definition_
at - The definition site for the symbol at the cursor (an index-backed, binding-correct go-to-definition).
- document_
highlights - v0.26 rider (ADR 0055):
documentHighlight— the symbol-at-cursor’s occurrences within that same file (thereferencesquery, file-scoped). The index does not distinguish read from write references, so the LSP layer omits the highlightkind. - group_
calls 🔒 - Group
edgesby the key returned bypick, attach each grouped symbol’s definition, and collect the call sites — the shared core of incoming and outgoing calls. Groups with no indexed definition are dropped (defensive; every call-edge endpoint is an index symbol by construction). Groups are ordered by definition position for a stable, top-to-bottom listing. - implementations
- v0.35 (ADR 0068):
textDocument/implementation— the definition sites of every provider implementing the capabilitykey, sorted by definition position. Empty for a non-capability or unknown key (the request then falls through; goto-def still serves the reverse, provider → capability). - incoming_
calls - v0.34 (ADR 0067):
callHierarchy/incomingCalls— the callers ofkey, each with the call sites at which it callskey. - index_
unchanged_ modulo_ rename - Validator (2): the re-built index must equal the pre-index modulo the rename — every other symbol’s reference set identical (after remapping shifted spans), the renamed symbol’s sites exactly the edited ones. Catches silent re-binding (capture/escape) that produces no diagnostic.
- key_
segment 🔒 - The member segment of a (possibly compound) key name — the text the rename actually edits (every site span covers exactly this).
- modifier_
bits 🔒 - named_
type_ target - The user-declared type a value’s type points at, for go-to-type-definition:
a
Nameddirectly, or the element of a single-parameter container (Option/Effect/List/HttpResult) unwrapped to it. Built-in, function, actor, and two-parameter (Result/Map) types have no single type-declaration target and yieldNone. - no_
new_ diagnostics - Validator (1): refuse when the edited project carries a diagnostic the original did not — compared as per-(file, category) counts, robust to span shifts. Removals are tolerated; additions refuse.
- outgoing_
calls - v0.34 (ADR 0067):
callHierarchy/outgoingCalls— whatkeycalls, each with the call sites withinkeyat which the callee is called. - plan_
rename - Build the rename plan for the symbol at the cursor. Errors are human-readable strings surfaced as LSP request failures.
- prepare_
call_ hierarchy - v0.34 (ADR 0067):
prepareCallHierarchy— the symbol under the cursor and its definition site (the goto-def resolution; an item is anchored on the definition).Nonefor out-of-scope positions. - prepare_
rename prepareRename: the renameable range under the cursor, orNonefor out-of-scope symbols (locals, unit names) — the request is refused rather than falling through to a partial rename.- remap_
site - The post-edit position of a pre-edit site — rename edits shift spans within edited files. An edited span maps to the new name’s span.
- renamed_
key_ 🔒name - The post-rename value of a (possibly compound) key name: for a member key
"Type.method", replace the segment after the last.; for a bare name, the new name as-is. - semantic_
tokens - Semantic tokens for
path, delta-encoded over the frozen legend — a pure read of the cached index’s two sources:symbols(user defs+refs; a def site carriesdeclaration) andforeign_refs(first-party references).range(byte offsets intotext, the analysed snapshot) filters to overlapping tokens for the…/rangerequest;Noneis the full document. - semantic_
tokens_ legend - The frozen semantic-tokens legend. Array order is the wire encoding
(clients index into these arrays): entries are append-only, never
reordered — pinned by the legend-stability test. Token types: standard
where faithful (
type,function), custom for the Bynk-distinctive kinds (capability,service,agent,provider). - sites_
for - Definition first, then references — the
referencessurface. - token_
type_ 🔒index - Legend indices/bits — must mirror
semantic_tokens_legend’s order. - type_
definitions_ named - Slice 6:
textDocument/typeDefinition— the definition site(s) of the type namedname(aTypesymbol). The checker’sTy::Named.nameand the index both use bare names, so this is a bare-name match; a name shared across units yields several locations (the LSP-conventional resolution — the client lets the user choose). Sorted by definition position. - validate_
new_ name - A new name must lex as exactly one identifier (keywords lex as their own token kinds, so they fail this check).
- workspace_
symbols - v0.26 rider (ADR 0055):
workspace/symbol— every index definition whose name contains the query, case-insensitive (an empty query lists all), sorted by (name, unit) for a stable order.