MCPcopy Index your code
hub / github.com/continuedev/continue / getIndexesToBuild

Method getIndexesToBuild

core/indexing/CodebaseIndexer.ts:146–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144 }
145
146 protected async getIndexesToBuild(): Promise<CodebaseIndex[]> {
147 const { config } = await this.configHandler.loadConfig();
148 if (!config) {
149 return [];
150 }
151
152 const embeddingsModel = config.selectedModelByRole.embed;
153 if (!embeddingsModel) {
154 return [];
155 }
156
157 const ideSettings = await this.ide.getIdeSettings();
158 if (!ideSettings) {
159 return [];
160 }
161 const continueServerClient = new ContinueServerClient(
162 ideSettings.remoteConfigServerUrl,
163 ideSettings.userToken,
164 );
165 if (!continueServerClient) {
166 return [];
167 }
168
169 const indexTypesToBuild = new Set( // use set to remove duplicates
170 config.contextProviders
171 .map((provider) => provider.description.dependsOnIndexing)
172 .filter((indexType) => Array.isArray(indexType)) // remove undefined indexTypes
173 .flat(),
174 );
175
176 const indexTypeToIndexerMapping: Record<
177 ContextIndexingType,
178 () => Promise<CodebaseIndex | null>
179 > = {
180 chunk: async () =>
181 new ChunkCodebaseIndex(
182 this.ide.readFile.bind(this.ide),
183 continueServerClient,
184 embeddingsModel.maxEmbeddingChunkSize,
185 ),
186 codeSnippets: async () => new CodeSnippetsCodebaseIndex(this.ide),
187 fullTextSearch: async () => new FullTextSearchCodebaseIndex(),
188 embeddings: async () => {
189 const lanceDbIndex = await LanceDbIndex.create(
190 embeddingsModel,
191 this.ide.readFile.bind(this.ide),
192 );
193 return lanceDbIndex;
194 },
195 };
196
197 const indexes: CodebaseIndex[] = [];
198 // not parallelizing to avoid race conditions in sqlite
199 for (const indexType of indexTypesToBuild) {
200 if (indexType && indexType in indexTypeToIndexerMapping) {
201 const index = await indexTypeToIndexerMapping[indexType]();
202 if (index) {
203 indexes.push(index);

Callers 3

refreshFileMethod · 0.95
indexFilesMethod · 0.95
wasAnyOneIndexAddedMethod · 0.95

Calls 4

getIdeSettingsMethod · 0.65
pushMethod · 0.65
loadConfigMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected