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

Method indexFiles

src/extraction/index.ts:2099–2141  ·  view source on GitHub ↗

* Index specific files

(filePaths: string[])

Source from the content-addressed store, hash-verified

2097 * Index specific files
2098 */
2099 async indexFiles(filePaths: string[]): Promise<IndexResult> {
2100 const startTime = Date.now();
2101 const errors: ExtractionError[] = [];
2102 let filesIndexed = 0;
2103 let filesSkipped = 0;
2104 let filesErrored = 0;
2105 let totalNodes = 0;
2106 let totalEdges = 0;
2107
2108 for (const filePath of filePaths) {
2109 const result = await this.indexFile(filePath);
2110
2111 if (result.errors.length > 0) {
2112 errors.push(...result.errors);
2113 }
2114
2115 if (result.nodes.length > 0) {
2116 filesIndexed++;
2117 totalNodes += result.nodes.length;
2118 totalEdges += result.edges.length;
2119 } else if (result.errors.some((e) => e.severity === 'error')) {
2120 filesErrored++;
2121 } else {
2122 const tracked = this.queries.getFileByPath(filePath);
2123 if (tracked && isFileLevelOnlyLanguage(tracked.language)) {
2124 filesIndexed++;
2125 } else {
2126 filesSkipped++;
2127 }
2128 }
2129 }
2130
2131 return {
2132 success: filesIndexed > 0 || errors.filter((e) => e.severity === 'error').length === 0,
2133 filesIndexed,
2134 filesSkipped,
2135 filesErrored,
2136 nodesCreated: totalNodes,
2137 edgesCreated: totalEdges,
2138 errors,
2139 durationMs: Date.now() - startTime,
2140 };
2141 }
2142
2143 /**
2144 * Index a single file

Callers

nothing calls this directly

Calls 3

indexFileMethod · 0.95
isFileLevelOnlyLanguageFunction · 0.90
getFileByPathMethod · 0.80

Tested by

no test coverage detected