[IC] Apply IDEA suggestions to IC caches code

This commit is contained in:
Alexander.Likhachev
2023-01-09 12:55:40 +01:00
committed by Space Team
parent 432b08e158
commit 7171c2531c
4 changed files with 23 additions and 23 deletions
@@ -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 {
@@ -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<ClassName>(
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<ClassName>(
protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile, pathConverter))
internal abstract val sourceToClassesMap: AbstractSourceToOutputMap<ClassName>
internal abstract val dirtyOutputClassesMap: AbstractDirtyClassesMap<ClassName>
/**
* 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<ClassName>(
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 {
@@ -102,7 +102,7 @@ open class IncrementalJsCache(
}
fun getOutputsBySource(sourceFile: File): Collection<File> {
return sourceToJsOutputsMap.get(sourceFile)
return sourceToJsOutputsMap[sourceFile]
}
fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) {
@@ -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