MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / getUnseenNames

Method getUnseenNames

src/db/queries.ts:2214–2233  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

2212 * lower(name) index and FTS postings), never a source scan, at most 16 names.
2213 */
2214 getUnseenNames(names: readonly string[]): string[] {
2215 const checked = [...new Set(names)].filter((n) => n.length > 0 && n.length <= 128).slice(0, 16);
2216 if (checked.length === 0) return [];
2217 if (!this.stmts.unseenName) {
2218 this.stmts.unseenName = this.db.prepare(`
2219 SELECT EXISTS (SELECT 1 FROM nodes WHERE lower(name) = lower(?))
2220 OR EXISTS (SELECT 1 FROM nodes_fts WHERE nodes_fts MATCH ?) AS seen
2221 `);
2222 }
2223 const stmt = this.stmts.unseenName;
2224 return checked.filter((name) => {
2225 const member = name.split(/::|\./).pop()!;
2226 // FTS splits the phrase on everything but letters and digits, so a
2227 // snake_case name is matched as the words it is made of.
2228 const phrase = member.replace(/"/g, '');
2229 if (phrase.length === 0) return false;
2230 const row = stmt.get(member, `{name qualified_name signature docstring} : "${phrase}"*`) as { seen: number };
2231 return !row.seen;
2232 });
2233 }
2234
2235 /**
2236 * FTS5 search with prefix matching

Callers 1

handleExploreMethod · 0.45

Calls 2

prepareMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected