* 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>)
| 3093 | * Chunked probe over `idx_nodes_name`, bounded by the caller's candidate list. |
| 3094 | */ |
| 3095 | getAmbiguousReferencedNames(names: Iterable<string>): Set<string> { |
| 3096 | const unique = [...new Set(names)].filter((name) => name.length > 0); |
| 3097 | const found = new Set<string>(); |
| 3098 | if (unique.length === 0) return found; |
| 3099 | |
| 3100 | for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 3101 | const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 3102 | const placeholders = chunk.map(() => '?').join(','); |
| 3103 | const rows = this.db |
| 3104 | .prepare( |
| 3105 | `SELECT name FROM ( |
| 3106 | SELECT n.name AS name, |
| 3107 | EXISTS ( |
| 3108 | SELECT 1 FROM edges e |
| 3109 | WHERE e.target = n.id AND e.kind != 'contains' |
| 3110 | ) AS referenced |
| 3111 | FROM nodes n |
| 3112 | WHERE n.name IN (${placeholders}) |
| 3113 | ) |
| 3114 | GROUP BY name |
| 3115 | HAVING COUNT(*) > 1 AND SUM(referenced) > 0` |
| 3116 | ) |
| 3117 | .all(...chunk) as Array<{ name: string }>; |
| 3118 | for (const row of rows) found.add(row.name); |
| 3119 | } |
| 3120 | return found; |
| 3121 | } |
| 3122 | |
| 3123 | /** |
| 3124 | * Which of the given languages the index records an EXPORT marker for. |