Rename SourceFileToPathConverter->FileToPathConverter
This commit is contained in:
@@ -47,7 +47,7 @@ interface IncrementalCacheCommon {
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractIncrementalCache<ClassName>(
|
abstract class AbstractIncrementalCache<ClassName>(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
protected val sourcePathConverter: SourceFileToPathConverter
|
protected val pathConverter: FileToPathConverter
|
||||||
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
||||||
companion object {
|
companion object {
|
||||||
private val SUBTYPES = "subtypes"
|
private val SUBTYPES = "subtypes"
|
||||||
@@ -73,7 +73,7 @@ abstract class AbstractIncrementalCache<ClassName>(
|
|||||||
|
|
||||||
private val subtypesMap = registerMap(SubtypesMap(SUBTYPES.storageFile))
|
private val subtypesMap = registerMap(SubtypesMap(SUBTYPES.storageFile))
|
||||||
private val supertypesMap = registerMap(SupertypesMap(SUPERTYPES.storageFile))
|
private val supertypesMap = registerMap(SupertypesMap(SUPERTYPES.storageFile))
|
||||||
protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile, sourcePathConverter))
|
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>
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +82,7 @@ abstract class AbstractIncrementalCache<ClassName>(
|
|||||||
* about missing parts.
|
* about missing parts.
|
||||||
* TODO: provide a better solution (maintain an index of expect/actual declarations akin to IncrementalPackagePartProvider)
|
* TODO: provide a better solution (maintain an index of expect/actual declarations akin to IncrementalPackagePartProvider)
|
||||||
*/
|
*/
|
||||||
private val complementaryFilesMap = registerMap(ComplementarySourceFilesMap(COMPLEMENTARY_FILES.storageFile, sourcePathConverter))
|
private val complementaryFilesMap = registerMap(ComplementarySourceFilesMap(COMPLEMENTARY_FILES.storageFile, pathConverter))
|
||||||
|
|
||||||
override fun classesFqNamesBySources(files: Iterable<File>): Collection<FqName> =
|
override fun classesFqNamesBySources(files: Iterable<File>): Collection<FqName> =
|
||||||
files.flatMapTo(HashSet()) { sourceToClassesMap.getFqNames(it) }
|
files.flatMapTo(HashSet()) { sourceToClassesMap.getFqNames(it) }
|
||||||
@@ -157,15 +157,15 @@ abstract class AbstractIncrementalCache<ClassName>(
|
|||||||
|
|
||||||
protected class ClassFqNameToSourceMap(
|
protected class ClassFqNameToSourceMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) :
|
) :
|
||||||
BasicStringMap<String>(storageFile, EnumeratorStringDescriptor(), PathStringDescriptor) {
|
BasicStringMap<String>(storageFile, EnumeratorStringDescriptor(), PathStringDescriptor) {
|
||||||
operator fun set(fqName: FqName, sourceFile: File) {
|
operator fun set(fqName: FqName, sourceFile: File) {
|
||||||
storage[fqName.asString()] = sourcePathConverter.toPath(sourceFile)
|
storage[fqName.asString()] = pathConverter.toPath(sourceFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(fqName: FqName): File? =
|
operator fun get(fqName: FqName): File? =
|
||||||
storage[fqName.asString()]?.let(sourcePathConverter::toFile)
|
storage[fqName.asString()]?.let(pathConverter::toFile)
|
||||||
|
|
||||||
fun remove(fqName: FqName) {
|
fun remove(fqName: FqName) {
|
||||||
storage.remove(fqName.asString())
|
storage.remove(fqName.asString())
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import java.io.File
|
|||||||
|
|
||||||
open class IncrementalJsCache(
|
open class IncrementalJsCache(
|
||||||
cachesDir: File,
|
cachesDir: File,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : AbstractIncrementalCache<FqName>(cachesDir, sourcePathConverter) {
|
) : AbstractIncrementalCache<FqName>(cachesDir, pathConverter) {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TRANSLATION_RESULT_MAP = "translation-result"
|
private const val TRANSLATION_RESULT_MAP = "translation-result"
|
||||||
private const val INLINE_FUNCTIONS = "inline-functions"
|
private const val INLINE_FUNCTIONS = "inline-functions"
|
||||||
@@ -45,10 +45,10 @@ open class IncrementalJsCache(
|
|||||||
fun hasHeaderFile(cachesDir: File) = File(cachesDir, HEADER_FILE_NAME).exists()
|
fun hasHeaderFile(cachesDir: File) = File(cachesDir, HEADER_FILE_NAME).exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
override val sourceToClassesMap = registerMap(SourceToFqNameMap(SOURCE_TO_CLASSES.storageFile, sourcePathConverter))
|
override val sourceToClassesMap = registerMap(SourceToFqNameMap(SOURCE_TO_CLASSES.storageFile, pathConverter))
|
||||||
override val dirtyOutputClassesMap = registerMap(DirtyClassesFqNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
|
override val dirtyOutputClassesMap = registerMap(DirtyClassesFqNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
|
||||||
private val translationResults = registerMap(TranslationResultMap(TRANSLATION_RESULT_MAP.storageFile, sourcePathConverter))
|
private val translationResults = registerMap(TranslationResultMap(TRANSLATION_RESULT_MAP.storageFile, pathConverter))
|
||||||
private val inlineFunctions = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile, sourcePathConverter))
|
private val inlineFunctions = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile, pathConverter))
|
||||||
|
|
||||||
private val dirtySources = hashSetOf<File>()
|
private val dirtySources = hashSetOf<File>()
|
||||||
|
|
||||||
@@ -154,24 +154,24 @@ private object TranslationResultValueExternalizer : DataExternalizer<Translation
|
|||||||
|
|
||||||
private class TranslationResultMap(
|
private class TranslationResultMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
|
) : BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
|
||||||
override fun dumpValue(value: TranslationResultValue): String =
|
override fun dumpValue(value: TranslationResultValue): String =
|
||||||
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}, InlineData: ${value.inlineData.md5()}"
|
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}, InlineData: ${value.inlineData.md5()}"
|
||||||
|
|
||||||
fun put(sourceFile: File, newMetadata: ByteArray, newBinaryAst: ByteArray, newInlineData: ByteArray) {
|
fun put(sourceFile: File, newMetadata: ByteArray, newBinaryAst: ByteArray, newInlineData: ByteArray) {
|
||||||
storage[sourcePathConverter.toPath(sourceFile)] =
|
storage[pathConverter.toPath(sourceFile)] =
|
||||||
TranslationResultValue(metadata = newMetadata, binaryAst = newBinaryAst, inlineData = newInlineData)
|
TranslationResultValue(metadata = newMetadata, binaryAst = newBinaryAst, inlineData = newInlineData)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(sourceFile: File): TranslationResultValue? =
|
operator fun get(sourceFile: File): TranslationResultValue? =
|
||||||
storage[sourcePathConverter.toPath(sourceFile)]
|
storage[pathConverter.toPath(sourceFile)]
|
||||||
|
|
||||||
fun keys(): Collection<String> =
|
fun keys(): Collection<String> =
|
||||||
storage.keys
|
storage.keys
|
||||||
|
|
||||||
fun remove(sourceFile: File, changesCollector: ChangesCollector) {
|
fun remove(sourceFile: File, changesCollector: ChangesCollector) {
|
||||||
val path = sourcePathConverter.toPath(sourceFile)
|
val path = pathConverter.toPath(sourceFile)
|
||||||
val protoBytes = storage[path]!!.metadata
|
val protoBytes = storage[path]!!.metadata
|
||||||
val protoMap = getProtoData(sourceFile, protoBytes)
|
val protoMap = getProtoData(sourceFile, protoBytes)
|
||||||
|
|
||||||
@@ -203,10 +203,10 @@ fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData>
|
|||||||
|
|
||||||
private class InlineFunctionsMap(
|
private class InlineFunctionsMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicStringMap<Map<String, Long>>(storageFile, StringToLongMapExternalizer) {
|
) : BasicStringMap<Map<String, Long>>(storageFile, StringToLongMapExternalizer) {
|
||||||
fun process(srcFile: File, newMap: Map<String, Long>, changesCollector: ChangesCollector) {
|
fun process(srcFile: File, newMap: Map<String, Long>, changesCollector: ChangesCollector) {
|
||||||
val key = sourcePathConverter.toPath(srcFile)
|
val key = pathConverter.toPath(srcFile)
|
||||||
val oldMap = storage[key] ?: emptyMap()
|
val oldMap = storage[key] ?: emptyMap()
|
||||||
|
|
||||||
if (newMap.isNotEmpty()) {
|
if (newMap.isNotEmpty()) {
|
||||||
@@ -223,7 +223,7 @@ private class InlineFunctionsMap(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun remove(sourceFile: File) {
|
fun remove(sourceFile: File) {
|
||||||
storage.remove(sourcePathConverter.toPath(sourceFile))
|
storage.remove(pathConverter.toPath(sourceFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dumpValue(value: Map<String, Long>): String =
|
override fun dumpValue(value: Map<String, Long>): String =
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin"
|
|||||||
open class IncrementalJvmCache(
|
open class IncrementalJvmCache(
|
||||||
private val targetDataRoot: File,
|
private val targetDataRoot: File,
|
||||||
targetOutputDir: File?,
|
targetOutputDir: File?,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : AbstractIncrementalCache<JvmClassName>(
|
) : AbstractIncrementalCache<JvmClassName>(
|
||||||
workingDir = File(targetDataRoot, KOTLIN_CACHE_DIRECTORY_NAME),
|
workingDir = File(targetDataRoot, KOTLIN_CACHE_DIRECTORY_NAME),
|
||||||
sourcePathConverter = sourcePathConverter
|
pathConverter = pathConverter
|
||||||
), IncrementalCache {
|
), IncrementalCache {
|
||||||
companion object {
|
companion object {
|
||||||
private val PROTO_MAP = "proto"
|
private val PROTO_MAP = "proto"
|
||||||
@@ -62,7 +62,7 @@ open class IncrementalJvmCache(
|
|||||||
private val MODULE_MAPPING_FILE_NAME = "." + ModuleMapping.MAPPING_FILE_EXT
|
private val MODULE_MAPPING_FILE_NAME = "." + ModuleMapping.MAPPING_FILE_EXT
|
||||||
}
|
}
|
||||||
|
|
||||||
override val sourceToClassesMap = registerMap(SourceToJvmNameMap(SOURCE_TO_CLASSES.storageFile, sourcePathConverter))
|
override val sourceToClassesMap = registerMap(SourceToJvmNameMap(SOURCE_TO_CLASSES.storageFile, pathConverter))
|
||||||
override val dirtyOutputClassesMap = registerMap(DirtyClassesJvmNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
|
override val dirtyOutputClassesMap = registerMap(DirtyClassesJvmNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
|
||||||
|
|
||||||
private val protoMap = registerMap(ProtoMap(PROTO_MAP.storageFile))
|
private val protoMap = registerMap(ProtoMap(PROTO_MAP.storageFile))
|
||||||
@@ -72,7 +72,7 @@ open class IncrementalJvmCache(
|
|||||||
private val partToMultifileFacade = registerMap(MultifileClassPartMap(MULTIFILE_CLASS_PARTS.storageFile))
|
private val partToMultifileFacade = registerMap(MultifileClassPartMap(MULTIFILE_CLASS_PARTS.storageFile))
|
||||||
private val inlineFunctionsMap = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile))
|
private val inlineFunctionsMap = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile))
|
||||||
// todo: try to use internal names only?
|
// todo: try to use internal names only?
|
||||||
private val internalNameToSource = registerMap(InternalNameToSourcesMap(INTERNAL_NAME_TO_SOURCE.storageFile, sourcePathConverter))
|
private val internalNameToSource = registerMap(InternalNameToSourcesMap(INTERNAL_NAME_TO_SOURCE.storageFile, pathConverter))
|
||||||
// gradle only
|
// gradle only
|
||||||
private val javaSourcesProtoMap = registerMap(JavaSourcesProtoMap(JAVA_SOURCES_PROTO_MAP.storageFile))
|
private val javaSourcesProtoMap = registerMap(JavaSourcesProtoMap(JAVA_SOURCES_PROTO_MAP.storageFile))
|
||||||
|
|
||||||
@@ -447,14 +447,14 @@ open class IncrementalJvmCache(
|
|||||||
|
|
||||||
inner class InternalNameToSourcesMap(
|
inner class InternalNameToSourcesMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicStringMap<Collection<String>>(storageFile, EnumeratorStringDescriptor(), PathCollectionExternalizer) {
|
) : BasicStringMap<Collection<String>>(storageFile, EnumeratorStringDescriptor(), PathCollectionExternalizer) {
|
||||||
operator fun set(internalName: String, sourceFiles: Collection<File>) {
|
operator fun set(internalName: String, sourceFiles: Collection<File>) {
|
||||||
storage[internalName] = sourcePathConverter.toPaths(sourceFiles)
|
storage[internalName] = pathConverter.toPaths(sourceFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(internalName: String): Collection<File> =
|
operator fun get(internalName: String): Collection<File> =
|
||||||
sourcePathConverter.toFiles(storage[internalName] ?: emptyList())
|
pathConverter.toFiles(storage[internalName] ?: emptyList())
|
||||||
|
|
||||||
fun remove(internalName: String) {
|
fun remove(internalName: String) {
|
||||||
storage.remove(internalName)
|
storage.remove(internalName)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import java.util.*
|
|||||||
|
|
||||||
open class LookupStorage(
|
open class LookupStorage(
|
||||||
targetDataDir: File,
|
targetDataDir: File,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : BasicMapsOwner(targetDataDir) {
|
) : BasicMapsOwner(targetDataDir) {
|
||||||
companion object {
|
companion object {
|
||||||
private val DELETED_TO_SIZE_TRESHOLD = 0.5
|
private val DELETED_TO_SIZE_TRESHOLD = 0.5
|
||||||
@@ -40,8 +40,8 @@ open class LookupStorage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val countersFile = "counters".storageFile
|
private val countersFile = "counters".storageFile
|
||||||
private val idToFile = registerMap(IdToFileMap("id-to-file".storageFile, sourcePathConverter))
|
private val idToFile = registerMap(IdToFileMap("id-to-file".storageFile, pathConverter))
|
||||||
private val fileToId = registerMap(FileToIdMap("file-to-id".storageFile, sourcePathConverter))
|
private val fileToId = registerMap(FileToIdMap("file-to-id".storageFile, pathConverter))
|
||||||
private val lookupMap = registerMap(LookupMap("lookups".storageFile))
|
private val lookupMap = registerMap(LookupMap("lookups".storageFile))
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
|
|||||||
+5
-5
@@ -10,21 +10,21 @@ import java.io.File
|
|||||||
|
|
||||||
class ComplementarySourceFilesMap(
|
class ComplementarySourceFilesMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
|
) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
|
||||||
|
|
||||||
operator fun set(sourceFile: File, complementaryFiles: Collection<File>) {
|
operator fun set(sourceFile: File, complementaryFiles: Collection<File>) {
|
||||||
storage[sourcePathConverter.toPath(sourceFile)] = sourcePathConverter.toPaths(complementaryFiles)
|
storage[pathConverter.toPath(sourceFile)] = pathConverter.toPaths(complementaryFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(sourceFile: File): Collection<File> {
|
operator fun get(sourceFile: File): Collection<File> {
|
||||||
val paths = storage[sourcePathConverter.toPath(sourceFile)].orEmpty()
|
val paths = storage[pathConverter.toPath(sourceFile)].orEmpty()
|
||||||
return sourcePathConverter.toFiles(paths)
|
return pathConverter.toFiles(paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dumpValue(value: Collection<String>) =
|
override fun dumpValue(value: Collection<String>) =
|
||||||
value.dumpCollection()
|
value.dumpCollection()
|
||||||
|
|
||||||
fun remove(file: File): Collection<File> =
|
fun remove(file: File): Collection<File> =
|
||||||
get(file).also { storage.remove(sourcePathConverter.toPath(file)) }
|
get(file).also { storage.remove(pathConverter.toPath(file)) }
|
||||||
}
|
}
|
||||||
@@ -20,25 +20,25 @@ import java.io.File
|
|||||||
|
|
||||||
internal class FileToIdMap(
|
internal class FileToIdMap(
|
||||||
file: File,
|
file: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicStringMap<Int>(file, IntExternalizer) {
|
) : BasicStringMap<Int>(file, IntExternalizer) {
|
||||||
override fun dumpValue(value: Int): String = value.toString()
|
override fun dumpValue(value: Int): String = value.toString()
|
||||||
|
|
||||||
operator fun get(file: File): Int? = storage[sourcePathConverter.toPath(file)]
|
operator fun get(file: File): Int? = storage[pathConverter.toPath(file)]
|
||||||
|
|
||||||
operator fun set(file: File, id: Int) {
|
operator fun set(file: File, id: Int) {
|
||||||
storage[sourcePathConverter.toPath(file)] = id
|
storage[pathConverter.toPath(file)] = id
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(file: File) {
|
fun remove(file: File) {
|
||||||
storage.remove(sourcePathConverter.toPath(file))
|
storage.remove(pathConverter.toPath(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toMap(): Map<File, Int> {
|
fun toMap(): Map<File, Int> {
|
||||||
val result = HashMap<File, Int>()
|
val result = HashMap<File, Int>()
|
||||||
for (key in storage.keys) {
|
for (key in storage.keys) {
|
||||||
val value = storage[key] ?: continue
|
val value = storage[key] ?: continue
|
||||||
result[sourcePathConverter.toFile(key)] = value
|
result[pathConverter.toFile(key)] = value
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -7,18 +7,18 @@ package org.jetbrains.kotlin.incremental.storage
|
|||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
interface SourceFileToPathConverter {
|
interface FileToPathConverter {
|
||||||
fun toPath(file: File): String
|
fun toPath(file: File): String
|
||||||
fun toFile(path: String): File
|
fun toFile(path: String): File
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SourceFileToPathConverter.toPaths(files: Collection<File>): List<String> =
|
fun FileToPathConverter.toPaths(files: Collection<File>): List<String> =
|
||||||
files.map { toPath(it) }
|
files.map { toPath(it) }
|
||||||
|
|
||||||
fun SourceFileToPathConverter.toFiles(paths: Collection<String>): List<File> =
|
fun FileToPathConverter.toFiles(paths: Collection<String>): List<File> =
|
||||||
paths.map { toFile(it) }
|
paths.map { toFile(it) }
|
||||||
|
|
||||||
object SourceFileToCanonicalPathConverter : SourceFileToPathConverter {
|
object FileToCanonicalPathConverter : FileToPathConverter {
|
||||||
override fun toPath(file: File): String = file.canonicalPath
|
override fun toPath(file: File): String = file.canonicalPath
|
||||||
|
|
||||||
override fun toFile(path: String): File = File(path)
|
override fun toFile(path: String): File = File(path)
|
||||||
@@ -22,18 +22,18 @@ import java.io.File
|
|||||||
|
|
||||||
internal class IdToFileMap(
|
internal class IdToFileMap(
|
||||||
file: File,
|
file: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicMap<Int, String>(file, ExternalIntegerKeyDescriptor(), EnumeratorStringDescriptor.INSTANCE) {
|
) : BasicMap<Int, String>(file, ExternalIntegerKeyDescriptor(), EnumeratorStringDescriptor.INSTANCE) {
|
||||||
override fun dumpKey(key: Int): String = key.toString()
|
override fun dumpKey(key: Int): String = key.toString()
|
||||||
|
|
||||||
override fun dumpValue(value: String): String = value
|
override fun dumpValue(value: String): String = value
|
||||||
|
|
||||||
operator fun get(id: Int): File? = storage[id]?.let { sourcePathConverter.toFile(it) }
|
operator fun get(id: Int): File? = storage[id]?.let { pathConverter.toFile(it) }
|
||||||
|
|
||||||
operator fun contains(id: Int): Boolean = id in storage
|
operator fun contains(id: Int): Boolean = id in storage
|
||||||
|
|
||||||
operator fun set(id: Int, file: File) {
|
operator fun set(id: Int, file: File) {
|
||||||
storage[id] = sourcePathConverter.toPath(file)
|
storage[id] = pathConverter.toPath(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(id: Int) {
|
fun remove(id: Int) {
|
||||||
|
|||||||
@@ -23,35 +23,35 @@ import java.io.File
|
|||||||
|
|
||||||
internal class SourceToJvmNameMap(
|
internal class SourceToJvmNameMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : AbstractSourceToOutputMap<JvmClassName>(JvmClassNameTransformer, storageFile, sourcePathConverter)
|
) : AbstractSourceToOutputMap<JvmClassName>(JvmClassNameTransformer, storageFile, pathConverter)
|
||||||
|
|
||||||
internal class SourceToFqNameMap(
|
internal class SourceToFqNameMap(
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : AbstractSourceToOutputMap<FqName>(FqNameTransformer, storageFile, sourcePathConverter)
|
) : AbstractSourceToOutputMap<FqName>(FqNameTransformer, storageFile, pathConverter)
|
||||||
|
|
||||||
internal abstract class AbstractSourceToOutputMap<Name>(
|
internal abstract class AbstractSourceToOutputMap<Name>(
|
||||||
private val nameTransformer: NameTransformer<Name>,
|
private val nameTransformer: NameTransformer<Name>,
|
||||||
storageFile: File,
|
storageFile: File,
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
|
) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
|
||||||
fun clearOutputsForSource(sourceFile: File) {
|
fun clearOutputsForSource(sourceFile: File) {
|
||||||
remove(sourcePathConverter.toPath(sourceFile))
|
remove(pathConverter.toPath(sourceFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(sourceFile: File, className: Name) {
|
fun add(sourceFile: File, className: Name) {
|
||||||
storage.append(sourcePathConverter.toPath(sourceFile), nameTransformer.asString(className))
|
storage.append(pathConverter.toPath(sourceFile), nameTransformer.asString(className))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun contains(sourceFile: File): Boolean =
|
fun contains(sourceFile: File): Boolean =
|
||||||
sourcePathConverter.toPath(sourceFile) in storage
|
pathConverter.toPath(sourceFile) in storage
|
||||||
|
|
||||||
operator fun get(sourceFile: File): Collection<Name> =
|
operator fun get(sourceFile: File): Collection<Name> =
|
||||||
storage[sourcePathConverter.toPath(sourceFile)].orEmpty().map(nameTransformer::asName)
|
storage[pathConverter.toPath(sourceFile)].orEmpty().map(nameTransformer::asName)
|
||||||
|
|
||||||
fun getFqNames(sourceFile: File): Collection<FqName> =
|
fun getFqNames(sourceFile: File): Collection<FqName> =
|
||||||
storage[sourcePathConverter.toPath(sourceFile)].orEmpty().map(nameTransformer::asFqName)
|
storage[pathConverter.toPath(sourceFile)].orEmpty().map(nameTransformer::asFqName)
|
||||||
|
|
||||||
override fun dumpValue(value: Collection<String>) =
|
override fun dumpValue(value: Collection<String>) =
|
||||||
value.dumpCollection()
|
value.dumpCollection()
|
||||||
|
|||||||
+2
-2
@@ -17,10 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.incremental
|
package org.jetbrains.kotlin.incremental
|
||||||
|
|
||||||
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
|
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
|
||||||
import org.jetbrains.kotlin.incremental.storage.SourceFileToCanonicalPathConverter
|
import org.jetbrains.kotlin.incremental.storage.FileToCanonicalPathConverter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
private val PATH_CONVERTER = SourceFileToCanonicalPathConverter
|
private val PATH_CONVERTER = FileToCanonicalPathConverter
|
||||||
|
|
||||||
abstract class IncrementalCachesManager<PlatformCache : AbstractIncrementalCache<*>>(
|
abstract class IncrementalCachesManager<PlatformCache : AbstractIncrementalCache<*>>(
|
||||||
cachesRootDir: File,
|
cachesRootDir: File,
|
||||||
|
|||||||
+2
-2
@@ -7,12 +7,12 @@ package org.jetbrains.kotlin.jps.build
|
|||||||
|
|
||||||
import org.jetbrains.jps.model.JpsProject
|
import org.jetbrains.jps.model.JpsProject
|
||||||
import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
|
import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
|
||||||
import org.jetbrains.kotlin.incremental.storage.SourceFileToPathConverter
|
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
private const val PROJECT_DIR_PLACEHOLDER = "${'$'}PROJECT_DIR$"
|
private const val PROJECT_DIR_PLACEHOLDER = "${'$'}PROJECT_DIR$"
|
||||||
|
|
||||||
internal class JpsSourceFileToPathConverter(jpsProject: JpsProject) : SourceFileToPathConverter {
|
internal class JpsFileToPathConverter(jpsProject: JpsProject) : FileToPathConverter {
|
||||||
private val baseDirPath = JpsModelSerializationDataService
|
private val baseDirPath = JpsModelSerializationDataService
|
||||||
.getBaseDirectory(jpsProject)?.canonicalFile?.invariantSeparatorsPath
|
.getBaseDirectory(jpsProject)?.canonicalFile?.invariantSeparatorsPath
|
||||||
|
|
||||||
@@ -12,11 +12,9 @@ import org.jetbrains.jps.incremental.GlobalContextKey
|
|||||||
import org.jetbrains.jps.incremental.fs.CompilationRound
|
import org.jetbrains.jps.incremental.fs.CompilationRound
|
||||||
import org.jetbrains.jps.incremental.messages.BuildMessage
|
import org.jetbrains.jps.incremental.messages.BuildMessage
|
||||||
import org.jetbrains.jps.incremental.messages.CompilerMessage
|
import org.jetbrains.jps.incremental.messages.CompilerMessage
|
||||||
import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
|
|
||||||
import org.jetbrains.kotlin.config.CompilerRunnerConstants
|
import org.jetbrains.kotlin.config.CompilerRunnerConstants
|
||||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||||
import org.jetbrains.kotlin.incremental.storage.SourceFileToCanonicalPathConverter
|
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
|
||||||
import org.jetbrains.kotlin.incremental.storage.SourceFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.jps.incremental.*
|
import org.jetbrains.kotlin.jps.incremental.*
|
||||||
import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndex
|
import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndex
|
||||||
import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndexBuilder
|
import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndexBuilder
|
||||||
@@ -69,10 +67,10 @@ class KotlinCompileContext(val jpsContext: CompileContext) {
|
|||||||
|
|
||||||
val hasKotlinMarker = HasKotlinMarker(dataManager)
|
val hasKotlinMarker = HasKotlinMarker(dataManager)
|
||||||
|
|
||||||
val sourceFileToPathConverter: SourceFileToPathConverter =
|
val fileToPathConverter: FileToPathConverter =
|
||||||
JpsSourceFileToPathConverter(jpsContext.projectDescriptor.project)
|
JpsFileToPathConverter(jpsContext.projectDescriptor.project)
|
||||||
|
|
||||||
val lookupStorageManager = JpsLookupStorageManager(dataManager, sourceFileToPathConverter)
|
val lookupStorageManager = JpsLookupStorageManager(dataManager, fileToPathConverter)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to prevent rebuilding twice.
|
* Flag to prevent rebuilding twice.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jps.incremental.storage.StorageOwner
|
|||||||
import org.jetbrains.kotlin.incremental.IncrementalCacheCommon
|
import org.jetbrains.kotlin.incremental.IncrementalCacheCommon
|
||||||
import org.jetbrains.kotlin.incremental.IncrementalJsCache
|
import org.jetbrains.kotlin.incremental.IncrementalJsCache
|
||||||
import org.jetbrains.kotlin.incremental.IncrementalJvmCache
|
import org.jetbrains.kotlin.incremental.IncrementalJvmCache
|
||||||
import org.jetbrains.kotlin.incremental.storage.SourceFileToPathConverter
|
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
|
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -36,8 +36,8 @@ interface JpsIncrementalCache : IncrementalCacheCommon, StorageOwner {
|
|||||||
class JpsIncrementalJvmCache(
|
class JpsIncrementalJvmCache(
|
||||||
target: ModuleBuildTarget,
|
target: ModuleBuildTarget,
|
||||||
paths: BuildDataPaths,
|
paths: BuildDataPaths,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : IncrementalJvmCache(paths.getTargetDataRoot(target), target.outputDir, sourcePathConverter), JpsIncrementalCache {
|
) : IncrementalJvmCache(paths.getTargetDataRoot(target), target.outputDir, pathConverter), JpsIncrementalCache {
|
||||||
override fun addJpsDependentCache(cache: JpsIncrementalCache) {
|
override fun addJpsDependentCache(cache: JpsIncrementalCache) {
|
||||||
if (cache is JpsIncrementalJvmCache) {
|
if (cache is JpsIncrementalJvmCache) {
|
||||||
addDependentCache(cache)
|
addDependentCache(cache)
|
||||||
@@ -52,8 +52,8 @@ class JpsIncrementalJvmCache(
|
|||||||
class JpsIncrementalJsCache(
|
class JpsIncrementalJsCache(
|
||||||
target: ModuleBuildTarget,
|
target: ModuleBuildTarget,
|
||||||
paths: BuildDataPaths,
|
paths: BuildDataPaths,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : IncrementalJsCache(paths.getTargetDataRoot(target), sourcePathConverter), JpsIncrementalCache {
|
) : IncrementalJsCache(paths.getTargetDataRoot(target), pathConverter), JpsIncrementalCache {
|
||||||
override fun addJpsDependentCache(cache: JpsIncrementalCache) {
|
override fun addJpsDependentCache(cache: JpsIncrementalCache) {
|
||||||
if (cache is JpsIncrementalJsCache) {
|
if (cache is JpsIncrementalJsCache) {
|
||||||
addDependentCache(cache)
|
addDependentCache(cache)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.jps.builders.storage.StorageProvider
|
|||||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
||||||
import org.jetbrains.jps.incremental.storage.StorageOwner
|
import org.jetbrains.jps.incremental.storage.StorageOwner
|
||||||
import org.jetbrains.kotlin.incremental.LookupStorage
|
import org.jetbrains.kotlin.incremental.LookupStorage
|
||||||
import org.jetbrains.kotlin.incremental.storage.SourceFileToPathConverter
|
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@@ -30,9 +30,9 @@ private object LookupStorageLock
|
|||||||
|
|
||||||
class JpsLookupStorageManager(
|
class JpsLookupStorageManager(
|
||||||
private val buildDataManager: BuildDataManager,
|
private val buildDataManager: BuildDataManager,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) {
|
) {
|
||||||
private val storageProvider = JpsLookupStorageProvider(sourcePathConverter)
|
private val storageProvider = JpsLookupStorageProvider(pathConverter)
|
||||||
|
|
||||||
fun cleanLookupStorage(log: Logger) {
|
fun cleanLookupStorage(log: Logger) {
|
||||||
synchronized(LookupStorageLock) {
|
synchronized(LookupStorageLock) {
|
||||||
@@ -58,14 +58,14 @@ class JpsLookupStorageManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class JpsLookupStorageProvider(
|
private class JpsLookupStorageProvider(
|
||||||
private val sourcePathConverter: SourceFileToPathConverter
|
private val pathConverter: FileToPathConverter
|
||||||
) : StorageProvider<JpsLookupStorage>() {
|
) : StorageProvider<JpsLookupStorage>() {
|
||||||
override fun createStorage(targetDataDir: File): JpsLookupStorage =
|
override fun createStorage(targetDataDir: File): JpsLookupStorage =
|
||||||
JpsLookupStorage(targetDataDir, sourcePathConverter)
|
JpsLookupStorage(targetDataDir, pathConverter)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JpsLookupStorage(
|
private class JpsLookupStorage(
|
||||||
targetDataDir: File,
|
targetDataDir: File,
|
||||||
sourcePathConverter: SourceFileToPathConverter
|
pathConverter: FileToPathConverter
|
||||||
) : StorageOwner, LookupStorage(targetDataDir, sourcePathConverter)
|
) : StorageOwner, LookupStorage(targetDataDir, pathConverter)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ class KotlinJsModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleBu
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createCacheStorage(paths: BuildDataPaths) =
|
override fun createCacheStorage(paths: BuildDataPaths) =
|
||||||
JpsIncrementalJsCache(jpsModuleBuildTarget, paths, kotlinContext.sourceFileToPathConverter)
|
JpsIncrementalJsCache(jpsModuleBuildTarget, paths, kotlinContext.fileToPathConverter)
|
||||||
|
|
||||||
override fun updateCaches(
|
override fun updateCaches(
|
||||||
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
|
|||||||
get() = IncrementalCompilation.isEnabledForJvm()
|
get() = IncrementalCompilation.isEnabledForJvm()
|
||||||
|
|
||||||
override fun createCacheStorage(paths: BuildDataPaths) =
|
override fun createCacheStorage(paths: BuildDataPaths) =
|
||||||
JpsIncrementalJvmCache(jpsModuleBuildTarget, paths, kotlinContext.sourceFileToPathConverter)
|
JpsIncrementalJvmCache(jpsModuleBuildTarget, paths, kotlinContext.fileToPathConverter)
|
||||||
|
|
||||||
override val buildMetaInfoFactory
|
override val buildMetaInfoFactory
|
||||||
get() = JvmBuildMetaInfo
|
get() = JvmBuildMetaInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user