| 23 | }); |
| 24 | |
| 25 | async function callsIn(files: Record<string, string>): Promise<string[]> { |
| 26 | const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-py-self-')); |
| 27 | dirs.push(dir); |
| 28 | for (const [rel, content] of Object.entries(files)) { |
| 29 | fs.mkdirSync(path.dirname(path.join(dir, rel)), { recursive: true }); |
| 30 | fs.writeFileSync(path.join(dir, rel), content); |
| 31 | } |
| 32 | cg = await CodeGraph.init(dir, { index: true }); |
| 33 | const rows = (cg as any).db.db |
| 34 | .prepare( |
| 35 | `SELECT s.qualified_name s, t.qualified_name t, t.file_path f FROM edges e |
| 36 | JOIN nodes s ON s.id = e.source JOIN nodes t ON t.id = e.target WHERE e.kind = 'calls'`, |
| 37 | ) |
| 38 | .all() as { s: string; t: string; f: string }[]; |
| 39 | return rows.map((r) => `${r.s} -> ${r.t} (${r.f})`).sort(); |
| 40 | } |
| 41 | |
| 42 | const httpkit = 'def get_ip(request):\n return "1.2.3.4"\n'; |
| 43 | |