Indexed references: postings replace the per-request refactor walk
textDocument/references now reads declaration-to-occurrence postings merged in WorkspaceIndex from compact per-file reference facts, with open buffers overlaying live semantics — 0.062 ms/request over 820 files vs 21.7 ms for the old Workspace::sources() walk (~350x). The walk stays as rename's engine and the equivalence oracle in tests. FACTS_FORMAT 1->2 discards v1 caches whole. Cursor lookups (symbol_at/reference_at/token_at) and macro-define lookup move to binary-searched sorted tables; include definition inspects only the cursor's line. Ambiguity refusals preserved throughout. External dev: codex. Lead-reviewed, gates re-run, probe reproduced. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
27fc216df3
commit
b2d778eb8d
13 files changed
+768
-81
No files matched your search
@@ -9,7 +9,9 @@ paths that could finish it — 19.6 % of every use on cleanly-parsed corpus file
|
||||
that finishes them. `WorkspaceIndex::build` scans every file in the workspace
|
||||
once and records what each one *declares* — modules, packages, file-scope
|
||||
typedefs, each package's and module's exported members, and each file's
|
||||
`` `define`` table. `resolve_external` walks one file's external candidates
|
||||
`` `define`` table. Since 2026-08-27 it also records compact reference facts
|
||||
and merges them into declaration-to-occurrence postings. `resolve_external`
|
||||
walks one file's external candidates
|
||||
against that index and answers them in an **overlay** keyed by reference id.
|
||||
That is what turns `import prim_pkg::*` and `prim_fifo_sync u_fifo (...)` into
|
||||
a jump into the file that declares them — TODO.md §6's "cross-file resolution
|
||||
@@ -25,12 +27,15 @@ impl WorkspaceIndex {
|
||||
|
||||
fn files(&self) -> &[PathBuf]; // indexed by FileId
|
||||
fn path(&self, FileId) -> Option<&Path>;
|
||||
fn file_id(&self, &Path) -> Option<FileId>; // 2026-08-27
|
||||
fn units(&self, name: &str) -> &[Def]; // module | package | file-scope typedef
|
||||
fn member(&self, unit: &str, member: &str) -> &[Def];
|
||||
fn members_of(&self, unit: &str) -> impl Iterator<Item = (&str, &[Def])>;
|
||||
fn defines(&self, FileId) -> Option<&DefineTable>;
|
||||
fn instantiations_of(&self, name: &str) -> &[InstantiationEdge]; // 2026-08-27
|
||||
fn subclasses_of(&self, name: &str) -> &[InheritanceEdge]; // 2026-08-27
|
||||
fn references_to(&self, def: &Def) -> &[ReferenceSite]; // 2026-08-27
|
||||
fn references_are_ambiguous(&self, def: &Def) -> bool; // 2026-08-27
|
||||
fn update_file(&mut self, PathBuf, src: &str); // 2026-08-27
|
||||
fn remove_file(&mut self, &Path) -> bool; // 2026-08-27
|
||||
fn fingerprint(&self) -> String; // 2026-08-27
|
||||
@@ -145,6 +150,11 @@ written"). Ambiguity means something else — see below.
|
||||
module stays unreachable, which is correct and is a test.
|
||||
- **`` `define`` tables**: `defines::collect_defines` per file, keyed by
|
||||
`FileId`, read off the same token stream the parse used.
|
||||
- **Reference postings**: uses of the externally reachable declarations above.
|
||||
Each file persists local declaration/use span pairs and unresolved external
|
||||
candidates; after every build or incremental update, the merged declaration
|
||||
tables resolve those compact facts into `DefinitionKey -> [ReferenceSite]`.
|
||||
Ambiguous candidates are marked rather than assigned to a guessed target.
|
||||
|
||||
A declaration whose `name_span` is empty (the single-file layer's "I could not
|
||||
locate this name in the source") is **not** indexed: an editor must never be
|
||||
@@ -407,10 +417,23 @@ and more than half of all external candidates answered on clean files.
|
||||
equal to a whole build; instantiation and inheritance edge tables
|
||||
(`instantiations_of`, `subclasses_of`); `fingerprint` as the equivalence
|
||||
witness
|
||||
- [x] 2026-08-27 (`references-nav` performance): persisted reference facts,
|
||||
declaration-to-occurrence postings, ambiguity markers and indexed macro
|
||||
lookup; reference postings included in the incremental fingerprint
|
||||
- [ ] Deferred (non-goals above): `` `include`` graph, elaboration
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-08-27 — indexed navigation.** `FileFacts` gained compact local and
|
||||
external reference records and its persisted format moved to version 2.
|
||||
`WorkspaceIndex` resolves them into reverse postings after declaration tables
|
||||
are merged, including on an incremental update, without rereading or reparsing
|
||||
other files. The public query is `references_to`; ambiguous external uses are
|
||||
tracked separately so navigation preserves the existing rename refusal. Three
|
||||
focused tests cover postings, incremental/full-build equivalence, and
|
||||
ambiguity, while the record round-trip and corpus acceptance cover persistence
|
||||
and real-source scale.
|
||||
|
||||
**2026-08-26 — overlay-promotion dev agent (lead-authorized, cross-module).**
|
||||
`resolve_external` gained one arm: an `InheritedCandidate`'s paths are tried
|
||||
like an external candidate's, and an entry is recorded only when one lands, so
|
||||
|
||||
Reference in new issue
Block a user