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

Function dispatch

__tests__/go-promoted-dispatch.test.ts:263–273  ·  view source on GitHub ↗

Where a call through the method dispatches, as `Target::m` or `Target::m <- promotedInto @registeredAt`.

(graph: CodeGraph, method: Node)

Source from the content-addressed store, hash-verified

261
262/** Where a call through the method dispatches, as `Target::m` or `Target::m <- promotedInto @registeredAt`. */
263function dispatch(graph: CodeGraph, method: Node): string[] {
264 return graph
265 .getOutgoingEdgesFrom([method.id], ['calls'])
266 .filter((e) => meta(e).synthesizedBy === 'interface-impl')
267 .map((e) => {
268 const target = graph.getNode(e.target)?.qualifiedName;
269 const into = meta(e).promotedInto;
270 return into === undefined ? `${target}` : `${target} <- ${into} @${meta(e).registeredAt}`;
271 })
272 .sort();
273}
274
275describe('a call through a Go interface reaches the method embedding promotes', () => {
276 it('links the interface method to the embedded type that declares it', () => {

Callers 2

closeFunction · 0.70

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
metaFunction · 0.70
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected