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

Function aliasTargets

__tests__/const-alias-flow.test.ts:43–54  ·  view source on GitHub ↗

What the alias named `name` in `file` links on to: ` : `, sorted.

(cg: CodeGraph, file: string, name: string)

Source from the content-addressed store, hash-verified

41
42/** What the alias named `name` in `file` links on to: `<file>:<qualified name>`, sorted. */
43function aliasTargets(cg: CodeGraph, file: string, name: string): string[] {
44 const alias = cg.getNodesInFile(file).find((n) => n.name === name && (n.kind === 'constant' || n.kind === 'variable'));
45 expect(alias, `${file}: ${name}`).toBeDefined();
46 return cg
47 .getOutgoingEdgesFrom([alias!.id])
48 .filter((e) => (e.metadata as Record<string, unknown> | undefined)?.synthesizedBy === 'const-alias')
49 .map((e) => {
50 const t = cg.getNode(e.target);
51 return `${t?.filePath}:${t?.qualifiedName}`;
52 })
53 .sort();
54}
55
56/** The names on the flow a query finds, in order. */
57function flow(cg: CodeGraph, query: string): string[] {

Callers 1

Calls 4

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

Tested by

no test coverage detected