Use simple data class TargetId instead of Module to get incremental cache
Original commit: 7e515e3820
This commit is contained in:
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
|||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil;
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil;
|
||||||
import org.jetbrains.kotlin.config.CompilerSettings;
|
import org.jetbrains.kotlin.config.CompilerSettings;
|
||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
|
||||||
import org.jetbrains.kotlin.modules.Module;
|
import org.jetbrains.kotlin.modules.TargetId;
|
||||||
import org.jetbrains.kotlin.rmi.*;
|
import org.jetbrains.kotlin.rmi.*;
|
||||||
import org.jetbrains.kotlin.rmi.kotlinr.KotlinCompilerClient;
|
import org.jetbrains.kotlin.rmi.kotlinr.KotlinCompilerClient;
|
||||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||||
@@ -59,7 +59,7 @@ public class KotlinCompilerRunner {
|
|||||||
CompilerSettings compilerSettings,
|
CompilerSettings compilerSettings,
|
||||||
MessageCollector messageCollector,
|
MessageCollector messageCollector,
|
||||||
CompilerEnvironment environment,
|
CompilerEnvironment environment,
|
||||||
Map<Module, IncrementalCache> incrementalCaches,
|
Map<TargetId, IncrementalCache> incrementalCaches,
|
||||||
File moduleFile,
|
File moduleFile,
|
||||||
OutputItemsCollector collector
|
OutputItemsCollector collector
|
||||||
) {
|
) {
|
||||||
@@ -76,7 +76,7 @@ public class KotlinCompilerRunner {
|
|||||||
@NotNull CompilerSettings compilerSettings,
|
@NotNull CompilerSettings compilerSettings,
|
||||||
@NotNull MessageCollector messageCollector,
|
@NotNull MessageCollector messageCollector,
|
||||||
@NotNull CompilerEnvironment environment,
|
@NotNull CompilerEnvironment environment,
|
||||||
Map<Module, IncrementalCache> incrementalCaches,
|
Map<TargetId, IncrementalCache> incrementalCaches,
|
||||||
@NotNull OutputItemsCollector collector,
|
@NotNull OutputItemsCollector collector,
|
||||||
@NotNull Collection<File> sourceFiles,
|
@NotNull Collection<File> sourceFiles,
|
||||||
@NotNull List<String> libraryFiles,
|
@NotNull List<String> libraryFiles,
|
||||||
@@ -96,7 +96,7 @@ public class KotlinCompilerRunner {
|
|||||||
MessageCollector messageCollector,
|
MessageCollector messageCollector,
|
||||||
OutputItemsCollector collector,
|
OutputItemsCollector collector,
|
||||||
CompilerEnvironment environment,
|
CompilerEnvironment environment,
|
||||||
Map<Module, IncrementalCache> incrementalCaches
|
Map<TargetId, IncrementalCache> incrementalCaches
|
||||||
) {
|
) {
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
PrintStream out = new PrintStream(stream);
|
PrintStream out = new PrintStream(stream);
|
||||||
@@ -117,7 +117,7 @@ public class KotlinCompilerRunner {
|
|||||||
CommonCompilerArguments arguments,
|
CommonCompilerArguments arguments,
|
||||||
String additionalArguments,
|
String additionalArguments,
|
||||||
CompilerEnvironment environment,
|
CompilerEnvironment environment,
|
||||||
Map<Module, IncrementalCache> incrementalCaches,
|
Map<TargetId, IncrementalCache> incrementalCaches,
|
||||||
PrintStream out,
|
PrintStream out,
|
||||||
MessageCollector messageCollector
|
MessageCollector messageCollector
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
|||||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||||
import org.jetbrains.kotlin.modules.Module
|
import org.jetbrains.kotlin.modules.TargetId
|
||||||
import org.jetbrains.kotlin.progress.CompilationCanceledException
|
import org.jetbrains.kotlin.progress.CompilationCanceledException
|
||||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||||
@@ -320,8 +320,8 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
}
|
}
|
||||||
|
|
||||||
return compileToJvm(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder, environment,
|
return compileToJvm(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder, environment,
|
||||||
incrementalCaches.mapKeysTo(HashMap<Module, IncrementalCache>(incrementalCaches.size()),
|
incrementalCaches.mapKeysTo(HashMap<TargetId, IncrementalCache>(incrementalCaches.size()),
|
||||||
{ ModuleToModuleBuildTargetAdapter(it.getKey()) }),
|
{ TargetId(it.getKey()) }),
|
||||||
filesToCompile, messageCollector)
|
filesToCompile, messageCollector)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
|| className.startsWith("org.apache.log4j.") // For logging from compiler
|
|| className.startsWith("org.apache.log4j.") // For logging from compiler
|
||||||
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledStatus"
|
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledStatus"
|
||||||
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledException"
|
|| className == "org.jetbrains.kotlin.progress.CompilationCanceledException"
|
||||||
|| className == "org.jetbrains.kotlin.modules.Module"
|
|| className == "org.jetbrains.kotlin.modules.TargetId"
|
||||||
},
|
},
|
||||||
compilerServices
|
compilerServices
|
||||||
)
|
)
|
||||||
@@ -488,7 +488,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
private fun compileToJs(chunk: ModuleChunk,
|
private fun compileToJs(chunk: ModuleChunk,
|
||||||
commonArguments: CommonCompilerArguments,
|
commonArguments: CommonCompilerArguments,
|
||||||
environment: CompilerEnvironment,
|
environment: CompilerEnvironment,
|
||||||
incrementalCaches: MutableMap<Module, IncrementalCache>?,
|
incrementalCaches: MutableMap<TargetId, IncrementalCache>?,
|
||||||
messageCollector: MessageCollectorAdapter, project: JpsProject
|
messageCollector: MessageCollectorAdapter, project: JpsProject
|
||||||
): OutputItemsCollectorImpl? {
|
): OutputItemsCollectorImpl? {
|
||||||
val outputItemCollector = OutputItemsCollectorImpl()
|
val outputItemCollector = OutputItemsCollectorImpl()
|
||||||
@@ -543,7 +543,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
context: CompileContext,
|
context: CompileContext,
|
||||||
dirtyFilesHolder: DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>,
|
dirtyFilesHolder: DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>,
|
||||||
environment: CompilerEnvironment,
|
environment: CompilerEnvironment,
|
||||||
incrementalCaches: MutableMap<Module, IncrementalCache>?,
|
incrementalCaches: MutableMap<TargetId, IncrementalCache>?,
|
||||||
filesToCompile: MultiMap<ModuleBuildTarget, File>, messageCollector: MessageCollectorAdapter
|
filesToCompile: MultiMap<ModuleBuildTarget, File>, messageCollector: MessageCollectorAdapter
|
||||||
): OutputItemsCollectorImpl? {
|
): OutputItemsCollectorImpl? {
|
||||||
val outputItemCollector = OutputItemsCollectorImpl()
|
val outputItemCollector = OutputItemsCollectorImpl()
|
||||||
|
|||||||
+3
-29
@@ -20,42 +20,16 @@ import org.jetbrains.jps.incremental.ModuleBuildTarget
|
|||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||||
import org.jetbrains.kotlin.modules.Module
|
import org.jetbrains.kotlin.modules.TargetId
|
||||||
|
|
||||||
public class IncrementalCompilationComponentsImpl(
|
public class IncrementalCompilationComponentsImpl(
|
||||||
caches: Map<ModuleBuildTarget, IncrementalCache>,
|
caches: Map<ModuleBuildTarget, IncrementalCache>,
|
||||||
private val lookupTracker: LookupTracker
|
private val lookupTracker: LookupTracker
|
||||||
): IncrementalCompilationComponents {
|
): IncrementalCompilationComponents {
|
||||||
private val caches = caches.mapKeys { ModuleToModuleBuildTargetAdapter(it.key) }
|
private val caches = caches.mapKeys { TargetId(it.key) }
|
||||||
|
|
||||||
override fun getIncrementalCache(target: Module): IncrementalCache =
|
override fun getIncrementalCache(target: TargetId): IncrementalCache =
|
||||||
caches[target]!!
|
caches[target]!!
|
||||||
|
|
||||||
override fun getLookupTracker(): LookupTracker = lookupTracker
|
override fun getLookupTracker(): LookupTracker = lookupTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ModuleToModuleBuildTargetAdapter(
|
|
||||||
private val moduleBuildTarget: ModuleBuildTarget
|
|
||||||
) : Module {
|
|
||||||
|
|
||||||
override fun getModuleName(): String =
|
|
||||||
moduleBuildTarget.id
|
|
||||||
|
|
||||||
override fun getModuleType(): String =
|
|
||||||
moduleBuildTarget.targetType.typeId
|
|
||||||
|
|
||||||
override fun getAnnotationsRoots(): List<String> =
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
|
|
||||||
override fun getClasspathRoots(): List<String> =
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
|
|
||||||
override fun getJavaSourceRoots(): List<String> =
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
|
|
||||||
override fun getOutputDirectory(): String =
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
|
|
||||||
override fun getSourceFiles(): List<String> =
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.modules
|
||||||
|
|
||||||
|
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||||
|
|
||||||
|
public fun TargetId(moduleBuildTarget: ModuleBuildTarget): TargetId =
|
||||||
|
TargetId(moduleBuildTarget.id, moduleBuildTarget.targetType.typeId)
|
||||||
Reference in New Issue
Block a user