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

Function graphOf

__tests__/parameter-flow.test.ts:584–593  ·  view source on GitHub ↗

Every node, edge and parked reference of an index, by natural key.

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

582describe('a sync gives what a fresh index gives', () => {
583 /** Every node, edge and parked reference of an index, by natural key. */
584 function graphOf(cg: CodeGraph): { edges: string[] } {
585 const keys = new Map(
586 cg.getFiles()
587 .flatMap((file) => cg.getNodesInFile(file.path))
588 .map((n) => [n.id, `${n.kind} ${n.filePath}:${n.qualifiedName}:${n.startLine}`] as const),
589 );
590 const edges = cg.getOutgoingEdgesFrom([...keys.keys()]).map((e) =>
591 `${e.kind} ${keys.get(e.source)} -> ${keys.get(e.target) ?? e.target} @${e.line}:${e.column} ${JSON.stringify(e.metadata ?? {})}`);
592 return { edges: edges.sort() };
593 }
594
595 const FRESH_TIMEOUT = 60_000;
596

Callers 2

convergesFunction · 0.70
syncedFunction · 0.70

Calls 5

mapMethod · 0.80
getFilesMethod · 0.80
getNodesInFileMethod · 0.65
getMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected