diff --git a/.idea/artifacts/KotlinJpsPlugin.xml b/.idea/artifacts/KotlinJpsPlugin.xml
index 339fcff5cfc..d20c1520000 100644
--- a/.idea/artifacts/KotlinJpsPlugin.xml
+++ b/.idea/artifacts/KotlinJpsPlugin.xml
@@ -24,6 +24,7 @@
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 2a0c2319c7a..647e0d006fd 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -13,6 +13,7 @@
+
diff --git a/build/build.iml b/build/build.iml
new file mode 100644
index 00000000000..00fa174c223
--- /dev/null
+++ b/build/build.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/src/org/jetbrains/kotlin/build/generatedFiles.kt b/build/src/org/jetbrains/kotlin/build/generatedFiles.kt
new file mode 100644
index 00000000000..e93777d96d1
--- /dev/null
+++ b/build/src/org/jetbrains/kotlin/build/generatedFiles.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2010-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.build
+
+import org.jetbrains.kotlin.incremental.LocalFileKotlinClass
+import org.jetbrains.kotlin.load.kotlin.ModuleMapping
+import org.jetbrains.kotlin.utils.sure
+import java.io.File
+
+open class GeneratedFile(
+ val target: Target,
+ val sourceFiles: Collection,
+ val outputFile: File
+)
+
+class GeneratedJvmClass (
+ target: Target,
+ sourceFiles: Collection,
+ outputFile: File
+) : GeneratedFile(target, sourceFiles, outputFile) {
+ val outputClass = LocalFileKotlinClass.create(outputFile).sure {
+ "Couldn't load KotlinClass from $outputFile; it may happen because class doesn't have valid Kotlin annotations"
+ }
+}
+
+fun File.isModuleMappingFile() = extension == ModuleMapping.MAPPING_FILE_EXT && parentFile.name == "META-INF"
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheVersion.kt b/build/src/org/jetbrains/kotlin/incremental/CacheVersion.kt
similarity index 56%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheVersion.kt
rename to build/src/org/jetbrains/kotlin/incremental/CacheVersion.kt
index a2abb79eceb..f66a90e1c7d 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheVersion.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/CacheVersion.kt
@@ -14,14 +14,10 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
import org.jetbrains.annotations.TestOnly
-import org.jetbrains.jps.builders.BuildTarget
-import org.jetbrains.jps.builders.storage.BuildDataPaths
-import org.jetbrains.jps.incremental.ModuleBuildTarget
import org.jetbrains.kotlin.config.IncrementalCompilation
-import org.jetbrains.kotlin.jps.incremental.CacheVersion.Action
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
import java.io.File
@@ -93,43 +89,38 @@ class CacheVersion(
}
}
-class CacheVersionProvider(private val paths: BuildDataPaths) {
- private val BuildTarget<*>.dataRoot: File
- get() = paths.getTargetDataRoot(this)
+fun normalCacheVersion(dataRoot: File): CacheVersion =
+ CacheVersion(ownVersion = NORMAL_VERSION,
+ versionFile = File(dataRoot, NORMAL_VERSION_FILE_NAME),
+ whenVersionChanged = CacheVersion.Action.REBUILD_CHUNK,
+ whenTurnedOn = CacheVersion.Action.REBUILD_CHUNK,
+ whenTurnedOff = CacheVersion.Action.CLEAN_NORMAL_CACHES,
+ isEnabled = { IncrementalCompilation.isEnabled() })
- fun normalVersion(target: ModuleBuildTarget): CacheVersion =
- CacheVersion(ownVersion = NORMAL_VERSION,
- versionFile = File(target.dataRoot, NORMAL_VERSION_FILE_NAME),
- whenVersionChanged = Action.REBUILD_CHUNK,
- whenTurnedOn = Action.REBUILD_CHUNK,
- whenTurnedOff = Action.CLEAN_NORMAL_CACHES,
- isEnabled = { IncrementalCompilation.isEnabled() })
+fun experimentalCacheVersion(dataRoot: File): CacheVersion =
+ CacheVersion(ownVersion = EXPERIMENTAL_VERSION,
+ versionFile = File(dataRoot, EXPERIMENTAL_VERSION_FILE_NAME),
+ whenVersionChanged = CacheVersion.Action.REBUILD_CHUNK,
+ whenTurnedOn = CacheVersion.Action.REBUILD_CHUNK,
+ whenTurnedOff = CacheVersion.Action.CLEAN_EXPERIMENTAL_CACHES,
+ isEnabled = { IncrementalCompilation.isExperimental() })
- fun experimentalVersion(target: ModuleBuildTarget): CacheVersion =
- CacheVersion(ownVersion = EXPERIMENTAL_VERSION,
- versionFile = File(target.dataRoot, EXPERIMENTAL_VERSION_FILE_NAME),
- whenVersionChanged = Action.REBUILD_CHUNK,
- whenTurnedOn = Action.REBUILD_CHUNK,
- whenTurnedOff = Action.CLEAN_EXPERIMENTAL_CACHES,
- isEnabled = { IncrementalCompilation.isExperimental() })
+fun dataContainerCacheVersion(dataRoot: File): CacheVersion =
+ CacheVersion(ownVersion = DATA_CONTAINER_VERSION,
+ versionFile = File(dataRoot, DATA_CONTAINER_VERSION_FILE_NAME),
+ whenVersionChanged = CacheVersion.Action.REBUILD_ALL_KOTLIN,
+ whenTurnedOn = CacheVersion.Action.REBUILD_ALL_KOTLIN,
+ whenTurnedOff = CacheVersion.Action.CLEAN_DATA_CONTAINER,
+ isEnabled = { IncrementalCompilation.isExperimental() })
- fun dataContainerVersion(): CacheVersion =
- CacheVersion(ownVersion = DATA_CONTAINER_VERSION,
- versionFile = File(KotlinDataContainerTarget.dataRoot, DATA_CONTAINER_VERSION_FILE_NAME),
- whenVersionChanged = Action.REBUILD_ALL_KOTLIN,
- whenTurnedOn = Action.REBUILD_ALL_KOTLIN,
- whenTurnedOff = Action.CLEAN_DATA_CONTAINER,
- isEnabled = { IncrementalCompilation.isExperimental() })
+fun allCachesVersions(containerDataRoot: File, dataRoots: Iterable): Iterable {
+ val versions = arrayListOf()
+ versions.add(dataContainerCacheVersion(containerDataRoot))
- fun allVersions(targets: Iterable): Iterable {
- val versions = arrayListOf()
- versions.add(dataContainerVersion())
-
- for (target in targets) {
- versions.add(normalVersion(target))
- versions.add(experimentalVersion(target))
- }
-
- return versions
+ for (dataRoot in dataRoots) {
+ versions.add(normalCacheVersion(dataRoot))
+ versions.add(experimentalCacheVersion(dataRoot))
}
-}
\ No newline at end of file
+
+ return versions
+}
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/build/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt
similarity index 93%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt
rename to build/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt
index 5b4157eab37..d0f17f43181 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/IncrementalCacheImpl.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
import com.google.protobuf.MessageLite
import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName
@@ -22,13 +22,9 @@ import com.intellij.util.SmartList
import com.intellij.util.io.BooleanDataDescriptor
import com.intellij.util.io.EnumeratorStringDescriptor
import org.jetbrains.annotations.TestOnly
-import org.jetbrains.jps.builders.storage.BuildDataPaths
-import org.jetbrains.jps.incremental.ModuleBuildTarget
-import org.jetbrains.jps.incremental.storage.PathStringDescriptor
+import org.jetbrains.kotlin.build.GeneratedJvmClass
import org.jetbrains.kotlin.config.IncrementalCompilation
-import org.jetbrains.kotlin.jps.build.GeneratedJvmClass
-import org.jetbrains.kotlin.jps.build.KotlinBuilder
-import org.jetbrains.kotlin.jps.incremental.storage.*
+import org.jetbrains.kotlin.incremental.storage.*
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
@@ -51,9 +47,10 @@ import java.util.*
val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin"
-open class IncrementalCacheImpl(
- private val target: ModuleBuildTarget,
- paths: BuildDataPaths
+open class IncrementalCacheImpl(
+ private val targetDataRoot: File,
+ targetOutputDir: File?,
+ target: Target
) : BasicMapsOwner(), IncrementalCache {
companion object {
private val PROTO_MAP = "proto"
@@ -69,8 +66,7 @@ open class IncrementalCacheImpl(
private val MODULE_MAPPING_FILE_NAME = "." + ModuleMapping.MAPPING_FILE_EXT
}
- private val baseDir = File(paths.getTargetDataRoot(target), KOTLIN_CACHE_DIRECTORY_NAME)
- private val cacheVersionProvider = CacheVersionProvider(paths)
+ private val baseDir = File(targetDataRoot, KOTLIN_CACHE_DIRECTORY_NAME)
private val experimentalMaps = arrayListOf>()
private fun > registerExperimentalMap(map: M): M {
@@ -91,19 +87,22 @@ open class IncrementalCacheImpl(
private val subtypesMap = registerExperimentalMap(SubtypesMap(SUBTYPES.storageFile))
private val supertypesMap = registerExperimentalMap(SupertypesMap(SUPERTYPES.storageFile))
- private val dependents = arrayListOf()
- private val outputDir by lazy(LazyThreadSafetyMode.NONE) { requireNotNull(target.outputDir) { "Target is expected to have output directory: $target" } }
+ private val dependents = arrayListOf>()
+ private val outputDir by lazy(LazyThreadSafetyMode.NONE) { requireNotNull(targetOutputDir) { "Target is expected to have output directory: $target" } }
- protected val dependentsWithThis: Sequence
+ // TODO: review
+ val dependentsWithThis: Sequence>
get() = sequenceOf(this).plus(dependents.asSequence())
- internal val dependentCaches: Iterable
+ internal val dependentCaches: Iterable>
get() = dependents
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
}
- fun addDependentCache(cache: IncrementalCacheImpl) {
+ protected open fun debugLog(message: String) {}
+
+ fun addDependentCache(cache: IncrementalCacheImpl) {
dependents.add(cache)
}
@@ -133,7 +132,7 @@ open class IncrementalCacheImpl(
return CompilationResult.NO_CHANGES
}
- fun saveFileToCache(generatedClass: GeneratedJvmClass): CompilationResult {
+ fun saveFileToCache(generatedClass: GeneratedJvmClass): CompilationResult {
val sourceFiles: Collection = generatedClass.sourceFiles
val kotlinClass: LocalFileKotlinClass = generatedClass.outputClass
val className = kotlinClass.className
@@ -199,7 +198,7 @@ open class IncrementalCacheImpl(
private fun CompilationResult.logIfSomethingChanged(className: JvmClassName) {
if (this == CompilationResult.NO_CHANGES) return
- KotlinBuilder.LOG.debug("$className is changed: $this")
+ debugLog("$className is changed: $this")
}
fun clearCacheForRemovedClasses(): CompilationResult {
@@ -301,7 +300,7 @@ open class IncrementalCacheImpl(
override fun getObsoletePackageParts(): Collection {
val obsoletePackageParts =
dirtyOutputClassesMap.getDirtyOutputClasses().filter { packagePartMap.isPackagePart(JvmClassName.byInternalName(it)) }
- KotlinBuilder.LOG.debug("Obsolete package parts: ${obsoletePackageParts}")
+ debugLog("Obsolete package parts: ${obsoletePackageParts}")
return obsoletePackageParts
}
@@ -317,7 +316,7 @@ open class IncrementalCacheImpl(
val dirtyFacade = partToMultifileFacade.get(dirtyClass) ?: continue
obsoleteMultifileClasses.add(dirtyFacade)
}
- KotlinBuilder.LOG.debug("Obsolete multifile class facades: $obsoleteMultifileClasses")
+ debugLog("Obsolete multifile class facades: $obsoleteMultifileClasses")
return obsoleteMultifileClasses
}
@@ -336,12 +335,12 @@ open class IncrementalCacheImpl(
override fun clean() {
super.clean()
- cacheVersionProvider.normalVersion(target).clean()
- cacheVersionProvider.experimentalVersion(target).clean()
+ normalCacheVersion(targetDataRoot).clean()
+ experimentalCacheVersion(targetDataRoot).clean()
}
fun cleanExperimental() {
- cacheVersionProvider.experimentalVersion(target).clean()
+ experimentalCacheVersion(targetDataRoot).clean()
experimentalMaps.forEach { it.clean() }
}
@@ -497,7 +496,8 @@ open class IncrementalCacheImpl(
override fun dumpValue(value: String): String = value
}
- private inner class SourceToClassesMap(storageFile: File) : BasicStringMap>(storageFile, PathStringDescriptor.INSTANCE, StringCollectionExternalizer) {
+ // TODO: find how to deal with PathStringDescriptor - it seems too deeply rooted in jps
+ inner class SourceToClassesMap(storageFile: File) : BasicStringMap>(storageFile, /* PathStringDescriptor.INSTANCE,*/ StringCollectionExternalizer) {
fun clearOutputsForSource(sourceFile: File) {
remove(sourceFile.absolutePath)
}
@@ -614,10 +614,10 @@ data class CompilationResult(
operator fun plus(other: CompilationResult): CompilationResult =
CompilationResult(protoChanged || other.protoChanged,
- constantsChanged || other.constantsChanged,
- inlineChanged || other.inlineChanged,
- inlineAdded || other.inlineAdded,
- changes + other.changes)
+ constantsChanged || other.constantsChanged,
+ inlineChanged || other.inlineChanged,
+ inlineAdded || other.inlineAdded,
+ changes + other.changes)
}
fun ByteArray.md5(): Long {
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCompilationComponentsImpl.kt b/build/src/org/jetbrains/kotlin/incremental/IncrementalCompilationComponentsImpl.kt
similarity index 82%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCompilationComponentsImpl.kt
rename to build/src/org/jetbrains/kotlin/incremental/IncrementalCompilationComponentsImpl.kt
index 7214001281f..80fd85a86c5 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCompilationComponentsImpl.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/IncrementalCompilationComponentsImpl.kt
@@ -14,22 +14,19 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
-import org.jetbrains.jps.incremental.ModuleBuildTarget
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
import org.jetbrains.kotlin.modules.TargetId
class IncrementalCompilationComponentsImpl(
- caches: Map,
+ private val caches: Map,
private val lookupTracker: LookupTracker
): IncrementalCompilationComponents {
- private val caches = caches.mapKeys { TargetId(it.key) }
-
override fun getIncrementalCache(target: TargetId): IncrementalCache =
- caches[target]!!
+ caches[target] ?: throw Exception("Incremental cache for target ${target.name} not found")
override fun getLookupTracker(): LookupTracker = lookupTracker
}
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/LocalFileKotlinClass.kt b/build/src/org/jetbrains/kotlin/incremental/LocalFileKotlinClass.kt
similarity index 97%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/LocalFileKotlinClass.kt
rename to build/src/org/jetbrains/kotlin/incremental/LocalFileKotlinClass.kt
index 356b58443eb..e94c8a3c101 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/LocalFileKotlinClass.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/LocalFileKotlinClass.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.load.kotlin.FileBasedKotlinClass
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/LookupStorage.kt b/build/src/org/jetbrains/kotlin/incremental/LookupStorage.kt
similarity index 93%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/LookupStorage.kt
rename to build/src/org/jetbrains/kotlin/incremental/LookupStorage.kt
index 27110d361d1..e1ca3696acf 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/LookupStorage.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/LookupStorage.kt
@@ -14,24 +14,20 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
import com.intellij.util.containers.MultiMap
import org.jetbrains.annotations.TestOnly
-import org.jetbrains.jps.builders.storage.StorageProvider
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.components.Position
import org.jetbrains.kotlin.incremental.components.ScopeKind
-import org.jetbrains.kotlin.jps.incremental.storage.*
+import org.jetbrains.kotlin.incremental.storage.*
import org.jetbrains.kotlin.utils.Printer
import java.io.File
import java.util.*
-object LookupStorageProvider : StorageProvider() {
- override fun createStorage(targetDataDir: File): LookupStorage = LookupStorage(targetDataDir)
-}
-class LookupStorage(private val targetDataDir: File) : BasicMapsOwner() {
+open class LookupStorage(private val targetDataDir: File) : BasicMapsOwner() {
companion object {
private val DELETED_TO_SIZE_TRESHOLD = 0.5
private val MINIMUM_GARBAGE_COLLECTIBLE_SIZE = 10000
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt b/build/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
similarity index 99%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
rename to build/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
index e09d74d90ab..bc11e1a0b0d 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.serialization.ProtoBuf
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/protoDifferenceUtils.kt b/build/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt
similarity index 97%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/protoDifferenceUtils.kt
rename to build/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt
index 3f7971857ad..273024b2ec7 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/protoDifferenceUtils.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental
+package org.jetbrains.kotlin.incremental
import com.google.protobuf.MessageLite
import org.jetbrains.kotlin.descriptors.Visibilities
-import org.jetbrains.kotlin.jps.incremental.ProtoCompareGenerated.ProtoBufClassKind
-import org.jetbrains.kotlin.jps.incremental.ProtoCompareGenerated.ProtoBufPackageKind
-import org.jetbrains.kotlin.jps.incremental.storage.ProtoMapValue
+import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufClassKind
+import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufPackageKind
+import org.jetbrains.kotlin.incremental.storage.ProtoMapValue
import org.jetbrains.kotlin.serialization.Flags
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.Deserialization
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/BasicMap.kt b/build/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt
similarity index 93%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/BasicMap.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt
index d2ba1c11631..ef3f7e0c6f7 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/BasicMap.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.EnumeratorStringDescriptor
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.utils.Printer
import java.io.File
-internal abstract class BasicMap, V>(
+abstract class BasicMap, V>(
storageFile: File,
keyDescriptor: KeyDescriptor,
valueExternalizer: DataExternalizer
@@ -67,7 +67,7 @@ internal abstract class BasicMap, V>(
protected abstract fun dumpValue(value: V): String
}
-internal abstract class BasicStringMap(
+abstract class BasicStringMap(
storageFile: File,
keyDescriptor: KeyDescriptor,
valueExternalizer: DataExternalizer
@@ -78,4 +78,4 @@ internal abstract class BasicStringMap(
) : this(storageFile, EnumeratorStringDescriptor.INSTANCE, valueExternalizer)
override fun dumpKey(key: String): String = key
-}
\ No newline at end of file
+}
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/BasicMapsOwner.kt b/build/src/org/jetbrains/kotlin/incremental/storage/BasicMapsOwner.kt
similarity index 81%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/BasicMapsOwner.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/BasicMapsOwner.kt
index 6e11fb22d50..5cc5cc28fae 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/BasicMapsOwner.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/BasicMapsOwner.kt
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import org.jetbrains.annotations.TestOnly
-import org.jetbrains.jps.incremental.storage.StorageOwner
-open class BasicMapsOwner : StorageOwner {
+open class BasicMapsOwner {
private val maps = arrayListOf>()
companion object {
@@ -31,15 +30,15 @@ open class BasicMapsOwner : StorageOwner {
return map
}
- override fun clean() {
+ open fun clean() {
maps.forEach { it.clean() }
}
- override fun close() {
+ open fun close() {
maps.forEach { it.close() }
}
- override fun flush(memoryCachesOnly: Boolean) {
+ open fun flush(memoryCachesOnly: Boolean) {
maps.forEach { it.flush(memoryCachesOnly) }
}
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/ClassOneToManyMap.kt b/build/src/org/jetbrains/kotlin/incremental/storage/ClassOneToManyMap.kt
similarity index 93%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/ClassOneToManyMap.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/ClassOneToManyMap.kt
index b04477bf682..e70f4b3a469 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/ClassOneToManyMap.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/ClassOneToManyMap.kt
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
-import org.jetbrains.kotlin.jps.incremental.dumpCollection
+import org.jetbrains.kotlin.incremental.dumpCollection
import org.jetbrains.kotlin.name.FqName
import java.io.File
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/FileToIdMap.kt b/build/src/org/jetbrains/kotlin/incremental/storage/FileToIdMap.kt
similarity index 95%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/FileToIdMap.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/FileToIdMap.kt
index fdae86816b5..90abe12b22d 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/FileToIdMap.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/FileToIdMap.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import org.jetbrains.kotlin.utils.keysToMap
import java.io.File
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/IdToFileMap.kt b/build/src/org/jetbrains/kotlin/incremental/storage/IdToFileMap.kt
similarity index 95%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/IdToFileMap.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/IdToFileMap.kt
index cd6ce62bc4e..98f84e01d43 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/IdToFileMap.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/IdToFileMap.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.ExternalIntegerKeyDescriptor
import java.io.File
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/LazyStorage.kt b/build/src/org/jetbrains/kotlin/incremental/storage/LazyStorage.kt
similarity index 97%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/LazyStorage.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/LazyStorage.kt
index 0a5690c8c41..55eddd43592 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/LazyStorage.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/LazyStorage.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.IOUtil
@@ -28,7 +28,7 @@ import java.io.IOException
/**
* It's lazy in a sense that PersistentHashMap is created only on write
*/
-internal class LazyStorage(
+class LazyStorage(
private val storageFile: File,
private val keyDescriptor: KeyDescriptor,
private val valueExternalizer: DataExternalizer
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/LookupMap.kt b/build/src/org/jetbrains/kotlin/incremental/storage/LookupMap.kt
similarity index 96%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/LookupMap.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/LookupMap.kt
index 70fe113bf72..d9fab23228b 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/LookupMap.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/LookupMap.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import java.io.File
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/externalizers.kt b/build/src/org/jetbrains/kotlin/incremental/storage/externalizers.kt
similarity index 92%
rename from jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/externalizers.kt
rename to build/src/org/jetbrains/kotlin/incremental/storage/externalizers.kt
index 39acab1e1de..fa9ebe38efc 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storage/externalizers.kt
+++ b/build/src/org/jetbrains/kotlin/incremental/storage/externalizers.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.jps.incremental.storage
+package org.jetbrains.kotlin.incremental.storage
import com.intellij.openapi.util.io.FileUtil
import com.intellij.util.io.DataExternalizer
@@ -22,7 +22,6 @@ import com.intellij.util.io.EnumeratorStringDescriptor
import com.intellij.util.io.IOUtil
import com.intellij.util.io.KeyDescriptor
import gnu.trove.THashSet
-import org.jetbrains.jps.incremental.storage.PathStringDescriptor
import java.io.DataInput
import java.io.DataInputStream
import java.io.DataOutput
@@ -125,6 +124,27 @@ object StringToLongMapExternalizer : StringMapExternalizer() {
}
}
+
+object PathStringCollectionExternalizer : DataExternalizer> {
+ override fun save(output: DataOutput, value: Collection) {
+ for (str in value) {
+ IOUtil.writeUTF(output, str)
+ }
+ }
+
+ override fun read(input: DataInput): Collection {
+ val result = THashSet(FileUtil.PATH_HASHING_STRATEGY)
+ val stream = input as DataInputStream
+
+ while (stream.available() > 0) {
+ val str = IOUtil.readUTF(stream)
+ result.add(str)
+ }
+
+ return result
+ }
+}
+
object ConstantsMapExternalizer : DataExternalizer