The qualified name each `calls` edge out of the method reaches, by the reference that made it.
(cg: CodeGraph, file: string, method: string)
| 99 | |
| 100 | /** The qualified name each `calls` edge out of the method reaches, by the reference that made it. */ |
| 101 | function 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 | |
| 114 | const addToCalls = (cg: CodeGraph): Record<string, string[]> => callsOf(cg, 'lib/reference.rb', 'Reference::add_to'); |
| 115 | const FLOWED = { 'table.column': ['TableDefinition::column'], 'table.index': ['TableDefinition::index'] }; |
no test coverage detected