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

Function callsOf

__tests__/ts-array-annotated-receivers.test.ts:37–57  ·  view source on GitHub ↗

Index `files` and return each call edge as ` -> `.

(files: Record<string, string>, withFiles = false)

Source from the content-addressed store, hash-verified

35
36/** Index `files` and return each call edge as `<refName> -> <target qualified name>`. */
37async function callsOf(files: Record<string, string>, withFiles = false): Promise<string[]> {
38 const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-ts-array-recv-'));
39 roots.push(root);
40 for (const [file, text] of Object.entries(files)) {
41 fs.mkdirSync(path.dirname(path.join(root, file)), { recursive: true });
42 fs.writeFileSync(path.join(root, file), text);
43 }
44 const graph = await CodeGraph.init(root, { index: true });
45 graphs.push(graph);
46 const nodes = graph.getFiles().flatMap((f) => graph.getNodesInFile(f.path));
47 const byId = new Map(nodes.map((n) => [n.id, n]));
48 return graph.getOutgoingEdgesFrom(nodes.map((n) => n.id), ['calls'])
49 .map((e) => {
50 const source = byId.get(e.source);
51 const target = byId.get(e.target);
52 return withFiles
53 ? `${source?.filePath}: ${e.metadata?.refName} -> ${target?.filePath}::${target?.qualifiedName}`
54 : `${e.metadata?.refName} -> ${target?.qualifiedName}`;
55 })
56 .sort();
57}
58
59const CLASSES = {
60 'package.json': JSON.stringify({ name: 'app' }),

Calls 8

pushMethod · 0.80
getFilesMethod · 0.80
mapMethod · 0.80
getNodesInFileMethod · 0.65
getMethod · 0.65
joinMethod · 0.45
initMethod · 0.45
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected