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

Function withIndex

__tests__/pascal-chained-calls.test.ts:94–107  ·  view source on GitHub ↗
(code: string, check: (cg: CodeGraph) => void)

Source from the content-addressed store, hash-verified

92}
93
94async function withIndex(code: string, check: (cg: CodeGraph) => void): Promise<void> {
95 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-pascal-chain-'));
96 try {
97 fs.writeFileSync(path.join(dir, 'Unit1.pas'), code);
98 const cg = await CodeGraph.init(dir, { index: true });
99 try {
100 check(cg);
101 } finally {
102 cg.close();
103 }
104 } finally {
105 fs.rmSync(dir, { recursive: true, force: true });
106 }
107}
108
109function edgesFrom(cg: CodeGraph, sourceName: string): string[] {
110 const source = cg.getNodesByKind('function').concat(cg.getNodesByKind('method')).find((n) => n.name === sourceName);

Callers 1

Calls 4

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

Tested by

no test coverage detected