Collapse per-kind backend lookup to one call - #413
Open
Firehed wants to merge 18 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #413 +/- ##
============================================
- Coverage 98.62% 98.62% -0.01%
- Complexity 1810 1814 +4
============================================
Files 125 128 +3
Lines 4594 4571 -23
============================================
- Hits 4531 4508 -23
Misses 63 63 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice S3.8d — Plan 0002 Step 3b, §5.6; RFC 1 §5.1, §8.1.
SymbolBackendcarriedlookupClassLikeandlookupFunctionseparately, so the same twenty lines of cache-then-build appeared twice inFilesystemBackendandBuiltinBackend, andOpenDocumentBackendheld two parallel array pairs. Adding constants (S3.8b) would have tripled that. The backends now take onelookup(QualifiedName, NameKind): ?SymbolInfo.SymbolSourceis unchanged: it keeps a typed method per kind because §5.1 requires a concrete return type. The composite narrows the marker back once per kind, at one site — the O(kinds) narrowing §5.6 trades against O(kinds × backends) methods.Kind dispatch lands in two factories, one per metadata route, rather than inline in a backend:
DeclarationSymbolInfoFactory(parsed declarations) andReflectionSymbolInfoFactory(the loaded runtime). §4.5 wants kind dispatch confined to a factory, and its static rule arrives in S4.1 — this puts the code in the shape that rule will expect. Moving reflection into the second factory relocates theReflection*allowlist entry offBuiltinBackendrather than widening it.Behaviour-preserving: every Step P golden is unchanged, and no golden was recaptured. The
phpstan-baseline.neondiff is message text only, following the allowlist message edit — count unchanged at 43.§8.1 mechanism
The slice also carries §8.1's mechanism for §5.1:
SymbolCoverageGridTest, a backend × kind × query grid. Both axes are derived — rows fromCompositeSymbolSource::$backends, columns fromNameKind::cases()×GridQuery::cases()— so a new kind or backend adds cells that did not exist when the file was written. Every cell either answers over the fixtures or is registered against a named blocker; an unregistered cell fails, and a registration on a cell that now answers fails too, so a blocker cannot outlive its gap.The grid found one gap on its first run, filed as manifest row SC.16:
SymbolExtractoremits noSymbolKind::Constant, so an open document's global constants are never indexed andOpenDocumentBackend::childrenOfcannot enumerate them — while both on-disk and built-in enumeration report constants.WorkspaceNamespaceSourcealready maps the kind; only a hand-built index in a unit test ever reached that arm. Not fixed here (out of scope); the cell is registered against SC.16.Acceptance criteria
SymbolBackendcarries one kind-parameterized lookup, not a method per kindSymbolSourcekeeps its typed per-kind methods (§5.1 concrete return types)SymbolInfomarker onClassInfoandFunctionInfo;Formattablenot reusedSets up S3.8b, whose acceptance is that its diff touches no
SymbolBackendimplementation.🤖 Generated with Claude Code