* Distinct node names present in the given files — the symbol names a sync * pass uses to look up retryable failed refs after those files changed. * `kinds` narrows them to nodes of those kinds.
(filePaths: string[], kinds?: readonly NodeKind[])
| 5711 | * `kinds` narrows them to nodes of those kinds. |
| 5712 | */ |
| 5713 | getNodeNamesByFiles(filePaths: string[], kinds?: readonly NodeKind[]): string[] { |
| 5714 | if (filePaths.length === 0) return []; |
| 5715 | const kindFilter = kinds ? ` AND kind IN (${kinds.map(() => '?').join(',')})` : ''; |
| 5716 | const names = new Set<string>(); |
| 5717 | for (let i = 0; i < filePaths.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 5718 | const chunk = filePaths.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 5719 | const placeholders = chunk.map(() => '?').join(','); |
| 5720 | const rows = this.db |
| 5721 | .prepare(`SELECT DISTINCT name FROM nodes WHERE file_path IN (${placeholders})${kindFilter}`) |
| 5722 | .all(...chunk, ...(kinds ?? [])) as Array<{ name: string }>; |
| 5723 | for (const row of rows) names.add(row.name); |
| 5724 | } |
| 5725 | return [...names]; |
| 5726 | } |
| 5727 | |
| 5728 | /** |
| 5729 | * Distinct `file\0name` pairs defined by the given files — the shape sync's |