@@ -22,22 +22,19 @@ import com.intellij.openapi.util.io.FileUtil
|
|||||||
import com.intellij.util.containers.MultiMap
|
import com.intellij.util.containers.MultiMap
|
||||||
import gnu.trove.THashSet
|
import gnu.trove.THashSet
|
||||||
import org.jetbrains.jps.ModuleChunk
|
import org.jetbrains.jps.ModuleChunk
|
||||||
import org.jetbrains.jps.builders.*
|
import org.jetbrains.jps.builders.BuildTarget
|
||||||
|
import org.jetbrains.jps.builders.DirtyFilesHolder
|
||||||
import org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl
|
import org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl
|
||||||
import org.jetbrains.jps.builders.impl.TargetOutputIndexImpl
|
import org.jetbrains.jps.builders.impl.TargetOutputIndexImpl
|
||||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil
|
import org.jetbrains.jps.builders.java.JavaBuilderUtil
|
||||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor
|
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor
|
||||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings
|
import org.jetbrains.jps.builders.java.dependencyView.Mappings
|
||||||
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
|
||||||
import org.jetbrains.jps.incremental.*
|
import org.jetbrains.jps.incremental.*
|
||||||
import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.*
|
import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.*
|
||||||
import org.jetbrains.jps.incremental.fs.CompilationRound
|
import org.jetbrains.jps.incremental.fs.CompilationRound
|
||||||
import org.jetbrains.jps.incremental.java.JavaBuilder
|
import org.jetbrains.jps.incremental.java.JavaBuilder
|
||||||
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.indices.IgnoredFileIndex
|
|
||||||
import org.jetbrains.jps.indices.ModuleExcludeIndex
|
|
||||||
import org.jetbrains.jps.model.JpsModel
|
|
||||||
import org.jetbrains.jps.model.JpsProject
|
import org.jetbrains.jps.model.JpsProject
|
||||||
import org.jetbrains.jps.model.JpsSimpleElement
|
import org.jetbrains.jps.model.JpsSimpleElement
|
||||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
||||||
@@ -156,7 +153,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
val project = projectDescriptor.project
|
val project = projectDescriptor.project
|
||||||
|
|
||||||
val lookupTracker = dataManager.getStorage(LOOKUP_TRACKER_TARGET, LOOKUP_TRACKER_STORAGE_PROVIDER)
|
val lookupTracker = dataManager.getStorage(LOOKUP_TRACKER_TARGET, LOOKUP_TRACKER_STORAGE_PROVIDER)
|
||||||
val incrementalCaches = getIncrementalCaches(chunk, context)
|
val incrementalCaches = getIncrementalCaches(chunk, context, lookupTracker)
|
||||||
val environment = createCompileEnvironment(incrementalCaches, lookupTracker, context)
|
val environment = createCompileEnvironment(incrementalCaches, lookupTracker, context)
|
||||||
if (!environment.success()) {
|
if (!environment.success()) {
|
||||||
environment.reportErrorsTo(messageCollector)
|
environment.reportErrorsTo(messageCollector)
|
||||||
@@ -626,7 +623,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
private val Iterable<BuildTarget<*>>.moduleTargets: Iterable<ModuleBuildTarget>
|
private val Iterable<BuildTarget<*>>.moduleTargets: Iterable<ModuleBuildTarget>
|
||||||
get() = filterIsInstance(javaClass<ModuleBuildTarget>())
|
get() = filterIsInstance(javaClass<ModuleBuildTarget>())
|
||||||
|
|
||||||
private fun getIncrementalCaches(chunk: ModuleChunk, context: CompileContext): Map<ModuleBuildTarget, IncrementalCacheImpl> {
|
private fun getIncrementalCaches(chunk: ModuleChunk, context: CompileContext, lookupTrackerImpl: LookupTrackerImpl?): Map<ModuleBuildTarget, IncrementalCacheImpl> {
|
||||||
val dataManager = context.projectDescriptor.dataManager
|
val dataManager = context.projectDescriptor.dataManager
|
||||||
val targets = chunk.targets
|
val targets = chunk.targets
|
||||||
|
|
||||||
@@ -656,6 +653,8 @@ private fun getIncrementalCaches(chunk: ModuleChunk, context: CompileContext): M
|
|||||||
dependents[target]?.forEach {
|
dependents[target]?.forEach {
|
||||||
cache.addDependentCache(caches[it]!!)
|
cache.addDependentCache(caches[it]!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache.setLookupTracker(lookupTrackerImpl)
|
||||||
}
|
}
|
||||||
|
|
||||||
return caches
|
return caches
|
||||||
|
|||||||
@@ -89,6 +89,11 @@ public class IncrementalCacheImpl(
|
|||||||
private val cacheFormatVersion = CacheFormatVersion(targetDataRoot)
|
private val cacheFormatVersion = CacheFormatVersion(targetDataRoot)
|
||||||
private val dependents = arrayListOf<IncrementalCacheImpl>()
|
private val dependents = arrayListOf<IncrementalCacheImpl>()
|
||||||
private val outputDir = requireNotNull(target.outputDir) { "Target is expected to have output directory: $target" }
|
private val outputDir = requireNotNull(target.outputDir) { "Target is expected to have output directory: $target" }
|
||||||
|
private var lookupTrackerImpl: LookupTrackerImpl? = null
|
||||||
|
|
||||||
|
public fun setLookupTracker(lookupTrackerImpl: LookupTrackerImpl?) {
|
||||||
|
this.lookupTrackerImpl = lookupTrackerImpl
|
||||||
|
}
|
||||||
|
|
||||||
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
override fun registerInline(fromPath: String, jvmSignature: String, toPath: String) {
|
||||||
inlinedTo.add(fromPath, jvmSignature, toPath)
|
inlinedTo.add(fromPath, jvmSignature, toPath)
|
||||||
@@ -480,17 +485,26 @@ public class IncrementalCacheImpl(
|
|||||||
|
|
||||||
private inner class SourceToClassesMap(storageFile: File) : BasicStringMap<List<String>>(storageFile, PathStringDescriptor.INSTANCE, STRING_LIST_EXTERNALIZER) {
|
private inner class SourceToClassesMap(storageFile: File) : BasicStringMap<List<String>>(storageFile, PathStringDescriptor.INSTANCE, STRING_LIST_EXTERNALIZER) {
|
||||||
public fun clearOutputsForSource(sourceFile: File) {
|
public fun clearOutputsForSource(sourceFile: File) {
|
||||||
storage.remove(sourceFile.absolutePath)
|
remove(sourceFile.absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun add(sourceFile: File, className: JvmClassName) {
|
public fun add(sourceFile: File, className: JvmClassName) {
|
||||||
storage.append(sourceFile.absolutePath, { out -> IOUtil.writeUTF(out, className.getInternalName()) })
|
storage.append(sourceFile.absolutePath, { out -> IOUtil.writeUTF(out, className.internalName) })
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun get(sourceFile: File): Collection<JvmClassName> =
|
public fun get(sourceFile: File): Collection<JvmClassName> =
|
||||||
storage[sourceFile.absolutePath].orEmpty().map { JvmClassName.byInternalName(it) }
|
storage[sourceFile.absolutePath].orEmpty().map { JvmClassName.byInternalName(it) }
|
||||||
|
|
||||||
override fun dumpValue(value: List<String>) = value.toString()
|
override fun dumpValue(value: List<String>) = value.toString()
|
||||||
|
|
||||||
|
override fun clean() {
|
||||||
|
storage.keys.forEach { remove(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun remove(path: String) {
|
||||||
|
storage.remove(path)
|
||||||
|
lookupTrackerImpl?.removeLookupsFrom(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class DirtyOutputClassesMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
|
private inner class DirtyOutputClassesMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
|
||||||
|
|||||||
@@ -50,5 +50,9 @@ class LookupTrackerImpl(private val targetDataDir: File) : BasicMapsOwner(), Loo
|
|||||||
override fun flush(memoryCachesOnly: Boolean) {
|
override fun flush(memoryCachesOnly: Boolean) {
|
||||||
lookupMap.flush(memoryCachesOnly)
|
lookupMap.flush(memoryCachesOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeLookupsFrom(path: String) {
|
||||||
|
filesMap.remove(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ internal abstract class BasicMap<K : Comparable<K>, V>(
|
|||||||
) {
|
) {
|
||||||
protected val storage = LazyStorage(storageFile, keyDescriptor, valueExternalizer)
|
protected val storage = LazyStorage(storageFile, keyDescriptor, valueExternalizer)
|
||||||
|
|
||||||
fun clean() {
|
open fun clean() {
|
||||||
storage.clean()
|
storage.clean()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ class FilesMap(file: File) : BasicMap<Int, Collection<String>>(file, ExternalInt
|
|||||||
storage.append(hash) { it.writeUTF(path) }
|
storage.append(hash) { it.writeUTF(path) }
|
||||||
return hash
|
return hash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun remove(path: String) {
|
||||||
|
val hash = FileUtil.PATH_HASHING_STRATEGY.computeHashCode(path)
|
||||||
|
val collection = storage[hash] as? MutableCollection<String> ?: return
|
||||||
|
collection.remove(path)
|
||||||
|
|
||||||
|
if (collection.isNotEmpty()) {
|
||||||
|
storage.remove(hash)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user