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

Method getCallGraph

src/graph/traversal.ts:373–404  ·  view source on GitHub ↗

* Get the call graph for a function (both callers and callees) * * @param nodeId - ID of the function/method node * @param depth - Maximum depth in each direction (default: 2) * @returns Subgraph containing the call graph

(nodeId: string, depth: number = 2)

Source from the content-addressed store, hash-verified

371 * @returns Subgraph containing the call graph
372 */
373 getCallGraph(nodeId: string, depth: number = 2): Subgraph {
374 const focalNode = this.queries.getNodeById(nodeId);
375 if (!focalNode) {
376 return { nodes: new Map(), edges: [], roots: [] };
377 }
378
379 const nodes = new Map<string, Node>();
380 const edges: Edge[] = [];
381
382 // Add focal node
383 nodes.set(focalNode.id, focalNode);
384
385 // Get callers
386 const callers = this.getCallers(nodeId, depth);
387 for (const { node, edge } of callers) {
388 nodes.set(node.id, node);
389 edges.push(edge);
390 }
391
392 // Get callees
393 const callees = this.getCallees(nodeId, depth);
394 for (const { node, edge } of callees) {
395 nodes.set(node.id, node);
396 edges.push(edge);
397 }
398
399 return {
400 nodes,
401 edges,
402 roots: [nodeId],
403 };
404 }
405
406 /**
407 * Get the type hierarchy for a class/interface

Callers

nothing calls this directly

Calls 4

getCallersMethod · 0.95
getCalleesMethod · 0.95
getNodeByIdMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected