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

Function calls

__tests__/python-external-module-receiver.test.ts:18–35  ·  view source on GitHub ↗
(files: Record<string, string>, fromName: string)

Source from the content-addressed store, hash-verified

16let cg: CodeGraph | null = null;
17
18async function calls(files: Record<string, string>, fromName: string): Promise<string[]> {
19 tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-2599-'));
20 for (const [rel, source] of Object.entries(files)) {
21 fs.mkdirSync(path.dirname(path.join(tempDir, rel)), { recursive: true });
22 fs.writeFileSync(path.join(tempDir, rel), source);
23 }
24 cg = await CodeGraph.init(tempDir, { index: true });
25 cg.resolveReferences();
26 const from = cg.getNodesByKind('function').find((n) => n.name === fromName)!;
27 expect(from).toBeDefined();
28 return cg
29 .getOutgoingEdges(from.id)
30 .filter((e) => e.kind === 'calls')
31 .map((e) => cg!.getNode(e.target))
32 .filter((n): n is NonNullable<typeof n> => !!n)
33 .map((n) => `${n.kind}:${n.qualifiedName}`)
34 .sort();
35}
36
37afterEach(() => {
38 cg?.close();

Calls 7

resolveReferencesMethod · 0.80
mapMethod · 0.80
getNodeMethod · 0.80
getNodesByKindMethod · 0.65
joinMethod · 0.45
initMethod · 0.45
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected