* 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)
| 5714 | * directly or within `depth` hops, and the touched files themselves. |
| 5715 | */ |
| 5716 | getPythonImporterClosure(filePaths: string[], depth: number = 6): string[] { |
| 5717 | const closure = new Set<string>(filePaths); |
| 5718 | let frontier = [...filePaths]; |
| 5719 | for (let hop = 0; hop < depth && frontier.length > 0; hop++) { |
| 5720 | const next: string[] = []; |
| 5721 | for (let i = 0; i < frontier.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 5722 | const chunk = frontier.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 5723 | const placeholders = chunk.map(() => '?').join(','); |
| 5724 | const rows = this.db |
| 5725 | .prepare( |
| 5726 | `SELECT DISTINCT src.file_path AS file_path |
| 5727 | FROM edges e |
| 5728 | JOIN nodes tgt ON tgt.id = e.target |
| 5729 | JOIN nodes src ON src.id = e.source |
| 5730 | WHERE e.kind = 'imports' AND tgt.file_path IN (${placeholders}) AND src.language = 'python'` |
| 5731 | ) |
| 5732 | .all(...chunk) as Array<{ file_path: string }>; |
| 5733 | for (const row of rows) { |
| 5734 | if (!closure.has(row.file_path)) { |
| 5735 | closure.add(row.file_path); |
| 5736 | next.push(row.file_path); |
| 5737 | } |
| 5738 | } |
| 5739 | } |
| 5740 | frontier = next; |
| 5741 | } |
| 5742 | return [...closure]; |
| 5743 | } |
| 5744 | |
| 5745 | /** |
| 5746 | * The failed python attribute-chain refs — one attribute hop |