jps-plugin: cleanup 'public', property access syntax

This commit is contained in:
Dmitry Jemerov
2016-01-07 18:14:31 +01:00
parent 6684dff14b
commit 33ef7ad024
28 changed files with 250 additions and 255 deletions
@@ -22,17 +22,17 @@ import com.intellij.openapi.components.ApplicationComponent
import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.extensions.PluginId import com.intellij.openapi.extensions.PluginId
public class BareJpsPluginRegistrar : ApplicationComponent { class BareJpsPluginRegistrar : ApplicationComponent {
override fun initComponent() { override fun initComponent() {
val mainKotlinPlugin = PluginManager.getPlugin(PluginId.getId("org.jetbrains.kotlin")) val mainKotlinPlugin = PluginManager.getPlugin(PluginId.getId("org.jetbrains.kotlin"))
if (mainKotlinPlugin != null && mainKotlinPlugin.isEnabled()) { if (mainKotlinPlugin != null && mainKotlinPlugin.isEnabled) {
// do nothing // do nothing
} }
else { else {
val compileServerPlugin = CompileServerPlugin() val compileServerPlugin = CompileServerPlugin()
compileServerPlugin.setClasspath("jps/kotlin-jps-plugin.jar;kotlin-runtime.jar;kotlin-reflect.jar;kotlin-bare-plugin.jar") compileServerPlugin.classpath = "jps/kotlin-jps-plugin.jar;kotlin-runtime.jar;kotlin-reflect.jar;kotlin-bare-plugin.jar"
compileServerPlugin.setPluginDescriptor(PluginManager.getPlugin(PluginId.getId("org.jetbrains.kotlin.bare"))) compileServerPlugin.pluginDescriptor = PluginManager.getPlugin(PluginId.getId("org.jetbrains.kotlin.bare"))
Extensions.getRootArea() Extensions.getRootArea()
.getExtensionPoint(CompileServerPlugin.EP_NAME) .getExtensionPoint(CompileServerPlugin.EP_NAME)
@@ -44,6 +44,6 @@ public class BareJpsPluginRegistrar : ApplicationComponent {
} }
override fun getComponentName(): String { override fun getComponentName(): String {
return javaClass.getName() return javaClass.name
} }
} }
@@ -44,12 +44,12 @@ import java.lang.reflect.Modifier
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
public object KotlinCompilerRunner { object KotlinCompilerRunner {
private val K2JVM_COMPILER = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" private val K2JVM_COMPILER = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
private val K2JS_COMPILER = "org.jetbrains.kotlin.cli.js.K2JSCompiler" private val K2JS_COMPILER = "org.jetbrains.kotlin.cli.js.K2JSCompiler"
private val INTERNAL_ERROR = ExitCode.INTERNAL_ERROR.toString() private val INTERNAL_ERROR = ExitCode.INTERNAL_ERROR.toString()
public fun runK2JvmCompiler( fun runK2JvmCompiler(
commonArguments: CommonCompilerArguments, commonArguments: CommonCompilerArguments,
k2jvmArguments: K2JVMCompilerArguments, k2jvmArguments: K2JVMCompilerArguments,
compilerSettings: CompilerSettings, compilerSettings: CompilerSettings,
@@ -63,7 +63,7 @@ public object KotlinCompilerRunner {
runCompiler(K2JVM_COMPILER, arguments, compilerSettings.additionalArguments, messageCollector, collector, environment) runCompiler(K2JVM_COMPILER, arguments, compilerSettings.additionalArguments, messageCollector, collector, environment)
} }
public fun runK2JsCompiler( fun runK2JsCompiler(
commonArguments: CommonCompilerArguments, commonArguments: CommonCompilerArguments,
k2jsArguments: K2JSCompilerArguments, k2jsArguments: K2JSCompilerArguments,
compilerSettings: CompilerSettings, compilerSettings: CompilerSettings,
@@ -138,7 +138,7 @@ public object KotlinCompilerRunner {
} }
internal class DaemonConnection(public val daemon: CompileService?, public val sessionId: Int = CompileService.NO_SESSION) internal class DaemonConnection(val daemon: CompileService?, val sessionId: Int = CompileService.NO_SESSION)
internal object getDaemonConnection { internal object getDaemonConnection {
private @Volatile var connection: DaemonConnection? = null private @Volatile var connection: DaemonConnection? = null
@@ -37,10 +37,10 @@ object JpsJsModuleUtils {
} }
fun getLibraryFiles(target: ModuleBuildTarget, result: MutableList<String>) { fun getLibraryFiles(target: ModuleBuildTarget, result: MutableList<String>) {
val libraries = JpsUtils.getAllDependencies(target).getLibraries() val libraries = JpsUtils.getAllDependencies(target).libraries
for (library in libraries) { for (library in libraries) {
for (root in library.getRoots(JpsOrderRootType.COMPILED)) { for (root in library.getRoots(JpsOrderRootType.COMPILED)) {
val path = JpsPathUtil.urlToPath(root.getUrl()) val path = JpsPathUtil.urlToPath(root.url)
// ignore files, added only for IDE support (stubs and indexes) // ignore files, added only for IDE support (stubs and indexes)
if (!path.startsWith(KotlinJavascriptMetadataUtils.VFS_PROTOCOL + "://")) { if (!path.startsWith(KotlinJavascriptMetadataUtils.VFS_PROTOCOL + "://")) {
result.add(path) result.add(path)
@@ -52,12 +52,12 @@ object JpsJsModuleUtils {
fun getDependencyModulesAndSources(target: ModuleBuildTarget, result: MutableList<String>) { fun getDependencyModulesAndSources(target: ModuleBuildTarget, result: MutableList<String>) {
JpsUtils.getAllDependencies(target).processModules(object : Consumer<JpsModule> { JpsUtils.getAllDependencies(target).processModules(object : Consumer<JpsModule> {
override fun consume(module: JpsModule) { override fun consume(module: JpsModule) {
if (module == target.getModule() || module.getModuleType() != JpsJavaModuleType.INSTANCE) return if (module == target.module || module.moduleType != JpsJavaModuleType.INSTANCE) return
val moduleBuildTarget = ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION) val moduleBuildTarget = ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)
val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(moduleBuildTarget) val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(moduleBuildTarget)
val metaInfoFile = getOutputMetaFile(outputDir, module.getName()) val metaInfoFile = getOutputMetaFile(outputDir, module.name)
result.add(metaInfoFile.getAbsolutePath()) result.add(metaInfoFile.absolutePath)
} }
}) })
} }
@@ -69,12 +69,11 @@ import org.jetbrains.org.objectweb.asm.ClassReader
import java.io.File import java.io.File
import java.util.* import java.util.*
public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
companion object { companion object {
@JvmField @JvmField val KOTLIN_BUILDER_NAME: String = "Kotlin Builder"
public val KOTLIN_BUILDER_NAME: String = "Kotlin Builder"
public val LOOKUP_TRACKER: JpsElementChildRoleBase<JpsSimpleElement<out LookupTracker>> = JpsElementChildRoleBase.create("lookup tracker") val LOOKUP_TRACKER: JpsElementChildRoleBase<JpsSimpleElement<out LookupTracker>> = JpsElementChildRoleBase.create("lookup tracker")
val LOG = Logger.getInstance("#org.jetbrains.kotlin.jps.build.KotlinBuilder") val LOG = Logger.getInstance("#org.jetbrains.kotlin.jps.build.KotlinBuilder")
} }
@@ -438,7 +437,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
messageCollector.report( messageCollector.report(
INFO, INFO,
"Plugin loaded: ${argumentProvider.javaClass.getSimpleName()}", "Plugin loaded: ${argumentProvider.javaClass.simpleName}",
CompilerMessageLocation.NO_LOCATION CompilerMessageLocation.NO_LOCATION
) )
} }
@@ -455,7 +454,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
.register(IncrementalCompilationComponents::class.java, IncrementalCompilationComponentsImpl(incrementalCaches, lookupTracker)) .register(IncrementalCompilationComponents::class.java, IncrementalCompilationComponentsImpl(incrementalCaches, lookupTracker))
.register(CompilationCanceledStatus::class.java, object : CompilationCanceledStatus { .register(CompilationCanceledStatus::class.java, object : CompilationCanceledStatus {
override fun checkCanceled() { override fun checkCanceled() {
if (context.getCancelStatus().isCanceled()) throw CompilationCanceledException() if (context.cancelStatus.isCanceled) throw CompilationCanceledException()
} }
}) })
.build() .build()
@@ -481,8 +480,8 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
): List<GeneratedFile> { ): List<GeneratedFile> {
// If there's only one target, this map is empty: get() always returns null, and the representativeTarget will be used below // If there's only one target, this map is empty: get() always returns null, and the representativeTarget will be used below
val sourceToTarget = HashMap<File, ModuleBuildTarget>() val sourceToTarget = HashMap<File, ModuleBuildTarget>()
if (chunk.getTargets().size > 1) { if (chunk.targets.size > 1) {
for (target in chunk.getTargets()) { for (target in chunk.targets) {
for (file in KotlinSourceFileCollector.getAllKotlinSourceFiles(target)) { for (file in KotlinSourceFileCollector.getAllKotlinSourceFiles(target)) {
sourceToTarget.put(file, target) sourceToTarget.put(file, target)
} }
@@ -492,7 +491,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val result = ArrayList<GeneratedFile>() val result = ArrayList<GeneratedFile>()
val representativeTarget = chunk.representativeTarget() val representativeTarget = chunk.representativeTarget()
for (outputItem in outputItemCollector.getOutputs()) { for (outputItem in outputItemCollector.outputs) {
val sourceFiles = outputItem.sourceFiles val sourceFiles = outputItem.sourceFiles
val outputFile = outputItem.outputFile val outputFile = outputItem.outputFile
val target = val target =
@@ -500,7 +499,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
chunk.targets.filter { it.outputDir?.let { outputFile.startsWith(it) } ?: false }.singleOrNull() ?: chunk.targets.filter { it.outputDir?.let { outputFile.startsWith(it) } ?: false }.singleOrNull() ?:
representativeTarget representativeTarget
if (outputFile.getName().endsWith(".class")) { if (outputFile.name.endsWith(".class")) {
result.add(GeneratedJvmClass(target, sourceFiles, outputFile)) result.add(GeneratedJvmClass(target, sourceFiles, outputFile))
} }
else { else {
@@ -518,15 +517,15 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
filesToCompile: MultiMap<ModuleBuildTarget, File>, filesToCompile: MultiMap<ModuleBuildTarget, File>,
generatedClasses: List<GeneratedJvmClass> generatedClasses: List<GeneratedJvmClass>
) { ) {
val previousMappings = context.getProjectDescriptor().dataManager.getMappings() val previousMappings = context.projectDescriptor.dataManager.mappings
val delta = previousMappings.createDelta() val delta = previousMappings.createDelta()
val callback = delta.getCallback() val callback = delta.callback
for (generatedClass in generatedClasses) { for (generatedClass in generatedClasses) {
callback.associate( callback.associate(
FileUtil.toSystemIndependentName(generatedClass.outputFile.getAbsolutePath()), FileUtil.toSystemIndependentName(generatedClass.outputFile.absolutePath),
generatedClass.sourceFiles.map { FileUtil.toSystemIndependentName(it.getAbsolutePath()) }, generatedClass.sourceFiles.map { FileUtil.toSystemIndependentName(it.absolutePath) },
ClassReader(generatedClass.outputClass.getFileContents()) ClassReader(generatedClass.outputClass.fileContents)
) )
} }
@@ -537,7 +536,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
private fun registerOutputItems(outputConsumer: ModuleLevelBuilder.OutputConsumer, generatedFiles: List<GeneratedFile>) { private fun registerOutputItems(outputConsumer: ModuleLevelBuilder.OutputConsumer, generatedFiles: List<GeneratedFile>) {
for (generatedFile in generatedFiles) { for (generatedFile in generatedFiles) {
outputConsumer.registerOutputFile(generatedFile.target, generatedFile.outputFile, generatedFile.sourceFiles.map { it.getPath() }) outputConsumer.registerOutputFile(generatedFile.target, generatedFile.outputFile, generatedFile.sourceFiles.map { it.path })
} }
} }
@@ -608,13 +607,13 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val outputItemCollector = OutputItemsCollectorImpl() val outputItemCollector = OutputItemsCollectorImpl()
val representativeTarget = chunk.representativeTarget() val representativeTarget = chunk.representativeTarget()
if (chunk.getModules().size > 1) { if (chunk.modules.size > 1) {
// We do not support circular dependencies, but if they are present, we do our best should not break the build, // We do not support circular dependencies, but if they are present, we do our best should not break the build,
// so we simply yield a warning and report NOTHING_DONE // so we simply yield a warning and report NOTHING_DONE
messageCollector.report( messageCollector.report(
WARNING, WARNING,
"Circular dependencies are not supported. The following JS modules depend on each other: " "Circular dependencies are not supported. The following JS modules depend on each other: "
+ chunk.getModules().map { it.getName() }.joinToString(", ") + ". " + chunk.modules.map { it.name }.joinToString(", ") + ". "
+ "Kotlin is not compiled for these modules", + "Kotlin is not compiled for these modules",
CompilerMessageLocation.NO_LOCATION CompilerMessageLocation.NO_LOCATION
) )
@@ -628,7 +627,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(representativeTarget) val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(representativeTarget)
val moduleName = representativeTarget.getModule().getName() val moduleName = representativeTarget.module.name
val outputFile = JpsJsModuleUtils.getOutputFile(outputDir, moduleName) val outputFile = JpsJsModuleUtils.getOutputFile(outputDir, moduleName)
val libraryFiles = JpsJsModuleUtils.getLibraryFilesAndDependencies(representativeTarget) val libraryFiles = JpsJsModuleUtils.getLibraryFilesAndDependencies(representativeTarget)
val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project) val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project)
@@ -643,7 +642,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(representativeTarget) val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(representativeTarget)
val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project) val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project)
if (compilerSettings.copyJsLibraryFiles) { if (compilerSettings.copyJsLibraryFiles) {
val outputLibraryRuntimeDirectory = File(outputDir, compilerSettings.outputDirectoryForJsLibraryFiles).getAbsolutePath() val outputLibraryRuntimeDirectory = File(outputDir, compilerSettings.outputDirectoryForJsLibraryFiles).absolutePath
val libraryFilesToCopy = arrayListOf<String>() val libraryFilesToCopy = arrayListOf<String>()
JpsJsModuleUtils.getLibraryFiles(representativeTarget, libraryFilesToCopy) JpsJsModuleUtils.getLibraryFiles(representativeTarget, libraryFilesToCopy)
LibraryUtils.copyJsFilesFromLibraries(libraryFilesToCopy, outputLibraryRuntimeDirectory) LibraryUtils.copyJsFilesFromLibraries(libraryFilesToCopy, outputLibraryRuntimeDirectory)
@@ -661,11 +660,11 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
): OutputItemsCollectorImpl? { ): OutputItemsCollectorImpl? {
val outputItemCollector = OutputItemsCollectorImpl() val outputItemCollector = OutputItemsCollectorImpl()
if (chunk.getModules().size > 1) { if (chunk.modules.size > 1) {
messageCollector.report( messageCollector.report(
WARNING, WARNING,
"Circular dependencies are only partially supported. The following modules depend on each other: " "Circular dependencies are only partially supported. The following modules depend on each other: "
+ chunk.getModules().map { it.getName() }.joinToString(", ") + ". " + chunk.modules.map { it.name }.joinToString(", ") + ". "
+ "Kotlin will compile them, but some strange effect may happen", + "Kotlin will compile them, but some strange effect may happen",
CompilerMessageLocation.NO_LOCATION CompilerMessageLocation.NO_LOCATION
) )
@@ -676,7 +675,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val processedTargetsWithRemoved = getProcessedTargetsWithRemovedFilesContainer(context) val processedTargetsWithRemoved = getProcessedTargetsWithRemovedFilesContainer(context)
var totalRemovedFiles = 0 var totalRemovedFiles = 0
for (target in chunk.getTargets()) { for (target in chunk.targets) {
val removedFilesInTarget = KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, target) val removedFilesInTarget = KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, target)
if (!removedFilesInTarget.isEmpty()) { if (!removedFilesInTarget.isEmpty()) {
if (processedTargetsWithRemoved.add(target)) { if (processedTargetsWithRemoved.add(target)) {
@@ -692,7 +691,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
return null return null
} }
val project = context.getProjectDescriptor().getProject() val project = context.projectDescriptor.project
val k2JvmArguments = JpsKotlinCompilerSettings.getK2JvmCompilerArguments(project) val k2JvmArguments = JpsKotlinCompilerSettings.getK2JvmCompilerArguments(project)
val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project) val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project)
@@ -706,7 +705,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
return outputItemCollector return outputItemCollector
} }
public class MessageCollectorAdapter(private val context: CompileContext) : MessageCollector { class MessageCollectorAdapter(private val context: CompileContext) : MessageCollector {
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) { override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
var prefix = "" var prefix = ""
@@ -832,7 +831,7 @@ private fun hasKotlinDirtyOrRemovedFiles(
return chunk.targets.any { KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, it).isNotEmpty() } return chunk.targets.any { KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, it).isNotEmpty() }
} }
public open class GeneratedFile internal constructor( open class GeneratedFile internal constructor(
val target: ModuleBuildTarget, val target: ModuleBuildTarget,
val sourceFiles: Collection<File>, val sourceFiles: Collection<File>,
val outputFile: File val outputFile: File
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.jps.build
import org.jetbrains.jps.incremental.CompileContext import org.jetbrains.jps.incremental.CompileContext
import org.jetbrains.jps.incremental.ModuleBuildTarget import org.jetbrains.jps.incremental.ModuleBuildTarget
public interface KotlinJpsCompilerArgumentsProvider { interface KotlinJpsCompilerArgumentsProvider {
public fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String>
public fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String>
} }
@@ -65,7 +65,7 @@ class TeamcityStatisticsLogger {
private fun printPerChunkStatistics(moduleChunk: ModuleChunk, timeToCompileNs: Long) { private fun printPerChunkStatistics(moduleChunk: ModuleChunk, timeToCompileNs: Long) {
printStatisticMessage( printStatisticMessage(
"${KotlinBuilder.KOTLIN_BUILDER_NAME} for ${moduleChunk.getPresentableShortName()} compilation time, ms", "${KotlinBuilder.KOTLIN_BUILDER_NAME} for ${moduleChunk.presentableShortName} compilation time, ms",
timeToCompileNs.nanosToMillis().toString() timeToCompileNs.nanosToMillis().toString()
) )
} }
@@ -56,7 +56,7 @@ import java.util.*
val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin" val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin"
public class IncrementalCacheImpl( class IncrementalCacheImpl(
private val target: ModuleBuildTarget, private val target: ModuleBuildTarget,
paths: BuildDataPaths paths: BuildDataPaths
) : BasicMapsOwner(), IncrementalCache { ) : BasicMapsOwner(), IncrementalCache {
@@ -112,11 +112,11 @@ public class IncrementalCacheImpl(
inlinedTo.add(fromPath, jvmSignature, toPath) inlinedTo.add(fromPath, jvmSignature, toPath)
} }
public fun addDependentCache(cache: IncrementalCacheImpl) { fun addDependentCache(cache: IncrementalCacheImpl) {
dependents.add(cache) dependents.add(cache)
} }
public fun markOutputClassesDirty(removedAndCompiledSources: List<File>) { fun markOutputClassesDirty(removedAndCompiledSources: List<File>) {
for (sourceFile in removedAndCompiledSources) { for (sourceFile in removedAndCompiledSources) {
val classes = sourceToClassesMap[sourceFile] val classes = sourceToClassesMap[sourceFile]
classes.forEach { classes.forEach {
@@ -127,7 +127,7 @@ public class IncrementalCacheImpl(
} }
} }
public fun getFilesToReinline(): Collection<File> { fun getFilesToReinline(): Collection<File> {
val result = THashSet(FileUtil.PATH_HASHING_STRATEGY) val result = THashSet(FileUtil.PATH_HASHING_STRATEGY)
for ((className, functions) in dirtyInlineFunctionsMap.getEntries()) { for ((className, functions) in dirtyInlineFunctionsMap.getEntries()) {
@@ -142,7 +142,7 @@ public class IncrementalCacheImpl(
return result.map { File(it) } return result.map { File(it) }
} }
public fun cleanDirtyInlineFunctions() { fun cleanDirtyInlineFunctions() {
dirtyInlineFunctionsMap.clean() dirtyInlineFunctionsMap.clean()
} }
@@ -150,7 +150,7 @@ public class IncrementalCacheImpl(
return toSystemIndependentName(File(outputDir, "$internalClassName.class").canonicalPath) return toSystemIndependentName(File(outputDir, "$internalClassName.class").canonicalPath)
} }
public fun saveModuleMappingToCache(sourceFiles: Collection<File>, file: File): CompilationResult { fun saveModuleMappingToCache(sourceFiles: Collection<File>, file: File): CompilationResult {
val jvmClassName = JvmClassName.byInternalName(MODULE_MAPPING_FILE_NAME) val jvmClassName = JvmClassName.byInternalName(MODULE_MAPPING_FILE_NAME)
protoMap.process(jvmClassName, file.readBytes(), emptyArray<String>(), isPackage = false, checkChangesIsOpenPart = false) protoMap.process(jvmClassName, file.readBytes(), emptyArray<String>(), isPackage = false, checkChangesIsOpenPart = false)
dirtyOutputClassesMap.notDirty(MODULE_MAPPING_FILE_NAME) dirtyOutputClassesMap.notDirty(MODULE_MAPPING_FILE_NAME)
@@ -158,7 +158,7 @@ public class IncrementalCacheImpl(
return CompilationResult.NO_CHANGES return CompilationResult.NO_CHANGES
} }
public fun saveFileToCache(generatedClass: GeneratedJvmClass): CompilationResult { fun saveFileToCache(generatedClass: GeneratedJvmClass): CompilationResult {
val sourceFiles: Collection<File> = generatedClass.sourceFiles val sourceFiles: Collection<File> = generatedClass.sourceFiles
val kotlinClass: LocalFileKotlinClass = generatedClass.outputClass val kotlinClass: LocalFileKotlinClass = generatedClass.outputClass
val className = kotlinClass.className val className = kotlinClass.className
@@ -216,7 +216,7 @@ public class IncrementalCacheImpl(
KotlinBuilder.LOG.debug("$className is changed: $this") KotlinBuilder.LOG.debug("$className is changed: $this")
} }
public fun clearCacheForRemovedClasses(): CompilationResult { fun clearCacheForRemovedClasses(): CompilationResult {
fun <T> T.getNonPrivateNames(nameResolver: NameResolver, vararg members: T.() -> List<MessageLite>): Set<String> = fun <T> T.getNonPrivateNames(nameResolver: NameResolver, vararg members: T.() -> List<MessageLite>): Set<String> =
members.flatMap { this.it().filterNot { it.isPrivate }.names(nameResolver) }.toSet() members.flatMap { this.it().filterNot { it.isPrivate }.names(nameResolver) }.toSet()
@@ -324,26 +324,26 @@ public class IncrementalCacheImpl(
return protoMap[JvmClassName.byInternalName(MODULE_MAPPING_FILE_NAME)]?.bytes return protoMap[JvmClassName.byInternalName(MODULE_MAPPING_FILE_NAME)]?.bytes
} }
public override fun clean() { override fun clean() {
super.clean() super.clean()
cacheVersionProvider.normalVersion(target).clean() cacheVersionProvider.normalVersion(target).clean()
cacheVersionProvider.experimentalVersion(target).clean() cacheVersionProvider.experimentalVersion(target).clean()
} }
public fun cleanExperimental() { fun cleanExperimental() {
cacheVersionProvider.experimentalVersion(target).clean() cacheVersionProvider.experimentalVersion(target).clean()
experimentalMaps.forEach { it.clean() } experimentalMaps.forEach { it.clean() }
} }
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) { private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
public fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult { fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult {
val header = kotlinClass.classHeader val header = kotlinClass.classHeader
val bytes = BitEncoding.decodeBytes(header.annotationData!!) val bytes = BitEncoding.decodeBytes(header.annotationData!!)
return put(kotlinClass.className, bytes, header.strings!!, isPackage, checkChangesIsOpenPart = true) return put(kotlinClass.className, bytes, header.strings!!, isPackage, checkChangesIsOpenPart = true)
} }
public fun process(className: JvmClassName, data: ByteArray, strings: Array<String>, isPackage: Boolean, checkChangesIsOpenPart: Boolean): CompilationResult { fun process(className: JvmClassName, data: ByteArray, strings: Array<String>, isPackage: Boolean, checkChangesIsOpenPart: Boolean): CompilationResult {
return put(className, data, strings, isPackage, checkChangesIsOpenPart) return put(className, data, strings, isPackage, checkChangesIsOpenPart)
} }
@@ -386,7 +386,7 @@ public class IncrementalCacheImpl(
operator fun get(className: JvmClassName): ProtoMapValue? = operator fun get(className: JvmClassName): ProtoMapValue? =
storage[className.internalName] storage[className.internalName]
public fun remove(className: JvmClassName) { fun remove(className: JvmClassName) {
storage.remove(className.internalName) storage.remove(className.internalName)
} }
@@ -415,12 +415,12 @@ public class IncrementalCacheImpl(
operator fun contains(className: JvmClassName): Boolean = operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage className.internalName in storage
public fun process(kotlinClass: LocalFileKotlinClass): CompilationResult { fun process(kotlinClass: LocalFileKotlinClass): CompilationResult {
return put(kotlinClass.className, getConstantsMap(kotlinClass.fileContents)) return put(kotlinClass.className, getConstantsMap(kotlinClass.fileContents))
} }
private fun put(className: JvmClassName, constantsMap: Map<String, Any>?): CompilationResult { private fun put(className: JvmClassName, constantsMap: Map<String, Any>?): CompilationResult {
val key = className.getInternalName() val key = className.internalName
val oldMap = storage[key] val oldMap = storage[key]
if (oldMap == constantsMap) return CompilationResult.NO_CHANGES if (oldMap == constantsMap) return CompilationResult.NO_CHANGES
@@ -435,7 +435,7 @@ public class IncrementalCacheImpl(
return CompilationResult(constantsChanged = true) return CompilationResult(constantsChanged = true)
} }
public fun remove(className: JvmClassName) { fun remove(className: JvmClassName) {
put(className, null) put(className, null)
} }
@@ -471,7 +471,7 @@ public class IncrementalCacheImpl(
return result return result
} }
public fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult { fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult {
return put(kotlinClass.className, getInlineFunctionsMap(kotlinClass.fileContents), isPackage) return put(kotlinClass.className, getInlineFunctionsMap(kotlinClass.fileContents), isPackage)
} }
@@ -517,7 +517,7 @@ public class IncrementalCacheImpl(
changes = changes) changes = changes)
} }
public fun remove(className: JvmClassName) { fun remove(className: JvmClassName) {
storage.remove(className.internalName) storage.remove(className.internalName)
} }
@@ -526,28 +526,28 @@ public class IncrementalCacheImpl(
} }
private inner class PackagePartMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) { private inner class PackagePartMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
public fun addPackagePart(className: JvmClassName) { fun addPackagePart(className: JvmClassName) {
storage[className.internalName] = true storage[className.internalName] = true
} }
public fun remove(className: JvmClassName) { fun remove(className: JvmClassName) {
storage.remove(className.internalName) storage.remove(className.internalName)
} }
public fun isPackagePart(className: JvmClassName): Boolean = fun isPackagePart(className: JvmClassName): Boolean =
className.internalName in storage className.internalName in storage
override fun dumpValue(value: Boolean) = "" override fun dumpValue(value: Boolean) = ""
} }
private inner class MultifileClassFacadeMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) { private inner class MultifileClassFacadeMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
public fun add(facadeName: JvmClassName, partNames: Collection<String>) { fun add(facadeName: JvmClassName, partNames: Collection<String>) {
storage[facadeName.internalName] = partNames storage[facadeName.internalName] = partNames
} }
public fun getMultifileClassParts(facadeName: String): Collection<String>? = storage[facadeName] fun getMultifileClassParts(facadeName: String): Collection<String>? = storage[facadeName]
public fun remove(className: JvmClassName) { fun remove(className: JvmClassName) {
storage.remove(className.internalName) storage.remove(className.internalName)
} }
@@ -555,15 +555,15 @@ public class IncrementalCacheImpl(
} }
private inner class MultifileClassPartMap(storageFile: File) : BasicStringMap<String>(storageFile, EnumeratorStringDescriptor.INSTANCE) { private inner class MultifileClassPartMap(storageFile: File) : BasicStringMap<String>(storageFile, EnumeratorStringDescriptor.INSTANCE) {
public fun add(partName: String, facadeName: String) { fun add(partName: String, facadeName: String) {
storage[partName] = facadeName storage[partName] = facadeName
} }
public fun getFacadeName(partName: String): String? { fun getFacadeName(partName: String): String? {
return storage.get(partName) return storage.get(partName)
} }
public fun remove(className: JvmClassName) { fun remove(className: JvmClassName) {
storage.remove(className.internalName) storage.remove(className.internalName)
} }
@@ -571,15 +571,15 @@ public class IncrementalCacheImpl(
} }
private inner class SourceToClassesMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor.INSTANCE, StringCollectionExternalizer) { private inner class SourceToClassesMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor.INSTANCE, StringCollectionExternalizer) {
public fun clearOutputsForSource(sourceFile: File) { fun clearOutputsForSource(sourceFile: File) {
remove(sourceFile.absolutePath) remove(sourceFile.absolutePath)
} }
public fun add(sourceFile: File, className: JvmClassName) { fun add(sourceFile: File, className: JvmClassName) {
storage.append(sourceFile.absolutePath, { out -> IOUtil.writeUTF(out, className.internalName) }) storage.append(sourceFile.absolutePath, { out -> IOUtil.writeUTF(out, className.internalName) })
} }
public operator fun get(sourceFile: File): Collection<JvmClassName> = operator 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: Collection<String>) = value.dumpCollection() override fun dumpValue(value: Collection<String>) = value.dumpCollection()
@@ -634,28 +634,28 @@ public class IncrementalCacheImpl(
} }
private inner class DirtyOutputClassesMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) { private inner class DirtyOutputClassesMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
public fun markDirty(className: String) { fun markDirty(className: String) {
storage[className] = true storage[className] = true
} }
public fun notDirty(className: String) { fun notDirty(className: String) {
storage.remove(className) storage.remove(className)
} }
public fun getDirtyOutputClasses(): Collection<String> = fun getDirtyOutputClasses(): Collection<String> =
storage.keys storage.keys
public fun isDirty(className: String): Boolean = fun isDirty(className: String): Boolean =
storage.contains(className) storage.contains(className)
override fun dumpValue(value: Boolean) = "" override fun dumpValue(value: Boolean) = ""
} }
private inner class DirtyInlineFunctionsMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) { private inner class DirtyInlineFunctionsMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
public fun getEntries(): Map<JvmClassName, Collection<String>> = fun getEntries(): Map<JvmClassName, Collection<String>> =
storage.keys.toMapBy(JvmClassName::byInternalName) { storage[it]!! } storage.keys.toMapBy(JvmClassName::byInternalName) { storage[it]!! }
public fun put(className: JvmClassName, changedFunctions: List<String>) { fun put(className: JvmClassName, changedFunctions: List<String>) {
storage[className.internalName] = changedFunctions storage[className.internalName] = changedFunctions
} }
@@ -672,14 +672,14 @@ public class IncrementalCacheImpl(
* * target files - collection of files inlineFunction has been inlined to * * target files - collection of files inlineFunction has been inlined to
*/ */
private inner class InlineFunctionsFilesMap(storageFile: File) : BasicMap<PathFunctionPair, Collection<String>>(storageFile, PathFunctionPairKeyDescriptor, PathCollectionExternalizer) { private inner class InlineFunctionsFilesMap(storageFile: File) : BasicMap<PathFunctionPair, Collection<String>>(storageFile, PathFunctionPairKeyDescriptor, PathCollectionExternalizer) {
public fun add(sourcePath: String, jvmSignature: String, targetPath: String) { fun add(sourcePath: String, jvmSignature: String, targetPath: String) {
val key = PathFunctionPair(sourcePath, jvmSignature) val key = PathFunctionPair(sourcePath, jvmSignature)
storage.append(key) { out -> storage.append(key) { out ->
IOUtil.writeUTF(out, targetPath) IOUtil.writeUTF(out, targetPath)
} }
} }
public operator fun get(sourcePath: String, jvmSignature: String): Collection<String> { operator fun get(sourcePath: String, jvmSignature: String): Collection<String> {
val key = PathFunctionPair(sourcePath, jvmSignature) val key = PathFunctionPair(sourcePath, jvmSignature)
return storage[key] ?: emptySet() return storage[key] ?: emptySet()
} }
@@ -717,7 +717,7 @@ data class CompilationResult(
val changes: Sequence<ChangeInfo> = emptySequence() val changes: Sequence<ChangeInfo> = emptySequence()
) { ) {
companion object { companion object {
public val NO_CHANGES: CompilationResult = CompilationResult() val NO_CHANGES: CompilationResult = CompilationResult()
} }
operator fun plus(other: CompilationResult): CompilationResult = operator fun plus(other: CompilationResult): CompilationResult =
@@ -772,6 +772,5 @@ private fun <K : Comparable<K>, V> Map<K, V>.dumpMap(dumpValue: (V)->String): St
append("}") append("}")
} }
@TestOnly @TestOnly fun <T : Comparable<T>> Collection<T>.dumpCollection(): String =
public fun <T : Comparable<T>> Collection<T>.dumpCollection(): String =
"[${sorted().joinToString(", ", transform = Any::toString)}]" "[${sorted().joinToString(", ", transform = Any::toString)}]"
@@ -22,7 +22,7 @@ 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.TargetId import org.jetbrains.kotlin.modules.TargetId
public class IncrementalCompilationComponentsImpl( class IncrementalCompilationComponentsImpl(
caches: Map<ModuleBuildTarget, IncrementalCache>, caches: Map<ModuleBuildTarget, IncrementalCache>,
private val lookupTracker: LookupTracker private val lookupTracker: LookupTracker
): IncrementalCompilationComponents { ): IncrementalCompilationComponents {
@@ -40,7 +40,7 @@ class LocalFileKotlinClass private constructor(
} }
} }
public val className: JvmClassName by lazy { JvmClassName.byClassId(classId) } val className: JvmClassName by lazy { JvmClassName.byClassId(classId) }
override fun getLocation(): String = file.absolutePath override fun getLocation(): String = file.absolutePath
@@ -65,14 +65,14 @@ class LookupStorage(private val targetDataDir: File) : BasicMapsOwner() {
} }
} }
public fun add(lookupSymbol: LookupSymbol, containingPaths: Collection<String>) { fun add(lookupSymbol: LookupSymbol, containingPaths: Collection<String>) {
val key = LookupSymbolKey(lookupSymbol.name, lookupSymbol.scope) val key = LookupSymbolKey(lookupSymbol.name, lookupSymbol.scope)
val fileIds = containingPaths.map { addFileIfNeeded(File(it)) }.toHashSet() val fileIds = containingPaths.map { addFileIfNeeded(File(it)) }.toHashSet()
fileIds.addAll(lookupMap[key] ?: emptySet()) fileIds.addAll(lookupMap[key] ?: emptySet())
lookupMap[key] = fileIds lookupMap[key] = fileIds
} }
public fun removeLookupsFrom(file: File) { fun removeLookupsFrom(file: File) {
val id = fileToId[file] ?: return val id = fileToId[file] ?: return
idToFile.remove(id) idToFile.remove(id)
fileToId.remove(file) fileToId.remove(file)
@@ -149,14 +149,12 @@ class LookupStorage(private val targetDataDir: File) : BasicMapsOwner() {
} }
} }
@TestOnly @TestOnly fun forceGC() {
public fun forceGC() {
removeGarbageIfNeeded(force = true) removeGarbageIfNeeded(force = true)
flush(false) flush(false)
} }
@TestOnly @TestOnly fun dump(lookupSymbols: Set<LookupSymbol>): String {
public fun dump(lookupSymbols: Set<LookupSymbol>): String {
flush(false) flush(false)
val sb = StringBuilder() val sb = StringBuilder()
@@ -25,12 +25,12 @@ import java.util.*
/** This file is generated by org.jetbrains.kotlin.generators.protobuf.GenerateProtoBufCompare. DO NOT MODIFY MANUALLY */ /** This file is generated by org.jetbrains.kotlin.generators.protobuf.GenerateProtoBufCompare. DO NOT MODIFY MANUALLY */
open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, public val newNameResolver: NameResolver) { open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameResolver: NameResolver) {
private val strings = Interner<String>() private val strings = Interner<String>()
public val oldStringIndexesMap: MutableMap<Int, Int> = hashMapOf() val oldStringIndexesMap: MutableMap<Int, Int> = hashMapOf()
public val newStringIndexesMap: MutableMap<Int, Int> = hashMapOf() val newStringIndexesMap: MutableMap<Int, Int> = hashMapOf()
public val oldClassIdIndexesMap: MutableMap<Int, Int> = hashMapOf() val oldClassIdIndexesMap: MutableMap<Int, Int> = hashMapOf()
public val newClassIdIndexesMap: MutableMap<Int, Int> = hashMapOf() val newClassIdIndexesMap: MutableMap<Int, Int> = hashMapOf()
private val classIds = Interner<ClassId>() private val classIds = Interner<ClassId>()
@@ -46,13 +46,13 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
return true return true
} }
public enum class ProtoBufPackageKind { enum class ProtoBufPackageKind {
FUNCTION_LIST, FUNCTION_LIST,
PROPERTY_LIST, PROPERTY_LIST,
TYPE_TABLE TYPE_TABLE
} }
public fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> { fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> {
val result = EnumSet.noneOf(ProtoBufPackageKind::class.java) val result = EnumSet.noneOf(ProtoBufPackageKind::class.java)
if (!checkEqualsPackageFunction(old, new)) result.add(ProtoBufPackageKind.FUNCTION_LIST) if (!checkEqualsPackageFunction(old, new)) result.add(ProtoBufPackageKind.FUNCTION_LIST)
@@ -109,7 +109,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
return true return true
} }
public enum class ProtoBufClassKind { enum class ProtoBufClassKind {
FLAGS, FLAGS,
FQ_NAME, FQ_NAME,
COMPANION_OBJECT_NAME, COMPANION_OBJECT_NAME,
@@ -125,7 +125,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
CLASS_ANNOTATION_LIST CLASS_ANNOTATION_LIST
} }
public fun difference(old: ProtoBuf.Class, new: ProtoBuf.Class): EnumSet<ProtoBufClassKind> { fun difference(old: ProtoBuf.Class, new: ProtoBuf.Class): EnumSet<ProtoBufClassKind> {
val result = EnumSet.noneOf(ProtoBufClassKind::class.java) val result = EnumSet.noneOf(ProtoBufClassKind::class.java)
if (old.hasFlags() != new.hasFlags()) result.add(ProtoBufClassKind.FLAGS) if (old.hasFlags() != new.hasFlags()) result.add(ProtoBufClassKind.FLAGS)
@@ -758,10 +758,10 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
return true return true
} }
public fun oldGetIndexOfString(index: Int): Int = getIndexOfString(index, oldStringIndexesMap, oldNameResolver) fun oldGetIndexOfString(index: Int): Int = getIndexOfString(index, oldStringIndexesMap, oldNameResolver)
public fun newGetIndexOfString(index: Int): Int = getIndexOfString(index, newStringIndexesMap, newNameResolver) fun newGetIndexOfString(index: Int): Int = getIndexOfString(index, newStringIndexesMap, newNameResolver)
public fun getIndexOfString(index: Int, map: MutableMap<Int, Int>, nameResolver: NameResolver): Int { fun getIndexOfString(index: Int, map: MutableMap<Int, Int>, nameResolver: NameResolver): Int {
map[index]?.let { return it } map[index]?.let { return it }
val result = strings.intern(nameResolver.getString(index)) val result = strings.intern(nameResolver.getString(index))
@@ -769,10 +769,10 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
return result return result
} }
public fun oldGetIndexOfClassId(index: Int): Int = getIndexOfClassId(index, oldClassIdIndexesMap, oldNameResolver) fun oldGetIndexOfClassId(index: Int): Int = getIndexOfClassId(index, oldClassIdIndexesMap, oldNameResolver)
public fun newGetIndexOfClassId(index: Int): Int = getIndexOfClassId(index, newClassIdIndexesMap, newNameResolver) fun newGetIndexOfClassId(index: Int): Int = getIndexOfClassId(index, newClassIdIndexesMap, newNameResolver)
public fun getIndexOfClassId(index: Int, map: MutableMap<Int, Int>, nameResolver: NameResolver): Int { fun getIndexOfClassId(index: Int, map: MutableMap<Int, Int>, nameResolver: NameResolver): Int {
map[index]?.let { return it } map[index]?.let { return it }
val result = classIds.intern(nameResolver.getClassId(index)) val result = classIds.intern(nameResolver.getClassId(index))
@@ -789,7 +789,7 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
} }
} }
public fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
for(i in 0..functionCount - 1) { for(i in 0..functionCount - 1) {
@@ -807,7 +807,7 @@ public fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes:
return hashCode return hashCode
} }
public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasFlags()) { if (hasFlags()) {
@@ -863,7 +863,7 @@ public fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (
return hashCode return hashCode
} }
public fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasFlags()) { if (hasFlags()) {
@@ -907,7 +907,7 @@ public fun ProtoBuf.Function.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes
return hashCode return hashCode
} }
public fun ProtoBuf.Property.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Property.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasFlags()) { if (hasFlags()) {
@@ -955,7 +955,7 @@ public fun ProtoBuf.Property.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes
return hashCode return hashCode
} }
public fun ProtoBuf.TypeTable.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.TypeTable.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
for(i in 0..typeCount - 1) { for(i in 0..typeCount - 1) {
@@ -969,7 +969,7 @@ public fun ProtoBuf.TypeTable.hashCode(stringIndexes: (Int) -> Int, fqNameIndexe
return hashCode return hashCode
} }
public fun ProtoBuf.TypeParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.TypeParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
hashCode = 31 * hashCode + id hashCode = 31 * hashCode + id
@@ -999,7 +999,7 @@ public fun ProtoBuf.TypeParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIn
return hashCode return hashCode
} }
public fun ProtoBuf.Type.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Type.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
for(i in 0..argumentCount - 1) { for(i in 0..argumentCount - 1) {
@@ -1053,7 +1053,7 @@ public fun ProtoBuf.Type.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (I
return hashCode return hashCode
} }
public fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasFlags()) { if (hasFlags()) {
@@ -1071,7 +1071,7 @@ public fun ProtoBuf.Constructor.hashCode(stringIndexes: (Int) -> Int, fqNameInde
return hashCode return hashCode
} }
public fun ProtoBuf.EnumEntry.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.EnumEntry.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasName()) { if (hasName()) {
@@ -1081,7 +1081,7 @@ public fun ProtoBuf.EnumEntry.hashCode(stringIndexes: (Int) -> Int, fqNameIndexe
return hashCode return hashCode
} }
public fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
hashCode = 31 * hashCode + fqNameIndexes(id) hashCode = 31 * hashCode + fqNameIndexes(id)
@@ -1093,7 +1093,7 @@ public fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndex
return hashCode return hashCode
} }
public fun ProtoBuf.ValueParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.ValueParameter.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasFlags()) { if (hasFlags()) {
@@ -1121,7 +1121,7 @@ public fun ProtoBuf.ValueParameter.hashCode(stringIndexes: (Int) -> Int, fqNameI
return hashCode return hashCode
} }
public fun JvmProtoBuf.JvmMethodSignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun JvmProtoBuf.JvmMethodSignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasName()) { if (hasName()) {
@@ -1135,7 +1135,7 @@ public fun JvmProtoBuf.JvmMethodSignature.hashCode(stringIndexes: (Int) -> Int,
return hashCode return hashCode
} }
public fun JvmProtoBuf.JvmPropertySignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun JvmProtoBuf.JvmPropertySignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasField()) { if (hasField()) {
@@ -1157,7 +1157,7 @@ public fun JvmProtoBuf.JvmPropertySignature.hashCode(stringIndexes: (Int) -> Int
return hashCode return hashCode
} }
public fun ProtoBuf.Type.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Type.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasProjection()) { if (hasProjection()) {
@@ -1175,7 +1175,7 @@ public fun ProtoBuf.Type.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIn
return hashCode return hashCode
} }
public fun ProtoBuf.Annotation.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Annotation.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
hashCode = 31 * hashCode + stringIndexes(nameId) hashCode = 31 * hashCode + stringIndexes(nameId)
@@ -1185,7 +1185,7 @@ public fun ProtoBuf.Annotation.Argument.hashCode(stringIndexes: (Int) -> Int, fq
return hashCode return hashCode
} }
public fun JvmProtoBuf.JvmFieldSignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun JvmProtoBuf.JvmFieldSignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasName()) { if (hasName()) {
@@ -1199,7 +1199,7 @@ public fun JvmProtoBuf.JvmFieldSignature.hashCode(stringIndexes: (Int) -> Int, f
return hashCode return hashCode
} }
public fun ProtoBuf.Annotation.Argument.Value.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int { fun ProtoBuf.Annotation.Argument.Value.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1 var hashCode = 1
if (hasType()) { if (hasType()) {
@@ -29,13 +29,13 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
import org.jetbrains.kotlin.utils.HashSetUtil import org.jetbrains.kotlin.utils.HashSetUtil
import java.util.* import java.util.*
public sealed class DifferenceKind() { sealed class DifferenceKind() {
public object NONE: DifferenceKind() object NONE: DifferenceKind()
public object CLASS_SIGNATURE: DifferenceKind() object CLASS_SIGNATURE: DifferenceKind()
public class MEMBERS(val names: Collection<String>): DifferenceKind() class MEMBERS(val names: Collection<String>): DifferenceKind()
} }
public fun difference(oldData: ProtoMapValue, newData: ProtoMapValue): DifferenceKind { fun difference(oldData: ProtoMapValue, newData: ProtoMapValue): DifferenceKind {
if (oldData.isPackageFacade != newData.isPackageFacade) return DifferenceKind.CLASS_SIGNATURE if (oldData.isPackageFacade != newData.isPackageFacade) return DifferenceKind.CLASS_SIGNATURE
val differenceObject = val differenceObject =
@@ -72,7 +72,7 @@ internal abstract class BasicStringMap<V>(
keyDescriptor: KeyDescriptor<String>, keyDescriptor: KeyDescriptor<String>,
valueExternalizer: DataExternalizer<V> valueExternalizer: DataExternalizer<V>
) : BasicMap<String, V>(storageFile, keyDescriptor, valueExternalizer) { ) : BasicMap<String, V>(storageFile, keyDescriptor, valueExternalizer) {
public constructor( constructor(
storageFile: File, storageFile: File,
valueExternalizer: DataExternalizer<V> valueExternalizer: DataExternalizer<V>
) : this(storageFile, EnumeratorStringDescriptor.INSTANCE, valueExternalizer) ) : this(storageFile, EnumeratorStringDescriptor.INSTANCE, valueExternalizer)
@@ -43,6 +43,5 @@ open class BasicMapsOwner : StorageOwner {
maps.forEach { it.flush(memoryCachesOnly) } maps.forEach { it.flush(memoryCachesOnly) }
} }
@TestOnly @TestOnly fun dump(): String = maps.map { it.dump() }.joinToString("\n\n")
public fun dump(): String = maps.map { it.dump() }.joinToString("\n\n")
} }
@@ -24,15 +24,15 @@ internal class FileToIdMap(file: File) : BasicMap<File, Int>(file, FileKeyDescri
override fun dumpValue(value: Int): String = value.toString() override fun dumpValue(value: Int): String = value.toString()
public operator fun get(file: File): Int? = storage[file] operator fun get(file: File): Int? = storage[file]
public operator fun set(file: File, id: Int) { operator fun set(file: File, id: Int) {
storage[file] = id storage[file] = id
} }
public fun remove(file: File) { fun remove(file: File) {
storage.remove(file) storage.remove(file)
} }
public fun toMap(): Map<File, Int> = storage.keys.keysToMap { storage[it]!! } fun toMap(): Map<File, Int> = storage.keys.keysToMap { storage[it]!! }
} }
@@ -24,15 +24,15 @@ internal class IdToFileMap(file: File) : BasicMap<Int, File>(file, ExternalInteg
override fun dumpValue(value: File): String = value.toString() override fun dumpValue(value: File): String = value.toString()
public operator fun get(id: Int): File? = storage[id] operator fun get(id: Int): File? = storage[id]
public operator fun contains(id: Int): Boolean = id in storage operator fun contains(id: Int): Boolean = id in storage
public operator fun set(id: Int, file: File) { operator fun set(id: Int, file: File) {
storage[id] = file storage[id] = file
} }
public fun remove(id: Int) { fun remove(id: Int) {
storage.remove(id) storage.remove(id)
} }
} }
@@ -23,20 +23,20 @@ internal class LookupMap(storage: File) : BasicMap<LookupSymbolKey, Collection<I
override fun dumpValue(value: Collection<Int>): String = value.toString() override fun dumpValue(value: Collection<Int>): String = value.toString()
public fun add(name: String, scope: String, fileId: Int) { fun add(name: String, scope: String, fileId: Int) {
storage.append(LookupSymbolKey(name, scope)) { out -> out.writeInt(fileId) } storage.append(LookupSymbolKey(name, scope)) { out -> out.writeInt(fileId) }
} }
public operator fun get(key: LookupSymbolKey): Collection<Int>? = storage[key] operator fun get(key: LookupSymbolKey): Collection<Int>? = storage[key]
public operator fun set(key: LookupSymbolKey, fileIds: Set<Int>) { operator fun set(key: LookupSymbolKey, fileIds: Set<Int>) {
storage[key] = fileIds storage[key] = fileIds
} }
public fun remove(key: LookupSymbolKey) { fun remove(key: LookupSymbolKey) {
storage.remove(key) storage.remove(key)
} }
public val keys: Collection<LookupSymbolKey> val keys: Collection<LookupSymbolKey>
get() = storage.keys get() = storage.keys
} }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.jps.incremental.storage
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
data class LookupSymbolKey(val nameHash: Int, val scopeHash: Int) : Comparable<LookupSymbolKey> { data class LookupSymbolKey(val nameHash: Int, val scopeHash: Int) : Comparable<LookupSymbolKey> {
public constructor(name: String, scope: String) : this(name.hashCode(), scope.hashCode()) constructor(name: String, scope: String) : this(name.hashCode(), scope.hashCode())
override fun compareTo(other: LookupSymbolKey): Int { override fun compareTo(other: LookupSymbolKey): Int {
val nameCmp = nameHash.compareTo(other.nameHash) val nameCmp = nameHash.compareTo(other.nameHash)
@@ -31,8 +31,8 @@ data class LookupSymbolKey(val nameHash: Int, val scopeHash: Int) : Comparable<L
} }
class PathFunctionPair( class PathFunctionPair(
public val path: String, val path: String,
public val function: String val function: String
): Comparable<PathFunctionPair> { ): Comparable<PathFunctionPair> {
override fun compareTo(other: PathFunctionPair): Int { override fun compareTo(other: PathFunctionPair): Int {
val pathComp = FileUtil.comparePaths(path, other.path) val pathComp = FileUtil.comparePaths(path, other.path)
@@ -18,5 +18,5 @@ package org.jetbrains.kotlin.modules
import org.jetbrains.jps.incremental.ModuleBuildTarget import org.jetbrains.jps.incremental.ModuleBuildTarget
public fun TargetId(moduleBuildTarget: ModuleBuildTarget): TargetId = fun TargetId(moduleBuildTarget: ModuleBuildTarget): TargetId =
TargetId(moduleBuildTarget.id, moduleBuildTarget.targetType.typeId) TargetId(moduleBuildTarget.id, moduleBuildTarget.targetType.typeId)
@@ -62,7 +62,7 @@ import kotlin.properties.Delegates
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFalse import kotlin.test.assertFalse
public abstract class AbstractIncrementalJpsTest( abstract class AbstractIncrementalJpsTest(
private val allowNoFilesWithSuffixInTestData: Boolean = false, private val allowNoFilesWithSuffixInTestData: Boolean = false,
private val checkDumpsCaseInsensitively: Boolean = false, private val checkDumpsCaseInsensitively: Boolean = false,
private val allowNoBuildLogFileInTestData: Boolean = false private val allowNoBuildLogFileInTestData: Boolean = false
@@ -230,7 +230,7 @@ public abstract class AbstractIncrementalJpsTest(
val modifications = ArrayList<Modification>() val modifications = ArrayList<Modification>()
for (file in testDataDir.listFiles()!!) { for (file in testDataDir.listFiles()!!) {
val fileName = file.getName() val fileName = file.name
if (fileName.endsWith(newSuffix)) { if (fileName.endsWith(newSuffix)) {
modifications.add(ModifyContent(getDirPrefix(fileName) + "/" + fileName.removeSuffix(newSuffix), file)) modifications.add(ModifyContent(getDirPrefix(fileName) + "/" + fileName.removeSuffix(newSuffix), file))
@@ -245,8 +245,8 @@ public abstract class AbstractIncrementalJpsTest(
return modifications return modifications
} }
val haveFilesWithoutNumbers = testDataDir.listFiles { it -> it.getName().matches(".+\\.($COMMANDS_AS_REGEX_PART)$".toRegex()) }?.isNotEmpty() ?: false val haveFilesWithoutNumbers = testDataDir.listFiles { it -> it.name.matches(".+\\.($COMMANDS_AS_REGEX_PART)$".toRegex()) }?.isNotEmpty() ?: false
val haveFilesWithNumbers = testDataDir.listFiles { it -> it.getName().matches(".+\\.($COMMANDS_AS_REGEX_PART)\\.\\d+$".toRegex()) }?.isNotEmpty() ?: false val haveFilesWithNumbers = testDataDir.listFiles { it -> it.name.matches(".+\\.($COMMANDS_AS_REGEX_PART)\\.\\d+$".toRegex()) }?.isNotEmpty() ?: false
if (haveFilesWithoutNumbers && haveFilesWithNumbers) { if (haveFilesWithoutNumbers && haveFilesWithNumbers) {
fail("Bad test data format: files ending with both unnumbered and numbered $COMMANDS_AS_MESSAGE_PART were found") fail("Bad test data format: files ending with both unnumbered and numbered $COMMANDS_AS_MESSAGE_PART were found")
@@ -512,7 +512,7 @@ public abstract class AbstractIncrementalJpsTest(
// TODO replace with org.jetbrains.jps.builders.TestProjectBuilderLogger // TODO replace with org.jetbrains.jps.builders.TestProjectBuilderLogger
private class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase() { private class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase() {
private val logBuf = StringBuilder() private val logBuf = StringBuilder()
public val log: String val log: String
get() = logBuf.toString() get() = logBuf.toString()
val compiledFiles = hashSetOf<File>() val compiledFiles = hashSetOf<File>()
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.jps.incremental.storage.BasicMapsOwner
import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.Printer
import java.io.File import java.io.File
public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest() { abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest() {
protected open val expectedCachesFileName: String protected open val expectedCachesFileName: String
get() = "expected-kotlin-caches.txt" get() = "expected-kotlin-caches.txt"
@@ -21,7 +21,7 @@ import com.intellij.util.concurrency.FixedFuture
import java.io.File import java.io.File
import java.util.concurrent.Future import java.util.concurrent.Future
public class IncrementalConstantSearchTest : AbstractIncrementalJpsTest() { class IncrementalConstantSearchTest : AbstractIncrementalJpsTest() {
fun testJavaConstantChangedUsedInKotlin() { fun testJavaConstantChangedUsedInKotlin() {
doTest("jps-plugin/testData/incremental/custom/javaConstantChangedUsedInKotlin/") doTest("jps-plugin/testData/incremental/custom/javaConstantChangedUsedInKotlin/")
} }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.jps.build
import com.intellij.openapi.util.SystemInfoRt import com.intellij.openapi.util.SystemInfoRt
import org.jetbrains.jps.model.java.JavaSourceRootType import org.jetbrains.jps.model.java.JavaSourceRootType
public class IncrementalProjectPathCaseChangedTest : AbstractIncrementalJpsTest(checkDumpsCaseInsensitively = true) { class IncrementalProjectPathCaseChangedTest : AbstractIncrementalJpsTest(checkDumpsCaseInsensitively = true) {
fun testProjectPathCaseChanged() { fun testProjectPathCaseChanged() {
doTest("jps-plugin/testData/incremental/custom/projectPathCaseChanged/") doTest("jps-plugin/testData/incremental/custom/projectPathCaseChanged/")
} }
@@ -37,8 +37,8 @@ public class IncrementalProjectPathCaseChangedTest : AbstractIncrementalJpsTest(
} }
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) { override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
val module = myProject.getModules()[0] val module = myProject.modules[0]
val sourceRoot = module.getSourceRoots()[0].getUrl() val sourceRoot = module.sourceRoots[0].url
assert(sourceRoot.endsWith("/src")) assert(sourceRoot.endsWith("/src"))
val newSourceRoot = sourceRoot.replace("/src", "/SRC") val newSourceRoot = sourceRoot.replace("/src", "/SRC")
module.removeSourceRoot(sourceRoot, JavaSourceRootType.SOURCE) module.removeSourceRoot(sourceRoot, JavaSourceRootType.SOURCE)
@@ -60,7 +60,7 @@ import java.util.zip.ZipOutputStream
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertTrue import kotlin.test.assertTrue
public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
companion object { companion object {
private val PROJECT_NAME = "kotlinProject" private val PROJECT_NAME = "kotlinProject"
private val ADDITIONAL_MODULE_NAME = "module2" private val ADDITIONAL_MODULE_NAME = "module2"
@@ -113,8 +113,8 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
val list = arrayListOf<String>() val list = arrayListOf<String>()
for (moduleName in moduleNames) { for (moduleName in moduleNames) {
val outputDir = File("out/production/$moduleName") val outputDir = File("out/production/$moduleName")
list.add(toSystemIndependentName(JpsJsModuleUtils.getOutputFile(outputDir, moduleName).getPath())) list.add(toSystemIndependentName(JpsJsModuleUtils.getOutputFile(outputDir, moduleName).path))
list.add(toSystemIndependentName(JpsJsModuleUtils.getOutputMetaFile(outputDir, moduleName).getPath())) list.add(toSystemIndependentName(JpsJsModuleUtils.getOutputMetaFile(outputDir, moduleName).path))
} }
return list.toTypedArray() return list.toTypedArray()
} }
@@ -133,7 +133,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
private fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) { private fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) {
for (path in relativePaths) { for (path in relativePaths) {
val outputFile = findFileInOutputDir(module, path) val outputFile = findFileInOutputDir(module, path)
assertTrue(outputFile.exists(), "Output not written: " + outputFile.getAbsolutePath() + "\n Directory contents: \n" + dirContents(outputFile.getParentFile())) assertTrue(outputFile.exists(), "Output not written: " + outputFile.absolutePath + "\n Directory contents: \n" + dirContents(outputFile.parentFile))
} }
} }
@@ -151,7 +151,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) val outputDir = File(JpsPathUtil.urlToPath(outputUrl))
for (path in relativePaths) { for (path in relativePaths) {
val outputFile = File(outputDir, path) val outputFile = File(outputDir, path)
assertFalse(outputFile.exists(), "Output directory \"" + outputFile.getAbsolutePath() + "\" contains \"" + path + "\"") assertFalse(outputFile.exists(), "Output directory \"" + outputFile.absolutePath + "\" contains \"" + path + "\"")
} }
} }
@@ -159,7 +159,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
val files = dir.listFiles() ?: return "<not found>" val files = dir.listFiles() ?: return "<not found>"
val builder = StringBuilder() val builder = StringBuilder()
for (file in files) { for (file in files) {
builder.append(" * ").append(file.getName()).append("\n") builder.append(" * ").append(file.name).append("\n")
} }
return builder.toString() return builder.toString()
} }
@@ -173,7 +173,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
return "out/production/$moduleName/${JvmCodegenUtil.getMappingFileName(moduleName)}" return "out/production/$moduleName/${JvmCodegenUtil.getMappingFileName(moduleName)}"
} }
public fun mergeArrays(vararg stringArrays: Array<String>): Array<String> { fun mergeArrays(vararg stringArrays: Array<String>): Array<String> {
val result = HashSet<String>() val result = HashSet<String>()
for (array in stringArrays) { for (array in stringArrays) {
result.addAll(Arrays.asList(*array)) result.addAll(Arrays.asList(*array))
@@ -186,7 +186,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
super.setUp() super.setUp()
val sourceFilesRoot = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) val sourceFilesRoot = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false))
workDir = AbstractKotlinJpsBuildTestCase.copyTestDataToTmpDir(sourceFilesRoot) workDir = AbstractKotlinJpsBuildTestCase.copyTestDataToTmpDir(sourceFilesRoot)
getOrCreateProjectDir() orCreateProjectDir
} }
override fun tearDown() { override fun tearDown() {
@@ -198,21 +198,21 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
private fun initProject() { private fun initProject() {
addJdk(JDK_NAME) addJdk(JDK_NAME)
loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr") loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr")
} }
public fun doTest() { fun doTest() {
initProject() initProject()
makeAll().assertSuccessful() makeAll().assertSuccessful()
} }
public fun doTestWithRuntime() { fun doTestWithRuntime() {
initProject() initProject()
addKotlinRuntimeDependency() addKotlinRuntimeDependency()
makeAll().assertSuccessful() makeAll().assertSuccessful()
} }
public fun doTestWithKotlinJavaScriptLibrary() { fun doTestWithKotlinJavaScriptLibrary() {
initProject() initProject()
addKotlinJavaScriptStdlibDependency() addKotlinJavaScriptStdlibDependency()
createKotlinJavaScriptLibraryArchive() createKotlinJavaScriptLibraryArchive()
@@ -220,17 +220,17 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
makeAll().assertSuccessful() makeAll().assertSuccessful()
} }
public fun testKotlinProject() { fun testKotlinProject() {
doTest() doTest()
checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt")) checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt"))
} }
public fun testSourcePackagePrefix() { fun testSourcePackagePrefix() {
doTest() doTest()
} }
public fun testSourcePackageLongPrefix() { fun testSourcePackageLongPrefix() {
initProject() initProject()
val buildResult = makeAll() val buildResult = makeAll()
buildResult.assertSuccessful() buildResult.assertSuccessful()
@@ -239,7 +239,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText) assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText)
} }
public fun testSourcePackagePrefixKnownIssueWithInnerClasses() { fun testSourcePackagePrefixKnownIssueWithInnerClasses() {
initProject() initProject()
val buildResult = makeAll() val buildResult = makeAll()
buildResult.assertFailed() buildResult.assertFailed()
@@ -247,7 +247,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
assertTrue("Message wasn't found. $errors", errors.first().contains("class xxx.JavaWithInner.TextRenderer, unresolved supertypes: TableRow")) assertTrue("Message wasn't found. $errors", errors.first().contains("class xxx.JavaWithInner.TextRenderer, unresolved supertypes: TableRow"))
} }
public fun testKotlinJavaScriptProject() { fun testKotlinJavaScriptProject() {
initProject() initProject()
addKotlinJavaScriptStdlibDependency() addKotlinJavaScriptStdlibDependency()
makeAll().assertSuccessful() makeAll().assertSuccessful()
@@ -256,7 +256,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME))
} }
public fun testKotlinJavaScriptProjectWithTwoModules() { fun testKotlinJavaScriptProjectWithTwoModules() {
initProject() initProject()
addKotlinJavaScriptStdlibDependency() addKotlinJavaScriptStdlibDependency()
makeAll().assertSuccessful() makeAll().assertSuccessful()
@@ -269,9 +269,9 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(arrayOf(touch("src/test1.kt"), touch("module2/src/module2.kt")), null, k2jsOutput(PROJECT_NAME, ADDITIONAL_MODULE_NAME)) checkWhen(arrayOf(touch("src/test1.kt"), touch("module2/src/module2.kt")), null, k2jsOutput(PROJECT_NAME, ADDITIONAL_MODULE_NAME))
} }
public fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() { fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() {
initProject() initProject()
val jslibJar = PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath() val jslibJar = PathUtil.getKotlinPathsForDistDirectory().jsStdLibJarPath
val jslibDir = File(workDir, "KotlinJavaScript") val jslibDir = File(workDir, "KotlinJavaScript")
try { try {
ZipUtil.extract(jslibJar, jslibDir, null) ZipUtil.extract(jslibJar, jslibDir, null)
@@ -287,7 +287,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME))
} }
public fun testKotlinJavaScriptProjectWithDirectoryAsLibrary() { fun testKotlinJavaScriptProjectWithDirectoryAsLibrary() {
initProject() initProject()
addKotlinJavaScriptStdlibDependency() addKotlinJavaScriptStdlibDependency()
addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY)) addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY))
@@ -297,28 +297,28 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME))
} }
public fun testKotlinJavaScriptProjectWithLibrary() { fun testKotlinJavaScriptProjectWithLibrary() {
doTestWithKotlinJavaScriptLibrary() doTestWithKotlinJavaScriptLibrary()
assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME))
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME))
} }
public fun testKotlinJavaScriptProjectWithLibraryCustomOutputDir() { fun testKotlinJavaScriptProjectWithLibraryCustomOutputDir() {
doTestWithKotlinJavaScriptLibrary() doTestWithKotlinJavaScriptLibrary()
assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR, contentOfOutputDir(PROJECT_NAME)) assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR, contentOfOutputDir(PROJECT_NAME))
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME))
} }
public fun testKotlinJavaScriptProjectWithLibraryNoCopy() { fun testKotlinJavaScriptProjectWithLibraryNoCopy() {
doTestWithKotlinJavaScriptLibrary() doTestWithKotlinJavaScriptLibrary()
assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY, contentOfOutputDir(PROJECT_NAME)) assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY, contentOfOutputDir(PROJECT_NAME))
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME))
} }
public fun testKotlinJavaScriptProjectWithLibraryAndErrors() { fun testKotlinJavaScriptProjectWithLibraryAndErrors() {
initProject() initProject()
addKotlinJavaScriptStdlibDependency() addKotlinJavaScriptStdlibDependency()
createKotlinJavaScriptLibraryArchive() createKotlinJavaScriptLibraryArchive()
@@ -328,20 +328,20 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME)) assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME))
} }
public fun testExcludeFolderInSourceRoot() { fun testExcludeFolderInSourceRoot() {
doTest() doTest()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "Foo.class") assertFilesExistInOutput(module, "Foo.class")
assertFilesNotExistInOutput(module, *EXCLUDE_FILES) assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo")))
} }
public fun testExcludeModuleFolderInSourceRootOfAnotherModule() { fun testExcludeModuleFolderInSourceRootOfAnotherModule() {
doTest() doTest()
for (module in myProject.getModules()) { for (module in myProject.modules) {
assertFilesExistInOutput(module, "Foo.class") assertFilesExistInOutput(module, "Foo.class")
} }
@@ -349,10 +349,10 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/module2/src/foo.kt"), null, arrayOf(klass("module2", "Foo"))) checkWhen(touch("src/module2/src/foo.kt"), null, arrayOf(klass("module2", "Foo")))
} }
public fun testExcludeFileUsingCompilerSettings() { fun testExcludeFileUsingCompilerSettings() {
doTest() doTest()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "Foo.class", "Bar.class") assertFilesExistInOutput(module, "Foo.class", "Bar.class")
assertFilesNotExistInOutput(module, *EXCLUDE_FILES) assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
@@ -361,10 +361,10 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING) checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING)
} }
public fun testExcludeFolderNonRecursivelyUsingCompilerSettings() { fun testExcludeFolderNonRecursivelyUsingCompilerSettings() {
doTest() doTest()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "Foo.class", "Bar.class") assertFilesExistInOutput(module, "Foo.class", "Bar.class")
assertFilesNotExistInOutput(module, *EXCLUDE_FILES) assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
@@ -375,10 +375,10 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING) checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING)
} }
public fun testExcludeFolderRecursivelyUsingCompilerSettings() { fun testExcludeFolderRecursivelyUsingCompilerSettings() {
doTest() doTest()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "Foo.class", "Bar.class") assertFilesExistInOutput(module, "Foo.class", "Bar.class")
assertFilesNotExistInOutput(module, *EXCLUDE_FILES) assertFilesNotExistInOutput(module, *EXCLUDE_FILES)
@@ -390,10 +390,10 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING) checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING)
} }
public fun testManyFiles() { fun testManyFiles() {
doTest() doTest()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class") assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt")) checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
@@ -412,10 +412,10 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/Bar.kt"), null, arrayOf(klass("kotlinProject", "foo.Bar"))) checkWhen(touch("src/Bar.kt"), null, arrayOf(klass("kotlinProject", "foo.Bar")))
} }
public fun testManyFilesForPackage() { fun testManyFilesForPackage() {
doTest() doTest()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class") assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt")) checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
@@ -441,7 +441,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
module("kotlinProject"))) module("kotlinProject")))
} }
public fun testKotlinProjectTwoFilesInOnePackage() { fun testKotlinProjectTwoFilesInOnePackage() {
doTest() doTest()
checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage"))
@@ -452,38 +452,38 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
packagePartClass("kotlinProject", "src/test2.kt", "_DefaultPackage"), packagePartClass("kotlinProject", "src/test2.kt", "_DefaultPackage"),
module("kotlinProject"))) module("kotlinProject")))
assertFilesNotExistInOutput(myProject.getModules().get(0), "_DefaultPackage.class") assertFilesNotExistInOutput(myProject.modules.get(0), "_DefaultPackage.class")
} }
public fun testKotlinJavaProject() { fun testKotlinJavaProject() {
doTestWithRuntime() doTestWithRuntime()
} }
public fun testJKJProject() { fun testJKJProject() {
doTestWithRuntime() doTestWithRuntime()
} }
public fun testKJKProject() { fun testKJKProject() {
doTestWithRuntime() doTestWithRuntime()
} }
public fun testKJCircularProject() { fun testKJCircularProject() {
doTestWithRuntime() doTestWithRuntime()
} }
public fun testJKJInheritanceProject() { fun testJKJInheritanceProject() {
doTestWithRuntime() doTestWithRuntime()
} }
public fun testKJKInheritanceProject() { fun testKJKInheritanceProject() {
doTestWithRuntime() doTestWithRuntime()
} }
public fun testCircularDependenciesNoKotlinFiles() { fun testCircularDependenciesNoKotlinFiles() {
doTest() doTest()
} }
public fun testCircularDependenciesDifferentPackages() { fun testCircularDependenciesDifferentPackages() {
initProject() initProject()
val result = makeAll() val result = makeAll()
@@ -497,7 +497,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt")) checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt"))
} }
public fun testCircularDependenciesSamePackage() { fun testCircularDependenciesSamePackage() {
initProject() initProject()
val result = makeAll() val result = makeAll()
result.assertSuccessful() result.assertSuccessful()
@@ -512,7 +512,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))
} }
public fun testCircularDependenciesSamePackageWithTests() { fun testCircularDependenciesSamePackageWithTests() {
initProject() initProject()
val result = makeAll() val result = makeAll()
result.assertSuccessful() result.assertSuccessful()
@@ -527,31 +527,31 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))
} }
public fun testInternalFromAnotherModule() { fun testInternalFromAnotherModule() {
initProject() initProject()
val result = makeAll() val result = makeAll()
result.assertFailed() result.assertFailed()
result.checkErrors() result.checkErrors()
} }
public fun testCircularDependenciesInternalFromAnotherModule() { fun testCircularDependenciesInternalFromAnotherModule() {
initProject() initProject()
val result = makeAll() val result = makeAll()
result.assertFailed() result.assertFailed()
result.checkErrors() result.checkErrors()
} }
public fun testCircularDependenciesWrongInternalFromTests() { fun testCircularDependenciesWrongInternalFromTests() {
initProject() initProject()
val result = makeAll() val result = makeAll()
result.assertFailed() result.assertFailed()
result.checkErrors() result.checkErrors()
} }
public fun testCircularDependencyWithReferenceToOldVersionLib() { fun testCircularDependencyWithReferenceToOldVersionLib() {
initProject() initProject()
val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.getAbsolutePath() + File.separator + "oldModuleLib/src", "module-lib", false) val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib", false)
AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, "module-lib", libraryJar) AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, "module-lib", libraryJar)
@@ -559,10 +559,10 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
result.assertSuccessful() result.assertSuccessful()
} }
public fun testDependencyToOldKotlinLib() { fun testDependencyToOldKotlinLib() {
initProject() initProject()
val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.getAbsolutePath() + File.separator + "oldModuleLib/src", "module-lib", false) val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib", false)
AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar) AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar)
@@ -572,7 +572,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
result.assertSuccessful() result.assertSuccessful()
} }
public fun testAccessToInternalInProductionFromTests() { fun testAccessToInternalInProductionFromTests() {
initProject() initProject()
val result = makeAll() val result = makeAll()
@@ -608,17 +608,17 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
return result return result
} }
public fun testReexportedDependency() { fun testReexportedDependency() {
initProject() initProject()
AbstractKotlinJpsBuildTestCase.addKotlinRuntimeDependency(JpsJavaDependencyScope.COMPILE, ContainerUtil.filter(myProject.getModules(), object : Condition<JpsModule> { AbstractKotlinJpsBuildTestCase.addKotlinRuntimeDependency(JpsJavaDependencyScope.COMPILE, ContainerUtil.filter(myProject.modules, object : Condition<JpsModule> {
override fun value(module: JpsModule): Boolean { override fun value(module: JpsModule): Boolean {
return module.getName() == "module2" return module.name == "module2"
} }
}), true) }), true)
makeAll().assertSuccessful() makeAll().assertSuccessful()
} }
public fun testCancelLongKotlinCompilation() { fun testCancelLongKotlinCompilation() {
generateLongKotlinFile("Foo.kt", "foo", "Foo") generateLongKotlinFile("Foo.kt", "foo", "Foo")
initProject() initProject()
@@ -636,28 +636,28 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
buildResult.assertSuccessful() buildResult.assertSuccessful()
assert(interval < 8000) { "expected time for canceled compilation < 8000 ms, but $interval" } assert(interval < 8000) { "expected time for canceled compilation < 8000 ms, but $interval" }
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesNotExistInOutput(module, "foo/Foo.class") assertFilesNotExistInOutput(module, "foo/Foo.class")
val expectedLog = workDir.getAbsolutePath() + File.separator + "expected.log" val expectedLog = workDir.absolutePath + File.separator + "expected.log"
checkFullLog(logger, File(expectedLog)) checkFullLog(logger, File(expectedLog))
} }
public fun testCancelKotlinCompilation() { fun testCancelKotlinCompilation() {
initProject() initProject()
makeAll().assertSuccessful() makeAll().assertSuccessful()
val module = myProject.getModules().get(0) val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/Bar.class") assertFilesExistInOutput(module, "foo/Bar.class")
val buildResult = BuildResult() val buildResult = BuildResult()
val canceledStatus = object: CanceledStatus { val canceledStatus = object: CanceledStatus {
var checkFromIndex = 0; var checkFromIndex = 0;
public override fun isCanceled(): Boolean { override fun isCanceled(): Boolean {
val messages = buildResult.getMessages(BuildMessage.Kind.INFO) val messages = buildResult.getMessages(BuildMessage.Kind.INFO)
for (i in checkFromIndex..messages.size - 1) { for (i in checkFromIndex..messages.size - 1) {
if (messages.get(i).getMessageText().startsWith("Kotlin JPS plugin version")) return true; if (messages.get(i).messageText.startsWith("Kotlin JPS plugin version")) return true;
} }
checkFromIndex = messages.size; checkFromIndex = messages.size;
@@ -672,7 +672,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
assertFilesNotExistInOutput(module, "foo/Bar.class") assertFilesNotExistInOutput(module, "foo/Bar.class")
} }
public fun testFileDoesNotExistWarning() { fun testFileDoesNotExistWarning() {
initProject() initProject()
AbstractKotlinJpsBuildTestCase.addDependency( AbstractKotlinJpsBuildTestCase.addDependency(
@@ -697,7 +697,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
) )
} }
public fun testDoNotCreateUselessKotlinIncrementalCaches() { fun testDoNotCreateUselessKotlinIncrementalCaches() {
initProject() initProject()
makeAll().assertSuccessful() makeAll().assertSuccessful()
@@ -706,7 +706,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists())
} }
public fun testDoNotCreateUselessKotlinIncrementalCachesForDependentTargets() { fun testDoNotCreateUselessKotlinIncrementalCachesForDependentTargets() {
initProject() initProject()
makeAll().assertSuccessful() makeAll().assertSuccessful()
@@ -741,16 +741,16 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
} }
private fun checkFullLog(logger: TestProjectBuilderLogger, expectedLogFile: File) { private fun checkFullLog(logger: TestProjectBuilderLogger, expectedLogFile: File) {
UsefulTestCase.assertSameLinesWithFile(expectedLogFile.getAbsolutePath(), logger.getFullLog(getOrCreateProjectDir(), myDataStorageRoot)) UsefulTestCase.assertSameLinesWithFile(expectedLogFile.absolutePath, logger.getFullLog(orCreateProjectDir, myDataStorageRoot))
} }
private fun assertCanceled(buildResult: BuildResult) { private fun assertCanceled(buildResult: BuildResult) {
val list = buildResult.getMessages(BuildMessage.Kind.INFO) val list = buildResult.getMessages(BuildMessage.Kind.INFO)
assertTrue("The build has been canceled".equals(list.last().getMessageText())) assertTrue("The build has been canceled".equals(list.last().messageText))
} }
private fun generateLongKotlinFile(filePath: String, packagename: String, className: String) { private fun generateLongKotlinFile(filePath: String, packagename: String, className: String) {
val file = File(workDir.getAbsolutePath() + File.separator + "src" + File.separator + filePath) val file = File(workDir.absolutePath + File.separator + "src" + File.separator + filePath)
FileUtilRt.createIfNotExists(file) FileUtilRt.createIfNotExists(file)
val writer = BufferedWriter(FileWriter(file)) val writer = BufferedWriter(FileWriter(file))
try { try {
@@ -769,8 +769,8 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
} }
private fun findModule(name: String): JpsModule { private fun findModule(name: String): JpsModule {
for (module in myProject.getModules()) { for (module in myProject.modules) {
if (module.getName() == name) { if (module.name == name) {
return module return module
} }
} }
@@ -802,7 +802,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
} }
private fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String { private fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String {
val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).getAbsolutePath()) val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).absolutePath)
val fakeVirtualFile = object : LightVirtualFile(path.substringAfterLast('/')) { val fakeVirtualFile = object : LightVirtualFile(path.substringAfterLast('/')) {
override fun getPath(): String { override fun getPath(): String {
// strip extra "/" from the beginning // strip extra "/" from the beginning
@@ -833,7 +833,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
Operation.CHANGE -> Operation.CHANGE ->
touch(file) touch(file)
Operation.DELETE -> Operation.DELETE ->
assertTrue(file.delete(), "Can not delete file \"" + file.getAbsolutePath() + "\"") assertTrue(file.delete(), "Can not delete file \"" + file.absolutePath + "\"")
else -> else ->
fail("Unknown operation") fail("Unknown operation")
} }
@@ -22,13 +22,13 @@ import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File import java.io.File
public class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
override fun setUp() { override fun setUp() {
super.setUp() super.setUp()
workDir = KotlinTestUtils.tmpDirForTest(this) workDir = KotlinTestUtils.tmpDirForTest(this)
} }
public fun testLoadingKotlinFromDifferentModules() { fun testLoadingKotlinFromDifferentModules() {
val aFile = createFile("m1/K.kt", val aFile = createFile("m1/K.kt",
""" """
package m1; package m1;
@@ -65,7 +65,7 @@ public class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
} }
// TODO: add JS tests // TODO: add JS tests
public fun testDaemon() { fun testDaemon() {
System.setProperty(COMPILE_DAEMON_ENABLED_PROPERTY, "") System.setProperty(COMPILE_DAEMON_ENABLED_PROPERTY, "")
System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "") System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "")
// spaces in the name to test proper file name handling // spaces in the name to test proper file name handling
@@ -57,7 +57,7 @@ fun getDirectoryString(dir: File, interestingPaths: List<String>): String {
val children = listFiles!!.sortedWith(compareBy ({ it.isDirectory }, { it.name } )) val children = listFiles!!.sortedWith(compareBy ({ it.isDirectory }, { it.name } ))
for (child in children) { for (child in children) {
if (child.isDirectory()) { if (child.isDirectory) {
p.println(child.name) p.println(child.name)
addDirContent(child) addDirContent(child)
} }
@@ -86,7 +86,7 @@ fun getDirectoryString(dir: File, interestingPaths: List<String>): String {
fun getAllRelativePaths(dir: File): Set<String> { fun getAllRelativePaths(dir: File): Set<String> {
val result = HashSet<String>() val result = HashSet<String>()
FileUtil.processFilesRecursively(dir) { FileUtil.processFilesRecursively(dir) {
if (it!!.isFile()) { if (it!!.isFile) {
result.add(FileUtil.getRelativePath(dir, it)!!) result.add(FileUtil.getRelativePath(dir, it)!!)
} }
@@ -132,7 +132,7 @@ fun classFileToString(classFile: File): String {
val traceVisitor = TraceClassVisitor(PrintWriter(out)) val traceVisitor = TraceClassVisitor(PrintWriter(out))
ClassReader(classFile.readBytes()).accept(traceVisitor, 0) ClassReader(classFile.readBytes()).accept(traceVisitor, 0)
val classHeader = LocalFileKotlinClass.create(classFile)?.getClassHeader() val classHeader = LocalFileKotlinClass.create(classFile)?.classHeader
val annotationDataEncoded = classHeader?.annotationData val annotationDataEncoded = classHeader?.annotationData
if (annotationDataEncoded != null) { if (annotationDataEncoded != null) {
@@ -28,9 +28,9 @@ import org.jetbrains.kotlin.test.MockLibraryUtil
import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.Printer
import java.io.File import java.io.File
public abstract class AbstractProtoComparisonTest : UsefulTestCase() { abstract class AbstractProtoComparisonTest : UsefulTestCase() {
public fun doTest(testDataPath: String) { fun doTest(testDataPath: String) {
val testDir = KotlinTestUtils.tmpDir("testDirectory") val testDir = KotlinTestUtils.tmpDir("testDirectory")
val oldClassFiles = compileFileAndGetClasses(testDataPath, testDir, "old") val oldClassFiles = compileFileAndGetClasses(testDataPath, testDir, "old")
@@ -30,22 +30,22 @@ import java.io.File
* To test this, we compile a Kotlin+Java module (in two modes: CLI and module-based) where a runtime Java class was replaced * To test this, we compile a Kotlin+Java module (in two modes: CLI and module-based) where a runtime Java class was replaced
* with a "newer" version in sources, and check that this class resolves to the one from sources by calling a method absent in the runtime * with a "newer" version in sources, and check that this class resolves to the one from sources by calling a method absent in the runtime
*/ */
public class ClasspathOrderTest : TestCaseWithTmpdir() { class ClasspathOrderTest : TestCaseWithTmpdir() {
companion object { companion object {
val sourceDir = File(KotlinTestUtils.getTestDataPathBase() + "/classpathOrder").getAbsoluteFile() val sourceDir = File(KotlinTestUtils.getTestDataPathBase() + "/classpathOrder").absoluteFile
} }
public fun testClasspathOrderForCLI() { fun testClasspathOrderForCLI() {
MockLibraryUtil.compileKotlin(sourceDir.getPath(), tmpdir) MockLibraryUtil.compileKotlin(sourceDir.path, tmpdir)
} }
public fun testClasspathOrderForModuleScriptBuild() { fun testClasspathOrderForModuleScriptBuild() {
val xmlContent = KotlinModuleXmlBuilder().addModule( val xmlContent = KotlinModuleXmlBuilder().addModule(
"name", "name",
File(tmpdir, "output").getAbsolutePath(), File(tmpdir, "output").absolutePath,
listOf(sourceDir), listOf(sourceDir),
listOf(JvmSourceRoot(sourceDir)), listOf(JvmSourceRoot(sourceDir)),
listOf(PathUtil.getKotlinPathsForDistDirectory().getRuntimePath()), listOf(PathUtil.getKotlinPathsForDistDirectory().runtimePath),
JavaModuleBuildTargetType.PRODUCTION, JavaModuleBuildTargetType.PRODUCTION,
setOf(), setOf(),
emptyList() emptyList()
@@ -54,6 +54,6 @@ public class ClasspathOrderTest : TestCaseWithTmpdir() {
val xml = File(tmpdir, "module.xml") val xml = File(tmpdir, "module.xml")
xml.writeText(xmlContent) xml.writeText(xmlContent)
MockLibraryUtil.compileKotlinModule(xml.getAbsolutePath()) MockLibraryUtil.compileKotlinModule(xml.absolutePath)
} }
} }