[IC] Apply IDEA suggestions to IC caches code
This commit is contained in:
committed by
Space Team
parent
432b08e158
commit
7171c2531c
@@ -6,10 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.build.report
|
package org.jetbrains.kotlin.build.report
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
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 java.io.File
|
||||||
import kotlin.reflect.KFunction1
|
|
||||||
|
|
||||||
interface ICReporter {
|
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>(
|
abstract class AbstractIncrementalCache<ClassName>(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
protected val pathConverter: FileToPathConverter
|
protected val pathConverter: FileToPathConverter
|
||||||
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
||||||
companion object {
|
companion object {
|
||||||
private val CLASS_ATTRIBUTES = "class-attributes"
|
private const val CLASS_ATTRIBUTES = "class-attributes"
|
||||||
private val SUBTYPES = "subtypes"
|
private const val SUBTYPES = "subtypes"
|
||||||
private val SUPERTYPES = "supertypes"
|
private const val SUPERTYPES = "supertypes"
|
||||||
private val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source"
|
private const val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source"
|
||||||
private val COMPLEMENTARY_FILES = "complementary-files"
|
private const val COMPLEMENTARY_FILES = "complementary-files"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
protected val SOURCE_TO_CLASSES = "source-to-classes"
|
protected val SOURCE_TO_CLASSES = "source-to-classes"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
protected val DIRTY_OUTPUT_CLASSES = "dirty-output-classes"
|
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))
|
protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile, pathConverter))
|
||||||
internal abstract val sourceToClassesMap: AbstractSourceToOutputMap<ClassName>
|
internal abstract val sourceToClassesMap: AbstractSourceToOutputMap<ClassName>
|
||||||
internal abstract val dirtyOutputClassesMap: AbstractDirtyClassesMap<ClassName>
|
internal abstract val dirtyOutputClassesMap: AbstractDirtyClassesMap<ClassName>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A file X is a complementary to a file Y if they contain corresponding expect/actual declarations.
|
* 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
|
* 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)
|
if (complementaryFiles.add(it) && !processedFiles.contains(it)) filesQueue.add(it)
|
||||||
}
|
}
|
||||||
val classes2recompile = sourceToClassesMap.getFqNames(file)
|
val classes2recompile = sourceToClassesMap.getFqNames(file)
|
||||||
classes2recompile.filter { !processedClasses.contains(it) }.forEach {class2recompile ->
|
classes2recompile.filter { !processedClasses.contains(it) }.forEach { class2recompile ->
|
||||||
processedClasses.add(class2recompile)
|
processedClasses.add(class2recompile)
|
||||||
val sealedClasses = findSealedSupertypes(class2recompile, listOf(this))
|
val sealedClasses = findSealedSupertypes(class2recompile, listOf(this))
|
||||||
val allSubtypes = sealedClasses.flatMap { withSubtypes(it, listOf(this)) }.also {
|
val allSubtypes = sealedClasses.flatMap { withSubtypes(it, listOf(this)) }.also {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ open class IncrementalJsCache(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getOutputsBySource(sourceFile: File): Collection<File> {
|
fun getOutputsBySource(sourceFile: File): Collection<File> {
|
||||||
return sourceToJsOutputsMap.get(sourceFile)
|
return sourceToJsOutputsMap[sourceFile]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) {
|
fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin"
|
const val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin"
|
||||||
|
|
||||||
open class IncrementalJvmCache(
|
open class IncrementalJvmCache(
|
||||||
targetDataRoot: File,
|
targetDataRoot: File,
|
||||||
@@ -51,17 +51,17 @@ open class IncrementalJvmCache(
|
|||||||
pathConverter = pathConverter
|
pathConverter = pathConverter
|
||||||
), IncrementalCache {
|
), IncrementalCache {
|
||||||
companion object {
|
companion object {
|
||||||
private val PROTO_MAP = "proto"
|
private const val PROTO_MAP = "proto"
|
||||||
private val FE_PROTO_MAP = "fe-proto"
|
private const val FE_PROTO_MAP = "fe-proto"
|
||||||
private val CONSTANTS_MAP = "constants"
|
private const val CONSTANTS_MAP = "constants"
|
||||||
private val PACKAGE_PARTS = "package-parts"
|
private const val PACKAGE_PARTS = "package-parts"
|
||||||
private val MULTIFILE_CLASS_FACADES = "multifile-class-facades"
|
private const val MULTIFILE_CLASS_FACADES = "multifile-class-facades"
|
||||||
private val MULTIFILE_CLASS_PARTS = "multifile-class-parts"
|
private const val MULTIFILE_CLASS_PARTS = "multifile-class-parts"
|
||||||
private val INLINE_FUNCTIONS = "inline-functions"
|
private const val INLINE_FUNCTIONS = "inline-functions"
|
||||||
private val INTERNAL_NAME_TO_SOURCE = "internal-name-to-source"
|
private const val INTERNAL_NAME_TO_SOURCE = "internal-name-to-source"
|
||||||
private val JAVA_SOURCES_PROTO_MAP = "java-sources-proto-map"
|
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))
|
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)
|
changesCollector.collectProtoChanges(oldMapValue?.toProtoData(className.packageFqName), newProtoData, packageProtoKey = key)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun check(
|
fun check(
|
||||||
className: JvmClassName, classProto: ProtoBuf.Class, stringTable: JvmStringTable, changesCollector: ChangesCollector
|
className: JvmClassName, classProto: ProtoBuf.Class, stringTable: JvmStringTable, changesCollector: ChangesCollector
|
||||||
) {
|
) {
|
||||||
val key = className.internalName
|
val key = className.internalName
|
||||||
|
|||||||
Reference in New Issue
Block a user