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

Function withIndex

__tests__/pascal-nested-routines.test.ts:24–37  ·  view source on GitHub ↗
(files: Record<string, string>, check: (cg: CodeGraph) => void)

Source from the content-addressed store, hash-verified

22});
23
24async function withIndex(files: Record<string, string>, check: (cg: CodeGraph) => void): Promise<void> {
25 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-pascal-nested-'));
26 try {
27 for (const [name, code] of Object.entries(files)) fs.writeFileSync(path.join(dir, name), code);
28 const cg = await CodeGraph.init(dir, { index: true });
29 try {
30 check(cg);
31 } finally {
32 cg.close();
33 }
34 } finally {
35 fs.rmSync(dir, { recursive: true, force: true });
36 }
37}
38
39function routine(cg: CodeGraph, qualifiedName: string) {
40 const node = cg.getNodesByKind('method').concat(cg.getNodesByKind('function')).find((n) => n.qualifiedName === qualifiedName);

Callers 1

Calls 4

checkFunction · 0.70
closeMethod · 0.65
joinMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected