MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / collect

Method collect

src/mcp/tools.ts:3446–3468  ·  view source on GitHub ↗
(defNodes: Node[])

Source from the content-addressed store, hash-verified

3444 // Every site of each caller (#2909): one row per caller, at the lines its
3445 // calls sit on, and the symbol itself when it calls itself.
3446 const collect = (defNodes: Node[]) => {
3447 const callers: Node[] = [];
3448 const labels = new Map<string, string>();
3449 const sites = new Map<string, Edge[]>();
3450 const recursive = new Set<string>();
3451 for (const node of defNodes) {
3452 for (const c of cg.getCallSites(node.id, 'callers')) {
3453 const known = sites.get(c.node.id);
3454 if (known) {
3455 known.push(...c.edges);
3456 continue;
3457 }
3458 sites.set(c.node.id, [...c.edges]);
3459 if (c.recursive) recursive.add(c.node.id);
3460 callers.push(c.node);
3461 answerPaths.add(c.node.filePath);
3462 const label = this.edgeLabel(c.edges[0]!);
3463 if (label) labels.set(c.node.id, label);
3464 }
3465 }
3466 const locations = new Map(callers.map((n) => [n.id, this.callSiteLocation(n, sites.get(n.id) ?? [])]));
3467 return { callers, labels, locations, recursive };
3468 };
3469
3470 // Single definition (or same-file overloads): the familiar flat list.
3471 if (groups.length === 1) {

Callers

nothing calls this directly

Calls 9

edgeLabelMethod · 0.95
callSiteLocationMethod · 0.95
pushMethod · 0.80
mapMethod · 0.80
hasMethod · 0.80
getMethod · 0.65
getCallSitesMethod · 0.45
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected