* How many OTHER files depend on each of the given files. * * Counted through the symbols, not the file nodes: an `imports` edge points * at the imported symbol, so a file node almost never receives one and * counting edges into it would report every file as depended on by nobody. * S
(filePaths: string[])
| 3275 | * in the index reaches into this file" — the honest reading of a root. |
| 3276 | */ |
| 3277 | getFileDependentCounts(filePaths: string[]): Array<{ filePath: string; dependents: number }> { |
| 3278 | if (filePaths.length === 0) return []; |
| 3279 | return this.db |
| 3280 | .prepare( |
| 3281 | `SELECT tn.file_path AS filePath, COUNT(DISTINCT sn.file_path) AS dependents |
| 3282 | FROM edges e |
| 3283 | JOIN nodes tn ON tn.id = e.target |
| 3284 | JOIN nodes sn ON sn.id = e.source |
| 3285 | WHERE e.kind != 'contains' |
| 3286 | AND tn.file_path IN (SELECT value FROM json_each(?)) |
| 3287 | AND sn.file_path <> tn.file_path |
| 3288 | GROUP BY tn.file_path` |
| 3289 | ) |
| 3290 | .all(JSON.stringify(filePaths)) as Array<{ filePath: string; dependents: number }>; |
| 3291 | } |
| 3292 | |
| 3293 | /** |
| 3294 | * How far each of the given files reaches OUT: distinct other files its |
no test coverage detected