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

Function calls

__tests__/python-local-import-alias.test.ts:16–32  ·  view source on GitHub ↗
(files: Record<string, string>, fromName: string)

Source from the content-addressed store, hash-verified

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