diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt index d3030087750..250e6b92e24 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt @@ -10,10 +10,9 @@ import org.jetbrains.jps.incremental.CompileContext import org.jetbrains.jps.incremental.FSOperations import org.jetbrains.jps.incremental.GlobalContextKey import org.jetbrains.jps.incremental.fs.CompilationRound +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.incremental.messages.CompilerMessage import org.jetbrains.kotlin.incremental.LookupSymbol -import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff -import org.jetbrains.kotlin.jps.incremental.CacheStatus -import org.jetbrains.kotlin.jps.incremental.loadDiff import org.jetbrains.kotlin.jps.incremental.* import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndex import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndexBuilder @@ -61,8 +60,6 @@ class KotlinCompileContext(val jpsContext: CompileContext) { val lookupsCacheAttributesManager: CompositeLookupsCacheAttributesManager = makeLookupsCacheAttributesManager() - val initialLookupsCacheStateDiff: CacheAttributesDiff<*> = loadLookupsCacheStateDiff() - val shouldCheckCacheVersions = System.getProperty(KotlinBuilder.SKIP_CACHE_VERSION_CHECK_PROPERTY) == null val hasKotlinMarker = HasKotlinMarker(dataManager) @@ -76,6 +73,12 @@ class KotlinCompileContext(val jpsContext: CompileContext) { var rebuildingAllKotlin = false + /** + * Note, [loadLookupsCacheStateDiff] should be initialized last as it requires initialized + * [targetsIndex], [hasKotlinMarker] and [rebuildAfterCacheVersionChanged] (see [markChunkForRebuildBeforeBuild]) + */ + private val initialLookupsCacheStateDiff: CacheAttributesDiff<*> = loadLookupsCacheStateDiff() + private fun makeLookupsCacheAttributesManager(): CompositeLookupsCacheAttributesManager { val expectedLookupsCacheComponents = mutableSetOf() @@ -102,7 +105,15 @@ class KotlinCompileContext(val jpsContext: CompileContext) { it.get(LookupSymbol("<#NAME#>", "<#SCOPE#>")) } } catch (e: Exception) { - jpsReportInternalBuilderError(jpsContext, Error("Lookup storage is corrupted, probe failed: ${e.message}", e)) + // replace to jpsReportInternalBuilderError when IDEA-201297 will be implemented + jpsContext.processMessage( + CompilerMessage( + "Kotlin", BuildMessage.Kind.WARNING, + "Incremental caches are corrupted. All Kotlin code will be rebuilt." + ) + ) + KotlinBuilder.LOG.info(Error("Lookup storage is corrupted, probe failed: ${e.message}", e)) + markAllKotlinForRebuild("Lookup storage is corrupted") return diff.copy(actual = null) }