Skip to content

Commit 500998f

Browse files
committed
Remove AST-based variable definition resolver and tests
1 parent 3d34177 commit 500998f

13 files changed

Lines changed: 154 additions & 2532 deletions

File tree

docs/todo/refactor.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,6 @@ A minor inefficiency, not a parallel system.
240240
back to linear scan of `uri_classes_index`. Covers race conditions during initial
241241
indexing. Legitimate safety net.
242242

243-
### `DIAGNOSTIC_SCOPE` vs `HOVER_SCOPE_CACHE`
244-
245-
Two caches storing the same data type (`ScopeSnapshotMap`) for different consumers.
246-
`DIAGNOSTIC_SCOPE` is ephemeral/per-pass (build all scopes for the whole file,
247-
discard on drop). `HOVER_SCOPE_CACHE` is persistent/per-method with content-hash
248-
invalidation. The split is intentional: diagnostics check every line so they
249-
build all scopes upfront; hover checks one spot so it lazily caches per-method.
250-
However, the `is_diagnostic_scope_active()` guard causes ~14 behavioral forks
251-
in the forward walker, meaning bugs fixed for one consumer may not manifest for
252-
the other. Unifying them would eliminate the divergent walker behavior.
253-
254-
### Consumer-gated caches
255-
256-
`CALLABLE_TARGET_CACHE`, `PARSE_CACHE`, and `ACTIVE_RESOLVED_CACHE` are activated
257-
only during diagnostic/analyse passes. Completion and hover re-resolve callable
258-
targets and re-parse files from scratch. Extending these to all consumers would
259-
avoid redundant work.
260-
261243
---
262244

263245
## Redundant backwards text walkers

src/completion/handler.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl Backend {
400400
// ── Variable name completion ────────────────────────────
401401
// Placed before the interpolation guard so that `"$`
402402
// and `"{$` both offer variable suggestions.
403-
if let Some(response) = Self::try_variable_name_completion(&content, position) {
403+
if let Some(response) = self.try_variable_name_completion(&content, position, &uri) {
404404
return Ok(Some(response));
405405
}
406406

@@ -1042,12 +1042,16 @@ impl Backend {
10421042
/// Returns `None` when the cursor is not at a variable-name position
10431043
/// or when no variables are found.
10441044
fn try_variable_name_completion(
1045+
&self,
10451046
content: &str,
10461047
position: Position,
1048+
uri: &str,
10471049
) -> Option<CompletionResponse> {
10481050
let partial = Self::extract_partial_variable_name(content, position)?;
1051+
let symbol_maps = self.symbol_maps.read();
1052+
let symbol_map = symbol_maps.get(uri).map(|arc| arc.as_ref());
10491053
let (var_items, var_incomplete) =
1050-
Self::build_variable_completions(content, &partial, position);
1054+
Self::build_variable_completions(content, &partial, position, symbol_map);
10511055

10521056
if var_items.is_empty() {
10531057
None

0 commit comments

Comments
 (0)