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

Function calls

__tests__/python-module-global-receiver-call.test.ts:17–34  ·  view source on GitHub ↗
(files: Record<string, string>, fromName: string)

Source from the content-addressed store, hash-verified

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