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

Function callsFrom

__tests__/python-receiver-rebinding.test.ts:193–202  ·  view source on GitHub ↗
(file: string, name: string)

Source from the content-addressed store, hash-verified

191
192 /** `file:name` of each project function `name` in `file` calls, sorted. */
193 const callsFrom = (file: string, name: string): string[] => {
194 const from = cg!.getNodesInFile(file).filter((n) => n.name === name && (n.kind === 'function' || n.kind === 'method'));
195 expect(from, `${name} in ${file}`).toHaveLength(1);
196 return cg!.getOutgoingEdgesFrom([from[0]!.id])
197 .filter((e) => e.kind === 'calls')
198 .map((e) => cg!.getNode(e.target)!)
199 .filter((t) => t.filePath.startsWith('src/'))
200 .map((t) => `${t.filePath}:${t.name}`)
201 .sort();
202 };
203
204 it('a call where nothing nearer binds the name reaches the module', () => {
205 expect(callsFrom('tests/shadow.py', 'real')).toEqual(['src/pkg/other.py:persist', 'src/pkg/other.py:update']);

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected