* Which of `names` the index has never seen: no node is called that, in any * case, and no indexed name, qualified name, signature or docstring has a * word starting with it. A file's path is its qualified name, so a folder or * file named that counts as seen too. Explore uses this to say p
(names: readonly string[])
| 2228 | * lower(name) index and FTS postings), never a source scan, at most 16 names. |
| 2229 | */ |
| 2230 | getUnseenNames(names: readonly string[]): string[] { |
| 2231 | const checked = [...new Set(names)].filter((n) => n.length > 0 && n.length <= 128).slice(0, 16); |
| 2232 | if (checked.length === 0) return []; |
| 2233 | if (!this.stmts.unseenName) { |
| 2234 | this.stmts.unseenName = this.db.prepare(` |
| 2235 | SELECT EXISTS (SELECT 1 FROM nodes WHERE lower(name) = lower(?)) |
| 2236 | OR EXISTS (SELECT 1 FROM nodes_fts WHERE nodes_fts MATCH ?) AS seen |
| 2237 | `); |
| 2238 | } |
| 2239 | const stmt = this.stmts.unseenName; |
| 2240 | return checked.filter((name) => { |
| 2241 | const member = name.split(/::|\./).pop()!; |
| 2242 | // FTS splits the phrase on everything but letters and digits, so a |
| 2243 | // snake_case name is matched as the words it is made of. |
| 2244 | const phrase = member.replace(/"/g, ''); |
| 2245 | if (phrase.length === 0) return false; |
| 2246 | const row = stmt.get(member, `{name qualified_name signature docstring} : "${phrase}"*`) as { seen: number }; |
| 2247 | return !row.seen; |
| 2248 | }); |
| 2249 | } |
| 2250 | |
| 2251 | /** |
| 2252 | * FTS5 search with prefix matching |
no test coverage detected