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

Function fnRefsFrom

__tests__/function-ref-package-imports.test.ts:38–48  ·  view source on GitHub ↗

` -> : ` for each function-as-value edge leaving `file`.

(cg: CodeGraph, file: string)

Source from the content-addressed store, hash-verified

36
37/** `<value name> -> <target file>:<target qualified name>` for each function-as-value edge leaving `file`. */
38function fnRefsFrom(cg: CodeGraph, file: string): string[] {
39 const ids = cg.getNodesInFile(file).map((n) => n.id);
40 return [...new Set(cg
41 .getOutgoingEdgesFrom(ids)
42 .filter((e) => e.metadata?.fnRef === true)
43 .map((e) => {
44 const target = cg.getNode(e.target);
45 return `${String(e.metadata?.refName)} -> ${target?.filePath}:${target?.qualifiedName}`;
46 }))]
47 .sort();
48}
49
50describe('a function value the file imports from a package', () => {
51 it('never lands on a project function of the same name', async () => {

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected