From 7171c2531cc4008d192f207aea0e7dcab5de652c Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Mon, 9 Jan 2023 12:55:40 +0100 Subject: [PATCH] [IC] Apply IDEA suggestions to IC caches code --- .../kotlin/build/report/ICReporter.kt | 3 --- .../incremental/AbstractIncrementalCache.kt | 17 +++++++------ .../kotlin/incremental/IncrementalJsCache.kt | 2 +- .../kotlin/incremental/IncrementalJvmCache.kt | 24 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build-common/src/org/jetbrains/kotlin/build/report/ICReporter.kt b/build-common/src/org/jetbrains/kotlin/build/report/ICReporter.kt index 9ae63f4b476..55de75902b0 100644 --- a/build-common/src/org/jetbrains/kotlin/build/report/ICReporter.kt +++ b/build-common/src/org/jetbrains/kotlin/build/report/ICReporter.kt @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.build.report import org.jetbrains.kotlin.cli.common.ExitCode -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity -import org.jetbrains.kotlin.cli.common.messages.MessageCollector import java.io.File -import kotlin.reflect.KFunction1 interface ICReporter { diff --git a/build-common/src/org/jetbrains/kotlin/incremental/AbstractIncrementalCache.kt b/build-common/src/org/jetbrains/kotlin/incremental/AbstractIncrementalCache.kt index 6bea2078cd3..6c7e699a6b5 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/AbstractIncrementalCache.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/AbstractIncrementalCache.kt @@ -47,20 +47,22 @@ interface IncrementalCacheCommon { } /** - * Incremental cache common for JVM and JS for specifit ClassName type + * Incremental cache common for JVM and JS for specific ClassName type */ abstract class AbstractIncrementalCache( workingDir: File, protected val pathConverter: FileToPathConverter ) : BasicMapsOwner(workingDir), IncrementalCacheCommon { companion object { - private val CLASS_ATTRIBUTES = "class-attributes" - private val SUBTYPES = "subtypes" - private val SUPERTYPES = "supertypes" - private val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source" - private val COMPLEMENTARY_FILES = "complementary-files" + private const val CLASS_ATTRIBUTES = "class-attributes" + private const val SUBTYPES = "subtypes" + private const val SUPERTYPES = "supertypes" + private const val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source" + private const val COMPLEMENTARY_FILES = "complementary-files" + @JvmStatic protected val SOURCE_TO_CLASSES = "source-to-classes" + @JvmStatic protected val DIRTY_OUTPUT_CLASSES = "dirty-output-classes" } @@ -82,6 +84,7 @@ abstract class AbstractIncrementalCache( protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile, pathConverter)) internal abstract val sourceToClassesMap: AbstractSourceToOutputMap internal abstract val dirtyOutputClassesMap: AbstractDirtyClassesMap + /** * A file X is a complementary to a file Y if they contain corresponding expect/actual declarations. * Complementary files should be compiled together during IC so the compiler does not complain @@ -218,7 +221,7 @@ abstract class AbstractIncrementalCache( if (complementaryFiles.add(it) && !processedFiles.contains(it)) filesQueue.add(it) } val classes2recompile = sourceToClassesMap.getFqNames(file) - classes2recompile.filter { !processedClasses.contains(it) }.forEach {class2recompile -> + classes2recompile.filter { !processedClasses.contains(it) }.forEach { class2recompile -> processedClasses.add(class2recompile) val sealedClasses = findSealedSupertypes(class2recompile, listOf(this)) val allSubtypes = sealedClasses.flatMap { withSubtypes(it, listOf(this)) }.also { diff --git a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJsCache.kt b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJsCache.kt index 94fedc5be70..51f44929c24 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJsCache.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJsCache.kt @@ -102,7 +102,7 @@ open class IncrementalJsCache( } fun getOutputsBySource(sourceFile: File): Collection { - return sourceToJsOutputsMap.get(sourceFile) + return sourceToJsOutputsMap[sourceFile] } fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) { diff --git a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt index 13af63396b1..2a1f27aa7a3 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmClassName import java.io.File import java.security.MessageDigest -val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin" +const val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin" open class IncrementalJvmCache( targetDataRoot: File, @@ -51,17 +51,17 @@ open class IncrementalJvmCache( pathConverter = pathConverter ), IncrementalCache { companion object { - private val PROTO_MAP = "proto" - private val FE_PROTO_MAP = "fe-proto" - private val CONSTANTS_MAP = "constants" - private val PACKAGE_PARTS = "package-parts" - private val MULTIFILE_CLASS_FACADES = "multifile-class-facades" - private val MULTIFILE_CLASS_PARTS = "multifile-class-parts" - private val INLINE_FUNCTIONS = "inline-functions" - private val INTERNAL_NAME_TO_SOURCE = "internal-name-to-source" - private val JAVA_SOURCES_PROTO_MAP = "java-sources-proto-map" + private const val PROTO_MAP = "proto" + private const val FE_PROTO_MAP = "fe-proto" + private const val CONSTANTS_MAP = "constants" + private const val PACKAGE_PARTS = "package-parts" + private const val MULTIFILE_CLASS_FACADES = "multifile-class-facades" + private const val MULTIFILE_CLASS_PARTS = "multifile-class-parts" + private const val INLINE_FUNCTIONS = "inline-functions" + private const val INTERNAL_NAME_TO_SOURCE = "internal-name-to-source" + private const val JAVA_SOURCES_PROTO_MAP = "java-sources-proto-map" - private val MODULE_MAPPING_FILE_NAME = "." + ModuleMapping.MAPPING_FILE_EXT + private const val MODULE_MAPPING_FILE_NAME = "." + ModuleMapping.MAPPING_FILE_EXT } override val sourceToClassesMap = registerMap(SourceToJvmNameMap(SOURCE_TO_CLASSES.storageFile, pathConverter)) @@ -366,7 +366,7 @@ open class IncrementalJvmCache( changesCollector.collectProtoChanges(oldMapValue?.toProtoData(className.packageFqName), newProtoData, packageProtoKey = key) } - internal fun check( + fun check( className: JvmClassName, classProto: ProtoBuf.Class, stringTable: JvmStringTable, changesCollector: ChangesCollector ) { val key = className.internalName