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

Function targetsOn

__tests__/rust-path-same-file.test.ts:20–30  ·  view source on GitHub ↗
(cg: CodeGraph, file: string, line: number, name: string)

Source from the content-addressed store, hash-verified

18
19/** What `file` links `name` to on `line`, as `kind qualifiedName file@line`, sorted. */
20const targetsOn = (cg: CodeGraph, file: string, line: number, name: string): string[] => {
21 const out: string[] = [];
22 for (const node of cg.getNodesInFile(file)) {
23 for (const edge of cg.getOutgoingEdges(node.id)) {
24 if (edge.line !== line) continue;
25 const target = cg.getNode(edge.target)!;
26 if (target.name === name) out.push(`${target.kind} ${target.qualifiedName} ${target.filePath}@${target.startLine}`);
27 }
28 }
29 return [...new Set(out)].sort();
30};
31
32describe('a Rust path into another module, type or crate', () => {
33 let root = '';

Callers 1

Calls 4

getNodeMethod · 0.80
pushMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected