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

Function targetsOf

__tests__/sync-default-export-change.test.ts:92–101  ·  view source on GitHub ↗

Where each reference to `refName` landed: ` -> :: `.

(graph: CodeGraph, refName: string)

Source from the content-addressed store, hash-verified

90
91/** Where each reference to `refName` landed: `<source> -> <target kind> <file>::<qualified name>`. */
92function targetsOf(graph: CodeGraph, refName: string): string[] {
93 const ids = graph.getFiles().flatMap((file) => graph.getNodesInFile(file.path)).map((n) => n.id);
94 return graph.getOutgoingEdgesFrom(ids)
95 .filter((e) => e.metadata?.refName === refName && e.kind !== 'imports')
96 .map((e) => {
97 const target = graph.getNode(e.target)!;
98 return `${graph.getNode(e.source)!.name} -> ${target.kind} ${target.filePath}::${target.qualifiedName}`;
99 })
100 .sort();
101}
102
103/** Index `before`, write `after` over it, sync; return the graph and what a full index of `after` holds. */
104async function syncEdit(before: Files, after: Files): Promise<{ root: string; graph: CodeGraph; full: string[]; modified: number }> {

Calls 5

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

Tested by

no test coverage detected