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

Function links

__tests__/go-asserted-locals.test.ts:283–294  ·  view source on GitHub ↗

* ` -> :: ` for every edge * of `kind` the function `name` in `file` has to a function or method.

(file: string, name: string, kind: 'calls' | 'references' = 'calls')

Source from the content-addressed store, hash-verified

281 * of `kind` the function `name` in `file` has to a function or method.
282 */
283 function links(file: string, name: string, kind: 'calls' | 'references' = 'calls'): string[] {
284 const fn = cg!.getNodesInFile(file).find((n) => n.qualifiedName === name && n.kind === 'function');
285 expect(fn, `${name} in ${file}`).toBeDefined();
286 const lines = FILES[file]!.split('\n');
287 return cg!
288 .getOutgoingEdges(fn!.id)
289 .filter((e) => e.kind === kind)
290 .map((e) => ({ e, target: cg!.getNode(e.target)! }))
291 .filter(({ target }) => target.kind === 'method' || target.kind === 'function')
292 .map(({ e, target }) => `${lines[e.line! - 1]!.trim()} -> ${target.filePath}::${target.qualifiedName}`)
293 .sort();
294 }
295
296 it('links nothing through an asserted type from outside the project', () => {
297 // Name matching took alpha's BufFlusher::Flush, whose owner shares the

Callers 1

Calls 4

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

Tested by

no test coverage detected