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

Function linksOf

__tests__/sync-python-import-binding-retry.test.ts:196–208  ·  view source on GitHub ↗

The links of `expected`'s reference names the graph has (LINKS by default).

(graph: CodeGraph, expected: string[] = LINKS)

Source from the content-addressed store, hash-verified

194
195/** The links of `expected`'s reference names the graph has ({@link LINKS} by default). */
196function 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. */
211async function fullIndexOf(files: Files): Promise<string[]> {

Calls 7

mapMethod · 0.80
getFilesMethod · 0.80
hasMethod · 0.80
getNodeMethod · 0.80
pushMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected