| 47 | }; |
| 48 | |
| 49 | const indexAndCollect = async (): Promise<{ edges: EdgeRow[]; nodes: number }> => { |
| 50 | fs.rmSync(path.join(dir, '.codegraph'), { recursive: true, force: true }); |
| 51 | const cg = await CodeGraph.init(dir, { silent: true }); |
| 52 | await cg.indexAll(); |
| 53 | const db = (cg as any).db.db; |
| 54 | const edges: EdgeRow[] = db |
| 55 | .prepare( |
| 56 | `SELECT s.name src, t.name tgt, json_extract(e.metadata,'$.via') via, e.line line |
| 57 | FROM edges e JOIN nodes s ON s.id = e.source JOIN nodes t ON t.id = e.target |
| 58 | WHERE json_extract(e.metadata,'$.synthesizedBy') = 'fn-pointer-dispatch' |
| 59 | ORDER BY e.id` |
| 60 | ) |
| 61 | .all(); |
| 62 | const nodes = db.prepare('SELECT count(*) c FROM nodes').get().c as number; |
| 63 | cg.close?.(); |
| 64 | return { edges, nodes }; |
| 65 | }; |
| 66 | |
| 67 | const writeFixture = () => { |
| 68 | // The git shape + designated init + assignment registration. |