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

Function importsOf

__tests__/php-web-root-includes.test.ts:48–57  ·  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

46
47/** The files anything in `file` imports (the file, or its namespace), sorted. */
48function importsOf(graph: CodeGraph, file: string): string[] {
49 const out = new Set<string>();
50 for (const node of graph.getNodesInFile(file)) {
51 for (const e of graph.getOutgoingEdges(node.id)) {
52 const t = graph.getNode(e.target);
53 if (e.kind === 'imports' && t?.kind === 'file') out.add(t.filePath);
54 }
55 }
56 return [...out].sort();
57}
58
59const fn = (name: string) => `<?php\nfunction ${name}() {}\n`;
60const config = (webRoot: unknown) => JSON.stringify({ webRoot });

Callers 1

Calls 4

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

Tested by

no test coverage detected