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

Method getTypeHierarchy

src/graph/traversal.ts:412–436  ·  view source on GitHub ↗

* Get the type hierarchy for a class/interface * * @param nodeId - ID of the class/interface node * @returns Subgraph containing the type hierarchy

(nodeId: string)

Source from the content-addressed store, hash-verified

410 * @returns Subgraph containing the type hierarchy
411 */
412 getTypeHierarchy(nodeId: string): Subgraph {
413 const focalNode = this.queries.getNodeById(nodeId);
414 if (!focalNode) {
415 return { nodes: new Map(), edges: [], roots: [] };
416 }
417
418 const nodes = new Map<string, Node>();
419 const edges: Edge[] = [];
420 const visited = new Set<string>();
421
422 // Add focal node
423 nodes.set(focalNode.id, focalNode);
424
425 // Get ancestors (what this extends/implements)
426 this.getTypeAncestors(nodeId, nodes, edges, visited);
427
428 // Get descendants (what extends/implements this)
429 this.getTypeDescendants(nodeId, nodes, edges, visited);
430
431 return {
432 nodes,
433 edges,
434 roots: [nodeId],
435 };
436 }
437
438 private getTypeAncestors(
439 nodeId: string,

Callers 1

findRelevantContextMethod · 0.45

Calls 4

getTypeAncestorsMethod · 0.95
getTypeDescendantsMethod · 0.95
getNodeByIdMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected