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

Function linksFrom

__tests__/go-framework-own-package.test.ts:159–167  ·  view source on GitHub ↗
(file: string, name: string, from?: { kind?: string; name?: string })

Source from the content-addressed store, hash-verified

157 * or named `from`) whose target is named `name`, deduplicated and sorted.
158 */
159const linksFrom = (file: string, name: string, from?: { kind?: string; name?: string }) => {
160 const sources = cg.getNodesInFile(file).filter((n) => (!from?.kind || n.kind === from.kind) && (!from?.name || n.name === from.name));
161 const links = cg.getOutgoingEdgesFrom(sources.map((n) => n.id))
162 .filter((e) => e.kind !== 'contains')
163 .map((e) => ({ kind: e.kind, target: cg.getNode(e.target)! }))
164 .filter(({ target }) => target.name === name)
165 .map(({ kind, target }) => `${kind} ${target.filePath}:${target.qualifiedName}`);
166 return [...new Set(links)].sort();
167};
168
169describe('Go framework heuristics pick only in the package Go reads the name from', () => {
170 it('a bare type is its own package’s interface, not another package’s struct', () => {

Calls 4

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

Tested by

no test coverage detected