Skip to main content

Module index_queries

Module index_queries 

Source
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:

  1. Collisions — apply the edits to an overlay, re-run diagnose_project, refuse if a new diagnostic appears (no_new_diagnostics).
  2. 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§

CallRelation
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 calls key is a caller and sites are where it calls the queried symbol; for outgoing, key is a callee and sites are where the queried symbol calls it. The sites double as the LSP fromRanges (identical for both directions).
RenamePlan
A planned rename: every name-segment edit, grouped per file, spans ascending. The definition site is edited along with every reference.

Functions§

apply_edits
Apply one file’s edits (spans ascending) to its snapshot text.
capability_provider_lenses
v0.127 (editor-currency slice 6): a provider-count lens per capability definition in path, as (capability def, provider def sites). The count is providers.len(); the provider sites feed the same showReferences peek the reference lens uses. Reuses the implementations relation (the impls_of edge behind go-to-implementation), so a capability with no provider yields no lens. Sorted by definition position, alongside the reference lenses.
code_lenses
v0.33 (ADR 0066): codeLens — one reference-count lens per top-level definition in path, as (def site, reference sites). The count is refs.len(); the reference sites feed the showReferences action. 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 (the references query, file-scoped). The index does not distinguish read from write references, so the LSP layer omits the highlight kind.
implementations
v0.35 (ADR 0068): textDocument/implementation — the definition sites of every provider implementing the capability key, 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 of key, each with the call sites at which it calls key.
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.
named_type_target
The user-declared type a value’s type points at, for go-to-type-definition: a Named directly, 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 yield None.
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 — what key calls, each with the call sites within key at 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). None for out-of-scope positions.
prepare_rename
prepareRename: the renameable range under the cursor, or None for out-of-scope symbols (locals, unit names) — the request is refused rather than falling through to a partial rename.
refinement_family_lenses
v0.129 (#259): a refinement-family lens per refined/opaque Type definition in path, as (type def, base, family def sites) — every refined/opaque type (and plain alias) declared over the same builtin base, across the project. The family includes the type itself, so a lens is emitted only for a family of ≥ 2 (a lone refinement has nothing to navigate to — no lens, mirroring capability_provider_lenses). Sorted by definition position, alongside the reference lenses.
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.
resolve_doc_link
#848: resolve one intra-doc-link candidate name (from bynk_ide::symbols::scan_doc_link_candidates) against owner_unit’s doc-link scope order in doc_scope — the unit itself, then its uses targets, then its consumes targets (mirrors bynk_check::index::IndexBuilder::qualify_with’s bare-name qualification).
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 carries declaration) and foreign_refs (first-party references). range (byte offsets into text, the analysed snapshot) filters to overlapping tokens for the …/range request; None is 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 references surface.
type_definitions_named
Slice 6: textDocument/typeDefinition — the definition site(s) of the type named name (a Type symbol). The checker’s Ty::Named.name and 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.