From 06875cc4b6de8cc24d64d00e76b294dbd9c2e806 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Fri, 6 Feb 2015 16:01:28 +0300 Subject: [PATCH] Extracted common function getRecompilationDecision. Original commit: 478118c12a79be675d693a3ea9d88d2571646559 --- .../jps/incremental/IncrementalCacheImpl.kt | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt index 1d720f8f2e1..ca9757d846b 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt @@ -119,6 +119,14 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen } } + private fun getRecompilationDecision(protoChanged: Boolean, constantsChanged: Boolean, inlinesChanged: Boolean) = + when { + inlinesChanged -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS + constantsChanged -> RECOMPILE_OTHERS_WITH_DEPENDANTS + protoChanged -> RECOMPILE_OTHERS_IN_CHUNK + else -> DO_NOTHING + } + public fun saveFileToCache(sourceFiles: Collection, classFile: File): RecompilationDecision { if (classFile.extension.toLowerCase() != "class") return DO_NOTHING @@ -137,22 +145,19 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen val annotationDataEncoded = header.annotationData if (annotationDataEncoded != null) { val data = BitEncoding.decodeBytes(annotationDataEncoded) - when { - header.isCompatiblePackageFacadeKind() -> { - return if (protoMap.put(className, data)) RECOMPILE_OTHERS_IN_CHUNK else DO_NOTHING - } - header.isCompatibleClassKind() -> { - val inlinesChanged = inlineFunctionsMap.process(className, fileBytes) - val protoChanged = protoMap.put(className, data) - val constantsChanged = constantsMap.process(className, fileBytes) - - return when { - inlinesChanged -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS - constantsChanged -> RECOMPILE_OTHERS_WITH_DEPENDANTS - protoChanged -> RECOMPILE_OTHERS_IN_CHUNK - else -> DO_NOTHING - } - } + return when { + header.isCompatiblePackageFacadeKind() -> + getRecompilationDecision( + protoChanged = protoMap.put(className, data), + constantsChanged = false, + inlinesChanged = false + ) + header.isCompatibleClassKind() -> + getRecompilationDecision( + protoChanged = protoMap.put(className, data), + constantsChanged = constantsMap.process(className, fileBytes), + inlinesChanged = inlineFunctionsMap.process(className, fileBytes) + ) else -> { throw IllegalStateException("Unexpected kind with annotationData: ${header.kind}, isCompatible: ${header.isCompatibleAbiVersion}") } @@ -163,14 +168,12 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen assert(sourceFiles.size() == 1) { "Package part from several source files: $sourceFiles" } packagePartMap.addPackagePart(className) - val inlinesChanged = inlineFunctionsMap.process(className, fileBytes) - val constantsChanged = constantsMap.process(className, fileBytes) - return when { - inlinesChanged -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS - constantsChanged -> RECOMPILE_OTHERS_WITH_DEPENDANTS - else -> DO_NOTHING - } + return getRecompilationDecision( + protoChanged = false, + constantsChanged = constantsMap.process(className, fileBytes), + inlinesChanged = inlineFunctionsMap.process(className, fileBytes) + ) } return DO_NOTHING @@ -181,12 +184,12 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen for (internalClassName in dirtyOutputClassesMap.getDirtyOutputClasses()) { val className = JvmClassName.byInternalName(internalClassName) - val newDecision = when { - internalClassName in inlineFunctionsMap -> RECOMPILE_ALL_CHUNK_AND_DEPENDANTS - internalClassName in constantsMap -> RECOMPILE_OTHERS_WITH_DEPENDANTS - internalClassName in protoMap -> RECOMPILE_OTHERS_IN_CHUNK - else -> DO_NOTHING - } + val newDecision = getRecompilationDecision( + protoChanged = internalClassName in protoMap, + constantsChanged = internalClassName in constantsMap, + inlinesChanged = internalClassName in inlineFunctionsMap + ) + recompilationDecision = recompilationDecision.merge(newDecision) protoMap.remove(className)