@@ -31,10 +31,12 @@ class SourcePath(
31
31
) {
32
32
private val files = mutableMapOf<URI , SourceFile >()
33
33
private val parseDataWriteLock = ReentrantLock ()
34
- private val indexAsync = AsyncExecutor ()
35
34
36
- val index = SymbolIndex ()
35
+ private val indexAsync = AsyncExecutor ()
36
+ private var indexInitialized: Boolean = false
37
37
var indexEnabled: Boolean by indexingConfig::enabled
38
+ val index = SymbolIndex ()
39
+
38
40
var beforeCompileCallback: () -> Unit = {}
39
41
40
42
var progressFactory: Progress .Factory = Progress .Factory .None
@@ -104,7 +106,7 @@ class SourcePath(
104
106
compiledFile = parsed
105
107
}
106
108
107
- updateIndexAsync (container)
109
+ initializeIndexAsyncIfNeeded (container)
108
110
}
109
111
110
112
private fun doCompileIfChanged () {
@@ -211,8 +213,8 @@ class SourcePath(
211
213
}
212
214
213
215
// Only index normal files, not build files
214
- if (indexEnabled && kind == CompilationKind .DEFAULT ) {
215
- updateIndexAsync (container)
216
+ if (kind == CompilationKind .DEFAULT ) {
217
+ initializeIndexAsyncIfNeeded (container)
216
218
}
217
219
218
220
return context
@@ -229,11 +231,15 @@ class SourcePath(
229
231
}
230
232
231
233
/* *
232
- * Updates the symbol index asynchronously.
234
+ * Initialized the symbol index asynchronously, if not
235
+ * already done.
233
236
*/
234
- private fun updateIndexAsync (container : ComponentProvider ) = indexAsync.execute {
235
- val module = container.getService(ModuleDescriptor ::class .java)
236
- index.update(module)
237
+ private fun initializeIndexAsyncIfNeeded (container : ComponentProvider ) = indexAsync.execute {
238
+ if (indexEnabled && ! indexInitialized) {
239
+ indexInitialized = true
240
+ val module = container.getService(ModuleDescriptor ::class .java)
241
+ index.refresh(module)
242
+ }
237
243
}
238
244
239
245
/* *
0 commit comments