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

Method getCallGraph

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

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