* Distinct `file\0name` pairs defined by the given files — the shape sync's * definition delta needs (CG-33). * * Deliberately NOT `getNodeNamesByFiles`: a bare name set is taken over the * WHOLE changed batch, so a name that moves between two files in one commit * (or exists in one c
(filePaths: string[])
| 5849 | * own fact, so the move is seen as one removal plus one addition. |
| 5850 | */ |
| 5851 | getNodeNamePairsByFiles(filePaths: string[]): Set<string> { |
| 5852 | const pairs = new Set<string>(); |
| 5853 | if (filePaths.length === 0) return pairs; |
| 5854 | for (let i = 0; i < filePaths.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 5855 | const chunk = filePaths.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 5856 | const placeholders = chunk.map(() => '?').join(','); |
| 5857 | const rows = this.db |
| 5858 | .prepare(`SELECT file_path, name, SUM(language = 'python' AND kind IN ('function', 'method')) AS python_defs |
| 5859 | FROM nodes WHERE file_path IN (${placeholders}) GROUP BY file_path, name`) |
| 5860 | .all(...chunk) as Array<{ file_path: string; name: string; python_defs: number }>; |
| 5861 | // NUL-joined: a path or a symbol name can contain a space, never a NUL. |
| 5862 | // A Python name a file defines more than once (typing.overload stubs and |
| 5863 | // the def below them) also counts its defs, behind a \u0001 in the file's |
| 5864 | // half: adding or removing the implementation moves every call to the |
| 5865 | // name (#2963) while the set of names stays the same. |
| 5866 | for (const row of rows) { |
| 5867 | const file = row.python_defs > 1 ? `${row.file_path}\u0001${row.python_defs}` : row.file_path; |
| 5868 | pairs.add(`${file}\0${row.name}`); |
| 5869 | } |
| 5870 | } |
| 5871 | return pairs; |
| 5872 | } |
| 5873 | |
| 5874 | /** |
| 5875 | * The `file\0statement` pairs of the `export … from` statements in |