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

Function callsFromMethod

__tests__/bare-call-no-method.test.ts:17–30  ·  view source on GitHub ↗
(source: string, methodName: string)

Source from the content-addressed store, hash-verified

15let cg: CodeGraph | null = null;
16
17async function callsFromMethod(source: string, methodName: string): Promise<string[]> {
18 tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-1714-'));
19 fs.writeFileSync(path.join(tempDir, 'record.ts'), source);
20 cg = await CodeGraph.init(tempDir, { index: true });
21 cg.resolveReferences();
22 const from = cg.getNodesByKind('method').find((n) => n.name === methodName)!;
23 expect(from).toBeDefined();
24 return cg
25 .getOutgoingEdges(from.id)
26 .filter((e) => e.kind === 'calls')
27 .map((e) => cg!.getNode(e.target))
28 .filter((n): n is NonNullable<typeof n> => !!n)
29 .map((n) => `${n.kind}:${n.qualifiedName ?? n.name}`);
30}
31
32afterEach(() => {
33 cg?.close();

Callers 1

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