(files: Record<string, string>, check: (cg: CodeGraph) => void)
| 25 | }); |
| 26 | |
| 27 | async function withIndex(files: Record<string, string>, check: (cg: CodeGraph) => void): Promise<void> { |
| 28 | const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-pascal-system-')); |
| 29 | try { |
| 30 | for (const [name, code] of Object.entries(files)) fs.writeFileSync(path.join(dir, name), code); |
| 31 | const cg = await CodeGraph.init(dir, { index: true }); |
| 32 | try { |
| 33 | check(cg); |
| 34 | } finally { |
| 35 | cg.close(); |
| 36 | } |
| 37 | } finally { |
| 38 | fs.rmSync(dir, { recursive: true, force: true }); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /** The calls a routine makes, as `line: Target::Name`. */ |
| 43 | function callsFrom(cg: CodeGraph, qualifiedName: string): string[] { |
no test coverage detected