Files
codegraph/__tests__
Colby MchenryandClaude Opus 5.5 fa03fa6bb4 fix(callers): list every call site of a caller, and a function that calls itself (#3077)
getCallers keeps one row per caller (issue #1086) with the caller's first
edge only, and seeds its reported set with the symbol itself, so
codegraph callers showed a caller that calls the symbol on two lines
once, at the line its own declaration starts on, and left a recursive
call out, though the index stores every one of those edges and each is
a line to edit when the symbol changes. The CLI also merged edges on
source, target and kind, which dropped a second call site from --json.

A new GraphTraverser.getCallSites (CodeGraph.getCallSites) reads the
direct callers or callees with every edge: one row per neighbour in the
order getCallers / getCallees list them, every site kept, and the
symbol's own row, flagged recursive, when it calls itself. getCallers
and getCallees are unchanged, so ranking, explore's Flow and blast
radius, impact and the viewer read exactly as before; a test pins that
every non-recursive row of getCallSites equals getCallers' row and first
edge. src/graph/call-sites.ts holds the one wording of a site list
(9, 10, +N more) the surfaces share.

- codegraph callers prints a caller at its call-site lines (up to 10,
  then +N more), a recursive row as "(calls itself)", and --json gives
  each row lines and recursive, with every site in edges. Callees keep
  the callee's declaration line, where a call leads.
- codegraph_callers / codegraph_callees read the same rows (10 sites per
  caller), and codegraph_node's trail shows callers at their sites, 3 at
  most, and the symbol once among its callers when it calls itself.

Validation: new callers-call-sites.test.ts (7 tests) fails 7 of 7 with
main's sources and passes with the fix; 11 neighbouring callers, trail
and lookup test files (217 tests) pass. Before/after on one index per
repo (expressjs/express 0dee2c52, excalidraw d3a9c2a1, gin-gonic/gin
0f09c3a9): trails changed for 108/253, 3630/4180 and 557/1395 symbols,
nearly all callers moving from the declaration line to the call sites;
recursive rows newly shown 2/20/7. Budget: trail median 115->117,
354->360, 185->187 chars, largest growth +131/+212/+91 chars, and the
busiest caller rows (67, 300 and 100 sites) stay one capped entry.
codegraph_callers on each repo's 15 busiest callees: largest answer
1025->1358, 1882->2127, 1790->1805 chars.

Not in this change: the issue's own recursion, child.walk() on a
for...of element over children: TreeNode[], is not linked at all on
main (the receiver's element type isn't inferred), so it needs a
resolution fix of its own; this.walk() and a plain recursive call are.

Reimplements PR #2994 by @johnhldiver-beep.

Fixes #2909

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:30:39 +00:00
..