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

Function outOf

__tests__/rust-method-path-value.test.ts:37–44  ·  view source on GitHub ↗

What `fn` references or calls, as ` : `, sorted.

(graph: CodeGraph, fn: string)

Source from the content-addressed store, hash-verified

35
36/** What `fn` references or calls, as `<kind> <file>:<qualified name>`, sorted. */
37function outOf(graph: CodeGraph, fn: string): string[] {
38 const node = graph.getNodesByName(fn).find((n) => n.kind === 'function' || n.kind === 'method');
39 expect(node, fn).toBeDefined();
40 return graph.getOutgoingEdges(node!.id)
41 .filter((e) => e.kind === 'references' || e.kind === 'calls')
42 .map((e) => { const t = graph.getNode(e.target)!; return `${e.kind} ${t.filePath}:${t.qualifiedName}`; })
43 .sort();
44}
45
46const GRAPH = 'pub struct Graph { n: u32 }\n\nimpl Graph {\n pub fn counts(&self) -> u32 { self.n }\n}\n';
47

Callers 2

targetsFunction · 0.70

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesByNameMethod · 0.65
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected