Skip to main content

Module index_queries

Module index_queries 

Source
Expand description

The pure binding-index queries live in [bynk_ide::index_queries] (#2520), where the hover ladder shared with bynk mcp reads them; this module keeps the old path working and adds the one query that builds lsp_types values.

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).
DocLinkContext
#2454: the declaration a doc comment is attached to, as far as link resolution needs it: attached is the byte offset of its name in path (bynk_ide::symbols::DocLinkSpan::attached), and locals that file’s local bindings, from which a fn / handler / op’s parameters are read, and text that file’s analysed source, which bounds the parameter list.
DocLinkMention
#2456: one doc-link mention in a source file that resolves to a definition (see doc_link_mentions).
DocLinkSuggestion
#2458: one name a doc link could be completed to.
RenamePlan
A planned rename: every name-segment edit, grouped per file, spans ascending. The definition site is edited along with every reference.
ResolvedDocLink
#2454: a resolved doc link — the definition site, and its index key when it has one (a parameter is a local binding, not an indexed symbol).

Enums§

DocLinkResolution
#2531: the outcome of resolve_doc_link_in.
HierarchyTarget
What prepareTypeHierarchy resolved the cursor to.

Constants§

DOC_LINK_BARE_KINDS
#848: the top-level kinds a bare doc-link name matches.
DOC_LINK_MEMBER_KINDS
#848: the flat compound-name member kinds ("Owner.member", built by bynk-emit’s assemble_index). A dotted doc-link name matches these verbatim — never split into owner/member.

Functions§

add_doc_link_edits
#2456: extend plan with the doc links that resolved to the renamed symbol before the rename, across every file in snapshots. A link to the symbol itself has its last segment rewritten ([Limiter], [Limiter.decide] when decide is renamed); when a type-like symbol is renamed, a link to one of its members has its owner segment rewritten ([Limiter.decide] when Limiter is). Display text and backticks are untouched, and a link that resolves to some other definition of the same name is left alone.
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).
doc_link_mentions
#2456: every doc-link mention in snapshots that resolves (through resolve_doc_link_in, with the declaration each comment is attached to as context, so a bare [field] in its own record’s doc counts) to the definition at target. locals is the round’s per-file local bindings.
doc_link_mentions_of
doc_link_mentions over several definitions at once: a mention is kept when it resolves to any of targets. Rename uses it to also catch [Type.member] links when the owning type is renamed.
doc_link_owner_declared
#2455: whether any unit in owner_unit’s doc-link scope declares a top-level symbol named owner (the part of a doc-link name before any .). A project declaration shadows a first-party name of the same spelling, so the first-party fallback must not run when this is true — even if resolve_doc_link_in declined (ambiguous, or a member miss).
doc_link_suggestions
#2458: the names a doc link in owner_unit could resolve, in resolution order — the single place completion defines that order:
doc_links_rebound
#2456 (decision C): after a rename, every doc link must resolve to the same definition it did before — modulo the rename itself. post_* describe the re-analysed project with the edits applied, post_texts the edited sources. A link that now resolves elsewhere, stops resolving, or starts resolving is a silent re-binding, reported like any other.
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.
own_part_names
#2459: the names resolve_doc_link_in resolves as the attached declaration’s own parts (member and parameter names, bare), for the did-you-mean candidates of the unresolved-link hint. Only names that resolve (a name defined as two member kinds is ambiguous, so never one).
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.
prepare_type_hierarchy
textDocument/prepareTypeHierarchy: the refined/opaque/alias type under the cursor, or the primitive named by the token under it (#2530) — a declaration’s base, a field or parameter type, anywhere it is written. text is path’s analysed snapshot. None for any other position, including a record or sum, which has no base.
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_in
#2454, #2531: the one doc-link resolver. A candidate resolves in order:
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). The names live in bynk_syntax::semantic_tokens, shared with the editor contract.
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.
type_subtypes
typeHierarchy/subtypes of a primitive: every refined, opaque or alias type declared over base across the project, sorted by definition position. An opaque type is listed only to requests from its declaring unit.
type_supertype
typeHierarchy/supertypes of a refined/opaque type: its builtin base and where the declaration writes it — the only supertype Bynk has (a base is always a primitive, never another declared type). None when the type has no base, or it is opaque and the request does not come from the declaring unit.
unit_of_file
The unit a source file belongs to, read off the first index symbol defined in it. None for a file that defines nothing.
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.