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

Function calls

__tests__/python-subscript-receivers.test.ts:28–38  ·  view source on GitHub ↗

Index one module and return the qualified names a function's call lines reach, by line.

(source: string, fn: string)

Source from the content-addressed store, hash-verified

26
27 /** Index one module and return the qualified names a function's call lines reach, by line. */
28 async function calls(source: string, fn: string): Promise<Array<[number, string]>> {
29 root = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-py-subscript-'));
30 fs.writeFileSync(path.join(root, 'a.py'), source);
31 const graph = (cg = await CodeGraph.init(root, { index: true }));
32 const node = graph.getNodesByName(fn).find((n) => n.kind === 'function' || n.kind === 'method')!;
33 return graph
34 .getOutgoingEdges(node.id)
35 .filter((e) => e.kind === 'calls')
36 .map((e): [number, string] => [e.line ?? 0, graph.getNode(e.target)!.qualifiedName])
37 .sort((a, b) => a[0] - b[0]);
38 }
39
40 const classes = [
41 'class Log:',

Calls 6

mapMethod · 0.80
getNodeMethod · 0.80
getNodesByNameMethod · 0.65
joinMethod · 0.45
initMethod · 0.45
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected