MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / buildIdentifierDocsForFile

Function buildIdentifierDocsForFile

src/tools/semantic-identifiers.ts:155–178  ·  view source on GitHub ↗
(rootDir: string, relativePath: string)

Source from the content-addressed store, hash-verified

153}
154
155async function buildIdentifierDocsForFile(rootDir: string, relativePath: string): Promise<IdentifierDoc[]> {
156 const normalized = normalizeRelativePath(relativePath);
157 const fullPath = resolve(rootDir, normalized);
158 if (!isSupportedFile(fullPath)) return [];
159
160 try {
161 const analysis = await analyzeFile(fullPath);
162 const flat = flattenSymbols(analysis.symbols);
163 return flat.map((symbol) => ({
164 id: `${normalized}:${symbol.name}:${symbol.line}`,
165 path: normalized,
166 header: analysis.header,
167 name: symbol.name,
168 kind: symbol.kind,
169 line: symbol.line,
170 endLine: symbol.endLine,
171 signature: symbol.signature,
172 parentName: symbol.parentName,
173 text: `${symbol.name} ${symbol.kind} ${symbol.signature} ${normalized} ${analysis.header} ${symbol.parentName ?? ""}`,
174 }));
175 } catch {
176 return [];
177 }
178}
179
180async function buildIdentifierIndex(rootDir: string): Promise<IdentifierIndex> {
181 if (cachedIndex && cachedRootDir === rootDir && Date.now() - cachedAt < INDEX_TTL_MS) {

Callers 1

Calls 4

isSupportedFileFunction · 0.85
analyzeFileFunction · 0.85
flattenSymbolsFunction · 0.85
normalizeRelativePathFunction · 0.70

Tested by

no test coverage detected