* Get unresolved references scoped to specific file paths. * Uses the idx_unresolved_file_path index for efficient lookup.
(filePaths: string[])
| 4831 | * Uses the idx_unresolved_file_path index for efficient lookup. |
| 4832 | */ |
| 4833 | getUnresolvedReferencesByFiles(filePaths: string[]): UnresolvedReference[] { |
| 4834 | if (filePaths.length === 0) return []; |
| 4835 | |
| 4836 | // Chunk under SQLite's parameter limit: the first sync of a very large repo |
| 4837 | // passes every changed file here, which an unbounded `IN (...)` would bind |
| 4838 | // as one parameter each — exceeding MAX_VARIABLE_NUMBER and aborting with |
| 4839 | // "too many SQL variables". (#540) |
| 4840 | const rows: UnresolvedRefRow[] = []; |
| 4841 | for (let i = 0; i < filePaths.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 4842 | const chunk = filePaths.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 4843 | const placeholders = chunk.map(() => '?').join(','); |
| 4844 | const chunkRows = this.db |
| 4845 | .prepare(`SELECT * FROM unresolved_refs WHERE status = 'pending' AND file_path IN (${placeholders})`) |
| 4846 | .all(...chunk) as UnresolvedRefRow[]; |
| 4847 | // Append with a loop, never a spread: the INPUT chunk is bounded, but |
| 4848 | // the RESULT rows per chunk are not — a dense recovery sync (e.g. the |
| 4849 | // #1541 self-heal re-indexing hundreds of files) returns more rows than |
| 4850 | // V8 allows as arguments, and `push(...chunkRows)` dies with "Maximum |
| 4851 | // call stack size exceeded", aborting resolution mid-sync (#1558). |
| 4852 | for (const row of chunkRows) rows.push(row); |
| 4853 | } |
| 4854 | |
| 4855 | return rows.map((row) => ({ |
| 4856 | fromNodeId: row.from_node_id, |
| 4857 | referenceName: row.reference_name, |
| 4858 | referenceKind: row.reference_kind as EdgeKind, |
| 4859 | line: row.line, |
| 4860 | column: row.col, |
| 4861 | candidates: row.candidates ? safeJsonParse(row.candidates, undefined) : undefined, |
| 4862 | filePath: row.file_path, |
| 4863 | language: row.language as Language, |
| 4864 | rowId: row.id, |
| 4865 | })); |
| 4866 | } |
| 4867 | |
| 4868 | /** |
| 4869 | * Delete all unresolved references (after resolution) |
no test coverage detected