diff --git a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt index 0d74c47f9da..800b41b613c 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt @@ -193,7 +193,7 @@ open class IncrementalCacheImpl( // As a workaround we can remove proto values for multifile facades. val additionalChangeInfo = if (className in protoMap) { val info = ChangeInfo.SignatureChanged(className.fqNameForClassNameWithoutDollars, areSubclassesAffected = true) - CompilationResult(protoChanged = true, changes = sequenceOf(info)) + CompilationResult(changes = sequenceOf(info)) } else CompilationResult.NO_CHANGES protoMap.remove(className) @@ -295,12 +295,7 @@ open class IncrementalCacheImpl( else emptySequence() - val changesInfo = dirtyClasses.fold(CompilationResult(changes = changes)) { info, className -> - val newInfo = CompilationResult(protoChanged = className in protoMap, - constantsChanged = className in constantsMap) - newInfo.logIfSomethingChanged(className) - info + newInfo - } + val changesInfo = CompilationResult(changes = changes) val facadesWithRemovedParts = hashMapOf>() for (dirtyClass in dirtyClasses) { @@ -398,7 +393,7 @@ open class IncrementalCacheImpl( // (also that would fail with exception). fun storeModuleMapping(className: JvmClassName, bytes: ByteArray): CompilationResult { storage[className.internalName] = ProtoMapValue(isPackageFacade = false, bytes = bytes, strings = emptyArray()) - return CompilationResult(protoChanged = true) + return CompilationResult() } private fun put( @@ -426,7 +421,7 @@ open class IncrementalCacheImpl( else emptySequence() - return CompilationResult(protoChanged = true, changes = changes) + return CompilationResult(changes = changes) } val difference = difference(oldData, data) @@ -441,7 +436,7 @@ open class IncrementalCacheImpl( changeList.add(ChangeInfo.MembersChanged(fqName, difference.changedMembersNames)) } - return CompilationResult(protoChanged = changeList.isNotEmpty(), changes = changeList.asSequence()) + return CompilationResult(changes = changeList.asSequence()) } operator fun contains(className: JvmClassName): Boolean = @@ -512,7 +507,7 @@ open class IncrementalCacheImpl( sequenceOf(ChangeInfo.MembersChanged(fqName, changedNames)) } - return CompilationResult(constantsChanged = true, changes = changes) + return CompilationResult(changes = changes) } fun remove(className: JvmClassName) { @@ -753,9 +748,7 @@ open class IncrementalCacheImpl( } processChangedInlineFunctions(className, changed) - return CompilationResult(inlineChanged = changed.isNotEmpty(), - inlineAdded = added.isNotEmpty(), - changes = changes) + return CompilationResult(changes = changes) } fun remove(className: JvmClassName) { @@ -793,10 +786,6 @@ sealed class ChangeInfo(val fqName: FqName) { } data class CompilationResult( - val protoChanged: Boolean = false, - val constantsChanged: Boolean = false, - val inlineChanged: Boolean = false, - val inlineAdded: Boolean = false, val changes: Sequence = emptySequence() ) { companion object { @@ -804,11 +793,7 @@ data class CompilationResult( } operator fun plus(other: CompilationResult): CompilationResult = - CompilationResult(protoChanged || other.protoChanged, - constantsChanged || other.constantsChanged, - inlineChanged || other.inlineChanged, - inlineAdded || other.inlineAdded, - changes + other.changes) + CompilationResult(changes + other.changes) } fun ByteArray.md5(): Long { diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 54399c116b9..c4ccecf8fc6 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -309,7 +309,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { return OK } - processChanges(filesToCompile.values().toSet(), allCompiledFiles, dataManager, incrementalCaches.values, changesInfo, fsOperations) + changesInfo.processChangesUsingLookups(filesToCompile.values().toSet(), dataManager, fsOperations, incrementalCaches.values) incrementalCaches.values.forEach { it.cleanDirtyInlineFunctions() } return OK @@ -814,51 +814,6 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { } } -private fun processChanges( - compiledFiles: Set, - allCompiledFiles: MutableSet, - dataManager: BuildDataManager, - caches: Collection, - compilationResult: CompilationResult, - fsOperations: FSOperationsHelper -) { - if (IncrementalCompilation.isExperimental()) { - compilationResult.doProcessChangesUsingLookups(compiledFiles, dataManager, fsOperations, caches) - } - else { - compilationResult.doProcessChanges(compiledFiles, allCompiledFiles, caches, fsOperations) - } -} - -private fun CompilationResult.doProcessChanges( - compiledFiles: Set, - allCompiledFiles: MutableSet, - caches: Collection, - fsOperations: FSOperationsHelper -) { - KotlinBuilder.LOG.debug("compilationResult = $this") - - when { - inlineAdded -> { - allCompiledFiles.clear() - fsOperations.markChunk(recursively = true, kotlinOnly = true, excludeFiles = compiledFiles) - return - } - constantsChanged -> { - fsOperations.markChunk(recursively = true, kotlinOnly = false, excludeFiles = allCompiledFiles) - return - } - protoChanged -> { - fsOperations.markChunk(recursively = false, kotlinOnly = true, excludeFiles = allCompiledFiles) - } - } - - if (inlineChanged) { - val files = caches.flatMap { it.getFilesToReinline() } - fsOperations.markFiles(files, excludeFiles = compiledFiles) - } -} - private class JpsICReporter : ICReporter { override fun report(message: ()->String) { if (KotlinBuilder.LOG.isDebugEnabled) { @@ -867,7 +822,7 @@ private class JpsICReporter : ICReporter { } } -private fun CompilationResult.doProcessChangesUsingLookups( +private fun CompilationResult.processChangesUsingLookups( compiledFiles: Set, dataManager: BuildDataManager, fsOperations: FSOperationsHelper,