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

Function importsOf

__tests__/php-dir-includes.test.ts:37–46  ·  view source on GitHub ↗

The files anything in `file` imports (the file, or its namespace), sorted.

(graph: CodeGraph, file: string)

Source from the content-addressed store, hash-verified

35
36/** The files anything in `file` imports (the file, or its namespace), sorted. */
37function importsOf(graph: CodeGraph, file: string): string[] {
38 const out = new Set<string>();
39 for (const node of graph.getNodesInFile(file)) {
40 for (const e of graph.getOutgoingEdges(node.id)) {
41 const t = graph.getNode(e.target);
42 if (e.kind === 'imports' && t?.kind === 'file') out.add(t.filePath);
43 }
44 }
45 return [...out].sort();
46}
47
48const fn = (name: string) => `<?php\nfunction ${name}() {}\n`;
49

Callers 1

Calls 4

getNodeMethod · 0.80
getNodesInFileMethod · 0.65
getOutgoingEdgesMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected