* The python files whose failed attribute-chain refs (`self.client.send`, * `make().send`) an edit to `filePaths` can affect. Such an answer is read * only from files reached through imports — the owner class, its bases, a * factory and the class it returns are each looked up through the im
(filePaths: string[], depth: number = 6)
| 5603 | * directly or within `depth` hops, and the touched files themselves. |
| 5604 | */ |
| 5605 | getPythonImporterClosure(filePaths: string[], depth: number = 6): string[] { |
| 5606 | const closure = new Set<string>(filePaths); |
| 5607 | let frontier = [...filePaths]; |
| 5608 | for (let hop = 0; hop < depth && frontier.length > 0; hop++) { |
| 5609 | const next: string[] = []; |
| 5610 | for (let i = 0; i < frontier.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 5611 | const chunk = frontier.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 5612 | const placeholders = chunk.map(() => '?').join(','); |
| 5613 | const rows = this.db |
| 5614 | .prepare( |
| 5615 | `SELECT DISTINCT src.file_path AS file_path |
| 5616 | FROM edges e |
| 5617 | JOIN nodes tgt ON tgt.id = e.target |
| 5618 | JOIN nodes src ON src.id = e.source |
| 5619 | WHERE e.kind = 'imports' AND tgt.file_path IN (${placeholders}) AND src.language = 'python'` |
| 5620 | ) |
| 5621 | .all(...chunk) as Array<{ file_path: string }>; |
| 5622 | for (const row of rows) { |
| 5623 | if (!closure.has(row.file_path)) { |
| 5624 | closure.add(row.file_path); |
| 5625 | next.push(row.file_path); |
| 5626 | } |
| 5627 | } |
| 5628 | } |
| 5629 | frontier = next; |
| 5630 | } |
| 5631 | return [...closure]; |
| 5632 | } |
| 5633 | |
| 5634 | /** |
| 5635 | * The failed python attribute-chain refs — one attribute hop |