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

Function callsOf

__tests__/parameter-flow.test.ts:101–112  ·  view source on GitHub ↗

The qualified name each `calls` edge out of the method reaches, by the reference that made it.

(cg: CodeGraph, file: string, method: string)

Source from the content-addressed store, hash-verified

99
100/** The qualified name each `calls` edge out of the method reaches, by the reference that made it. */
101function callsOf(cg: CodeGraph, file: string, method: string): Record<string, string[]> {
102 const nodes = cg.getNodesInFile(file);
103 const source = nodes.find((n) => n.qualifiedName === method && n.kind === 'method');
104 expect(source, method).toBeDefined();
105 const calls: Record<string, string[]> = {};
106 for (const e of cg.getOutgoingEdgesFrom([source!.id])) {
107 if (e.kind !== 'calls') continue;
108 const name = String(e.metadata?.refName);
109 (calls[name] ??= []).push(cg.getNode(e.target)!.qualifiedName);
110 }
111 return calls;
112}
113
114const addToCalls = (cg: CodeGraph): Record<string, string[]> => callsOf(cg, 'lib/reference.rb', 'Reference::add_to');
115const FLOWED = { 'table.column': ['TableDefinition::column'], 'table.index': ['TableDefinition::index'] };

Callers 2

addToCallsFunction · 0.70

Calls 4

pushMethod · 0.80
getNodeMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected