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

Method getCallGraph

src/graph/traversal.ts:456–487  ·  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

454 * @returns Subgraph containing the call graph
455 */
456 getCallGraph(nodeId: string, depth: number = 2): Subgraph {
457 const focalNode = this.queries.getNodeById(nodeId);
458 if (!focalNode) {
459 return { nodes: new Map(), edges: [], roots: [] };
460 }
461
462 const nodes = new Map<string, Node>();
463 const edges: Edge[] = [];
464
465 // Add focal node
466 nodes.set(focalNode.id, focalNode);
467
468 // Get callers
469 const callers = this.getCallers(nodeId, depth);
470 for (const { node, edge } of callers) {
471 nodes.set(node.id, node);
472 edges.push(edge);
473 }
474
475 // Get callees
476 const callees = this.getCallees(nodeId, depth);
477 for (const { node, edge } of callees) {
478 nodes.set(node.id, node);
479 edges.push(edge);
480 }
481
482 return {
483 nodes,
484 edges,
485 roots: [nodeId],
486 };
487 }
488
489 /**
490 * Get the type hierarchy for a class/interface

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected