* 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)
| 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 |
nothing calls this directly
no test coverage detected