fix(incremental): port same-class this.method() and defineProperty fallbacks into buildCallEdges#1401
Conversation
…llbacks into buildCallEdges After resolveCallTargets returns empty: 1. Retry with class-qualified name (ClassName.method) for this-receiver calls 2. Resolve via Object.defineProperty accessor receiver typeMap or same-file lookup These two blocks existed in buildFileCallEdges (build-edges.ts) but were missing from the incremental path, causing divergence between full and watch-mode builds. Also adds the missing callerName argument to resolveCallTargets. Closes #1384
Greptile SummaryThis PR fixes the incremental (watch-mode) rebuild path so it produces the same call edges as a full build. Two fallback resolution blocks present in
Confidence Score: 5/5Safe to merge — the change is additive, only fires when targets.length === 0, and is a faithful port of logic that already runs on the full-build path. Both fallback blocks are direct ports from buildFileCallEdges in build-edges.ts with identical guard conditions, typeMap value extraction, and lookup calls. The missing 6th callerName argument is straightforwardly corrected. The new code cannot produce false edges that the native JS path would not already produce. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[buildCallEdges loop over calls] --> B{BUILTIN receiver?}
B -- yes --> SKIP[skip]
B -- no --> C[findCaller]
C --> D["resolveCallTargets(..., callerName)"]
D --> E{targets found?}
E -- yes --> INSERT[insert call edges]
E -- no --> F{receiver=this and callerName has dot?}
F -- yes --> G[same-class fallback via byNameAndFile filtered to kind=method]
G --> H{targets found?}
H -- yes --> INSERT
H -- no --> I{definePropertyReceivers has callerName?}
F -- no --> I
I -- yes --> J[typeMap lookup then byNameAndFile fallback]
J --> INSERT
I -- no --> INSERT
Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
Codegraph Impact Analysis1 functions changed → 5 callers affected across 2 files
|
…edges-fallbacks-1384
|
Sweep: merged origin/main (PR #1399 — super.method() dispatch) into the branch to bring it up to date. No conflicts. CI re-triggered; all previous checks were green except one transient Commitlint infrastructure failure (npm install in ops-codegraph-tool). New run in progress. |
Summary
incremental.ts:buildCallEdgeswas missing two fallback resolution blocks that exist inbuild-edges.ts:buildFileCallEdges, causing the incremental (watch-mode) rebuild path to produce fewer call edges than a full rebuild.this.method()fallback: afterresolveCallTargetsreturns empty for athis-receiver call, derive the enclosing class name fromcallerName(e.g.Logger.info→Logger) and retry with the qualified nameLogger._writerestricted tokind === 'method'. Mirrors the native engine's class-scoped symbol table behaviour.Object.defineProperty(obj, "bar", { get: fn }),thisinsidefnrefers toobj. Resolvethis.X()viaobj's typeMap entry or a same-file lookup — mirrorsbuildDefinePropertyPostPassin the native path.caller.callerNameargument to theresolveCallTargetscall (the 6th parameter introduced by PR fix(resolver/native/incremental): callerName parity, func-prop cross-file edges, O(n) Phase 8.3f, qualified callerName dispatch #1383).Test plan
npx vitest run)Closes #1384