MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / indexFile

Method indexFile

src/codegraph/indexer.ts:144–160  ·  view source on GitHub ↗

Index just a single file (used for live updates after a write_file).

(filePath: string)

Source from the content-addressed store, hash-verified

142
143 /** Index just a single file (used for live updates after a write_file). */
144 async indexFile(filePath: string): Promise<{ symbols: number } | null> {
145 try {
146 const stat = await fs.stat(filePath);
147 const lang = detectLanguage(filePath);
148 if (!lang || stat.size > MAX_FILE_SIZE) return null;
149 const buf = await fs.readFile(filePath);
150 if (isBinaryBuffer(buf)) return null;
151 const contentHash = crypto.createHash('sha256').update(buf).digest('hex').slice(0, 16);
152 const source = buf.toString('utf-8');
153 const symbols = await extractSymbols(filePath, source);
154 this.db.replaceFileSymbols(filePath, lang, stat.mtimeMs, stat.size, contentHash, symbols);
155 return { symbols: symbols.length };
156 } catch (e: any) {
157 logger.debug('indexFile failed', { filePath, err: e.message });
158 return null;
159 }
160 }
161
162 private async walk(dir: string, onFile: (path: string) => void): Promise<void> {
163 let entries: any[];

Callers 1

runMethod · 0.80

Calls 6

detectLanguageFunction · 0.85
isBinaryBufferFunction · 0.85
extractSymbolsFunction · 0.85
updateMethod · 0.80
replaceFileSymbolsMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected