* Which of `names` are carried by MORE THAN ONE symbol, at least one of which * something points at. * * The false positive this exists to kill: `CodeGraph.getTopRouteFile` calls * `this.queries.getTopRouteFile()`, and the resolver — which prefers a * same-name definition in the call
(names: Iterable<string>)
| 3127 | * Chunked probe over `idx_nodes_name`, bounded by the caller's candidate list. |
| 3128 | */ |
| 3129 | getAmbiguousReferencedNames(names: Iterable<string>): Set<string> { |
| 3130 | const unique = [...new Set(names)].filter((name) => name.length > 0); |
| 3131 | const found = new Set<string>(); |
| 3132 | if (unique.length === 0) return found; |
| 3133 | |
| 3134 | for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 3135 | const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 3136 | const placeholders = chunk.map(() => '?').join(','); |
| 3137 | const rows = this.db |
| 3138 | .prepare( |
| 3139 | `SELECT name FROM ( |
| 3140 | SELECT n.name AS name, |
| 3141 | EXISTS ( |
| 3142 | SELECT 1 FROM edges e |
| 3143 | WHERE e.target = n.id AND e.kind != 'contains' |
| 3144 | ) AS referenced |
| 3145 | FROM nodes n |
| 3146 | WHERE n.name IN (${placeholders}) |
| 3147 | ) |
| 3148 | GROUP BY name |
| 3149 | HAVING COUNT(*) > 1 AND SUM(referenced) > 0` |
| 3150 | ) |
| 3151 | .all(...chunk) as Array<{ name: string }>; |
| 3152 | for (const row of rows) found.add(row.name); |
| 3153 | } |
| 3154 | return found; |
| 3155 | } |
| 3156 | |
| 3157 | /** |
| 3158 | * Which of the given languages the index records an EXPORT marker for. |