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

Function targetsOf

__tests__/python-dotted-chain-target.test.ts:39–50  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

37`;
38
39async function targetsOf(body: string): Promise<string[]> {
40 const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-py-chain-'));
41 roots.push(root);
42 fs.writeFileSync(path.join(root, 'response.py'), RESPONSE);
43 fs.writeFileSync(path.join(root, 'use.py'), `from response import HttpResponse\n\n\ndef caller(self):\n ${body}\n`);
44 const cg = await CodeGraph.init(root, { index: true });
45 graphs.push(cg);
46 const fn = cg.getNodesByName('caller')[0]!;
47 return cg.getOutgoingEdges(fn.id)
48 .filter((e) => e.kind === 'calls' || e.kind === 'instantiates')
49 .map((e) => `${e.kind} ${cg.getNode(e.target)!.qualifiedName}`);
50}
51
52describe('a Python chain through an imported class', () => {
53 it.each([

Calls 7

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

Tested by

no test coverage detected