Every node and edge by natural key, so two indexes of the same files compare directly.
(cg: CodeGraph)
| 38 | |
| 39 | /** Every node and edge by natural key, so two indexes of the same files compare directly. */ |
| 40 | function graphOf(cg: CodeGraph): { nodes: string[]; edges: string[] } { |
| 41 | const keys = new Map( |
| 42 | cg.getFiles() |
| 43 | .flatMap((file) => cg.getNodesInFile(file.path)) |
| 44 | .map((n) => [n.id, `${n.kind} ${n.filePath}:${n.qualifiedName}:${n.startLine}`] as const) |
| 45 | ); |
| 46 | const edges = cg.getOutgoingEdgesFrom([...keys.keys()]) |
| 47 | .map((e) => `${e.kind} ${keys.get(e.source)} -> ${keys.get(e.target) ?? e.target}`); |
| 48 | return { nodes: [...keys.values()].sort(), edges: edges.sort() }; |
| 49 | } |
| 50 | |
| 51 | describe('Sync Module', () => { |
| 52 | describe('Sync Functionality', () => { |
no test coverage detected