Repository navigation
fix(member): one shim-aware MEMBER lookup for every feature - #867
Merged
msarson merged 1 commit intoNov 25, 2026
Merged
Conversation
A module whose MEMBER sits in an INCLUDE'd shim had no parent for Go to Implementation, the hover card's implementation link, FAR's MAP-declaration step and three parent-MAP diagnostics: each read MEMBER with findMemberHeaderToken, which sees only the module's own tokens. Hover, F12, completion, the include check and the MAP-include walk each had a private copy of the shim walk; those five copies are now one, MemberHeaderResolver, and all eleven direct callers use it. MemberHeaderShimAllFeatures.test.ts: 22 tests, 6 of them fail without the fix. Full server suite: 4641 passing, 3 pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
One shim-aware MEMBER lookup for every feature
What happens
A common project layout keeps a module's
MEMBER('program')statement in a small shim file that every module includes as its first statement:With
Workerdeclared in the PROGRAM's MAP and implemented inmainprog.clw:Worker(inSTART( Worker )orWorker()), or onOtherProc(), does nothing.Workershows the MAP declaration link, but not the implementation link.usage.clwwith no MAP entry in the PROGRAM is not reported.The same module with
MEMBER('mainprog')written in it works for all of these.Root cause
Each of these paths reads the MEMBER statement with
TokenHelper.findMemberHeaderToken(tokens), which only sees the tokens it is given: the module's own. For a module headed by a shim it finds nothing, so the feature concludes the module has no parent:The shim has been handled before, one feature at a time: #388 (hover and F12), #395 (missing-include check), the PROGRAM-globals completion fix, and the MAP-include walk in
MapProcedureResolver. Each added its own copy of the first-statement walk, so there were five copies, and eleven call sites still used the direct lookup:ImplementationProviderProcedureHoverResolverHoverProviderDefinitionProvider(3)ReferencesProviderMapDeclarationDiagnosticsPrivateProcedureDiagnosticsUnresolvedProcedureCallDiagnosticsserver.ts(2)The fix
utils/MemberHeaderResolver.tsholds the walk once:It keeps the existing rules: only the first statement can be a shim, the owner project's redirection comes first (#328) and then the module's folder, at most three hops, and a visited set stops cycles. It is synchronous: it loads a shim with
TokenCache.getTokensForClosedFile(open buffer first, mtime-cached), so the synchronous callers (server.ts, the diagnostics) can use it too. It returns the file the MEMBER line is written in (hostFile), for callers that resolve the parent from there (MapProcedureResolver,WordCompletionProvider).resolveMemberHeaderTokenForUri(tokens, document.uri).MemberLocatorService,SymbolFinderServiceandIncludeVerifierkeep their private method as a one-line wrapper, so their call sites are unchanged.MemberLocatorServicepasses its ownresolveFilePath, which keeps its no-solution search;MapProcedureResolverpasses its cachedresolveIncludeTarget.DefinitionProvider.findTypeInIncludesnow adds the implied.clwto the MEMBER target before resolving it. Without it,MEMBER('mainprog')found through a shim still missed the parent.Testing
server/src/test/MemberHeaderShimAllFeatures.test.ts, 22 tests:hostFilenaming the shim), a chained shim, an include cycle, a later INCLUDE not followed, a shim that cannot be found.START()argument and on a call into another member module, the hover's declaration and implementation links, F12, FAR from an implementation label, the missing-MAP-declaration warning, the unresolved-call resolver, and the PRIVATE-call warning.Proven real: with the caller changes stashed (the new helper kept, since the walk tests import it), 6 of the 8 shim tests fail and all 8 control tests pass. F12 and FAR already pass without the fix (#388, #854); they stay as regression guards so a later change to those paths cannot drop the shim again.
Full server suite: 4641 passing, 3 pending, 0 failing. One run hit a 30 s timeout in
StructureDeclarationIndexer.DiskCache.test("a corrupt disk cache degrades to a full scan"); it passes on its own with and without this change (about 15 s) and passed on the next full run.Scope
Left out on purpose:
HoverProvider's MEMBER-parent tier still resolves the parent only in the module's own folder (path.resolve(currentFileDir, ...)), not through redirection. That is unchanged by this PR and is a separate question from finding the MEMBER statement.TokenHelper.findMemberHeaderTokenitself is unchanged: it answers "is a MEMBER written in these tokens", which the walk is built on, andTokenHelpercannot load files without an import cycle.server.tsre-validation now walks the shim of each open module when the PROGRAM changes. The walk costs nothing for a module whose first statement is not an INCLUDE; for a shim-headed one it is a stat of a small, cached file.