Skip to content

Commit 50245a4

Browse files
committed
Clean up old references to renamed maps
1 parent a099ec8 commit 50245a4

36 files changed

Lines changed: 214 additions & 210 deletions

docs/todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ unlikely to move the needle for most users.
171171
| P5 | `memmap2` for file reads during scanning | Low | Low |
172172
| P6 | O(n²) transitive eviction in `evict_fqn` | Low | Low |
173173
| P7 | `diag_pending_uris` uses `Vec::contains` for dedup | Low | Low |
174-
| P8 | `find_class_in_ast_map` linear fallback scan | Low | Low |
174+
| P8 | `find_class_in_uri_classes_index` linear fallback scan | Low | Low |
175175
| P12 | [`find_or_load_function` Phase 1.75 serial bottleneck](todo/performance.md#p12-find_or_load_function-phase-175-serial-bottleneck) | Low | Low |
176176
| P17 | [`mago-names` resolution on the parse hot path](todo/performance.md#p17-mago-names-resolution-on-the-parse-hot-path) | Medium | Low |
177177
| P18 | [Subtype result caching](todo/performance.md#p18-subtype-result-caching) (per-request HashMap for hierarchy walks) | Medium | Low |

docs/todo/indexing.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ editing `composer.json` dependencies.
9393

9494
Background-parse every PHP file in the project. Uses Composer data to
9595
guide file discovery when available, falls back to scanning all PHP
96-
files in the workspace when it is not. Populates the ast_map,
96+
files in the workspace when it is not. Populates the uri_classes_index,
9797
symbol_maps, and all derived indices. Enables workspace symbols, fast
9898
find-references without on-demand scanning, and rich hover on
9999
completion items. Memory usage grows proportionally to project size.
@@ -157,7 +157,7 @@ join before the function returns). The thread count is capped at
157157
cores). Batches of 2 or fewer files skip threading overhead.
158158

159159
Transient entry eviction after GTI and find references has been
160-
removed. Parsed files stay cached in `ast_map`, `symbol_maps`,
160+
removed. Parsed files stay cached in `uri_classes_index`, `symbol_maps`,
161161
`use_map`, and `namespace_map` so that subsequent operations benefit
162162
from the work already done. This trades a small amount of memory for
163163
faster repeat queries and simpler code.
@@ -235,7 +235,7 @@ user scrolls.
235235
### Approach: "what's already discovered"
236236

237237
Use `completionItem/resolve` to populate `detail` and
238-
`documentation` fields. If the class is already in the ast_map (parsed
238+
`documentation` fields. If the class is already in the uri_classes_index (parsed
239239
during a prior resolution), return the full signature and docblock.
240240
If not, return just the item label with no extra detail.
241241

@@ -282,7 +282,7 @@ Full mode is not a separate discovery system. It works exactly like
282282
name completion and O(1) file lookup.
283283
2. **Second pass:** Iterate every file path in the now-populated
284284
in-memory classmap and call `update_ast` on each one at Low
285-
priority. This populates ast_map, symbol_maps, class_index,
285+
priority. This populates uri_classes_index, symbol_maps, fqn_uri_index,
286286
global_functions, and global_defines.
287287

288288
No new file discovery logic is needed. The classmap from the first
@@ -329,14 +329,14 @@ sizes over time. The aim is to stay under 512 MB for a full project.
329329

330330
The performance prerequisites above (P1 `Arc<ClassInfo>`,
331331
`Arc<String>`, `Arc<SymbolMap>`) directly reduce memory usage by
332-
sharing data across the ast_map, caches, and snapshot copies instead
332+
sharing data across the uri_classes_index, caches, and snapshot copies instead
333333
of deep-cloning each. These should be measured before and after to
334334
validate the 512 MB target.
335335

336336
### Workspace symbols
337337

338338
With the full index populated, `workspace/symbol` becomes a simple
339-
filter over the ast_map and global_functions maps. No additional
339+
filter over the uri_classes_index and global_functions maps. No additional
340340
infrastructure needed.
341341

342342
In other modes, workspace symbols still works but only returns results
@@ -370,7 +370,7 @@ three areas:
370370
3. **Go to Implementation and Find References.** These report
371371
begin/end only. The underlying scans (`find_implementors`,
372372
`find_member_references`, `find_class_references`) iterate over
373-
classmap files, ast_map entries, and PSR-4 directories, all of
373+
classmap files, uri_classes_index entries, and PSR-4 directories, all of
374374
which have known or discoverable totals.
375375

376376
### Design
@@ -498,10 +498,10 @@ better.
498498
**Impact: Medium · Effort: Medium**
499499

500500
The current lazy-loading design provides an implicit recency signal:
501-
classes in `ast_map` were loaded because the developer interacted with
501+
classes in `uri_classes_index` were loaded because the developer interacted with
502502
their file during this session (hovered, navigated, completed). Source
503503
tiers 0 (use-imported) and 1 (same-namespace) already capture this
504-
for the current file's neighborhood. The `class_index` source captures
504+
for the current file's neighborhood. The `fqn_uri_index` source captures
505505
cross-file interactions (go-to-definition, hover, or completion that
506506
triggered a load).
507507

docs/todo/lsp-features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ instantly instead of blocking until every source has been scanned.
2929
`find_implementors` already runs five sequential phases (see
3030
`docs/ARCHITECTURE.md` § Go-to-Implementation):
3131

32-
1. **Phase 1 — ast_map** (already-parsed classes in memory) — essentially
32+
1. **Phase 1 — uri_classes_index** (already-parsed classes in memory) — essentially
3333
free. Flush results immediately.
34-
2. **Phase 2 — class_index** (FQN → URI entries not yet in ast_map) —
34+
2. **Phase 2 — fqn_uri_index** (FQN → URI entries not yet in uri_classes_index) —
3535
loads individual files. Flush after each batch.
3636
3. **Phase 3 — classmap files** (Composer classmap, user + vendor mixed)
3737
— iterates unique file paths, applies string pre-filter, parses

docs/todo/performance.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Split Phase 3 into two sub-phases:
3636
only the paths that pass the filter along with their content.
3737

3838
2. **Sequential parse.** For the (few) files that pass, call
39-
`parse_and_cache_file` sequentially. This step mutates `ast_map`
39+
`parse_and_cache_file` sequentially. This step mutates `uri_classes_index`
4040
and calls `class_loader`, which may re-lock shared state.
4141

4242
The same pattern applies to Phase 5 (PSR-4 directory walk for files
@@ -166,12 +166,12 @@ not important and a plain `HashSet` suffices.
166166

167167
---
168168

169-
## P8. `find_class_in_ast_map` linear fallback scan
169+
## P8. `find_class_in_uri_classes_index` linear fallback scan
170170

171171
**Impact: Low · Effort: Low**
172172

173-
The fast O(1) `fqn_index` lookup in `find_class_in_ast_map` covers
174-
the common case. The slow fallback iterates every file in `ast_map`
173+
The fast O(1) `fqn_index` lookup in `find_class_in_uri_classes_index` covers
174+
the common case. The slow fallback iterates every file in `uri_classes_index`
175175
linearly. The comment says this covers "race conditions during
176176
initial indexing" and anonymous classes.
177177

@@ -385,7 +385,7 @@ The 630 phpstorm-stubs PHP files are embedded as raw source via
385385
classes extend built-in types.
386386

387387
3. **Duplicate data.** After parsing, the `Arc<ClassInfo>` lives in
388-
`ast_map` and `fqn_index`, but the raw PHP source stays resident
388+
`uri_classes_index` and `fqn_index`, but the raw PHP source stays resident
389389
in `.rodata` forever. Both copies exist simultaneously.
390390

391391
### Indexing order: stubs → vendor → user
@@ -456,7 +456,7 @@ serializes as `Vec<T>` and deserializes into `SharedVec::from(vec)`.
456456
**What gets removed:**
457457

458458
- The `STUB_FILES` array (raw PHP source embedding)
459-
- The `phpantom-stub://` URI scheme and associated `ast_map` entries
459+
- The `phpantom-stub://` URI scheme and associated `uri_classes_index` entries
460460
- The `parse_and_cache_content_versioned` path for stubs
461461
- The `is_stub_function_removed` / `is_stub_class_removed` byte
462462
scanners (replaced by version fields on deserialized structs)

docs/todo/type-inference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ supports glob patterns like `**/vendor/composer/autoload_*.php`.
5858

5959
- On change notification, re-run the same parsing logic from
6060
`initialized` for the affected artifact.
61-
- Invalidate `class_index` entries that came from vendor files (their
61+
- Invalidate `fqn_uri_index` entries that came from vendor files (their
6262
parsed AST may have changed).
63-
- Clear and re-populate `classmap` from the new `autoload_classmap.php`.
63+
- Clear and re-populate `fqn_uri_index` from the new `autoload_classmap.php`.
6464
- Log the reload to the output panel so the user knows it happened.
6565
- Debounce rapid changes (Composer writes multiple files in sequence)
6666
with a short delay (e.g. 500ms) to avoid redundant reloads.

src/analyse.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ pub async fn run(options: AnalyseOptions) -> i32 {
163163
// ── 4. Two-phase parallel analysis ──────────────────────────────
164164
//
165165
// Phase 1 — **Parse**: run `update_ast` on every user file so that
166-
// `fqn_index`, `ast_map`, `symbol_maps`, `use_map`, `namespace_map`
167-
// and `class_index` are fully populated for the entire project.
166+
// `fqn_index`, `uri_classes_index`, `symbol_maps`, `use_map`, `namespace_map`
167+
// and `fqn_uri_index` are fully populated for the entire project.
168168
//
169169
// Phase 2 — **Diagnose**: collect diagnostics for every file.
170170
// Because all user classes are already in `fqn_index`, cross-file
171171
// references resolve via an O(1) hash lookup instead of falling
172-
// through to classmap / PSR-4 lazy loading (which takes write
172+
// through to fqn_uri_index / PSR-4 lazy loading (which takes write
173173
// locks and serialises threads).
174174
//
175175
// Splitting the work this way also means the diagnostic phase
@@ -247,12 +247,12 @@ pub async fn run(options: AnalyseOptions) -> i32 {
247247
// cached — eliminating the unbounded mutual recursion in
248248
// resolve_class_fully_inner that previously caused stack overflow.
249249
//
250-
// We snapshot the toposorted FQN list while holding the ast_map
250+
// We snapshot the toposorted FQN list while holding the uri_classes_index
251251
// read lock, then drop the lock before resolving. Resolution may
252-
// call find_or_load_class which takes write locks on ast_map.
252+
// call find_or_load_class which takes write locks on uri_classes_index.
253253
let sorted_fqns = {
254-
let ast_map = backend.uri_classes_index.read();
255-
crate::toposort::toposort_from_ast_map(&ast_map)
254+
let uri_classes_index = backend.uri_classes_index.read();
255+
crate::toposort::toposort_from_uri_classes_index(&uri_classes_index)
256256
};
257257
// Run eager population on a large-stack thread. `resolve_class_fully_inner`
258258
// can nest deeply when the toposort misses dependencies (stubs, dynamically

src/classmap_scanner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! directly (not by this module). Functions and constants from
2222
//! `autoload_files.php` are discovered by the full-scan during
2323
//! initialization, populating `autoload_function_index`,
24-
//! `autoload_constant_index`, and `class_index`. Lazy
24+
//! `autoload_constant_index`, and `fqn_uri_index`. Lazy
2525
//! `update_ast` on first access provides complete details.
2626
//!
2727
//! 2. **Composer self-scan** — the PSR-4 scanner builds a classmap

src/code_actions/change_visibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl Backend {
258258
cursor_offset: u32,
259259
member_kind: &MemberKind,
260260
) -> Option<u8> {
261-
// Find the enclosing ClassInfo from the ast_map.
261+
// Find the enclosing ClassInfo from the uri_classes_index.
262262
let local_classes: Vec<Arc<ClassInfo>> = self
263263
.uri_classes_index
264264
.read()

src/code_actions/import_class.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl Backend {
340340
let mut candidates = Vec::new();
341341
let name_lower = name.to_lowercase();
342342

343-
// ── 1. class_index ──────────────────────────────────────────────
343+
// ── 1. fqn_uri_index ──────────────────────────────────────────────
344344
{
345345
let idx = self.fqn_uri_index.read();
346346
for fqn in idx.keys() {
@@ -364,7 +364,7 @@ impl Backend {
364364
}
365365
}
366366

367-
// ── 3. ast_map (already-parsed files) ───────────────────────────
367+
// ── 3. uri_classes_index (already-parsed files) ───────────────────────────
368368
{
369369
let amap = self.uri_classes_index.read();
370370
for (_file_uri, classes) in amap.iter() {
@@ -1460,7 +1460,7 @@ final class Foo extends Data
14601460
// ── find_import_candidates smoke test ───────────────────────────────
14611461

14621462
#[test]
1463-
fn find_candidates_from_class_index() {
1463+
fn find_candidates_from_fqn_uri_index() {
14641464
let backend = crate::Backend::new_test();
14651465
// Populate class index with a known class.
14661466
{
@@ -1501,7 +1501,7 @@ final class Foo extends Data
15011501
#[test]
15021502
fn find_candidates_deduplicates() {
15031503
let backend = crate::Backend::new_test();
1504-
// Add the same FQN to class_index — should only appear once.
1504+
// Add the same FQN to fqn_uri_index — should only appear once.
15051505
{
15061506
let mut idx = backend.fqn_uri_index.write();
15071507
idx.insert("App\\Foo".to_string(), "file:///foo.php".to_string());
@@ -1999,19 +1999,19 @@ final class Foo extends Data
19991999
}
20002000

20012001
#[test]
2002-
fn import_action_offered_when_namespaced_class_in_ast_map() {
2002+
fn import_action_offered_when_namespaced_class_in_uri_classes_index() {
20032003
// Reproduces issue #59: when a namespaced class like `Carbon\Carbon`
2004-
// is already parsed and in the ast_map, `find_or_load_class("Carbon")`
2004+
// is already parsed and in the uri_classes_index, `find_or_load_class("Carbon")`
20052005
// must NOT match it — the bare name `"Carbon"` is a global-scope
20062006
// lookup and should not resolve to `Carbon\Carbon`.
20072007
//
2008-
// Without the fix, `find_class_in_ast_map("Carbon")` ignores the
2008+
// Without the fix, `find_class_in_uri_classes_index("Carbon")` ignores the
20092009
// namespace filter when `expected_ns` is `None`, so ANY class with
20102010
// short name `Carbon` matches. The import action then skips it
20112011
// thinking "this class resolves in global scope".
20122012
let backend = crate::Backend::new_test();
20132013

2014-
// Parse the dependency file so Carbon\Carbon is in the ast_map.
2014+
// Parse the dependency file so Carbon\Carbon is in the uri_classes_index.
20152015
let uri_dep = "file:///vendor/carbon.php";
20162016
let content_dep = "<?php\nnamespace Carbon;\n\nclass Carbon {}\n";
20172017
backend.update_ast(uri_dep, content_dep);
@@ -2052,7 +2052,7 @@ final class Foo extends Data
20522052
false
20532053
}
20542054
}),
2055-
"expected an import action for Carbon\\Carbon when the namespaced class is in ast_map, got: {:?}",
2055+
"expected an import action for Carbon\\Carbon when the namespaced class is in uri_classes_index, got: {:?}",
20562056
actions
20572057
.iter()
20582058
.map(|a| match a {

src/completion/context/catch_completion.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ fn find_try_block_body(_content: &str, before_catch: &str) -> Option<String> {
374374

375375
impl Backend {
376376
/// Check whether a class is a confirmed `\Throwable` descendant using
377-
/// only already-loaded data from the `ast_map`.
377+
/// only already-loaded data from the `uri_classes_index`.
378378
///
379379
/// Returns `true` only when the full parent chain can be walked to
380380
/// one of the three Throwable root types (`Throwable`, `Exception`,
@@ -384,7 +384,7 @@ impl Backend {
384384
/// This is a strict check: the caller should only include the class
385385
/// when this returns `true`.
386386
///
387-
/// This never triggers disk I/O; it only consults `ast_map`.
387+
/// This never triggers disk I/O; it only consults `uri_classes_index`.
388388
fn is_throwable_descendant(&self, class_name: &str, depth: u32) -> bool {
389389
if depth > 20 {
390390
return false; // prevent infinite loops
@@ -397,8 +397,8 @@ impl Backend {
397397
return true;
398398
}
399399

400-
// Look up ClassInfo from ast_map (no disk I/O).
401-
match self.find_class_in_ast_map(class_name) {
400+
// Look up ClassInfo from uri_classes_index (no disk I/O).
401+
match self.find_class_in_uri_classes_index(class_name) {
402402
Some(ci) => {
403403
// Walk the parent class chain first.
404404
if let Some(parent) = &ci.parent_class
@@ -528,7 +528,7 @@ impl Backend {
528528
let classify = |fqn: &str, sn: &str| -> Option<(char, bool)> {
529529
// Check if loaded as a class or interface so we can verify
530530
// Throwable ancestry.
531-
let loaded_info = self.find_class_in_ast_map(fqn);
531+
let loaded_info = self.find_class_in_uri_classes_index(fqn);
532532
let is_loaded_class_or_interface = loaded_info
533533
.as_ref()
534534
.is_some_and(|c| matches!(c.kind, ClassLikeKind::Class | ClassLikeKind::Interface));

0 commit comments

Comments
 (0)