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

Function importEdges

__tests__/python-from-import-module-file.test.ts:28–38  ·  view source on GitHub ↗

`kind:name@file` of every target of an `imports` edge from `fromFile`'s file node, sorted.

(fromFile: string)

Source from the content-addressed store, hash-verified

26
27/** `kind:name@file` of every target of an `imports` edge from `fromFile`'s file node, sorted. */
28function importEdges(fromFile: string): string[] {
29 const file = cg!.getNodesByKind('file').find((n) => n.filePath === fromFile)!;
30 expect(file).toBeDefined();
31 return cg!
32 .getOutgoingEdges(file.id)
33 .filter((e) => e.kind === 'imports')
34 .map((e) => cg!.getNode(e.target))
35 .filter((n): n is NonNullable<typeof n> => !!n)
36 .map((n) => `${n.kind}:${n.name}@${n.filePath}`)
37 .sort();
38}
39
40async function indexed(files: Record<string, string>): Promise<void> {
41 tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-from-module-'));

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesByKindMethod · 0.65
getOutgoingEdgesMethod · 0.45

Tested by

no test coverage detected