The links of `expected`'s reference names the graph has (LINKS by default).
(graph: CodeGraph, expected: string[] = LINKS)
| 194 | |
| 195 | /** The links of `expected`'s reference names the graph has ({@link LINKS} by default). */ |
| 196 | function linksOf(graph: CodeGraph, expected: string[] = LINKS): string[] { |
| 197 | const names = new Set(expected.map((link) => link.slice(0, link.indexOf(':')))); |
| 198 | const ids = graph.getFiles().flatMap((file) => graph.getNodesInFile(file.path)).map((n) => n.id); |
| 199 | const links: string[] = []; |
| 200 | for (const edge of graph.getOutgoingEdgesFrom(ids)) { |
| 201 | const ref = edge.metadata?.refName; |
| 202 | if (typeof ref !== 'string' || !names.has(ref)) continue; |
| 203 | const source = graph.getNode(edge.source)!; |
| 204 | const target = graph.getNode(edge.target)!; |
| 205 | links.push(`${ref}: ${edge.kind} ${source.kind} ${source.filePath} -> ${target.kind} ${target.filePath}::${target.name}`); |
| 206 | } |
| 207 | return [...new Set(links)].sort(); |
| 208 | } |
| 209 | |
| 210 | /** The final tree, indexed from scratch in a folder of its own: what the sync has to match. */ |
| 211 | async function fullIndexOf(files: Files): Promise<string[]> { |
no test coverage detected