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

Function reached

__tests__/pascal-implementation-calls.test.ts:92–102  ·  view source on GitHub ↗

For each call the method `from` makes to `name`, by line: the signature of the overload it reaches.

(name: string, from = 'Paint')

Source from the content-addressed store, hash-verified

90
91 /** For each call the method `from` makes to `name`, by line: the signature of the overload it reaches. */
92 function reached(name: string, from = 'Paint'): string[] {
93 const caller = cg!.getNodesInFile('Win.pas').find((n) => n.name === from && n.kind === 'method');
94 expect(caller).toBeDefined();
95 return cg!
96 .getOutgoingEdges(caller!.id)
97 .filter((e) => e.kind === 'calls')
98 .map((e) => ({ line: e.line ?? 0, target: cg!.getNode(e.target)! }))
99 .filter((c) => c.target.name === name)
100 .sort((a, b) => a.line - b.line)
101 .map((c) => c.target.signature ?? '');
102 }
103
104 it('reaches the one-parameter overload for one argument, though the other is implemented nearer', () => {
105 expect(reached('SetRedraw')).toEqual(['(const Value: Boolean)', '(Handle: Integer; const Value: Boolean)']);

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected