Skip to content

fix(incremental): port same-class this.method() and defineProperty fallbacks into buildCallEdges#1401

Merged
carlos-alm merged 7 commits into
mainfrom
fix/incremental-call-edges-fallbacks-1384
Jun 9, 2026
Merged

fix(incremental): port same-class this.method() and defineProperty fallbacks into buildCallEdges#1401
carlos-alm merged 7 commits into
mainfrom
fix/incremental-call-edges-fallbacks-1384

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

incremental.ts:buildCallEdges was missing two fallback resolution blocks that exist in build-edges.ts:buildFileCallEdges, causing the incremental (watch-mode) rebuild path to produce fewer call edges than a full rebuild.

  • Same-class this.method() fallback: after resolveCallTargets returns empty for a this-receiver call, derive the enclosing class name from callerName (e.g. Logger.infoLogger) and retry with the qualified name Logger._write restricted to kind === 'method'. Mirrors the native engine's class-scoped symbol table behaviour.
  • Object.defineProperty accessor fallback: when a function is registered via Object.defineProperty(obj, "bar", { get: fn }), this inside fn refers to obj. Resolve this.X() via obj's typeMap entry or a same-file lookup — mirrors buildDefinePropertyPostPass in the native path.
  • Also adds the missing caller.callerName argument to the resolveCallTargets call (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

  • All 633 existing tests pass (npx vitest run)
  • No new lint warnings introduced

Closes #1384

…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-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This 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 build-edges.ts:buildFileCallEdges were absent from incremental.ts:buildCallEdges, and the 6th callerName argument introduced by PR #1383 was also missing from the resolveCallTargets call.

  • Same-class this.method() fallback — derives the enclosing class name from callerName (e.g. Logger.infoLogger) and retries with the qualified name restricted to kind === 'method', mirroring the class-scoped symbol-table behaviour in the native engine.
  • Object.defineProperty accessor fallback — resolves this.X() calls inside getter/setter functions registered via Object.defineProperty by looking up the object via definePropertyReceivers → typeMap, with a same-file name lookup as a final backstop; also fixes the missing callerName 6th argument to resolveCallTargets.

Confidence Score: 5/5

Safe 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

Filename Overview
src/domain/graph/builder/incremental.ts Added same-class this.method() and Object.defineProperty accessor fallbacks, plus the missing callerName 6th argument to resolveCallTargets, faithfully porting both blocks from buildFileCallEdges in build-edges.ts.

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
Loading

Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

1 functions changed5 callers affected across 2 files

  • buildCallEdges in src/domain/graph/builder/incremental.ts:485 (5 transitive callers)

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

@carlos-alm

Copy link
Copy Markdown
Contributor Author

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.

@carlos-alm carlos-alm merged commit d95a09d into main Jun 9, 2026
22 checks passed
@carlos-alm carlos-alm deleted the fix/incremental-call-edges-fallbacks-1384 branch June 9, 2026 04:52
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(incremental): buildCallEdges missing same-class this.method() and Object.defineProperty fallbacks from build-edges.ts

1 participant