diff --git a/jps/jps-common/build.gradle.kts b/jps/jps-common/build.gradle.kts new file mode 100644 index 00000000000..f59eca69fcd --- /dev/null +++ b/jps/jps-common/build.gradle.kts @@ -0,0 +1,24 @@ + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + compile(kotlinStdlib()) + compileOnly(project(":kotlin-reflect-api")) + compile(project(":compiler:util")) + compile(project(":compiler:cli-common")) + compile(project(":compiler:frontend.java")) + compile(project(":js:js.frontend")) + compile(project(":native:frontend.native")) + compileOnly(intellijDep()) + compileOnly(jpsStandalone()) { includeJars("jps-model") } +} + +sourceSets { + "main" { projectDefault() } + "test" {} +} + +runtimeJar() diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/CompilerRunnerConstants.java b/jps/jps-common/src/org/jetbrains/kotlin/config/CompilerRunnerConstants.java new file mode 100644 index 00000000000..70c584e3f28 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/CompilerRunnerConstants.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.config; + +public class CompilerRunnerConstants { + public static final String KOTLIN_COMPILER_NAME = "Kotlin"; + public static final String INTERNAL_ERROR_PREFIX = "[Internal Error] "; +} diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt new file mode 100644 index 00000000000..89abfd326c0 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/CompilerSettings.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.config + +import com.intellij.openapi.util.text.StringUtil +import org.jetbrains.kotlin.cli.common.arguments.Freezable + +class CompilerSettings : Freezable() { + var additionalArguments: String by FreezableVar(DEFAULT_ADDITIONAL_ARGUMENTS) + var scriptTemplates: String by FreezableVar("") + var scriptTemplatesClasspath: String by FreezableVar("") + var copyJsLibraryFiles: Boolean by FreezableVar(true) + var outputDirectoryForJsLibraryFiles: String by FreezableVar(DEFAULT_OUTPUT_DIRECTORY) + + companion object { + val DEFAULT_ADDITIONAL_ARGUMENTS = "-version" + private val DEFAULT_OUTPUT_DIRECTORY = "lib" + } +} + +val CompilerSettings.additionalArgumentsAsList: List + get() = splitArgumentString(additionalArguments) + +fun splitArgumentString(arguments: String) = StringUtil.splitHonorQuotes(arguments, ' ').map { + if (it.startsWith('"')) StringUtil.unescapeChar(StringUtil.unquoteString(it), '"') else it +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/JpsUtils.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/JpsUtils.kt new file mode 100644 index 00000000000..b3ff11964ff --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/JpsUtils.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config + +import com.intellij.openapi.application.ApplicationManager + +private const val APPLICATION_MANAGER_CLASS_NAME = "com.intellij.openapi.application.ApplicationManager" + +val isJps: Boolean by lazy { + /* + Normally, JPS shouldn't have an ApplicationManager class in the classpath, + but that's not true for JPS inside IDEA right now. + Though Application is not properly initialized inside JPS so we can use it as a check. + */ + return@lazy if (doesClassExist(APPLICATION_MANAGER_CLASS_NAME)) { + ApplicationManager.getApplication() == null + } else { + true + } +} + +private fun doesClassExist(fqName: String): Boolean { + val classPath = fqName.replace('.', '/') + ".class" + return {}.javaClass.classLoader.getResource(classPath) != null +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinCommonJpsModelSerializerExtension.java b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinCommonJpsModelSerializerExtension.java new file mode 100644 index 00000000000..a088979f6be --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinCommonJpsModelSerializerExtension.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension; +import org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer; + +import java.util.Arrays; +import java.util.List; + +public class KotlinCommonJpsModelSerializerExtension extends JpsModelSerializerExtension { + @NotNull + @Override + public List> getModuleSourceRootPropertiesSerializers() { + return Arrays.asList( + KotlinSourceRootPropertiesSerializer.Source.INSTANCE, + KotlinSourceRootPropertiesSerializer.TestSource.INSTANCE, + KotlinResourceRootPropertiesSerializer.Resource.INSTANCE, + KotlinResourceRootPropertiesSerializer.TestResource.INSTANCE + ); + } +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt new file mode 100644 index 00000000000..3d0094627a2 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -0,0 +1,293 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config + +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.module.Module +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.cli.common.arguments.Argument +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.copyBean +import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments +import org.jetbrains.kotlin.platform.IdePlatformKind +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.TargetPlatformVersion +import org.jetbrains.kotlin.platform.compat.toIdePlatform +import org.jetbrains.kotlin.platform.isCommon +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.utils.DescriptionAware +import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import kotlin.reflect.KProperty1 +import kotlin.reflect.full.findAnnotation + +@Deprecated("Use IdePlatformKind instead.", level = DeprecationLevel.ERROR) +sealed class TargetPlatformKind( + val version: Version, + val name: String +) : DescriptionAware { + override val description = "$name ${version.description}" + + class Jvm(version: JvmTarget) : @Suppress("DEPRECATION_ERROR") TargetPlatformKind(version, "JVM") { + companion object { + private val JVM_PLATFORMS by lazy { JvmTarget.values().map(::Jvm) } + operator fun get(version: JvmTarget) = JVM_PLATFORMS[version.ordinal] + } + } + + object JavaScript : @Suppress("DEPRECATION_ERROR") TargetPlatformKind( + TargetPlatformVersion.NoVersion, + "JavaScript" + ) + + object Common : @Suppress("DEPRECATION_ERROR") TargetPlatformKind( + TargetPlatformVersion.NoVersion, + "Common (experimental)" + ) +} + +sealed class VersionView : DescriptionAware { + abstract val version: LanguageVersion + + object LatestStable : VersionView() { + override val version: LanguageVersion = RELEASED_VERSION + + override val description: String + get() = "Latest stable (${version.versionString})" + } + + class Specific(override val version: LanguageVersion) : VersionView() { + override val description: String + get() = version.description + + override fun equals(other: Any?) = other is Specific && version == other.version + + override fun hashCode() = version.hashCode() + } + + companion object { + val RELEASED_VERSION = LanguageVersion.LATEST_STABLE + + fun deserialize(value: String?, isAutoAdvance: Boolean): VersionView { + if (isAutoAdvance) return LatestStable + val languageVersion = LanguageVersion.fromVersionString(value) + return if (languageVersion != null) Specific(languageVersion) else LatestStable + } + } +} + +var CommonCompilerArguments.languageVersionView: VersionView + get() = VersionView.deserialize(languageVersion, autoAdvanceLanguageVersion) + set(value) { + languageVersion = value.version.versionString + autoAdvanceLanguageVersion = value == VersionView.LatestStable + } + +var CommonCompilerArguments.apiVersionView: VersionView + get() = VersionView.deserialize(apiVersion, autoAdvanceApiVersion) + set(value) { + apiVersion = value.version.versionString + autoAdvanceApiVersion = value == VersionView.LatestStable + } + +enum class KotlinModuleKind { + DEFAULT, + SOURCE_SET_HOLDER, + COMPILATION_AND_SOURCE_SET_HOLDER; + + @Deprecated("Use KotlinFacetSettings.mppVersion.isNewMpp") + val isNewMPP: Boolean + get() = this != DEFAULT +} + +enum class KotlinMultiplatformVersion(val version: Int) { + M1(1), // the first implementation of MPP. Aka 1.2.0 MPP + M2(2), // the "New" MPP. Aka 1.3.0 MPP + M3(3) // the "Hierarchical" MPP. +} + +val KotlinMultiplatformVersion?.isOldMpp: Boolean + get() = this == KotlinMultiplatformVersion.M1 + +val KotlinMultiplatformVersion?.isNewMPP: Boolean + get() = this == KotlinMultiplatformVersion.M2 + +val KotlinMultiplatformVersion?.isHmpp: Boolean + get() = this == KotlinMultiplatformVersion.M3 + +interface ExternalSystemRunTask { + val taskName: String + val externalSystemProjectId: String + val targetName: String? +} + +data class ExternalSystemTestRunTask( + override val taskName: String, + override val externalSystemProjectId: String, + override val targetName: String? +) : ExternalSystemRunTask { + + fun toStringRepresentation() = "$taskName|$externalSystemProjectId|$targetName" + + companion object { + fun fromStringRepresentation(line: String) = + line.split("|").let { if (it.size == 3) ExternalSystemTestRunTask(it[0], it[1], it[2]) else null } + } + + override fun toString() = "$taskName@$externalSystemProjectId [$targetName]" +} + +data class ExternalSystemNativeMainRunTask( + override val taskName: String, + override val externalSystemProjectId: String, + override val targetName: String?, + val entryPoint: String, + val debuggable: Boolean, +) : ExternalSystemRunTask { + + fun toStringRepresentation() = "$taskName|$externalSystemProjectId|$targetName|$entryPoint|$debuggable" + + companion object { + fun fromStringRepresentation(line: String): ExternalSystemNativeMainRunTask? = + line.split("|").let { + if (it.size == 5) ExternalSystemNativeMainRunTask(it[0], it[1], it[2], it[3], it[4].toBoolean()) else null + } + } +} + +class KotlinFacetSettings { + companion object { + // Increment this when making serialization-incompatible changes to configuration data + val CURRENT_VERSION = 4 + val DEFAULT_VERSION = 0 + } + + var version = CURRENT_VERSION + var useProjectSettings: Boolean = true + + var mergedCompilerArguments: CommonCompilerArguments? = null + private set + + // TODO: Workaround for unwanted facet settings modification on code analysis + // To be replaced with proper API for settings update (see BaseKotlinCompilerSettings as an example) + fun updateMergedArguments() { + val compilerArguments = compilerArguments + val compilerSettings = compilerSettings + + mergedCompilerArguments = if (compilerArguments != null) { + copyBean(compilerArguments).apply { + if (compilerSettings != null) { + parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, this) + } + } + } else null + } + + var compilerArguments: CommonCompilerArguments? = null + set(value) { + field = value?.unfrozen() as CommonCompilerArguments? + updateMergedArguments() + } + + var compilerSettings: CompilerSettings? = null + set(value) { + field = value?.unfrozen() as CompilerSettings? + updateMergedArguments() + } + + /* + This function is needed as some setting values may not be present in compilerArguments + but present in additional arguments instead, so we have to check both cases manually + */ + inline fun isCompilerSettingPresent(settingReference: KProperty1): Boolean { + val isEnabledByCompilerArgument = compilerArguments?.safeAs()?.let(settingReference::get) + if (isEnabledByCompilerArgument == true) return true + val isEnabledByAdditionalSettings = run { + val stringArgumentName = settingReference.findAnnotation()?.value ?: return@run null + compilerSettings?.additionalArguments?.contains(stringArgumentName, ignoreCase = true) + } + return isEnabledByAdditionalSettings ?: false + } + + var languageLevel: LanguageVersion? + get() = compilerArguments?.languageVersion?.let { LanguageVersion.fromFullVersionString(it) } + set(value) { + compilerArguments?.apply { + languageVersion = value?.versionString + } + } + + var apiLevel: LanguageVersion? + get() = compilerArguments?.apiVersion?.let { LanguageVersion.fromFullVersionString(it) } + set(value) { + compilerArguments?.apply { + apiVersion = value?.versionString + } + } + + var targetPlatform: TargetPlatform? = null + get() { + // This work-around is required in order to fix importing of the proper JVM target version and works only + // for fully actualized JVM target platform + //TODO(auskov): this hack should be removed after fixing equals in SimplePlatform + val args = compilerArguments + val singleSimplePlatform = field?.componentPlatforms?.singleOrNull() + if (singleSimplePlatform == JvmPlatforms.defaultJvmPlatform.singleOrNull() && args != null) { + return IdePlatformKind.platformByCompilerArguments(args) + } + return field + } + + var externalSystemRunTasks: List = emptyList() + + @Suppress("DEPRECATION_ERROR") + @Deprecated( + message = "This accessor is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead", + replaceWith = ReplaceWith("targetPlatform"), + level = DeprecationLevel.ERROR + ) + fun getPlatform(): org.jetbrains.kotlin.platform.IdePlatform<*, *>? { + return targetPlatform?.toIdePlatform() + } + + var implementedModuleNames: List = emptyList() // used for first implementation of MPP, aka 'old' MPP + var dependsOnModuleNames: List = emptyList() // used for New MPP and later implementations + + var productionOutputPath: String? = null + var testOutputPath: String? = null + + var kind: KotlinModuleKind = KotlinModuleKind.DEFAULT + var sourceSetNames: List = emptyList() + var isTestModule: Boolean = false + + var externalProjectId: String = "" + + @Deprecated(message = "Use mppVersion.isHmppEnabled") + var isHmppEnabled: Boolean = false + + val mppVersion: KotlinMultiplatformVersion? + get() = when { + isHmppEnabled -> KotlinMultiplatformVersion.M3 + kind.isNewMPP -> KotlinMultiplatformVersion.M2 + targetPlatform.isCommon() || implementedModuleNames.isNotEmpty() -> KotlinMultiplatformVersion.M1 + else -> null + } + + var pureKotlinSourceFolders: List = emptyList() +} + +interface KotlinFacetSettingsProvider { + fun getSettings(module: Module): KotlinFacetSettings? + fun getInitializedSettings(module: Module): KotlinFacetSettings + + companion object { + fun getInstance(project: Project): KotlinFacetSettingsProvider? { + if (project.isDisposed) { + return null + } + return ServiceManager.getService(project, KotlinFacetSettingsProvider::class.java) + } + } +} diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinResourceRootType.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinResourceRootType.kt new file mode 100644 index 00000000000..2c93fa0c6c0 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinResourceRootType.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config + +import org.jetbrains.jps.model.ex.JpsElementTypeBase +import org.jetbrains.jps.model.java.JavaResourceRootProperties +import org.jetbrains.jps.model.java.JavaResourceRootType +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModuleSourceRootType + +sealed class KotlinResourceRootType() : JpsElementTypeBase(), + JpsModuleSourceRootType { + + override fun createDefaultProperties() = + JpsJavaExtensionService.getInstance().createResourceRootProperties("", false) +} + +object ResourceKotlinRootType : KotlinResourceRootType() + +object TestResourceKotlinRootType : KotlinResourceRootType() { + override fun isForTests() = true +} + +val ALL_KOTLIN_RESOURCE_ROOT_TYPES = setOf(ResourceKotlinRootType, TestResourceKotlinRootType) \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinSourceRootType.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinSourceRootType.kt new file mode 100644 index 00000000000..3df74657313 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinSourceRootType.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config + +import org.jetbrains.jps.model.ex.JpsElementTypeBase +import org.jetbrains.jps.model.java.JavaSourceRootProperties +import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModuleSourceRootType + +sealed class KotlinSourceRootType() : JpsElementTypeBase(), JpsModuleSourceRootType { + + override fun createDefaultProperties() = JpsJavaExtensionService.getInstance().createSourceRootProperties("") + +} + +object SourceKotlinRootType : KotlinSourceRootType() + +object TestSourceKotlinRootType : KotlinSourceRootType() { + override fun isForTests() = true +} + +val ALL_KOTLIN_SOURCE_ROOT_TYPES = setOf(SourceKotlinRootType, TestSourceKotlinRootType) diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/SettingConstants.java b/jps/jps-common/src/org/jetbrains/kotlin/config/SettingConstants.java new file mode 100644 index 00000000000..1c7aca6064f --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/SettingConstants.java @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.config; + +public class SettingConstants { + private SettingConstants() {} + + public static final String KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION = "KotlinCommonCompilerArguments"; + public static final String KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION = "Kotlin2JsCompilerArguments"; + public static final String KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION = "Kotlin2JvmCompilerArguments"; + public static final String KOTLIN_COMPILER_SETTINGS_SECTION = "KotlinCompilerSettings"; + + public static final String KOTLIN_COMPILER_SETTINGS_FILE = "kotlinc.xml"; +} diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt new file mode 100644 index 00000000000..7412c7a016f --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -0,0 +1,457 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config + +import com.intellij.util.PathUtil +import com.intellij.util.xmlb.SerializationFilter +import com.intellij.util.xmlb.SkipDefaultsSerializationFilter +import com.intellij.util.xmlb.XmlSerializer +import org.jdom.DataConversionException +import org.jdom.Element +import org.jdom.Text +import org.jetbrains.kotlin.cli.common.arguments.* +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.platform.* +import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments +import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind +import org.jetbrains.kotlin.platform.js.isJs +import org.jetbrains.kotlin.platform.jvm.JdkPlatform +import org.jetbrains.kotlin.platform.jvm.isJvm +import org.jetbrains.kotlin.platform.konan.* +import java.lang.reflect.Modifier +import kotlin.reflect.KClass +import kotlin.reflect.full.superclasses + +fun Element.getOption(name: String) = getChildren("option").firstOrNull { it.getAttribute("name").value == name } + +private fun Element.getOptionValue(name: String) = getOption(name)?.getAttribute("value")?.value + +private fun Element.getOptionBody(name: String) = getOption(name)?.children?.firstOrNull() + +fun TargetPlatform.createArguments(init: (CommonCompilerArguments).() -> Unit = {}): CommonCompilerArguments { + return when { + isCommon() -> K2MetadataCompilerArguments().apply { init() } + isJvm() -> K2JVMCompilerArguments().apply { + init() + // TODO(dsavvinov): review this + jvmTarget = (single() as? JdkPlatform)?.targetVersion?.description ?: JvmTarget.DEFAULT.description + } + isJs() -> K2JSCompilerArguments().apply { init() } + isNative() -> FakeK2NativeCompilerArguments().apply { init() } + else -> error("Unknown platform $this") + } +} + +private fun readV1Config(element: Element): KotlinFacetSettings { + return KotlinFacetSettings().apply { + val useProjectSettings = element.getOptionValue("useProjectSettings")?.toBoolean() + + val versionInfoElement = element.getOptionBody("versionInfo") + val targetPlatformName = versionInfoElement?.getOptionValue("targetPlatformName") + val languageLevel = versionInfoElement?.getOptionValue("languageLevel") + val apiLevel = versionInfoElement?.getOptionValue("apiLevel") + val targetPlatform = CommonPlatforms.allSimplePlatforms.union(setOf(CommonPlatforms.defaultCommonPlatform)) + .firstOrNull { it.oldFashionedDescription == targetPlatformName } + ?: JvmIdePlatformKind.defaultPlatform // FIXME(dsavvinov): choose proper default + + val compilerInfoElement = element.getOptionBody("compilerInfo") + + val compilerSettings = CompilerSettings().apply { + compilerInfoElement?.getOptionBody("compilerSettings")?.let { compilerSettingsElement -> + XmlSerializer.deserializeInto(this, compilerSettingsElement) + } + } + + val commonArgumentsElement = compilerInfoElement?.getOptionBody("_commonCompilerArguments") + val jvmArgumentsElement = compilerInfoElement?.getOptionBody("k2jvmCompilerArguments") + val jsArgumentsElement = compilerInfoElement?.getOptionBody("k2jsCompilerArguments") + + val compilerArguments = targetPlatform.createArguments { freeArgs = arrayListOf() } + + commonArgumentsElement?.let { XmlSerializer.deserializeInto(compilerArguments, it) } + when (compilerArguments) { + is K2JVMCompilerArguments -> jvmArgumentsElement?.let { XmlSerializer.deserializeInto(compilerArguments, it) } + is K2JSCompilerArguments -> jsArgumentsElement?.let { XmlSerializer.deserializeInto(compilerArguments, it) } + } + + if (languageLevel != null) { + compilerArguments.languageVersion = languageLevel + } + + if (apiLevel != null) { + compilerArguments.apiVersion = apiLevel + } + + compilerArguments.detectVersionAutoAdvance() + + if (useProjectSettings != null) { + this.useProjectSettings = useProjectSettings + } else { + // Migration problem workaround for pre-1.1-beta releases (mainly 1.0.6) -> 1.1-rc+ + // Problematic cases: 1.1-beta/1.1-beta2 -> 1.1-rc+ (useProjectSettings gets reset to false) + // This heuristic detects old enough configurations: + if (jvmArgumentsElement == null) { + this.useProjectSettings = false + } + } + + this.compilerSettings = compilerSettings + this.compilerArguments = compilerArguments + this.targetPlatform = IdePlatformKind.platformByCompilerArguments(compilerArguments) + } +} + +// TODO: Introduce new version of facet serialization. See https://youtrack.jetbrains.com/issue/KT-38235 +// This is necessary to avoid having too much custom logic for platform serialization. +fun Element.getFacetPlatformByConfigurationElement(): TargetPlatform { + val targetPlatform = getAttributeValue("allPlatforms").deserializeTargetPlatformByComponentPlatforms() + if (targetPlatform != null) return targetPlatform + + // failed to read list of all platforms. Fallback to legacy algorithm + val platformName = getAttributeValue("platform") ?: return DefaultIdeTargetPlatformKindProvider.defaultPlatform + + return CommonPlatforms.allSimplePlatforms.firstOrNull { + // first, look for exact match through all simple platforms + it.oldFashionedDescription == platformName + } ?: CommonPlatforms.defaultCommonPlatform.takeIf { + // then, check exact match for the default common platform + it.oldFashionedDescription == platformName + } ?: NativePlatforms.unspecifiedNativePlatform.takeIf { + // if none of the above succeeded, check if it's an old-style record about native platform (without suffix with target name) + it.oldFashionedDescription.startsWith(platformName) + }.orDefault() // finally, fallback to the default platform +} + +private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings { + return KotlinFacetSettings().apply { + element.getAttributeValue("useProjectSettings")?.let { useProjectSettings = it.toBoolean() } + val targetPlatform = element.getFacetPlatformByConfigurationElement() + this.targetPlatform = targetPlatform + readElementsList(element, "implements", "implement")?.let { implementedModuleNames = it } + readElementsList(element, "dependsOnModuleNames", "dependsOn")?.let { dependsOnModuleNames = it } + element.getChild("externalSystemTestTasks")?.let { + val testRunTasks = it.getChildren("externalSystemTestTask") + .mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim } + .mapNotNull { ExternalSystemTestRunTask.fromStringRepresentation(it) } + val nativeMainRunTasks = it.getChildren("externalSystemNativeMainRunTask") + .mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim } + .mapNotNull { ExternalSystemNativeMainRunTask.fromStringRepresentation(it) } + + externalSystemRunTasks = testRunTasks + nativeMainRunTasks + } + + element.getChild("sourceSets")?.let { + val items = it.getChildren("sourceSet") + sourceSetNames = items.mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim } + } + kind = element.getChild("newMppModelJpsModuleKind")?.let { + val kindName = (it.content.firstOrNull() as? Text)?.textTrim + if (kindName != null) { + try { + KotlinModuleKind.valueOf(kindName) + } catch (e: Exception) { + null + } + } else null + } ?: KotlinModuleKind.DEFAULT + isTestModule = element.getAttributeValue("isTestModule")?.toBoolean() ?: false + externalProjectId = element.getAttributeValue("externalProjectId") ?: "" + isHmppEnabled = element.getAttribute("isHmppProject")?.booleanValue ?: false + pureKotlinSourceFolders = element.getAttributeValue("pureKotlinSourceFolders")?.split(";")?.toList() ?: emptyList() + element.getChild("compilerSettings")?.let { + compilerSettings = CompilerSettings() + XmlSerializer.deserializeInto(compilerSettings!!, it) + } + element.getChild("compilerArguments")?.let { + compilerArguments = targetPlatform.createArguments { + freeArgs = mutableListOf() + internalArguments = mutableListOf() + } + XmlSerializer.deserializeInto(compilerArguments!!, it) + compilerArguments!!.detectVersionAutoAdvance() + } + productionOutputPath = element.getChild("productionOutputPath")?.let { + PathUtil.toSystemDependentName((it.content.firstOrNull() as? Text)?.textTrim) + } ?: (compilerArguments as? K2JSCompilerArguments)?.outputFile + testOutputPath = element.getChild("testOutputPath")?.let { + PathUtil.toSystemDependentName((it.content.firstOrNull() as? Text)?.textTrim) + } ?: (compilerArguments as? K2JSCompilerArguments)?.outputFile + } +} + +private fun readElementsList(element: Element, rootElementName: String, elementName: String): List? { + element.getChild(rootElementName)?.let { + val items = it.getChildren(elementName) + return if (items.isNotEmpty()) { + items.mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim } + } else { + listOfNotNull((it.content.firstOrNull() as? Text)?.textTrim) + } + } + return null +} + +private fun readV3Config(element: Element): KotlinFacetSettings { + return readV2AndLaterConfig(element) +} + +private fun readV2Config(element: Element): KotlinFacetSettings { + return readV2AndLaterConfig(element) +} + +private fun readLatestConfig(element: Element): KotlinFacetSettings { + return readV2AndLaterConfig(element) +} + +fun deserializeFacetSettings(element: Element): KotlinFacetSettings { + val version = try { + element.getAttribute("version")?.intValue + } catch (e: DataConversionException) { + null + } ?: KotlinFacetSettings.DEFAULT_VERSION + return when (version) { + 1 -> readV1Config(element) + 2 -> readV2Config(element) + 3 -> readV3Config(element) + KotlinFacetSettings.CURRENT_VERSION -> readLatestConfig(element) + else -> return KotlinFacetSettings() // Reset facet configuration if versions don't match + }.apply { this.version = version } +} + +fun CommonCompilerArguments.convertPathsToSystemIndependent() { + pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths!![index] = PathUtil.toSystemIndependentName(s) } + + when (this) { + is K2JVMCompilerArguments -> { + destination = PathUtil.toSystemIndependentName(destination) + classpath = PathUtil.toSystemIndependentName(classpath) + jdkHome = PathUtil.toSystemIndependentName(jdkHome) + kotlinHome = PathUtil.toSystemIndependentName(kotlinHome) + friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = PathUtil.toSystemIndependentName(s) } + declarationsOutputPath = PathUtil.toSystemIndependentName(declarationsOutputPath) + } + + is K2JSCompilerArguments -> { + outputFile = PathUtil.toSystemIndependentName(outputFile) + libraries = PathUtil.toSystemIndependentName(libraries) + } + + is K2MetadataCompilerArguments -> { + destination = PathUtil.toSystemIndependentName(destination) + classpath = PathUtil.toSystemIndependentName(classpath) + } + } +} + +fun CompilerSettings.convertPathsToSystemIndependent() { + scriptTemplatesClasspath = PathUtil.toSystemIndependentName(scriptTemplatesClasspath) + outputDirectoryForJsLibraryFiles = PathUtil.toSystemIndependentName(outputDirectoryForJsLibraryFiles) +} + +private fun KClass<*>.superClass() = superclasses.firstOrNull { !it.java.isInterface } + +private fun Class<*>.computeNormalPropertyOrdering(): Map { + val result = LinkedHashMap() + var count = 0 + generateSequence(this) { it.superclass }.forEach { clazz -> + for (field in clazz.declaredFields) { + if (field.modifiers and Modifier.STATIC != 0) continue + + var propertyName = field.name + if (propertyName.endsWith(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX)) { + propertyName = propertyName.dropLast(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX.length) + } + + result[propertyName] = count++ + } + } + return result +} + +private val allNormalOrderings = HashMap, Map>() + +private val Class<*>.normalOrdering + get() = synchronized(allNormalOrderings) { allNormalOrderings.getOrPut(this) { computeNormalPropertyOrdering() } } + +// Replacing fields with delegated properties leads to unexpected reordering of entries in facet configuration XML +// It happens due to XmlSerializer using different orderings for field- and method-based accessors +// This code restores the original ordering +private fun Element.restoreNormalOrdering(bean: Any) { + val normalOrdering = bean.javaClass.normalOrdering + val elementsToReorder = this.getContent { it is Element && it.getAttribute("name")?.value in normalOrdering } + elementsToReorder.sortedBy { normalOrdering[it.getAttribute("name")?.value!!] } + .forEachIndexed { index, element -> elementsToReorder[index] = element.clone() } +} + +private fun buildChildElement(element: Element, tag: String, bean: Any, filter: SerializationFilter): Element { + return Element(tag).apply { + XmlSerializer.serializeInto(bean, this, filter) + restoreNormalOrdering(bean) + element.addContent(this) + } +} + +private fun KotlinFacetSettings.writeLatestConfig(element: Element) { + val filter = SkipDefaultsSerializationFilter() + + // TODO: Introduce new version of facet serialization. See https://youtrack.jetbrains.com/issue/KT-38235 + // This is necessary to avoid having too much custom logic for platform serialization. + targetPlatform?.let { targetPlatform -> + element.setAttribute("platform", targetPlatform.oldFashionedDescription) + element.setAttribute("allPlatforms", targetPlatform.serializeComponentPlatforms()) + } + if (!useProjectSettings) { + element.setAttribute("useProjectSettings", useProjectSettings.toString()) + } + saveElementsList(element, implementedModuleNames, "implements", "implement") + saveElementsList(element, dependsOnModuleNames, "dependsOnModuleNames", "dependsOn") + + if (sourceSetNames.isNotEmpty()) { + element.addContent( + Element("sourceSets").apply { + sourceSetNames.map { addContent(Element("sourceSet").apply { addContent(it) }) } + } + ) + } + if (kind != KotlinModuleKind.DEFAULT) { + element.addContent(Element("newMppModelJpsModuleKind").apply { addContent(kind.name) }) + element.setAttribute("isTestModule", isTestModule.toString()) + } + if (externalProjectId.isNotEmpty()) { + element.setAttribute("externalProjectId", externalProjectId) + } + if (isHmppEnabled) { + element.setAttribute("isHmppProject", mppVersion.isHmpp.toString()) + } + if (externalSystemRunTasks.isNotEmpty()) { + element.addContent( + Element("externalSystemTestTasks").apply { + externalSystemRunTasks.forEach { task -> + when(task) { + is ExternalSystemTestRunTask -> { + addContent( + Element("externalSystemTestTask").apply { addContent(task.toStringRepresentation()) } + ) + } + is ExternalSystemNativeMainRunTask -> { + addContent( + Element("externalSystemNativeMainRunTask").apply { addContent(task.toStringRepresentation()) } + ) + } + } + } + } + ) + } + if (pureKotlinSourceFolders.isNotEmpty()) { + element.setAttribute("pureKotlinSourceFolders", pureKotlinSourceFolders.joinToString(";")) + } + productionOutputPath?.let { + if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) { + element.addContent(Element("productionOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) }) + } + } + testOutputPath?.let { + if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) { + element.addContent(Element("testOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) }) + } + } + compilerSettings?.let { copyBean(it) }?.let { + it.convertPathsToSystemIndependent() + buildChildElement(element, "compilerSettings", it, filter) + } + compilerArguments?.let { copyBean(it) }?.let { + it.convertPathsToSystemIndependent() + val compilerArgumentsXml = buildChildElement(element, "compilerArguments", it, filter) + compilerArgumentsXml.dropVersionsIfNecessary(it) + } +} + +private fun saveElementsList(element: Element, elementsList: List, rootElementName: String, elementName: String) { + if (elementsList.isNotEmpty()) { + element.addContent( + Element(rootElementName).apply { + val singleModule = elementsList.singleOrNull() + if (singleModule != null) { + addContent(singleModule) + } else { + elementsList.map { addContent(Element(elementName).apply { addContent(it) }) } + } + } + ) + } +} + +fun CommonCompilerArguments.detectVersionAutoAdvance() { + autoAdvanceLanguageVersion = languageVersion == null + autoAdvanceApiVersion = apiVersion == null +} + +fun Element.dropVersionsIfNecessary(settings: CommonCompilerArguments) { + // Do not serialize language/api version if they correspond to the default language version + if (settings.autoAdvanceLanguageVersion) { + getOption("languageVersion")?.detach() + } + + if (settings.autoAdvanceApiVersion) { + getOption("apiVersion")?.detach() + } +} + +fun KotlinFacetSettings.serializeFacetSettings(element: Element) { + val versionToWrite = when (version) { + 2, 3 -> version + else -> KotlinFacetSettings.CURRENT_VERSION + } + element.setAttribute("version", versionToWrite.toString()) + writeLatestConfig(element) +} + +private fun TargetPlatform.serializeComponentPlatforms(): String { + val componentPlatforms = componentPlatforms + val componentPlatformNames = componentPlatforms.mapTo(ArrayList()) { it.serializeToString() } + + // workaround for old Kotlin IDE plugins, KT-38634 + if (componentPlatforms.any { it is NativePlatform }) + componentPlatformNames.add(NativePlatformUnspecifiedTarget.legacySerializeToString()) + + return componentPlatformNames.sorted().joinToString("/") +} + +private fun String?.deserializeTargetPlatformByComponentPlatforms(): TargetPlatform? { + val componentPlatformNames = this?.split('/')?.toSet() + if (componentPlatformNames == null || componentPlatformNames.isEmpty()) + return null + + val knownComponentPlatforms = HashMap() // "serialization presentation" to "simple platform name" + + // first, collect serialization presentations for every known simple platform + CommonPlatforms.allSimplePlatforms + .flatMap { it.componentPlatforms } + .forEach { knownComponentPlatforms[it.serializeToString()] = it } + + // next, add legacy aliases for some of the simple platforms; ex: unspecifiedNativePlatform + NativePlatformUnspecifiedTarget.let { knownComponentPlatforms[it.legacySerializeToString()] = it } + + val componentPlatforms = componentPlatformNames.mapNotNull(knownComponentPlatforms::get).toSet() + return when (componentPlatforms.size) { + 0 -> { + // empty set of component platforms is not allowed, in such case fallback to legacy algorithm + null + } + 1 -> TargetPlatform(componentPlatforms) + else -> { + // workaround for old Kotlin IDE plugins, KT-38634 + if (componentPlatforms.any { it is NativePlatformUnspecifiedTarget } + && componentPlatforms.any { it is NativePlatformWithTarget } + ) { + TargetPlatform(componentPlatforms - NativePlatformUnspecifiedTarget) + } else { + TargetPlatform(componentPlatforms) + } + } + } +} diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/moduleSourceRootPropertiesSerializers.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/moduleSourceRootPropertiesSerializers.kt new file mode 100644 index 00000000000..f9b1c3d4b66 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/moduleSourceRootPropertiesSerializers.kt @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.config + +import org.jdom.Element +import org.jetbrains.jps.model.java.JavaResourceRootProperties +import org.jetbrains.jps.model.java.JavaSourceRootProperties +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModuleSourceRootType +import org.jetbrains.jps.model.serialization.module.JpsModuleRootModelSerializer +import org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer + +private const val IS_GENERATED_ATTRIBUTE = "generated" +private const val RELATIVE_OUTPUT_PATH_ATTRIBUTE = "relativeOutputPath" + +const val KOTLIN_SOURCE_ROOT_TYPE_ID = "kotlin-source" +const val KOTLIN_TEST_ROOT_TYPE_ID = "kotlin-test" +const val KOTLIN_RESOURCE_ROOT_TYPE_ID = "kotlin-resource" +const val KOTLIN_TEST_RESOURCE_ROOT_TYPE_ID = "kotlin-test-resource" + +// Based on org.jetbrains.jps.model.serialization.java.JpsJavaModelSerializerExtension.JavaSourceRootPropertiesSerializer class +sealed class KotlinSourceRootPropertiesSerializer( + type: JpsModuleSourceRootType, + typeId: String +) : JpsModuleSourceRootPropertiesSerializer(type, typeId) { + object Source : KotlinSourceRootPropertiesSerializer( + SourceKotlinRootType, + KOTLIN_SOURCE_ROOT_TYPE_ID + ) + + object TestSource : KotlinSourceRootPropertiesSerializer( + TestSourceKotlinRootType, + KOTLIN_TEST_ROOT_TYPE_ID + ) + + override fun loadProperties(sourceRootTag: Element): JavaSourceRootProperties { + val packagePrefix = sourceRootTag.getAttributeValue(JpsModuleRootModelSerializer.PACKAGE_PREFIX_ATTRIBUTE) ?: "" + val isGenerated = sourceRootTag.getAttributeValue(IS_GENERATED_ATTRIBUTE)?.toBoolean() ?: false + return JpsJavaExtensionService.getInstance().createSourceRootProperties(packagePrefix, isGenerated) + } + + override fun saveProperties(properties: JavaSourceRootProperties, sourceRootTag: Element) { + val packagePrefix = properties.packagePrefix + if (packagePrefix.isNotEmpty()) { + sourceRootTag.setAttribute(JpsModuleRootModelSerializer.PACKAGE_PREFIX_ATTRIBUTE, packagePrefix) + } + if (properties.isForGeneratedSources) { + sourceRootTag.setAttribute(IS_GENERATED_ATTRIBUTE, "true") + } + } +} + +// Based on org.jetbrains.jps.model.serialization.java.JpsJavaModelSerializerExtension.JavaResourceRootPropertiesSerializer +sealed class KotlinResourceRootPropertiesSerializer( + type: JpsModuleSourceRootType, + typeId: String +) : JpsModuleSourceRootPropertiesSerializer(type, typeId) { + object Resource : KotlinResourceRootPropertiesSerializer( + ResourceKotlinRootType, + KOTLIN_RESOURCE_ROOT_TYPE_ID + ) + + object TestResource : KotlinResourceRootPropertiesSerializer( + TestResourceKotlinRootType, + KOTLIN_TEST_RESOURCE_ROOT_TYPE_ID + ) + + override fun loadProperties(sourceRootTag: Element): JavaResourceRootProperties { + val relativeOutputPath = sourceRootTag.getAttributeValue(RELATIVE_OUTPUT_PATH_ATTRIBUTE) ?: "" + val isGenerated = sourceRootTag.getAttributeValue(IS_GENERATED_ATTRIBUTE)?.toBoolean() ?: false + return JpsJavaExtensionService.getInstance().createResourceRootProperties(relativeOutputPath, isGenerated) + } + + override fun saveProperties(properties: JavaResourceRootProperties, sourceRootTag: Element) { + val relativeOutputPath = properties.relativeOutputPath + if (relativeOutputPath.isNotEmpty()) { + sourceRootTag.setAttribute(RELATIVE_OUTPUT_PATH_ATTRIBUTE, relativeOutputPath) + } + if (properties.isForGeneratedSources) { + sourceRootTag.setAttribute(IS_GENERATED_ATTRIBUTE, "true") + } + } +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/DefaultIdeTargetPlatformKindProvider.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/DefaultIdeTargetPlatformKindProvider.kt new file mode 100644 index 00000000000..47f69690e16 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/DefaultIdeTargetPlatformKindProvider.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.platform + +import com.intellij.openapi.components.ServiceManager +import org.jetbrains.kotlin.config.isJps +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.platform.TargetPlatform + +interface DefaultIdeTargetPlatformKindProvider { + val defaultPlatform: TargetPlatform + + companion object { + val defaultPlatform: TargetPlatform + get() { + if (isJps) { + // TODO support passing custom platforms in JPS + return JvmPlatforms.defaultJvmPlatform + } + + return ServiceManager.getService(DefaultIdeTargetPlatformKindProvider::class.java).defaultPlatform + } + } +} + +fun TargetPlatform?.orDefault(): TargetPlatform { + return this ?: DefaultIdeTargetPlatformKindProvider.defaultPlatform +} + +fun IdePlatformKind<*>?.orDefault(): IdePlatformKind<*> { + return this ?: DefaultIdeTargetPlatformKindProvider.defaultPlatform.idePlatformKind +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatform.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatform.kt new file mode 100644 index 00000000000..03747c37be5 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatform.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.platform + +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.utils.DescriptionAware + +@Suppress("DEPRECATION_ERROR") +@Deprecated( + message = "This interface is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead", + replaceWith = ReplaceWith("TargetPlatform", "org.jetbrains.kotlin.platform.TargetPlatform"), + level = DeprecationLevel.ERROR +) +abstract class IdePlatform, out Arguments : CommonCompilerArguments> : DescriptionAware { + abstract val kind: Kind + abstract val version: TargetPlatformVersion + + abstract fun createArguments(init: Arguments.() -> Unit = {}): Arguments + + override val description + get() = kind.name + " " + version.description + + override fun toString() = description +} diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt new file mode 100644 index 00000000000..fe75bbad037 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:JvmName("IdePlatformKindUtil") + +package org.jetbrains.kotlin.platform + +import com.intellij.openapi.diagnostic.Logger +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.config.isJps +import org.jetbrains.kotlin.extensions.ApplicationExtensionDescriptor +import org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind +import org.jetbrains.kotlin.platform.impl.JsIdePlatformKind +import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind +import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind +import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult + +abstract class IdePlatformKind> { + abstract fun supportsTargetPlatform(platform: TargetPlatform): Boolean + + abstract val defaultPlatform: TargetPlatform + + @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + abstract fun getDefaultPlatform(): IdePlatform<*, *> + + abstract fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? + + abstract val argumentsClass: Class + + abstract val name: String + + abstract fun createArguments(): CommonCompilerArguments + + override fun equals(other: Any?): Boolean = javaClass == other?.javaClass + override fun hashCode(): Int = javaClass.hashCode() + + override fun toString() = name + + companion object { + // We can't use the ApplicationExtensionDescriptor class directly because it's missing in the JPS process + private val extension = run { + if (isJps) return@run null + ApplicationExtensionDescriptor("org.jetbrains.kotlin.idePlatformKind", IdePlatformKind::class.java) + } + + // For using only in JPS + private val JPS_KINDS + get() = listOf( + JvmIdePlatformKind, + JsIdePlatformKind, + CommonIdePlatformKind, + NativeIdePlatformKind + ) + + val ALL_KINDS by lazy { + val kinds = extension?.getInstances() ?: return@lazy JPS_KINDS + require(kinds.isNotEmpty()) { "Platform kind list is empty" } + kinds + } + + + fun platformByCompilerArguments(arguments: Args): TargetPlatform? = + ALL_KINDS.firstNotNullResult { it.platformByCompilerArguments(arguments) } + + } +} + +val TargetPlatform.idePlatformKind: IdePlatformKind<*> + get() = IdePlatformKind.ALL_KINDS.filter { it.supportsTargetPlatform(this) }.let { list -> + when { + list.size == 1 -> list.first() + list.size > 1 -> list.first().also { + Logger.getInstance(IdePlatformKind.javaClass).warn("Found more than one IdePlatformKind [$list] for target [$this].") + } + else -> error("Unknown platform $this") + } + } \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/compat/compatConversions.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/compat/compatConversions.kt new file mode 100644 index 00000000000..2b8d7d2ea87 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/compat/compatConversions.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("DEPRECATION_ERROR", "TYPEALIAS_EXPANSION_DEPRECATION_ERROR") + +package org.jetbrains.kotlin.platform.compat + +import org.jetbrains.kotlin.config.JvmTarget +import org.jetbrains.kotlin.platform.CommonPlatforms +import org.jetbrains.kotlin.platform.IdePlatform +import org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind +import org.jetbrains.kotlin.platform.impl.JsIdePlatformKind +import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind +import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind +import org.jetbrains.kotlin.platform.js.JsPlatform +import org.jetbrains.kotlin.platform.js.JsPlatforms +import org.jetbrains.kotlin.platform.jvm.JdkPlatform +import org.jetbrains.kotlin.platform.jvm.JvmPlatform +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.platform.konan.NativePlatforms +import org.jetbrains.kotlin.platform.konan.NativePlatform + +typealias OldPlatform = org.jetbrains.kotlin.resolve.TargetPlatform +typealias NewPlatform = org.jetbrains.kotlin.platform.TargetPlatform + +fun NewPlatform.toOldPlatform(): OldPlatform = when (val single = singleOrNull()) { + null -> CommonPlatforms.CompatCommonPlatform + is JvmPlatform -> JvmPlatforms.CompatJvmPlatform + is JsPlatform -> JsPlatforms.CompatJsPlatform + is NativePlatform -> NativePlatforms.CompatNativePlatform + else -> error("Unknown platform $single") +} + +fun OldPlatform.toNewPlatform(): NewPlatform = when (this) { + is CommonPlatforms.CompatCommonPlatform -> this + is JvmPlatforms.CompatJvmPlatform -> this + is JsPlatforms.CompatJsPlatform -> this + is NativePlatforms.CompatNativePlatform -> this + else -> error( + "Can't convert org.jetbrains.kotlin.resolve.TargetPlatform to org.jetbrains.kotlin.platform.TargetPlatform: " + + "non-Compat instance passed\n" + + "toString: $this\n" + + "class: ${this::class}\n" + + "hashCode: ${this.hashCode().toString(16)}" + ) +} + +fun IdePlatform<*, *>.toNewPlatform(): NewPlatform = when (this) { + is CommonIdePlatformKind.Platform -> CommonPlatforms.defaultCommonPlatform + is JvmIdePlatformKind.Platform -> JvmPlatforms.jvmPlatformByTargetVersion(this.version) + is JsIdePlatformKind.Platform -> JsPlatforms.defaultJsPlatform + is NativeIdePlatformKind.Platform -> NativePlatforms.unspecifiedNativePlatform + else -> error("Unknown platform $this") +} + +fun NewPlatform.toIdePlatform(): IdePlatform<*, *> = when (val single = singleOrNull()) { + null -> CommonIdePlatformKind.Platform + is JdkPlatform -> JvmIdePlatformKind.Platform(single.targetVersion) + is JvmPlatform -> JvmIdePlatformKind.Platform(JvmTarget.DEFAULT) + is JsPlatform -> JsIdePlatformKind.Platform + is NativePlatform -> NativeIdePlatformKind.Platform + else -> error("Unknown platform $single") +} diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/CommonIdePlatformKind.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/CommonIdePlatformKind.kt new file mode 100644 index 00000000000..6200b08bc08 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/CommonIdePlatformKind.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:JvmName("CommonIdePlatformUtil") +@file:Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") + +package org.jetbrains.kotlin.platform.impl + +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.platform.* + +object CommonIdePlatformKind : IdePlatformKind() { + override fun supportsTargetPlatform(platform: TargetPlatform) = platform.isCommon() + + override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? { + return if (arguments is K2MetadataCompilerArguments) + CommonPlatforms.defaultCommonPlatform + else + null + } + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + override fun getDefaultPlatform(): IdePlatform<*, *> = Platform + + override fun createArguments(): CommonCompilerArguments { + return K2MetadataCompilerArguments() // TODO(dsavvinov): review that, as now MPP !== K2Metadata + } + + override val defaultPlatform get() = CommonPlatforms.defaultCommonPlatform + + override val argumentsClass get() = K2MetadataCompilerArguments::class.java + + override val name get() = "Common (experimental)" + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + object Platform : IdePlatform() { + override val kind get() = CommonIdePlatformKind + override val version get() = TargetPlatformVersion.NoVersion + override fun createArguments(init: CommonCompilerArguments.() -> Unit) = K2MetadataCompilerArguments().apply(init) + } +} + +val IdePlatformKind<*>?.isCommon + get() = this is CommonIdePlatformKind + +@Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR +) +val IdePlatform<*, *>.isCommon: Boolean + get() = this is CommonIdePlatformKind.Platform \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/IdeaDefaultIdeTargetPlatformKindProvider.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/IdeaDefaultIdeTargetPlatformKindProvider.kt new file mode 100644 index 00000000000..b59c2f974dc --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/IdeaDefaultIdeTargetPlatformKindProvider.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.platform.impl + +import org.jetbrains.kotlin.platform.DefaultIdeTargetPlatformKindProvider + +class IdeaDefaultIdeTargetPlatformKindProvider private constructor() : DefaultIdeTargetPlatformKindProvider { + override val defaultPlatform = JvmIdePlatformKind.defaultPlatform +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt new file mode 100644 index 00000000000..6b145c67ceb --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/JsIdePlatformKind.kt @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:JvmName("JsIdePlatformUtil") +@file:Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") + +package org.jetbrains.kotlin.platform.impl + +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.platform.IdePlatform +import org.jetbrains.kotlin.platform.IdePlatformKind +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.TargetPlatformVersion +import org.jetbrains.kotlin.platform.js.JsPlatforms +import org.jetbrains.kotlin.platform.js.isJs + +object JsIdePlatformKind : IdePlatformKind() { + override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isJs() + + override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? { + return if (arguments is K2JSCompilerArguments) + JsPlatforms.defaultJsPlatform + else + null + } + + val platforms get() = listOf(JsPlatforms.defaultJsPlatform) + override val defaultPlatform get() = JsPlatforms.defaultJsPlatform + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + override fun getDefaultPlatform(): IdePlatform<*, *> = Platform + + override fun createArguments(): CommonCompilerArguments { + return K2JSCompilerArguments() + } + + override val argumentsClass get() = K2JSCompilerArguments::class.java + + override val name get() = "JavaScript" + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + object Platform : IdePlatform() { + override val kind get() = JsIdePlatformKind + override val version get() = TargetPlatformVersion.NoVersion + override fun createArguments(init: K2JSCompilerArguments.() -> Unit) = K2JSCompilerArguments().apply(init) + } +} + +val IdePlatformKind<*>?.isJavaScript + get() = this is JsIdePlatformKind + +@Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR +) +val IdePlatform<*, *>?.isJavaScript + get() = this is JsIdePlatformKind.Platform diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt new file mode 100644 index 00000000000..378d3da152d --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/JvmIdePlatformKind.kt @@ -0,0 +1,77 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:JvmName("JvmIdePlatformUtil") +@file:Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") + +package org.jetbrains.kotlin.platform.impl + +import com.intellij.util.text.VersionComparatorUtil +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.config.JvmTarget +import org.jetbrains.kotlin.platform.IdePlatform +import org.jetbrains.kotlin.platform.IdePlatformKind +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.platform.jvm.isJvm + +object JvmIdePlatformKind : IdePlatformKind() { + override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isJvm() + + override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? { + if (arguments !is K2JVMCompilerArguments) return null + + val jvmTargetDescription = arguments.jvmTarget + ?: return JvmPlatforms.defaultJvmPlatform + + val jvmTarget = JvmTarget.values() + .firstOrNull { VersionComparatorUtil.COMPARATOR.compare(it.description, jvmTargetDescription) >= 0 } + ?: return JvmPlatforms.defaultJvmPlatform + + return JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget) + } + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + override fun getDefaultPlatform(): Platform = Platform(JvmTarget.DEFAULT) + + override fun createArguments(): CommonCompilerArguments { + return K2JVMCompilerArguments() + } + + val platforms: List = JvmTarget.values() + .map { ver -> JvmPlatforms.jvmPlatformByTargetVersion(ver) } + listOf(JvmPlatforms.unspecifiedJvmPlatform) + + override val defaultPlatform get() = JvmPlatforms.defaultJvmPlatform + + override val argumentsClass get() = K2JVMCompilerArguments::class.java + + override val name get() = "JVM" + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + data class Platform(override val version: JvmTarget) : IdePlatform() { + override val kind get() = JvmIdePlatformKind + + override fun createArguments(init: K2JVMCompilerArguments.() -> Unit) = K2JVMCompilerArguments() + .apply(init) + .apply { jvmTarget = this@Platform.version.description } + } +} + +val IdePlatformKind<*>?.isJvm + get() = this is JvmIdePlatformKind + +@Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR +) +val IdePlatform<*, *>.isJvm: Boolean + get() = this is JvmIdePlatformKind.Platform \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/NativeIdePlatformKind.kt b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/NativeIdePlatformKind.kt new file mode 100644 index 00000000000..d6ab4adfa55 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/platform/impl/NativeIdePlatformKind.kt @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:JvmName("NativeIdePlatformUtil") +@file:Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith") + +package org.jetbrains.kotlin.platform.impl + +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.platform.IdePlatform +import org.jetbrains.kotlin.platform.IdePlatformKind +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.TargetPlatformVersion +import org.jetbrains.kotlin.platform.konan.NativePlatforms +import org.jetbrains.kotlin.platform.konan.isNative + +object NativeIdePlatformKind : IdePlatformKind() { + override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isNative() + + override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? { + return if (arguments is FakeK2NativeCompilerArguments) + NativePlatforms.unspecifiedNativePlatform + else + null + } + + override fun createArguments(): CommonCompilerArguments { + return FakeK2NativeCompilerArguments() + } + + override val defaultPlatform: TargetPlatform + get() = NativePlatforms.unspecifiedNativePlatform + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + override fun getDefaultPlatform(): IdePlatform<*, *> = Platform + + override val argumentsClass + get() = FakeK2NativeCompilerArguments::class.java + + override val name + get() = "Native" + + @Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR + ) + object Platform : IdePlatform() { + override val kind get() = NativeIdePlatformKind + override val version get() = TargetPlatformVersion.NoVersion + override fun createArguments(init: FakeK2NativeCompilerArguments.() -> Unit) = FakeK2NativeCompilerArguments().apply(init) + } +} + +// These are fake compiler arguments for Kotlin/Native - only for usage within IDEA plugin: +class FakeK2NativeCompilerArguments : CommonCompilerArguments() + +val IdePlatformKind<*>?.isKotlinNative + get() = this is NativeIdePlatformKind + +@Deprecated( + message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform", + level = DeprecationLevel.ERROR +) +val IdePlatform<*, *>?.isKotlinNative + get() = this is NativeIdePlatformKind.Platform diff --git a/jps/jps-plugin/build.gradle.kts b/jps/jps-plugin/build.gradle.kts new file mode 100644 index 00000000000..de19db01850 --- /dev/null +++ b/jps/jps-plugin/build.gradle.kts @@ -0,0 +1,71 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +val compilerModules: Array by rootProject.extra + +dependencies { + compile(project(":kotlin-build-common")) + compile(project(":core:descriptors")) + compile(project(":core:descriptors.jvm")) + compile(project(":kotlin-compiler-runner")) + compile(project(":daemon-common")) + compile(project(":daemon-common-new")) + compile(projectRuntimeJar(":kotlin-daemon-client")) + compile(projectRuntimeJar(":kotlin-daemon")) + compile(project(":compiler:frontend.java")) + compile(project(":js:js.frontend")) + compile(projectRuntimeJar(":kotlin-preloader")) + compile(project(":idea:idea-jps-common")) + Platform[193].orLower { + compileOnly(intellijDep()) { includeJars("openapi", rootProject = rootProject) } + } + compileOnly(intellijDep()) { + includeJars("jdom", "trove4j", "jps-model", "platform-api", "util", "asm-all", rootProject = rootProject) + } + compileOnly(jpsStandalone()) { includeJars("jps-builders", "jps-builders-6") } + testCompileOnly(project(":kotlin-reflect-api")) + testCompile(project(":compiler:incremental-compilation-impl")) + testCompile(projectTests(":compiler:tests-common")) + testCompile(projectTests(":compiler:incremental-compilation-impl")) + testCompile(commonDep("junit:junit")) + testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectTests(":kotlin-build-common")) + testCompileOnly(jpsStandalone()) { includeJars("jps-builders", "jps-builders-6") } + Ide.IJ { + testCompile(intellijDep("devkit")) + } + + testCompile(intellijDep()) + + testCompile(jpsBuildTest()) + compilerModules.forEach { + testRuntime(project(it)) + } + + testRuntimeOnly(intellijPluginDep("java")) + + testRuntimeOnly(toolsJar()) + testRuntime(project(":kotlin-reflect")) + testRuntime(project(":kotlin-script-runtime")) +} + +sourceSets { + "main" { projectDefault() } + "test" { + Ide.IJ { + java.srcDirs("jps-tests/test") + } + } +} + +projectTest(parallel = true) { + // do not replace with compile/runtime dependency, + // because it forces Intellij reindexing after each compiler change + dependsOn(":kotlin-compiler:dist") + dependsOn(":kotlin-stdlib-js-ir:packFullRuntimeKLib") + workingDir = rootDir +} + +testsJar {} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractDataContainerVersionChangedTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractDataContainerVersionChangedTest.kt new file mode 100644 index 00000000000..fa7076627e4 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractDataContainerVersionChangedTest.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget + +/** + * @see [jps-plugin/testData/incremental/cacheVersionChanged/README.md] + */ +abstract class AbstractDataContainerVersionChangedTest : AbstractIncrementalCacheVersionChangedTest() { + override val buildLogFinder: BuildLogFinder + get() = BuildLogFinder(isDataContainerBuildLogEnabled = true) + + override fun getVersionManagersToTest(target: KotlinModuleBuildTarget<*>) = + listOf(kotlinCompileContext.lookupsCacheAttributesManager.versionManagerForTesting) +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalCacheVersionChangedTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalCacheVersionChangedTest.kt new file mode 100644 index 00000000000..0369db33eb3 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalCacheVersionChangedTest.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.kotlin.incremental.testingUtils.Modification +import org.jetbrains.kotlin.incremental.testingUtils.ModifyContent +import org.jetbrains.kotlin.jps.incremental.CacheVersionManager +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget + +/** + * @see [jps-plugin/testData/incremental/cacheVersionChanged/README.md] + */ +abstract class AbstractIncrementalCacheVersionChangedTest : AbstractIncrementalJvmJpsTest(allowNoFilesWithSuffixInTestData = true) { + override fun performAdditionalModifications(modifications: List) { + val modifiedFiles = modifications.filterIsInstance().map { it.path } + val targets = projectDescriptor.allModuleTargets + val hasKotlin = HasKotlinMarker(projectDescriptor.dataManager) + + if (modifiedFiles.any { it.endsWith("clear-has-kotlin") }) { + targets.forEach { hasKotlin.clean(it) } + } + + if (modifiedFiles.none { it.endsWith("do-not-change-cache-versions") }) { + val versions = targets.flatMap { + getVersionManagersToTest(kotlinCompileContext.targetsBinding[it]!!) + } + + versions.forEach { + if (it.versionFileForTesting.exists()) { + it.versionFileForTesting.writeText("777") + } + } + } + } + + protected open fun getVersionManagersToTest(target: KotlinModuleBuildTarget<*>): List = + listOf(target.localCacheVersionManager) +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt new file mode 100644 index 00000000000..62ab22a1cc1 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -0,0 +1,683 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build +import com.intellij.openapi.Disposable +import com.intellij.openapi.util.Disposer +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.testFramework.TestLoggerFactory +import com.intellij.testFramework.UsefulTestCase +import junit.framework.TestCase +import org.apache.log4j.ConsoleAppender +import org.apache.log4j.Level +import org.apache.log4j.Logger +import org.apache.log4j.PatternLayout +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.api.CanceledStatus +import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.CompileScopeTestBuilder +import org.jetbrains.jps.builders.impl.BuildDataPathsImpl +import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerBase +import org.jetbrains.jps.builders.java.dependencyView.Callbacks +import org.jetbrains.jps.builders.logging.BuildLoggingManager +import org.jetbrains.jps.cmdline.ProjectDescriptor +import org.jetbrains.jps.incremental.* +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.model.JpsDummyElement +import org.jetbrains.jps.model.JpsModuleRootModificationUtil +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.library.sdk.JpsSdk +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments +import org.jetbrains.kotlin.incremental.LookupSymbol +import org.jetbrains.kotlin.incremental.testingUtils.* +import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt +import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxtBuilder +import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture +import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff +import org.jetbrains.kotlin.jps.incremental.CacheVersionManager +import org.jetbrains.kotlin.jps.incremental.CompositeLookupsCacheAttributesManager +import org.jetbrains.kotlin.jps.incremental.getKotlinCache +import org.jetbrains.kotlin.jps.model.JpsKotlinFacetModuleExtension +import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinFacet +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.platform.idePlatformKind +import org.jetbrains.kotlin.platform.impl.isJavaScript +import org.jetbrains.kotlin.platform.impl.isJvm +import org.jetbrains.kotlin.platform.orDefault +import org.jetbrains.kotlin.utils.Printer +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.PrintStream +import java.util.* +import kotlin.reflect.jvm.javaField + +abstract class AbstractIncrementalJpsTest( + private val allowNoFilesWithSuffixInTestData: Boolean = false, + private val checkDumpsCaseInsensitively: Boolean = false +) : BaseKotlinJpsBuildTestCase() { + companion object { + private val COMPILATION_FAILED = "COMPILATION FAILED" + + // change to "/tmp" or anything when default is too long (for easier debugging) + private val TEMP_DIRECTORY_TO_USE = File(FileUtilRt.getTempDirectory()) + + private val DEBUG_LOGGING_ENABLED = System.getProperty("debug.logging.enabled") == "true" + + private const val ARGUMENTS_FILE_NAME = "args.txt" + + private fun parseAdditionalArgs(testDir: File): List { + return File(testDir, ARGUMENTS_FILE_NAME) + .takeIf { it.exists() } + ?.readText() + ?.split(" ", "\n") + ?.filter { it.isNotBlank() } + ?: emptyList() + } + } + + protected lateinit var testDataDir: File + protected lateinit var workDir: File + protected lateinit var projectDescriptor: ProjectDescriptor + protected lateinit var additionalCommandLineArguments: List + // is used to compare lookup dumps in a human readable way (lookup symbols are hashed in an actual lookup storage) + protected lateinit var lookupsDuringTest: MutableSet + private var isJvmICEnabledBackup: Boolean = false + private var isJsICEnabledBackup: Boolean = false + + protected var mapWorkingToOriginalFile: MutableMap = hashMapOf() + + lateinit var kotlinCompileContext: KotlinCompileContext + + protected open val buildLogFinder: BuildLogFinder + get() = BuildLogFinder() + + private fun enableDebugLogging() { + com.intellij.openapi.diagnostic.Logger.setFactory(TestLoggerFactory::class.java) + TestLoggerFactory.dumpLogToStdout("") + TestLoggerFactory.enableDebugLogging(testRootDisposable, "#org") + + val console = ConsoleAppender() + console.layout = PatternLayout("%d [%p|%c|%C{1}] %m%n") + console.threshold = Level.ALL + console.activateOptions() + Logger.getRootLogger().addAppender(console) + } + + private var systemPropertiesBackup = run { + val props = System.getProperties() + val output = ByteArrayOutputStream() + props.store(output, "System properties backup") + output.toByteArray() + } + + private fun restoreSystemProperties() { + val input = ByteArrayInputStream(systemPropertiesBackup) + val props = Properties() + props.load(input) + System.setProperties(props) + } + + private val enableICFixture = EnableICFixture() + + override fun setUp() { + super.setUp() + + enableICFixture.setUp() + lookupsDuringTest = hashSetOf() + + if (DEBUG_LOGGING_ENABLED) { + enableDebugLogging() + } + } + + override fun tearDown() { + restoreSystemProperties() + + (AbstractIncrementalJpsTest::myProject).javaField!![this] = null + (AbstractIncrementalJpsTest::projectDescriptor).javaField!![this] = null + (AbstractIncrementalJpsTest::systemPropertiesBackup).javaField!![this] = null + + lookupsDuringTest.clear() + enableICFixture.tearDown() + super.tearDown() + } + + // JPS forces rebuild of all files when JVM constant has been changed and Callbacks.ConstantAffectionResolver + // is not provided, so ConstantAffectionResolver is mocked with empty implementation + // Usages in Kotlin files are expected to be found by KotlinLookupConstantSearch + protected open val mockConstantSearch: Callbacks.ConstantAffectionResolver? + get() = MockJavaConstantSearch(workDir) + + private fun build( + name: String?, + scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules() + ): MakeResult { + val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath) + + val logger = MyLogger(workDirPath) + projectDescriptor = createProjectDescriptor(BuildLoggingManager(logger)) + + val lookupTracker = TestLookupTracker() + val testingContext = TestingContext(lookupTracker, logger) + projectDescriptor.project.setTestingContext(testingContext) + + try { + val builder = IncProjectBuilder( + projectDescriptor, + BuilderRegistry.getInstance(), + myBuildParams, + CanceledStatus.NULL, + true + ) + val buildResult = BuildResult() + builder.addMessageHandler(buildResult) + val finalScope = scope.build() + projectDescriptor.project.kotlinCommonCompilerArguments = projectDescriptor.project.kotlinCommonCompilerArguments.apply { + updateCommandLineArguments(this) + } + + builder.build(finalScope, false) + + // testingContext.kotlinCompileContext is initialized in KotlinBuilder.initializeKotlinContext + kotlinCompileContext = testingContext.kotlinCompileContext!! + + lookupTracker.lookups.mapTo(lookupsDuringTest) { LookupSymbol(it.name, it.scopeFqName) } + + if (!buildResult.isSuccessful) { + val errorMessages = + buildResult + .getMessages(BuildMessage.Kind.ERROR) + .map { it.messageText } + .map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() } + .joinToString("\n") + return MakeResult( + log = logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", + makeFailed = true, + mappingsDump = null, + name = name + ) + } else { + return MakeResult( + log = logger.log, + makeFailed = false, + mappingsDump = createMappingsDump(projectDescriptor, kotlinCompileContext, lookupsDuringTest), + name = name + ) + } + } finally { + projectDescriptor.dataManager.flush(false) + projectDescriptor.release() + } + } + + private fun initialMake(): MakeResult { + val makeResult = build(null) + + val initBuildLogFile = File(testDataDir, "init-build.log") + if (initBuildLogFile.exists()) { + UsefulTestCase.assertSameLinesWithFile(initBuildLogFile.absolutePath, makeResult.log) + } else { + assertFalse("Initial make failed:\n$makeResult", makeResult.makeFailed) + } + + return makeResult + } + + private fun make(name: String?): MakeResult { + return build(name) + } + + private fun rebuild(): MakeResult { + return build(null, CompileScopeTestBuilder.rebuild().allModules()) + } + + private fun updateCommandLineArguments(arguments: CommonCompilerArguments) { + parseCommandLineArguments(additionalCommandLineArguments, arguments) + } + + private fun rebuildAndCheckOutput(makeOverallResult: MakeResult) { + val outDir = File(getAbsolutePath("out")) + val outAfterMake = File(getAbsolutePath("out-after-make")) + + if (outDir.exists()) { + FileUtil.copyDir(outDir, outAfterMake) + } + + val rebuildResult = rebuild() + assertEquals( + "Rebuild failed: ${rebuildResult.makeFailed}, last make failed: ${makeOverallResult.makeFailed}. Rebuild result: $rebuildResult", + rebuildResult.makeFailed, makeOverallResult.makeFailed + ) + + if (!outAfterMake.exists()) { + assertFalse(outDir.exists()) + } else { + assertEqualDirectories(outDir, outAfterMake, makeOverallResult.makeFailed) + } + + if (!makeOverallResult.makeFailed) { + if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.toLowerCase() == makeOverallResult.mappingsDump?.toLowerCase()) { + // do nothing + } else { + TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump) + } + } + + FileUtil.delete(outAfterMake) + } + + private fun clearCachesRebuildAndCheckOutput(makeOverallResult: MakeResult) { + FileUtil.delete(BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot!!) + + rebuildAndCheckOutput(makeOverallResult) + } + + open val modulesTxtFile + get() = File(testDataDir, "dependencies.txt") + + private fun readModulesTxt(): ModulesTxt? { + var actualModulesTxtFile = modulesTxtFile + + if (!actualModulesTxtFile.exists()) { + // also try `"_${fileName}.txt"`. Useful for sorting files in IDE. + actualModulesTxtFile = modulesTxtFile.parentFile.resolve("_" + modulesTxtFile.name) + if (!actualModulesTxtFile.exists()) return null + } + + return ModulesTxtBuilder().readFile(actualModulesTxtFile) + } + + protected open fun createBuildLog(incrementalMakeResults: List): String = + buildString { + incrementalMakeResults.forEachIndexed { i, makeResult -> + if (i > 0) append("\n") + if (makeResult.name != null) { + append("================ Step #${i + 1} ${makeResult.name} =================\n\n") + } else { + append("================ Step #${i + 1} =================\n\n") + } + append(makeResult.log) + } + } + + protected open fun doTest(testDataPath: String) { + testDataDir = File(testDataPath) + workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "aijt-jps-build", null) + additionalCommandLineArguments = parseAdditionalArgs(File(testDataPath)) + val buildLogFile = buildLogFinder.findBuildLog(testDataDir) + Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) }) + + val modulesTxt = configureModules() + if (modulesTxt?.muted == true) return + + initialMake() + + val otherMakeResults = performModificationsAndMake( + modulesTxt?.modules?.map { it.name }, + hasBuildLog = buildLogFile != null + ) + + buildLogFile?.let { + val logs = createBuildLog(otherMakeResults) + UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs) + + val lastMakeResult = otherMakeResults.last() + clearCachesRebuildAndCheckOutput(lastMakeResult) + } + } + + protected data class MakeResult( + val log: String, + val makeFailed: Boolean, + val mappingsDump: String?, + val name: String? = null + ) + + open val testDataSrc: File + get() = testDataDir + + private fun performModificationsAndMake( + moduleNames: Collection?, + hasBuildLog: Boolean + ): List { + val results = arrayListOf() + val modifications = getModificationsToPerform( + testDataSrc, + moduleNames, + allowNoFilesWithSuffixInTestData = allowNoFilesWithSuffixInTestData || !hasBuildLog, + touchPolicy = TouchPolicy.TIMESTAMP + ) + + if (!hasBuildLog) { + check(modifications.size == 1 && modifications.single().isEmpty()) { + "Bad test data: build steps are provided, but there is no `build.log` file" + } + return results + } + + val stepsTxt = File(testDataSrc, "_steps.txt") + val modificationNames = if (stepsTxt.exists()) stepsTxt.readLines() else null + + modifications.forEachIndexed { index, step -> + step.forEach { it.perform(workDir, mapWorkingToOriginalFile) } + performAdditionalModifications(step) + if (moduleNames == null) { + preProcessSources(File(workDir, "src")) + } else { + moduleNames.forEach { preProcessSources(File(workDir, "$it/src")) } + } + + val name = modificationNames?.getOrNull(index) + val makeResult = make(name) + results.add(makeResult) + } + return results + } + + protected open fun performAdditionalModifications(modifications: List) { + } + + protected open fun generateModuleSources(modulesTxt: ModulesTxt) = Unit + + // null means one module + private fun configureModules(): ModulesTxt? { + JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = + JpsPathUtil.pathToUrl(getAbsolutePath("out")) + + val jdk = addJdk("my jdk") + val modulesTxt = readModulesTxt() + mapWorkingToOriginalFile = hashMapOf() + + if (modulesTxt == null) configureSingleModuleProject(jdk) + else configureMultiModuleProject(modulesTxt, jdk) + + overrideModuleSettings() + configureRequiredLibraries() + + return modulesTxt + } + + open fun overrideModuleSettings() { + } + + private fun configureSingleModuleProject(jdk: JpsSdk?) { + addModule("module", arrayOf(getAbsolutePath("src")), null, null, jdk) + + val sourceDestinationDir = File(workDir, "src") + val sourcesMapping = copyTestSources(testDataDir, File(workDir, "src"), "") + mapWorkingToOriginalFile.putAll(sourcesMapping) + + preProcessSources(sourceDestinationDir) + } + + protected open val ModulesTxt.Module.sourceFilePrefix: String + get() = "${name}_" + + private fun configureMultiModuleProject( + modulesTxt: ModulesTxt, + jdk: JpsSdk? + ) { + modulesTxt.modules.forEach { module -> + module.jpsModule = addModule( + module.name, + arrayOf(getAbsolutePath("${module.name}/src")), + null, + null, + jdk + )!! + + val kotlinFacetSettings = module.kotlinFacetSettings + if (kotlinFacetSettings != null) { + val compilerArguments = kotlinFacetSettings.compilerArguments + if (compilerArguments is K2MetadataCompilerArguments) { + val out = getAbsolutePath("${module.name}/out") + File(out).mkdirs() + compilerArguments.destination = out + } else if (compilerArguments is K2JVMCompilerArguments) { + compilerArguments.disableDefaultScriptingPlugin = true + } + + module.jpsModule.container.setChild( + JpsKotlinFacetModuleExtension.KIND, + JpsKotlinFacetModuleExtension(kotlinFacetSettings) + ) + } + } + + modulesTxt.dependencies.forEach { + JpsModuleRootModificationUtil.addDependency( + it.from.jpsModule, it.to.jpsModule, + it.scope, it.exported + ) + } + + // configure module contents + generateModuleSources(modulesTxt) + modulesTxt.modules.forEach { module -> + val sourceDirName = "${module.name}/src" + val sourceDestinationDir = File(workDir, sourceDirName) + val sourcesMapping = copyTestSources(testDataSrc, sourceDestinationDir, module.sourceFilePrefix) + mapWorkingToOriginalFile.putAll(sourcesMapping) + + preProcessSources(sourceDestinationDir) + } + } + + private fun configureRequiredLibraries() { + myProject.modules.forEach { module -> + val platformKind = module.kotlinFacet?.settings?.targetPlatform?.idePlatformKind.orDefault() + + when { + platformKind.isJvm -> { + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JvmStdLib)) + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JvmTest)) + } + platformKind.isJavaScript -> { + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JsStdLib)) + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JsTest)) + } + } + } + } + + protected open fun preProcessSources(srcDir: File) { + } + + override fun doGetProjectDir(): File? = workDir + + internal class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase(), TestingBuildLogger { + private val markedDirtyBeforeRound = ArrayList() + private val markedDirtyAfterRound = ArrayList() + private val customMessages = mutableListOf() + + override fun invalidOrUnusedCache( + chunk: KotlinChunk?, + target: KotlinModuleBuildTarget<*>?, + attributesDiff: CacheAttributesDiff<*> + ) { + val cacheManager = attributesDiff.manager + val cacheTitle = when (cacheManager) { + is CacheVersionManager -> "Local cache for ${chunk ?: target}" + is CompositeLookupsCacheAttributesManager -> "Lookups cache" + else -> error("Unknown cache manager $cacheManager") + } + + logLine("$cacheTitle are ${attributesDiff.status}") + } + + override fun markedAsDirtyBeforeRound(files: Iterable) { + markedDirtyBeforeRound.addAll(files) + } + + override fun markedAsDirtyAfterRound(files: Iterable) { + markedDirtyAfterRound.addAll(files) + } + + override fun chunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + logDirtyFiles(markedDirtyBeforeRound) // files can be marked as dirty during build start (KotlinCompileContext initialization) + + if (!chunk.isDummy(context) && context.projectDescriptor.project.modules.size > 1) { + logLine("Building ${chunk.modules.sortedBy { it.name }.joinToString { it.name }}") + } + } + + override fun afterChunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + logDirtyFiles(markedDirtyBeforeRound) + } + + override fun addCustomMessage(message: String) { + customMessages.add(message) + } + + override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) { + customMessages.forEach { + logLine(it) + } + customMessages.clear() + logDirtyFiles(markedDirtyAfterRound) + logLine("Exit code: $exitCode") + logLine("------------------------------------------") + } + + private fun logDirtyFiles(files: MutableList) { + if (files.isEmpty()) return + + logLine("Marked as dirty by Kotlin:") + files.apply { + map { FileUtil.toSystemIndependentName(it.path) } + .sorted() + .forEach { logLine(it) } + + clear() + } + } + + private val logBuf = StringBuilder() + val log: String + get() = logBuf.toString() + + val compiledFiles = hashSetOf() + + override fun isEnabled(): Boolean = true + + override fun logCompiledFiles(files: MutableCollection?, builderName: String?, description: String?) { + super.logCompiledFiles(files, builderName, description) + + if (builderName == KotlinBuilder.KOTLIN_BUILDER_NAME) { + compiledFiles.addAll(files!!) + } + } + + override fun logLine(message: String?) { + logBuf.append(message!!.replace("^$rootPath/".toRegex(), " ")).append('\n') + } + } +} + +private fun createMappingsDump( + project: ProjectDescriptor, + kotlinContext: KotlinCompileContext, + lookupsDuringTest: Set +) = createKotlinCachesDump(project, kotlinContext, lookupsDuringTest) + "\n\n\n" + + createCommonMappingsDump(project) + "\n\n\n" + + createJavaMappingsDump(project) + +internal fun createKotlinCachesDump( + project: ProjectDescriptor, + kotlinContext: KotlinCompileContext, + lookupsDuringTest: Set +) = createKotlinIncrementalCacheDump(project, kotlinContext) + "\n\n\n" + + createLookupCacheDump(kotlinContext, lookupsDuringTest) + +private fun createKotlinIncrementalCacheDump( + project: ProjectDescriptor, + kotlinContext: KotlinCompileContext +): String { + return buildString { + for (target in project.allModuleTargets.sortedBy { it.presentableName }) { + val kotlinCache = project.dataManager.getKotlinCache(kotlinContext.targetsBinding[target]) + if (kotlinCache != null) { + append("\n") + append(kotlinCache.dump()) + append("\n\n\n") + } + } + } +} + +private fun createLookupCacheDump(kotlinContext: KotlinCompileContext, lookupsDuringTest: Set): String { + val sb = StringBuilder() + val p = Printer(sb) + p.println("Begin of Lookup Maps") + p.println() + + kotlinContext.lookupStorageManager.withLookupStorage { lookupStorage -> + lookupStorage.forceGC() + p.print(lookupStorage.dump(lookupsDuringTest)) + } + + p.println() + p.println("End of Lookup Maps") + return sb.toString() +} + +private fun createCommonMappingsDump(project: ProjectDescriptor): String { + val resultBuf = StringBuilder() + val result = Printer(resultBuf) + + result.println("Begin of SourceToOutputMap") + result.pushIndent() + + for (target in project.allModuleTargets) { + result.println(target) + result.pushIndent() + + val mapping = project.dataManager.getSourceToOutputMap(target) + mapping.sources.sorted().forEach { + val outputs = mapping.getOutputs(it)!!.sorted() + if (outputs.isNotEmpty()) { + result.println("source $it -> $outputs") + } + } + + result.popIndent() + } + + result.popIndent() + result.println("End of SourceToOutputMap") + + return resultBuf.toString() +} + +private fun createJavaMappingsDump(project: ProjectDescriptor): String { + val byteArrayOutputStream = ByteArrayOutputStream() + PrintStream(byteArrayOutputStream).use { + project.dataManager.mappings.toStream(it) + } + return byteArrayOutputStream.toString() +} + +internal val ProjectDescriptor.allModuleTargets: Collection + get() = buildTargetIndex.allTargets.filterIsInstance() + +private val EXPORTED_SUFFIX = "[exported]" diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 new file mode 100644 index 00000000000..557bd7ff795 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 @@ -0,0 +1,681 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build +import com.intellij.openapi.Disposable +import com.intellij.openapi.util.Disposer +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.testFramework.TestLoggerFactory +import com.intellij.testFramework.UsefulTestCase +import junit.framework.TestCase +import org.apache.log4j.ConsoleAppender +import org.apache.log4j.Level +import org.apache.log4j.Logger +import org.apache.log4j.PatternLayout +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.api.CanceledStatus +import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.CompileScopeTestBuilder +import org.jetbrains.jps.builders.impl.BuildDataPathsImpl +import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerBase +import org.jetbrains.jps.builders.java.dependencyView.Callbacks +import org.jetbrains.jps.builders.logging.BuildLoggingManager +import org.jetbrains.jps.cmdline.ProjectDescriptor +import org.jetbrains.jps.incremental.* +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.model.JpsDummyElement +import org.jetbrains.jps.model.JpsModuleRootModificationUtil +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.library.sdk.JpsSdk +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments +import org.jetbrains.kotlin.incremental.LookupSymbol +import org.jetbrains.kotlin.incremental.testingUtils.* +import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt +import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxtBuilder +import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture +import org.jetbrains.kotlin.jps.incremental.* +import org.jetbrains.kotlin.jps.model.JpsKotlinFacetModuleExtension +import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinFacet +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.platform.idePlatformKind +import org.jetbrains.kotlin.platform.impl.isJavaScript +import org.jetbrains.kotlin.platform.impl.isJvm +import org.jetbrains.kotlin.platform.orDefault +import org.jetbrains.kotlin.utils.Printer +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.PrintStream +import java.util.* +import kotlin.reflect.jvm.javaField + +abstract class AbstractIncrementalJpsTest( + private val allowNoFilesWithSuffixInTestData: Boolean = false, + private val checkDumpsCaseInsensitively: Boolean = false +) : BaseKotlinJpsBuildTestCase() { + companion object { + private val COMPILATION_FAILED = "COMPILATION FAILED" + + // change to "/tmp" or anything when default is too long (for easier debugging) + private val TEMP_DIRECTORY_TO_USE = File(FileUtilRt.getTempDirectory()) + + private val DEBUG_LOGGING_ENABLED = System.getProperty("debug.logging.enabled") == "true" + + private const val ARGUMENTS_FILE_NAME = "args.txt" + + private fun parseAdditionalArgs(testDir: File): List { + return File(testDir, ARGUMENTS_FILE_NAME) + .takeIf { it.exists() } + ?.readText() + ?.split(" ", "\n") + ?.filter { it.isNotBlank() } + ?: emptyList() + } + } + + protected lateinit var testDataDir: File + protected lateinit var workDir: File + protected lateinit var projectDescriptor: ProjectDescriptor + protected lateinit var additionalCommandLineArguments: List + // is used to compare lookup dumps in a human readable way (lookup symbols are hashed in an actual lookup storage) + protected lateinit var lookupsDuringTest: MutableSet + private var isJvmICEnabledBackup: Boolean = false + private var isJsICEnabledBackup: Boolean = false + + protected var mapWorkingToOriginalFile: MutableMap = hashMapOf() + + lateinit var kotlinCompileContext: KotlinCompileContext + + protected open val buildLogFinder: BuildLogFinder + get() = BuildLogFinder() + + private fun enableDebugLogging() { + com.intellij.openapi.diagnostic.Logger.setFactory(TestLoggerFactory::class.java) + TestLoggerFactory.dumpLogToStdout("") + TestLoggerFactory.enableDebugLogging(testRootDisposable, "#org") + + val console = ConsoleAppender() + console.layout = PatternLayout("%d [%p|%c|%C{1}] %m%n") + console.threshold = Level.ALL + console.activateOptions() + Logger.getRootLogger().addAppender(console) + } + + private var systemPropertiesBackup = run { + val props = System.getProperties() + val output = ByteArrayOutputStream() + props.store(output, "System properties backup") + output.toByteArray() + } + + private fun restoreSystemProperties() { + val input = ByteArrayInputStream(systemPropertiesBackup) + val props = Properties() + props.load(input) + System.setProperties(props) + } + + private val enableICFixture = EnableICFixture() + + override fun setUp() { + super.setUp() + + enableICFixture.setUp() + lookupsDuringTest = hashSetOf() + + if (DEBUG_LOGGING_ENABLED) { + enableDebugLogging() + } + } + + override fun tearDown() { + restoreSystemProperties() + + (AbstractIncrementalJpsTest::myProject).javaField!![this] = null + (AbstractIncrementalJpsTest::projectDescriptor).javaField!![this] = null + (AbstractIncrementalJpsTest::systemPropertiesBackup).javaField!![this] = null + + lookupsDuringTest.clear() + enableICFixture.tearDown() + super.tearDown() + } + + // JPS forces rebuild of all files when JVM constant has been changed and Callbacks.ConstantAffectionResolver + // is not provided, so ConstantAffectionResolver is mocked with empty implementation + // Usages in Kotlin files are expected to be found by KotlinLookupConstantSearch + protected open val mockConstantSearch: Callbacks.ConstantAffectionResolver? + get() = MockJavaConstantSearch(workDir) + + private fun build( + name: String?, + scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules() + ): MakeResult { + val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath) + + val logger = MyLogger(workDirPath) + projectDescriptor = createProjectDescriptor(BuildLoggingManager(logger)) + + val lookupTracker = TestLookupTracker() + val testingContext = TestingContext(lookupTracker, logger) + projectDescriptor.project.setTestingContext(testingContext) + + try { + val builder = IncProjectBuilder( + projectDescriptor, + BuilderRegistry.getInstance(), + myBuildParams, + CanceledStatus.NULL, + mockConstantSearch, + true + ) + val buildResult = BuildResult() + builder.addMessageHandler(buildResult) + val finalScope = scope.build() + projectDescriptor.project.kotlinCommonCompilerArguments = projectDescriptor.project.kotlinCommonCompilerArguments.apply { + updateCommandLineArguments(this) + } + + builder.build(finalScope, false) + + // testingContext.kotlinCompileContext is initialized in KotlinBuilder.initializeKotlinContext + kotlinCompileContext = testingContext.kotlinCompileContext!! + + lookupTracker.lookups.mapTo(lookupsDuringTest) { LookupSymbol(it.name, it.scopeFqName) } + + if (!buildResult.isSuccessful) { + val errorMessages = + buildResult + .getMessages(BuildMessage.Kind.ERROR) + .map { it.messageText } + .map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() } + .joinToString("\n") + return MakeResult( + log = logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", + makeFailed = true, + mappingsDump = null, + name = name + ) + } else { + return MakeResult( + log = logger.log, + makeFailed = false, + mappingsDump = createMappingsDump(projectDescriptor, kotlinCompileContext, lookupsDuringTest), + name = name + ) + } + } finally { + projectDescriptor.dataManager.flush(false) + projectDescriptor.release() + } + } + + private fun initialMake(): MakeResult { + val makeResult = build(null) + + val initBuildLogFile = File(testDataDir, "init-build.log") + if (initBuildLogFile.exists()) { + UsefulTestCase.assertSameLinesWithFile(initBuildLogFile.absolutePath, makeResult.log) + } else { + assertFalse("Initial make failed:\n$makeResult", makeResult.makeFailed) + } + + return makeResult + } + + private fun make(name: String?): MakeResult { + return build(name) + } + + private fun rebuild(): MakeResult { + return build(null, CompileScopeTestBuilder.rebuild().allModules()) + } + + private fun updateCommandLineArguments(arguments: CommonCompilerArguments) { + parseCommandLineArguments(additionalCommandLineArguments, arguments) + } + + private fun rebuildAndCheckOutput(makeOverallResult: MakeResult) { + val outDir = File(getAbsolutePath("out")) + val outAfterMake = File(getAbsolutePath("out-after-make")) + + if (outDir.exists()) { + FileUtil.copyDir(outDir, outAfterMake) + } + + val rebuildResult = rebuild() + assertEquals( + "Rebuild failed: ${rebuildResult.makeFailed}, last make failed: ${makeOverallResult.makeFailed}. Rebuild result: $rebuildResult", + rebuildResult.makeFailed, makeOverallResult.makeFailed + ) + + if (!outAfterMake.exists()) { + assertFalse(outDir.exists()) + } else { + assertEqualDirectories(outDir, outAfterMake, makeOverallResult.makeFailed) + } + + if (!makeOverallResult.makeFailed) { + if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.toLowerCase() == makeOverallResult.mappingsDump?.toLowerCase()) { + // do nothing + } else { + TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump) + } + } + + FileUtil.delete(outAfterMake) + } + + private fun clearCachesRebuildAndCheckOutput(makeOverallResult: MakeResult) { + FileUtil.delete(BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot!!) + + rebuildAndCheckOutput(makeOverallResult) + } + + open val modulesTxtFile + get() = File(testDataDir, "dependencies.txt") + + private fun readModulesTxt(): ModulesTxt? { + var actualModulesTxtFile = modulesTxtFile + + if (!actualModulesTxtFile.exists()) { + // also try `"_${fileName}.txt"`. Useful for sorting files in IDE. + actualModulesTxtFile = modulesTxtFile.parentFile.resolve("_" + modulesTxtFile.name) + if (!actualModulesTxtFile.exists()) return null + } + + return ModulesTxtBuilder().readFile(actualModulesTxtFile) + } + + protected open fun createBuildLog(incrementalMakeResults: List): String = + buildString { + incrementalMakeResults.forEachIndexed { i, makeResult -> + if (i > 0) append("\n") + if (makeResult.name != null) { + append("================ Step #${i + 1} ${makeResult.name} =================\n\n") + } else { + append("================ Step #${i + 1} =================\n\n") + } + append(makeResult.log) + } + } + + protected open fun doTest(testDataPath: String) { + testDataDir = File(testDataPath) + workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "aijt-jps-build", null) + additionalCommandLineArguments = parseAdditionalArgs(File(testDataPath)) + val buildLogFile = buildLogFinder.findBuildLog(testDataDir) + Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) }) + + val modulesTxt = configureModules() + if (modulesTxt?.muted == true) return + + initialMake() + + val otherMakeResults = performModificationsAndMake( + modulesTxt?.modules?.map { it.name }, + hasBuildLog = buildLogFile != null + ) + + buildLogFile?.let { + val logs = createBuildLog(otherMakeResults) + UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs) + + val lastMakeResult = otherMakeResults.last() + clearCachesRebuildAndCheckOutput(lastMakeResult) + } + } + + protected data class MakeResult( + val log: String, + val makeFailed: Boolean, + val mappingsDump: String?, + val name: String? = null + ) + + open val testDataSrc: File + get() = testDataDir + + private fun performModificationsAndMake( + moduleNames: Collection?, + hasBuildLog: Boolean + ): List { + val results = arrayListOf() + val modifications = getModificationsToPerform( + testDataSrc, + moduleNames, + allowNoFilesWithSuffixInTestData = allowNoFilesWithSuffixInTestData || !hasBuildLog, + touchPolicy = TouchPolicy.TIMESTAMP + ) + + if (!hasBuildLog) { + check(modifications.size == 1 && modifications.single().isEmpty()) { + "Bad test data: build steps are provided, but there is no `build.log` file" + } + return results + } + + val stepsTxt = File(testDataSrc, "_steps.txt") + val modificationNames = if (stepsTxt.exists()) stepsTxt.readLines() else null + + modifications.forEachIndexed { index, step -> + step.forEach { it.perform(workDir, mapWorkingToOriginalFile) } + performAdditionalModifications(step) + if (moduleNames == null) { + preProcessSources(File(workDir, "src")) + } else { + moduleNames.forEach { preProcessSources(File(workDir, "$it/src")) } + } + + val name = modificationNames?.getOrNull(index) + val makeResult = make(name) + results.add(makeResult) + } + return results + } + + protected open fun performAdditionalModifications(modifications: List) { + } + + protected open fun generateModuleSources(modulesTxt: ModulesTxt) = Unit + + // null means one module + private fun configureModules(): ModulesTxt? { + JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = + JpsPathUtil.pathToUrl(getAbsolutePath("out")) + + val jdk = addJdk("my jdk") + val modulesTxt = readModulesTxt() + mapWorkingToOriginalFile = hashMapOf() + + if (modulesTxt == null) configureSingleModuleProject(jdk) + else configureMultiModuleProject(modulesTxt, jdk) + + overrideModuleSettings() + configureRequiredLibraries() + + return modulesTxt + } + + open fun overrideModuleSettings() { + } + + private fun configureSingleModuleProject(jdk: JpsSdk?) { + addModule("module", arrayOf(getAbsolutePath("src")), null, null, jdk) + + val sourceDestinationDir = File(workDir, "src") + val sourcesMapping = copyTestSources(testDataDir, File(workDir, "src"), "") + mapWorkingToOriginalFile.putAll(sourcesMapping) + + preProcessSources(sourceDestinationDir) + } + + protected open val ModulesTxt.Module.sourceFilePrefix: String + get() = "${name}_" + + private fun configureMultiModuleProject( + modulesTxt: ModulesTxt, + jdk: JpsSdk? + ) { + modulesTxt.modules.forEach { module -> + module.jpsModule = addModule( + module.name, + arrayOf(getAbsolutePath("${module.name}/src")), + null, + null, + jdk + )!! + + val kotlinFacetSettings = module.kotlinFacetSettings + if (kotlinFacetSettings != null) { + val compilerArguments = kotlinFacetSettings.compilerArguments + if (compilerArguments is K2MetadataCompilerArguments) { + val out = getAbsolutePath("${module.name}/out") + File(out).mkdirs() + compilerArguments.destination = out + } else if (compilerArguments is K2JVMCompilerArguments) { + compilerArguments.disableDefaultScriptingPlugin = true + } + + module.jpsModule.container.setChild( + JpsKotlinFacetModuleExtension.KIND, + JpsKotlinFacetModuleExtension(kotlinFacetSettings) + ) + } + } + + modulesTxt.dependencies.forEach { + JpsModuleRootModificationUtil.addDependency( + it.from.jpsModule, it.to.jpsModule, + it.scope, it.exported + ) + } + + // configure module contents + generateModuleSources(modulesTxt) + modulesTxt.modules.forEach { module -> + val sourceDirName = "${module.name}/src" + val sourceDestinationDir = File(workDir, sourceDirName) + val sourcesMapping = copyTestSources(testDataSrc, sourceDestinationDir, module.sourceFilePrefix) + mapWorkingToOriginalFile.putAll(sourcesMapping) + + preProcessSources(sourceDestinationDir) + } + } + + private fun configureRequiredLibraries() { + myProject.modules.forEach { module -> + val platformKind = module.kotlinFacet?.settings?.targetPlatform?.idePlatformKind.orDefault() + + when { + platformKind.isJvm -> { + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JvmStdLib)) + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JvmTest)) + } + platformKind.isJavaScript -> { + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JsStdLib)) + JpsModuleRootModificationUtil.addDependency(module, requireLibrary(KotlinJpsLibrary.JsTest)) + } + } + } + } + + protected open fun preProcessSources(srcDir: File) { + } + + override fun doGetProjectDir(): File? = workDir + + internal class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase(), TestingBuildLogger { + private val markedDirtyBeforeRound = ArrayList() + private val markedDirtyAfterRound = ArrayList() + private val customMessages = mutableListOf() + + override fun invalidOrUnusedCache( + chunk: KotlinChunk?, + target: KotlinModuleBuildTarget<*>?, + attributesDiff: CacheAttributesDiff<*> + ) { + val cacheManager = attributesDiff.manager + val cacheTitle = when (cacheManager) { + is CacheVersionManager -> "Local cache for ${chunk ?: target}" + is CompositeLookupsCacheAttributesManager -> "Lookups cache" + else -> error("Unknown cache manager $cacheManager") + } + + logLine("$cacheTitle are ${attributesDiff.status}") + } + + override fun markedAsDirtyBeforeRound(files: Iterable) { + markedDirtyBeforeRound.addAll(files) + } + + override fun markedAsDirtyAfterRound(files: Iterable) { + markedDirtyAfterRound.addAll(files) + } + + override fun chunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + logDirtyFiles(markedDirtyBeforeRound) // files can be marked as dirty during build start (KotlinCompileContext initialization) + + if (!chunk.isDummy(context) && context.projectDescriptor.project.modules.size > 1) { + logLine("Building ${chunk.modules.sortedBy { it.name }.joinToString { it.name }}") + } + } + + override fun afterChunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + logDirtyFiles(markedDirtyBeforeRound) + } + + override fun addCustomMessage(message: String) { + customMessages.add(message) + } + + override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) { + customMessages.forEach { + logLine(it) + } + customMessages.clear() + logDirtyFiles(markedDirtyAfterRound) + logLine("Exit code: $exitCode") + logLine("------------------------------------------") + } + + private fun logDirtyFiles(files: MutableList) { + if (files.isEmpty()) return + + logLine("Marked as dirty by Kotlin:") + files.apply { + map { FileUtil.toSystemIndependentName(it.path) } + .sorted() + .forEach { logLine(it) } + + clear() + } + } + + private val logBuf = StringBuilder() + val log: String + get() = logBuf.toString() + + val compiledFiles = hashSetOf() + + override fun isEnabled(): Boolean = true + + override fun logCompiledFiles(files: MutableCollection?, builderName: String?, description: String?) { + super.logCompiledFiles(files, builderName, description) + + if (builderName == KotlinBuilder.KOTLIN_BUILDER_NAME) { + compiledFiles.addAll(files!!) + } + } + + override fun logLine(message: String?) { + logBuf.append(message!!.replace("^$rootPath/".toRegex(), " ")).append('\n') + } + } +} + +private fun createMappingsDump( + project: ProjectDescriptor, + kotlinContext: KotlinCompileContext, + lookupsDuringTest: Set +) = createKotlinCachesDump(project, kotlinContext, lookupsDuringTest) + "\n\n\n" + + createCommonMappingsDump(project) + "\n\n\n" + + createJavaMappingsDump(project) + +internal fun createKotlinCachesDump( + project: ProjectDescriptor, + kotlinContext: KotlinCompileContext, + lookupsDuringTest: Set +) = createKotlinIncrementalCacheDump(project, kotlinContext) + "\n\n\n" + + createLookupCacheDump(kotlinContext, lookupsDuringTest) + +private fun createKotlinIncrementalCacheDump( + project: ProjectDescriptor, + kotlinContext: KotlinCompileContext +): String { + return buildString { + for (target in project.allModuleTargets.sortedBy { it.presentableName }) { + val kotlinCache = project.dataManager.getKotlinCache(kotlinContext.targetsBinding[target]) + if (kotlinCache != null) { + append("\n") + append(kotlinCache.dump()) + append("\n\n\n") + } + } + } +} + +private fun createLookupCacheDump(kotlinContext: KotlinCompileContext, lookupsDuringTest: Set): String { + val sb = StringBuilder() + val p = Printer(sb) + p.println("Begin of Lookup Maps") + p.println() + + kotlinContext.lookupStorageManager.withLookupStorage { lookupStorage -> + lookupStorage.forceGC() + p.print(lookupStorage.dump(lookupsDuringTest)) + } + + p.println() + p.println("End of Lookup Maps") + return sb.toString() +} + +private fun createCommonMappingsDump(project: ProjectDescriptor): String { + val resultBuf = StringBuilder() + val result = Printer(resultBuf) + + result.println("Begin of SourceToOutputMap") + result.pushIndent() + + for (target in project.allModuleTargets) { + result.println(target) + result.pushIndent() + + val mapping = project.dataManager.getSourceToOutputMap(target) + mapping.sources.sorted().forEach { + val outputs = mapping.getOutputs(it)!!.sorted() + if (outputs.isNotEmpty()) { + result.println("source $it -> $outputs") + } + } + + result.popIndent() + } + + result.popIndent() + result.println("End of SourceToOutputMap") + + return resultBuf.toString() +} + +private fun createJavaMappingsDump(project: ProjectDescriptor): String { + val byteArrayOutputStream = ByteArrayOutputStream() + PrintStream(byteArrayOutputStream).use { + project.dataManager.mappings.toStream(it) + } + return byteArrayOutputStream.toString() +} + +internal val ProjectDescriptor.allModuleTargets: Collection + get() = buildTargetIndex.allTargets.filterIsInstance() + +private val EXPORTED_SUFFIX = "[exported]" diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJsJpsTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJsJpsTest.kt new file mode 100644 index 00000000000..743b0aee3f9 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJsJpsTest.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.config.KotlinFacetSettings +import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder +import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder.Companion.JS_JPS_LOG +import org.jetbrains.kotlin.jps.model.JpsKotlinFacetModuleExtension +import org.jetbrains.kotlin.platform.js.JsPlatforms +import java.io.File + +abstract class AbstractIncrementalJsJpsTest : AbstractIncrementalJpsTest() { + override val buildLogFinder: BuildLogFinder + get() = super.buildLogFinder.copy(isJsEnabled = true) + + override fun doTest(testDataPath: String) { + val buildLogFile = File(testDataPath).resolve(JS_JPS_LOG) + if (!buildLogFile.exists()) { + buildLogFile.writeText("JPS JS LOG PLACEHOLDER") + } + super.doTest(testDataPath) + } + + override fun overrideModuleSettings() { + myProject.modules.forEach { + val facet = KotlinFacetSettings() + facet.compilerArguments = K2JSCompilerArguments() + facet.targetPlatform = JsPlatforms.defaultJsPlatform + + it.container.setChild( + JpsKotlinFacetModuleExtension.KIND, + JpsKotlinFacetModuleExtension(facet) + ) + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJvmJpsTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJvmJpsTest.kt new file mode 100644 index 00000000000..e6ba8b3195f --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJvmJpsTest.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.jps.model.k2JvmCompilerArguments + +abstract class AbstractIncrementalJvmJpsTest( + allowNoFilesWithSuffixInTestData: Boolean = false +) : AbstractIncrementalJpsTest(allowNoFilesWithSuffixInTestData = allowNoFilesWithSuffixInTestData) { + override fun overrideModuleSettings() { + myProject.k2JvmCompilerArguments = K2JVMCompilerArguments().also { + it.disableDefaultScriptingPlugin = true + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt new file mode 100644 index 00000000000..9cb1353cc30 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt @@ -0,0 +1,151 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.testFramework.UsefulTestCase +import org.jetbrains.jps.builders.BuildTarget +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.incremental.KOTLIN_CACHE_DIRECTORY_NAME +import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner +import org.jetbrains.kotlin.incremental.testingUtils.Modification +import org.jetbrains.kotlin.incremental.testingUtils.ModifyContent +import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture +import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.utils.Printer +import java.io.File + +abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest() { + private val expectedCachesFileName: String + get() = "expected-kotlin-caches.txt" + + private val enableICFixture = EnableICFixture() + + override fun setUp() { + super.setUp() + enableICFixture.setUp() + } + + override fun tearDown() { + enableICFixture.tearDown() + super.tearDown() + } + + override fun doTest(testDataPath: String) { + super.doTest(testDataPath) + + val actual = dumpKotlinCachesFileNames() + val expectedFile = File(testDataPath, expectedCachesFileName) + UsefulTestCase.assertSameLinesWithFile(expectedFile.canonicalPath, actual) + } + + override fun performAdditionalModifications(modifications: List) { + super.performAdditionalModifications(modifications) + + for (modification in modifications) { + if (modification !is ModifyContent) continue + + val name = File(modification.path).name + + when { + name.endsWith("incremental-compilation") -> { + IncrementalCompilation.setIsEnabledForJvm(modification.dataFile.readAsBool()) + } + } + } + } + + fun File.readAsBool(): Boolean { + val content = this.readText() + + return when (content.trim()) { + "on" -> true + "off" -> false + else -> throw IllegalStateException("$this content is expected to be 'on' or 'off'") + } + } + + private fun dumpKotlinCachesFileNames(): String { + val sb = StringBuilder() + val printer = Printer(sb) + val chunks = kotlinCompileContext.targetsIndex.chunks + val dataManager = projectDescriptor.dataManager + val paths = dataManager.dataPaths + + dumpCachesForTarget( + printer, + paths, + KotlinDataContainerTarget, + kotlinCompileContext.lookupsCacheAttributesManager.versionManagerForTesting.versionFileForTesting + ) + + data class TargetInChunk(val chunk: KotlinChunk, val target: KotlinModuleBuildTarget<*>) + + val allTargets = chunks.flatMap { chunk -> + chunk.targets.map { target -> + TargetInChunk(chunk, target) + } + }.sortedBy { it.target.jpsModuleBuildTarget.presentableName } + + allTargets.forEach { (chunk, target) -> + val metaBuildInfo = chunk.buildMetaInfoFile(target.jpsModuleBuildTarget) + dumpCachesForTarget( + printer, paths, target.jpsModuleBuildTarget, + target.localCacheVersionManager.versionFileForTesting, + metaBuildInfo, + subdirectory = KOTLIN_CACHE_DIRECTORY_NAME + ) + } + + + return sb.toString() + } + + private fun dumpCachesForTarget( + p: Printer, + paths: BuildDataPaths, + target: BuildTarget<*>, + vararg cacheVersionsFiles: File, + subdirectory: String? = null + ) { + p.println(target) + p.pushIndent() + + val dataRoot = paths.getTargetDataRoot(target).let { if (subdirectory != null) File(it, subdirectory) else it } + cacheVersionsFiles + .filter(File::exists) + .sortedBy { it.name } + .forEach { p.println(it.name) } + + kotlinCacheNames(dataRoot).sorted().forEach { p.println(it) } + + p.popIndent() + } + + private fun kotlinCacheNames(dir: File): List { + val result = arrayListOf() + + for (file in dir.walk()) { + if (file.isFile && file.extension == BasicMapsOwner.CACHE_EXTENSION) { + result.add(file.name) + } + } + + return result + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractKotlinJpsBuildTestCase.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractKotlinJpsBuildTestCase.kt new file mode 100644 index 00000000000..9f2da53372a --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractKotlinJpsBuildTestCase.kt @@ -0,0 +1,116 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.jps.model.JpsDummyElement +import org.jetbrains.jps.model.JpsModuleRootModificationUtil +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.java.JpsJavaDependencyScope +import org.jetbrains.jps.model.java.JpsJavaLibraryType +import org.jetbrains.jps.model.java.JpsJavaSdkType +import org.jetbrains.jps.model.library.JpsLibrary +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.model.library.sdk.JpsSdk +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime +import org.jetbrains.kotlin.utils.PathUtil + +import java.io.File +import java.io.IOException + +abstract class AbstractKotlinJpsBuildTestCase : BaseKotlinJpsBuildTestCase() { + protected lateinit var workDir: File + + @Throws(IOException::class) + override fun doGetProjectDir(): File? { + return workDir + } + + override fun addJdk(name: String, path: String?): JpsSdk { + val homePath = System.getProperty("java.home") + val versionString = System.getProperty("java.version") + val jdk = myModel.global.addSdk(name, homePath, versionString, JpsJavaSdkType.INSTANCE) + jdk.addRoot(JpsPathUtil.pathToUrl(path), JpsOrderRootType.COMPILED) + return jdk.properties + } + + protected fun addKotlinMockRuntimeDependency(): JpsLibrary { + return addDependency(KotlinJpsLibrary.MockRuntime) + } + + protected fun addKotlinStdlibDependency(): JpsLibrary { + return addDependency(KotlinJpsLibrary.JvmStdLib) + } + + protected fun addKotlinJavaScriptStdlibDependency(): JpsLibrary { + return addDependency(KotlinJpsLibrary.JsStdLib) + } + + private fun addDependency(library: KotlinJpsLibrary): JpsLibrary { + return addDependency(myProject, library) + } + + protected fun addDependency(libraryName: String, libraryFile: File): JpsLibrary { + return addDependency(myProject, libraryName, libraryFile) + } + + companion object { + val TEST_DATA_PATH = "jps-plugin/testData/" + + @JvmStatic + protected fun addKotlinStdlibDependency(modules: Collection, exported: Boolean = false): JpsLibrary { + return addDependency(modules, KotlinJpsLibrary.JvmStdLib, exported) + } + + @JvmStatic + private fun addDependency(project: JpsProject, library: KotlinJpsLibrary, exported: Boolean = false): JpsLibrary { + return addDependency(JpsJavaDependencyScope.COMPILE, project.modules, exported, library.id, *library.roots) + } + + @JvmStatic + private fun addDependency(modules: Collection, library: KotlinJpsLibrary, exported: Boolean = false): JpsLibrary { + return addDependency(JpsJavaDependencyScope.COMPILE, modules, exported, library.id, *library.roots) + } + + @JvmStatic + private fun addDependency(project: JpsProject, libraryName: String, libraryFile: File): JpsLibrary { + return addDependency(JpsJavaDependencyScope.COMPILE, project.modules, false, libraryName, libraryFile) + } + + @JvmStatic + protected fun addDependency( + type: JpsJavaDependencyScope, + modules: Collection, + exported: Boolean, + libraryName: String, + vararg file: File + ): JpsLibrary { + val library = modules.iterator().next().project.addLibrary(libraryName, JpsJavaLibraryType.INSTANCE) + + for (fileRoot in file) { + library.addRoot(fileRoot, JpsOrderRootType.COMPILED) + } + + for (module in modules) { + JpsModuleRootModificationUtil.addDependency(module, library, type, exported) + } + return library + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt new file mode 100644 index 00000000000..714c2f7a54b --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt @@ -0,0 +1,368 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.testFramework.UsefulTestCase +import com.intellij.util.containers.StringInterner +import org.jetbrains.kotlin.TestWithWorkingDir +import org.jetbrains.kotlin.build.JvmSourceRoot +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler +import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime +import org.jetbrains.kotlin.compilerRunner.* +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.incremental.components.LookupInfo +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.incremental.components.Position +import org.jetbrains.kotlin.incremental.components.ScopeKind +import org.jetbrains.kotlin.incremental.isKotlinFile +import org.jetbrains.kotlin.incremental.js.* +import org.jetbrains.kotlin.incremental.makeModuleFile +import org.jetbrains.kotlin.incremental.testingUtils.TouchPolicy +import org.jetbrains.kotlin.incremental.testingUtils.copyTestSources +import org.jetbrains.kotlin.incremental.testingUtils.getModificationsToPerform +import org.jetbrains.kotlin.incremental.utils.TestMessageCollector +import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture +import org.jetbrains.kotlin.jps.incremental.createTestingCompilerEnvironment +import org.jetbrains.kotlin.jps.incremental.runJSCompiler +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.utils.JsMetadataVersion +import org.jetbrains.kotlin.utils.PathUtil +import java.io.* +import java.util.* + +abstract class AbstractJvmLookupTrackerTest : AbstractLookupTrackerTest() { + + private val sourceToOutputMapping = hashMapOf>() + + override fun setUp() { + super.setUp() + sourceToOutputMapping.clear() + } + + override fun markDirty(removedAndModifiedSources: Iterable) { + for (sourceFile in removedAndModifiedSources) { + val outputs = sourceToOutputMapping.remove(sourceFile) ?: continue + for (output in outputs) { + output.delete() + } + } + } + + override fun processCompilationResults(outputItemsCollector: OutputItemsCollectorImpl, services: Services) { + for ((sourceFiles, outputFile) in outputItemsCollector.outputs) { + if (outputFile.extension == "kotlin_module") continue + + for (sourceFile in sourceFiles) { + val outputsForSource = sourceToOutputMapping.getOrPut(sourceFile) { hashSetOf() } + outputsForSource.add(outputFile) + } + } + } + + override fun runCompiler(filesToCompile: Iterable, env: JpsCompilerEnvironment): Any? { + val moduleFile = makeModuleFile( + name = "test", + isTest = true, + outputDir = outDir, + sourcesToCompile = filesToCompile.toList(), + commonSources = emptyList(), + javaSourceRoots = listOf(JvmSourceRoot(srcDir, null)), + classpath = listOf(outDir, ForTestCompileRuntime.runtimeJarForTests()).filter { it.exists() }, + friendDirs = emptyList() + ) + + val args = K2JVMCompilerArguments().apply { + disableDefaultScriptingPlugin = true + buildFile = moduleFile.canonicalPath + reportOutputFiles = true + } + val argsArray = ArgumentUtils.convertArgumentsToStringList(args).toTypedArray() + + try { + val stream = ByteArrayOutputStream() + val out = PrintStream(stream) + val exitCode = CompilerRunnerUtil.invokeExecMethod(K2JVMCompiler::class.java.name, argsArray, env, out) + val reader = BufferedReader(StringReader(stream.toString())) + CompilerOutputParser.parseCompilerMessagesFromReader(env.messageCollector, reader, env.outputItemsCollector) + + return exitCode + } + finally { + moduleFile.delete() + } + } +} + +abstract class AbstractJsKlibLookupTrackerTest : AbstractJsLookupTrackerTest() { + override val jsStdlibFile: File + get() = File("build/js-ir-runtime/full-runtime.klib") + + override fun configureAdditionalArgs(args: K2JSCompilerArguments) { + args.irProduceKlibDir = true + args.irOnly = true + args.outputFile = outDir.resolve("out.klib").absolutePath + } +} + +abstract class AbstractJsLookupTrackerTest : AbstractLookupTrackerTest() { + private var header: ByteArray? = null + private val packageParts: MutableMap = hashMapOf() + private val serializedIrFiles: MutableMap = hashMapOf() + + override fun setUp() { + super.setUp() + header = null + packageParts.clear() + serializedIrFiles.clear() + } + + override fun Services.Builder.registerAdditionalServices() { + if (header != null) { + register( + IncrementalDataProvider::class.java, + IncrementalDataProviderImpl( + headerMetadata = header!!, + compiledPackageParts = packageParts, + metadataVersion = JsMetadataVersion.INSTANCE.toArray(), + packageMetadata = emptyMap(), // TODO pass correct metadata + serializedIrFiles = serializedIrFiles + ) + ) + } + + register(IncrementalResultsConsumer::class.java, IncrementalResultsConsumerImpl()) + } + + override fun markDirty(removedAndModifiedSources: Iterable) { + removedAndModifiedSources.forEach { + packageParts.remove(it) + serializedIrFiles.remove(it) + } + } + + override fun processCompilationResults(outputItemsCollector: OutputItemsCollectorImpl, services: Services) { + val incrementalResults = services.get(IncrementalResultsConsumer::class.java) as IncrementalResultsConsumerImpl + header = incrementalResults.headerMetadata + packageParts.putAll(incrementalResults.packageParts) + serializedIrFiles.putAll(incrementalResults.irFileData) + } + + protected open val jsStdlibFile: File + get() = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath + + protected open fun configureAdditionalArgs(args: K2JSCompilerArguments) { + args.outputFile = File(outDir, "out.js").canonicalPath + } + + override fun runCompiler(filesToCompile: Iterable, env: JpsCompilerEnvironment): Any? { + val args = K2JSCompilerArguments().apply { + val libPaths = arrayListOf(jsStdlibFile.absolutePath) + (libraries ?: "").split(File.pathSeparator) + libraries = libPaths.joinToString(File.pathSeparator) + reportOutputFiles = true + freeArgs = filesToCompile.map { it.canonicalPath } + } + configureAdditionalArgs(args) + return runJSCompiler(args, env) + } +} + +abstract class AbstractLookupTrackerTest : TestWithWorkingDir() { + private val DECLARATION_KEYWORDS = listOf("interface", "class", "enum class", "object", "fun", "operator fun", "val", "var") + private val DECLARATION_STARTS_WITH = DECLARATION_KEYWORDS.map { it + " " } + // ignore KDoc like comments which starts with `/**`, example: /** text */ + private val COMMENT_WITH_LOOKUP_INFO = "/\\*[^*]+\\*/".toRegex() + + protected lateinit var srcDir: File + protected lateinit var outDir: File + private val enableICFixture = EnableICFixture() + + override fun setUp() { + super.setUp() + srcDir = File(workingDir, "src").apply { mkdirs() } + outDir = File(workingDir, "out") + enableICFixture.setUp() + } + + override fun tearDown() { + enableICFixture.tearDown() + super.tearDown() + } + + protected abstract fun markDirty(removedAndModifiedSources: Iterable) + protected abstract fun processCompilationResults(outputItemsCollector: OutputItemsCollectorImpl, services: Services) + protected abstract fun runCompiler(filesToCompile: Iterable, env: JpsCompilerEnvironment): Any? + + fun doTest(path: String) { + val sb = StringBuilder() + fun StringBuilder.indentln(string: String) { + appendLine(" $string") + } + fun CompilerOutput.logOutput(stepName: String) { + sb.appendLine("==== $stepName ====") + + sb.appendLine("Compiling files:") + for (compiledFile in compiledFiles.sortedBy { it.canonicalPath }) { + val lookupsFromFile = lookups[compiledFile] + val lookupStatus = when { + lookupsFromFile == null -> "(unknown)" + lookupsFromFile.isEmpty() -> "(no lookups)" + else -> "" + } + val relativePath = compiledFile.toRelativeString(workingDir).replace("\\", "/") + sb.indentln("$relativePath$lookupStatus") + } + + sb.appendLine("Exit code: $exitCode") + errors.forEach(sb::indentln) + + sb.appendLine() + } + + val testDir = File(path) + val workToOriginalFileMap = HashMap(copyTestSources(testDir, srcDir, filePrefix = "")) + var dirtyFiles = srcDir.walk().filterTo(HashSet()) { it.isKotlinFile(listOf("kt", "kts")) } + val steps = getModificationsToPerform(testDir, moduleNames = null, allowNoFilesWithSuffixInTestData = true, touchPolicy = TouchPolicy.CHECKSUM) + .filter { it.isNotEmpty() } + + val filesToLookups = arrayListOf>>() + fun CompilerOutput.originalFilesToLookups() = + compiledFiles.associateBy({ workToOriginalFileMap[it]!! }, { lookups[it] ?: emptyList() }) + + make(dirtyFiles).apply { + logOutput("INITIAL BUILD") + filesToLookups.add(originalFilesToLookups()) + + } + for ((i, modifications) in steps.withIndex()) { + dirtyFiles = modifications.mapNotNullTo(HashSet()) { it.perform(workingDir, workToOriginalFileMap) } + make(dirtyFiles).apply { + logOutput("STEP ${i + 1}") + filesToLookups.add(originalFilesToLookups()) + } + } + + val expectedBuildLog = File(testDir, "build.log") + UsefulTestCase.assertSameLinesWithFile(expectedBuildLog.canonicalPath, sb.toString()) + + assertEquals(steps.size + 1, filesToLookups.size) + for ((i, lookupsAtStepI) in filesToLookups.withIndex()) { + val step = if (i == 0) "INITIAL BUILD" else "STEP $i" + for ((file, lookups) in lookupsAtStepI) { + checkLookupsInFile(step, file, lookups) + } + } + } + + private class CompilerOutput( + val exitCode: String, + val errors: List, + val compiledFiles: Iterable, + val lookups: Map> + ) + + private fun make(filesToCompile: Iterable): CompilerOutput { + filesToCompile.forEach { + it.writeText(it.readText().replace(COMMENT_WITH_LOOKUP_INFO, "")) + } + + markDirty(filesToCompile) + val lookupTracker = TestLookupTracker() + val messageCollector = TestMessageCollector() + val outputItemsCollector = OutputItemsCollectorImpl() + val services = Services.Builder().run { + register(LookupTracker::class.java, lookupTracker) + registerAdditionalServices() + build() + } + val environment = createTestingCompilerEnvironment(messageCollector, outputItemsCollector, services) + val exitCode = runCompiler(filesToCompile, environment) as? ExitCode + if (exitCode == ExitCode.OK) { + processCompilationResults(outputItemsCollector, environment.services) + } + + val lookups = lookupTracker.lookups.groupBy { File(it.filePath) } + val lookupsFromCompiledFiles = filesToCompile.associate { it to (lookups[it] ?: emptyList()) } + return CompilerOutput(exitCode.toString(), messageCollector.errors, filesToCompile, lookupsFromCompiledFiles) + } + + protected open fun Services.Builder.registerAdditionalServices() {} + + private fun checkLookupsInFile(step: String, expectedFile: File, lookupsFromFile: List) { + val text = expectedFile.readText().replace(COMMENT_WITH_LOOKUP_INFO, "") + val lines = text.lines().toMutableList() + + for ((line, lookupsFromLine) in lookupsFromFile.groupBy { it.position.line }) { + val columnToLookups = lookupsFromLine.groupBy { it.position.column }.toList().sortedBy { it.first } + + val lineContent = lines[line - 1] + val parts = ArrayList(columnToLookups.size * 2) + + var start = 0 + + for ((column, lookupsFromColumn) in columnToLookups) { + val end = column - 1 + parts.add(lineContent.subSequence(start, end)) + + val lookups = lookupsFromColumn.mapTo(sortedSetOf()) { + val rest = lineContent.substring(end) + + val name = + when { + rest.startsWith(it.name) || // same name + rest.startsWith("$" + it.name) || // backing field + DECLARATION_STARTS_WITH.any { rest.startsWith(it) } // it's declaration + -> "" + else -> "(" + it.name + ")" + } + + it.scopeKind.toString()[0].toLowerCase() + .toString() + ":" + it.scopeFqName.let { if (it.isNotEmpty()) it else "" } + name + }.joinToString(separator = " ", prefix = "/*", postfix = "*/") + + parts.add(lookups) + + start = end + } + + lines[line - 1] = parts.joinToString("") + lineContent.subSequence(start, lineContent.length) + } + + val actual = lines.joinToString("\n") + KotlinTestUtils.assertEqualsToFile("Lookups do not match after $step", expectedFile, actual) + } +} + +class TestLookupTracker : LookupTracker { + val lookups = arrayListOf() + private val interner = StringInterner() + + override val requiresPosition: Boolean + get() = true + + override fun record(filePath: String, position: Position, scopeFqName: String, scopeKind: ScopeKind, name: String) { + val internedFilePath = interner.intern(filePath) + val internedScopeFqName = interner.intern(scopeFqName) + val internedName = interner.intern(name) + + lookups.add(LookupInfo(internedFilePath, position, internedScopeFqName, scopeKind, internedName)) + } +} + + diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractMultiplatformJpsTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractMultiplatformJpsTest.kt new file mode 100644 index 00000000000..a1da1c51621 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractMultiplatformJpsTest.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt +import org.jetbrains.kotlin.jps.build.dependeciestxt.MppJpsIncTestsGenerator +import java.io.File + +abstract class AbstractMultiplatformJpsTestWithGeneratedContent : AbstractIncrementalJpsTest() { + override val modulesTxtFile: File + get() = File(testDataDir.parent, "dependencies.txt").also { + check(it.exists()) { + "`dependencies.txt` should be in parent dir. " + + "See `jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/README.md` for details" + } + } + + override val testDataSrc: File + get() = File(workDir, "generatedTestDataSources") + + override fun generateModuleSources(modulesTxt: ModulesTxt) { + testDataSrc.mkdirs() + + val testCaseName = testDataDir.name + + val generator = MppJpsIncTestsGenerator(modulesTxt) { testDataSrc } + val testCase = generator.testCases.find { it.name == testCaseName } + ?: error("Test case `$testCaseName` is not configured in ${modulesTxt.fileName}") + testCase.generate() + } + + override val ModulesTxt.Module.sourceFilePrefix: String + get() = "${indexedName}_" +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/BaseKotlinJpsBuildTestCase.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/BaseKotlinJpsBuildTestCase.kt new file mode 100644 index 00000000000..a07e0ab2229 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/BaseKotlinJpsBuildTestCase.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.builders.JpsBuildTestCase +import org.jetbrains.jps.model.library.JpsLibrary +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner +import org.jetbrains.kotlin.test.WithMutedInDatabaseRunTest +import org.jetbrains.kotlin.test.runTest + +@WithMutedInDatabaseRunTest +abstract class BaseKotlinJpsBuildTestCase : JpsBuildTestCase() { + @Throws(Exception::class) + override fun setUp() { + super.setUp() + System.setProperty("kotlin.jps.tests", "true") + } + + @Throws(Exception::class) + override fun tearDown() { + System.clearProperty("kotlin.jps.tests") + myModel = null + myBuildParams.clear() + JpsKotlinCompilerRunner.releaseCompileServiceSession() + super.tearDown() + } + + private val libraries = mutableMapOf() + + protected fun requireLibrary(library: KotlinJpsLibrary) = libraries.getOrPut(library.id) { + library.create(myProject) + } + + override fun runTest() { + runTest { + super.runTest() + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/DataContainerVersionChangedTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/DataContainerVersionChangedTestGenerated.java new file mode 100644 index 00000000000..e6187d62e7d --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/DataContainerVersionChangedTestGenerated.java @@ -0,0 +1,229 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class DataContainerVersionChangedTestGenerated extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCacheVersionChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("clearedHasKotlin") + public void testClearedHasKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin/"); + } + + @TestMetadata("exportedModule") + public void testExportedModule() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/"); + } + + @TestMetadata("javaOnlyModulesAreNotAffected") + public void testJavaOnlyModulesAreNotAffected() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected/"); + } + + @TestMetadata("module1Modified") + public void testModule1Modified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified/"); + } + + @TestMetadata("module2Modified") + public void testModule2Modified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/module2Modified/"); + } + + @TestMetadata("moduleWithConstantModified") + public void testModuleWithConstantModified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/"); + } + + @TestMetadata("moduleWithInlineModified") + public void testModuleWithInlineModified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/"); + } + + @TestMetadata("touchedFile") + public void testTouchedFile() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/touchedFile/"); + } + + @TestMetadata("touchedOnlyJavaFile") + public void testTouchedOnlyJavaFile() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile/"); + } + + @TestMetadata("untouchedFiles") + public void testUntouchedFiles() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles/"); + } + + @TestMetadata("withError") + public void testWithError() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/withError/"); + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClearedHasKotlin extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClearedHasKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExportedModule extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInExportedModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaOnlyModulesAreNotAffected extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJavaOnlyModulesAreNotAffected() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Module1Modified extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModule1Modified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module2Modified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Module2Modified extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModule2Modified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/module2Modified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ModuleWithConstantModified extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModuleWithConstantModified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ModuleWithInlineModified extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModuleWithInlineModified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedFile") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TouchedFile extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTouchedFile() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/touchedFile"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TouchedOnlyJavaFile extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTouchedOnlyJavaFile() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UntouchedFiles extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUntouchedFiles() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/withError") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class WithError extends AbstractDataContainerVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInWithError() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/withError"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalCacheVersionChangedTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalCacheVersionChangedTestGenerated.java new file mode 100644 index 00000000000..fbd79fb342e --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalCacheVersionChangedTestGenerated.java @@ -0,0 +1,229 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class IncrementalCacheVersionChangedTestGenerated extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCacheVersionChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("clearedHasKotlin") + public void testClearedHasKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin/"); + } + + @TestMetadata("exportedModule") + public void testExportedModule() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/"); + } + + @TestMetadata("javaOnlyModulesAreNotAffected") + public void testJavaOnlyModulesAreNotAffected() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected/"); + } + + @TestMetadata("module1Modified") + public void testModule1Modified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified/"); + } + + @TestMetadata("module2Modified") + public void testModule2Modified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/module2Modified/"); + } + + @TestMetadata("moduleWithConstantModified") + public void testModuleWithConstantModified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/"); + } + + @TestMetadata("moduleWithInlineModified") + public void testModuleWithInlineModified() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/"); + } + + @TestMetadata("touchedFile") + public void testTouchedFile() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/touchedFile/"); + } + + @TestMetadata("touchedOnlyJavaFile") + public void testTouchedOnlyJavaFile() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile/"); + } + + @TestMetadata("untouchedFiles") + public void testUntouchedFiles() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles/"); + } + + @TestMetadata("withError") + public void testWithError() throws Exception { + runTest("jps-plugin/testData/incremental/cacheVersionChanged/withError/"); + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClearedHasKotlin extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClearedHasKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExportedModule extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInExportedModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaOnlyModulesAreNotAffected extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJavaOnlyModulesAreNotAffected() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Module1Modified extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModule1Modified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module2Modified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Module2Modified extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModule2Modified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/module2Modified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ModuleWithConstantModified extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModuleWithConstantModified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ModuleWithInlineModified extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInModuleWithInlineModified() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedFile") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TouchedFile extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTouchedFile() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/touchedFile"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TouchedOnlyJavaFile extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTouchedOnlyJavaFile() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UntouchedFiles extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUntouchedFiles() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/cacheVersionChanged/withError") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class WithError extends AbstractIncrementalCacheVersionChangedTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInWithError() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged/withError"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalConstantSearchTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalConstantSearchTest.kt new file mode 100644 index 00000000000..fbb7ce3022b --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalConstantSearchTest.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +class IncrementalConstantSearchTest : AbstractIncrementalJpsTest() { + fun testJavaConstantChangedUsedInKotlin() { + doTest("jps-plugin/testData/incremental/custom/javaConstantChangedUsedInKotlin/") + } + + fun testJavaConstantUnchangedUsedInKotlin() { + doTest("jps-plugin/testData/incremental/custom/javaConstantUnchangedUsedInKotlin/") + } + + fun testKotlinConstantChangedUsedInJava() { + doTest("jps-plugin/testData/incremental/custom/kotlinConstantChangedUsedInJava/") + } + + fun testKotlinJvmFieldChangedUsedInJava() { + doTest("jps-plugin/testData/incremental/custom/kotlinJvmFieldChangedUsedInJava/") + } + + fun testKotlinConstantUnchangedUsedInJava() { + doTest("jps-plugin/testData/incremental/custom/kotlinConstantUnchangedUsedInJava/") + } + + fun testKotlinJvmFieldUnchangedUsedInJava() { + doTest("jps-plugin/testData/incremental/custom/kotlinJvmFieldUnchangedUsedInJava/") + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJsJpsTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJsJpsTestGenerated.java new file mode 100644 index 00000000000..60fe26dcd93 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJsJpsTestGenerated.java @@ -0,0 +1,463 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/multiModule/common") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class IncrementalJsJpsTestGenerated extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCommon() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classAdded") + public void testClassAdded() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/classAdded/"); + } + + @TestMetadata("classRemoved") + public void testClassRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/classRemoved/"); + } + + @TestMetadata("constantValueChanged") + public void testConstantValueChanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/constantValueChanged/"); + } + + @TestMetadata("copyFileToAnotherModule") + public void testCopyFileToAnotherModule() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/copyFileToAnotherModule/"); + } + + @TestMetadata("defaultArgumentInConstructorRemoved") + public void testDefaultArgumentInConstructorRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultArgumentInConstructorRemoved/"); + } + + @TestMetadata("defaultParameterAdded") + public void testDefaultParameterAdded() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterAdded/"); + } + + @TestMetadata("defaultParameterAddedForTopLevelFun") + public void testDefaultParameterAddedForTopLevelFun() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterAddedForTopLevelFun/"); + } + + @TestMetadata("defaultParameterRemoved") + public void testDefaultParameterRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemoved/"); + } + + @TestMetadata("defaultParameterRemovedForTopLevelFun") + public void testDefaultParameterRemovedForTopLevelFun() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemovedForTopLevelFun/"); + } + + @TestMetadata("defaultValueInConstructorRemoved") + public void testDefaultValueInConstructorRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultValueInConstructorRemoved/"); + } + + @TestMetadata("duplicatedClass") + public void testDuplicatedClass() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/duplicatedClass/"); + } + + @TestMetadata("exportedDependency") + public void testExportedDependency() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/exportedDependency/"); + } + + @TestMetadata("functionFromDifferentPackageChanged") + public void testFunctionFromDifferentPackageChanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/functionFromDifferentPackageChanged/"); + } + + @TestMetadata("inlineFunctionInlined") + public void testInlineFunctionInlined() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/inlineFunctionInlined/"); + } + + @TestMetadata("inlineFunctionTwoPackageParts") + public void testInlineFunctionTwoPackageParts() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/inlineFunctionTwoPackageParts/"); + } + + @TestMetadata("moveFileToAnotherModule") + public void testMoveFileToAnotherModule() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/moveFileToAnotherModule/"); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simple/"); + } + + @TestMetadata("simpleDependency") + public void testSimpleDependency() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependency/"); + } + + @TestMetadata("simpleDependencyErrorOnAccessToInternal1") + public void testSimpleDependencyErrorOnAccessToInternal1() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal1/"); + } + + @TestMetadata("simpleDependencyErrorOnAccessToInternal2") + public void testSimpleDependencyErrorOnAccessToInternal2() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal2/"); + } + + @TestMetadata("simpleDependencyUnchanged") + public void testSimpleDependencyUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependencyUnchanged/"); + } + + @TestMetadata("transitiveDependency") + public void testTransitiveDependency() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/transitiveDependency/"); + } + + @TestMetadata("transitiveInlining") + public void testTransitiveInlining() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/transitiveInlining/"); + } + + @TestMetadata("twoDependants") + public void testTwoDependants() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/twoDependants/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/classAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassAdded extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/classAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/classRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassRemoved extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/classRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/constantValueChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstantValueChanged extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInConstantValueChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/constantValueChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/copyFileToAnotherModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CopyFileToAnotherModule extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCopyFileToAnotherModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/copyFileToAnotherModule"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultArgumentInConstructorRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultArgumentInConstructorRemoved extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultArgumentInConstructorRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultArgumentInConstructorRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterAdded extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterAddedForTopLevelFun") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterAddedForTopLevelFun extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterAddedForTopLevelFun() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterAddedForTopLevelFun"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterRemoved extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemovedForTopLevelFun") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterRemovedForTopLevelFun extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterRemovedForTopLevelFun() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemovedForTopLevelFun"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultValueInConstructorRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValueInConstructorRemoved extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValueInConstructorRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultValueInConstructorRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/duplicatedClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DuplicatedClass extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDuplicatedClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/duplicatedClass"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/exportedDependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExportedDependency extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInExportedDependency() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/exportedDependency"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/functionFromDifferentPackageChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionFromDifferentPackageChanged extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInFunctionFromDifferentPackageChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/functionFromDifferentPackageChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/inlineFunctionInlined") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionInlined extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionInlined() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/inlineFunctionInlined"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/inlineFunctionTwoPackageParts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionTwoPackageParts extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionTwoPackageParts() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/inlineFunctionTwoPackageParts"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/moveFileToAnotherModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MoveFileToAnotherModule extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMoveFileToAnotherModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/moveFileToAnotherModule"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simple") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Simple extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimple() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simple"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependency extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependency() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependency"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal1") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependencyErrorOnAccessToInternal1 extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependencyErrorOnAccessToInternal1() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal1"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal2") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependencyErrorOnAccessToInternal2 extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependencyErrorOnAccessToInternal2() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal2"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependencyUnchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependencyUnchanged extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependencyUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependencyUnchanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/transitiveDependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TransitiveDependency extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTransitiveDependency() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/transitiveDependency"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/transitiveInlining") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TransitiveInlining extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTransitiveInlining() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/transitiveInlining"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/twoDependants") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TwoDependants extends AbstractIncrementalJsJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTwoDependants() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/twoDependants"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java new file mode 100644 index 00000000000..fcaad30416a --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java @@ -0,0 +1,3693 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@RunWith(JUnit3RunnerWithInners.class) +public class IncrementalJvmJpsTestGenerated extends AbstractIncrementalJvmJpsTest { + @TestMetadata("jps-plugin/testData/incremental/multiModule/common") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Common extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCommon() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("classAdded") + public void testClassAdded() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/classAdded/"); + } + + @TestMetadata("classRemoved") + public void testClassRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/classRemoved/"); + } + + @TestMetadata("constantValueChanged") + public void testConstantValueChanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/constantValueChanged/"); + } + + @TestMetadata("copyFileToAnotherModule") + public void testCopyFileToAnotherModule() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/copyFileToAnotherModule/"); + } + + @TestMetadata("defaultArgumentInConstructorRemoved") + public void testDefaultArgumentInConstructorRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultArgumentInConstructorRemoved/"); + } + + @TestMetadata("defaultParameterAdded") + public void testDefaultParameterAdded() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterAdded/"); + } + + @TestMetadata("defaultParameterAddedForTopLevelFun") + public void testDefaultParameterAddedForTopLevelFun() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterAddedForTopLevelFun/"); + } + + @TestMetadata("defaultParameterRemoved") + public void testDefaultParameterRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemoved/"); + } + + @TestMetadata("defaultParameterRemovedForTopLevelFun") + public void testDefaultParameterRemovedForTopLevelFun() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemovedForTopLevelFun/"); + } + + @TestMetadata("defaultValueInConstructorRemoved") + public void testDefaultValueInConstructorRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/defaultValueInConstructorRemoved/"); + } + + @TestMetadata("duplicatedClass") + public void testDuplicatedClass() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/duplicatedClass/"); + } + + @TestMetadata("exportedDependency") + public void testExportedDependency() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/exportedDependency/"); + } + + @TestMetadata("functionFromDifferentPackageChanged") + public void testFunctionFromDifferentPackageChanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/functionFromDifferentPackageChanged/"); + } + + @TestMetadata("inlineFunctionInlined") + public void testInlineFunctionInlined() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/inlineFunctionInlined/"); + } + + @TestMetadata("inlineFunctionTwoPackageParts") + public void testInlineFunctionTwoPackageParts() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/inlineFunctionTwoPackageParts/"); + } + + @TestMetadata("moveFileToAnotherModule") + public void testMoveFileToAnotherModule() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/moveFileToAnotherModule/"); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simple/"); + } + + @TestMetadata("simpleDependency") + public void testSimpleDependency() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependency/"); + } + + @TestMetadata("simpleDependencyErrorOnAccessToInternal1") + public void testSimpleDependencyErrorOnAccessToInternal1() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal1/"); + } + + @TestMetadata("simpleDependencyErrorOnAccessToInternal2") + public void testSimpleDependencyErrorOnAccessToInternal2() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal2/"); + } + + @TestMetadata("simpleDependencyUnchanged") + public void testSimpleDependencyUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/simpleDependencyUnchanged/"); + } + + @TestMetadata("transitiveDependency") + public void testTransitiveDependency() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/transitiveDependency/"); + } + + @TestMetadata("transitiveInlining") + public void testTransitiveInlining() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/transitiveInlining/"); + } + + @TestMetadata("twoDependants") + public void testTwoDependants() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/common/twoDependants/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/classAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/classAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/classRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/classRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/constantValueChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstantValueChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConstantValueChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/constantValueChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/copyFileToAnotherModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CopyFileToAnotherModule extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCopyFileToAnotherModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/copyFileToAnotherModule"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultArgumentInConstructorRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultArgumentInConstructorRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultArgumentInConstructorRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultArgumentInConstructorRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterAddedForTopLevelFun") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterAddedForTopLevelFun extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterAddedForTopLevelFun() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterAddedForTopLevelFun"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemovedForTopLevelFun") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultParameterRemovedForTopLevelFun extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultParameterRemovedForTopLevelFun() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultParameterRemovedForTopLevelFun"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/defaultValueInConstructorRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValueInConstructorRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValueInConstructorRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/defaultValueInConstructorRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/duplicatedClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DuplicatedClass extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDuplicatedClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/duplicatedClass"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/exportedDependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExportedDependency extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInExportedDependency() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/exportedDependency"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/functionFromDifferentPackageChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionFromDifferentPackageChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunctionFromDifferentPackageChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/functionFromDifferentPackageChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/inlineFunctionInlined") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionInlined extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionInlined() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/inlineFunctionInlined"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/inlineFunctionTwoPackageParts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionTwoPackageParts extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionTwoPackageParts() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/inlineFunctionTwoPackageParts"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/moveFileToAnotherModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MoveFileToAnotherModule extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMoveFileToAnotherModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/moveFileToAnotherModule"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simple") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Simple extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSimple() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simple"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependency extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependency() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependency"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal1") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependencyErrorOnAccessToInternal1 extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependencyErrorOnAccessToInternal1() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal1"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal2") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependencyErrorOnAccessToInternal2 extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependencyErrorOnAccessToInternal2() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependencyErrorOnAccessToInternal2"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/simpleDependencyUnchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleDependencyUnchanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSimpleDependencyUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/simpleDependencyUnchanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/transitiveDependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TransitiveDependency extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTransitiveDependency() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/transitiveDependency"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/transitiveInlining") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TransitiveInlining extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTransitiveInlining() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/transitiveInlining"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/common/twoDependants") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TwoDependants extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTwoDependants() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/common/twoDependants"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/jvm") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJvm() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/jvm"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("circular") + public void testCircular() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/jvm/circular/"); + } + + @TestMetadata("circularDependencyClasses") + public void testCircularDependencyClasses() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyClasses/"); + } + + @TestMetadata("circularDependencySamePackageUnchanged") + public void testCircularDependencySamePackageUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/jvm/circularDependencySamePackageUnchanged/"); + } + + @TestMetadata("circularDependencyTopLevelFunctions") + public void testCircularDependencyTopLevelFunctions() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyTopLevelFunctions/"); + } + + @TestMetadata("circularDependencyWithAccessToInternal") + public void testCircularDependencyWithAccessToInternal() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyWithAccessToInternal/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/jvm/circular") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Circular extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCircular() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/jvm/circular"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyClasses") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CircularDependencyClasses extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCircularDependencyClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyClasses"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/jvm/circularDependencySamePackageUnchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CircularDependencySamePackageUnchanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCircularDependencySamePackageUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/jvm/circularDependencySamePackageUnchanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyTopLevelFunctions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CircularDependencyTopLevelFunctions extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCircularDependencyTopLevelFunctions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyTopLevelFunctions"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyWithAccessToInternal") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CircularDependencyWithAccessToInternal extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCircularDependencyWithAccessToInternal() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/jvm/circularDependencyWithAccessToInternal"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Custom extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCustom() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("buildError") + public void testBuildError() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/buildError/"); + } + + @TestMetadata("buildError2Levels") + public void testBuildError2Levels() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/buildError2Levels/"); + } + + @TestMetadata("commonSourcesCompilerArg") + public void testCommonSourcesCompilerArg() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/commonSourcesCompilerArg/"); + } + + @TestMetadata("complementaryFiles") + public void testComplementaryFiles() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/complementaryFiles/"); + } + + @TestMetadata("modifyOptionalAnnotationUsage") + public void testModifyOptionalAnnotationUsage() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/modifyOptionalAnnotationUsage/"); + } + + @TestMetadata("notSameCompiler") + public void testNotSameCompiler() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/notSameCompiler/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/buildError") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BuildError extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInBuildError() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/buildError"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/buildError2Levels") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BuildError2Levels extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInBuildError2Levels() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/buildError2Levels"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/commonSourcesCompilerArg") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CommonSourcesCompilerArg extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCommonSourcesCompilerArg() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/commonSourcesCompilerArg"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/complementaryFiles") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ComplementaryFiles extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInComplementaryFiles() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/complementaryFiles"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/modifyOptionalAnnotationUsage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ModifyOptionalAnnotationUsage extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInModifyOptionalAnnotationUsage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/modifyOptionalAnnotationUsage"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/notSameCompiler") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NotSameCompiler extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInNotSameCompiler() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/notSameCompiler"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/pureKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PureKotlin extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + @TestMetadata("accessingFunctionsViaPackagePart") + public void testAccessingFunctionsViaPackagePart() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/accessingFunctionsViaPackagePart/"); + } + + @TestMetadata("accessingPropertiesViaField") + public void testAccessingPropertiesViaField() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/accessingPropertiesViaField/"); + } + + @TestMetadata("addClass") + public void testAddClass() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/addClass/"); + } + + @TestMetadata("addFileWithFunctionOverload") + public void testAddFileWithFunctionOverload() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/addFileWithFunctionOverload/"); + } + + @TestMetadata("addMemberTypeAlias") + public void testAddMemberTypeAlias() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/addMemberTypeAlias/"); + } + + @TestMetadata("addTopLevelTypeAlias") + public void testAddTopLevelTypeAlias() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/addTopLevelTypeAlias/"); + } + + @TestMetadata("allConstants") + public void testAllConstants() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/allConstants/"); + } + + public void testAllFilesPresentInPureKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, false); + } + + @TestMetadata("annotations") + public void testAnnotations() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/annotations/"); + } + + @TestMetadata("anonymousObjectChanged") + public void testAnonymousObjectChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/anonymousObjectChanged/"); + } + + @TestMetadata("changeTypeImplicitlyWithCircularDependency") + public void testChangeTypeImplicitlyWithCircularDependency() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/changeTypeImplicitlyWithCircularDependency/"); + } + + @TestMetadata("changeWithRemovingUsage") + public void testChangeWithRemovingUsage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/changeWithRemovingUsage/"); + } + + @TestMetadata("classInlineFunctionChanged") + public void testClassInlineFunctionChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/classInlineFunctionChanged/"); + } + + @TestMetadata("classObjectConstantChanged") + public void testClassObjectConstantChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/classObjectConstantChanged/"); + } + + @TestMetadata("classRecreated") + public void testClassRecreated() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/classRecreated/"); + } + + @TestMetadata("classRemoved") + public void testClassRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/classRemoved/"); + } + + @TestMetadata("classSignatureChanged") + public void testClassSignatureChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/classSignatureChanged/"); + } + + @TestMetadata("classSignatureUnchanged") + public void testClassSignatureUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/classSignatureUnchanged/"); + } + + @TestMetadata("compilationErrorThenFixedOtherPackage") + public void testCompilationErrorThenFixedOtherPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedOtherPackage/"); + } + + @TestMetadata("compilationErrorThenFixedSamePackage") + public void testCompilationErrorThenFixedSamePackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedSamePackage/"); + } + + @TestMetadata("compilationErrorThenFixedWithPhantomPart") + public void testCompilationErrorThenFixedWithPhantomPart() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedWithPhantomPart/"); + } + + @TestMetadata("compilationErrorThenFixedWithPhantomPart2") + public void testCompilationErrorThenFixedWithPhantomPart2() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedWithPhantomPart2/"); + } + + @TestMetadata("compilationErrorThenFixedWithPhantomPart3") + public void testCompilationErrorThenFixedWithPhantomPart3() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedWithPhantomPart3/"); + } + + @TestMetadata("constantRemoved") + public void testConstantRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/constantRemoved/"); + } + + @TestMetadata("constantValueChanged") + public void testConstantValueChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/constantValueChanged/"); + } + + @TestMetadata("constantsUnchanged") + public void testConstantsUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/"); + } + + @TestMetadata("defaultArgumentInConstructorAdded") + public void testDefaultArgumentInConstructorAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultArgumentInConstructorAdded/"); + } + + @TestMetadata("defaultArgumentInConstructorRemoved") + public void testDefaultArgumentInConstructorRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultArgumentInConstructorRemoved/"); + } + + @TestMetadata("defaultValueAdded") + public void testDefaultValueAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultValueAdded/"); + } + + @TestMetadata("defaultValueChanged") + public void testDefaultValueChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultValueChanged/"); + } + + @TestMetadata("defaultValueInConstructorChanged") + public void testDefaultValueInConstructorChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultValueInConstructorChanged/"); + } + + @TestMetadata("defaultValueInConstructorRemoved") + public void testDefaultValueInConstructorRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultValueInConstructorRemoved/"); + } + + @TestMetadata("defaultValueRemoved1") + public void testDefaultValueRemoved1() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultValueRemoved1/"); + } + + @TestMetadata("defaultValueRemoved2") + public void testDefaultValueRemoved2() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/defaultValueRemoved2/"); + } + + @TestMetadata("delegatedPropertyInlineExtensionAccessor") + public void testDelegatedPropertyInlineExtensionAccessor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/"); + } + + @TestMetadata("delegatedPropertyInlineMethodAccessor") + public void testDelegatedPropertyInlineMethodAccessor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/"); + } + + @TestMetadata("dependencyClassReferenced") + public void testDependencyClassReferenced() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/dependencyClassReferenced/"); + } + + @TestMetadata("fileWithConstantRemoved") + public void testFileWithConstantRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/fileWithConstantRemoved/"); + } + + @TestMetadata("fileWithInlineFunctionRemoved") + public void testFileWithInlineFunctionRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/fileWithInlineFunctionRemoved/"); + } + + @TestMetadata("filesExchangePackages") + public void testFilesExchangePackages() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/filesExchangePackages/"); + } + + @TestMetadata("funRedeclaration") + public void testFunRedeclaration() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/funRedeclaration/"); + } + + @TestMetadata("funVsConstructorOverloadConflict") + public void testFunVsConstructorOverloadConflict() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/"); + } + + @TestMetadata("functionBecameInline") + public void testFunctionBecameInline() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/functionBecameInline/"); + } + + @TestMetadata("functionReferencingClass") + public void testFunctionReferencingClass() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/"); + } + + @TestMetadata("independentClasses") + public void testIndependentClasses() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/independentClasses/"); + } + + @TestMetadata("inlineFunctionBecomesNonInline") + public void testInlineFunctionBecomesNonInline() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineFunctionBecomesNonInline/"); + } + + @TestMetadata("inlineFunctionUsageAdded") + public void testInlineFunctionUsageAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineFunctionUsageAdded/"); + } + + @TestMetadata("inlineFunctionsCircularDependency") + public void testInlineFunctionsCircularDependency() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineFunctionsCircularDependency/"); + } + + @TestMetadata("inlineFunctionsUnchanged") + public void testInlineFunctionsUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineFunctionsUnchanged/"); + } + + @TestMetadata("inlineLinesChanged") + public void testInlineLinesChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineLinesChanged/"); + } + + @TestMetadata("inlineModifiedWithUsage") + public void testInlineModifiedWithUsage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineModifiedWithUsage/"); + } + + @TestMetadata("inlinePrivateFunctionAdded") + public void testInlinePrivateFunctionAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlinePrivateFunctionAdded/"); + } + + @TestMetadata("inlinePropertyInClass") + public void testInlinePropertyInClass() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlinePropertyInClass/"); + } + + @TestMetadata("inlinePropertyOnTopLevel") + public void testInlinePropertyOnTopLevel() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlinePropertyOnTopLevel/"); + } + + @TestMetadata("inlineSuspendFunctionChanged") + public void testInlineSuspendFunctionChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineSuspendFunctionChanged/"); + } + + @TestMetadata("inlineTwoFunctionsOneChanged") + public void testInlineTwoFunctionsOneChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineTwoFunctionsOneChanged/"); + } + + @TestMetadata("inlineUsedWhereDeclared") + public void testInlineUsedWhereDeclared() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/"); + } + + @TestMetadata("innerClassesFromSupertypes") + public void testInnerClassesFromSupertypes() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/"); + } + + @TestMetadata("internalClassChanged") + public void testInternalClassChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/"); + } + + @TestMetadata("internalMemberInClassChanged") + public void testInternalMemberInClassChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/internalMemberInClassChanged/"); + } + + @TestMetadata("internalTypealias") + public void testInternalTypealias() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/internalTypealias/"); + } + + @TestMetadata("internalTypealiasConstructor") + public void testInternalTypealiasConstructor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/internalTypealiasConstructor/"); + } + + @TestMetadata("internalTypealiasObject") + public void testInternalTypealiasObject() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/internalTypealiasObject/"); + } + + @TestMetadata("localClassChanged") + public void testLocalClassChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/localClassChanged/"); + } + + @TestMetadata("moveClass") + public void testMoveClass() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/moveClass/"); + } + + @TestMetadata("moveFileWithChangingPackage") + public void testMoveFileWithChangingPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/moveFileWithChangingPackage/"); + } + + @TestMetadata("moveFileWithoutChangingPackage") + public void testMoveFileWithoutChangingPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/moveFileWithoutChangingPackage/"); + } + + @TestMetadata("multiplePackagesModified") + public void testMultiplePackagesModified() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/multiplePackagesModified/"); + } + + @TestMetadata("objectConstantChanged") + public void testObjectConstantChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/objectConstantChanged/"); + } + + @TestMetadata("ourClassReferenced") + public void testOurClassReferenced() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/ourClassReferenced/"); + } + + @TestMetadata("overloadInlined") + public void testOverloadInlined() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/overloadInlined/"); + } + + @TestMetadata("packageConstantChanged") + public void testPackageConstantChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageConstantChanged/"); + } + + @TestMetadata("packageFileAdded") + public void testPackageFileAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageFileAdded/"); + } + + @TestMetadata("packageFileChangedPackage") + public void testPackageFileChangedPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageFileChangedPackage/"); + } + + @TestMetadata("packageFileChangedThenOtherRemoved") + public void testPackageFileChangedThenOtherRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageFileChangedThenOtherRemoved/"); + } + + @TestMetadata("packageFileRemoved") + public void testPackageFileRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageFileRemoved/"); + } + + @TestMetadata("packageFilesChangedInTurn") + public void testPackageFilesChangedInTurn() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageFilesChangedInTurn/"); + } + + @TestMetadata("packageInlineFunctionAccessingField") + public void testPackageInlineFunctionAccessingField() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageInlineFunctionAccessingField/"); + } + + @TestMetadata("packageInlineFunctionFromOurPackage") + public void testPackageInlineFunctionFromOurPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageInlineFunctionFromOurPackage/"); + } + + @TestMetadata("packagePrivateOnlyChanged") + public void testPackagePrivateOnlyChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packagePrivateOnlyChanged/"); + } + + @TestMetadata("packageRecreated") + public void testPackageRecreated() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageRecreated/"); + } + + @TestMetadata("packageRecreatedAfterRenaming") + public void testPackageRecreatedAfterRenaming() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageRecreatedAfterRenaming/"); + } + + @TestMetadata("packageRemoved") + public void testPackageRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/packageRemoved/"); + } + + @TestMetadata("parameterWithDefaultValueAdded") + public void testParameterWithDefaultValueAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/parameterWithDefaultValueAdded/"); + } + + @TestMetadata("parameterWithDefaultValueRemoved") + public void testParameterWithDefaultValueRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/parameterWithDefaultValueRemoved/"); + } + + @TestMetadata("privateConstantsChanged") + public void testPrivateConstantsChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateConstantsChanged/"); + } + + @TestMetadata("privateMethodAdded") + public void testPrivateMethodAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateMethodAdded/"); + } + + @TestMetadata("privateMethodDeleted") + public void testPrivateMethodDeleted() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateMethodDeleted/"); + } + + @TestMetadata("privateMethodSignatureChanged") + public void testPrivateMethodSignatureChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateMethodSignatureChanged/"); + } + + @TestMetadata("privateSecondaryConstructorAdded") + public void testPrivateSecondaryConstructorAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateSecondaryConstructorAdded/"); + } + + @TestMetadata("privateSecondaryConstructorDeleted") + public void testPrivateSecondaryConstructorDeleted() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateSecondaryConstructorDeleted/"); + } + + @TestMetadata("privateValAccessorChanged") + public void testPrivateValAccessorChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateValAccessorChanged/"); + } + + @TestMetadata("privateValAdded") + public void testPrivateValAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateValAdded/"); + } + + @TestMetadata("privateValDeleted") + public void testPrivateValDeleted() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateValDeleted/"); + } + + @TestMetadata("privateValSignatureChanged") + public void testPrivateValSignatureChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateValSignatureChanged/"); + } + + @TestMetadata("privateVarAdded") + public void testPrivateVarAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateVarAdded/"); + } + + @TestMetadata("privateVarDeleted") + public void testPrivateVarDeleted() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateVarDeleted/"); + } + + @TestMetadata("privateVarSignatureChanged") + public void testPrivateVarSignatureChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/privateVarSignatureChanged/"); + } + + @TestMetadata("propertyRedeclaration") + public void testPropertyRedeclaration() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/"); + } + + @TestMetadata("publicPropertyWithPrivateSetter") + public void testPublicPropertyWithPrivateSetter() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/publicPropertyWithPrivateSetter/"); + } + + @TestMetadata("removeAndRestoreCompanion") + public void testRemoveAndRestoreCompanion() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeAndRestoreCompanion/"); + } + + @TestMetadata("removeAndRestoreCompanionWithImplicitUsages") + public void testRemoveAndRestoreCompanionWithImplicitUsages() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeAndRestoreCompanionWithImplicitUsages/"); + } + + @TestMetadata("removeClass") + public void testRemoveClass() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeClass/"); + } + + @TestMetadata("removeClassInDefaultPackage") + public void testRemoveClassInDefaultPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeClassInDefaultPackage/"); + } + + @TestMetadata("removeFileWithFunctionOverload") + public void testRemoveFileWithFunctionOverload() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeFileWithFunctionOverload/"); + } + + @TestMetadata("removeMemberTypeAlias") + public void testRemoveMemberTypeAlias() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeMemberTypeAlias/"); + } + + @TestMetadata("removeTopLevelTypeAlias") + public void testRemoveTopLevelTypeAlias() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeTopLevelTypeAlias/"); + } + + @TestMetadata("removeUnusedFile") + public void testRemoveUnusedFile() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/removeUnusedFile/"); + } + + @TestMetadata("renameClass") + public void testRenameClass() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/renameClass/"); + } + + @TestMetadata("renameFileWithFunctionOverload") + public void testRenameFileWithFunctionOverload() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/renameFileWithFunctionOverload/"); + } + + @TestMetadata("returnTypeChanged") + public void testReturnTypeChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/returnTypeChanged/"); + } + + @TestMetadata("sealedClassesAddImplements") + public void testSealedClassesAddImplements() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/sealedClassesAddImplements/"); + } + + @TestMetadata("sealedClassesAddInheritor") + public void testSealedClassesAddInheritor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/sealedClassesAddInheritor/"); + } + + @TestMetadata("sealedClassesRemoveImplements") + public void testSealedClassesRemoveImplements() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/sealedClassesRemoveImplements/"); + } + + @TestMetadata("sealedClassesRemoveInheritor") + public void testSealedClassesRemoveInheritor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/sealedClassesRemoveInheritor/"); + } + + @TestMetadata("sealedClassesUseSwitch") + public void testSealedClassesUseSwitch() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/sealedClassesUseSwitch/"); + } + + @TestMetadata("secondaryConstructorInlined") + public void testSecondaryConstructorInlined() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/"); + } + + @TestMetadata("simpleClassDependency") + public void testSimpleClassDependency() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/"); + } + + @TestMetadata("soleFileChangesPackage") + public void testSoleFileChangesPackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/soleFileChangesPackage/"); + } + + @TestMetadata("subpackage") + public void testSubpackage() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/subpackage/"); + } + + @TestMetadata("suspendWithStateMachine") + public void testSuspendWithStateMachine() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/suspendWithStateMachine/"); + } + + @TestMetadata("topLevelFunctionSameSignature") + public void testTopLevelFunctionSameSignature() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/topLevelFunctionSameSignature/"); + } + + @TestMetadata("topLevelMembersInTwoFiles") + public void testTopLevelMembersInTwoFiles() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/topLevelMembersInTwoFiles/"); + } + + @TestMetadata("topLevelPrivateValUsageAdded") + public void testTopLevelPrivateValUsageAdded() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/topLevelPrivateValUsageAdded/"); + } + + @TestMetadata("traitClassObjectConstantChanged") + public void testTraitClassObjectConstantChanged() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/traitClassObjectConstantChanged/"); + } + + @TestMetadata("valAddCustomAccessor") + public void testValAddCustomAccessor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/valAddCustomAccessor/"); + } + + @TestMetadata("valRemoveCustomAccessor") + public void testValRemoveCustomAccessor() throws Exception { + runTest("jps-plugin/testData/incremental/pureKotlin/valRemoveCustomAccessor/"); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class WithJava extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInWithJava() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConvertBetweenJavaAndKotlin extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConvertBetweenJavaAndKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("javaToKotlin") + public void testJavaToKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlin/"); + } + + @TestMetadata("javaToKotlinAndBack") + public void testJavaToKotlinAndBack() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlinAndBack/"); + } + + @TestMetadata("javaToKotlinAndRemove") + public void testJavaToKotlinAndRemove() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlinAndRemove/"); + } + + @TestMetadata("kotlinToJava") + public void testKotlinToJava() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/kotlinToJava/"); + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaToKotlin extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaToKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlin"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlinAndBack") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaToKotlinAndBack extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaToKotlinAndBack() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlinAndBack"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlinAndRemove") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaToKotlinAndRemove extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaToKotlinAndRemove() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/javaToKotlinAndRemove"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/kotlinToJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class KotlinToJava extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInKotlinToJava() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/convertBetweenJavaAndKotlin/kotlinToJava"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaUsedInKotlin extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaUsedInKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("changeFieldType") + public void testChangeFieldType() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType/"); + } + + @TestMetadata("changeNotUsedSignature") + public void testChangeNotUsedSignature() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeNotUsedSignature/"); + } + + @TestMetadata("changePropertyOverrideType") + public void testChangePropertyOverrideType() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changePropertyOverrideType/"); + } + + @TestMetadata("changeSignature") + public void testChangeSignature() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignature/"); + } + + @TestMetadata("changeSignaturePackagePrivate") + public void testChangeSignaturePackagePrivate() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignaturePackagePrivate/"); + } + + @TestMetadata("changeSignaturePackagePrivateNonRoot") + public void testChangeSignaturePackagePrivateNonRoot() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignaturePackagePrivateNonRoot/"); + } + + @TestMetadata("changeSignatureStatic") + public void testChangeSignatureStatic() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignatureStatic/"); + } + + @TestMetadata("constantChanged") + public void testConstantChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/constantChanged/"); + } + + @TestMetadata("constantUnchanged") + public void testConstantUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/constantUnchanged/"); + } + + @TestMetadata("enumEntryAdded") + public void testEnumEntryAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/enumEntryAdded/"); + } + + @TestMetadata("enumEntryRemoved") + public void testEnumEntryRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/enumEntryRemoved/"); + } + + @TestMetadata("javaAndKotlinChangedSimultaneously") + public void testJavaAndKotlinChangedSimultaneously() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaAndKotlinChangedSimultaneously/"); + } + + @TestMetadata("javaFieldNullabilityChanged") + public void testJavaFieldNullabilityChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaFieldNullabilityChanged/"); + } + + @TestMetadata("javaMethodParamNullabilityChanged") + public void testJavaMethodParamNullabilityChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaMethodParamNullabilityChanged/"); + } + + @TestMetadata("javaMethodReturnTypeNullabilityChanged") + public void testJavaMethodReturnTypeNullabilityChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaMethodReturnTypeNullabilityChanged/"); + } + + @TestMetadata("methodAddedInSuper") + public void testMethodAddedInSuper() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/methodAddedInSuper/"); + } + + @TestMetadata("methodRenamed") + public void testMethodRenamed() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/methodRenamed/"); + } + + @TestMetadata("mixedInheritance") + public void testMixedInheritance() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/mixedInheritance/"); + } + + @TestMetadata("notChangeSignature") + public void testNotChangeSignature() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/notChangeSignature/"); + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeFieldType extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeFieldType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeNotUsedSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeNotUsedSignature extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeNotUsedSignature() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeNotUsedSignature"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changePropertyOverrideType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangePropertyOverrideType extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangePropertyOverrideType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changePropertyOverrideType"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeSignature extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeSignature() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignature"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignaturePackagePrivate") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeSignaturePackagePrivate extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeSignaturePackagePrivate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignaturePackagePrivate"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignaturePackagePrivateNonRoot") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeSignaturePackagePrivateNonRoot extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeSignaturePackagePrivateNonRoot() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignaturePackagePrivateNonRoot"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignatureStatic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeSignatureStatic extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeSignatureStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeSignatureStatic"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/constantChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstantChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConstantChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/constantChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/constantUnchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstantUnchanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConstantUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/constantUnchanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/enumEntryAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumEntryAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInEnumEntryAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/enumEntryAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/enumEntryRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumEntryRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInEnumEntryRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/enumEntryRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaAndKotlinChangedSimultaneously") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaAndKotlinChangedSimultaneously extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaAndKotlinChangedSimultaneously() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaAndKotlinChangedSimultaneously"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaFieldNullabilityChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaFieldNullabilityChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaFieldNullabilityChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaFieldNullabilityChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaMethodParamNullabilityChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaMethodParamNullabilityChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaMethodParamNullabilityChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaMethodParamNullabilityChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaMethodReturnTypeNullabilityChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaMethodReturnTypeNullabilityChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaMethodReturnTypeNullabilityChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/javaMethodReturnTypeNullabilityChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/methodAddedInSuper") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodAddedInSuper extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodAddedInSuper() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/methodAddedInSuper"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/methodRenamed") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodRenamed extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodRenamed() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/methodRenamed"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/mixedInheritance") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedInheritance extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMixedInheritance() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/mixedInheritance"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/notChangeSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NotChangeSignature extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInNotChangeSignature() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/notChangeSignature"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SamConversions extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSamConversions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("methodAdded") + public void testMethodAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodAdded/"); + } + + @TestMetadata("methodAddedSamAdapter") + public void testMethodAddedSamAdapter() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodAddedSamAdapter/"); + } + + @TestMetadata("methodSignatureChanged") + public void testMethodSignatureChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodSignatureChanged/"); + } + + @TestMetadata("methodSignatureChangedSamAdapter") + public void testMethodSignatureChangedSamAdapter() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodSignatureChangedSamAdapter/"); + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodAddedSamAdapter") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodAddedSamAdapter extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodAddedSamAdapter() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodAddedSamAdapter"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodSignatureChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodSignatureChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodSignatureChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodSignatureChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodSignatureChangedSamAdapter") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodSignatureChangedSamAdapter extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodSignatureChangedSamAdapter() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions/methodSignatureChangedSamAdapter"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class KotlinUsedInJava extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + @TestMetadata("addOptionalParameter") + public void testAddOptionalParameter() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/addOptionalParameter/"); + } + + public void testAllFilesPresentInKotlinUsedInJava() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("changeNotUsedSignature") + public void testChangeNotUsedSignature() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/changeNotUsedSignature/"); + } + + @TestMetadata("changeSignature") + public void testChangeSignature() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/changeSignature/"); + } + + @TestMetadata("constantChanged") + public void testConstantChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/constantChanged/"); + } + + @TestMetadata("constantUnchanged") + public void testConstantUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/constantUnchanged/"); + } + + @TestMetadata("funRenamed") + public void testFunRenamed() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/funRenamed/"); + } + + @TestMetadata("jvmFieldChanged") + public void testJvmFieldChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldChanged/"); + } + + @TestMetadata("jvmFieldUnchanged") + public void testJvmFieldUnchanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldUnchanged/"); + } + + @TestMetadata("methodAddedInSuper") + public void testMethodAddedInSuper() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper/"); + } + + @TestMetadata("notChangeSignature") + public void testNotChangeSignature() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/notChangeSignature/"); + } + + @TestMetadata("onlyTopLevelFunctionInFileRemoved") + public void testOnlyTopLevelFunctionInFileRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/onlyTopLevelFunctionInFileRemoved/"); + } + + @TestMetadata("packageFileAdded") + public void testPackageFileAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/packageFileAdded/"); + } + + @TestMetadata("privateChanges") + public void testPrivateChanges() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/privateChanges/"); + } + + @TestMetadata("propertyRenamed") + public void testPropertyRenamed() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/propertyRenamed/"); + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/addOptionalParameter") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AddOptionalParameter extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInAddOptionalParameter() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/addOptionalParameter"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/changeNotUsedSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeNotUsedSignature extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeNotUsedSignature() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/changeNotUsedSignature"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/changeSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeSignature extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInChangeSignature() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/changeSignature"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/constantChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstantChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConstantChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/constantChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/constantUnchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstantUnchanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConstantUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/constantUnchanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/funRenamed") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunRenamed extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunRenamed() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/funRenamed"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JvmFieldChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJvmFieldChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldUnchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JvmFieldUnchanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJvmFieldUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/jvmFieldUnchanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodAddedInSuper extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodAddedInSuper() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/methodAddedInSuper"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/notChangeSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NotChangeSignature extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInNotChangeSignature() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/notChangeSignature"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/onlyTopLevelFunctionInFileRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class OnlyTopLevelFunctionInFileRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInOnlyTopLevelFunctionInFileRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/onlyTopLevelFunctionInFileRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/packageFileAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFileAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPackageFileAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/packageFileAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/privateChanges") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PrivateChanges extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPrivateChanges() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/privateChanges"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/propertyRenamed") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyRenamed extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPropertyRenamed() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/kotlinUsedInJava/propertyRenamed"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Other extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + @TestMetadata("accessingFunctionsViaRenamedFileClass") + public void testAccessingFunctionsViaRenamedFileClass() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/accessingFunctionsViaRenamedFileClass/"); + } + + public void testAllFilesPresentInOther() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("allKotlinFilesRemovedThenNewAdded") + public void testAllKotlinFilesRemovedThenNewAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/allKotlinFilesRemovedThenNewAdded/"); + } + + @TestMetadata("classRedeclaration") + public void testClassRedeclaration() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/classRedeclaration/"); + } + + @TestMetadata("classToPackageFacade") + public void testClassToPackageFacade() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/classToPackageFacade/"); + } + + @TestMetadata("conflictingPlatformDeclarations") + public void testConflictingPlatformDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/conflictingPlatformDeclarations/"); + } + + @TestMetadata("defaultValueInConstructorAdded") + public void testDefaultValueInConstructorAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/defaultValueInConstructorAdded/"); + } + + @TestMetadata("inlineFunctionWithJvmNameInClass") + public void testInlineFunctionWithJvmNameInClass() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/inlineFunctionWithJvmNameInClass/"); + } + + @TestMetadata("inlineTopLevelFunctionWithJvmName") + public void testInlineTopLevelFunctionWithJvmName() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/inlineTopLevelFunctionWithJvmName/"); + } + + @TestMetadata("inlineTopLevelValPropertyWithJvmName") + public void testInlineTopLevelValPropertyWithJvmName() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/inlineTopLevelValPropertyWithJvmName/"); + } + + @TestMetadata("innerClassNotGeneratedWhenRebuilding") + public void testInnerClassNotGeneratedWhenRebuilding() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/innerClassNotGeneratedWhenRebuilding/"); + } + + @TestMetadata("jvmNameChanged") + public void testJvmNameChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/jvmNameChanged/"); + } + + @TestMetadata("mainRedeclaration") + public void testMainRedeclaration() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/mainRedeclaration/"); + } + + @TestMetadata("multifileClassAddTopLevelFunWithDefault") + public void testMultifileClassAddTopLevelFunWithDefault() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault/"); + } + + @TestMetadata("multifileClassFileAdded") + public void testMultifileClassFileAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded/"); + } + + @TestMetadata("multifileClassFileChanged") + public void testMultifileClassFileChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged/"); + } + + @TestMetadata("multifileClassFileMovedToAnotherMultifileClass") + public void testMultifileClassFileMovedToAnotherMultifileClass() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassFileMovedToAnotherMultifileClass/"); + } + + @TestMetadata("multifileClassInlineFunction") + public void testMultifileClassInlineFunction() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassInlineFunction/"); + } + + @TestMetadata("multifileClassInlineFunctionAccessingField") + public void testMultifileClassInlineFunctionAccessingField() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassInlineFunctionAccessingField/"); + } + + @TestMetadata("multifileClassRecreated") + public void testMultifileClassRecreated() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassRecreated/"); + } + + @TestMetadata("multifileClassRecreatedAfterRenaming") + public void testMultifileClassRecreatedAfterRenaming() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassRecreatedAfterRenaming/"); + } + + @TestMetadata("multifileClassRemoved") + public void testMultifileClassRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileClassRemoved/"); + } + + @TestMetadata("multifilePackagePartMethodAdded") + public void testMultifilePackagePartMethodAdded() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded/"); + } + + @TestMetadata("multifilePartsWithProperties") + public void testMultifilePartsWithProperties() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/"); + } + + @TestMetadata("multifileDependantUsage") + public void testMultifileDependantUsage() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/"); + } + + @TestMetadata("optionalParameter") + public void testOptionalParameter() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/optionalParameter/"); + } + + @TestMetadata("packageFacadeToClass") + public void testPackageFacadeToClass() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/packageFacadeToClass/"); + } + + @TestMetadata("packageMultifileClassOneFileWithPublicChanges") + public void testPackageMultifileClassOneFileWithPublicChanges() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/packageMultifileClassOneFileWithPublicChanges/"); + } + + @TestMetadata("packageMultifileClassPrivateOnlyChanged") + public void testPackageMultifileClassPrivateOnlyChanged() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/packageMultifileClassPrivateOnlyChanged/"); + } + + @TestMetadata("publicPropertyWithPrivateSetterMultiFileFacade") + public void testPublicPropertyWithPrivateSetterMultiFileFacade() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/publicPropertyWithPrivateSetterMultiFileFacade/"); + } + + @TestMetadata("topLevelFunctionWithJvmName") + public void testTopLevelFunctionWithJvmName() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/topLevelFunctionWithJvmName/"); + } + + @TestMetadata("topLevelPropertyWithJvmName") + public void testTopLevelPropertyWithJvmName() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/topLevelPropertyWithJvmName/"); + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/accessingFunctionsViaRenamedFileClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AccessingFunctionsViaRenamedFileClass extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInAccessingFunctionsViaRenamedFileClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/accessingFunctionsViaRenamedFileClass"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/allKotlinFilesRemovedThenNewAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AllKotlinFilesRemovedThenNewAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInAllKotlinFilesRemovedThenNewAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/allKotlinFilesRemovedThenNewAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/classRedeclaration") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassRedeclaration extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassRedeclaration() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/classRedeclaration"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/classToPackageFacade") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassToPackageFacade extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassToPackageFacade() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/classToPackageFacade"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/conflictingPlatformDeclarations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConflictingPlatformDeclarations extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConflictingPlatformDeclarations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/conflictingPlatformDeclarations"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/defaultValueInConstructorAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValueInConstructorAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValueInConstructorAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/defaultValueInConstructorAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/inlineFunctionWithJvmNameInClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionWithJvmNameInClass extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionWithJvmNameInClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/inlineFunctionWithJvmNameInClass"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/inlineTopLevelFunctionWithJvmName") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineTopLevelFunctionWithJvmName extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineTopLevelFunctionWithJvmName() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/inlineTopLevelFunctionWithJvmName"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/inlineTopLevelValPropertyWithJvmName") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineTopLevelValPropertyWithJvmName extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineTopLevelValPropertyWithJvmName() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/inlineTopLevelValPropertyWithJvmName"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/innerClassNotGeneratedWhenRebuilding") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InnerClassNotGeneratedWhenRebuilding extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInnerClassNotGeneratedWhenRebuilding() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/innerClassNotGeneratedWhenRebuilding"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/jvmNameChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JvmNameChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJvmNameChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/jvmNameChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/mainRedeclaration") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MainRedeclaration extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMainRedeclaration() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/mainRedeclaration"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassAddTopLevelFunWithDefault extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassAddTopLevelFunWithDefault() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassFileAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassFileAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassFileChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassFileChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassFileMovedToAnotherMultifileClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassFileMovedToAnotherMultifileClass extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassFileMovedToAnotherMultifileClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassFileMovedToAnotherMultifileClass"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassInlineFunction") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassInlineFunction extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassInlineFunction() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassInlineFunction"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassInlineFunctionAccessingField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassInlineFunctionAccessingField extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassInlineFunctionAccessingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassInlineFunctionAccessingField"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassRecreated") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassRecreated extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassRecreated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassRecreated"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassRecreatedAfterRenaming") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassRecreatedAfterRenaming extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassRecreatedAfterRenaming() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassRecreatedAfterRenaming"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifileClassRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifileClassRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifileClassRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifileClassRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifilePackagePartMethodAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifilePackagePartMethodAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifilePartsWithProperties extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMultifilePartsWithProperties() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/optionalParameter") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class OptionalParameter extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInOptionalParameter() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/optionalParameter"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/packageFacadeToClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadeToClass extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadeToClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/packageFacadeToClass"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/packageMultifileClassOneFileWithPublicChanges") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageMultifileClassOneFileWithPublicChanges extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPackageMultifileClassOneFileWithPublicChanges() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/packageMultifileClassOneFileWithPublicChanges"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/packageMultifileClassPrivateOnlyChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageMultifileClassPrivateOnlyChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPackageMultifileClassPrivateOnlyChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/packageMultifileClassPrivateOnlyChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/publicPropertyWithPrivateSetterMultiFileFacade") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PublicPropertyWithPrivateSetterMultiFileFacade extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPublicPropertyWithPrivateSetterMultiFileFacade() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/publicPropertyWithPrivateSetterMultiFileFacade"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/topLevelFunctionWithJvmName") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TopLevelFunctionWithJvmName extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTopLevelFunctionWithJvmName() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/topLevelFunctionWithJvmName"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/withJava/other/topLevelPropertyWithJvmName") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TopLevelPropertyWithJvmName extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTopLevelPropertyWithJvmName() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/topLevelPropertyWithJvmName"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunCallSite extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunCallSite() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("classProperty") + public void testClassProperty() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/classProperty/"); + } + + @TestMetadata("companionObjectProperty") + public void testCompanionObjectProperty() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/companionObjectProperty/"); + } + + @TestMetadata("coroutine") + public void testCoroutine() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/coroutine/"); + } + + @TestMetadata("function") + public void testFunction() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/function/"); + } + + @TestMetadata("getter") + public void testGetter() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/getter/"); + } + + @TestMetadata("lambda") + public void testLambda() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/lambda/"); + } + + @TestMetadata("localFun") + public void testLocalFun() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/localFun/"); + } + + @TestMetadata("method") + public void testMethod() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/method/"); + } + + @TestMetadata("parameterDefaultValue") + public void testParameterDefaultValue() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/parameterDefaultValue/"); + } + + @TestMetadata("primaryConstructorParameterDefaultValue") + public void testPrimaryConstructorParameterDefaultValue() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/primaryConstructorParameterDefaultValue/"); + } + + @TestMetadata("superCall") + public void testSuperCall() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/superCall/"); + } + + @TestMetadata("thisCall") + public void testThisCall() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/thisCall/"); + } + + @TestMetadata("topLevelObjectProperty") + public void testTopLevelObjectProperty() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/topLevelObjectProperty/"); + } + + @TestMetadata("topLevelProperty") + public void testTopLevelProperty() throws Exception { + runTest("jps-plugin/testData/incremental/inlineFunCallSite/topLevelProperty/"); + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/classProperty") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassProperty extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/classProperty"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/companionObjectProperty") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CompanionObjectProperty extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCompanionObjectProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/companionObjectProperty"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/coroutine") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Coroutine extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCoroutine() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/coroutine"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/function") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Function extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunction() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/function"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/getter") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Getter extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInGetter() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/getter"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/lambda") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Lambda extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInLambda() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/lambda"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/localFun") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LocalFun extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInLocalFun() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/localFun"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/method") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Method extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethod() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/method"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/parameterDefaultValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ParameterDefaultValue extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInParameterDefaultValue() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/parameterDefaultValue"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/primaryConstructorParameterDefaultValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PrimaryConstructorParameterDefaultValue extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPrimaryConstructorParameterDefaultValue() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/primaryConstructorParameterDefaultValue"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/superCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SuperCall extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSuperCall() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/superCall"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/thisCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ThisCall extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInThisCall() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/thisCall"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/topLevelObjectProperty") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TopLevelObjectProperty extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTopLevelObjectProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/topLevelObjectProperty"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/inlineFunCallSite/topLevelProperty") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TopLevelProperty extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTopLevelProperty() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/inlineFunCallSite/topLevelProperty"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassHierarchyAffected extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassHierarchyAffected() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("annotationFlagRemoved") + public void testAnnotationFlagRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/annotationFlagRemoved/"); + } + + @TestMetadata("annotationListChanged") + public void testAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/annotationListChanged/"); + } + + @TestMetadata("bridgeGenerated") + public void testBridgeGenerated() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/bridgeGenerated/"); + } + + @TestMetadata("classBecameFinal") + public void testClassBecameFinal() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/classBecameFinal/"); + } + + @TestMetadata("classBecameInterface") + public void testClassBecameInterface() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/classBecameInterface/"); + } + + @TestMetadata("classBecamePrivate") + public void testClassBecamePrivate() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/classBecamePrivate/"); + } + + @TestMetadata("classMovedIntoOtherClass") + public void testClassMovedIntoOtherClass() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass/"); + } + + @TestMetadata("classRemoved") + public void testClassRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/classRemoved/"); + } + + @TestMetadata("classRemovedAndRestored") + public void testClassRemovedAndRestored() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/classRemovedAndRestored/"); + } + + @TestMetadata("companionObjectInheritedMemberChanged") + public void testCompanionObjectInheritedMemberChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectInheritedMemberChanged/"); + } + + @TestMetadata("companionObjectMemberChanged") + public void testCompanionObjectMemberChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectMemberChanged/"); + } + + @TestMetadata("companionObjectNameChanged") + public void testCompanionObjectNameChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectNameChanged/"); + } + + @TestMetadata("companionObjectToSimpleObject") + public void testCompanionObjectToSimpleObject() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectToSimpleObject/"); + } + + @TestMetadata("constructorVisibilityChanged") + public void testConstructorVisibilityChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/constructorVisibilityChanged/"); + } + + @TestMetadata("enumEntryAdded") + public void testEnumEntryAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/enumEntryAdded/"); + } + + @TestMetadata("enumEntryRemoved") + public void testEnumEntryRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved/"); + } + + @TestMetadata("enumMemberChanged") + public void testEnumMemberChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/enumMemberChanged/"); + } + + @TestMetadata("flagsAndMemberInDifferentClassesChanged") + public void testFlagsAndMemberInDifferentClassesChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/flagsAndMemberInDifferentClassesChanged/"); + } + + @TestMetadata("flagsAndMemberInSameClassChanged") + public void testFlagsAndMemberInSameClassChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/flagsAndMemberInSameClassChanged/"); + } + + @TestMetadata("implcitUpcast") + public void testImplcitUpcast() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/implcitUpcast/"); + } + + @TestMetadata("inferredTypeArgumentChanged") + public void testInferredTypeArgumentChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/inferredTypeArgumentChanged/"); + } + + @TestMetadata("inferredTypeChanged") + public void testInferredTypeChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/inferredTypeChanged/"); + } + + @TestMetadata("interfaceAnyMethods") + public void testInterfaceAnyMethods() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/interfaceAnyMethods/"); + } + + @TestMetadata("lambdaParameterAffected") + public void testLambdaParameterAffected() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/lambdaParameterAffected/"); + } + + @TestMetadata("methodAdded") + public void testMethodAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/methodAdded/"); + } + + @TestMetadata("methodAnnotationAdded") + public void testMethodAnnotationAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/methodAnnotationAdded/"); + } + + @TestMetadata("methodNullabilityChanged") + public void testMethodNullabilityChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/methodNullabilityChanged/"); + } + + @TestMetadata("methodParameterWithDefaultValueAdded") + public void testMethodParameterWithDefaultValueAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/methodParameterWithDefaultValueAdded/"); + } + + @TestMetadata("methodRemoved") + public void testMethodRemoved() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/methodRemoved/"); + } + + @TestMetadata("overrideExplicit") + public void testOverrideExplicit() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/overrideExplicit/"); + } + + @TestMetadata("overrideImplicit") + public void testOverrideImplicit() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/overrideImplicit/"); + } + + @TestMetadata("propertyNullabilityChanged") + public void testPropertyNullabilityChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged/"); + } + + @TestMetadata("sealedClassImplAdded") + public void testSealedClassImplAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassImplAdded/"); + } + + @TestMetadata("sealedClassIndirectImplAdded") + public void testSealedClassIndirectImplAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassIndirectImplAdded/"); + } + + @TestMetadata("sealedClassNestedImplAdded") + public void testSealedClassNestedImplAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassNestedImplAdded/"); + } + + @TestMetadata("secondaryConstructorAdded") + public void testSecondaryConstructorAdded() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded/"); + } + + @TestMetadata("starProjectionUpperBoundChanged") + public void testStarProjectionUpperBoundChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/starProjectionUpperBoundChanged/"); + } + + @TestMetadata("supertypesListChanged") + public void testSupertypesListChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/supertypesListChanged/"); + } + + @TestMetadata("typeParameterListChanged") + public void testTypeParameterListChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/typeParameterListChanged/"); + } + + @TestMetadata("varianceChanged") + public void testVarianceChanged() throws Exception { + runTest("jps-plugin/testData/incremental/classHierarchyAffected/varianceChanged/"); + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/annotationFlagRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AnnotationFlagRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInAnnotationFlagRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/annotationFlagRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/annotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AnnotationListChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/annotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/bridgeGenerated") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BridgeGenerated extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInBridgeGenerated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/bridgeGenerated"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classBecameFinal") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassBecameFinal extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassBecameFinal() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/classBecameFinal"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classBecameInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassBecameInterface extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassBecameInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/classBecameInterface"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classBecamePrivate") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassBecamePrivate extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassBecamePrivate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/classBecamePrivate"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassMovedIntoOtherClass extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassMovedIntoOtherClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/classRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classRemovedAndRestored") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassRemovedAndRestored extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInClassRemovedAndRestored() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/classRemovedAndRestored"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectInheritedMemberChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CompanionObjectInheritedMemberChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCompanionObjectInheritedMemberChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectInheritedMemberChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectMemberChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CompanionObjectMemberChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCompanionObjectMemberChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectMemberChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectNameChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CompanionObjectNameChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCompanionObjectNameChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectNameChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectToSimpleObject") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CompanionObjectToSimpleObject extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInCompanionObjectToSimpleObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/companionObjectToSimpleObject"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/constructorVisibilityChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstructorVisibilityChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInConstructorVisibilityChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/constructorVisibilityChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/enumEntryAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumEntryAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInEnumEntryAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/enumEntryAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumEntryRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInEnumEntryRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/enumMemberChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumMemberChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInEnumMemberChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/enumMemberChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/flagsAndMemberInDifferentClassesChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FlagsAndMemberInDifferentClassesChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFlagsAndMemberInDifferentClassesChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/flagsAndMemberInDifferentClassesChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/flagsAndMemberInSameClassChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FlagsAndMemberInSameClassChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFlagsAndMemberInSameClassChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/flagsAndMemberInSameClassChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/implcitUpcast") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ImplcitUpcast extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInImplcitUpcast() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/implcitUpcast"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/inferredTypeArgumentChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InferredTypeArgumentChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInferredTypeArgumentChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/inferredTypeArgumentChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/inferredTypeChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InferredTypeChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInferredTypeChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/inferredTypeChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/interfaceAnyMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InterfaceAnyMethods extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInterfaceAnyMethods() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/interfaceAnyMethods"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/lambdaParameterAffected") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LambdaParameterAffected extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInLambdaParameterAffected() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/lambdaParameterAffected"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/methodAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/methodAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/methodAnnotationAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodAnnotationAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodAnnotationAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/methodAnnotationAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/methodNullabilityChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodNullabilityChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodNullabilityChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/methodNullabilityChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/methodParameterWithDefaultValueAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodParameterWithDefaultValueAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodParameterWithDefaultValueAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/methodParameterWithDefaultValueAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/methodRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MethodRemoved extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMethodRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/methodRemoved"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/overrideExplicit") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class OverrideExplicit extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInOverrideExplicit() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/overrideExplicit"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/overrideImplicit") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class OverrideImplicit extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInOverrideImplicit() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/overrideImplicit"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyNullabilityChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInPropertyNullabilityChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassImplAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassIndirectImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassIndirectImplAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassIndirectImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassIndirectImplAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassNestedImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/sealedClassNestedImplAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SecondaryConstructorAdded extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSecondaryConstructorAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/starProjectionUpperBoundChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class StarProjectionUpperBoundChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInStarProjectionUpperBoundChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/starProjectionUpperBoundChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/supertypesListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SupertypesListChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSupertypesListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/supertypesListChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/typeParameterListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterListChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/typeParameterListChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected/varianceChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class VarianceChanged extends AbstractIncrementalJvmJpsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInVarianceChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/classHierarchyAffected/varianceChanged"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true); + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalLazyCachesTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalLazyCachesTestGenerated.java new file mode 100644 index 00000000000..2fbe2a1e904 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalLazyCachesTestGenerated.java @@ -0,0 +1,263 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@RunWith(JUnit3RunnerWithInners.class) +public class IncrementalLazyCachesTestGenerated extends AbstractIncrementalLazyCachesTest { + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LazyKotlinCaches extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInLazyKotlinCaches() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("class") + public void testClass() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/class/"); + } + + @TestMetadata("classInheritance") + public void testClassInheritance() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/classInheritance/"); + } + + @TestMetadata("constant") + public void testConstant() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/constant/"); + } + + @TestMetadata("function") + public void testFunction() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/function/"); + } + + @TestMetadata("inlineFunctionWithUsage") + public void testInlineFunctionWithUsage() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/"); + } + + @TestMetadata("inlineFunctionWithoutUsage") + public void testInlineFunctionWithoutUsage() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/"); + } + + @TestMetadata("noKotlin") + public void testNoKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/"); + } + + @TestMetadata("topLevelPropertyAccess") + public void testTopLevelPropertyAccess() throws Exception { + runTest("jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/"); + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/class") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Class extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/class"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/classInheritance") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassInheritance extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassInheritance() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/classInheritance"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/constant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Constant extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInConstant() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/constant"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/function") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Function extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInFunction() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/function"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionWithUsage extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionWithUsage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineFunctionWithoutUsage extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInlineFunctionWithoutUsage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoKotlin extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNoKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TopLevelPropertyAccess extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTopLevelPropertyAccess() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/changeIncrementalOption") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeIncrementalOption extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInChangeIncrementalOption() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/changeIncrementalOption"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("incrementalOff") + public void testIncrementalOff() throws Exception { + runTest("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff/"); + } + + @TestMetadata("incrementalOffOn") + public void testIncrementalOffOn() throws Exception { + runTest("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/"); + } + + @TestMetadata("incrementalOffOnJavaChanged") + public void testIncrementalOffOnJavaChanged() throws Exception { + runTest("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOnJavaChanged/"); + } + + @TestMetadata("incrementalOffOnJavaOnly") + public void testIncrementalOffOnJavaOnly() throws Exception { + runTest("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOnJavaOnly/"); + } + + @TestMetadata("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class IncrementalOff extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInIncrementalOff() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class IncrementalOffOn extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInIncrementalOffOn() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOnJavaChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class IncrementalOffOnJavaChanged extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInIncrementalOffOnJavaChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOnJavaChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOnJavaOnly") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class IncrementalOffOnJavaOnly extends AbstractIncrementalLazyCachesTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInIncrementalOffOnJavaOnly() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOnJavaOnly"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt new file mode 100644 index 00000000000..e2b3e54d6b1 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.util.SystemInfoRt +import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.kotlin.incremental.testingUtils.Modification + +class IncrementalProjectPathCaseChangedTest : AbstractIncrementalJpsTest(checkDumpsCaseInsensitively = true) { + fun testProjectPathCaseChanged() { + doTest("jps-plugin/testData/incremental/custom/projectPathCaseChanged/") + } + + fun testProjectPathCaseChangedMultiFile() { + doTest("jps-plugin/testData/incremental/custom/projectPathCaseChangedMultiFile/") + } + + override fun doTest(testDataPath: String) { + if (SystemInfoRt.isFileSystemCaseSensitive) { + return + } + + super.doTest(testDataPath) + } + + override fun performAdditionalModifications(modifications: List) { + val module = myProject.modules[0] + val sourceRoot = module.sourceRoots[0].url + assert(sourceRoot.endsWith("/src")) + val newSourceRoot = sourceRoot.replace("/src", "/SRC") + module.removeSourceRoot(sourceRoot, JavaSourceRootType.SOURCE) + module.addSourceRoot(newSourceRoot, JavaSourceRootType.SOURCE) + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JoinToReadableStringTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JoinToReadableStringTest.kt new file mode 100644 index 00000000000..cdba8ef49b7 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JoinToReadableStringTest.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import junit.framework.TestCase + +class JoinToReadableStringTest : TestCase() { + fun test0() { + assertEquals( + "", + listOf().joinToReadableString() + ) + } + + fun test1() { + assertEquals( + "a", + listOf("a").joinToReadableString() + ) + } + + fun test2() { + assertEquals( + "a and b", + listOf("a", "b").joinToReadableString() + ) + } + + fun test3() { + assertEquals( + "a, b and c", + listOf("a", "b", "c").joinToReadableString() + ) + } + + fun test4() { + assertEquals( + "a, b, c and d", + listOf("a", "b", "c", "d").joinToReadableString() + ) + } + + fun test5() { + assertEquals( + "a, b, c, d and e", + listOf("a", "b", "c", "d", "e").joinToReadableString() + ) + } + + fun test6() { + assertEquals( + "a, b, c, d, e and 1 more", + listOf("a", "b", "c", "d", "e", "f").joinToReadableString() + ) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JsKlibLookupTrackerTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JsKlibLookupTrackerTestGenerated.java new file mode 100644 index 00000000000..0d2f4a2beb8 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JsKlibLookupTrackerTestGenerated.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/lookupTracker/jsKlib") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class JsKlibLookupTrackerTestGenerated extends AbstractJsKlibLookupTrackerTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJsKlib() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker/jsKlib"), Pattern.compile("^([^\\.]+)$"), null, false); + } + + @TestMetadata("classifierMembers") + public void testClassifierMembers() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jsKlib/classifierMembers/"); + } + + @TestMetadata("conventions") + public void testConventions() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jsKlib/conventions/"); + } + + @TestMetadata("expressionType") + public void testExpressionType() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jsKlib/expressionType/"); + } + + @TestMetadata("localDeclarations") + public void testLocalDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jsKlib/localDeclarations/"); + } + + @TestMetadata("packageDeclarations") + public void testPackageDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jsKlib/packageDeclarations/"); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jsKlib/simple/"); + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JsLookupTrackerTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JsLookupTrackerTestGenerated.java new file mode 100644 index 00000000000..1234f1b33bc --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JsLookupTrackerTestGenerated.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/lookupTracker/js") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class JsLookupTrackerTestGenerated extends AbstractJsLookupTrackerTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker/js"), Pattern.compile("^([^\\.]+)$"), null, false); + } + + @TestMetadata("classifierMembers") + public void testClassifierMembers() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/js/classifierMembers/"); + } + + @TestMetadata("conventions") + public void testConventions() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/js/conventions/"); + } + + @TestMetadata("expressionType") + public void testExpressionType() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/js/expressionType/"); + } + + @TestMetadata("localDeclarations") + public void testLocalDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/js/localDeclarations/"); + } + + @TestMetadata("packageDeclarations") + public void testPackageDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/js/packageDeclarations/"); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/js/simple/"); + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JvmLookupTrackerTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JvmLookupTrackerTestGenerated.java new file mode 100644 index 00000000000..0c0cf2847d6 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JvmLookupTrackerTestGenerated.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/lookupTracker/jvm") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class JvmLookupTrackerTestGenerated extends AbstractJvmLookupTrackerTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJvm() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker/jvm"), Pattern.compile("^([^\\.]+)$"), null, false); + } + + @TestMetadata("classifierMembers") + public void testClassifierMembers() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/classifierMembers/"); + } + + @TestMetadata("conventions") + public void testConventions() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/conventions/"); + } + + @TestMetadata("expressionType") + public void testExpressionType() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/expressionType/"); + } + + @TestMetadata("java") + public void testJava() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/java/"); + } + + @TestMetadata("localDeclarations") + public void testLocalDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/localDeclarations/"); + } + + @TestMetadata("packageDeclarations") + public void testPackageDeclarations() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/packageDeclarations/"); + } + + @TestMetadata("SAM") + public void testSAM() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/SAM/"); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/simple/"); + } + + @TestMetadata("syntheticProperties") + public void testSyntheticProperties() throws Exception { + runTest("jps-plugin/testData/incremental/lookupTracker/jvm/syntheticProperties/"); + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt new file mode 100644 index 00000000000..28b46b667f4 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -0,0 +1,1120 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.google.common.collect.Lists +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.openapi.util.text.StringUtil +import com.intellij.openapi.vfs.StandardFileSystems +import com.intellij.testFramework.LightVirtualFile +import com.intellij.testFramework.UsefulTestCase +import com.intellij.util.io.URLUtil +import com.intellij.util.io.ZipUtil +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.api.CanceledStatus +import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.CompileScopeTestBuilder +import org.jetbrains.jps.builders.JpsBuildTestCase +import org.jetbrains.jps.builders.TestProjectBuilderLogger +import org.jetbrains.jps.builders.impl.BuildDataPathsImpl +import org.jetbrains.jps.builders.logging.BuildLoggingManager +import org.jetbrains.jps.cmdline.ProjectDescriptor +import org.jetbrains.jps.devkit.model.JpsPluginModuleType +import org.jetbrains.jps.incremental.BuilderRegistry +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.IncProjectBuilder +import org.jetbrains.jps.incremental.ModuleLevelBuilder +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.incremental.messages.CompilerMessage +import org.jetbrains.jps.model.JpsModuleRootModificationUtil +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.jps.model.java.JpsJavaDependencyScope +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.java.JpsJavaSdkType +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.cli.common.Usage +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler +import org.jetbrains.kotlin.codegen.AsmUtil +import org.jetbrains.kotlin.codegen.JvmCodegenUtil +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.incremental.withIC +import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestBase.LibraryDependency.* +import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff +import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.MockLibraryUtilExt +import org.jetbrains.kotlin.test.util.KtTestUtil +import org.jetbrains.kotlin.utils.PathUtil +import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.org.objectweb.asm.ClassReader +import org.jetbrains.org.objectweb.asm.ClassVisitor +import org.jetbrains.org.objectweb.asm.MethodVisitor +import org.jetbrains.org.objectweb.asm.Opcodes +import org.junit.Assert +import java.io.File +import java.io.FileNotFoundException +import java.io.FileOutputStream +import java.io.IOException +import java.net.URLClassLoader +import java.util.* +import java.util.zip.ZipOutputStream + +open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() { + companion object { + private val ADDITIONAL_MODULE_NAME = "module2" + + private val EXCLUDE_FILES = arrayOf("Excluded.class", "YetAnotherExcluded.class") + private val NOTHING = arrayOf() + private val KOTLIN_JS_LIBRARY = "jslib-example" + private val PATH_TO_KOTLIN_JS_LIBRARY = AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/KotlinJavaScriptProjectWithDirectoryAsLibrary/" + KOTLIN_JS_LIBRARY + private val KOTLIN_JS_LIBRARY_JAR = "$KOTLIN_JS_LIBRARY.jar" + + private fun getMethodsOfClass(classFile: File): Set { + val result = TreeSet() + ClassReader(FileUtil.loadFileBytes(classFile)).accept(object : ClassVisitor(Opcodes.API_VERSION) { + override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array?): MethodVisitor? { + result.add(name) + return null + } + }, 0) + return result + } + + @JvmStatic + protected fun klass(moduleName: String, classFqName: String): String { + val outputDirPrefix = "out/production/$moduleName/" + return outputDirPrefix + classFqName.replace('.', '/') + ".class" + } + + @JvmStatic + protected fun module(moduleName: String): String { + return "out/production/$moduleName/${JvmCodegenUtil.getMappingFileName(moduleName)}" + } + } + + fun doTest() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + } + + fun doTestWithRuntime() { + initProject(JVM_FULL_RUNTIME) + buildAllModules().assertSuccessful() + } + + fun doTestWithKotlinJavaScriptLibrary() { + initProject(JS_STDLIB) + createKotlinJavaScriptLibraryArchive() + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + buildAllModules().assertSuccessful() + } + + fun testKotlinProject() { + doTest() + + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt")) + } + + fun testSourcePackagePrefix() { + doTest() + } + + fun testSourcePackageLongPrefix() { + initProject(JVM_MOCK_RUNTIME) + val buildResult = buildAllModules() + buildResult.assertSuccessful() + val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) + assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 1, warnings.size) + assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText) + } + + fun testSourcePackagePrefixWithInnerClasses() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProject() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, pathsToDelete = k2jsOutput(PROJECT_NAME)) + } + + private fun k2jsOutput(vararg moduleNames: String): Array { + val moduleNamesSet = moduleNames.toSet() + val list = mutableListOf() + + myProject.modules.forEach { + if (it.name in moduleNamesSet) { + val outputDir = it.productionBuildTarget.outputDir!! + list.add(toSystemIndependentName(File("$outputDir/${it.name}.js").relativeTo(workDir).path)) + list.add(toSystemIndependentName(File("$outputDir/${it.name}.meta.js").relativeTo(workDir).path)) + + val kjsmFiles = outputDir.walk() + .filter { it.isFile && it.extension.equals("kjsm", ignoreCase = true) } + + list.addAll(kjsmFiles.map { toSystemIndependentName(it.relativeTo(workDir).path) }) + } + } + + return list.toTypedArray() + } + + fun testKotlinJavaScriptProjectNewSourceRootTypes() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + } + + fun testKotlinJavaScriptProjectWithCustomOutputPaths() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList(File(workDir, "target")) + } + + fun testKotlinJavaScriptProjectWithSourceMap() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + val sourceMapContent = File(getOutputDir(PROJECT_NAME), "$PROJECT_NAME.js.map").readText() + val expectedPath = "prefix-dir/src/pkg/test1.kt" + assertTrue("Source map file should contain relative path ($expectedPath)", sourceMapContent.contains("\"$expectedPath\"")) + + val librarySourceMapFile = File(getOutputDir(PROJECT_NAME), "lib/kotlin.js.map") + assertTrue("Source map for stdlib should be copied to $librarySourceMapFile", librarySourceMapFile.exists()) + } + + fun testKotlinJavaScriptProjectWithSourceMapRelativePaths() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + val sourceMapContent = File(getOutputDir(PROJECT_NAME), "$PROJECT_NAME.js.map").readText() + val expectedPath = "../../../src/pkg/test1.kt" + assertTrue("Source map file should contain relative path ($expectedPath)", sourceMapContent.contains("\"$expectedPath\"")) + + val librarySourceMapFile = File(getOutputDir(PROJECT_NAME), "lib/kotlin.js.map") + assertTrue("Source map for stdlib should be copied to $librarySourceMapFile", librarySourceMapFile.exists()) + } + + fun testKotlinJavaScriptProjectWithTwoModules() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + checkWhen(touch("module2/src/module2.kt"), null, k2jsOutput(ADDITIONAL_MODULE_NAME)) + checkWhen(arrayOf(touch("src/test1.kt"), touch("module2/src/module2.kt")), null, k2jsOutput(PROJECT_NAME, ADDITIONAL_MODULE_NAME)) + } + + @WorkingDir("KotlinJavaScriptProjectWithTwoModules") + fun testKotlinJavaScriptProjectWithTwoModulesAndWithLibrary() { + initProject() + createKotlinJavaScriptLibraryArchive() + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + addKotlinJavaScriptStdlibDependency() + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() { + initProject() + val jslibJar = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath + val jslibDir = File(workDir, "KotlinJavaScript") + try { + ZipUtil.extract(jslibJar, jslibDir, null) + } + catch (ex: IOException) { + throw IllegalStateException(ex.message) + } + + addDependency("KotlinJavaScript", jslibDir) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithDirectoryAsLibrary() { + initProject(JS_STDLIB) + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY)) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibrary() { + doTestWithKotlinJavaScriptLibrary() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibraryCustomOutputDir() { + doTestWithKotlinJavaScriptLibrary() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibraryNoCopy() { + doTestWithKotlinJavaScriptLibrary() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibraryAndErrors() { + initProject(JS_STDLIB) + createKotlinJavaScriptLibraryArchive() + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + buildAllModules().assertFailed() + + checkOutputFilesList() + } + + fun testKotlinJavaScriptProjectWithEmptyDependencies() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptInternalFromSpecialRelatedModule() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithTests() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency() { + initProject(JS_STDLIB) + val buildResult = buildAllModules() + buildResult.assertSuccessful() + + val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) + assertEquals("Warning about duplicate module definition: $warnings", 0, warnings.size) + } + + fun testKotlinJavaScriptProjectWithTwoSrcModuleDependency() { + initProject(JS_STDLIB) + val buildResult = buildAllModules() + buildResult.assertSuccessful() + + val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) + assertEquals("Warning about duplicate module definition: $warnings", 0, warnings.size) + } + + fun testExcludeFolderInSourceRoot() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + checkWhen( + touch("src/foo.kt"), null, + arrayOf(klass("kotlinProject", "Foo"), module("kotlinProject")) + ) + } + + fun testExcludeModuleFolderInSourceRootOfAnotherModule() { + doTest() + + for (module in myProject.modules) { + assertFilesExistInOutput(module, "Foo.class") + } + + checkWhen( + touch("src/foo.kt"), null, + arrayOf(klass("kotlinProject", "Foo"), module("kotlinProject")) + ) + checkWhen( + touch("src/module2/src/foo.kt"), null, + arrayOf(klass("module2", "Foo"), module("module2")) + ) + } + + fun testExcludeFileUsingCompilerSettings() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + } + + checkWhen(touch("src/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING) + } + + fun testExcludeFolderNonRecursivelyUsingCompilerSettings() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo"))) + checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Bar"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + checkWhen(touch("src/dir/subdir/bar.kt"), null, allClasses) + } + + checkWhen(touch("src/dir/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING) + } + + fun testExcludeFolderRecursivelyUsingCompilerSettings() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + } + + checkWhen(touch("src/exclude/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/YetAnotherExcluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/subdir/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING) + } + + fun testKotlinProjectTwoFilesInOnePackage() { + doTest() + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) + checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/test1.kt"), null, allClasses) + checkWhen(touch("src/test2.kt"), null, allClasses) + } + + checkWhen(arrayOf(del("src/test1.kt"), del("src/test2.kt")), NOTHING, + arrayOf(packagePartClass("kotlinProject", "src/test1.kt", "_DefaultPackage"), + packagePartClass("kotlinProject", "src/test2.kt", "_DefaultPackage"), + module("kotlinProject"))) + + assertFilesNotExistInOutput(myProject.modules.get(0), "_DefaultPackage.class") + } + + fun testDefaultLanguageVersionCustomApiVersion() { + initProject(JVM_FULL_RUNTIME) + buildAllModules().assertFailed() + + assertEquals(1, myProject.modules.size) + val module = myProject.modules.first() + val args = module.kotlinCompilerArguments + args.apiVersion = "1.4" + myProject.kotlinCommonCompilerArguments = args + + buildAllModules().assertSuccessful() + } + + fun testPureJavaProject() { + initProject(JVM_FULL_RUNTIME) + + fun build() { + var someFilesCompiled = false + + buildCustom(CanceledStatus.NULL, TestProjectBuilderLogger(), BuildResult()) { + project.setTestingContext(TestingContext(LookupTracker.DO_NOTHING, object : TestingBuildLogger { + override fun compilingFiles(files: Collection, allRemovedFilesFiles: Collection) { + someFilesCompiled = true + } + })) + } + + assertFalse("Kotlin builder should return early if there are no Kotlin files", someFilesCompiled) + } + + build() + + rename("${workDir}/src/Test.java", "Test1.java") + build() + } + + fun testKotlinJavaProject() { + doTestWithRuntime() + } + + fun testJKJProject() { + doTestWithRuntime() + } + + fun testKJKProject() { + doTestWithRuntime() + } + + fun testKJCircularProject() { + doTestWithRuntime() + } + + fun testJKJInheritanceProject() { + doTestWithRuntime() + } + + fun testKJKInheritanceProject() { + doTestWithRuntime() + } + + fun testCircularDependenciesNoKotlinFiles() { + doTest() + } + + fun testCircularDependenciesDifferentPackages() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + + // Check that outputs are located properly + assertFilesExistInOutput(findModule("module2"), "kt1/Kt1Kt.class") + assertFilesExistInOutput(findModule("kotlinProject"), "kt2/Kt2Kt.class") + + result.assertSuccessful() + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Kt")) + checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/kt2.kt"), null, allClasses) + checkWhen(touch("module2/src/kt1.kt"), null, allClasses) + } + } + + fun testCircularDependenciesSamePackage() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertSuccessful() + + // Check that outputs are located properly + val facadeWithA = findFileInOutputDir(findModule("module1"), "test/AKt.class") + val facadeWithB = findFileInOutputDir(findModule("module2"), "test/BKt.class") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "getA") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "getB", "setB") + + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("module1/src/a.kt"), null, allClasses) + checkWhen(touch("module2/src/b.kt"), null, allClasses) + } + } + + fun testCircularDependenciesSamePackageWithTests() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertSuccessful() + + // Check that outputs are located properly + val facadeWithA = findFileInOutputDir(findModule("module1"), "test/AKt.class") + val facadeWithB = findFileInOutputDir(findModule("module2"), "test/BKt.class") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "funA", "getA") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "funB", "getB", "setB") + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + } + else { + val allProductionClasses = myProject.outputPaths(tests = false) + checkWhen(touch("module1/src/a.kt"), null, allProductionClasses) + checkWhen(touch("module2/src/b.kt"), null, allProductionClasses) + } + } + + fun testInternalFromAnotherModule() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testInternalFromSpecialRelatedModule() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + val classpath = listOf("out/production/module1", "out/test/module2").map { File(workDir, it).toURI().toURL() }.toTypedArray() + val clazz = URLClassLoader(classpath).loadClass("test2.BarKt") + clazz.getMethod("box").invoke(null) + } + + fun testCircularDependenciesInternalFromAnotherModule() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testCircularDependenciesWrongInternalFromTests() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testCircularDependencyWithReferenceToOldVersionLib() { + initProject(JVM_MOCK_RUNTIME) + + val libraryJar = MockLibraryUtilExt.compileJvmLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib") + + AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, "module-lib", libraryJar) + + val result = buildAllModules() + result.assertSuccessful() + } + + fun testDependencyToOldKotlinLib() { + initProject() + + val libraryJar = MockLibraryUtilExt.compileJvmLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib") + + AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar) + + addKotlinStdlibDependency() + + val result = buildAllModules() + result.assertSuccessful() + } + + fun testDevKitProject() { + initProject(JVM_MOCK_RUNTIME) + val module = myProject.modules.single() + assertEquals(module.moduleType, JpsPluginModuleType.INSTANCE) + buildAllModules().assertSuccessful() + assertFilesExistInOutput(module, "TestKt.class") + } + + fun testAccessToInternalInProductionFromTests() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertSuccessful() + } + + private fun createKotlinJavaScriptLibraryArchive() { + val jarFile = File(workDir, KOTLIN_JS_LIBRARY_JAR) + try { + val zip = ZipOutputStream(FileOutputStream(jarFile)) + ZipUtil.addDirToZipRecursively(zip, jarFile, File(PATH_TO_KOTLIN_JS_LIBRARY), "", null, null) + zip.close() + } + catch (ex: FileNotFoundException) { + throw IllegalStateException(ex.message) + } + catch (ex: IOException) { + throw IllegalStateException(ex.message) + } + + } + + protected fun checkOutputFilesList(outputDir: File = productionOutputDir) { + if (!expectedOutputFile.exists()) { + expectedOutputFile.writeText("") + throw IllegalStateException("$expectedOutputFile did not exist. Created empty file.") + } + + val sb = StringBuilder() + val p = Printer(sb, " ") + outputDir.printFilesRecursively(p) + + UsefulTestCase.assertSameLinesWithFile(expectedOutputFile.canonicalPath, sb.toString(), true) + } + + private fun File.printFilesRecursively(p: Printer) { + val files = listFiles() ?: return + + for (file in files.sortedBy { it.name }) { + when { + file.isFile -> { + p.println(file.name) + } + file.isDirectory -> { + p.println(file.name + "/") + p.pushIndent() + file.printFilesRecursively(p) + p.popIndent() + } + } + } + } + + private val productionOutputDir + get() = File(workDir, "out/production") + + private fun getOutputDir(moduleName: String): File = File(productionOutputDir, moduleName) + + fun testReexportedDependency() { + initProject() + AbstractKotlinJpsBuildTestCase.addKotlinStdlibDependency(myProject.modules.filter { module -> module.name == "module2" }, true) + buildAllModules().assertSuccessful() + } + + fun testCheckIsCancelledIsCalledOftenEnough() { + val classCount = 30 + val methodCount = 30 + + fun generateFiles() { + val srcDir = File(workDir, "src") + srcDir.mkdirs() + + for (i in 0..classCount) { + val code = buildString { + appendLine("package foo") + appendLine("class Foo$i {") + for (j in 0..methodCount) { + appendLine(" fun get${j*j}(): Int = square($j)") + } + appendLine("}") + + } + File(srcDir, "Foo$i.kt").writeText(code) + } + } + + generateFiles() + initProject(JVM_MOCK_RUNTIME) + + var checkCancelledCalledCount = 0 + val countingCancelledStatus = CanceledStatus { + checkCancelledCalledCount++ + false + } + + val logger = TestProjectBuilderLogger() + val buildResult = BuildResult() + + buildCustom(countingCancelledStatus, logger, buildResult) + + buildResult.assertSuccessful() + assert(checkCancelledCalledCount > classCount) { + "isCancelled should be called at least once per class. Expected $classCount, but got $checkCancelledCalledCount" + } + } + + fun testCancelKotlinCompilation() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "foo/Bar.class") + + val buildResult = BuildResult() + val canceledStatus = object : CanceledStatus { + var checkFromIndex = 0 + + override fun isCanceled(): Boolean { + val messages = buildResult.getMessages(BuildMessage.Kind.INFO) + for (i in checkFromIndex..messages.size - 1) { + if (messages[i].messageText.matches("kotlinc-jvm .+ \\(JRE .+\\)".toRegex())) { + return true + } + } + + checkFromIndex = messages.size + return false + } + } + + touch("src/Bar.kt").apply() + buildCustom(canceledStatus, TestProjectBuilderLogger(), buildResult) + assertCanceled(buildResult) + } + + fun testFileDoesNotExistWarning() { + fun absoluteFiles(vararg paths: String): Array = + paths.map { File(it).absoluteFile }.toTypedArray() + + initProject(JVM_MOCK_RUNTIME) + + val filesToBeReported = absoluteFiles("badroot.jar", "some/test.class") + val otherFiles = absoluteFiles("test/other/file.xml", "some/other/baddir") + + AbstractKotlinJpsBuildTestCase.addDependency( + JpsJavaDependencyScope.COMPILE, + Lists.newArrayList(findModule("module")), + false, + "LibraryWithBadRoots", + *(filesToBeReported + otherFiles) + ) + + val result = buildAllModules() + result.assertSuccessful() + + val actualWarnings = result.getMessages(BuildMessage.Kind.WARNING).map { it.messageText } + val expectedWarnings = filesToBeReported.map { "Classpath entry points to a non-existent location: $it" } + + val expectedText = expectedWarnings.sorted().joinToString("\n") + val actualText = actualWarnings.sorted().joinToString("\n") + + Assert.assertEquals(expectedText, actualText) + } + + fun testHelp() { + initProject() + + val result = buildAllModules() + result.assertSuccessful() + val warning = result.getMessages(BuildMessage.Kind.WARNING).single() + + val expectedText = StringUtil.convertLineSeparators(Usage.render(K2JVMCompiler(), K2JVMCompilerArguments())) + Assert.assertEquals(expectedText, warning.messageText) + } + + fun testWrongArgument() { + initProject() + + val result = buildAllModules() + result.assertFailed() + val errors = result.getMessages(BuildMessage.Kind.ERROR).joinToString("\n\n") { it.messageText } + + Assert.assertEquals("Invalid argument: -abcdefghij-invalid-argument", errors) + } + + fun testCodeInKotlinPackage() { + initProject(JVM_MOCK_RUNTIME) + + val result = buildAllModules() + result.assertFailed() + val errors = result.getMessages(BuildMessage.Kind.ERROR) + + Assert.assertEquals("Only the Kotlin standard library is allowed to use the 'kotlin' package", errors.single().messageText) + } + + fun testDoNotCreateUselessKotlinIncrementalCaches() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + val storageRoot = BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot + assertFalse(File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists()) + assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) + } + + fun testDoNotCreateUselessKotlinIncrementalCachesForDependentTargets() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/utils.kt"), null, packageClasses("kotlinProject", "src/utils.kt", "_DefaultPackage")) + } + else { + val allClasses = findModule("kotlinProject").outputFilesPaths() + checkWhen(touch("src/utils.kt"), null, allClasses.toTypedArray()) + } + + val storageRoot = BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot + assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) + assertFalse(File(storageRoot, "targets/java-production/module2/kotlin").exists()) + } + + fun testKotlinProjectWithEmptyProductionOutputDir() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testKotlinProjectWithEmptyTestOutputDir() { + doTest() + } + + fun testKotlinProjectWithEmptyProductionOutputDirWithoutSrcDir() { + doTest() + } + + fun testKotlinProjectWithEmptyOutputDirInSomeModules() { + doTest() + } + + fun testEAPToReleaseIC() { + fun setPreRelease(value: Boolean) { + System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, value.toString()) + } + + try { + withIC { + initProject(JVM_MOCK_RUNTIME) + + setPreRelease(true) + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Bar.kt", "src/Foo.kt") + + touch("src/Foo.kt").apply() + buildAllModules() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Foo.kt") + + setPreRelease(false) + touch("src/Foo.kt").apply() + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Bar.kt", "src/Foo.kt") + } + } + finally { + System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY) + } + } + + fun testGetDependentTargets() { + fun addModuleWithSourceAndTestRoot(name: String): JpsModule { + return addModule(name, "src/").apply { + contentRootsList.addUrl(JpsPathUtil.pathToUrl("test/")) + addSourceRoot(JpsPathUtil.pathToUrl("test/"), JavaSourceRootType.TEST_SOURCE) + } + } + + // c -> b -exported-> a + // c2 -> b2 ------------^ + + val a = addModuleWithSourceAndTestRoot("a") + val b = addModuleWithSourceAndTestRoot("b") + val c = addModuleWithSourceAndTestRoot("c") + val b2 = addModuleWithSourceAndTestRoot("b2") + val c2 = addModuleWithSourceAndTestRoot("c2") + + JpsModuleRootModificationUtil.addDependency(b, a, JpsJavaDependencyScope.COMPILE, /*exported =*/ true) + JpsModuleRootModificationUtil.addDependency(c, b, JpsJavaDependencyScope.COMPILE, /*exported =*/ false) + JpsModuleRootModificationUtil.addDependency(b2, a, JpsJavaDependencyScope.COMPILE, /*exported =*/ false) + JpsModuleRootModificationUtil.addDependency(c2, b2, JpsJavaDependencyScope.COMPILE, /*exported =*/ false) + + val actual = StringBuilder() + buildCustom(CanceledStatus.NULL, TestProjectBuilderLogger(), BuildResult()) { + project.setTestingContext(TestingContext(LookupTracker.DO_NOTHING, object : TestingBuildLogger { + override fun chunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + actual.append("Targets dependent on ${chunk.targets.joinToString()}:\n") + val dependentRecursively = mutableSetOf() + context.kotlin.getChunk(chunk)!!.collectDependentChunksRecursivelyExportedOnly(dependentRecursively) + dependentRecursively.asSequence().map { it.targets.joinToString() }.sorted().joinTo(actual, "\n") + actual.append("\n---------\n") + } + + override fun afterChunkBuildStarted(context: CompileContext, chunk: ModuleChunk) {} + override fun invalidOrUnusedCache( + chunk: KotlinChunk?, + target: KotlinModuleBuildTarget<*>?, + attributesDiff: CacheAttributesDiff<*> + ) {} + override fun addCustomMessage(message: String) {} + override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {} + override fun markedAsDirtyBeforeRound(files: Iterable) {} + override fun markedAsDirtyAfterRound(files: Iterable) {} + })) + } + + val expectedFile = File(getCurrentTestDataRoot(), "expected.txt") + + KotlinTestUtils.assertEqualsToFile(expectedFile, actual.toString()) + } + + fun testJre9() { + val jdk9Path = KtTestUtil.getJdk9Home().absolutePath + + val jdk = myModel.global.addSdk(JDK_NAME, jdk9Path, "9", JpsJavaSdkType.INSTANCE) + jdk.addRoot(StandardFileSystems.JRT_PROTOCOL_PREFIX + jdk9Path + URLUtil.JAR_SEPARATOR + "java.base", JpsOrderRootType.COMPILED) + + loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr") + addKotlinStdlibDependency() + + buildAllModules().assertSuccessful() + } + + fun testCustomDestination() { + loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr") + addKotlinStdlibDependency() + buildAllModules().apply { + assertSuccessful() + + val aClass = File(workDir, "customOut/A.class") + assert(aClass.exists()) { "$aClass does not exist!" } + + val warnings = getMessages(BuildMessage.Kind.WARNING) + assert(warnings.isEmpty()) { "Unexpected warnings: \n${warnings.joinToString("\n")}" } + } + } + + private fun BuildResult.checkErrors() { + val actualErrors = getMessages(BuildMessage.Kind.ERROR) + .map { it as CompilerMessage } + .map { "${it.messageText} at line ${it.line}, column ${it.column}" }.sorted().joinToString("\n") + val expectedFile = File(getCurrentTestDataRoot(), "errors.txt") + KotlinTestUtils.assertEqualsToFile(expectedFile, actualErrors) + } + + private fun getCurrentTestDataRoot() = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) + + private fun buildCustom( + canceledStatus: CanceledStatus, + logger: TestProjectBuilderLogger, + buildResult: BuildResult, + setupProject: ProjectDescriptor.() -> Unit = {} + ) { + val scopeBuilder = CompileScopeTestBuilder.make().allModules() + val descriptor = this.createProjectDescriptor(BuildLoggingManager(logger)) + + descriptor.setupProject() + + try { + val builder = IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), this.myBuildParams, canceledStatus, true) + builder.addMessageHandler(buildResult) + builder.build(scopeBuilder.build(), false) + } + finally { + descriptor.dataManager.flush(false) + descriptor.release() + } + } + + private fun assertCanceled(buildResult: BuildResult) { + val list = buildResult.getMessages(BuildMessage.Kind.INFO) + assertTrue("The build has been canceled" == list.last().messageText) + } + + private fun findModule(name: String): JpsModule { + for (module in myProject.modules) { + if (module.name == name) { + return module + } + } + throw IllegalStateException("Couldn't find module $name") + } + + protected fun checkWhen(action: Action, pathsToCompile: Array?, pathsToDelete: Array?) { + checkWhen(arrayOf(action), pathsToCompile, pathsToDelete) + } + + protected fun checkWhen(actions: Array, pathsToCompile: Array?, pathsToDelete: Array?) { + for (action in actions) { + action.apply() + } + + buildAllModules().assertSuccessful() + + if (pathsToCompile != null) { + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, *pathsToCompile) + } + + if (pathsToDelete != null) { + assertDeleted(*pathsToDelete) + } + } + + protected fun packageClasses(moduleName: String, fileName: String, packageClassFqName: String): Array { + return arrayOf(module(moduleName), packagePartClass(moduleName, fileName, packageClassFqName)) + } + + protected fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String { + val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).absolutePath) + val fakeVirtualFile = object : LightVirtualFile(path.substringAfterLast('/')) { + override fun getPath(): String { + // strip extra "/" from the beginning + return path.substring(1) + } + } + + val packagePartFqName = PackagePartClassUtils.getDefaultPartFqName(FqName(packageClassFqName), fakeVirtualFile) + return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName)) + } + + private fun JpsProject.outputPaths(production: Boolean = true, tests: Boolean = true) = + modules.flatMap { it.outputFilesPaths(production = production, tests = tests) }.toTypedArray() + + private fun JpsModule.outputFilesPaths(production: Boolean = true, tests: Boolean = true): List { + val outputFiles = arrayListOf() + if (production) { + prodOut.walk().filterTo(outputFiles) { it.isFile } + } + if (tests) { + testsOut.walk().filterTo(outputFiles) { it.isFile } + } + return outputFiles.map { FileUtilRt.toSystemIndependentName(it.relativeTo(workDir).path) } + } + + private val JpsModule.prodOut: File + get() = outDir(forTests = false) + + private val JpsModule.testsOut: File + get() = outDir(forTests = true) + + private fun JpsModule.outDir(forTests: Boolean) = + JpsJavaExtensionService.getInstance().getOutputDirectory(this, forTests)!! + + protected enum class Operation { + CHANGE, + DELETE + } + + protected fun touch(path: String): Action = Action(Operation.CHANGE, path) + + protected fun del(path: String): Action = Action(Operation.DELETE, path) + + // TODO inline after KT-3974 will be fixed + protected fun touch(file: File): Unit = JpsBuildTestCase.change(file.absolutePath) + + protected inner class Action constructor(private val operation: Operation, private val path: String) { + fun apply() { + val file = File(workDir, path) + when (operation) { + Operation.CHANGE -> + touch(file) + Operation.DELETE -> + assertTrue("Can not delete file \"" + file.absolutePath + "\"", file.delete()) + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt.201 b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt.201 new file mode 100644 index 00000000000..82625bda9cf --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt.201 @@ -0,0 +1,1120 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.google.common.collect.Lists +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.openapi.util.text.StringUtil +import com.intellij.openapi.vfs.StandardFileSystems +import com.intellij.testFramework.LightVirtualFile +import com.intellij.testFramework.UsefulTestCase +import com.intellij.util.io.URLUtil +import com.intellij.util.io.ZipUtil +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.api.CanceledStatus +import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.CompileScopeTestBuilder +import org.jetbrains.jps.builders.JpsBuildTestCase +import org.jetbrains.jps.builders.TestProjectBuilderLogger +import org.jetbrains.jps.builders.impl.BuildDataPathsImpl +import org.jetbrains.jps.builders.logging.BuildLoggingManager +import org.jetbrains.jps.cmdline.ProjectDescriptor +import org.jetbrains.jps.devkit.model.JpsPluginModuleType +import org.jetbrains.jps.incremental.BuilderRegistry +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.IncProjectBuilder +import org.jetbrains.jps.incremental.ModuleLevelBuilder +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.incremental.messages.CompilerMessage +import org.jetbrains.jps.model.JpsModuleRootModificationUtil +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.jps.model.java.JpsJavaDependencyScope +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.java.JpsJavaSdkType +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.cli.common.Usage +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler +import org.jetbrains.kotlin.codegen.AsmUtil +import org.jetbrains.kotlin.codegen.JvmCodegenUtil +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.incremental.withIC +import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestBase.LibraryDependency.* +import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff +import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.MockLibraryUtilExt +import org.jetbrains.kotlin.test.util.KtTestUtil +import org.jetbrains.kotlin.utils.PathUtil +import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.org.objectweb.asm.ClassReader +import org.jetbrains.org.objectweb.asm.ClassVisitor +import org.jetbrains.org.objectweb.asm.MethodVisitor +import org.jetbrains.org.objectweb.asm.Opcodes +import org.junit.Assert +import java.io.File +import java.io.FileNotFoundException +import java.io.FileOutputStream +import java.io.IOException +import java.net.URLClassLoader +import java.util.* +import java.util.zip.ZipOutputStream + +open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() { + companion object { + private val ADDITIONAL_MODULE_NAME = "module2" + + private val EXCLUDE_FILES = arrayOf("Excluded.class", "YetAnotherExcluded.class") + private val NOTHING = arrayOf() + private val KOTLIN_JS_LIBRARY = "jslib-example" + private val PATH_TO_KOTLIN_JS_LIBRARY = AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/KotlinJavaScriptProjectWithDirectoryAsLibrary/" + KOTLIN_JS_LIBRARY + private val KOTLIN_JS_LIBRARY_JAR = "$KOTLIN_JS_LIBRARY.jar" + + private fun getMethodsOfClass(classFile: File): Set { + val result = TreeSet() + ClassReader(FileUtil.loadFileBytes(classFile)).accept(object : ClassVisitor(Opcodes.API_VERSION) { + override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array?): MethodVisitor? { + result.add(name) + return null + } + }, 0) + return result + } + + @JvmStatic + protected fun klass(moduleName: String, classFqName: String): String { + val outputDirPrefix = "out/production/$moduleName/" + return outputDirPrefix + classFqName.replace('.', '/') + ".class" + } + + @JvmStatic + protected fun module(moduleName: String): String { + return "out/production/$moduleName/${JvmCodegenUtil.getMappingFileName(moduleName)}" + } + } + + fun doTest() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + } + + fun doTestWithRuntime() { + initProject(JVM_FULL_RUNTIME) + buildAllModules().assertSuccessful() + } + + fun doTestWithKotlinJavaScriptLibrary() { + initProject(JS_STDLIB) + createKotlinJavaScriptLibraryArchive() + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + buildAllModules().assertSuccessful() + } + + fun testKotlinProject() { + doTest() + + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt")) + } + + fun testSourcePackagePrefix() { + doTest() + } + + fun testSourcePackageLongPrefix() { + initProject(JVM_MOCK_RUNTIME) + val buildResult = buildAllModules() + buildResult.assertSuccessful() + val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) + assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 1, warnings.size) + assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText) + } + + fun testSourcePackagePrefixWithInnerClasses() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProject() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, pathsToDelete = k2jsOutput(PROJECT_NAME)) + } + + private fun k2jsOutput(vararg moduleNames: String): Array { + val moduleNamesSet = moduleNames.toSet() + val list = mutableListOf() + + myProject.modules.forEach { + if (it.name in moduleNamesSet) { + val outputDir = it.productionBuildTarget.outputDir!! + list.add(toSystemIndependentName(File("$outputDir/${it.name}.js").relativeTo(workDir).path)) + list.add(toSystemIndependentName(File("$outputDir/${it.name}.meta.js").relativeTo(workDir).path)) + + val kjsmFiles = outputDir.walk() + .filter { it.isFile && it.extension.equals("kjsm", ignoreCase = true) } + + list.addAll(kjsmFiles.map { toSystemIndependentName(it.relativeTo(workDir).path) }) + } + } + + return list.toTypedArray() + } + + fun testKotlinJavaScriptProjectNewSourceRootTypes() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + } + + fun testKotlinJavaScriptProjectWithCustomOutputPaths() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList(File(workDir, "target")) + } + + fun testKotlinJavaScriptProjectWithSourceMap() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + val sourceMapContent = File(getOutputDir(PROJECT_NAME), "$PROJECT_NAME.js.map").readText() + val expectedPath = "prefix-dir/src/pkg/test1.kt" + assertTrue("Source map file should contain relative path ($expectedPath)", sourceMapContent.contains("\"$expectedPath\"")) + + val librarySourceMapFile = File(getOutputDir(PROJECT_NAME), "lib/kotlin.js.map") + assertTrue("Source map for stdlib should be copied to $librarySourceMapFile", librarySourceMapFile.exists()) + } + + fun testKotlinJavaScriptProjectWithSourceMapRelativePaths() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + val sourceMapContent = File(getOutputDir(PROJECT_NAME), "$PROJECT_NAME.js.map").readText() + val expectedPath = "../../../src/pkg/test1.kt" + assertTrue("Source map file should contain relative path ($expectedPath)", sourceMapContent.contains("\"$expectedPath\"")) + + val librarySourceMapFile = File(getOutputDir(PROJECT_NAME), "lib/kotlin.js.map") + assertTrue("Source map for stdlib should be copied to $librarySourceMapFile", librarySourceMapFile.exists()) + } + + fun testKotlinJavaScriptProjectWithTwoModules() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + checkWhen(touch("module2/src/module2.kt"), null, k2jsOutput(ADDITIONAL_MODULE_NAME)) + checkWhen(arrayOf(touch("src/test1.kt"), touch("module2/src/module2.kt")), null, k2jsOutput(PROJECT_NAME, ADDITIONAL_MODULE_NAME)) + } + + @WorkingDir("KotlinJavaScriptProjectWithTwoModules") + fun testKotlinJavaScriptProjectWithTwoModulesAndWithLibrary() { + initProject() + createKotlinJavaScriptLibraryArchive() + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + addKotlinJavaScriptStdlibDependency() + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() { + initProject() + val jslibJar = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath + val jslibDir = File(workDir, "KotlinJavaScript") + try { + ZipUtil.extract(jslibJar, jslibDir, null) + } + catch (ex: IOException) { + throw IllegalStateException(ex.message) + } + + addDependency("KotlinJavaScript", jslibDir) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithDirectoryAsLibrary() { + initProject(JS_STDLIB) + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY)) + buildAllModules().assertSuccessful() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibrary() { + doTestWithKotlinJavaScriptLibrary() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibraryCustomOutputDir() { + doTestWithKotlinJavaScriptLibrary() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibraryNoCopy() { + doTestWithKotlinJavaScriptLibrary() + + checkOutputFilesList() + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + } + + fun testKotlinJavaScriptProjectWithLibraryAndErrors() { + initProject(JS_STDLIB) + createKotlinJavaScriptLibraryArchive() + addDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + buildAllModules().assertFailed() + + checkOutputFilesList() + } + + fun testKotlinJavaScriptProjectWithEmptyDependencies() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptInternalFromSpecialRelatedModule() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithTests() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies() { + initProject(JS_STDLIB) + buildAllModules().assertSuccessful() + } + + fun testKotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency() { + initProject(JS_STDLIB) + val buildResult = buildAllModules() + buildResult.assertSuccessful() + + val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) + assertEquals("Warning about duplicate module definition: $warnings", 0, warnings.size) + } + + fun testKotlinJavaScriptProjectWithTwoSrcModuleDependency() { + initProject(JS_STDLIB) + val buildResult = buildAllModules() + buildResult.assertSuccessful() + + val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) + assertEquals("Warning about duplicate module definition: $warnings", 0, warnings.size) + } + + fun testExcludeFolderInSourceRoot() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + checkWhen( + touch("src/foo.kt"), null, + arrayOf(klass("kotlinProject", "Foo"), module("kotlinProject")) + ) + } + + fun testExcludeModuleFolderInSourceRootOfAnotherModule() { + doTest() + + for (module in myProject.modules) { + assertFilesExistInOutput(module, "Foo.class") + } + + checkWhen( + touch("src/foo.kt"), null, + arrayOf(klass("kotlinProject", "Foo"), module("kotlinProject")) + ) + checkWhen( + touch("src/module2/src/foo.kt"), null, + arrayOf(klass("module2", "Foo"), module("module2")) + ) + } + + fun testExcludeFileUsingCompilerSettings() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + } + + checkWhen(touch("src/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING) + } + + fun testExcludeFolderNonRecursivelyUsingCompilerSettings() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo"))) + checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Bar"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + checkWhen(touch("src/dir/subdir/bar.kt"), null, allClasses) + } + + checkWhen(touch("src/dir/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING) + } + + fun testExcludeFolderRecursivelyUsingCompilerSettings() { + doTest() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "Foo"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + } + + checkWhen(touch("src/exclude/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/YetAnotherExcluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/subdir/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING) + } + + fun testKotlinProjectTwoFilesInOnePackage() { + doTest() + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) + checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/test1.kt"), null, allClasses) + checkWhen(touch("src/test2.kt"), null, allClasses) + } + + checkWhen(arrayOf(del("src/test1.kt"), del("src/test2.kt")), NOTHING, + arrayOf(packagePartClass("kotlinProject", "src/test1.kt", "_DefaultPackage"), + packagePartClass("kotlinProject", "src/test2.kt", "_DefaultPackage"), + module("kotlinProject"))) + + assertFilesNotExistInOutput(myProject.modules.get(0), "_DefaultPackage.class") + } + + fun testDefaultLanguageVersionCustomApiVersion() { + initProject(JVM_FULL_RUNTIME) + buildAllModules().assertFailed() + + assertEquals(1, myProject.modules.size) + val module = myProject.modules.first() + val args = module.kotlinCompilerArguments + args.apiVersion = "1.4" + myProject.kotlinCommonCompilerArguments = args + + buildAllModules().assertSuccessful() + } + + fun testPureJavaProject() { + initProject(JVM_FULL_RUNTIME) + + fun build() { + var someFilesCompiled = false + + buildCustom(CanceledStatus.NULL, TestProjectBuilderLogger(), BuildResult()) { + project.setTestingContext(TestingContext(LookupTracker.DO_NOTHING, object : TestingBuildLogger { + override fun compilingFiles(files: Collection, allRemovedFilesFiles: Collection) { + someFilesCompiled = true + } + })) + } + + assertFalse("Kotlin builder should return early if there are no Kotlin files", someFilesCompiled) + } + + build() + + rename("${workDir}/src/Test.java", "Test1.java") + build() + } + + fun testKotlinJavaProject() { + doTestWithRuntime() + } + + fun testJKJProject() { + doTestWithRuntime() + } + + fun testKJKProject() { + doTestWithRuntime() + } + + fun testKJCircularProject() { + doTestWithRuntime() + } + + fun testJKJInheritanceProject() { + doTestWithRuntime() + } + + fun testKJKInheritanceProject() { + doTestWithRuntime() + } + + fun testCircularDependenciesNoKotlinFiles() { + doTest() + } + + fun testCircularDependenciesDifferentPackages() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + + // Check that outputs are located properly + assertFilesExistInOutput(findModule("module2"), "kt1/Kt1Kt.class") + assertFilesExistInOutput(findModule("kotlinProject"), "kt2/Kt2Kt.class") + + result.assertSuccessful() + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Kt")) + checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/kt2.kt"), null, allClasses) + checkWhen(touch("module2/src/kt1.kt"), null, allClasses) + } + } + + fun testCircularDependenciesSamePackage() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertSuccessful() + + // Check that outputs are located properly + val facadeWithA = findFileInOutputDir(findModule("module1"), "test/AKt.class") + val facadeWithB = findFileInOutputDir(findModule("module2"), "test/BKt.class") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "getA") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "getB", "setB") + + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("module1/src/a.kt"), null, allClasses) + checkWhen(touch("module2/src/b.kt"), null, allClasses) + } + } + + fun testCircularDependenciesSamePackageWithTests() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertSuccessful() + + // Check that outputs are located properly + val facadeWithA = findFileInOutputDir(findModule("module1"), "test/AKt.class") + val facadeWithB = findFileInOutputDir(findModule("module2"), "test/BKt.class") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "funA", "getA") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "funB", "getB", "setB") + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + } + else { + val allProductionClasses = myProject.outputPaths(tests = false) + checkWhen(touch("module1/src/a.kt"), null, allProductionClasses) + checkWhen(touch("module2/src/b.kt"), null, allProductionClasses) + } + } + + fun testInternalFromAnotherModule() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testInternalFromSpecialRelatedModule() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + val classpath = listOf("out/production/module1", "out/test/module2").map { File(workDir, it).toURI().toURL() }.toTypedArray() + val clazz = URLClassLoader(classpath).loadClass("test2.BarKt") + clazz.getMethod("box").invoke(null) + } + + fun testCircularDependenciesInternalFromAnotherModule() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testCircularDependenciesWrongInternalFromTests() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testCircularDependencyWithReferenceToOldVersionLib() { + initProject(JVM_MOCK_RUNTIME) + + val libraryJar = MockLibraryUtilExt.compileJvmLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib") + + AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, "module-lib", libraryJar) + + val result = buildAllModules() + result.assertSuccessful() + } + + fun testDependencyToOldKotlinLib() { + initProject() + + val libraryJar = MockLibraryUtilExt.compileJvmLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib") + + AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar) + + addKotlinStdlibDependency() + + val result = buildAllModules() + result.assertSuccessful() + } + + fun testDevKitProject() { + initProject(JVM_MOCK_RUNTIME) + val module = myProject.modules.single() + assertEquals(module.moduleType, JpsPluginModuleType.INSTANCE) + buildAllModules().assertSuccessful() + assertFilesExistInOutput(module, "TestKt.class") + } + + fun testAccessToInternalInProductionFromTests() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertSuccessful() + } + + private fun createKotlinJavaScriptLibraryArchive() { + val jarFile = File(workDir, KOTLIN_JS_LIBRARY_JAR) + try { + val zip = ZipOutputStream(FileOutputStream(jarFile)) + ZipUtil.addDirToZipRecursively(zip, jarFile, File(PATH_TO_KOTLIN_JS_LIBRARY), "", null, null) + zip.close() + } + catch (ex: FileNotFoundException) { + throw IllegalStateException(ex.message) + } + catch (ex: IOException) { + throw IllegalStateException(ex.message) + } + + } + + protected fun checkOutputFilesList(outputDir: File = productionOutputDir) { + if (!expectedOutputFile.exists()) { + expectedOutputFile.writeText("") + throw IllegalStateException("$expectedOutputFile did not exist. Created empty file.") + } + + val sb = StringBuilder() + val p = Printer(sb, " ") + outputDir.printFilesRecursively(p) + + UsefulTestCase.assertSameLinesWithFile(expectedOutputFile.canonicalPath, sb.toString(), true) + } + + private fun File.printFilesRecursively(p: Printer) { + val files = listFiles() ?: return + + for (file in files.sortedBy { it.name }) { + when { + file.isFile -> { + p.println(file.name) + } + file.isDirectory -> { + p.println(file.name + "/") + p.pushIndent() + file.printFilesRecursively(p) + p.popIndent() + } + } + } + } + + private val productionOutputDir + get() = File(workDir, "out/production") + + private fun getOutputDir(moduleName: String): File = File(productionOutputDir, moduleName) + + fun testReexportedDependency() { + initProject() + AbstractKotlinJpsBuildTestCase.addKotlinStdlibDependency(myProject.modules.filter { module -> module.name == "module2" }, true) + buildAllModules().assertSuccessful() + } + + fun testCheckIsCancelledIsCalledOftenEnough() { + val classCount = 30 + val methodCount = 30 + + fun generateFiles() { + val srcDir = File(workDir, "src") + srcDir.mkdirs() + + for (i in 0..classCount) { + val code = buildString { + appendLine("package foo") + appendLine("class Foo$i {") + for (j in 0..methodCount) { + appendLine(" fun get${j*j}(): Int = square($j)") + } + appendLine("}") + + } + File(srcDir, "Foo$i.kt").writeText(code) + } + } + + generateFiles() + initProject(JVM_MOCK_RUNTIME) + + var checkCancelledCalledCount = 0 + val countingCancelledStatus = CanceledStatus { + checkCancelledCalledCount++ + false + } + + val logger = TestProjectBuilderLogger() + val buildResult = BuildResult() + + buildCustom(countingCancelledStatus, logger, buildResult) + + buildResult.assertSuccessful() + assert(checkCancelledCalledCount > classCount) { + "isCancelled should be called at least once per class. Expected $classCount, but got $checkCancelledCalledCount" + } + } + + fun testCancelKotlinCompilation() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + val module = myProject.modules.get(0) + assertFilesExistInOutput(module, "foo/Bar.class") + + val buildResult = BuildResult() + val canceledStatus = object : CanceledStatus { + var checkFromIndex = 0 + + override fun isCanceled(): Boolean { + val messages = buildResult.getMessages(BuildMessage.Kind.INFO) + for (i in checkFromIndex..messages.size - 1) { + if (messages[i].messageText.matches("kotlinc-jvm .+ \\(JRE .+\\)".toRegex())) { + return true + } + } + + checkFromIndex = messages.size + return false + } + } + + touch("src/Bar.kt").apply() + buildCustom(canceledStatus, TestProjectBuilderLogger(), buildResult) + assertCanceled(buildResult) + } + + fun testFileDoesNotExistWarning() { + fun absoluteFiles(vararg paths: String): Array = + paths.map { File(it).absoluteFile }.toTypedArray() + + initProject(JVM_MOCK_RUNTIME) + + val filesToBeReported = absoluteFiles("badroot.jar", "some/test.class") + val otherFiles = absoluteFiles("test/other/file.xml", "some/other/baddir") + + AbstractKotlinJpsBuildTestCase.addDependency( + JpsJavaDependencyScope.COMPILE, + Lists.newArrayList(findModule("module")), + false, + "LibraryWithBadRoots", + *(filesToBeReported + otherFiles) + ) + + val result = buildAllModules() + result.assertSuccessful() + + val actualWarnings = result.getMessages(BuildMessage.Kind.WARNING).map { it.messageText } + val expectedWarnings = filesToBeReported.map { "Classpath entry points to a non-existent location: $it" } + + val expectedText = expectedWarnings.sorted().joinToString("\n") + val actualText = actualWarnings.sorted().joinToString("\n") + + Assert.assertEquals(expectedText, actualText) + } + + fun testHelp() { + initProject() + + val result = buildAllModules() + result.assertSuccessful() + val warning = result.getMessages(BuildMessage.Kind.WARNING).single() + + val expectedText = StringUtil.convertLineSeparators(Usage.render(K2JVMCompiler(), K2JVMCompilerArguments())) + Assert.assertEquals(expectedText, warning.messageText) + } + + fun testWrongArgument() { + initProject() + + val result = buildAllModules() + result.assertFailed() + val errors = result.getMessages(BuildMessage.Kind.ERROR).joinToString("\n\n") { it.messageText } + + Assert.assertEquals("Invalid argument: -abcdefghij-invalid-argument", errors) + } + + fun testCodeInKotlinPackage() { + initProject(JVM_MOCK_RUNTIME) + + val result = buildAllModules() + result.assertFailed() + val errors = result.getMessages(BuildMessage.Kind.ERROR) + + Assert.assertEquals("Only the Kotlin standard library is allowed to use the 'kotlin' package", errors.single().messageText) + } + + fun testDoNotCreateUselessKotlinIncrementalCaches() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + val storageRoot = BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot + assertFalse(File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists()) + assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) + } + + fun testDoNotCreateUselessKotlinIncrementalCachesForDependentTargets() { + initProject(JVM_MOCK_RUNTIME) + buildAllModules().assertSuccessful() + + if (IncrementalCompilation.isEnabledForJvm()) { + checkWhen(touch("src/utils.kt"), null, packageClasses("kotlinProject", "src/utils.kt", "_DefaultPackage")) + } + else { + val allClasses = findModule("kotlinProject").outputFilesPaths() + checkWhen(touch("src/utils.kt"), null, allClasses.toTypedArray()) + } + + val storageRoot = BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot + assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) + assertFalse(File(storageRoot, "targets/java-production/module2/kotlin").exists()) + } + + fun testKotlinProjectWithEmptyProductionOutputDir() { + initProject(JVM_MOCK_RUNTIME) + val result = buildAllModules() + result.assertFailed() + result.checkErrors() + } + + fun testKotlinProjectWithEmptyTestOutputDir() { + doTest() + } + + fun testKotlinProjectWithEmptyProductionOutputDirWithoutSrcDir() { + doTest() + } + + fun testKotlinProjectWithEmptyOutputDirInSomeModules() { + doTest() + } + + fun testEAPToReleaseIC() { + fun setPreRelease(value: Boolean) { + System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, value.toString()) + } + + try { + withIC { + initProject(JVM_MOCK_RUNTIME) + + setPreRelease(true) + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Bar.kt", "src/Foo.kt") + + touch("src/Foo.kt").apply() + buildAllModules() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Foo.kt") + + setPreRelease(false) + touch("src/Foo.kt").apply() + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Bar.kt", "src/Foo.kt") + } + } + finally { + System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY) + } + } + + fun testGetDependentTargets() { + fun addModuleWithSourceAndTestRoot(name: String): JpsModule { + return addModule(name, "src/").apply { + contentRootsList.addUrl(JpsPathUtil.pathToUrl("test/")) + addSourceRoot(JpsPathUtil.pathToUrl("test/"), JavaSourceRootType.TEST_SOURCE) + } + } + + // c -> b -exported-> a + // c2 -> b2 ------------^ + + val a = addModuleWithSourceAndTestRoot("a") + val b = addModuleWithSourceAndTestRoot("b") + val c = addModuleWithSourceAndTestRoot("c") + val b2 = addModuleWithSourceAndTestRoot("b2") + val c2 = addModuleWithSourceAndTestRoot("c2") + + JpsModuleRootModificationUtil.addDependency(b, a, JpsJavaDependencyScope.COMPILE, /*exported =*/ true) + JpsModuleRootModificationUtil.addDependency(c, b, JpsJavaDependencyScope.COMPILE, /*exported =*/ false) + JpsModuleRootModificationUtil.addDependency(b2, a, JpsJavaDependencyScope.COMPILE, /*exported =*/ false) + JpsModuleRootModificationUtil.addDependency(c2, b2, JpsJavaDependencyScope.COMPILE, /*exported =*/ false) + + val actual = StringBuilder() + buildCustom(CanceledStatus.NULL, TestProjectBuilderLogger(), BuildResult()) { + project.setTestingContext(TestingContext(LookupTracker.DO_NOTHING, object : TestingBuildLogger { + override fun chunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + actual.append("Targets dependent on ${chunk.targets.joinToString()}:\n") + val dependentRecursively = mutableSetOf() + context.kotlin.getChunk(chunk)!!.collectDependentChunksRecursivelyExportedOnly(dependentRecursively) + dependentRecursively.asSequence().map { it.targets.joinToString() }.sorted().joinTo(actual, "\n") + actual.append("\n---------\n") + } + + override fun afterChunkBuildStarted(context: CompileContext, chunk: ModuleChunk) {} + override fun invalidOrUnusedCache( + chunk: KotlinChunk?, + target: KotlinModuleBuildTarget<*>?, + attributesDiff: CacheAttributesDiff<*> + ) {} + override fun addCustomMessage(message: String) {} + override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {} + override fun markedAsDirtyBeforeRound(files: Iterable) {} + override fun markedAsDirtyAfterRound(files: Iterable) {} + })) + } + + val expectedFile = File(getCurrentTestDataRoot(), "expected.txt") + + KotlinTestUtils.assertEqualsToFile(expectedFile, actual.toString()) + } + + fun testJre9() { + val jdk9Path = KtTestUtil.getJdk9Home().absolutePath + + val jdk = myModel.global.addSdk(JDK_NAME, jdk9Path, "9", JpsJavaSdkType.INSTANCE) + jdk.addRoot(StandardFileSystems.JRT_PROTOCOL_PREFIX + jdk9Path + URLUtil.JAR_SEPARATOR + "java.base", JpsOrderRootType.COMPILED) + + loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr") + addKotlinStdlibDependency() + + buildAllModules().assertSuccessful() + } + + fun testCustomDestination() { + loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr") + addKotlinStdlibDependency() + buildAllModules().apply { + assertSuccessful() + + val aClass = File(workDir, "customOut/A.class") + assert(aClass.exists()) { "$aClass does not exist!" } + + val warnings = getMessages(BuildMessage.Kind.WARNING) + assert(warnings.isEmpty()) { "Unexpected warnings: \n${warnings.joinToString("\n")}" } + } + } + + private fun BuildResult.checkErrors() { + val actualErrors = getMessages(BuildMessage.Kind.ERROR) + .map { it as CompilerMessage } + .map { "${it.messageText} at line ${it.line}, column ${it.column}" }.sorted().joinToString("\n") + val expectedFile = File(getCurrentTestDataRoot(), "errors.txt") + KotlinTestUtils.assertEqualsToFile(expectedFile, actualErrors) + } + + private fun getCurrentTestDataRoot() = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) + + private fun buildCustom( + canceledStatus: CanceledStatus, + logger: TestProjectBuilderLogger, + buildResult: BuildResult, + setupProject: ProjectDescriptor.() -> Unit = {} + ) { + val scopeBuilder = CompileScopeTestBuilder.make().allModules() + val descriptor = this.createProjectDescriptor(BuildLoggingManager(logger)) + + descriptor.setupProject() + + try { + val builder = IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), this.myBuildParams, canceledStatus, null, true) + builder.addMessageHandler(buildResult) + builder.build(scopeBuilder.build(), false) + } + finally { + descriptor.dataManager.flush(false) + descriptor.release() + } + } + + private fun assertCanceled(buildResult: BuildResult) { + val list = buildResult.getMessages(BuildMessage.Kind.INFO) + assertTrue("The build has been canceled" == list.last().messageText) + } + + private fun findModule(name: String): JpsModule { + for (module in myProject.modules) { + if (module.name == name) { + return module + } + } + throw IllegalStateException("Couldn't find module $name") + } + + protected fun checkWhen(action: Action, pathsToCompile: Array?, pathsToDelete: Array?) { + checkWhen(arrayOf(action), pathsToCompile, pathsToDelete) + } + + protected fun checkWhen(actions: Array, pathsToCompile: Array?, pathsToDelete: Array?) { + for (action in actions) { + action.apply() + } + + buildAllModules().assertSuccessful() + + if (pathsToCompile != null) { + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, *pathsToCompile) + } + + if (pathsToDelete != null) { + assertDeleted(*pathsToDelete) + } + } + + protected fun packageClasses(moduleName: String, fileName: String, packageClassFqName: String): Array { + return arrayOf(module(moduleName), packagePartClass(moduleName, fileName, packageClassFqName)) + } + + protected fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String { + val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).absolutePath) + val fakeVirtualFile = object : LightVirtualFile(path.substringAfterLast('/')) { + override fun getPath(): String { + // strip extra "/" from the beginning + return path.substring(1) + } + } + + val packagePartFqName = PackagePartClassUtils.getDefaultPartFqName(FqName(packageClassFqName), fakeVirtualFile) + return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName)) + } + + private fun JpsProject.outputPaths(production: Boolean = true, tests: Boolean = true) = + modules.flatMap { it.outputFilesPaths(production = production, tests = tests) }.toTypedArray() + + private fun JpsModule.outputFilesPaths(production: Boolean = true, tests: Boolean = true): List { + val outputFiles = arrayListOf() + if (production) { + prodOut.walk().filterTo(outputFiles) { it.isFile } + } + if (tests) { + testsOut.walk().filterTo(outputFiles) { it.isFile } + } + return outputFiles.map { FileUtilRt.toSystemIndependentName(it.relativeTo(workDir).path) } + } + + private val JpsModule.prodOut: File + get() = outDir(forTests = false) + + private val JpsModule.testsOut: File + get() = outDir(forTests = true) + + private fun JpsModule.outDir(forTests: Boolean) = + JpsJavaExtensionService.getInstance().getOutputDirectory(this, forTests)!! + + protected enum class Operation { + CHANGE, + DELETE + } + + protected fun touch(path: String): Action = Action(Operation.CHANGE, path) + + protected fun del(path: String): Action = Action(Operation.DELETE, path) + + // TODO inline after KT-3974 will be fixed + protected fun touch(file: File): Unit = JpsBuildTestCase.change(file.absolutePath) + + protected inner class Action constructor(private val operation: Operation, private val path: String) { + fun apply() { + val file = File(workDir, path) + when (operation) { + Operation.CHANGE -> + touch(file) + Operation.DELETE -> + assertTrue("Can not delete file \"" + file.absolutePath + "\"", file.delete()) + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTestBase.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTestBase.kt new file mode 100644 index 00000000000..eae51a0d386 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTestBase.kt @@ -0,0 +1,111 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import java.io.File +import java.nio.file.Paths + +abstract class KotlinJpsBuildTestBase : AbstractKotlinJpsBuildTestCase() { + protected lateinit var originalProjectDir: File + protected val expectedOutputFile: File + get() = File(originalProjectDir, "expected-output.txt") + + override fun setUp() { + super.setUp() + val currentTestMethod = this::class.members.firstOrNull { it.name == "test" + getTestName(false) } + val workingDirFromAnnotation = currentTestMethod?.annotations?.filterIsInstance()?.firstOrNull()?.name + val projDirPath = Paths.get( + TEST_DATA_PATH, + "general", + workingDirFromAnnotation ?: getTestName(false) + ) + originalProjectDir = projDirPath.toFile() + workDir = copyTestDataToTmpDir(originalProjectDir) + orCreateProjectDir + } + + protected open fun copyTestDataToTmpDir(testDataDir: File): File { + assert(testDataDir.exists()) { "Cannot find source folder " + testDataDir.absolutePath } + val tmpDir = FileUtil.createTempDirectory("kjbtb-jps-build", null) + FileUtil.copyDir(testDataDir, tmpDir) + return tmpDir + } + + override fun tearDown() { + workDir.deleteRecursively() + super.tearDown() + } + + override fun doGetProjectDir(): File = workDir + + annotation class WorkingDir(val name: String) + + enum class LibraryDependency { + NONE, + JVM_MOCK_RUNTIME, + JVM_FULL_RUNTIME, + JS_STDLIB, + } + + protected fun initProject(libraryDependency: LibraryDependency = LibraryDependency.NONE) { + addJdk(JDK_NAME) + loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr") + + when (libraryDependency) { + LibraryDependency.NONE -> {} + LibraryDependency.JVM_MOCK_RUNTIME -> addKotlinMockRuntimeDependency() + LibraryDependency.JVM_FULL_RUNTIME -> addKotlinStdlibDependency() + LibraryDependency.JS_STDLIB -> addKotlinJavaScriptStdlibDependency() + } + } + + companion object { + const val JDK_NAME = "IDEA_JDK" + const val PROJECT_NAME = "kotlinProject" + + @JvmStatic + protected fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) { + for (path in relativePaths) { + val outputFile = findFileInOutputDir(module, path) + assertTrue("Output not written: " + outputFile.absolutePath + "\n Directory contents: \n" + dirContents( + outputFile.parentFile + ), outputFile.exists()) + } + } + + @JvmStatic + protected fun findFileInOutputDir(module: JpsModule, relativePath: String): File { + val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) + assertNotNull(outputUrl) + val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) + return File(outputDir, relativePath) + } + + @JvmStatic + protected fun assertFilesNotExistInOutput(module: JpsModule, vararg relativePaths: String) { + val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) + assertNotNull(outputUrl) + val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) + for (path in relativePaths) { + val outputFile = File(outputDir, path) + assertFalse("Output directory \"" + outputFile.absolutePath + "\" contains \"" + path + "\"", outputFile.exists()) + } + } + + private fun dirContents(dir: File): String { + val files = dir.listFiles() ?: return "" + val builder = StringBuilder() + for (file in files) { + builder.append(" * ").append(file.name).append("\n") + } + return builder.toString() + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTestIncremental.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTestIncremental.kt new file mode 100644 index 00000000000..7ce1a6b3bd8 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTestIncremental.kt @@ -0,0 +1,159 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.builders.JpsBuildTestCase +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner +import org.jetbrains.kotlin.config.LanguageVersion +import org.jetbrains.kotlin.daemon.common.isDaemonEnabled +import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture +import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments +import java.io.File +import kotlin.reflect.KMutableProperty1 + +class KotlinJpsBuildTestIncremental : KotlinJpsBuildTest() { + private val enableICFixture = EnableICFixture() + + override fun setUp() { + super.setUp() + enableICFixture.setUp() + } + + override fun tearDown() { + enableICFixture.tearDown() + super.tearDown() + } + + fun testKotlinJavaScriptChangePackage() { + initProject(LibraryDependency.JS_STDLIB) + buildAllModules().assertSuccessful() + + val class2Kt = File(workDir, "src/Class2.kt") + val newClass2KtContent = class2Kt.readText().replace("package2", "package1") + JpsBuildTestCase.change(class2Kt.path, newClass2KtContent) + buildAllModules().assertSuccessful() + checkOutputFilesList(File(workDir, "out/production")) + } + + fun testJpsDaemonIC() { + fun testImpl() { + assertTrue("Daemon was not enabled!", isDaemonEnabled()) + + doTest() + val module = myProject.modules.get(0) + val mainKtClassFile = findFileInOutputDir(module, "MainKt.class") + assertTrue("$mainKtClassFile does not exist!", mainKtClassFile.exists()) + + val fooKt = File(workDir, "src/Foo.kt") + JpsBuildTestCase.change(fooKt.path, null) + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Foo.kt") + + JpsBuildTestCase.change(fooKt.path, "class Foo(val x: Int = 0)") + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/main.kt", "src/Foo.kt") + } + + withDaemon { + withSystemProperty(JpsKotlinCompilerRunner.FAIL_ON_FALLBACK_PROPERTY, "true") { + testImpl() + } + } + } + + fun testManyFiles() { + doTest() + + val module = myProject.modules.get(0) + 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/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt")) + checkWhen(touch("src/Bar.kt"), arrayOf("src/Bar.kt"), arrayOf(module("kotlinProject"), klass("kotlinProject", "foo.Bar"))) + + checkWhen(del("src/main.kt"), + pathsToCompile = null, + pathsToDelete = packageClasses("kotlinProject", "src/main.kt", "foo.MainKt")) + assertFilesExistInOutput(module, "boo/BooKt.class", "foo/Bar.class") + assertFilesNotExistInOutput(module, "foo/MainKt.class") + + checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt")) + checkWhen(touch("src/Bar.kt"), null, arrayOf(module("kotlinProject"), klass("kotlinProject", "foo.Bar"))) + } + + fun testManyFilesForPackage() { + doTest() + + val module = myProject.modules.get(0) + 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/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt")) + checkWhen(touch("src/Bar.kt"), + arrayOf("src/Bar.kt"), + arrayOf(klass("kotlinProject", "foo.Bar"), + packagePartClass("kotlinProject", "src/Bar.kt", "foo.MainKt"), + module("kotlinProject"))) + + checkWhen(del("src/main.kt"), + pathsToCompile = null, + pathsToDelete = packageClasses("kotlinProject", "src/main.kt", "foo.MainKt")) + assertFilesExistInOutput(module, "boo/BooKt.class", "foo/Bar.class") + + checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt")) + checkWhen(touch("src/Bar.kt"), null, + arrayOf(klass("kotlinProject", "foo.Bar"), + packagePartClass("kotlinProject", "src/Bar.kt", "foo.MainKt"), + module("kotlinProject"))) + } + + @WorkingDir("LanguageOrApiVersionChanged") + fun testLanguageVersionChanged() { + languageOrApiVersionChanged(CommonCompilerArguments::languageVersion) + } + + @WorkingDir("LanguageOrApiVersionChanged") + fun testApiVersionChanged() { + languageOrApiVersionChanged(CommonCompilerArguments::apiVersion) + } + + private fun languageOrApiVersionChanged(versionProperty: KMutableProperty1) { + initProject(LibraryDependency.JVM_MOCK_RUNTIME) + + assertEquals(1, myProject.modules.size) + val module = myProject.modules.first() + val args = module.kotlinCompilerArguments + + fun setVersion(newVersion: String) { + versionProperty.set(args, newVersion) + myProject.kotlinCommonCompilerArguments = args + } + + assertNull(args.apiVersion) + buildAllModules().assertSuccessful() + + setVersion(LanguageVersion.LATEST_STABLE.versionString) + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME) + + setVersion(LanguageVersion.KOTLIN_1_3.versionString) + buildAllModules().assertSuccessful() + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Bar.kt", "src/Foo.kt") + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinLibraries.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinLibraries.kt new file mode 100644 index 00000000000..aa227ea0cef --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinLibraries.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.java.JpsJavaLibraryType +import org.jetbrains.jps.model.library.JpsLibrary +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime +import org.jetbrains.kotlin.utils.PathUtil +import java.io.File + +enum class KotlinJpsLibrary(val id: String, vararg val roots: File) { + MockRuntime( + "kotlin-mock-runtime", + ForTestCompileRuntime.minimalRuntimeJarForTests() + ), + + JvmStdLib( + "kotlin-stdlib", + PathUtil.kotlinPathsForDistDirectory.stdlibPath, + File(PathUtil.kotlinPathsForDistDirectory.libPath, "annotations-13.0.jar") + ), + JvmTest( + "kotlin-test", + PathUtil.kotlinPathsForDistDirectory.kotlinTestPath + ), + + JsStdLib( + "KotlinJavaScript", + PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath + ), + JsTest( + "KotlinJavaScriptTest", + PathUtil.kotlinPathsForDistDirectory.jsKotlinTestJarPath + ); + + fun create(project: JpsProject): JpsLibrary { + val library = project.addLibrary(id, JpsJavaLibraryType.INSTANCE) + + for (fileRoot in roots) { + library.addRoot(fileRoot, JpsOrderRootType.COMPILED) + } + + return library + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/MockJavaConstantSearch.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/MockJavaConstantSearch.kt new file mode 100644 index 00000000000..30fdc3f733f --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/MockJavaConstantSearch.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.util.concurrency.FixedFuture +import org.jetbrains.jps.builders.java.dependencyView.Callbacks +import org.jetbrains.kotlin.incremental.isJavaFile +import java.io.File +import java.util.concurrent.Future + +/** + * Mocks Intellij Java constant search. + * When JPS is run from Intellij, it sends find usages request to IDE (it only searches for references inside Java files). + * + * We rely on heuristics instead of precise usages search. + * A Java file is considered affected if: + * 1. It contains changed field name as a content substring. + * 2. Its simple file name is not equal to a field's owner class simple name (to avoid recompiling field's declaration again) + */ +class MockJavaConstantSearch(private val workDir: File) : + Callbacks.ConstantAffectionResolver { + override fun request( + ownerClassName: String, + fieldName: String, + accessFlags: Int, + fieldRemoved: Boolean, + accessChanged: Boolean + ): Future { + fun File.isAffected(): Boolean { + if (!isJavaFile()) return false + + if (nameWithoutExtension == ownerClassName.substringAfterLast(".")) return false + + val code = readText() + return code.contains(fieldName) + } + + + val affectedJavaFiles = workDir.walk().filter(File::isAffected).toList() + return FixedFuture( + Callbacks.ConstantAffection( + affectedJavaFiles + ) + ) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/MultiplatformJpsTestWithGeneratedContentGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/MultiplatformJpsTestWithGeneratedContentGenerated.java new file mode 100644 index 00000000000..747ea41ecaf --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/MultiplatformJpsTestWithGeneratedContentGenerated.java @@ -0,0 +1,456 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class MultiplatformJpsTestWithGeneratedContentGenerated extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMultiplatformMultiModule() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class IgnoreAndWarnAboutNative extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInIgnoreAndWarnAboutNative() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("editingCKotlin") + public void testEditingCKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingCKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingCKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Simple extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimple() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("editingCKotlin") + public void testEditingCKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingCKotlin/"); + } + + @TestMetadata("editingPJsKotlin") + public void testEditingPJsKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJsKotlin/"); + } + + @TestMetadata("editingPJvmJava") + public void testEditingPJvmJava() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJvmJava/"); + } + + @TestMetadata("editingPJvmKotlin") + public void testEditingPJvmKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJvmKotlin/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingCKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingCKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingCKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingCKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJsKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingPJsKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingPJsKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJsKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJvmJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingPJvmJava extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingPJvmJava() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJvmJava"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJvmKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingPJvmKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingPJvmKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple/editingPJvmKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleJsJvmProjectWithTests extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimpleJsJvmProjectWithTests() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("editingCMainExpectActual") + public void testEditingCMainExpectActual() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests/editingCMainExpectActual/"); + } + + @TestMetadata("editingCTestsExpectActual") + public void testEditingCTestsExpectActual() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests/editingCTestsExpectActual/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests/editingCMainExpectActual") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingCMainExpectActual extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingCMainExpectActual() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests/editingCMainExpectActual"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests/editingCTestsExpectActual") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingCTestsExpectActual extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingCTestsExpectActual() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleJsJvmProjectWithTests/editingCTestsExpectActual"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimpleNewMpp extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSimpleNewMpp() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("editingCKotlin") + public void testEditingCKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingCKotlin/"); + } + + @TestMetadata("editingPJsKotlin") + public void testEditingPJsKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJsKotlin/"); + } + + @TestMetadata("editingPJvmJava") + public void testEditingPJvmJava() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJvmJava/"); + } + + @TestMetadata("editingPJvmKotlin") + public void testEditingPJvmKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJvmKotlin/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingCKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingCKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingCKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingCKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJsKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingPJsKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingPJsKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJsKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJvmJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingPJvmJava extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingPJvmJava() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJvmJava"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJvmKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingPJvmKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingPJvmKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simpleNewMpp/editingPJvmKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Ultimate extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUltimate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("editingACommonExpectActual") + public void testEditingACommonExpectActual() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingACommonExpectActual/"); + } + + @TestMetadata("editingAJsClientKotlin") + public void testEditingAJsClientKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJsClientKotlin/"); + } + + @TestMetadata("editingAJvmClientJava") + public void testEditingAJvmClientJava() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJvmClientJava/"); + } + + @TestMetadata("editingAJvmClientKotlin") + public void testEditingAJvmClientKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJvmClientKotlin/"); + } + + @TestMetadata("editingBCommonExpectActual") + public void testEditingBCommonExpectActual() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingBCommonExpectActual/"); + } + + @TestMetadata("editingRJsKotlin") + public void testEditingRJsKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRJsKotlin/"); + } + + @TestMetadata("editingRJvmKotlin") + public void testEditingRJvmKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRJvmKotlin/"); + } + + @TestMetadata("editingRaJsKotlin") + public void testEditingRaJsKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRaJsKotlin/"); + } + + @TestMetadata("editingRaJvmKotlin") + public void testEditingRaJvmKotlin() throws Exception { + runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRaJvmKotlin/"); + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingACommonExpectActual") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingACommonExpectActual extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingACommonExpectActual() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingACommonExpectActual"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJsClientKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingAJsClientKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingAJsClientKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJsClientKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJvmClientJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingAJvmClientJava extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingAJvmClientJava() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJvmClientJava"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJvmClientKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingAJvmClientKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingAJvmClientKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingAJvmClientKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingBCommonExpectActual") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingBCommonExpectActual extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingBCommonExpectActual() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingBCommonExpectActual"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRJsKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingRJsKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingRJsKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRJsKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRJvmKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingRJvmKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingRJvmKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRJvmKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRaJsKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingRaJsKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingRaJsKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRaJsKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRaJvmKotlin") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EditingRaJvmKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInEditingRaJvmKotlin() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ultimate/editingRaJvmKotlin"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/RelocatableJpsCachesTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/RelocatableJpsCachesTest.kt new file mode 100644 index 00000000000..7eda8ebed38 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/RelocatableJpsCachesTest.kt @@ -0,0 +1,152 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.builders.* +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor +import org.jetbrains.jps.cmdline.ProjectDescriptor +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot +import org.jetbrains.kotlin.incremental.KOTLIN_CACHE_DIRECTORY_NAME +import org.jetbrains.kotlin.incremental.testingUtils.assertEqualDirectories +import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture +import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget +import java.io.File +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.createTempDirectory +import kotlin.reflect.KFunction1 + +class RelocatableJpsCachesTest : BaseKotlinJpsBuildTestCase() { + private val enableICFixture = EnableICFixture() + private lateinit var workingDir: File + + @OptIn(ExperimentalPathApi::class) + override fun setUp() { + super.setUp() + enableICFixture.setUp() + workingDir = createTempDirectory("RelocatableJpsCachesTest-" + getTestName(false)).toFile() + } + + override fun tearDown() { + workingDir.deleteRecursively() + enableICFixture.tearDown() + super.tearDown() + } + + fun testRelocatableCaches() { + buildTwiceAndCompare(RelocatableCacheTestCase::testRelocatableCaches) + } + + private fun buildTwiceAndCompare(testMethod: KFunction1) { + val test1WorkingDir = workingDir.resolve("test1") + val test1KotlinCachesDir = workingDir.resolve("test1KotlinCaches") + val test2WorkingDir = workingDir.resolve("test2") + val test2KotlinCachesDir = workingDir.resolve("test2KotlinCaches") + + runTestAndCopyKotlinCaches(test1WorkingDir, test1KotlinCachesDir, testMethod) + runTestAndCopyKotlinCaches(test2WorkingDir, test2KotlinCachesDir, testMethod) + + assertEqualDirectories(test1KotlinCachesDir, test2KotlinCachesDir, forgiveExtraFiles = false) + } + + private fun runTestAndCopyKotlinCaches( + projectWorkingDir: File, + dirToCopyKotlinCaches: File, + testMethod: KFunction1 + ) { + val testCase = object : RelocatableCacheTestCase( + projectWorkingDir = projectWorkingDir, + dirToCopyKotlinCaches = dirToCopyKotlinCaches + ) { + override fun getName(): String = testMethod.name + } + testCase.exposedPrivateApi.setUp() + + try { + testMethod.call(testCase) + } finally { + testCase.exposedPrivateApi.tearDown() + } + } +} + +// the class should not be executed directly (hence it's abstract) +abstract class RelocatableCacheTestCase( + private val projectWorkingDir: File, + private val dirToCopyKotlinCaches: File +) : KotlinJpsBuildTestBase() { + val exposedPrivateApi = ExposedPrivateApi() + + fun testRelocatableCaches() { + initProject(LibraryDependency.JVM_FULL_RUNTIME) + buildAllModules().assertSuccessful() + + assertFilesExistInOutput( + myProject.modules.single(), + "MainKt.class", "Foo.class", "FooChild.class", "utils/Utils.class" + ) + } + + override fun copyTestDataToTmpDir(testDataDir: File): File { + testDataDir.copyRecursively(projectWorkingDir) + return projectWorkingDir + } + + override fun doBuild(descriptor: ProjectDescriptor, scopeBuilder: CompileScopeTestBuilder?): BuildResult = + super.doBuild(descriptor, scopeBuilder).also { + copyKotlinCaches(descriptor) + } + + private fun copyKotlinCaches(descriptor: ProjectDescriptor) { + val kotlinDataPaths = HashSet() + val dataPaths = descriptor.dataManager.dataPaths + kotlinDataPaths.add(dataPaths.getTargetDataRoot(KotlinDataContainerTarget)) + + for (target in descriptor.buildTargetIndex.allTargets) { + if (!target.isKotlinTarget(descriptor)) continue + + val targetDataRoot = descriptor.dataManager.dataPaths.getTargetDataRoot(target) + val kotlinDataRoot = targetDataRoot.resolve(KOTLIN_CACHE_DIRECTORY_NAME) + assert(kotlinDataRoot.isDirectory) { "Kotlin data root '$kotlinDataRoot' is not a directory" } + kotlinDataPaths.add(kotlinDataRoot) + } + + dirToCopyKotlinCaches.deleteRecursively() + val originalStorageRoot = descriptor.dataManager.dataPaths.dataStorageRoot + for (kotlinCacheRoot in kotlinDataPaths) { + val relativePath = kotlinCacheRoot.relativeTo(originalStorageRoot).path + val targetDir = dirToCopyKotlinCaches.resolve(relativePath) + targetDir.parentFile.mkdirs() + kotlinCacheRoot.copyRecursively(targetDir) + } + } + + private fun BuildTarget<*>.isKotlinTarget(descriptor: ProjectDescriptor): Boolean { + fun JavaSourceRootDescriptor.containsKotlinSources() = root.walk().any { it.isKotlinSourceFile } + + if (this !is ModuleBuildTarget) return false + + val rootDescriptors = computeRootDescriptors( + descriptor.model, + descriptor.moduleExcludeIndex, + descriptor.ignoredFileIndex, + descriptor.dataManager.dataPaths + ) + + return rootDescriptors.any { it is JavaSourceRootDescriptor && it.containsKotlinSources() } + } + + // the famous Public Morozov pattern + inner class ExposedPrivateApi { + fun setUp() { + this@RelocatableCacheTestCase.setUp() + } + + fun tearDown() { + this@RelocatableCacheTestCase.tearDown() + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt new file mode 100644 index 00000000000..a228fcceb6c --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt @@ -0,0 +1,89 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.util.PathUtil +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.kotlin.cli.common.CompilerSystemProperties +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner +import org.jetbrains.kotlin.daemon.common.OSKind +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File + +class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { + override fun setUp() { + super.setUp() + workDir = KotlinTestUtils.tmpDirForTest(this) + } + + fun testLoadingKotlinFromDifferentModules() { + val aFile = createFile("m1/K.kt", + """ + package m1; + + interface K { + } + """) + createFile("m1/J.java", + """ + package m1; + + public interface J { + K bar(); + } + """) + val a = addModule("m1", PathUtil.getParentPath(aFile)) + + val bFile = createFile("m2/m2.kt", + """ + import m1.J; + import m1.K; + + interface M2: J { + override fun bar(): K + } + """) + val b = addModule("b", PathUtil.getParentPath(bFile)) + JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension( + b.dependenciesList.addModuleDependency(a) + ).isExported = false + + addKotlinStdlibDependency() + rebuildAllModules() + } + + // TODO: add JS tests + fun testDaemon() { + withDaemon { + withSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.property, "true") { + withSystemProperty(JpsKotlinCompilerRunner.FAIL_ON_FALLBACK_PROPERTY, "true") { + testLoadingKotlinFromDifferentModules() + } + } + } + } +} + +// copied from CompilerDaemonTest.kt +// TODO: find shared place for this function +// java.util.Logger used in the daemon silently forgets to log into a file specified in the config on Windows, +// if file path is given in windows form (using backslash as a separator); the reason is unknown +// this function makes a path with forward slashed, that works on windows too +internal val File.loggerCompatiblePath: String + get() = + if (OSKind.current == OSKind.Windows) absolutePath.replace('\\', '/') + else absolutePath diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/ModulesTxt.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/ModulesTxt.kt new file mode 100644 index 00000000000..eeedd28f334 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/ModulesTxt.kt @@ -0,0 +1,329 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build.dependeciestxt + +import org.jetbrains.jps.model.java.JpsJavaDependencyScope +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.config.CompilerSettings +import org.jetbrains.kotlin.config.KotlinFacetSettings +import org.jetbrains.kotlin.config.KotlinModuleKind.COMPILATION_AND_SOURCE_SET_HOLDER +import org.jetbrains.kotlin.config.KotlinModuleKind.SOURCE_SET_HOLDER +import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt.Dependency.Kind.* +import org.jetbrains.kotlin.platform.CommonPlatforms +import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments +import org.jetbrains.kotlin.platform.isCommon +import org.jetbrains.kotlin.platform.js.JsPlatforms +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.platform.jvm.isJvm +import org.jetbrains.kotlin.platform.konan.NativePlatforms +import java.io.File +import kotlin.reflect.KMutableProperty1 +import kotlin.reflect.full.findAnnotation +import kotlin.reflect.full.memberProperties + +/** + * Modules description file. + * See [README.md] for more details. + */ +data class ModulesTxt( + val muted: Boolean, + val file: File, + val fileName: String, + val modules: List, + val dependencies: List +) { + override fun toString() = fileName + + data class Module(val name: String) { + var index: Int = -1 + + val indexedName + get() = "${index.toString().padStart(2, '0')}_$name" + + /** + * Facet should not be created for old tests + */ + var kotlinFacetSettings: KotlinFacetSettings? = null + + val dependencies = mutableListOf() + val usages = mutableListOf() + + val isCommonModule + get() = + kotlinFacetSettings?.targetPlatform.isCommon() || + kotlinFacetSettings?.kind == SOURCE_SET_HOLDER + + val isJvmModule + get() = kotlinFacetSettings?.targetPlatform.isJvm() + + val expectedBy + get() = dependencies.filter { + it.kind == EXPECTED_BY || + it.kind == INCLUDE + } + + @Flag + var edit: Boolean = false + + @Flag + var editJvm: Boolean = false + + @Flag + var editExpectActual: Boolean = false + + lateinit var jpsModule: JpsModule + + companion object { + val flags: Map> = Module::class.memberProperties + .filter { it.findAnnotation() != null } + .filterIsInstance>() + .associateBy { it.name } + } + } + + annotation class Flag + + data class Dependency( + val from: Module, + val to: Module, + val scope: JpsJavaDependencyScope, + val kind: Kind, + val exported: Boolean + ) { + val effectivelyExported + get() = kind == EXPECTED_BY || exported + + init { + from.dependencies.add(this) + to.usages.add(this) + } + + enum class Kind { + DEPENDENCY, + EXPECTED_BY, + INCLUDE + } + } +} + +class ModulesTxtBuilder { + var muted = false + + val modules = mutableMapOf() + private val dependencies = mutableListOf() + + /** + * Reference to module which can be defined later + */ + class ModuleRef(name: String) { + var defined: Boolean = false + var actual: ModulesTxt.Module = ModulesTxt.Module(name) + + override fun toString() = actual.name + + fun build(index: Int): ModulesTxt.Module { + val result = actual + result.index = index + val kotlinFacetSettings = result.kotlinFacetSettings + if (kotlinFacetSettings != null) { + kotlinFacetSettings.implementedModuleNames = + result.dependencies.asSequence() + .filter { it.kind == EXPECTED_BY } + .map { it.to.name } + .toList() + + kotlinFacetSettings.sourceSetNames = + result.dependencies.asSequence() + .filter { it.kind == INCLUDE } + .map { it.to.name } + .toList() + } + return result + } + } + + /** + * Temporary object for resolving references to modules. + */ + data class DependencyBuilder( + val from: ModuleRef, + val to: ModuleRef, + val scope: JpsJavaDependencyScope, + val kind: ModulesTxt.Dependency.Kind, + val exported: Boolean + ) { + fun build(): ModulesTxt.Dependency { + when (kind) { + DEPENDENCY -> Unit + EXPECTED_BY -> check(to.actual.isCommonModule) { + "$this: ${to.actual} is not common module" + } + INCLUDE -> check(to.actual.kotlinFacetSettings?.kind == SOURCE_SET_HOLDER) { + "$this: ${to.actual} is not source set holder" + } + } + return ModulesTxt.Dependency(from.actual, to.actual, scope, kind, exported) + } + } + + fun readFile(file: File, fileTitle: String = file.toString()): ModulesTxt { + try { + file.forEachLine { line -> + parseDeclaration(line) + } + + // dependencies need to be build first: module.build() requires it + val dependencies = dependencies.map { it.build() } + val modules = modules.values.mapIndexed { index, moduleRef -> moduleRef.build(index) } + + return ModulesTxt(muted, file, fileTitle, modules, dependencies) + } catch (t: Throwable) { + throw Error("Error while reading $file: ${t.message}", t) + } + } + + private fun parseDeclaration(line: String) = doParseDeclaration(removeComments(line)) + + private fun removeComments(line: String) = line.split("//", limit = 2)[0].trim() + + private fun doParseDeclaration(line: String) { + when { + line.isEmpty() -> Unit // skip empty lines + line == "MUTED" -> { + muted = true + } + line.contains("->") -> { + val (from, rest) = line.split("->", limit = 2) + if (rest.isBlank()) { + // `name -> ` - module + newModule(ValueWithFlags(from)) + } else { + val (to, flags) = parseValueWithFlags(rest.trim()) + newDependency(from.trim(), to.trim(), flags) // `from -> to [flag1, flag2, ...]` - dependency + } + } + else -> newModule(parseValueWithFlags(line)) // `name [flag1, flag2, ...]` - module + } + } + + /** + * `value [flag1, flag2, ...]` + */ + private fun parseValueWithFlags(str: String): ValueWithFlags { + val parts = str.split("[", limit = 2) + return if (parts.size > 1) { + val (value, flags) = parts + ValueWithFlags( + value = value.trim(), + flags = flags.trim() + .removeSuffix("]") + .split(",") + .map { it.trim() } + .filter { it.isNotEmpty() } + .toSet() + ) + } else ValueWithFlags(str) + } + + data class ValueWithFlags(val value: String, val flags: Set = setOf()) + + private fun moduleRef(name: String) = + modules.getOrPut(name) { ModuleRef(name) } + + private fun newModule(def: ValueWithFlags): ModulesTxt.Module { + val name = def.value.trim() + + val module = ModulesTxt.Module(name) + val settings = KotlinFacetSettings() + module.kotlinFacetSettings = settings + + settings.useProjectSettings = false + settings.compilerSettings = CompilerSettings().also { + it.additionalArguments = "-version -Xmulti-platform" + } + + val moduleRef = moduleRef(name) + check(!moduleRef.defined) { "Module `$name` already defined" } + moduleRef.defined = true + moduleRef.actual = module + + def.flags.forEach { flag -> + when (flag) { + "sourceSetHolder" -> settings.kind = SOURCE_SET_HOLDER + "compilationAndSourceSetHolder" -> settings.kind = COMPILATION_AND_SOURCE_SET_HOLDER + "common" -> settings.compilerArguments = + K2MetadataCompilerArguments().also { settings.targetPlatform = CommonPlatforms.defaultCommonPlatform } + "jvm" -> settings.compilerArguments = + K2JVMCompilerArguments().also { settings.targetPlatform = JvmPlatforms.defaultJvmPlatform } + "js" -> settings.compilerArguments = + K2JSCompilerArguments().also { settings.targetPlatform = JsPlatforms.defaultJsPlatform } + "native" -> settings.compilerArguments = + FakeK2NativeCompilerArguments().also { settings.targetPlatform = NativePlatforms.unspecifiedNativePlatform } + else -> { + val flagProperty = ModulesTxt.Module.flags[flag] + if (flagProperty != null) flagProperty.set(module, true) + else error("Unknown module flag `$flag`") + } + } + } + + return module + } + + private fun newDependency(from: String, to: String, flags: Set): DependencyBuilder? { + if (to.isEmpty()) { + // `x -> ` should just create undefined module `x` + moduleRef(from) + + check(flags.isEmpty()) { + "`name -> [flag1, flag2, ...]` - not allowed due to the ambiguity of belonging to modules/dependencies. " + + "Please use `x [attrs...]` syntax for module attributes." + } + + return null + } else { + var exported = false + var scope: JpsJavaDependencyScope? = null + var kind: ModulesTxt.Dependency.Kind = DEPENDENCY + + fun setScope(newScope: JpsJavaDependencyScope) { + check(scope == null) { "`$this: $from -> $to` dependency is already flagged as $scope" } + scope = newScope + } + + fun setKind(newKind: ModulesTxt.Dependency.Kind) { + check(kind == DEPENDENCY) { "`$this: $from -> $to` dependency is already flagged as $kind" } + kind = newKind + } + + flags.forEach { flag -> + when (flag) { + "exported" -> exported = true + "compile" -> setScope(JpsJavaDependencyScope.COMPILE) + "test" -> setScope(JpsJavaDependencyScope.TEST) + "runtime" -> setScope(JpsJavaDependencyScope.RUNTIME) + "provided" -> setScope(JpsJavaDependencyScope.PROVIDED) + "expectedBy" -> setKind(EXPECTED_BY) + "include" -> setKind(INCLUDE) + else -> error("Unknown dependency flag `$flag`") + } + } + + return DependencyBuilder( + from = moduleRef(from), + to = moduleRef(to), + scope = scope ?: JpsJavaDependencyScope.COMPILE, + kind = kind, + exported = exported + ).also { + dependencies.add(it) + } + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/MppJpsIncTestsGenerator.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/MppJpsIncTestsGenerator.kt new file mode 100644 index 00000000000..36700d219e4 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/MppJpsIncTestsGenerator.kt @@ -0,0 +1,441 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build.dependeciestxt + +import java.io.File + +/** + * Utility for generating common/platform module stub contents based on it's dependencies. + */ +fun actualizeMppJpsIncTestCaseDirs(rootDir: String, dir: String) { + val rootDirFile = File("$rootDir/$dir") + check(rootDirFile.isDirectory) { "`$rootDirFile` is not a directory" } + + rootDirFile.listFiles { it: File -> it.isDirectory }.forEach { dirFile -> + val dependenciesTxtFile = File(dirFile, "dependencies.txt") + if (dependenciesTxtFile.exists()) { + val fileTitle = "$dir/${dirFile.name}/dependencies.txt" + val dependenciesTxt = ModulesTxtBuilder().readFile(dependenciesTxtFile, fileTitle) + + MppJpsIncTestsGenerator(dependenciesTxt) { File(dirFile, it.name) } + .actualizeTestCasesDirs(dirFile) + } + } + + return +} + +class MppJpsIncTestsGenerator(val txt: ModulesTxt, val testCaseDirProvider: (TestCase) -> File) { + val ModulesTxt.Module.capitalName get() = name.capitalize() + + val testCases: List + + init { + val testCases = mutableListOf() + + txt.modules.forEach { + if (it.edit) + testCases.add(EditingTestCase(it, changeJavaClass = false)) + + if (it.editJvm && it.isJvmModule) + testCases.add(EditingTestCase(it, changeJavaClass = true)) + + if (it.editExpectActual && it.isCommonModule) + testCases.add(EditingExpectActualTestCase(it)) + } + + this.testCases = testCases + } + + fun actualizeTestCasesDirs(rootDir: File) { + val requiredDirs = mutableSetOf() + testCases.forEach { + val dir = it.dir + check(requiredDirs.add(dir)) { "TestCase dir clash $dir" } + + if (!dir.exists()) { + File(dir, "build.log").setFileContent("") + } + } + + rootDir.listFiles().forEach { + if (it.isDirectory && it !in requiredDirs) { + it.deleteRecursively() + } + } + } + + /** + * Set required content for [this] [File]. + */ + fun File.setFileContent(content: String) { + check(!exists()) { + "File `$this` already exists," + + "\n\n============= contents ============\n" + + readText() + + "\n===================================\n" + + "\n============ new content ==========\n" + + content + + "\n===================================\n" + } + + parentFile.mkdirs() + writeText(content) + } + + data class ModuleContentSettings( + val module: ModulesTxt.Module, + val serviceNameSuffix: String = "", + val generateActualDeclarationsFor: List = module.expectedBy.map { it.to }, + val generatePlatformDependent: Boolean = true, + var generateKtFile: Boolean = true, + var generateJavaFile: Boolean = true + ) + + inner class EditingTestCase(val module: ModulesTxt.Module, val changeJavaClass: Boolean) : TestCase() { + override val name: String = + if (changeJavaClass) "editing${module.capitalName}Java" + else "editing${module.capitalName}Kotlin" + + override val dir: File = testCaseDirProvider(this) + + override fun generate() { + generateBaseContent() + + // create new file with service implementation + // don't create expect/actual functions (generatePlatformDependent = false) + module.contentsSettings = ModuleContentSettings( + module, + serviceNameSuffix = "New", + generatePlatformDependent = false, + generateKtFile = !changeJavaClass, + generateJavaFile = changeJavaClass + ) + + when { + module.isCommonModule -> { + step("create new service") { + generateCommonFile( + module, + fileNameSuffix = ".new.$step" + ) + } + + step("edit new service") { + generateCommonFile( + module, + fileNameSuffix = ".touch.$step" + ) + } + + step("delete new service") { + serviceKtFile( + module, + fileNameSuffix = ".delete.$step" + ).setFileContent("") + } + } + else -> { + step("create new service") { + // generateKtFile event if changeJavaClass requested (for test calling java from kotlin) + val prevModuleContentsSettings = module.contentsSettings + module.contentsSettings = module.contentsSettings.copy(generateKtFile = true) + + + generatePlatformFile( + module, + fileNameSuffix = ".new.$step" + ) + + module.contentsSettings = prevModuleContentsSettings + } + + step("edit new service") { + generatePlatformFile( + module, + fileNameSuffix = ".touch.$step" + ) + } + + step("delete new service") { + if (changeJavaClass) serviceJavaFile(module, fileNameSuffix = ".delete.$step").setFileContent("") + + // kotlin file also created for testing java class + serviceKtFile(module, fileNameSuffix = ".delete.$step").setFileContent("") + } + } + } + + generateStepsTxt() + } + + } + + inner class EditingExpectActualTestCase(val commonModule: ModulesTxt.Module) : TestCase() { + override val name: String = "editing${commonModule.capitalName}ExpectActual" + override val dir: File = testCaseDirProvider(this) + + override fun generate() { + generateBaseContent() + check(commonModule.isCommonModule) + val implModules = commonModule.usages + .asSequence() + .filter { + it.kind == ModulesTxt.Dependency.Kind.EXPECTED_BY || + it.kind == ModulesTxt.Dependency.Kind.INCLUDE + } + .map { it.from } + + commonModule.contentsSettings = ModuleContentSettings(commonModule, serviceNameSuffix = "New") + implModules.forEach { implModule -> + implModule.contentsSettings = ModuleContentSettings( + implModule, + serviceNameSuffix = "New", + generateActualDeclarationsFor = listOf(commonModule) + ) + } + + step("create new service in ${commonModule.name}") { + generateCommonFile(commonModule, fileNameSuffix = ".new.$step") + } + + implModules.forEach { implModule -> + step("create new service in ${implModule.name}") { + generatePlatformFile(implModule, fileNameSuffix = ".new.$step") + } + } + + step("change new service in ${commonModule.name}") { + generateCommonFile(commonModule, fileNameSuffix = ".touch.$step") + } + + implModules.forEach { implModule -> + if (implModule.isJvmModule) { + implModule.contentsSettings.generateKtFile = false + implModule.contentsSettings.generateJavaFile = true + step("change new service in ${implModule.name}: java") { + generatePlatformFile(implModule, fileNameSuffix = ".touch.$step") + } + + implModule.contentsSettings.generateKtFile = true + implModule.contentsSettings.generateJavaFile = false + step("change new service in ${implModule.name}: kotlin") { + generatePlatformFile(implModule, fileNameSuffix = ".touch.$step") + } + } else { + step("change new service in ${implModule.name}") { + generatePlatformFile(implModule, fileNameSuffix = ".touch.$step") + } + } + } + + implModules.forEach { implModule -> + step("delete new service in ${implModule.name}") { + serviceKtFile(implModule, fileNameSuffix = ".delete.$step").setFileContent("") + } + } + + step("delete new service in ${commonModule.name}") { + serviceKtFile(commonModule, fileNameSuffix = ".delete.$step").setFileContent("") + } + + generateStepsTxt() + } + } + + abstract inner class TestCase() { + abstract val name: String + + abstract fun generate() + + abstract val dir: File + + private val modules = mutableMapOf() + + var step = 1 + val steps = mutableListOf() + + protected inline fun step(name: String, body: () -> Unit) { + body() + steps.add(name) + step++ + } + + var ModulesTxt.Module.contentsSettings: ModuleContentSettings + get() = modules.getOrPut(this) { ModuleContentSettings(this) } + set(value) { + modules[this] = value + } + + protected fun generateStepsTxt() { + File(dir, "_steps.txt").setFileContent(steps.joinToString("\n")) + } + + fun generateBaseContent() { + dir.mkdir() + + txt.modules.forEach { + generateModuleContents(it) + } + } + + private fun generateModuleContents(module: ModulesTxt.Module) { + when { + module.isCommonModule -> { + // common module + generateCommonFile(module) + } + module.expectedBy.isEmpty() -> { + // regular module + generatePlatformFile(module) + } + else -> { + // common module platform implementation + generatePlatformFile(module) + } + } + } + + private val ModulesTxt.Module.serviceName + get() = "$capitalName${contentsSettings.serviceNameSuffix}" + + private val ModulesTxt.Module.javaClassName + get() = "${serviceName}JavaClass" + + protected fun serviceKtFile(module: ModulesTxt.Module, fileNameSuffix: String = ""): File { + val suffix = + if (module.isCommonModule) "${module.serviceName}Header" + else "${module.name.capitalize()}${module.contentsSettings.serviceNameSuffix}Impl" + + return File(dir, "${module.indexedName}_service$suffix.kt$fileNameSuffix") + } + + fun serviceJavaFile(module: ModulesTxt.Module, fileNameSuffix: String = ""): File { + return File(dir, "${module.indexedName}_${module.javaClassName}.java$fileNameSuffix") + } + + private val ModulesTxt.Module.platformDependentFunName: String + get() { + check(isCommonModule) + return "${name}_platformDependent$serviceName" + } + + private val ModulesTxt.Module.platformIndependentFunName: String + get() { + check(isCommonModule) + return "${name}_platformIndependent$serviceName" + } + + private val ModulesTxt.Module.platformOnlyFunName: String + get() { + // platformOnly fun names already unique, so no module name prefix required + return "${name}_platformOnly${contentsSettings.serviceNameSuffix}" + } + + protected fun generateCommonFile( + module: ModulesTxt.Module, + fileNameSuffix: String = "" + ) { + val settings = module.contentsSettings + + serviceKtFile(module, fileNameSuffix).setFileContent(buildString { + if (settings.generatePlatformDependent) + appendLine("expect fun ${module.platformDependentFunName}(): String") + + appendLine("fun ${module.platformIndependentFunName}() = \"common$fileNameSuffix\"") + + appendTestFun(module, settings) + }) + } + + protected fun generatePlatformFile( + module: ModulesTxt.Module, + fileNameSuffix: String = "" + ) { + val isJvm = module.isJvmModule + val settings = module.contentsSettings + + val javaClassName = module.javaClassName + + if (settings.generateKtFile) { + serviceKtFile(module, fileNameSuffix).setFileContent(buildString { + if (settings.generatePlatformDependent) { + for (expectedBy in settings.generateActualDeclarationsFor) { + appendLine( + "actual fun ${expectedBy.platformDependentFunName}(): String" + + " = \"${module.name}$fileNameSuffix\"" + ) + } + } + + appendLine( + "fun ${module.platformOnlyFunName}()" + + " = \"${module.name}$fileNameSuffix\"" + ) + + appendTestFun(module, settings) + }) + } + + if (isJvm && settings.generateJavaFile) { + serviceJavaFile(module, fileNameSuffix).setFileContent( + """ + |public class $javaClassName { + | public String doStuff() { + | return "${module.name}$fileNameSuffix"; + | } + |} + """.trimMargin() + ) + } + } + + // call all functions declared in this module and all of its dependencies recursively + private fun StringBuilder.appendTestFun( + module: ModulesTxt.Module, + settings: ModuleContentSettings + ) { + appendLine() + appendLine("fun Test${module.serviceName}() {") + + val thisAndDependencies = mutableSetOf(module) + module.collectDependenciesRecursivelyTo(thisAndDependencies) + thisAndDependencies.forEach { thisOrDependent -> + if (thisOrDependent.isCommonModule) { + appendLine(" ${thisOrDependent.platformIndependentFunName}()") + + if (settings.generatePlatformDependent) { + appendLine(" ${thisOrDependent.platformDependentFunName}()") + } + } else { + // platform module + appendLine(" ${thisOrDependent.platformOnlyFunName}()") + + if (thisOrDependent.isJvmModule && thisOrDependent.contentsSettings.generateJavaFile) { + appendLine(" ${thisOrDependent.javaClassName}().doStuff()") + } + } + } + + appendLine("}") + } + + private fun ModulesTxt.Module.collectDependenciesRecursivelyTo( + collection: MutableCollection, + exportedOnly: Boolean = false + ) { + dependencies.forEach { + if (!exportedOnly || it.effectivelyExported) { + val dependentModule = it.to + collection.add(dependentModule) + dependentModule.collectDependenciesRecursivelyTo(collection, exportedOnly = true) + } + } + } + + override fun toString() = name + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/PACKAGE.md b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/PACKAGE.md new file mode 100644 index 00000000000..e662d94a931 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/dependeciestxt/PACKAGE.md @@ -0,0 +1,38 @@ +Useful micro-language for concise description of project structure. +Mostly like the [DOT language](https://www.graphviz.org/doc/info/attrs.html). + +## Example + +``` +c [common] +p1 [jvm] +p2 [jvm] + +p1 -> c [expectedBy] +p2 -> c [expectedBy] +``` + +## Format + +File contains declarations of modules and dependencies: + - Module: `module_name [flag1, key1=value1, ...]` + - Dependency: `source_module_name -> target_module_name [flag1, key1=value1, ...]` + +Referring to undefined module is allowed (`jvm` module will be created at this case). +This modules can be defined after reference. Several declarations for same module is not allowed. + +Supported module flags: + - `common` (old MPP) + - `sourceSetHolder`, `compilationAndSourceSetHolder` (new MPP) + - `jvm` (default) + - `js` + - `edit`, `editJvm`, `editExcpetActual` - see jps-plugin/testData/incremental/multiplatform/multiModule/README.md + +Supported dependency flags: + - `compile` (default) + - `test` + - `runtime` + - `provided` + - `expectedBy` (old MPP) + - `included` (new MPP) + - `exproted` \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/fixtures/EnableICFixture.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/fixtures/EnableICFixture.kt new file mode 100644 index 00000000000..68bff03674f --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/fixtures/EnableICFixture.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build.fixtures + +import org.jetbrains.kotlin.config.IncrementalCompilation + +class EnableICFixture( + private val enableJvmIC: Boolean = true, + private val enableJsIC: Boolean = true +) { + private var isICEnabledBackup: Boolean = false + private var isICEnabledForJsBackup: Boolean = false + + fun setUp() { + isICEnabledBackup = IncrementalCompilation.isEnabledForJvm() + IncrementalCompilation.setIsEnabledForJvm(enableJvmIC) + + isICEnabledForJsBackup = IncrementalCompilation.isEnabledForJs() + IncrementalCompilation.setIsEnabledForJs(enableJsIC) + } + + fun tearDown() { + IncrementalCompilation.setIsEnabledForJvm(isICEnabledBackup) + IncrementalCompilation.setIsEnabledForJs(isICEnabledForJsBackup) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/incrementalCustomTests.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/incrementalCustomTests.kt new file mode 100644 index 00000000000..eb97885fac1 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/incrementalCustomTests.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.kotlin.incremental.testingUtils.Modification + +class IncrementalRenameModuleTest : AbstractIncrementalJpsTest() { + fun testRenameModule() { + doTest("jps-plugin/testData/incremental/custom/renameModule/") + } + + override fun performAdditionalModifications(modifications: List) { + projectDescriptor.project.modules.forEach { it.name += "Renamed" } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt new file mode 100644 index 00000000000..990f417d6b1 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt @@ -0,0 +1,73 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.cli.common.CompilerSystemProperties +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner + +inline fun withSystemProperty(property: String, newValue: String?, fn: ()->Unit) { + val backup = System.getProperty(property) + setOrClearSysProperty(property, newValue) + + try { + fn() + } + finally { + setOrClearSysProperty(property, backup) + } +} + + +@Suppress("NOTHING_TO_INLINE") +inline fun setOrClearSysProperty(property: String, newValue: String?) { + if (newValue != null) { + System.setProperty(property, newValue) + } + else { + System.clearProperty(property) + } +} + +fun withDaemon(fn: () -> Unit) { + val daemonHome = FileUtil.createTempDirectory("daemon-home", "testJpsDaemonIC") + + withSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS.property, daemonHome.absolutePath) { + withSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_ENABLED_PROPERTY.property, "true") { + try { + fn() + } finally { + JpsKotlinCompilerRunner.shutdownDaemon() + + // Try to force directory deletion to prevent test failure later in tearDown(). + // Working Daemon can prevent folder deletion on Windows, because Daemon shutdown + // is asynchronous. + var attempts = 0 + daemonHome.deleteRecursively() + while (daemonHome.exists() && attempts < 100) { + daemonHome.deleteRecursively() + attempts++ + Thread.sleep(50) + } + + if (daemonHome.exists()) { + error("Couldn't delete Daemon home directory") + } + } + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt new file mode 100644 index 00000000000..f796c54aa4d --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJsProtoComparisonTest.kt @@ -0,0 +1,72 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants +import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.incremental.ProtoData +import org.jetbrains.kotlin.incremental.getProtoData +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl +import org.jetbrains.kotlin.incremental.utils.TestMessageCollector +import org.jetbrains.kotlin.name.ClassId +import org.junit.Assert +import java.io.File + +abstract class AbstractJsProtoComparisonTest : AbstractProtoComparisonTest() { + override fun expectedOutputFile(testDir: File): File = + File(testDir, "result-js.out") + .takeIf { it.exists() } + ?: super.expectedOutputFile(testDir) + + override fun compileAndGetClasses(sourceDir: File, outputDir: File): Map { + val incrementalResults = IncrementalResultsConsumerImpl() + val services = Services.Builder().run { + register(IncrementalResultsConsumer::class.java, incrementalResults) + build() + } + + val ktFiles = sourceDir.walkMatching { it.name.endsWith(".kt") }.map { it.canonicalPath }.toList() + val messageCollector = TestMessageCollector() + val outputItemsCollector = OutputItemsCollectorImpl() + val args = K2JSCompilerArguments().apply { + outputFile = File(outputDir, "out.js").canonicalPath + metaInfo = true + main = K2JsArgumentConstants.NO_CALL + freeArgs = ktFiles + } + + val env = createTestingCompilerEnvironment(messageCollector, outputItemsCollector, services) + runJSCompiler(args, env).let { exitCode -> + val expectedOutput = "OK" + val actualOutput = (listOf(exitCode?.name) + messageCollector.errors).joinToString("\n") + Assert.assertEquals(expectedOutput, actualOutput) + } + + val classes = hashMapOf() + + for ((sourceFile, translationResult) in incrementalResults.packageParts) { + classes.putAll(getProtoData(sourceFile, translationResult.metadata)) + } + + return classes + } + + override fun ProtoData.toProtoData(): ProtoData? = this +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJvmProtoComparisonTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJvmProtoComparisonTest.kt new file mode 100644 index 00000000000..3e0be6a8cf2 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractJvmProtoComparisonTest.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.kotlin.incremental.LocalFileKotlinClass +import org.jetbrains.kotlin.incremental.ProtoData +import org.jetbrains.kotlin.incremental.storage.ProtoMapValue +import org.jetbrains.kotlin.incremental.toProtoData +import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader +import org.jetbrains.kotlin.metadata.jvm.deserialization.BitEncoding +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.test.MockLibraryUtil +import java.io.File + +abstract class AbstractJvmProtoComparisonTest : AbstractProtoComparisonTest() { + override fun compileAndGetClasses(sourceDir: File, outputDir: File): Map { + MockLibraryUtil.compileKotlin(sourceDir.path, outputDir, extraOptions = listOf("-Xdisable-default-scripting-plugin")) + + val classFiles = outputDir.walkMatching { it.name.endsWith(".class") } + val localClassFiles = classFiles.map { LocalFileKotlinClass.create(it)!! } + return localClassFiles.associateBy { it.classId } + } + + override fun LocalFileKotlinClass.toProtoData(): ProtoData? { + assert(classHeader.metadataVersion.isCompatible()) { "Incompatible class ($classHeader): $location" } + + val bytes by lazy { BitEncoding.decodeBytes(classHeader.data!!) } + val strings by lazy { classHeader.strings!! } + val packageFqName = classId.packageFqName + + return when (classHeader.kind) { + KotlinClassHeader.Kind.CLASS -> { + ProtoMapValue(false, bytes, strings).toProtoData(packageFqName) + } + KotlinClassHeader.Kind.FILE_FACADE, + KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> { + ProtoMapValue(true, bytes, strings).toProtoData(packageFqName) + } + else -> { + null + } + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt new file mode 100644 index 00000000000..da16372d4c1 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt @@ -0,0 +1,123 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.kotlin.TestWithWorkingDir +import org.jetbrains.kotlin.incremental.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.utils.Printer +import java.io.File + +abstract class AbstractProtoComparisonTest : TestWithWorkingDir() { + protected abstract fun compileAndGetClasses(sourceDir: File, outputDir: File): Map + protected abstract fun PROTO_DATA.toProtoData(): ProtoData? + + protected open fun expectedOutputFile(testDir: File): File = + File(testDir, "result.out") + + fun doTest(testDataPath: String) { + val testDir = File(testDataPath) + + val oldClassMap = classesForPrefixedSources(testDir, workingDir, "old") + val newClassMap = classesForPrefixedSources(testDir, workingDir, "new") + + val sb = StringBuilder() + val p = Printer(sb) + + (oldClassMap.keys - newClassMap.keys).sortedBy { it.toString() }.forEach { classId -> + p.println("REMOVED $classId") + } + + (newClassMap.keys - oldClassMap.keys).sortedBy { it.toString() }.forEach { classId -> + p.println("ADDED $classId") + } + + (oldClassMap.keys.intersect(newClassMap.keys)).sortedBy { it.toString() }.forEach { classId -> + val oldData = oldClassMap[classId]!!.toProtoData() + val newData = newClassMap[classId]!!.toProtoData() + + if (oldData == null || newData == null) { + p.println("SKIPPED $classId") + return@forEach + } + + val rawProtoDifference = when { + oldData is ClassProtoData && newData is ClassProtoData -> { + ProtoCompareGenerated( + oldNameResolver = oldData.nameResolver, + newNameResolver = newData.nameResolver, + oldTypeTable = oldData.proto.typeTableOrNull, + newTypeTable = newData.proto.typeTableOrNull + ).difference(oldData.proto, newData.proto) + } + oldData is PackagePartProtoData && newData is PackagePartProtoData -> { + ProtoCompareGenerated( + oldNameResolver = oldData.nameResolver, + newNameResolver = newData.nameResolver, + oldTypeTable = oldData.proto.typeTableOrNull, + newTypeTable = newData.proto.typeTableOrNull + ).difference(oldData.proto, newData.proto) + } + else -> null + } + rawProtoDifference?.let { + if (it.isNotEmpty()) { + p.println("PROTO DIFFERENCE in $classId: ${it.sortedBy { it.name }.joinToString()}") + } + } + + val changesInfo = ChangesCollector().apply { collectProtoChanges(oldData, newData) }.changes() + if (changesInfo.isEmpty()) { + return@forEach + } + + val changes = changesInfo.map { + when (it) { + is ChangeInfo.SignatureChanged -> "CLASS_SIGNATURE" + is ChangeInfo.MembersChanged -> "MEMBERS\n ${it.names.sorted()}" + is ChangeInfo.ParentsChanged -> "PARENTS\n ${it.parentsChanged.map { it.asString()}.sorted()}" + + } + }.sorted() + + p.println("CHANGES in $classId: ${changes.joinToString()}") + } + + KotlinTestUtils.assertEqualsToFile(expectedOutputFile(testDir), sb.toString()) + } + + private fun classesForPrefixedSources(testDir: File, workingDir: File, prefix: String): Map { + val srcDir = workingDir.createSubDirectory("$prefix/src") + val outDir = workingDir.createSubDirectory("$prefix/out") + copySourceFiles(testDir, srcDir, prefix) + return compileAndGetClasses(srcDir, outDir) + } + + private fun copySourceFiles(sourceDir: File, targetDir: File, prefix: String) { + for (srcFile in sourceDir.walkMatching { it.name.startsWith(prefix) }) { + val targetFile = File(targetDir, srcFile.name.replaceFirst(prefix, "main")) + srcFile.copyTo(targetFile) + } + } + + protected fun File.createSubDirectory(relativePath: String): File = + File(this, relativePath).apply { mkdirs() } + + protected fun File.walkMatching(predicate: (File)->Boolean): Sequence = + walk().filter { predicate(it) } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/CacheVersionTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/CacheVersionTest.kt new file mode 100644 index 00000000000..30a361cae7b --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/CacheVersionTest.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.kotlin.load.kotlin.JvmBytecodeBinaryVersion +import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion +import org.junit.Assert.assertEquals +import org.junit.Test + +class CacheVersionTest { + @Test + fun testConstruct() { + assertEquals( + 3011001, + CacheVersion( + 3, + JvmBytecodeBinaryVersion(1, 0, 3), + JvmMetadataVersion(1, 1, 13) + ).intValue + ) + } + + @Test + fun testDeconstruct() { + assertEquals( + "CacheVersion(caches: 3, bytecode: 1.0, metadata: 1.1)", + CacheVersion(3011001).toString() + ) + } + + @Test + fun testConstructDeconstruct() { + val version = CacheVersion( + 1, + JvmBytecodeBinaryVersion(2, 3), + JvmMetadataVersion(4, 5) + ) + + assertEquals(1024305, version.intValue) + assertEquals("CacheVersion(caches: 1, bytecode: 2.3, metadata: 4.5)", version.toString()) + } + + @Test + fun testMaxValues() { + assertEquals( + "CacheVersion(caches: 2146, bytecode: 9.9, metadata: 9.99)", + CacheVersion( + 2146, + JvmBytecodeBinaryVersion(9, 9), + JvmMetadataVersion(9, 99) + ).toString() + ) + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/CompositeLookupsCacheAttributesManagerTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/CompositeLookupsCacheAttributesManagerTest.kt new file mode 100644 index 00000000000..bc162aba34d --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/CompositeLookupsCacheAttributesManagerTest.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.kotlin.jps.incremental.CacheStatus +import org.jetbrains.kotlin.jps.incremental.loadDiff +import org.junit.Test +import java.io.File +import kotlin.test.assertEquals + +class CompositeLookupsCacheAttributesManagerTest { + val manager = CompositeLookupsCacheAttributesManager(File("not-used"), setOf()) + + @Test + fun testNothingToJava() { + assertEquals( + CacheStatus.INVALID, + manager.loadDiff( + actual = null, + expected = CompositeLookupsCacheAttributes(1, setOf("jvm")) + ).status + ) + } + + @Test + fun testNothingToJavaAndJs() { + assertEquals( + CacheStatus.INVALID, + manager.loadDiff( + actual = null, + expected = CompositeLookupsCacheAttributes(1, setOf("jvm", "js")) + ).status + ) + } + + @Test + fun testJsToJava() { + assertEquals( + CacheStatus.INVALID, + manager.loadDiff( + actual = CompositeLookupsCacheAttributes(1, setOf("jvm")), + expected = CompositeLookupsCacheAttributes(1, setOf("js")) + ).status + ) + } + + @Test + fun testJsAndJavaToJava() { + assertEquals( + CacheStatus.VALID, + manager.loadDiff( + actual = CompositeLookupsCacheAttributes(1, setOf("jvm", "js")), + expected = CompositeLookupsCacheAttributes(1, setOf("jvm")) + ).status + ) + } + + @Test + fun testJsAndJavaToJavaWithOtherVersion() { + assertEquals( + CacheStatus.INVALID, + manager.loadDiff( + actual = CompositeLookupsCacheAttributes(1, setOf("jvm", "js")), + expected = CompositeLookupsCacheAttributes(2, setOf("jvm")) + ).status + ) + } + + @Test + fun testJavaToJsAndJava() { + assertEquals( + CacheStatus.INVALID, + manager.loadDiff( + actual = CompositeLookupsCacheAttributes(1, setOf("jvm")), + expected = CompositeLookupsCacheAttributes(1, setOf("jvm", "js")) + ).status + ) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/JsProtoComparisonTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/JsProtoComparisonTestGenerated.java new file mode 100644 index 00000000000..bc9ea513f77 --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/JsProtoComparisonTestGenerated.java @@ -0,0 +1,711 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@RunWith(JUnit3RunnerWithInners.class) +public class JsProtoComparisonTestGenerated extends AbstractJsProtoComparisonTest { + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassSignatureChange extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassSignatureChange() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classAnnotationListChanged") + public void testClassAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/"); + } + + @TestMetadata("classFlagsAndMembersChanged") + public void testClassFlagsAndMembersChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/"); + } + + @TestMetadata("classFlagsChanged") + public void testClassFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/"); + } + + @TestMetadata("classTypeParameterListChanged") + public void testClassTypeParameterListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/"); + } + + @TestMetadata("classWithSuperTypeListChanged") + public void testClassWithSuperTypeListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/"); + } + + @TestMetadata("nestedClassSignatureChanged") + public void testNestedClassSignatureChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/"); + } + + @TestMetadata("sealedClassImplAdded") + public void testSealedClassImplAdded() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/"); + } + + @TestMetadata("sealedClassImplRemoved") + public void testSealedClassImplRemoved() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/"); + } + + @TestMetadata("sealedClassNestedImplAdded") + public void testSealedClassNestedImplAdded() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/"); + } + + @TestMetadata("sealedClassNestedImplAddedDeep") + public void testSealedClassNestedImplAddedDeep() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/"); + } + + @TestMetadata("sealedClassNestedImplRemoved") + public void testSealedClassNestedImplRemoved() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/"); + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassAnnotationListChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassFlagsAndMembersChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassFlagsAndMembersChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassFlagsChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassTypeParameterListChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassTypeParameterListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithSuperTypeListChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithSuperTypeListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NestedClassSignatureChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNestedClassSignatureChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplAdded extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplRemoved extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplAdded extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplAddedDeep extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplAddedDeep() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplRemoved extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassPrivateOnlyChange extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassPrivateOnlyChange() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classWithPrivateFunChanged") + public void testClassWithPrivateFunChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/"); + } + + @TestMetadata("classWithPrivatePrimaryConstructorChanged") + public void testClassWithPrivatePrimaryConstructorChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/"); + } + + @TestMetadata("classWithPrivateSecondaryConstructorChanged") + public void testClassWithPrivateSecondaryConstructorChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/"); + } + + @TestMetadata("classWithPrivateValChanged") + public void testClassWithPrivateValChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/"); + } + + @TestMetadata("classWithPrivateVarChanged") + public void testClassWithPrivateVarChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/"); + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateFunChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateFunChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivatePrimaryConstructorChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivatePrimaryConstructorChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateSecondaryConstructorChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateSecondaryConstructorChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateValChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateValChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateVarChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateVarChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassMembersOnlyChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassMembersOnlyChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classWithCompanionObjectChanged") + public void testClassWithCompanionObjectChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/"); + } + + @TestMetadata("classWithConstructorChanged") + public void testClassWithConstructorChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/"); + } + + @TestMetadata("classWithFunAndValChanged") + public void testClassWithFunAndValChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/"); + } + + @TestMetadata("classWithNestedClassesChanged") + public void testClassWithNestedClassesChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/"); + } + + @TestMetadata("classWitnEnumChanged") + public void testClassWitnEnumChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/"); + } + + @TestMetadata("defaultValues") + public void testDefaultValues() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/"); + } + + @TestMetadata("membersAnnotationListChanged") + public void testMembersAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/"); + } + + @TestMetadata("membersFlagsChanged") + public void testMembersFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/"); + } + + @TestMetadata("nestedClassMembersChanged") + public void testNestedClassMembersChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/"); + } + + @TestMetadata("sealedClassImplAdded") + public void testSealedClassImplAdded() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/"); + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithCompanionObjectChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithCompanionObjectChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithConstructorChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithConstructorChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithFunAndValChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithFunAndValChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithNestedClassesChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithNestedClassesChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWitnEnumChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWitnEnumChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValues extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersAnnotationListChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersFlagsChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NestedClassMembersChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNestedClassMembersChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplAdded extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageMembers extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageMembers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("defaultValues") + public void testDefaultValues() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/defaultValues/"); + } + + @TestMetadata("membersAnnotationListChanged") + public void testMembersAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/"); + } + + @TestMetadata("membersFlagsChanged") + public void testMembersFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/"); + } + + @TestMetadata("packageFacadePrivateOnlyChanges") + public void testPackageFacadePrivateOnlyChanges() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/"); + } + + @TestMetadata("packageFacadePublicChanges") + public void testPackageFacadePublicChanges() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/"); + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/defaultValues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValues extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/defaultValues"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersAnnotationListChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/membersFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersFlagsChanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/membersFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadePrivateOnlyChanges extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadePrivateOnlyChanges() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadePublicChanges extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadePublicChanges() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/unchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Unchanged extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/unchanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("unchangedClass") + public void testUnchangedClass() throws Exception { + runTest("jps-plugin/testData/comparison/unchanged/unchangedClass/"); + } + + @TestMetadata("unchangedPackageFacade") + public void testUnchangedPackageFacade() throws Exception { + runTest("jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/"); + } + + @TestMetadata("jps-plugin/testData/comparison/unchanged/unchangedClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UnchangedClass extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUnchangedClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/unchanged/unchangedClass"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/unchanged/unchangedPackageFacade") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UnchangedPackageFacade extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUnchangedPackageFacade() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/unchanged/unchangedPackageFacade"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/jsOnly") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JsOnly extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJsOnly() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jsOnly"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("externals") + public void testExternals() throws Exception { + runTest("jps-plugin/testData/comparison/jsOnly/externals/"); + } + + @TestMetadata("jps-plugin/testData/comparison/jsOnly/externals") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Externals extends AbstractJsProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInExternals() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jsOnly/externals"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/JvmProtoComparisonTestGenerated.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/JvmProtoComparisonTestGenerated.java new file mode 100644 index 00000000000..1573b5af26a --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/JvmProtoComparisonTestGenerated.java @@ -0,0 +1,765 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@RunWith(JUnit3RunnerWithInners.class) +public class JvmProtoComparisonTestGenerated extends AbstractJvmProtoComparisonTest { + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassSignatureChange extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassSignatureChange() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classAnnotationListChanged") + public void testClassAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/"); + } + + @TestMetadata("classFlagsAndMembersChanged") + public void testClassFlagsAndMembersChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/"); + } + + @TestMetadata("classFlagsChanged") + public void testClassFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/"); + } + + @TestMetadata("classTypeParameterListChanged") + public void testClassTypeParameterListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/"); + } + + @TestMetadata("classWithSuperTypeListChanged") + public void testClassWithSuperTypeListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/"); + } + + @TestMetadata("nestedClassSignatureChanged") + public void testNestedClassSignatureChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/"); + } + + @TestMetadata("sealedClassImplAdded") + public void testSealedClassImplAdded() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/"); + } + + @TestMetadata("sealedClassImplRemoved") + public void testSealedClassImplRemoved() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/"); + } + + @TestMetadata("sealedClassNestedImplAdded") + public void testSealedClassNestedImplAdded() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/"); + } + + @TestMetadata("sealedClassNestedImplAddedDeep") + public void testSealedClassNestedImplAddedDeep() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/"); + } + + @TestMetadata("sealedClassNestedImplRemoved") + public void testSealedClassNestedImplRemoved() throws Exception { + runTest("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/"); + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassAnnotationListChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassFlagsAndMembersChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassFlagsAndMembersChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassFlagsChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassTypeParameterListChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassTypeParameterListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithSuperTypeListChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithSuperTypeListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NestedClassSignatureChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNestedClassSignatureChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplAdded extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplRemoved extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplAdded extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplAddedDeep extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplAddedDeep() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassNestedImplRemoved extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassNestedImplRemoved() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassPrivateOnlyChange extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassPrivateOnlyChange() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classWithPrivateFunChanged") + public void testClassWithPrivateFunChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/"); + } + + @TestMetadata("classWithPrivatePrimaryConstructorChanged") + public void testClassWithPrivatePrimaryConstructorChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/"); + } + + @TestMetadata("classWithPrivateSecondaryConstructorChanged") + public void testClassWithPrivateSecondaryConstructorChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/"); + } + + @TestMetadata("classWithPrivateValChanged") + public void testClassWithPrivateValChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/"); + } + + @TestMetadata("classWithPrivateVarChanged") + public void testClassWithPrivateVarChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/"); + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateFunChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateFunChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivatePrimaryConstructorChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivatePrimaryConstructorChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateSecondaryConstructorChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateSecondaryConstructorChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateValChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateValChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithPrivateVarChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithPrivateVarChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassMembersOnlyChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassMembersOnlyChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classWithCompanionObjectChanged") + public void testClassWithCompanionObjectChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/"); + } + + @TestMetadata("classWithConstructorChanged") + public void testClassWithConstructorChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/"); + } + + @TestMetadata("classWithFunAndValChanged") + public void testClassWithFunAndValChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/"); + } + + @TestMetadata("classWithNestedClassesChanged") + public void testClassWithNestedClassesChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/"); + } + + @TestMetadata("classWitnEnumChanged") + public void testClassWitnEnumChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/"); + } + + @TestMetadata("defaultValues") + public void testDefaultValues() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/"); + } + + @TestMetadata("membersAnnotationListChanged") + public void testMembersAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/"); + } + + @TestMetadata("membersFlagsChanged") + public void testMembersFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/"); + } + + @TestMetadata("nestedClassMembersChanged") + public void testNestedClassMembersChanged() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/"); + } + + @TestMetadata("sealedClassImplAdded") + public void testSealedClassImplAdded() throws Exception { + runTest("jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/"); + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithCompanionObjectChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithCompanionObjectChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithConstructorChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithConstructorChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithFunAndValChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithFunAndValChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWithNestedClassesChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWithNestedClassesChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassWitnEnumChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassWitnEnumChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValues extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersAnnotationListChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersFlagsChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NestedClassMembersChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNestedClassMembersChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SealedClassImplAdded extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSealedClassImplAdded() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageMembers extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageMembers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("defaultValues") + public void testDefaultValues() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/defaultValues/"); + } + + @TestMetadata("membersAnnotationListChanged") + public void testMembersAnnotationListChanged() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/"); + } + + @TestMetadata("membersFlagsChanged") + public void testMembersFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/"); + } + + @TestMetadata("packageFacadePrivateOnlyChanges") + public void testPackageFacadePrivateOnlyChanges() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/"); + } + + @TestMetadata("packageFacadePublicChanges") + public void testPackageFacadePublicChanges() throws Exception { + runTest("jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/"); + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/defaultValues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultValues extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDefaultValues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/defaultValues"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersAnnotationListChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersAnnotationListChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/membersFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersFlagsChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/membersFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadePrivateOnlyChanges extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadePrivateOnlyChanges() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadePublicChanges extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadePublicChanges() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/unchanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Unchanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUnchanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/unchanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("unchangedClass") + public void testUnchangedClass() throws Exception { + runTest("jps-plugin/testData/comparison/unchanged/unchangedClass/"); + } + + @TestMetadata("unchangedPackageFacade") + public void testUnchangedPackageFacade() throws Exception { + runTest("jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/"); + } + + @TestMetadata("jps-plugin/testData/comparison/unchanged/unchangedClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UnchangedClass extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUnchangedClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/unchanged/unchangedClass"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/unchanged/unchangedPackageFacade") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UnchangedPackageFacade extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInUnchangedPackageFacade() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/unchanged/unchangedPackageFacade"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } + + @TestMetadata("jps-plugin/testData/comparison/jvmOnly") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JvmOnly extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJvmOnly() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jvmOnly"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("classToFileFacade") + public void testClassToFileFacade() throws Exception { + runTest("jps-plugin/testData/comparison/jvmOnly/classToFileFacade/"); + } + + @TestMetadata("membersFlagsChanged") + public void testMembersFlagsChanged() throws Exception { + runTest("jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/"); + } + + @TestMetadata("packageFacadeMultifileClassChanged") + public void testPackageFacadeMultifileClassChanged() throws Exception { + runTest("jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/"); + } + + @TestMetadata("packageFacadeToClass") + public void testPackageFacadeToClass() throws Exception { + runTest("jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/"); + } + + @TestMetadata("jps-plugin/testData/comparison/jvmOnly/classToFileFacade") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassToFileFacade extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInClassToFileFacade() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jvmOnly/classToFileFacade"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MembersFlagsChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMembersFlagsChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadeMultifileClassChanged extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadeMultifileClassChanged() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PackageFacadeToClass extends AbstractJvmProtoComparisonTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPackageFacadeToClass() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/compilerUtils.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/compilerUtils.kt new file mode 100644 index 00000000000..1eae8c7231f --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/incremental/compilerUtils.kt @@ -0,0 +1,67 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.cli.js.K2JSCompiler +import org.jetbrains.kotlin.compilerRunner.* +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.jps.build.KotlinBuilder +import org.jetbrains.kotlin.utils.PathUtil +import java.io.* + +fun createTestingCompilerEnvironment( + messageCollector: MessageCollector, + outputItemsCollector: OutputItemsCollectorImpl, + services: Services +): JpsCompilerEnvironment { + val paths = PathUtil.kotlinPathsForDistDirectory + + val wrappedMessageCollector = MessageCollectorToOutputItemsCollectorAdapter(messageCollector, outputItemsCollector) + return JpsCompilerEnvironment( + paths, + services, + KotlinBuilder.classesToLoadByParent, + wrappedMessageCollector, + outputItemsCollector, + MockProgressReporter + ) +} + +fun runJSCompiler(args: K2JSCompilerArguments, env: JpsCompilerEnvironment): ExitCode? { + val argsArray = ArgumentUtils.convertArgumentsToStringList(args).toTypedArray() + + val stream = ByteArrayOutputStream() + val out = PrintStream(stream) + val exitCode = CompilerRunnerUtil.invokeExecMethod(K2JSCompiler::class.java.name, argsArray, env, out) + val reader = BufferedReader(StringReader(stream.toString())) + CompilerOutputParser.parseCompilerMessagesFromReader(env.messageCollector, reader, env.outputItemsCollector) + return exitCode as? ExitCode +} + +private object MockProgressReporter : ProgressReporter { + override fun progress(message: String) { + } + + override fun compilationStarted() { + } + + override fun clearProgress() { + } +} \ No newline at end of file diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt new file mode 100644 index 00000000000..244a538fdde --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jvm.compiler + +import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType +import org.jetbrains.kotlin.build.JvmSourceRoot +import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder +import org.jetbrains.kotlin.test.MockLibraryUtil +import org.jetbrains.kotlin.test.TestCaseWithTmpdir +import org.jetbrains.kotlin.test.util.KtTestUtil +import org.jetbrains.kotlin.utils.PathUtil +import java.io.File + +/** + * This test checks that Java classes from sources have higher priority in Kotlin resolution process than classes from binaries. + * 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 + */ +class ClasspathOrderTest : TestCaseWithTmpdir() { + companion object { + private val sourceDir = File(KtTestUtil.getTestDataPathBase() + "/classpathOrder").absoluteFile + } + + fun testClasspathOrderForCLI() { + MockLibraryUtil.compileKotlin(sourceDir.path, tmpdir) + } + + fun testClasspathOrderForModuleScriptBuild() { + val xmlContent = KotlinModuleXmlBuilder().addModule( + "name", + File(tmpdir, "output").absolutePath, + listOf(sourceDir), + listOf(JvmSourceRoot(sourceDir)), + listOf(PathUtil.kotlinPathsForDistDirectory.stdlibPath), + emptyList(), + null, + JavaModuleBuildTargetType.PRODUCTION.typeId, + JavaModuleBuildTargetType.PRODUCTION.isTests, + setOf(), + emptyList() + ).asText().toString() + + val xml = File(tmpdir, "module.xml") + xml.writeText(xmlContent) + + MockLibraryUtil.compileKotlinModule(xml.absolutePath) + } +} diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java new file mode 100644 index 00000000000..ede464de4dc --- /dev/null +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java @@ -0,0 +1,111 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.modules; + +import junit.framework.TestCase; +import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType; +import org.jetbrains.kotlin.build.JvmSourceRoot; +import org.jetbrains.kotlin.test.KotlinTestUtils; + +import java.io.File; +import java.util.Arrays; +import java.util.Collections; + +public class KotlinModuleXmlGeneratorTest extends TestCase { + public void testBasic() throws Exception { + String actual = new KotlinModuleXmlBuilder().addModule( + "name", + "output", + Arrays.asList(new File("s1"), new File("s2")), + Collections.singletonList(new JvmSourceRoot(new File("java"), null)), + Arrays.asList(new File("cp1"), new File("cp2")), + Collections.emptyList(), + null, + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), + Collections.emptySet(), + Collections.emptyList() + ).asText().toString(); + KotlinTestUtils.assertEqualsToFile(new File("idea/testData/modules.xml/basic.xml"), actual); + } + + public void testFiltered() throws Exception { + String actual = new KotlinModuleXmlBuilder().addModule( + "name", + "output", + Arrays.asList(new File("s1"), new File("s2")), + Collections.emptyList(), + Arrays.asList(new File("cp1"), new File("cp2")), + Collections.emptyList(), + null, + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), + Collections.singleton(new File("cp1")), + Collections.emptyList() + ).asText().toString(); + KotlinTestUtils.assertEqualsToFile(new File("idea/testData/modules.xml/filtered.xml"), actual); + } + + public void testMultiple() throws Exception { + KotlinModuleXmlBuilder builder = new KotlinModuleXmlBuilder(); + builder.addModule( + "name", + "output", + Arrays.asList(new File("s1"), new File("s2")), + Collections.emptyList(), + Arrays.asList(new File("cp1"), new File("cp2")), + Collections.emptyList(), + null, + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), + Collections.singleton(new File("cp1")), + Collections.emptyList() + ); + builder.addModule( + "name2", + "output2", + Arrays.asList(new File("s12"), new File("s22")), + Collections.emptyList(), + Arrays.asList(new File("cp12"), new File("cp22")), + Collections.emptyList(), + null, + JavaModuleBuildTargetType.TEST.getTypeId(), + JavaModuleBuildTargetType.TEST.isTests(), + Collections.singleton(new File("cp12")), + Collections.emptyList() + ); + String actual = builder.asText().toString(); + KotlinTestUtils.assertEqualsToFile(new File("idea/testData/modules.xml/multiple.xml"), actual); + } + + public void testModularJdkRoot() throws Exception { + String actual = new KotlinModuleXmlBuilder().addModule( + "name", + "output", + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + new File("/path/to/modular/jdk"), + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), + Collections.emptySet(), + Collections.emptyList() + ).asText().toString(); + KotlinTestUtils.assertEqualsToFile(new File("idea/testData/modules.xml/modularJdkRoot.xml"), actual); + } +} diff --git a/jps/jps-plugin/kannotator-jps-plugin-test/test/org/jetbrains/kotlin/jps/build/kannotator/KannotatorJpsTest.java b/jps/jps-plugin/kannotator-jps-plugin-test/test/org/jetbrains/kotlin/jps/build/kannotator/KannotatorJpsTest.java new file mode 100644 index 00000000000..acea57d742a --- /dev/null +++ b/jps/jps-plugin/kannotator-jps-plugin-test/test/org/jetbrains/kotlin/jps/build/kannotator/KannotatorJpsTest.java @@ -0,0 +1,115 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build.kannotator; + +import com.intellij.openapi.util.io.FileUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.builders.BuildResult; +import org.jetbrains.jps.model.module.JpsModule; +import org.jetbrains.jps.model.module.JpsModuleSourceRoot; +import org.jetbrains.kotlin.incremental.testingUtils.ClassFilesComparisonKt; +import org.jetbrains.kotlin.jps.build.AbstractKotlinJpsBuildTestCase; + +import java.io.File; +import java.io.IOException; + +public class KannotatorJpsTest extends AbstractKotlinJpsBuildTestCase { + private static final String JDK_NAME = "1.6"; + + @Override + public void setUp() throws Exception { + super.setUp(); + File sourceFilesRoot = new File(TEST_DATA_PATH + File.separator + "kannotator"); + workDir = copyTestDataToTmpDir(sourceFilesRoot); + } + + public void testMakeKannotator() throws IOException { + initProject(); + rebuildAllModules(); + FileUtil.copyDir(getOutDir(), getOutDirAfterRebuild()); + for (JpsModule module : myProject.getModules()) { + for (JpsModuleSourceRoot sourceRoot : module.getSourceRoots()) { + processFile(sourceRoot.getFile()); + } + } + } + + @NotNull + private File getOutDir() { + return new File(workDir, "out"); + } + + @NotNull + private File getOutDirAfterRebuild() { + return new File(workDir, "out-after-rebuild"); + } + + private void processFile(File root) { + if (root.isDirectory()) { + File[] files = root.listFiles(); + if (files == null) return; + for (File file : files) { + processFile(file); + } + } + else if (root.getName().endsWith(".kt")) { + System.out.println("Test started. File: " + root.getName()); + String path = root.getAbsolutePath(); + System.out.println("Change file: " + path); + change(path); + buildAllModules().assertSuccessful(); + System.out.println("Make successful"); + + System.out.println("Checking output directories after make and rebuild"); + + ClassFilesComparisonKt + .assertEqualDirectories(new File(getOutDirAfterRebuild(), "production"), new File(getOutDir(), "production"), false); + ClassFilesComparisonKt.assertEqualDirectories(new File(getOutDirAfterRebuild(), "test"), new File(getOutDir(), "test"), false); + + System.out.println("Test successfully finished. File: " + root.getName()); + System.out.println("-----"); + } + } + + @Override + protected void rebuildAllModules() { + System.out.println("'Rebuild all' started"); + super.rebuildAllModules(); + System.out.println("'Rebuild all' finished"); + } + + @NotNull + @Override + protected BuildResult buildAllModules() { + System.out.println("'Make all' started"); + BuildResult result = super.buildAllModules(); + System.out.println("'Make all' finished"); + return result; + } + + private void initProject() { + addJdk(JDK_NAME); + loadProject(workDir.getAbsolutePath()); + addKotlinStdlibDependency(); + } + + @Override + public void tearDown() throws Exception { + FileUtil.delete(workDir); + super.tearDown(); + } +} diff --git a/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.AdditionalRootsProviderService b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.AdditionalRootsProviderService new file mode 100644 index 00000000000..775a989618d --- /dev/null +++ b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.AdditionalRootsProviderService @@ -0,0 +1,2 @@ +org.jetbrains.kotlin.jps.build.KotlinSourceRootProvider +org.jetbrains.kotlin.jps.build.KotlinResourcesRootProvider \ No newline at end of file diff --git a/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.java.JavaBuilderExtension b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.java.JavaBuilderExtension new file mode 100644 index 00000000000..206b2c9a36d --- /dev/null +++ b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.java.JavaBuilderExtension @@ -0,0 +1 @@ +org.jetbrains.kotlin.jps.build.KotlinJavaBuilderExtension \ No newline at end of file diff --git a/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.java.dependencyView.AnnotationsChangeTracker b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.java.dependencyView.AnnotationsChangeTracker new file mode 100644 index 00000000000..2acdad61d00 --- /dev/null +++ b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.builders.java.dependencyView.AnnotationsChangeTracker @@ -0,0 +1 @@ +org.jetbrains.jps.builders.java.dependencyView.NullabilityAnnotationsTracker \ No newline at end of file diff --git a/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.incremental.BuilderService b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.incremental.BuilderService new file mode 100644 index 00000000000..caf9af82251 --- /dev/null +++ b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.incremental.BuilderService @@ -0,0 +1 @@ +org.jetbrains.kotlin.jps.build.KotlinBuilderService \ No newline at end of file diff --git a/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension new file mode 100644 index 00000000000..6310ade24c5 --- /dev/null +++ b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension @@ -0,0 +1 @@ +org.jetbrains.kotlin.jps.model.KotlinModelSerializerService \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/jps/builders/java/dependencyView/NullabilityAnnotationsTracker.kt b/jps/jps-plugin/src/org/jetbrains/jps/builders/java/dependencyView/NullabilityAnnotationsTracker.kt new file mode 100644 index 00000000000..7e202b9b1fc --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/jps/builders/java/dependencyView/NullabilityAnnotationsTracker.kt @@ -0,0 +1,79 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jps.builders.java.dependencyView + +import gnu.trove.TIntHashSet +import org.jetbrains.jps.builders.java.dependencyView.TypeRepr.ClassType +import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses +import org.jetbrains.kotlin.load.java.JAVAX_NONNULL_ANNOTATION +import org.jetbrains.kotlin.load.java.NOT_NULL_ANNOTATIONS +import org.jetbrains.kotlin.load.java.NULLABLE_ANNOTATIONS +import java.util.* + +internal class NullabilityAnnotationsTracker : AnnotationsChangeTracker() { + private val annotations = + (NULLABLE_ANNOTATIONS + JAVAX_NONNULL_ANNOTATION + NOT_NULL_ANNOTATIONS).mapTo(HashSet()) { it.internalNameWithoutInnerClasses } + .toTypedArray() + + override fun methodAnnotationsChanged( + context: DependencyContext, + method: MethodRepr, + annotationsDiff: Difference.Specifier, + paramAnnotationsDiff: Difference.Specifier + ): Set { + val changedAnnotations = annotationsDiff.addedOrRemoved() + + paramAnnotationsDiff.addedOrRemoved().map { it.type } + + return handleNullAnnotationsChanges(context, method, changedAnnotations) + } + + + override fun fieldAnnotationsChanged( + context: NamingContext, + field: FieldRepr, + annotationsDiff: Difference.Specifier + ): Set { + return handleNullAnnotationsChanges(context, field, annotationsDiff.addedOrRemoved()) + } + + private fun handleNullAnnotationsChanges( + context: NamingContext, + protoMember: ProtoMember, + annotations: Sequence + ): Set { + val nullabilityAnnotations = TIntHashSet(this.annotations.toIntArray { context.get(it) }) + val changedNullAnnotation = annotations.firstOrNull { nullabilityAnnotations.contains(it.className) } + + val result = EnumSet.noneOf(Recompile::class.java) + if (changedNullAnnotation != null) { + result.add(Recompile.USAGES) + + if (protoMember is MethodRepr && !protoMember.isFinal) { + // methods can be overridden, whereas fields cannot be + result.add(Recompile.SUBCLASSES) + } + } + + return result + } + + private fun Difference.Specifier.addedOrRemoved(): Sequence = + added().asSequence() + removed().asSequence() + + private inline fun Array.toIntArray(fn: (T) -> Int): IntArray = + IntArray(size) { i -> fn(get(i)) } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/CompilerRunnerUtil.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/CompilerRunnerUtil.kt new file mode 100644 index 00000000000..282fded48c8 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/CompilerRunnerUtil.kt @@ -0,0 +1,123 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.compilerRunner + +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.preloading.ClassPreloadingUtils +import org.jetbrains.kotlin.preloading.Preloader +import org.jetbrains.kotlin.utils.KotlinPaths +import org.jetbrains.kotlin.utils.KotlinPathsFromBaseDirectory +import java.io.File +import java.io.PrintStream +import java.lang.ref.SoftReference + +object CompilerRunnerUtil { + private var ourClassLoaderRef = SoftReference(null) + + internal val jdkToolsJar: File? + get() { + val javaHomePath = System.getProperty("java.home") + if (javaHomePath == null || javaHomePath.isEmpty()) { + return null + } + val javaHome = File(javaHomePath) + var toolsJar = File(javaHome, "lib/tools.jar") + if (toolsJar.exists()) { + return toolsJar.canonicalFile + } + + // We might be inside jre. + if (javaHome.name == "jre") { + toolsJar = File(javaHome.parent, "lib/tools.jar") + if (toolsJar.exists()) { + return toolsJar.canonicalFile + } + } + + return null + } + + @Synchronized + private fun getOrCreateClassLoader( + environment: JpsCompilerEnvironment, + paths: List + ): ClassLoader { + var classLoader = ourClassLoaderRef.get() + if (classLoader == null) { + classLoader = ClassPreloadingUtils.preloadClasses( + paths, + Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, + CompilerRunnerUtil::class.java.classLoader, + environment.classesToLoadByParent + ) + ourClassLoaderRef = SoftReference(classLoader) + } + return classLoader!! + } + + fun getLibPath(paths: KotlinPaths, messageCollector: MessageCollector): File? { + val libs = paths.libPath + if (libs.exists() && !libs.isFile) return libs + + messageCollector.report( + ERROR, + "Broken compiler at '" + libs.absolutePath + "'. Make sure plugin is properly installed", null + ) + + return null + } + + fun invokeExecMethod( + compilerClassName: String, + arguments: Array, + environment: JpsCompilerEnvironment, + out: PrintStream + ): Any? = withCompilerClassloader(environment) { classLoader -> + val compiler = Class.forName(compilerClassName, true, classLoader) + val exec = compiler.getMethod( + "execAndOutputXml", + PrintStream::class.java, + Class.forName("org.jetbrains.kotlin.config.Services", true, classLoader), + Array::class.java + ) + exec.invoke(compiler.newInstance(), out, environment.services, arguments) + } + + fun invokeClassesFqNames( + environment: JpsCompilerEnvironment, + files: Set + ): Set = withCompilerClassloader(environment) { classLoader -> + val klass = Class.forName("org.jetbrains.kotlin.incremental.parsing.ParseFileUtilsKt", true, classLoader) + val method = klass.getMethod("classesFqNames", Set::class.java) + @Suppress("UNCHECKED_CAST") + method.invoke(klass, files) as? Set + } ?: emptySet() + + private fun withCompilerClassloader( + environment: JpsCompilerEnvironment, + fn: (ClassLoader) -> T + ): T? { + val libPath = getLibPath(environment.kotlinPaths, environment.messageCollector) ?: return null + val kotlinPaths = KotlinPathsFromBaseDirectory(libPath) + val paths = kotlinPaths.classPath(KotlinPaths.ClassPaths.CompilerWithScripting).toMutableList() + jdkToolsJar?.let { paths.add(it) } + + val classLoader = getOrCreateClassLoader(environment, paths) + return fn(classLoader) + } +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment.kt new file mode 100644 index 00000000000..42ec2da3431 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.compilerRunner + +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.preloading.ClassCondition +import org.jetbrains.kotlin.utils.KotlinPaths + +class JpsCompilerEnvironment( + val kotlinPaths: KotlinPaths, + services: Services, + val classesToLoadByParent: ClassCondition, + messageCollector: MessageCollector, + outputItemsCollector: OutputItemsCollectorImpl, + val progressReporter: ProgressReporter +) : CompilerEnvironment(services, messageCollector, outputItemsCollector) { + override val outputItemsCollector: OutputItemsCollectorImpl + get() = super.outputItemsCollector as OutputItemsCollectorImpl +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt new file mode 100644 index 00000000000..93165ff6411 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.compilerRunner + +import org.jetbrains.kotlin.daemon.client.CompilerCallbackServicesFacadeServer +import org.jetbrains.kotlin.daemon.client.reportFromDaemon +import org.jetbrains.kotlin.daemon.common.JpsCompilerServicesFacade +import org.jetbrains.kotlin.daemon.common.SOCKET_ANY_FREE_PORT +import org.jetbrains.kotlin.incremental.components.ExpectActualTracker +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer +import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents +import org.jetbrains.kotlin.progress.CompilationCanceledStatus +import java.io.Serializable + +internal class JpsCompilerServicesFacadeImpl( + private val env: JpsCompilerEnvironment, + port: Int = SOCKET_ANY_FREE_PORT +) : CompilerCallbackServicesFacadeServer( + env.services[IncrementalCompilationComponents::class.java], + env.services[LookupTracker::class.java], + env.services[CompilationCanceledStatus::class.java], + env.services[ExpectActualTracker::class.java], + env.services[IncrementalResultsConsumer::class.java], + env.services[IncrementalDataProvider::class.java], + port +), JpsCompilerServicesFacade { + + override fun report(category: Int, severity: Int, message: String?, attachment: Serializable?) { + env.messageCollector.reportFromDaemon( + { outFile, srcFiles -> env.outputItemsCollector.add(srcFiles, outFile) }, + category, severity, message, attachment + ) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt new file mode 100644 index 00000000000..0668e492e67 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt @@ -0,0 +1,375 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.compilerRunner + +import com.intellij.util.xmlb.XmlSerializerUtil +import org.jetbrains.annotations.TestOnly +import org.jetbrains.jps.api.GlobalOptions +import org.jetbrains.kotlin.cli.common.CompilerSystemProperties +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.* +import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil +import org.jetbrains.kotlin.config.CompilerSettings +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.config.additionalArgumentsAsList +import org.jetbrains.kotlin.daemon.client.CompileServiceSession +import org.jetbrains.kotlin.daemon.client.KotlinCompilerClient +import org.jetbrains.kotlin.daemon.common.* +import org.jetbrains.kotlin.jps.build.KotlinBuilder +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.PrintStream + +class JpsKotlinCompilerRunner { + private val log: KotlinLogger = JpsKotlinLogger(KotlinBuilder.LOG) + + private var compilerSettings: CompilerSettings? = null + + private inline fun withCompilerSettings(settings: CompilerSettings, fn: () -> Unit) { + val old = compilerSettings + try { + compilerSettings = settings + fn() + } finally { + compilerSettings = old + } + } + + companion object { + @Volatile + private var _jpsCompileServiceSession: CompileServiceSession? = null + + @TestOnly + fun shutdownDaemon() { + _jpsCompileServiceSession?.let { + try { + it.compileService.shutdown() + } catch (_: Throwable) { + } + } + _jpsCompileServiceSession = null + } + + fun releaseCompileServiceSession() { + _jpsCompileServiceSession?.let { + try { + it.compileService.releaseCompileSession(it.sessionId) + } catch (_: Throwable) { + } + } + _jpsCompileServiceSession = null + } + + @Synchronized + private fun getOrCreateDaemonConnection(newConnection: () -> CompileServiceSession?): CompileServiceSession? { + // TODO: consider adding state "ping" to the daemon interface + if (_jpsCompileServiceSession == null || _jpsCompileServiceSession!!.compileService.getDaemonOptions() !is CompileService.CallResult.Good) { + releaseCompileServiceSession() + _jpsCompileServiceSession = newConnection() + } + + return _jpsCompileServiceSession + } + + const val FAIL_ON_FALLBACK_PROPERTY = "test.kotlin.jps.compiler.runner.fail.on.fallback" + } + + fun classesFqNamesByFiles( + environment: JpsCompilerEnvironment, + files: Set + ): Set = withDaemonOrFallback( + withDaemon = { + doWithDaemon(environment) { sessionId, daemon -> + daemon.classesFqNamesByFiles( + sessionId, + files.toSet() // convert to standard HashSet to avoid serialization issues + ) + } + }, + fallback = { + CompilerRunnerUtil.invokeClassesFqNames(environment, files) + } + ) + + fun runK2MetadataCompiler( + commonArguments: CommonCompilerArguments, + k2MetadataArguments: K2MetadataCompilerArguments, + compilerSettings: CompilerSettings, + environment: JpsCompilerEnvironment, + destination: String, + classpath: Collection, + sourceFiles: Collection + ) { + val arguments = mergeBeans(commonArguments, XmlSerializerUtil.createCopy(k2MetadataArguments)) + + val classpathSet = arguments.classpath?.split(File.pathSeparator)?.toMutableSet() ?: mutableSetOf() + classpathSet.addAll(classpath) + arguments.classpath = classpath.joinToString(File.pathSeparator) + arguments.freeArgs = sourceFiles.map { it.absolutePath } + arguments.destination = arguments.destination ?: destination + + withCompilerSettings(compilerSettings) { + runCompiler(KotlinCompilerClass.METADATA, arguments, environment) + } + } + + fun runK2JvmCompiler( + commonArguments: CommonCompilerArguments, + k2jvmArguments: K2JVMCompilerArguments, + compilerSettings: CompilerSettings, + environment: JpsCompilerEnvironment, + moduleFile: File + ) { + val arguments = mergeBeans(commonArguments, XmlSerializerUtil.createCopy(k2jvmArguments)) + setupK2JvmArguments(moduleFile, arguments) + withCompilerSettings(compilerSettings) { + runCompiler(KotlinCompilerClass.JVM, arguments, environment) + } + } + + fun runK2JsCompiler( + commonArguments: CommonCompilerArguments, + k2jsArguments: K2JSCompilerArguments, + compilerSettings: CompilerSettings, + environment: JpsCompilerEnvironment, + allSourceFiles: Collection, + commonSources: Collection, + sourceMapRoots: Collection, + libraries: List, + friendModules: List, + outputFile: File + ) { + log.debug("K2JS: common arguments: " + ArgumentUtils.convertArgumentsToStringList(commonArguments)) + log.debug("K2JS: JS arguments: " + ArgumentUtils.convertArgumentsToStringList(k2jsArguments)) + + val arguments = mergeBeans(commonArguments, XmlSerializerUtil.createCopy(k2jsArguments)) + log.debug("K2JS: merged arguments: " + ArgumentUtils.convertArgumentsToStringList(arguments)) + + setupK2JsArguments(outputFile, allSourceFiles, commonSources, libraries, friendModules, arguments) + if (arguments.sourceMap) { + arguments.sourceMapBaseDirs = sourceMapRoots.joinToString(File.pathSeparator) { it.path } + } + + log.debug("K2JS: arguments after setup" + ArgumentUtils.convertArgumentsToStringList(arguments)) + + withCompilerSettings(compilerSettings) { + runCompiler(KotlinCompilerClass.JS, arguments, environment) + } + } + + private fun compileWithDaemonOrFallback( + compilerClassName: String, + compilerArgs: CommonCompilerArguments, + environment: JpsCompilerEnvironment + ) { + log.debug("Using kotlin-home = " + environment.kotlinPaths.homePath) + + withDaemonOrFallback( + withDaemon = { compileWithDaemon(compilerClassName, compilerArgs, environment) }, + fallback = { fallbackCompileStrategy(compilerArgs, compilerClassName, environment) } + ) + } + + private fun runCompiler(compilerClassName: String, compilerArgs: CommonCompilerArguments, environment: JpsCompilerEnvironment) { + try { + compileWithDaemonOrFallback(compilerClassName, compilerArgs, environment) + } catch (e: Throwable) { + MessageCollectorUtil.reportException(environment.messageCollector, e) + reportInternalCompilerError(environment.messageCollector) + } + } + + private fun compileWithDaemon( + compilerClassName: String, + compilerArgs: CommonCompilerArguments, + environment: JpsCompilerEnvironment + ): Int? { + val targetPlatform = when (compilerClassName) { + KotlinCompilerClass.JVM -> CompileService.TargetPlatform.JVM + KotlinCompilerClass.JS -> CompileService.TargetPlatform.JS + KotlinCompilerClass.METADATA -> CompileService.TargetPlatform.METADATA + else -> throw IllegalArgumentException("Unknown compiler type $compilerClassName") + } + val compilerMode = CompilerMode.JPS_COMPILER + val verbose = compilerArgs.verbose + val options = CompilationOptions( + compilerMode, + targetPlatform, + reportCategories(verbose), + reportSeverity(verbose), + requestedCompilationResults = emptyArray() + ) + return doWithDaemon(environment) { sessionId, daemon -> + environment.withProgressReporter { progress -> + progress.compilationStarted() + daemon.compile( + sessionId, + withAdditionalCompilerArgs(compilerArgs), + options, + JpsCompilerServicesFacadeImpl(environment), + null + ) + } + } + } + + private fun withDaemonOrFallback(withDaemon: () -> T?, fallback: () -> T): T = + if (isDaemonEnabled()) { + withDaemon() ?: fallback() + } else { + fallback() + } + + private fun doWithDaemon( + environment: JpsCompilerEnvironment, + fn: (sessionId: Int, daemon: CompileService) -> CompileService.CallResult + ): T? { + log.debug("Try to connect to daemon") + val connection = getDaemonConnection(environment) + if (connection == null) { + log.info("Could not connect to daemon") + return null + } + + val (daemon, sessionId) = connection + val res = fn(sessionId, daemon) + // TODO: consider implementing connection retry, instead of fallback here + return res.takeUnless { it is CompileService.CallResult.Dying }?.get() + } + + private fun withAdditionalCompilerArgs(compilerArgs: CommonCompilerArguments): Array { + val allArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs) + + (compilerSettings?.additionalArgumentsAsList ?: emptyList()) + return allArgs.toTypedArray() + } + + private fun reportCategories(verbose: Boolean): Array { + val categories = + if (!verbose) { + arrayOf(ReportCategory.COMPILER_MESSAGE, ReportCategory.EXCEPTION) + } else { + ReportCategory.values() + } + + return categories.map { it.code }.toTypedArray() + } + + + private fun reportSeverity(verbose: Boolean): Int = + if (!verbose) { + ReportSeverity.INFO.code + } else { + ReportSeverity.DEBUG.code + } + + private fun fallbackCompileStrategy( + compilerArgs: CommonCompilerArguments, + compilerClassName: String, + environment: JpsCompilerEnvironment + ) { + if ("true" == System.getProperty("kotlin.jps.tests") && "true" == System.getProperty(FAIL_ON_FALLBACK_PROPERTY)) { + error("Cannot compile with Daemon, see logs bellow. Fallback strategy is disabled in tests") + } + + // otherwise fallback to in-process + log.info("Compile in-process") + + val stream = ByteArrayOutputStream() + val out = PrintStream(stream) + + // the property should be set at least for parallel builds to avoid parallel building problems (racing between destroying and using environment) + // unfortunately it cannot be currently set by default globally, because it breaks many tests + // since there is no reliable way so far to detect running under tests, switching it on only for parallel builds + if (System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false").toBoolean()) + CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value = "true" + + val rc = environment.withProgressReporter { progress -> + progress.compilationStarted() + CompilerRunnerUtil.invokeExecMethod(compilerClassName, withAdditionalCompilerArgs(compilerArgs), environment, out) + } + + // exec() returns an ExitCode object, class of which is loaded with a different class loader, + // so we take it's contents through reflection + val exitCode = ExitCode.valueOf(getReturnCodeFromObject(rc)) + processCompilerOutput(environment.messageCollector, environment.outputItemsCollector, stream, exitCode) + } + + private fun setupK2JvmArguments(moduleFile: File, settings: K2JVMCompilerArguments) { + with(settings) { + buildFile = moduleFile.absolutePath + destination = null + noStdlib = true + noReflect = true + noJdk = true + } + } + + private fun setupK2JsArguments( + _outputFile: File, + allSourceFiles: Collection, + _commonSources: Collection, + _libraries: List, + _friendModules: List, + settings: K2JSCompilerArguments + ) { + with(settings) { + noStdlib = true + freeArgs = allSourceFiles.map { it.path }.toMutableList() + commonSources = _commonSources.map { it.path }.toTypedArray() + outputFile = _outputFile.path + metaInfo = true + libraries = _libraries.joinToString(File.pathSeparator) + friendModules = _friendModules.joinToString(File.pathSeparator) + } + } + + private fun getReturnCodeFromObject(rc: Any?): String = when { + rc == null -> ExitCode.INTERNAL_ERROR.toString() + ExitCode::class.java.name == rc::class.java.name -> rc.toString() + else -> throw IllegalStateException("Unexpected return: " + rc) + } + + private fun getDaemonConnection(environment: JpsCompilerEnvironment): CompileServiceSession? = + getOrCreateDaemonConnection { + environment.progressReporter.progress("connecting to daemon") + val libPath = CompilerRunnerUtil.getLibPath(environment.kotlinPaths, environment.messageCollector) + val compilerPath = File(libPath, "kotlin-compiler.jar") + val daemonJarPath = File(libPath, "kotlin-daemon.jar") + val toolsJarPath = CompilerRunnerUtil.jdkToolsJar + val compilerId = CompilerId.makeCompilerId(listOfNotNull(compilerPath, toolsJarPath, daemonJarPath)) + val daemonOptions = configureDaemonOptions() + val additionalJvmParams = mutableListOf() + + IncrementalCompilation.toJvmArgs(additionalJvmParams) + + val clientFlagFile = KotlinCompilerClient.getOrCreateClientFlagFile(daemonOptions) + val sessionFlagFile = makeAutodeletingFlagFile("compiler-jps-session-", File(daemonOptions.runFilesPathOrDefault)) + + environment.withProgressReporter { progress -> + progress.progress("connecting to daemon") + KotlinCompilerRunnerUtils.newDaemonConnection( + compilerId, + clientFlagFile, + sessionFlagFile, + environment.messageCollector, + log.isDebugEnabled, + daemonOptions, + additionalJvmParams.toTypedArray() + ) + } + } +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinLogger.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinLogger.kt new file mode 100644 index 00000000000..47aacea901f --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinLogger.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.compilerRunner + +import com.intellij.openapi.diagnostic.Logger + +internal class JpsKotlinLogger(private val log: Logger) : KotlinLogger { + override fun error(msg: String) { + log.error(msg) + } + + override fun warn(msg: String) { + log.warn(msg) + } + + override fun info(msg: String) { + log.info(msg) + } + + override fun debug(msg: String) { + log.debug(msg) + } + + override val isDebugEnabled: Boolean + get() = log.isDebugEnabled +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/ProgressReporter.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/ProgressReporter.kt new file mode 100644 index 00000000000..1c05dc5b9f8 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/ProgressReporter.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.compilerRunner + +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.ProgressMessage + +interface ProgressReporter { + fun progress(message: String) + fun compilationStarted() + fun clearProgress() +} + +class ProgressReporterImpl(private val context: CompileContext, private val chunk: ModuleChunk) : ProgressReporter { + override fun progress(message: String) { + context.processMessage(ProgressMessage("Kotlin: $message")) + } + + override fun compilationStarted() { + progress("compiling [${chunk.presentableShortName}]") + } + + override fun clearProgress() { + context.processMessage(ProgressMessage("")) + } + +} + +inline fun JpsCompilerEnvironment.withProgressReporter(fn: (ProgressReporter) -> T): T = + try { + fn(progressReporter) + } finally { + progressReporter.clearProgress() + } \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/FSOperationsHelper.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/FSOperationsHelper.kt new file mode 100644 index 00000000000..d38aebdc087 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/FSOperationsHelper.kt @@ -0,0 +1,168 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.diagnostic.Logger +import com.intellij.util.containers.ContainerUtil +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.builders.BuildRootDescriptor +import org.jetbrains.jps.builders.BuildTarget +import org.jetbrains.jps.builders.FileProcessor +import org.jetbrains.jps.builders.impl.DirtyFilesHolderBase +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor +import org.jetbrains.jps.builders.java.dependencyView.Mappings +import org.jetbrains.jps.incremental.BuildOperations +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.FSOperations +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.incremental.fs.CompilationRound +import java.io.File +import java.util.HashMap +import kotlin.collections.* + +/** + * Entry point for safely marking files as dirty. + */ +class FSOperationsHelper( + private val compileContext: CompileContext, + private val chunk: ModuleChunk, + private val dirtyFilesHolder: KotlinDirtySourceFilesHolder, + private val log: Logger +) { + private val moduleBasedFilter = ModulesBasedFileFilter(compileContext, chunk) + + internal var hasMarkedDirty = false + private set + + private val buildLogger = compileContext.testingContext?.buildLogger + + fun markChunk(recursively: Boolean, kotlinOnly: Boolean, excludeFiles: Set = setOf()) { + fun shouldMark(file: File): Boolean { + if (kotlinOnly && !file.isKotlinSourceFile) return false + + if (file in excludeFiles) return false + + hasMarkedDirty = true + return true + } + + if (recursively) { + FSOperations.markDirtyRecursively(compileContext, CompilationRound.NEXT, chunk, ::shouldMark) + } else { + FSOperations.markDirty(compileContext, CompilationRound.NEXT, chunk, ::shouldMark) + } + } + + internal fun markFilesForCurrentRound(files: Iterable) { + files.forEach { + val root = compileContext.projectDescriptor.buildRootIndex.findJavaRootDescriptor(compileContext, it) + if (root != null) dirtyFilesHolder.byTarget[root.target]?._markDirty(it, root) + } + + markFilesImpl(files, currentRound = true) { it.exists() && moduleBasedFilter.accept(it) } + } + + /** + * Marks given [files] as dirty for current round and given [target] of [chunk]. + */ + fun markFilesForCurrentRound(target: ModuleBuildTarget, files: Collection) { + require(target in chunk.targets) + + val targetDirtyFiles = dirtyFilesHolder.byTarget.getValue(target) + val dirtyFileToRoot = HashMap() + files.forEach { file -> + val root = compileContext.projectDescriptor.buildRootIndex + .findAllParentDescriptors(file, compileContext) + .single { sourceRoot -> sourceRoot.target == target } + + targetDirtyFiles._markDirty(file, root as JavaSourceRootDescriptor) + dirtyFileToRoot[file] = root + } + + markFilesImpl(files, currentRound = true) { it.exists() } + cleanOutputsForNewDirtyFilesInCurrentRound(target, dirtyFileToRoot) + } + + private fun cleanOutputsForNewDirtyFilesInCurrentRound(target: ModuleBuildTarget, dirtyFiles: Map) { + val dirtyFilesHolder = object : DirtyFilesHolderBase(compileContext) { + override fun processDirtyFiles(processor: FileProcessor) { + dirtyFiles.forEach { (file, root) -> processor.apply(target, file, root) } + } + + override fun hasDirtyFiles(): Boolean = dirtyFiles.isNotEmpty() + } + BuildOperations.cleanOutputsCorrespondingToChangedFiles(compileContext, dirtyFilesHolder) + } + + fun markFiles(files: Iterable) { + markFilesImpl(files, currentRound = false) { it.exists() } + } + + fun markInChunkOrDependents(files: Iterable, excludeFiles: Set) { + markFilesImpl(files, currentRound = false) { + it !in excludeFiles && it.exists() && moduleBasedFilter.accept(it) + } + } + + private inline fun markFilesImpl( + files: Iterable, + currentRound: Boolean, + shouldMark: (File) -> Boolean + ) { + val filesToMark = files.filterTo(HashSet(), shouldMark) + if (filesToMark.isEmpty()) return + + val compilationRound = if (currentRound) { + buildLogger?.markedAsDirtyBeforeRound(filesToMark) + CompilationRound.CURRENT + } else { + buildLogger?.markedAsDirtyAfterRound(filesToMark) + hasMarkedDirty = true + CompilationRound.NEXT + } + + for (fileToMark in filesToMark) { + FSOperations.markDirty(compileContext, compilationRound, fileToMark) + } + log.debug("Mark dirty: $filesToMark ($compilationRound)") + } + + // Based on `JavaBuilderUtil#ModulesBasedFileFilter` from Intellij + private class ModulesBasedFileFilter( + private val context: CompileContext, + chunk: ModuleChunk + ) : Mappings.DependentFilesFilter { + private val chunkTargets = chunk.targets + private val buildRootIndex = context.projectDescriptor.buildRootIndex + private val buildTargetIndex = context.projectDescriptor.buildTargetIndex + private val cache = HashMap, Set>>() + + override fun accept(file: File): Boolean { + val rd = buildRootIndex.findJavaRootDescriptor(context, file) ?: return true + val target = rd.target + if (target in chunkTargets) return true + + val targetOfFileWithDependencies = cache.getOrPut(target) { buildTargetIndex.getDependenciesRecursively(target, context) } + return ContainerUtil.intersects(targetOfFileWithDependencies, chunkTargets) + } + + override fun belongsToCurrentTargetChunk(file: File): Boolean { + val rd = buildRootIndex.findJavaRootDescriptor(context, file) + return rd != null && chunkTargets.contains(rd.target) + } + } +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/JpsFileToPathConverter.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/JpsFileToPathConverter.kt new file mode 100644 index 00000000000..4cdd0581928 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/JpsFileToPathConverter.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService +import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter + +internal class JpsFileToPathConverter( + jpsProject: JpsProject +) : RelativeFileToPathConverter(JpsModelSerializationDataService.getBaseDirectory(jpsProject)) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt new file mode 100644 index 00000000000..7266485c1ca --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -0,0 +1,772 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.diagnostic.Logger +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.builders.DirtyFilesHolder +import org.jetbrains.jps.builders.FileProcessor +import org.jetbrains.jps.builders.impl.DirtyFilesHolderBase +import org.jetbrains.jps.builders.java.JavaBuilderUtil +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor +import org.jetbrains.jps.builders.storage.BuildDataCorruptedException +import org.jetbrains.jps.incremental.* +import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.* +import org.jetbrains.jps.incremental.java.JavaBuilder +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.kotlin.build.GeneratedFile +import org.jetbrains.kotlin.build.GeneratedJvmClass +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.* +import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil +import org.jetbrains.kotlin.compilerRunner.* +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.config.KotlinModuleKind +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.daemon.common.isDaemonEnabled +import org.jetbrains.kotlin.incremental.* +import org.jetbrains.kotlin.incremental.components.ExpectActualTracker +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.build.report.ICReporterBase +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache +import org.jetbrains.kotlin.jps.incremental.JpsLookupStorageManager +import org.jetbrains.kotlin.jps.model.kotlinKind +import org.jetbrains.kotlin.jps.targets.KotlinJvmModuleBuildTarget +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.preloading.ClassCondition +import org.jetbrains.kotlin.utils.KotlinPaths +import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir +import org.jetbrains.kotlin.utils.PathUtil +import java.io.File +import java.util.* +import kotlin.collections.HashSet +import kotlin.system.measureTimeMillis + +class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { + companion object { + const val KOTLIN_BUILDER_NAME: String = "Kotlin Builder" + + val LOG = Logger.getInstance("#org.jetbrains.kotlin.jps.build.KotlinBuilder") + const val SKIP_CACHE_VERSION_CHECK_PROPERTY = "kotlin.jps.skip.cache.version.check" + const val JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home" + + val classesToLoadByParent: ClassCondition + get() = ClassCondition { className -> + className.startsWith("org.jetbrains.kotlin.load.kotlin.incremental.components.") + || className.startsWith("org.jetbrains.kotlin.incremental.components.") + || className.startsWith("org.jetbrains.kotlin.incremental.js") + || className == "org.jetbrains.kotlin.config.Services" + || className.startsWith("org.apache.log4j.") // For logging from compiler + || className == "org.jetbrains.kotlin.progress.CompilationCanceledStatus" + || className == "org.jetbrains.kotlin.progress.CompilationCanceledException" + || className == "org.jetbrains.kotlin.modules.TargetId" + || className == "org.jetbrains.kotlin.cli.common.ExitCode" + } + } + + private val statisticsLogger = TeamcityStatisticsLogger() + + override fun getPresentableName() = KOTLIN_BUILDER_NAME + + override fun getCompilableFileExtensions() = arrayListOf("kt", "kts") + + override fun buildStarted(context: CompileContext) { + logSettings(context) + } + + private fun logSettings(context: CompileContext) { + LOG.debug("==========================================") + LOG.info("is Kotlin incremental compilation enabled for JVM: ${IncrementalCompilation.isEnabledForJvm()}") + LOG.info("is Kotlin incremental compilation enabled for JS: ${IncrementalCompilation.isEnabledForJs()}") + LOG.info("is Kotlin compiler daemon enabled: ${isDaemonEnabled()}") + + val historyLabel = context.getBuilderParameter("history label") + if (historyLabel != null) { + LOG.info("Label in local history: $historyLabel") + } + } + + /** + * Ensure Kotlin Context initialized. + * Kotlin Context should be initialized only when required (before first kotlin chunk build). + */ + private fun ensureKotlinContextInitialized(context: CompileContext): KotlinCompileContext { + val kotlinCompileContext = context.getUserData(kotlinCompileContextKey) + if (kotlinCompileContext != null) return kotlinCompileContext + + // don't synchronize on context, since it is chunk local only + synchronized(kotlinCompileContextKey) { + val actualKotlinCompileContext = context.getUserData(kotlinCompileContextKey) + if (actualKotlinCompileContext != null) return actualKotlinCompileContext + + try { + return initializeKotlinContext(context) + } catch (t: Throwable) { + jpsReportInternalBuilderError(context, Error("Cannot initialize Kotlin context: ${t.message}", t)) + throw t + } + } + } + + private fun initializeKotlinContext(context: CompileContext): KotlinCompileContext { + val kotlinContext: KotlinCompileContext + + val time = measureTimeMillis { + kotlinContext = KotlinCompileContext(context) + + context.putUserData(kotlinCompileContextKey, kotlinContext) + context.testingContext?.kotlinCompileContext = kotlinContext + + if (kotlinContext.shouldCheckCacheVersions && kotlinContext.hasKotlin()) { + kotlinContext.checkCacheVersions() + } + + kotlinContext.cleanupCaches() + kotlinContext.reportUnsupportedTargets() + } + + LOG.info("Total Kotlin global compile context initialization time: $time ms") + + return kotlinContext + } + + override fun buildFinished(context: CompileContext) { + ensureKotlinContextDisposed(context) + } + + private fun ensureKotlinContextDisposed(context: CompileContext) { + if (context.getUserData(kotlinCompileContextKey) != null) { + // don't synchronize on context, since it chunk local only + synchronized(kotlinCompileContextKey) { + val kotlinCompileContext = context.getUserData(kotlinCompileContextKey) + if (kotlinCompileContext != null) { + kotlinCompileContext.dispose() + context.putUserData(kotlinCompileContextKey, null) + + statisticsLogger.reportTotal() + } + } + } + } + + override fun chunkBuildStarted(context: CompileContext, chunk: ModuleChunk) { + super.chunkBuildStarted(context, chunk) + + if (chunk.isDummy(context)) return + + val kotlinContext = ensureKotlinContextInitialized(context) + + val buildLogger = context.testingContext?.buildLogger + buildLogger?.chunkBuildStarted(context, chunk) + + if (JavaBuilderUtil.isForcedRecompilationAllJavaModules(context)) return + + val targets = chunk.targets + if (targets.none { kotlinContext.hasKotlinMarker[it] == true }) return + + val kotlinChunk = kotlinContext.getChunk(chunk) ?: return + kotlinContext.checkChunkCacheVersion(kotlinChunk) + + if (!kotlinContext.rebuildingAllKotlin && kotlinChunk.isEnabled) { + markAdditionalFilesForInitialRound(kotlinChunk, chunk, kotlinContext) + } + + buildLogger?.afterChunkBuildStarted(context, chunk) + } + + /** + * Invalidate usages of removed classes. + * See KT-13677 for more details. + * + * todo(1.2.80): move to KotlinChunk + * todo(1.2.80): got rid of jpsGlobalContext usages (replace with KotlinCompileContext) + */ + private fun markAdditionalFilesForInitialRound( + kotlinChunk: KotlinChunk, + chunk: ModuleChunk, + kotlinContext: KotlinCompileContext + ) { + val context = kotlinContext.jpsContext + val dirtyFilesHolder = KotlinDirtySourceFilesHolder( + chunk, + context, + object : DirtyFilesHolderBase(context) { + override fun processDirtyFiles(processor: FileProcessor) { + FSOperations.processFilesToRecompile(context, chunk, processor) + } + } + ) + val fsOperations = FSOperationsHelper(context, chunk, dirtyFilesHolder, LOG) + + val representativeTarget = kotlinContext.targetsBinding[chunk.representativeTarget()] ?: return + + // dependent caches are not required, since we are not going to update caches + val incrementalCaches = kotlinChunk.loadCaches(loadDependent = false) + + val messageCollector = MessageCollectorAdapter(context, representativeTarget) + val environment = createCompileEnvironment( + kotlinContext.jpsContext, + representativeTarget, + incrementalCaches, + LookupTracker.DO_NOTHING, + ExpectActualTracker.DoNothing, + chunk, + messageCollector + ) ?: return + + val removedClasses = HashSet() + for (target in kotlinChunk.targets) { + val cache = incrementalCaches[target] ?: continue + val dirtyFiles = dirtyFilesHolder.getDirtyFiles(target.jpsModuleBuildTarget).keys + val removedFiles = dirtyFilesHolder.getRemovedFiles(target.jpsModuleBuildTarget) + + val existingClasses = JpsKotlinCompilerRunner().classesFqNamesByFiles(environment, dirtyFiles) + val previousClasses = cache.classesFqNamesBySources(dirtyFiles + removedFiles) + for (jvmClassName in previousClasses) { + val fqName = jvmClassName.asString() + if (fqName !in existingClasses) { + removedClasses.add(fqName) + } + } + } + + val changesCollector = ChangesCollector() + removedClasses.forEach { changesCollector.collectSignature(FqName(it), areSubclassesAffected = true) } + val affectedByRemovedClasses = changesCollector.getDirtyFiles(incrementalCaches.values, kotlinContext.lookupStorageManager) + + fsOperations.markFilesForCurrentRound(affectedByRemovedClasses.dirtyFiles + affectedByRemovedClasses.forceRecompileTogether) + } + + override fun chunkBuildFinished(context: CompileContext, chunk: ModuleChunk) { + super.chunkBuildFinished(context, chunk) + + if (chunk.isDummy(context)) return + + // Temporary workaround for KT-33808 + val kotlinContext = ensureKotlinContextInitialized(context) + for (target in chunk.targets) { + if (kotlinContext.hasKotlinMarker[target] != true) continue + + val outputRoots = target.getOutputRoots(context) + if (outputRoots.size > 1) { + outputRoots.forEach { it.mkdirs() } + } + } + + LOG.debug("------------------------------------------") + } + + override fun build( + context: CompileContext, + chunk: ModuleChunk, + dirtyFilesHolder: DirtyFilesHolder, + outputConsumer: ModuleLevelBuilder.OutputConsumer + ): ModuleLevelBuilder.ExitCode { + if (chunk.isDummy(context)) + return NOTHING_DONE + + val kotlinTarget = context.kotlinBuildTargets[chunk.representativeTarget()] ?: return OK + val messageCollector = MessageCollectorAdapter(context, kotlinTarget) + + // New mpp project model: modules which is imported from sources sets of the compilations shouldn't be compiled for now. + // It should be compiled only as one of source root of target compilation, which is added in [KotlinSourceRootProvider]. + if (chunk.modules.any { it.kotlinKind == KotlinModuleKind.SOURCE_SET_HOLDER }) { + if (chunk.modules.size > 1) { + messageCollector.report( + CompilerMessageSeverity.ERROR, + "Cyclically dependent modules are not supported in multiplatform projects" + ) + return ABORT + } + + return NOTHING_DONE + } + + val kotlinDirtyFilesHolder = KotlinDirtySourceFilesHolder(chunk, context, dirtyFilesHolder) + val fsOperations = FSOperationsHelper(context, chunk, kotlinDirtyFilesHolder, LOG) + + try { + val proposedExitCode = + doBuild(chunk, kotlinTarget, context, kotlinDirtyFilesHolder, messageCollector, outputConsumer, fsOperations) + + val actualExitCode = if (proposedExitCode == OK && fsOperations.hasMarkedDirty) ADDITIONAL_PASS_REQUIRED else proposedExitCode + + LOG.debug("Build result: $actualExitCode") + + context.testingContext?.buildLogger?.buildFinished(actualExitCode) + + return actualExitCode + } catch (e: StopBuildException) { + LOG.info("Caught exception: $e") + throw e + } catch (e: BuildDataCorruptedException) { + LOG.info("Caught exception: $e") + throw e + } catch (e: Throwable) { + LOG.info("Caught exception: $e") + MessageCollectorUtil.reportException(messageCollector, e) + return ABORT + } + } + + private fun doBuild( + chunk: ModuleChunk, + representativeTarget: KotlinModuleBuildTarget<*>, + context: CompileContext, + kotlinDirtyFilesHolder: KotlinDirtySourceFilesHolder, + messageCollector: MessageCollectorAdapter, + outputConsumer: OutputConsumer, + fsOperations: FSOperationsHelper + ): ModuleLevelBuilder.ExitCode { + // Workaround for Android Studio + if (representativeTarget is KotlinJvmModuleBuildTarget && !JavaBuilder.IS_ENABLED[context, true]) { + messageCollector.report(INFO, "Kotlin JPS plugin is disabled") + return NOTHING_DONE + } + + val kotlinContext = context.kotlin + val kotlinChunk = chunk.toKotlinChunk(context)!! + + if (!kotlinChunk.haveSameCompiler) { + messageCollector.report( + ERROR, + "Cyclically dependent modules ${kotlinChunk.presentableModulesToCompilersList} should have same compiler." + ) + return ABORT + } + + if (!kotlinChunk.isEnabled) { + return NOTHING_DONE + } + + val projectDescriptor = context.projectDescriptor + val dataManager = projectDescriptor.dataManager + val targets = chunk.targets + + val isChunkRebuilding = JavaBuilderUtil.isForcedRecompilationAllJavaModules(context) + || targets.any { kotlinContext.rebuildAfterCacheVersionChanged[it] == true } + + if (!kotlinDirtyFilesHolder.hasDirtyOrRemovedFiles) { + if (isChunkRebuilding) { + targets.forEach { + kotlinContext.hasKotlinMarker[it] = false + } + } + + targets.forEach { kotlinContext.rebuildAfterCacheVersionChanged.clean(it) } + return NOTHING_DONE + } + + // Request CHUNK_REBUILD when IC is off and there are dirty Kotlin files + // Otherwise unexpected compile error might happen, when there are Groovy files, + // but they are not dirty, so Groovy builder does not generate source stubs, + // and Kotlin builder is filtering out output directory from classpath + // (because it may contain outdated Java classes). + if (!isChunkRebuilding && !representativeTarget.isIncrementalCompilationEnabled) { + targets.forEach { kotlinContext.rebuildAfterCacheVersionChanged[it] = true } + return CHUNK_REBUILD_REQUIRED + } + + val targetsWithoutOutputDir = targets.filter { it.outputDir == null } + if (targetsWithoutOutputDir.isNotEmpty()) { + messageCollector.report(ERROR, "Output directory not specified for " + targetsWithoutOutputDir.joinToString()) + return ABORT + } + + val project = projectDescriptor.project + val lookupTracker = getLookupTracker(project, representativeTarget) + val exceptActualTracer = ExpectActualTrackerImpl() + val incrementalCaches = kotlinChunk.loadCaches() + val environment = createCompileEnvironment( + context, + representativeTarget, + incrementalCaches, + lookupTracker, + exceptActualTracer, + chunk, + messageCollector + ) ?: return ABORT + + context.testingContext?.buildLogger?.compilingFiles( + kotlinDirtyFilesHolder.allDirtyFiles, + kotlinDirtyFilesHolder.allRemovedFilesFiles + ) + + if (LOG.isDebugEnabled) { + LOG.debug("Compiling files: ${kotlinDirtyFilesHolder.allDirtyFiles}") + } + + val start = System.nanoTime() + val outputItemCollector = doCompileModuleChunk( + kotlinChunk, + representativeTarget, + kotlinChunk.compilerArguments, + context, + kotlinDirtyFilesHolder, + fsOperations, + environment, + incrementalCaches + ) + + statisticsLogger.registerStatistic(chunk, System.nanoTime() - start) + + if (outputItemCollector == null) { + return NOTHING_DONE + } + + val compilationErrors = Utils.ERRORS_DETECTED_KEY[context, false] + if (compilationErrors) { + LOG.info("Compiled with errors") + return ABORT + } else { + LOG.info("Compiled successfully") + } + + val generatedFiles = getGeneratedFiles(context, chunk, environment.outputItemsCollector) + + markDirtyComplementaryMultifileClasses(generatedFiles, kotlinContext, incrementalCaches, fsOperations) + + val kotlinTargets = kotlinContext.targetsBinding + for ((target, outputItems) in generatedFiles) { + val kotlinTarget = kotlinTargets[target] ?: error("Could not find Kotlin target for JPS target $target") + kotlinTarget.registerOutputItems(outputConsumer, outputItems) + } + kotlinChunk.saveVersions() + + if (targets.any { kotlinContext.hasKotlinMarker[it] == null }) { + fsOperations.markChunk(recursively = false, kotlinOnly = true, excludeFiles = kotlinDirtyFilesHolder.allDirtyFiles) + } + + for (target in targets) { + kotlinContext.hasKotlinMarker[target] = true + kotlinContext.rebuildAfterCacheVersionChanged.clean(target) + } + + kotlinChunk.targets.forEach { + it.doAfterBuild() + } + + representativeTarget.updateChunkMappings( + context, + chunk, + kotlinDirtyFilesHolder, + generatedFiles, + incrementalCaches + ) + + if (!representativeTarget.isIncrementalCompilationEnabled) { + return OK + } + + context.checkCanceled() + + environment.withProgressReporter { progress -> + progress.progress("performing incremental compilation analysis") + + val changesCollector = ChangesCollector() + + for ((target, files) in generatedFiles) { + val kotlinModuleBuilderTarget = kotlinContext.targetsBinding[target]!! + kotlinModuleBuilderTarget.updateCaches( + kotlinDirtyFilesHolder, + incrementalCaches[kotlinModuleBuilderTarget]!!, + files, + changesCollector, + environment + ) + } + + updateLookupStorage(lookupTracker, kotlinContext.lookupStorageManager, kotlinDirtyFilesHolder) + + if (!isChunkRebuilding) { + changesCollector.processChangesUsingLookups( + kotlinDirtyFilesHolder.allDirtyFiles, + kotlinContext.lookupStorageManager, + fsOperations, + incrementalCaches.values + ) + } + } + + return OK + } + + // todo(1.2.80): got rid of ModuleChunk (replace with KotlinChunk) + // todo(1.2.80): introduce KotlinRoundCompileContext, move dirtyFilesHolder, fsOperations, environment to it + private fun doCompileModuleChunk( + kotlinChunk: KotlinChunk, + representativeTarget: KotlinModuleBuildTarget<*>, + commonArguments: CommonCompilerArguments, + context: CompileContext, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + fsOperations: FSOperationsHelper, + environment: JpsCompilerEnvironment, + incrementalCaches: Map, JpsIncrementalCache> + ): OutputItemsCollector? { + loadPlugins(representativeTarget, commonArguments, context) + + kotlinChunk.targets.forEach { + it.nextRound(context) + } + + if (representativeTarget.isIncrementalCompilationEnabled) { + for (target in kotlinChunk.targets) { + val cache = incrementalCaches[target] + val jpsTarget = target.jpsModuleBuildTarget + + val targetDirtyFiles = dirtyFilesHolder.byTarget[jpsTarget] + if (cache != null && targetDirtyFiles != null) { + val dirtyFiles = targetDirtyFiles.dirty.keys + targetDirtyFiles.removed + val complementaryFiles = cache.getComplementaryFilesRecursive(dirtyFiles) + + // Get all parts of @JvmMultifileClass file for simultaneous rebuild + var dirtyMultifileClassFiles: Collection = emptyList() + if (cache is IncrementalJvmCache) { + dirtyMultifileClassFiles = cache.classesBySources(dirtyFiles) + .filter { cache.isMultifileFacade(it) } + .flatMap { cache.getAllPartsOfMultifileFacade(it).orEmpty() } + .flatMap { cache.sourcesByInternalName(it) } + .distinct() + .filter { !dirtyFiles.contains(it) } + } + fsOperations.markFilesForCurrentRound(jpsTarget, complementaryFiles + dirtyMultifileClassFiles) + + cache.markDirty(targetDirtyFiles.dirty.keys + targetDirtyFiles.removed) + } + } + } + + val isDoneSomething = representativeTarget.compileModuleChunk(commonArguments, dirtyFilesHolder, environment) + + return if (isDoneSomething) environment.outputItemsCollector else null + } + + private fun loadPlugins( + representativeTarget: KotlinModuleBuildTarget<*>, + commonArguments: CommonCompilerArguments, + context: CompileContext + ) { + fun concatenate(strings: Array?, cp: List) = arrayOf(*strings.orEmpty(), *cp.toTypedArray()) + + for (argumentProvider in ServiceLoader.load(KotlinJpsCompilerArgumentsProvider::class.java)) { + val jpsModuleBuildTarget = representativeTarget.jpsModuleBuildTarget + // appending to pluginOptions + commonArguments.pluginOptions = concatenate( + commonArguments.pluginOptions, + argumentProvider.getExtraArguments(jpsModuleBuildTarget, context) + ) + // appending to classpath + commonArguments.pluginClasspaths = concatenate( + commonArguments.pluginClasspaths, + argumentProvider.getClasspath(jpsModuleBuildTarget, context) + ) + + LOG.debug("Plugin loaded: ${argumentProvider::class.java.simpleName}") + } + } + + private fun createCompileEnvironment( + context: CompileContext, + kotlinModuleBuilderTarget: KotlinModuleBuildTarget<*>, + incrementalCaches: Map, JpsIncrementalCache>, + lookupTracker: LookupTracker, + exceptActualTracer: ExpectActualTracker, + chunk: ModuleChunk, + messageCollector: MessageCollectorAdapter + ): JpsCompilerEnvironment? { + val compilerServices = with(Services.Builder()) { + kotlinModuleBuilderTarget.makeServices(this, incrementalCaches, lookupTracker, exceptActualTracer) + build() + } + + val paths = computeKotlinPathsForJpsPlugin() + if (paths == null || !paths.homePath.exists()) { + messageCollector.report( + ERROR, "Cannot find kotlinc home. Make sure the plugin is properly installed, " + + "or specify $JPS_KOTLIN_HOME_PROPERTY system property" + ) + return null + } + + return JpsCompilerEnvironment( + paths, + compilerServices, + classesToLoadByParent, + messageCollector, + OutputItemsCollectorImpl(), + ProgressReporterImpl(context, chunk) + ) + } + + // When JPS is run on TeamCity, it can not rely on Kotlin plugin layout, + // so the path to Kotlin is specified in a system property + private fun computeKotlinPathsForJpsPlugin(): KotlinPaths? { + if (System.getProperty("kotlin.jps.tests").equals("true", ignoreCase = true)) { + return PathUtil.kotlinPathsForDistDirectory + } + + val jpsKotlinHome = System.getProperty(JPS_KOTLIN_HOME_PROPERTY) + if (jpsKotlinHome != null) { + return KotlinPathsFromHomeDir(File(jpsKotlinHome)) + } + + val jar = PathUtil.pathUtilJar.takeIf(File::exists) + if (jar?.name == "kotlin-jps-plugin.jar") { + val pluginHome = jar.parentFile.parentFile.parentFile + return KotlinPathsFromHomeDir(File(pluginHome, PathUtil.HOME_FOLDER_NAME)) + } + + return null + } + + private fun getGeneratedFiles( + context: CompileContext, + chunk: ModuleChunk, + outputItemCollector: OutputItemsCollectorImpl + ): Map> { + // If there's only one target, this map is empty: get() always returns null, and the representativeTarget will be used below + val sourceToTarget = HashMap() + if (chunk.targets.size > 1) { + for (target in chunk.targets) { + context.kotlinBuildTargets[target]?.sourceFiles?.forEach { + sourceToTarget[it] = target + } + } + } + + val representativeTarget = chunk.representativeTarget() + fun SimpleOutputItem.target() = + sourceFiles.firstOrNull()?.let { sourceToTarget[it] } + ?: chunk.targets.singleOrNull { target -> + target.outputDir?.let { outputDir -> + outputFile.startsWith(outputDir) + } ?: false + } + ?: representativeTarget + + return outputItemCollector.outputs + .sortedBy { it.outputFile } + .groupBy(SimpleOutputItem::target, SimpleOutputItem::toGeneratedFile) + } + + private fun updateLookupStorage( + lookupTracker: LookupTracker, + lookupStorageManager: JpsLookupStorageManager, + dirtyFilesHolder: KotlinDirtySourceFilesHolder + ) { + if (lookupTracker !is LookupTrackerImpl) + throw AssertionError("Lookup tracker is expected to be LookupTrackerImpl, got ${lookupTracker::class.java}") + + lookupStorageManager.withLookupStorage { lookupStorage -> + lookupStorage.removeLookupsFrom(dirtyFilesHolder.allDirtyFiles.asSequence() + dirtyFilesHolder.allRemovedFilesFiles.asSequence()) + lookupStorage.addAll(lookupTracker.lookups, lookupTracker.pathInterner.values) + } + } + + private fun markDirtyComplementaryMultifileClasses( + generatedFiles: Map>, + kotlinContext: KotlinCompileContext, + incrementalCaches: Map, JpsIncrementalCache>, + fsOperations: FSOperationsHelper + ) { + for ((target, files) in generatedFiles) { + val kotlinModuleBuilderTarget = kotlinContext.targetsBinding[target] ?: continue + val cache = incrementalCaches[kotlinModuleBuilderTarget] as? IncrementalJvmCache ?: continue + val generated = files.filterIsInstance() + val multifileClasses = generated.filter { it.outputClass.classHeader.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS } + val expectedAllParts = multifileClasses.flatMap { cache.getAllPartsOfMultifileFacade(it.outputClass.className).orEmpty() } + if (multifileClasses.isEmpty()) continue + val actualParts = generated.filter { it.outputClass.classHeader.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART } + .map { it.outputClass.className.toString() } + if (!actualParts.containsAll(expectedAllParts)) { + fsOperations.markFiles(expectedAllParts.flatMap { cache.sourcesByInternalName(it) } + + multifileClasses.flatMap { it.sourceFiles }) + } + } + } +} + +private class JpsICReporter : ICReporterBase() { + override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection, exitCode: ExitCode) { + } + + override fun report(message: () -> String) { + if (KotlinBuilder.LOG.isDebugEnabled) { + KotlinBuilder.LOG.debug(message()) + } + } + + override fun reportVerbose(message: () -> String) { + report(message) + } +} + +private fun ChangesCollector.processChangesUsingLookups( + compiledFiles: Set, + lookupStorageManager: JpsLookupStorageManager, + fsOperations: FSOperationsHelper, + caches: Iterable +) { + val allCaches = caches.flatMap { it.thisWithDependentCaches } + val reporter = JpsICReporter() + + reporter.reportVerbose { "Start processing changes" } + + val dirtyFiles = getDirtyFiles(allCaches, lookupStorageManager) + // if list of inheritors of sealed class has changed it should be recompiled with all the inheritors + // Here we have a small optimization. Do not recompile the bunch if ALL these files were recompiled during the previous round. + val excludeFiles = if (compiledFiles.containsAll(dirtyFiles.forceRecompileTogether)) + compiledFiles + else + compiledFiles.minus(dirtyFiles.forceRecompileTogether) + fsOperations.markInChunkOrDependents( + (dirtyFiles.dirtyFiles + dirtyFiles.forceRecompileTogether).asIterable(), + excludeFiles = excludeFiles + ) + + reporter.reportVerbose { "End of processing changes" } +} + +data class FilesToRecompile(val dirtyFiles: Set, val forceRecompileTogether: Set) + +private fun ChangesCollector.getDirtyFiles( + caches: Iterable, + lookupStorageManager: JpsLookupStorageManager +): FilesToRecompile { + val reporter = JpsICReporter() + val (dirtyLookupSymbols, dirtyClassFqNames, forceRecompile) = getDirtyData(caches, reporter) + val dirtyFilesFromLookups = lookupStorageManager.withLookupStorage { + mapLookupSymbolsToFiles(it, dirtyLookupSymbols, reporter) + } + return FilesToRecompile( + dirtyFilesFromLookups + mapClassesFqNamesToFiles(caches, dirtyClassFqNames, reporter), + mapClassesFqNamesToFiles(caches, forceRecompile, reporter) + ) + +} + +private fun getLookupTracker(project: JpsProject, representativeTarget: KotlinModuleBuildTarget<*>): LookupTracker { + val testLookupTracker = project.testingContext?.lookupTracker ?: LookupTracker.DO_NOTHING + + if (representativeTarget.isIncrementalCompilationEnabled) return LookupTrackerImpl(testLookupTracker) + + return testLookupTracker +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderService.java b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderService.java new file mode 100644 index 00000000000..2ad701e4433 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderService.java @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.incremental.BuilderService; +import org.jetbrains.jps.incremental.ModuleLevelBuilder; + +import java.util.Collections; +import java.util.List; + +public class KotlinBuilderService extends BuilderService { + @NotNull + @Override + public List createModuleLevelBuilders() { + return Collections.singletonList(new KotlinBuilder()); + } +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinChunk.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinChunk.kt new file mode 100644 index 00000000000..24b5982e1f9 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinChunk.kt @@ -0,0 +1,166 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.kotlin.config.ApiVersion +import org.jetbrains.kotlin.config.LanguageVersion +import org.jetbrains.kotlin.config.VersionView +import org.jetbrains.kotlin.jps.incremental.CacheStatus +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache +import org.jetbrains.kotlin.jps.incremental.getKotlinCache +import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.utils.keysToMapExceptNulls +import java.io.File + +/** + * Chunk of cyclically dependent [KotlinModuleBuildTarget]s + */ +class KotlinChunk internal constructor(val context: KotlinCompileContext, val targets: List>) { + val containsTests = targets.any { it.isTests } + + lateinit var dependencies: List + // Should be initialized only in KotlinChunk.calculateChunkDependencies + internal set + + lateinit var dependent: List + // Should be initialized only in KotlinChunk.calculateChunkDependencies + internal set + + // used only during dependency calculation + internal var _dependent: MutableSet? = mutableSetOf() + + val representativeTarget + get() = targets.first() + + val presentableModulesToCompilersList: String + get() = targets.joinToString { "${it.module.name} (${it.globalLookupCacheId})" } + + val haveSameCompiler = targets.all { it.javaClass == representativeTarget.javaClass } + + private val defaultLanguageVersion = VersionView.RELEASED_VERSION + + val compilerArguments = representativeTarget.jpsModuleBuildTarget.module.kotlinCompilerArguments.also { + it.reportOutputFiles = true + + // Always report the version to help diagnosing user issues if they submit the compiler output + it.version = true + + if (it.languageVersion == null) it.languageVersion = defaultLanguageVersion.versionString + } + + val langVersion = + compilerArguments.languageVersion?.let { LanguageVersion.fromVersionString(it) } + ?: defaultLanguageVersion // use default language version when version string is invalid (todo: report warning?) + + val apiVersion = + compilerArguments.apiVersion?.let { ApiVersion.parse(it) } + ?: ApiVersion.createByLanguageVersion(langVersion) // todo: report version parse error? + + val isEnabled: Boolean = representativeTarget.isEnabled(compilerArguments) + + fun shouldRebuild(): Boolean { + val buildMetaInfo = representativeTarget.buildMetaInfoFactory.create(compilerArguments) + + targets.forEach { target -> + if (target.isVersionChanged(this, buildMetaInfo)) { + KotlinBuilder.LOG.info("$target version changed, rebuilding $this") + return true + } + + if (target.initialLocalCacheAttributesDiff.status == CacheStatus.INVALID) { + context.testingLogger?.invalidOrUnusedCache(this, null, target.initialLocalCacheAttributesDiff) + KotlinBuilder.LOG.info("$target cache is invalid ${target.initialLocalCacheAttributesDiff}, rebuilding $this") + return true + } + } + + return false + } + + fun buildMetaInfoFile(target: ModuleBuildTarget): File = + File( + context.dataPaths.getTargetDataRoot(target), + representativeTarget.buildMetaInfoFileName + ) + + fun saveVersions() { + context.ensureLookupsCacheAttributesSaved() + + targets.forEach { + it.initialLocalCacheAttributesDiff.manager.writeVersion() + } + + val serializedMetaInfo = representativeTarget.buildMetaInfoFactory.serializeToString(compilerArguments) + + targets.forEach { + buildMetaInfoFile(it.jpsModuleBuildTarget).writeText(serializedMetaInfo) + } + } + + fun collectDependentChunksRecursivelyExportedOnly(result: MutableSet = mutableSetOf()) { + dependent.forEach { + if (result.add(it.src.chunk)) { + if (it.exported) { + it.src.chunk.collectDependentChunksRecursivelyExportedOnly(result) + } + } + } + } + + fun loadCaches(loadDependent: Boolean = true): Map, JpsIncrementalCache> { + val dataManager = context.dataManager + + val cacheByChunkTarget = targets.keysToMapExceptNulls { + dataManager.getKotlinCache(it) + } + + if (loadDependent) { + addDependentCaches(cacheByChunkTarget.values) + } + + return cacheByChunkTarget + } + + private fun addDependentCaches(targetsCaches: Collection) { + val dependentChunks = mutableSetOf() + + collectDependentChunksRecursivelyExportedOnly(dependentChunks) + + val dataManager = context.dataManager + dependentChunks.forEach { decedentChunk -> + decedentChunk.targets.forEach { + val dependentCache = dataManager.getKotlinCache(it) + if (dependentCache != null) { + + for (chunkCache in targetsCaches) { + chunkCache.addJpsDependentCache(dependentCache) + } + } + } + } + } + + /** + * The same as [org.jetbrains.jps.ModuleChunk.getPresentableShortName] + */ + val presentableShortName: String + get() = buildString { + if (containsTests) append("tests of ") + append(targets.first().module.name) + if (targets.size > 1) { + val andXMore = " and ${targets.size - 1} more" + val other = ", " + targets.asSequence().drop(1).joinToString() + append(if (other.length < andXMore.length) other else andXMore) + } + } + + override fun toString(): String { + return "KotlinChunk<${representativeTarget.javaClass.simpleName}>" + + "(${targets.joinToString { it.jpsModuleBuildTarget.presentableName }})" + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt new file mode 100644 index 00000000000..2d039bb8a33 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt @@ -0,0 +1,314 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.FSOperations +import org.jetbrains.jps.incremental.GlobalContextKey +import org.jetbrains.jps.incremental.fs.CompilationRound +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.incremental.messages.CompilerMessage +import org.jetbrains.kotlin.config.CompilerRunnerConstants +import org.jetbrains.kotlin.config.CompilerRunnerConstants.* +import org.jetbrains.kotlin.incremental.LookupSymbol +import org.jetbrains.kotlin.incremental.storage.FileToPathConverter +import org.jetbrains.kotlin.jps.incremental.* +import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndex +import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndexBuilder +import org.jetbrains.kotlin.jps.targets.KotlinUnsupportedModuleBuildTarget +import java.io.File +import java.util.concurrent.atomic.AtomicBoolean + +/** + * KotlinCompileContext is shared between all threads (i.e. it is [GlobalContextKey]). + * + * It is initialized lazily, and only before building of first chunk with kotlin code, + * and will be disposed on build finish. + */ +internal val CompileContext.kotlin: KotlinCompileContext + get() { + val userData = getUserData(kotlinCompileContextKey) + if (userData != null) return userData + + // here is error (KotlinCompilation available only at build phase) + // let's also check for concurrent initialization + val errorMessage = "KotlinCompileContext available only at build phase " + + "(between first KotlinBuilder.chunkBuildStarted and KotlinBuilder.buildFinished)" + + synchronized(kotlinCompileContextKey) { + val newUsedData = getUserData(kotlinCompileContextKey) + if (newUsedData != null) { + error("Concurrent CompileContext.kotlin getter call and KotlinCompileContext initialization detected: $errorMessage") + } + } + + error(errorMessage) + } + +internal val kotlinCompileContextKey = GlobalContextKey("kotlin") + +class KotlinCompileContext(val jpsContext: CompileContext) { + val dataManager = jpsContext.projectDescriptor.dataManager + val dataPaths = dataManager.dataPaths + val testingLogger: TestingBuildLogger? + get() = jpsContext.testingContext?.buildLogger + + val targetsIndex: KotlinTargetsIndex = KotlinTargetsIndexBuilder(this).build() + + val targetsBinding + get() = targetsIndex.byJpsTarget + + val lookupsCacheAttributesManager: CompositeLookupsCacheAttributesManager = makeLookupsCacheAttributesManager() + + val shouldCheckCacheVersions = System.getProperty(KotlinBuilder.SKIP_CACHE_VERSION_CHECK_PROPERTY) == null + + val hasKotlinMarker = HasKotlinMarker(dataManager) + + val isInstrumentationEnabled: Boolean by lazy { + val value = System.getProperty("kotlin.jps.instrument.bytecode")?.toBoolean() ?: false + if (value) { + val message = "Experimental bytecode instrumentation for Kotlin classes is enabled" + jpsContext.processMessage(CompilerMessage(KOTLIN_COMPILER_NAME, BuildMessage.Kind.INFO, message)) + } + value + } + + val fileToPathConverter: FileToPathConverter = + JpsFileToPathConverter(jpsContext.projectDescriptor.project) + + val lookupStorageManager = JpsLookupStorageManager(dataManager, fileToPathConverter) + + /** + * Flag to prevent rebuilding twice. + * + * TODO: looks like it is not required since cache version checking are refactored + */ + val rebuildAfterCacheVersionChanged = RebuildAfterCacheVersionChangeMarker(dataManager) + + var rebuildingAllKotlin = false + + /** + * Note, [loadLookupsCacheStateDiff] should be initialized last as it requires initialized + * [targetsIndex], [hasKotlinMarker] and [rebuildAfterCacheVersionChanged] (see [markChunkForRebuildBeforeBuild]) + */ + private val initialLookupsCacheStateDiff: CacheAttributesDiff<*> = loadLookupsCacheStateDiff() + + private fun makeLookupsCacheAttributesManager(): CompositeLookupsCacheAttributesManager { + val expectedLookupsCacheComponents = mutableSetOf() + + targetsIndex.chunks.forEach { chunk -> + chunk.targets.forEach { target -> + if (target.isIncrementalCompilationEnabled) { + expectedLookupsCacheComponents.add(target.globalLookupCacheId) + } + } + } + + val lookupsCacheRootPath = dataPaths.getTargetDataRoot(KotlinDataContainerTarget) + return CompositeLookupsCacheAttributesManager(lookupsCacheRootPath, expectedLookupsCacheComponents) + } + + private fun loadLookupsCacheStateDiff(): CacheAttributesDiff { + val diff = lookupsCacheAttributesManager.loadDiff() + + if (diff.status == CacheStatus.VALID) { + // try to perform a lookup + // request rebuild if storage is corrupted + try { + lookupStorageManager.withLookupStorage { + it.get(LookupSymbol("<#NAME#>", "<#SCOPE#>")) + } + } catch (e: Exception) { + // replace to jpsReportInternalBuilderError when IDEA-201297 will be implemented + jpsContext.processMessage( + CompilerMessage( + "Kotlin", BuildMessage.Kind.WARNING, + "Incremental caches are corrupted. All Kotlin code will be rebuilt." + ) + ) + KotlinBuilder.LOG.info(Error("Lookup storage is corrupted, probe failed: ${e.message}", e)) + + markAllKotlinForRebuild("Lookup storage is corrupted") + return diff.copy(actual = null) + } + } + + return diff + } + + fun hasKotlin() = targetsIndex.chunks.any { chunk -> + chunk.targets.any { target -> + hasKotlinMarker[target] == true + } + } + + fun checkCacheVersions() { + when (initialLookupsCacheStateDiff.status) { + CacheStatus.INVALID -> { + // global cache needs to be rebuilt + + testingLogger?.invalidOrUnusedCache(null, null, initialLookupsCacheStateDiff) + + if (initialLookupsCacheStateDiff.actual != null) { + markAllKotlinForRebuild("Kotlin incremental cache settings or format was changed") + clearLookupCache() + } else { + markAllKotlinForRebuild("Kotlin incremental cache is missed or corrupted") + } + } + CacheStatus.VALID -> Unit + CacheStatus.SHOULD_BE_CLEARED -> { + jpsContext.testingContext?.buildLogger?.invalidOrUnusedCache(null, null, initialLookupsCacheStateDiff) + KotlinBuilder.LOG.info("Removing global cache as it is not required anymore: $initialLookupsCacheStateDiff") + + clearAllCaches() + } + CacheStatus.CLEARED -> Unit + } + } + + private val lookupAttributesSaved = AtomicBoolean(false) + + /** + * Called on every successful compilation + */ + fun ensureLookupsCacheAttributesSaved() { + if (lookupAttributesSaved.compareAndSet(false, true)) { + initialLookupsCacheStateDiff.manager.writeVersion() + } + } + + fun checkChunkCacheVersion(chunk: KotlinChunk) { + if (shouldCheckCacheVersions && !rebuildingAllKotlin) { + if (chunk.shouldRebuild()) markChunkForRebuildBeforeBuild(chunk) + } + } + + private fun logMarkDirtyForTestingBeforeRound(file: File, shouldProcess: Boolean): Boolean { + if (shouldProcess) { + testingLogger?.markedAsDirtyBeforeRound(listOf(file)) + } + return shouldProcess + } + + private fun markAllKotlinForRebuild(reason: String) { + if (rebuildingAllKotlin) return + rebuildingAllKotlin = true + + KotlinBuilder.LOG.info("Rebuilding all Kotlin: $reason") + + targetsIndex.chunks.forEach { + markChunkForRebuildBeforeBuild(it) + } + + lookupStorageManager.cleanLookupStorage(KotlinBuilder.LOG) + } + + private fun markChunkForRebuildBeforeBuild(chunk: KotlinChunk) { + chunk.targets.forEach { + FSOperations.markDirty(jpsContext, CompilationRound.NEXT, it.jpsModuleBuildTarget) { file -> + logMarkDirtyForTestingBeforeRound(file, file.isKotlinSourceFile) + } + + dataManager.getKotlinCache(it)?.clean() + hasKotlinMarker.clean(it) + rebuildAfterCacheVersionChanged[it] = true + } + } + + private fun clearAllCaches() { + clearLookupCache() + + KotlinBuilder.LOG.info("Clearing caches for all targets") + targetsIndex.chunks.forEach { chunk -> + chunk.targets.forEach { + dataManager.getKotlinCache(it)?.clean() + } + } + } + + private fun clearLookupCache() { + KotlinBuilder.LOG.info("Clearing lookup cache") + lookupStorageManager.cleanLookupStorage(KotlinBuilder.LOG) + initialLookupsCacheStateDiff.manager.writeVersion() + } + + fun cleanupCaches() { + // todo: remove lookups for targets with disabled IC (or split global lookups cache into several caches for each compiler) + + targetsIndex.chunks.forEach { chunk -> + chunk.targets.forEach { target -> + if (target.initialLocalCacheAttributesDiff.status == CacheStatus.SHOULD_BE_CLEARED) { + KotlinBuilder.LOG.info( + "$target caches is cleared as not required anymore: ${target.initialLocalCacheAttributesDiff}" + ) + testingLogger?.invalidOrUnusedCache(null, target, target.initialLocalCacheAttributesDiff) + target.initialLocalCacheAttributesDiff.manager.writeVersion(null) + dataManager.getKotlinCache(target)?.clean() + } + } + } + } + + fun dispose() { + + } + + fun getChunk(rawChunk: ModuleChunk): KotlinChunk? { + val rawRepresentativeTarget = rawChunk.representativeTarget() + if (rawRepresentativeTarget !in targetsBinding) return null + + return targetsIndex.chunksByJpsRepresentativeTarget[rawRepresentativeTarget] + ?: error("Kotlin binding for chunk $this is not loaded at build start") + } + + fun reportUnsupportedTargets() { + // group all KotlinUnsupportedModuleBuildTarget by kind + // only representativeTarget will be added + val byKind = mutableMapOf>() + + targetsIndex.chunks.forEach { + val target = it.representativeTarget + if (target is KotlinUnsupportedModuleBuildTarget) { + if (target.sourceFiles.isNotEmpty()) { + byKind.getOrPut(target.kind) { mutableListOf() }.add(target) + } + } + } + + byKind.forEach { (kind, targets) -> + targets.sortBy { it.module.name } + val chunkNames = targets.map { it.chunk.presentableShortName } + val presentableChunksListString = chunkNames.joinToReadableString() + + val msg = + if (kind == null) { + "$presentableChunksListString is not yet supported in IDEA internal build system. " + + "Please use Gradle to build them (enable 'Delegate IDE build/run actions to Gradle' in Settings)." + } else { + "$kind is not yet supported in IDEA internal build system. " + + "Please use Gradle to build $presentableChunksListString (enable 'Delegate IDE build/run actions to Gradle' in Settings)." + } + + testingLogger?.addCustomMessage(msg) + jpsContext.processMessage( + CompilerMessage( + KOTLIN_COMPILER_NAME, + BuildMessage.Kind.WARNING, + msg + ) + ) + } + } +} + +fun List.joinToReadableString(): String = when { + size > 5 -> take(5).joinToString() + " and ${size - 5} more" + size > 1 -> dropLast(1).joinToString() + " and ${last()}" + size == 1 -> single() + else -> "" +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinDirtySourceFilesHolder.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinDirtySourceFilesHolder.kt new file mode 100644 index 00000000000..32aca9b2949 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinDirtySourceFilesHolder.kt @@ -0,0 +1,111 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.util.io.FileUtilRt +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.builders.DirtyFilesHolder +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import java.io.File + +/** + * Holding kotlin dirty files list for particular build round. + * Dirty and removed files set are initialized from [delegate]. + * + * Additional dirty files should be added only through [FSOperationsHelper.markFilesForCurrentRound] + */ +class KotlinDirtySourceFilesHolder( + val chunk: ModuleChunk, + val context: CompileContext, + delegate: DirtyFilesHolder +) { + val byTarget: Map + + inner class TargetFiles(val target: ModuleBuildTarget, val removed: Collection) { + private val _dirty: MutableMap = mutableMapOf() + + val dirty: Map + get() = _dirty + + /** + * Should be called only from [FSOperationsHelper.markFilesForCurrentRound] + * and during KotlinDirtySourceFilesHolder initialization. + */ + internal fun _markDirty(file: File, root: JavaSourceRootDescriptor) { + val isCrossCompiled = root is KotlinIncludedModuleSourceRoot + val old = _dirty.put(file.canonicalFile, KotlinModuleBuildTarget.Source(file, isCrossCompiled)) + + check(old == null || old.isCrossCompiled == isCrossCompiled) { + "`${file.canonicalFile}` already marked as dirty: " + + "old is cross compiled: ${old!!.isCrossCompiled}, " + + "new is cross compiled: $isCrossCompiled" + } + } + } + + val hasRemovedFiles: Boolean + get() = byTarget.any { it.value.removed.isNotEmpty() } + + val hasDirtyFiles: Boolean + get() = byTarget.any { it.value.dirty.isNotEmpty() } + + val hasDirtyOrRemovedFiles: Boolean + get() = hasRemovedFiles || hasDirtyFiles + + init { + val byTarget = mutableMapOf() + + chunk.targets.forEach { target -> + val removedFiles = delegate.getRemovedFiles(target) + .map { File(it) } + .filter { it.isKotlinSourceFile } + + byTarget[target] = TargetFiles(target, removedFiles) + } + + delegate.processDirtyFiles { target, file, root -> + val targetInfo = byTarget[target] + ?: error("processDirtyFiles should callback only on chunk `$chunk` targets (`$target` is not)") + + if (file.isKotlinSourceFile) { + targetInfo._markDirty(file, root) + } + + true + } + + this.byTarget = byTarget + } + + fun getDirtyFiles(target: ModuleBuildTarget): Map = + byTarget[target]?.dirty ?: mapOf() + + fun getRemovedFiles(target: ModuleBuildTarget): Collection = + byTarget[target]?.removed ?: listOf() + + val allDirtyFiles: Set + get() = byTarget.flatMapTo(mutableSetOf()) { it.value.dirty.keys } + + val allRemovedFilesFiles: Set + get() = byTarget.flatMapTo(mutableSetOf()) { it.value.removed } +} + +val File.isKotlinSourceFile: Boolean + get() = FileUtilRt.extensionEquals(name, "kt") || FileUtilRt.extensionEquals(name, "kts") diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinJavaBuilderExtension.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinJavaBuilderExtension.kt new file mode 100644 index 00000000000..d5ca80f4205 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinJavaBuilderExtension.kt @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.api.BasicFuture +import org.jetbrains.jps.builders.java.JavaBuilderExtension +import org.jetbrains.jps.builders.java.dependencyView.Callbacks +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.kotlin.incremental.LookupSymbol +import java.io.File +import java.util.concurrent.Executors +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +class KotlinJavaBuilderExtension : JavaBuilderExtension() { + override fun getConstantSearch(context: CompileContext): Callbacks.ConstantAffectionResolver { + return KotlinLookupConstantSearch(context) + } +} + +private class KotlinLookupConstantSearch(context: CompileContext) : Callbacks.ConstantAffectionResolver { + private val pool = Executors.newSingleThreadExecutor() + private val kotlinContext by lazy { context.kotlin } + + override fun request( + ownerClassName: String, + fieldName: String, + accessFlags: Int, + fieldRemoved: Boolean, + accessChanged: Boolean + ): Future { + val future = object : BasicFuture() { + @Volatile + private var result: Callbacks.ConstantAffection = Callbacks.ConstantAffection.EMPTY + + fun result(files: Collection) { + result = Callbacks.ConstantAffection(files) + setDone() + } + + override fun get(): Callbacks.ConstantAffection { + super.get() + return result + } + + override fun get(timeout: Long, unit: TimeUnit): Callbacks.ConstantAffection { + super.get(timeout, unit) + return result + } + } + pool.submit { + if (!future.isCancelled) { + kotlinContext.lookupStorageManager.withLookupStorage { storage -> + val paths = storage.get(LookupSymbol(name = fieldName, scope = ownerClassName)) + future.result(paths.map { File(it) }) + } + } + } + return future + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinJpsCompilerArgumentsProvider.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinJpsCompilerArgumentsProvider.kt new file mode 100644 index 00000000000..20513a1f2cc --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinJpsCompilerArgumentsProvider.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.ModuleBuildTarget + +interface KotlinJpsCompilerArgumentsProvider { + fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List + fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinResourcesRootProvider.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinResourcesRootProvider.kt new file mode 100644 index 00000000000..d8e6024f4a8 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinResourcesRootProvider.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.builders.AdditionalRootsProviderService +import org.jetbrains.jps.builders.BuildTarget +import org.jetbrains.jps.builders.java.ResourceRootDescriptor +import org.jetbrains.jps.builders.java.ResourcesTargetType +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.ResourcesTarget +import org.jetbrains.jps.model.java.JavaResourceRootProperties +import org.jetbrains.kotlin.config.ResourceKotlinRootType +import org.jetbrains.kotlin.config.TestResourceKotlinRootType + +class KotlinResourcesRootProvider : AdditionalRootsProviderService(ResourcesTargetType.ALL_TYPES) { + override fun getAdditionalRoots( + target: BuildTarget, + dataPaths: BuildDataPaths? + ): List { + val moduleBuildTarget = target as? ResourcesTarget ?: return listOf() + val module = moduleBuildTarget.module + + val result = mutableListOf() + + // Add source roots with type KotlinResourceRootType. + // See the note in KotlinSourceRootProvider + val kotlinResourceRootType = if (target.isTests) TestResourceKotlinRootType else ResourceKotlinRootType + module.getSourceRoots(kotlinResourceRootType).forEach { + result.add( + ResourceRootDescriptor( + it.file, + target, + it.properties.packagePrefix, + setOf() + ) + ) + } + + return result + } +} + +/** + * Copied from implementation of org.jetbrains.jps.incremental.ResourcesTarget.computeRootDescriptors + */ +private val JavaResourceRootProperties.packagePrefix: String + get() = relativeOutputPath.replace('/', '.') \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinSourceRootProvider.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinSourceRootProvider.kt new file mode 100644 index 00000000000..becc525704c --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinSourceRootProvider.kt @@ -0,0 +1,112 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.builders.AdditionalRootsProviderService +import org.jetbrains.jps.builders.BuildTarget +import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.model.java.JavaResourceRootType +import org.jetbrains.jps.model.java.JavaSourceRootProperties +import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.model.module.JpsModuleSourceRootType +import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.jps.model.expectedByModules +import org.jetbrains.kotlin.jps.model.isTestModule +import org.jetbrains.kotlin.jps.model.sourceSetModules +import java.io.File + +class KotlinSourceRootProvider : AdditionalRootsProviderService(JavaModuleBuildTargetType.ALL_TYPES) { + override fun getAdditionalRoots( + target: BuildTarget, + dataPaths: BuildDataPaths? + ): List { + val moduleBuildTarget = target as? ModuleBuildTarget ?: return listOf() + val module = moduleBuildTarget.module + + val result = mutableListOf() + + // Add source roots with type KotlinSourceRootType. + // + // Note: `KotlinSourceRootType` cannot be supported directly, since `SourceRootDescriptors` are computed by + // `ModuleBuildTarget.computeAllTargets`. `ModuleBuildTarget` is required for incremental compilation. + // We cannot define our own `ModuleBuildTarget` since it is final and `ModuleBuildTarget` supports only `JavaSourceRootDescriptor`. + // So the only one way to support `KotlinSourceRootType` is to add a fake `JavaSourceRootDescriptor` for each source root with that type. + val kotlinSourceRootType = if (target.isTests) TestSourceKotlinRootType else SourceKotlinRootType + module.getSourceRoots(kotlinSourceRootType).forEach { + result.add( + JavaSourceRootDescriptor( + it.file, + target, + false, + false, + it.properties.packagePrefix, + setOf() + ) + ) + } + + // new multiplatform model support: + if (target.isTests == module.isTestModule) { + module.sourceSetModules.forEach { sourceSetModule -> + addModuleSourceRoots(result, sourceSetModule, target) + } + } + + // legacy multiplatform model support: + module.expectedByModules.forEach { commonModule -> + addModuleSourceRoots(result, commonModule, target) + } + + return result + } + + private fun addModuleSourceRoots( + result: MutableList, + module: JpsModule, + target: ModuleBuildTarget + ) { + for (commonSourceRoot in module.sourceRoots) { + val isCommonTestsRootType = commonSourceRoot.rootType.isTestsRootType + if (isCommonTestsRootType != null && target.isTests == isCommonTestsRootType) { + val javaSourceRootProperties = commonSourceRoot.properties as? JavaSourceRootProperties + + result.add( + KotlinIncludedModuleSourceRoot( + commonSourceRoot.file, + target, + javaSourceRootProperties?.isForGeneratedSources ?: false, + false, + javaSourceRootProperties?.packagePrefix ?: "", + setOf() + ) + ) + } + } + } +} + +private val JpsModuleSourceRootType<*>.isTestsRootType + get() = when (this) { + is KotlinSourceRootType -> this == TestSourceKotlinRootType + is KotlinResourceRootType -> this == TestResourceKotlinRootType + // for compatibility: + is JavaSourceRootType -> this == JavaSourceRootType.TEST_SOURCE + is JavaResourceRootType -> this == JavaResourceRootType.TEST_RESOURCE + else -> null + } + +class KotlinIncludedModuleSourceRoot( + root: File, + target: ModuleBuildTarget, + isGenerated: Boolean, + isTemp: Boolean, + packagePrefix: String, + excludes: Set +) : JavaSourceRootDescriptor(root, target, isGenerated, isTemp, packagePrefix, excludes) \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/MarkerFile.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/MarkerFile.kt new file mode 100644 index 00000000000..1bcfd687b12 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/MarkerFile.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.incremental.storage.BuildDataManager +import org.jetbrains.kotlin.incremental.KOTLIN_CACHE_DIRECTORY_NAME +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import java.io.File + +private val HAS_KOTLIN_MARKER_FILE_NAME = "has-kotlin-marker.txt" +private val REBUILD_AFTER_CACHE_VERSION_CHANGE_MARKER = "rebuild-after-cache-version-change-marker.txt" + +abstract class MarkerFile(private val fileName: String, private val paths: BuildDataPaths) { + operator fun get(target: KotlinModuleBuildTarget<*>): Boolean? = + get(target.jpsModuleBuildTarget) + + operator fun get(target: ModuleBuildTarget): Boolean? { + val file = target.markerFile + + if (!file.exists()) return null + + return file.readText().toBoolean() + } + + operator fun set(target: KotlinModuleBuildTarget<*>, value: Boolean) = + set(target.jpsModuleBuildTarget, value) + + operator fun set(target: ModuleBuildTarget, value: Boolean) { + val file = target.markerFile + + if (!file.exists()) { + file.parentFile.mkdirs() + file.createNewFile() + } + + file.writeText(value.toString()) + } + + fun clean(target: KotlinModuleBuildTarget<*>) = + clean(target.jpsModuleBuildTarget) + + fun clean(target: ModuleBuildTarget) { + target.markerFile.delete() + } + + private val ModuleBuildTarget.markerFile: File + get() { + val directory = File(paths.getTargetDataRoot(this), KOTLIN_CACHE_DIRECTORY_NAME) + return File(directory, fileName) + } +} + +class HasKotlinMarker(dataManager: BuildDataManager) : MarkerFile(HAS_KOTLIN_MARKER_FILE_NAME, dataManager.dataPaths) +class RebuildAfterCacheVersionChangeMarker(dataManager: BuildDataManager) : + MarkerFile(REBUILD_AFTER_CACHE_VERSION_CHANGE_MARKER, dataManager.dataPaths) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/MessageCollectorAdapter.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/MessageCollectorAdapter.kt new file mode 100644 index 00000000000..3ac886c1d27 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/MessageCollectorAdapter.kt @@ -0,0 +1,72 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.BuildMessage +import org.jetbrains.jps.incremental.messages.CompilerMessage +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CompilerRunnerConstants +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import java.io.File + +class MessageCollectorAdapter( + private val context: CompileContext, + private val kotlinTarget: KotlinModuleBuildTarget<*>? +) : MessageCollector { + private var hasErrors = false + + override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) { + hasErrors = hasErrors || severity.isError + + var prefix = "" + if (severity == CompilerMessageSeverity.EXCEPTION) { + prefix = CompilerRunnerConstants.INTERNAL_ERROR_PREFIX + } + + val kind = kind(severity) + if (kind != null) { + // Report target when cross-compiling common files + if (location != null && kotlinTarget != null && kotlinTarget.isFromIncludedSourceRoot(File(location.path))) { + val moduleName = kotlinTarget.module.name + prefix += "[$moduleName] " + } + + context.processMessage( + CompilerMessage( + CompilerRunnerConstants.KOTLIN_COMPILER_NAME, + kind, + prefix + message, + location?.path, + -1, -1, -1, + location?.line?.toLong() ?: -1, + location?.column?.toLong() ?: -1 + ) + ) + } else { + val path = if (location != null) "${location.path}:${location.line}:${location.column}: " else "" + KotlinBuilder.LOG.debug(path + message) + } + } + + override fun clear() { + hasErrors = false + } + + override fun hasErrors(): Boolean = hasErrors + + private fun kind(severity: CompilerMessageSeverity): BuildMessage.Kind? { + return when (severity) { + CompilerMessageSeverity.INFO -> BuildMessage.Kind.INFO + CompilerMessageSeverity.ERROR, CompilerMessageSeverity.EXCEPTION -> BuildMessage.Kind.ERROR + CompilerMessageSeverity.WARNING, CompilerMessageSeverity.STRONG_WARNING -> BuildMessage.Kind.WARNING + CompilerMessageSeverity.LOGGING -> null + else -> throw IllegalArgumentException("Unsupported severity: $severity") + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TeamcityStatisticsLogger.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TeamcityStatisticsLogger.kt new file mode 100644 index 00000000000..01c7900edf0 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TeamcityStatisticsLogger.kt @@ -0,0 +1,87 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.ModuleChunk +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicLong + +class TeamcityStatisticsLogger { + private val isOnTeamcity = System.getenv("TEAMCITY_VERSION") != null + + private val totalTime = AtomicLong() + + //NOTE: mostly copied from TeamCityBuildInfoPrinter + private fun escapedChar(c: Char): Char { + return when (c) { + '\n' -> 'n' + '\r' -> 'r' + '\u0085' -> 'x' // next-line character + '\u2028' -> 'l' // line-separator character + '\u2029' -> 'p' // paragraph-separator character + '|' -> '|' + '\'' -> '\'' + '[' -> '[' + ']' -> ']' + else -> 0.toChar() + } + } + + private fun escape(text: String): String { + val escaped = StringBuilder() + for (c in text.toCharArray()) { + val escChar = escapedChar(c) + if (escChar == 0.toChar()) { + escaped.append(c) + } else { + escaped.append('|').append(escChar) + } + } + + return escaped.toString() + } + + fun registerStatistic(moduleChunk: ModuleChunk, timeToCompileNs: Long) { + if (!isOnTeamcity) return + + totalTime.addAndGet(timeToCompileNs) + printPerChunkStatistics(moduleChunk, timeToCompileNs) + } + + private fun printPerChunkStatistics(moduleChunk: ModuleChunk, timeToCompileNs: Long) { + printStatisticMessage( + "${KotlinBuilder.KOTLIN_BUILDER_NAME} for ${moduleChunk.presentableShortName} compilation time, ms", + timeToCompileNs.nanosToMillis().toString() + ) + } + + fun reportTotal() { + if (!isOnTeamcity) return + + printStatisticMessage( + "${KotlinBuilder.KOTLIN_BUILDER_NAME} total compilation time, ms", + totalTime.get().nanosToMillis().toString() + ) + } + + + private fun printStatisticMessage(key: String, value: String) { + println("##teamcity[buildStatisticValue key='${escape(key)}' value='${escape(value)}']") + } + + private fun Long.nanosToMillis() = TimeUnit.NANOSECONDS.toMillis(this) +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TestingBuildLogger.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TestingBuildLogger.kt new file mode 100644 index 00000000000..9beec30eec2 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TestingBuildLogger.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.ModuleLevelBuilder +import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import java.io.File + +/** + * Used for assertions in tests. + */ +interface TestingBuildLogger { + fun invalidOrUnusedCache(chunk: KotlinChunk?, target: KotlinModuleBuildTarget<*>?, attributesDiff: CacheAttributesDiff<*>) = Unit + fun chunkBuildStarted(context: CompileContext, chunk: org.jetbrains.jps.ModuleChunk) = Unit + fun afterChunkBuildStarted(context: CompileContext, chunk: org.jetbrains.jps.ModuleChunk) = Unit + fun compilingFiles(files: Collection, allRemovedFilesFiles: Collection) = Unit + fun addCustomMessage(message: String) = Unit + fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) = Unit + fun markedAsDirtyBeforeRound(files: Iterable) = Unit + fun markedAsDirtyAfterRound(files: Iterable) = Unit +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TestingContext.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TestingContext.kt new file mode 100644 index 00000000000..bda459ad2b6 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/TestingContext.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.annotations.TestOnly +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.model.JpsElementFactory +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.JpsSimpleElement +import org.jetbrains.jps.model.ex.JpsElementChildRoleBase +import org.jetbrains.kotlin.incremental.components.LookupTracker + +private val TESTING_CONTEXT = JpsElementChildRoleBase.create>("Testing kcontext") + +@TestOnly +fun JpsProject.setTestingContext(context: TestingContext) { + val dataContainer = JpsElementFactory.getInstance().createSimpleElement(context) + container.setChild(TESTING_CONTEXT, dataContainer) +} + +val JpsProject.testingContext: TestingContext? + get() = container.getChild(TESTING_CONTEXT)?.data + +val CompileContext.testingContext: TestingContext? + get() = projectDescriptor?.project?.testingContext + +class TestingContext( + val lookupTracker: LookupTracker, + val buildLogger: TestingBuildLogger? +) { + var kotlinCompileContext: KotlinCompileContext? = null +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt new file mode 100644 index 00000000000..13c4a9b89b3 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.CompilerMessage + +fun jpsReportInternalBuilderError(context: CompileContext, error: Throwable) { + val builderError = CompilerMessage.createInternalBuilderError("Kotlin", error) + context.processMessage(builderError) +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as33 b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as33 new file mode 100644 index 00000000000..6546b2059d2 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as33 @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.CompilerMessage + +fun jpsReportInternalBuilderError(context: CompileContext, error: Throwable) { + KotlinBuilder.LOG.info(error) +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as36 b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as36 new file mode 100644 index 00000000000..6546b2059d2 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as36 @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.CompilerMessage + +fun jpsReportInternalBuilderError(context: CompileContext, error: Throwable) { + KotlinBuilder.LOG.info(error) +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as41 b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as41 new file mode 100644 index 00000000000..6546b2059d2 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as41 @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.CompilerMessage + +fun jpsReportInternalBuilderError(context: CompileContext, error: Throwable) { + KotlinBuilder.LOG.info(error) +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as42 b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as42 new file mode 100644 index 00000000000..6546b2059d2 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/ideaPlatform.kt.as42 @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.messages.CompilerMessage + +fun jpsReportInternalBuilderError(context: CompileContext, error: Throwable) { + KotlinBuilder.LOG.info(error) +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/jpsUtil.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/jpsUtil.kt new file mode 100644 index 00000000000..c63f0771e6a --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/jpsUtil.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.model.module.JpsModule + +fun ModuleChunk.isDummy(context: CompileContext): Boolean { + val targetIndex = context.projectDescriptor.buildTargetIndex + return targets.all { targetIndex.isDummy(it) } +} + +@Deprecated("Use `kotlin.targetBinding` instead", ReplaceWith("kotlin.targetsBinding")) +val CompileContext.kotlinBuildTargets + get() = kotlin.targetsBinding + +fun ModuleChunk.toKotlinChunk(context: CompileContext): KotlinChunk? = + context.kotlin.getChunk(this) + +fun ModuleBuildTarget(module: JpsModule, isTests: Boolean) = + ModuleBuildTarget( + module, + if (isTests) JavaModuleBuildTargetType.TEST else JavaModuleBuildTargetType.PRODUCTION + ) + +val JpsModule.productionBuildTarget + get() = ModuleBuildTarget(this, false) + +val JpsModule.testBuildTarget + get() = ModuleBuildTarget(this, true) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheAttributesDiff.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheAttributesDiff.kt new file mode 100644 index 00000000000..7e51729aba1 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheAttributesDiff.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +/** + * Diff between actual and expected cache attributes. + * [status] are calculated based on this diff (see [CacheStatus]). + * Based on that [status] system may perform required actions (i.e. rebuild something, clearing caches, etc...). + * + * [CacheAttributesDiff] can be used to cache current attribute values and as facade for version operations. + */ +data class CacheAttributesDiff( + val manager: CacheAttributesManager, + val actual: Attrs?, + val expected: Attrs? +) { + val status: CacheStatus + get() = + if (expected != null) { + if (actual != null && manager.isCompatible(actual, expected)) CacheStatus.VALID + else CacheStatus.INVALID + } else { + if (actual != null) CacheStatus.SHOULD_BE_CLEARED + else CacheStatus.CLEARED + } + + override fun toString(): String { + return "$status: actual=$actual -> expected=$expected" + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheAttributesManager.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheAttributesManager.kt new file mode 100644 index 00000000000..cd6a838e18d --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheAttributesManager.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +/** + * Manages cache attributes values. + * + * Attribute values can be loaded by calling [loadActual]. + * Based on loaded actual and fixed [expected] values [CacheAttributesDiff] can be constructed which can calculate [CacheStatus]. + * Build system may perform required actions based on that (i.e. rebuild something, clearing caches, etc...). + * + * [CacheAttributesDiff] can be used to cache current attribute values and then can be used as facade for cache version operations. + */ +interface CacheAttributesManager { + /** + * Cache attribute values expected by the current version of build system and compiler. + * `null` means that cache is not required (incremental compilation is disabled). + */ + val expected: Attrs? + + /** + * Load actual cache attribute values. + * `null` means that cache is not yet created. + * + * This is internal operation that should be implemented by particular implementation of CacheAttributesManager. + * Consider using `loadDiff().actual` for getting actual values. + */ + fun loadActual(): Attrs? + + /** + * Write [values] as cache attributes for next build execution. + */ + fun writeVersion(values: Attrs? = expected) + + /** + * Check if cache with [actual] attributes values can be used when [expected] attributes are required. + */ + fun isCompatible(actual: Attrs, expected: Attrs): Boolean = actual == expected +} + +fun CacheAttributesManager.loadDiff( + actual: Attrs? = this.loadActual(), + expected: Attrs? = this.expected +) = CacheAttributesDiff(this, actual, expected) \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheStatus.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheStatus.kt new file mode 100644 index 00000000000..6a815c402ec --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheStatus.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +/** + * Status that is used by system to perform required actions (i.e. rebuild something, clearing caches, etc...). + */ +enum class CacheStatus { + /** + * Cache is valid and ready to use. + */ + VALID, + + /** + * Cache is not exists or have outdated versions and/or other attributes. + */ + INVALID, + + /** + * Cache is exists, but not required anymore. + */ + SHOULD_BE_CLEARED, + + /** + * Cache is not exists and not required. + */ + CLEARED +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheVersionManager.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheVersionManager.kt new file mode 100644 index 00000000000..df3cddd57e4 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CacheVersionManager.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.annotations.TestOnly +import org.jetbrains.kotlin.load.kotlin.JvmBytecodeBinaryVersion +import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion +import java.io.File +import java.io.IOException + +/** + * Manages files with actual version [loadActual] and provides expected version [expected]. + * Based on that actual and expected versions [CacheStatus] can be calculated. + * This can be done by constructing [CacheAttributesDiff] and calling [CacheAttributesDiff.status]. + * Based on that status system may perform required actions (i.e. rebuild something, clearing caches, etc...). + */ +class CacheVersionManager( + private val versionFile: File, + expectedOwnVersion: Int? +) : CacheAttributesManager { + override val expected: CacheVersion? = + if (expectedOwnVersion == null) null + else CacheVersion(expectedOwnVersion, JvmBytecodeBinaryVersion.INSTANCE, JvmMetadataVersion.INSTANCE) + + override fun loadActual(): CacheVersion? = + if (!versionFile.exists()) null + else try { + CacheVersion(versionFile.readText().toInt()) + } catch (e: NumberFormatException) { + null + } catch (e: IOException) { + null + } + + override fun writeVersion(values: CacheVersion?) { + if (values == null) versionFile.delete() + else { + versionFile.parentFile.mkdirs() + versionFile.writeText(values.intValue.toString()) + } + } + + @get:TestOnly + val versionFileForTesting: File + get() = versionFile +} + +fun CacheVersion(own: Int, bytecode: JvmBytecodeBinaryVersion, metadata: JvmMetadataVersion): CacheVersion { + require(own in 0..(Int.MAX_VALUE / 1000000 - 1)) + require(bytecode.major in 0..9) + require(bytecode.minor in 0..9) + require(metadata.major in 0..9) + require(metadata.minor in 0..99) + + return CacheVersion( + own * 1000000 + + bytecode.major * 10000 + bytecode.minor * 100 + + metadata.major * 1000 + metadata.minor + ) +} + +data class CacheVersion(val intValue: Int) { + val own: Int + get() = intValue / 1000000 + + val bytecode: JvmBytecodeBinaryVersion + get() = JvmBytecodeBinaryVersion( + intValue / 10000 % 10, + intValue / 100 % 10 + ) + + val metadata: JvmMetadataVersion + get() = JvmMetadataVersion( + intValue / 1000 % 10, + intValue / 1 % 100 + ) + + override fun toString(): String = "CacheVersion(caches: $own, bytecode: $bytecode, metadata: $metadata)" +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CompositeLookupsCacheAttributes.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CompositeLookupsCacheAttributes.kt new file mode 100644 index 00000000000..04115c7bc39 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/CompositeLookupsCacheAttributes.kt @@ -0,0 +1,75 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.annotations.TestOnly +import java.io.File +import java.io.IOException + +/** + * Attributes manager for global lookups cache that may contain lookups for several compilers (jvm, js). + * Works by delegating to [lookupsCacheVersionManager] and managing additional file with list of executed compilers (cache components). + * + * TODO(1.2.80): got rid of shared lookup cache, replace with individual lookup cache for each compiler + */ +class CompositeLookupsCacheAttributesManager( + rootPath: File, + expectedComponents: Set +) : CacheAttributesManager { + private val versionManager = lookupsCacheVersionManager( + rootPath, + expectedComponents.isNotEmpty() + ) + + private val actualComponentsFile = File(rootPath, "components.txt") + + override val expected: CompositeLookupsCacheAttributes? = + if (expectedComponents.isEmpty()) null + else CompositeLookupsCacheAttributes(versionManager.expected!!.intValue, expectedComponents) + + override fun loadActual(): CompositeLookupsCacheAttributes? { + val version = versionManager.loadActual() ?: return null + + if (!actualComponentsFile.exists()) return null + + val components = try { + actualComponentsFile.readLines().toSet() + } catch (e: IOException) { + return null + } + + return CompositeLookupsCacheAttributes(version.intValue, components) + } + + override fun writeVersion(values: CompositeLookupsCacheAttributes?) { + if (values == null) { + versionManager.writeVersion(null) + actualComponentsFile.delete() + } else { + versionManager.writeVersion(CacheVersion(values.version)) + + actualComponentsFile.parentFile.mkdirs() + actualComponentsFile.writeText(values.components.joinToString("\n")) + } + } + + override fun isCompatible(actual: CompositeLookupsCacheAttributes, expected: CompositeLookupsCacheAttributes): Boolean { + // cache can be reused when all required (expected) components are present + // (components that are not required anymore are not not interfere) + return actual.version == expected.version && actual.components.containsAll(expected.components) + } + + @get:TestOnly + val versionManagerForTesting + get() = versionManager +} + +data class CompositeLookupsCacheAttributes( + val version: Int, + val components: Set +) { + override fun toString() = "($version, $components)" +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCache.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCache.kt new file mode 100644 index 00000000000..3e4203fc14d --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCache.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.builders.storage.StorageProvider +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.incremental.storage.BuildDataManager +import org.jetbrains.jps.incremental.storage.StorageOwner +import org.jetbrains.kotlin.incremental.IncrementalCacheCommon +import org.jetbrains.kotlin.incremental.IncrementalJsCache +import org.jetbrains.kotlin.incremental.IncrementalJvmCache +import org.jetbrains.kotlin.incremental.storage.FileToPathConverter +import org.jetbrains.kotlin.jps.build.KotlinBuilder +import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol +import java.io.File + +interface JpsIncrementalCache : IncrementalCacheCommon, StorageOwner { + fun addJpsDependentCache(cache: JpsIncrementalCache) +} + +class JpsIncrementalJvmCache( + target: ModuleBuildTarget, + paths: BuildDataPaths, + pathConverter: FileToPathConverter +) : IncrementalJvmCache(paths.getTargetDataRoot(target), target.outputDir, pathConverter), JpsIncrementalCache { + override fun addJpsDependentCache(cache: JpsIncrementalCache) { + if (cache is JpsIncrementalJvmCache) { + addDependentCache(cache) + } + } + + override fun debugLog(message: String) { + KotlinBuilder.LOG.debug(message) + } +} + +class JpsIncrementalJsCache( + target: ModuleBuildTarget, + paths: BuildDataPaths, + pathConverter: FileToPathConverter +) : IncrementalJsCache(paths.getTargetDataRoot(target), pathConverter, JsSerializerProtocol), JpsIncrementalCache { + override fun addJpsDependentCache(cache: JpsIncrementalCache) { + if (cache is JpsIncrementalJsCache) { + addDependentCache(cache) + } + } +} + +private class KotlinIncrementalStorageProvider( + private val target: KotlinModuleBuildTarget<*>, + private val paths: BuildDataPaths +) : StorageProvider() { + init { + check(target.hasCaches) + } + + override fun equals(other: Any?) = other is KotlinIncrementalStorageProvider && target == other.target + + override fun hashCode() = target.hashCode() + + override fun createStorage(targetDataDir: File): JpsIncrementalCache = target.createCacheStorage(paths) +} + +fun BuildDataManager.getKotlinCache(target: KotlinModuleBuildTarget<*>?): JpsIncrementalCache? = + if (target == null || !target.hasCaches) null + else getStorage(target.jpsModuleBuildTarget, KotlinIncrementalStorageProvider(target, dataPaths)) + diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsLookupStorage.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsLookupStorage.kt new file mode 100644 index 00000000000..0fd2eaaa7be --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsLookupStorage.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import com.intellij.openapi.diagnostic.Logger +import org.jetbrains.jps.builders.storage.BuildDataCorruptedException +import org.jetbrains.jps.builders.storage.StorageProvider +import org.jetbrains.jps.incremental.storage.BuildDataManager +import org.jetbrains.jps.incremental.storage.StorageOwner +import org.jetbrains.kotlin.incremental.LookupStorage +import org.jetbrains.kotlin.incremental.storage.FileToPathConverter +import java.io.File +import java.io.IOException + +private object LookupStorageLock + +class JpsLookupStorageManager( + private val buildDataManager: BuildDataManager, + pathConverter: FileToPathConverter +) { + private val storageProvider = JpsLookupStorageProvider(pathConverter) + + fun cleanLookupStorage(log: Logger) { + synchronized(LookupStorageLock) { + try { + buildDataManager.cleanTargetStorages(KotlinDataContainerTarget) + } catch (e: IOException) { + if (!buildDataManager.dataPaths.getTargetDataRoot(KotlinDataContainerTarget).deleteRecursively()) { + log.debug("Could not clear lookup storage caches", e) + } + } + } + } + + fun withLookupStorage(fn: (LookupStorage) -> T): T { + synchronized(LookupStorageLock) { + try { + val lookupStorage = buildDataManager.getStorage(KotlinDataContainerTarget, storageProvider) + return fn(lookupStorage) + } catch (e: IOException) { + throw BuildDataCorruptedException(e) + } + } + } + + private class JpsLookupStorageProvider( + private val pathConverter: FileToPathConverter + ) : StorageProvider() { + override fun createStorage(targetDataDir: File): JpsLookupStorage = + JpsLookupStorage(targetDataDir, pathConverter) + } + + private class JpsLookupStorage( + targetDataDir: File, + pathConverter: FileToPathConverter + ) : StorageOwner, LookupStorage(targetDataDir, pathConverter) +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/KotlinDataContainerTargetType.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/KotlinDataContainerTargetType.kt new file mode 100644 index 00000000000..d8e64680d61 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/KotlinDataContainerTargetType.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental + +import org.jetbrains.jps.builders.* +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.indices.IgnoredFileIndex +import org.jetbrains.jps.indices.ModuleExcludeIndex +import org.jetbrains.jps.model.JpsModel +import java.io.File + +private val KOTLIN_DATA_CONTAINER = "kotlin-data-container" + +object KotlinDataContainerTargetType : BuildTargetType(KOTLIN_DATA_CONTAINER) { + override fun computeAllTargets(model: JpsModel): List = listOf(KotlinDataContainerTarget) + + override fun createLoader(model: JpsModel): BuildTargetLoader = + object : BuildTargetLoader() { + override fun createTarget(targetId: String): KotlinDataContainerTarget? = KotlinDataContainerTarget + } +} + +// Fake target to store data per project for incremental compilation +object KotlinDataContainerTarget : BuildTarget(KotlinDataContainerTargetType) { + override fun getId(): String? = KOTLIN_DATA_CONTAINER + override fun getPresentableName(): String = KOTLIN_DATA_CONTAINER + + override fun computeRootDescriptors( + model: JpsModel?, + index: ModuleExcludeIndex?, + ignoredFileIndex: IgnoredFileIndex?, + dataPaths: BuildDataPaths? + ): List = listOf() + + override fun getOutputRoots(context: CompileContext): Collection { + val dataManager = context.projectDescriptor.dataManager + val storageRoot = dataManager.dataPaths.dataStorageRoot + return listOf(File(storageRoot, KOTLIN_DATA_CONTAINER)) + } + + override fun findRootDescriptor(rootId: String?, rootIndex: BuildRootIndex?): BuildRootDescriptor? = null + + override fun computeDependencies( + targetRegistry: BuildTargetRegistry?, + outputIndex: TargetOutputIndex? + ): Collection>? = listOf() +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/local.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/local.kt new file mode 100644 index 00000000000..6f51a4e29b3 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/local.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +import java.io.File + +private val NORMAL_VERSION = 14 +private val NORMAL_VERSION_FILE_NAME = "format-version.txt" + +fun localCacheVersionManager(dataRoot: File, isCachesEnabled: Boolean) = + CacheVersionManager( + File(dataRoot, NORMAL_VERSION_FILE_NAME), + if (isCachesEnabled) NORMAL_VERSION else null + ) \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/lookups.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/lookups.kt new file mode 100644 index 00000000000..b670b9d8cd5 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/lookups.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.incremental + +import java.io.File + +private val DATA_CONTAINER_VERSION_FILE_NAME = "data-container-format-version.txt" +private val DATA_CONTAINER_VERSION = 5 + +fun lookupsCacheVersionManager(dataRoot: File, isEnabled: Boolean) = + CacheVersionManager( + File(dataRoot, DATA_CONTAINER_VERSION_FILE_NAME), + if (isEnabled) DATA_CONTAINER_VERSION else null + ) \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storages/externalizers.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storages/externalizers.kt new file mode 100644 index 00000000000..5625caca6fa --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storages/externalizers.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental.storages + +import com.intellij.openapi.util.io.FileUtil +import com.intellij.util.io.IOUtil +import com.intellij.util.io.KeyDescriptor +import gnu.trove.THashSet +import org.jetbrains.jps.incremental.storage.PathStringDescriptor +import org.jetbrains.kotlin.incremental.storage.CollectionExternalizer +import java.io.DataInput +import java.io.DataOutput + +object PathFunctionPairKeyDescriptor : KeyDescriptor { + override fun read(input: DataInput): PathFunctionPair { + val path = IOUtil.readUTF(input) + val function = IOUtil.readUTF(input) + return PathFunctionPair(path, function) + } + + override fun save(output: DataOutput, value: PathFunctionPair) { + IOUtil.writeUTF(output, value.path) + IOUtil.writeUTF(output, value.function) + } + + override fun getHashCode(value: PathFunctionPair): Int = value.hashCode() + + override fun isEqual(val1: PathFunctionPair, val2: PathFunctionPair): Boolean = val1 == val2 +} + +object PathCollectionExternalizer : CollectionExternalizer(PathStringDescriptor(), { THashSet(FileUtil.PATH_HASHING_STRATEGY) }) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storages/values.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storages/values.kt new file mode 100644 index 00000000000..49ec3a59487 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/storages/values.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.incremental.storages + +import com.intellij.openapi.util.io.FileUtil + +class PathFunctionPair( + val path: String, + val function: String +) : Comparable { + override fun compareTo(other: PathFunctionPair): Int { + val pathComp = FileUtil.comparePaths(path, other.path) + + if (pathComp != 0) return pathComp + + return function.compareTo(other.function) + } + + override fun equals(other: Any?): Boolean = + when (other) { + is PathFunctionPair -> + FileUtil.pathsEqual(path, other.path) && function == other.function + else -> + false + } + + override fun hashCode(): Int = 31 * FileUtil.pathHashCode(path) + function.hashCode() +} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/ModuleSettings.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/ModuleSettings.kt new file mode 100644 index 00000000000..1e8deea43fe --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/ModuleSettings.kt @@ -0,0 +1,117 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.model + +import org.jetbrains.jps.model.ex.JpsElementBase +import org.jetbrains.jps.model.ex.JpsElementChildRoleBase +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.kotlin.cli.common.arguments.* +import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.platform.TargetPlatform + +val JpsModule.kotlinFacet: JpsKotlinFacetModuleExtension? + get() = container.getChild(JpsKotlinFacetModuleExtension.KIND) + +val JpsModule.platform: TargetPlatform? + get() = kotlinFacet?.settings?.targetPlatform + +val JpsModule.kotlinKind: KotlinModuleKind + get() = kotlinFacet?.settings?.kind ?: KotlinModuleKind.DEFAULT + +val JpsModule.isTestModule: Boolean + get() = kotlinFacet?.settings?.isTestModule ?: false + +/** + * Modules which is imported from sources sets of the compilation represented by this module. + * This module is not included. + */ +val JpsModule.sourceSetModules: List + get() = findDependencies(kotlinFacet?.settings?.sourceSetNames) + +/** + * Legacy. List of modules with `expectedBy` dependency. + */ +val JpsModule.expectedByModules: List + get() = findDependencies(kotlinFacet?.settings?.implementedModuleNames) + +private fun JpsModule.findDependencies(moduleNames: List?): List { + if (moduleNames == null || moduleNames.isEmpty()) return listOf() + + val result = mutableSetOf() + + JpsJavaExtensionService.dependencies(this) + .processModules { + if (it.name in moduleNames) { + // Note, production sources should be added for both production and tests targets + result.add(it) + } + } + + return result.toList() +} + +val JpsModule.productionOutputFilePath: String? + get() { + val facetSettings = kotlinFacet?.settings ?: return null + if (facetSettings.useProjectSettings) return null + return facetSettings.productionOutputPath + } + +val JpsModule.testOutputFilePath: String? + get() { + val facetSettings = kotlinFacet?.settings ?: return null + if (facetSettings.useProjectSettings) return null + return facetSettings.testOutputPath + } + +val JpsModule.kotlinCompilerSettings: CompilerSettings + get() { + val defaultSettings = copyBean(project.kotlinCompilerSettings) + val facetSettings = kotlinFacet?.settings ?: return defaultSettings + if (facetSettings.useProjectSettings) return defaultSettings + return facetSettings.compilerSettings ?: defaultSettings + } + +val JpsModule.kotlinCompilerArguments + get() = getCompilerArguments() + +val JpsModule.k2MetadataCompilerArguments + get() = getCompilerArguments() + +val JpsModule.k2JsCompilerArguments + get() = getCompilerArguments() + +val JpsModule.k2JvmCompilerArguments + get() = getCompilerArguments() + +private inline fun JpsModule.getCompilerArguments(): T { + val projectSettings = project.kotlinCompilerSettingsContainer[T::class.java] + val projectSettingsCopy = copyBean(projectSettings) + + val facetSettings = kotlinFacet?.settings ?: return projectSettingsCopy + if (facetSettings.useProjectSettings) return projectSettingsCopy + facetSettings.updateMergedArguments() + return facetSettings.mergedCompilerArguments as? T ?: projectSettingsCopy +} + +class JpsKotlinFacetModuleExtension(settings: KotlinFacetSettings) : JpsElementBase() { + var settings = settings + private set + + companion object { + val KIND = JpsElementChildRoleBase.create("kotlin facet extension") + // These must be changed in sync with KotlinFacetType.TYPE_ID and KotlinFacetType.NAME + val FACET_TYPE_ID = "kotlin-language" + val FACET_NAME = "Kotlin" + } + + override fun createCopy() = JpsKotlinFacetModuleExtension(settings) + + override fun applyChanges(modified: JpsKotlinFacetModuleExtension) { + this.settings = modified.settings + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/ProjectSettings.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/ProjectSettings.kt new file mode 100644 index 00000000000..39373136e48 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/ProjectSettings.kt @@ -0,0 +1,91 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.model + +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.ex.JpsElementBase +import org.jetbrains.jps.model.ex.JpsElementChildRoleBase +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.config.CompilerSettings + +var JpsProject.kotlinCompilerSettings + get() = kotlinCompilerSettingsContainer.compilerSettings + internal set(value) { + getOrCreateSettings().compilerSettings = value + } + +var JpsProject.kotlinCommonCompilerArguments + get() = kotlinCompilerSettingsContainer.commonCompilerArguments + internal set(value) { + getOrCreateSettings().commonCompilerArguments = value + } + +var JpsProject.k2MetadataCompilerArguments + get() = kotlinCompilerSettingsContainer.k2MetadataCompilerArguments + internal set(value) { + getOrCreateSettings().k2MetadataCompilerArguments = value + } + +var JpsProject.k2JsCompilerArguments + get() = kotlinCompilerSettingsContainer.k2JsCompilerArguments + internal set(value) { + getOrCreateSettings().k2JsCompilerArguments = value + } + +var JpsProject.k2JvmCompilerArguments + get() = kotlinCompilerSettingsContainer.k2JvmCompilerArguments + internal set(value) { + getOrCreateSettings().k2JvmCompilerArguments = value + } + +internal val JpsProject.kotlinCompilerSettingsContainer + get() = container.getChild(JpsKotlinCompilerSettings.ROLE) ?: JpsKotlinCompilerSettings() + +private fun JpsProject.getOrCreateSettings(): JpsKotlinCompilerSettings { + var settings = container.getChild(JpsKotlinCompilerSettings.ROLE) + if (settings == null) { + settings = JpsKotlinCompilerSettings() + container.setChild(JpsKotlinCompilerSettings.ROLE, settings) + } + return settings +} + +class JpsKotlinCompilerSettings : JpsElementBase() { + internal var commonCompilerArguments: CommonCompilerArguments = CommonCompilerArguments.DummyImpl() + internal var k2MetadataCompilerArguments = K2MetadataCompilerArguments() + internal var k2JvmCompilerArguments = K2JVMCompilerArguments() + internal var k2JsCompilerArguments = K2JSCompilerArguments() + internal var compilerSettings = CompilerSettings() + + @Suppress("UNCHECKED_CAST") + internal operator fun get(compilerArgumentsClass: Class): T = when (compilerArgumentsClass) { + K2MetadataCompilerArguments::class.java -> k2MetadataCompilerArguments as T + K2JVMCompilerArguments::class.java -> k2JvmCompilerArguments as T + K2JSCompilerArguments::class.java -> k2JsCompilerArguments as T + else -> commonCompilerArguments as T + } + + override fun createCopy(): JpsKotlinCompilerSettings { + val copy = JpsKotlinCompilerSettings() + copy.commonCompilerArguments = this.commonCompilerArguments + copy.k2MetadataCompilerArguments = this.k2MetadataCompilerArguments + copy.k2JvmCompilerArguments = this.k2JvmCompilerArguments + copy.k2JsCompilerArguments = this.k2JsCompilerArguments + copy.compilerSettings = this.compilerSettings + return copy + } + + override fun applyChanges(modified: JpsKotlinCompilerSettings) { + // do nothing + } + + companion object { + internal val ROLE = JpsElementChildRoleBase.create("Kotlin Compiler Settings") + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/Serializer.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/Serializer.kt new file mode 100644 index 00000000000..01f47614d54 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/model/Serializer.kt @@ -0,0 +1,107 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.model + +import com.intellij.util.xmlb.XmlSerializer +import org.jdom.Element +import org.jetbrains.jps.model.JpsElement +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer +import org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.setApiVersionToLanguageVersionIfNeeded +import org.jetbrains.kotlin.config.* +import java.util.* + +class KotlinModelSerializerService : KotlinCommonJpsModelSerializerExtension() { + override fun getProjectExtensionSerializers() = listOf( + KotlinCommonCompilerArgumentsSerializer(), + Kotlin2JvmCompilerArgumentsSerializer(), + Kotlin2JsCompilerArgumentsSerializer(), + KotlinCompilerSettingsSerializer() + ) + + override fun getFacetConfigurationSerializers() = listOf(JpsKotlinFacetConfigurationSerializer) +} + +object JpsKotlinFacetConfigurationSerializer : JpsFacetConfigurationSerializer( + JpsKotlinFacetModuleExtension.KIND, + JpsKotlinFacetModuleExtension.FACET_TYPE_ID, + JpsKotlinFacetModuleExtension.FACET_NAME +) { + override fun loadExtension( + facetConfigurationElement: Element, + name: String, + parent: JpsElement?, + module: JpsModule + ): JpsKotlinFacetModuleExtension { + return JpsKotlinFacetModuleExtension(deserializeFacetSettings(facetConfigurationElement)) + } + + override fun saveExtension( + extension: JpsKotlinFacetModuleExtension?, + facetConfigurationTag: Element, + module: JpsModule + ) { + (extension as JpsKotlinFacetModuleExtension).settings.serializeFacetSettings(facetConfigurationTag) + } +} + +abstract class BaseJpsCompilerSettingsSerializer( + componentName: String, + private val settingsFactory: () -> T +) : JpsProjectExtensionSerializer(SettingConstants.KOTLIN_COMPILER_SETTINGS_FILE, componentName) { + protected abstract fun onLoad(project: JpsProject, settings: T) + + override fun loadExtension(project: JpsProject, componentTag: Element) { + val settings = settingsFactory().apply { + if (this is CommonCompilerArguments) { + freeArgs = ArrayList() + } + } + XmlSerializer.deserializeInto(settings, componentTag) + onLoad(project, settings) + } + + override fun saveExtension(project: JpsProject, componentTag: Element) { + } +} + +internal class KotlinCompilerSettingsSerializer : BaseJpsCompilerSettingsSerializer( + SettingConstants.KOTLIN_COMPILER_SETTINGS_SECTION, ::CompilerSettings +) { + override fun onLoad(project: JpsProject, settings: CompilerSettings) { + project.kotlinCompilerSettings = settings + } +} + +internal class KotlinCommonCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer( + SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION, CommonCompilerArguments::DummyImpl +) { + override fun onLoad(project: JpsProject, settings: CommonCompilerArguments.DummyImpl) { + settings.setApiVersionToLanguageVersionIfNeeded() + project.kotlinCommonCompilerArguments = settings + } +} + +internal class Kotlin2JsCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer( + SettingConstants.KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION, ::K2JSCompilerArguments +) { + override fun onLoad(project: JpsProject, settings: K2JSCompilerArguments) { + project.k2JsCompilerArguments = settings + } +} + +internal class Kotlin2JvmCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer( + SettingConstants.KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION, ::K2JVMCompilerArguments +) { + override fun onLoad(project: JpsProject, settings: K2JVMCompilerArguments) { + project.k2JvmCompilerArguments = settings + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinCommonModuleBuildTarget.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinCommonModuleBuildTarget.kt new file mode 100644 index 00000000000..001f9555df9 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinCommonModuleBuildTarget.kt @@ -0,0 +1,110 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.targets + +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.build.CommonBuildMetaInfo +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner +import org.jetbrains.kotlin.jps.build.KotlinCompileContext +import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder +import org.jetbrains.kotlin.jps.build.ModuleBuildTarget +import org.jetbrains.kotlin.jps.model.k2MetadataCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings + +private const val COMMON_BUILD_META_INFO_FILE_NAME = "common-build-meta-info.txt" + +class KotlinCommonModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleBuildTarget: ModuleBuildTarget) : + KotlinModuleBuildTarget(kotlinContext, jpsModuleBuildTarget) { + + override fun isEnabled(chunkCompilerArguments: CommonCompilerArguments): Boolean { + val k2MetadataArguments = module.k2MetadataCompilerArguments + return k2MetadataArguments.enabledInJps || (chunkCompilerArguments as? K2MetadataCompilerArguments)?.enabledInJps == true + } + + override val isIncrementalCompilationEnabled: Boolean + get() = false + + override val buildMetaInfoFactory + get() = CommonBuildMetaInfo + + override val buildMetaInfoFileName + get() = COMMON_BUILD_META_INFO_FILE_NAME + + override val globalLookupCacheId: String + get() = "metadata-compiler" + + override fun compileModuleChunk( + commonArguments: CommonCompilerArguments, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + environment: JpsCompilerEnvironment + ): Boolean { + require(chunk.representativeTarget == this) + + reportAndSkipCircular(environment) + + JpsKotlinCompilerRunner().runK2MetadataCompiler( + commonArguments, + module.k2MetadataCompilerArguments, + module.kotlinCompilerSettings, + environment, + destination, + dependenciesOutputDirs + libraryFiles, + sourceFiles // incremental K2MetadataCompiler not supported yet + ) + + return true + } + + private val libraryFiles: List + get() = mutableListOf().also { result -> + for (library in allDependencies.libraries) { + for (root in library.getRoots(JpsOrderRootType.COMPILED)) { + result.add(JpsPathUtil.urlToPath(root.url)) + } + } + } + + private val dependenciesOutputDirs: List + get() = mutableListOf().also { result -> + allDependencies.processModules { module -> + if (isTests) addDependencyMetaFile(module, result, isTests = true) + + // note: production targets should be also added as dependency to test targets + addDependencyMetaFile(module, result, isTests = false) + } + } + + val destination: String + get() = module.k2MetadataCompilerArguments.destination ?: outputDir.absolutePath + + private fun addDependencyMetaFile( + module: JpsModule, + result: MutableList, + isTests: Boolean + ) { + val dependencyBuildTarget = kotlinContext.targetsBinding[ModuleBuildTarget(module, isTests)] + + if (dependencyBuildTarget != this@KotlinCommonModuleBuildTarget && + dependencyBuildTarget is KotlinCommonModuleBuildTarget && + dependencyBuildTarget.sources.isNotEmpty() + ) { + result.add(dependencyBuildTarget.destination) + } + } + + override val hasCaches: Boolean + get() = false + + override fun createCacheStorage(paths: BuildDataPaths) = + error("incremental K2MetadataCompiler not supported yet, createCacheStorage() should not be called") +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJsModuleBuildTarget.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJsModuleBuildTarget.kt new file mode 100644 index 00000000000..6c94a735e4b --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJsModuleBuildTarget.kt @@ -0,0 +1,230 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.targets + +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.build.GeneratedFile +import org.jetbrains.kotlin.build.JsBuildMetaInfo +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.incremental.ChangesCollector +import org.jetbrains.kotlin.incremental.IncrementalJsCache +import org.jetbrains.kotlin.incremental.components.ExpectActualTracker +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider +import org.jetbrains.kotlin.incremental.js.IncrementalDataProviderFromCache +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl +import org.jetbrains.kotlin.jps.build.KotlinCompileContext +import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder +import org.jetbrains.kotlin.jps.build.ModuleBuildTarget +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalJsCache +import org.jetbrains.kotlin.jps.model.k2JsCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings +import org.jetbrains.kotlin.jps.model.productionOutputFilePath +import org.jetbrains.kotlin.jps.model.testOutputFilePath +import org.jetbrains.kotlin.utils.JsLibraryUtils +import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.JS_EXT +import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.META_JS_SUFFIX +import java.io.File +import java.net.URI + +private const val JS_BUILD_META_INFO_FILE_NAME = "js-build-meta-info.txt" + +class KotlinJsModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleBuildTarget: ModuleBuildTarget) : + KotlinModuleBuildTarget(kotlinContext, jpsModuleBuildTarget) { + override val globalLookupCacheId: String + get() = "js" + + override val isIncrementalCompilationEnabled: Boolean + get() = IncrementalCompilation.isEnabledForJs() + + override val buildMetaInfoFactory + get() = JsBuildMetaInfo + + override val buildMetaInfoFileName: String + get() = JS_BUILD_META_INFO_FILE_NAME + + val isFirstBuild: Boolean + get() { + val targetDataRoot = jpsGlobalContext.projectDescriptor.dataManager.dataPaths.getTargetDataRoot(jpsModuleBuildTarget) + return !IncrementalJsCache.hasHeaderFile(targetDataRoot) + } + + override fun makeServices( + builder: Services.Builder, + incrementalCaches: Map, JpsIncrementalCache>, + lookupTracker: LookupTracker, + exceptActualTracer: ExpectActualTracker + ) { + super.makeServices(builder, incrementalCaches, lookupTracker, exceptActualTracer) + + with(builder) { + register(IncrementalResultsConsumer::class.java, IncrementalResultsConsumerImpl()) + + if (isIncrementalCompilationEnabled && !isFirstBuild) { + val cache = incrementalCaches[this@KotlinJsModuleBuildTarget] as IncrementalJsCache + + register( + IncrementalDataProvider::class.java, + IncrementalDataProviderFromCache(cache) + ) + } + } + } + + override fun compileModuleChunk( + commonArguments: CommonCompilerArguments, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + environment: JpsCompilerEnvironment + ): Boolean { + require(chunk.representativeTarget == this) + + if (reportAndSkipCircular(environment)) return false + + val sources = collectSourcesToCompile(dirtyFilesHolder) + + if (!sources.logFiles()) { + return false + } + + val libraries = libraryFiles + dependenciesMetaFiles + + JpsKotlinCompilerRunner().runK2JsCompiler( + commonArguments, + module.k2JsCompilerArguments, + module.kotlinCompilerSettings, + environment, + sources.allFiles, + sources.crossCompiledFiles, + sourceMapRoots, + libraries, + friendBuildTargetsMetaFiles, + outputFile + ) + + return true + } + + override fun doAfterBuild() { + copyJsLibraryFilesIfNeeded() + } + + private fun copyJsLibraryFilesIfNeeded() { + if (module.kotlinCompilerSettings.copyJsLibraryFiles) { + val outputLibraryRuntimeDirectory = File(outputDir, module.kotlinCompilerSettings.outputDirectoryForJsLibraryFiles).absolutePath + JsLibraryUtils.copyJsFilesFromLibraries( + libraryFiles, outputLibraryRuntimeDirectory, + copySourceMap = module.k2JsCompilerArguments.sourceMap + ) + } + } + + private val sourceMapRoots: List + get() { + // Compiler starts to produce path relative to base dirs in source maps if at least one statement is true: + // 1) base dirs are specified; + // 2) prefix is specified (i.e. non-empty) + // Otherwise compiler produces paths relative to source maps location. + // We don't have UI to configure base dirs, but we have UI to configure prefix. + // If prefix is not specified (empty) in UI, we want to produce paths relative to source maps location + return if (module.k2JsCompilerArguments.sourceMapPrefix.isNullOrBlank()) emptyList() + else module.contentRootsList.urls + .map { URI.create(it) } + .filter { it.scheme == "file" } + .map { File(it.path) } + } + + val friendBuildTargetsMetaFiles + get() = friendBuildTargets.mapNotNull { + (it as? KotlinJsModuleBuildTarget)?.outputMetaFile?.absoluteFile?.toString() + } + + val outputFile + get() = explicitOutputPath?.let { File(it) } ?: implicitOutputFile + + private val explicitOutputPath + get() = if (isTests) module.testOutputFilePath else module.productionOutputFilePath + + private val implicitOutputFile: File + get() { + val suffix = if (isTests) "_test" else "" + + return File(outputDir, module.name + suffix + JS_EXT) + } + + private val outputFileBaseName: String + get() = outputFile.path.substringBeforeLast(".") + + val outputMetaFile: File + get() = File(outputFileBaseName + META_JS_SUFFIX) + + private val libraryFiles: List + get() = mutableListOf().also { result -> + for (library in allDependencies.libraries) { + for (root in library.getRoots(JpsOrderRootType.COMPILED)) { + result.add(JpsPathUtil.urlToPath(root.url)) + } + } + } + + private val dependenciesMetaFiles: List + get() = mutableListOf().also { result -> + allDependencies.processModules { module -> + if (isTests) addDependencyMetaFile(module, result, isTests = true) + + // note: production targets should be also added as dependency to test targets + addDependencyMetaFile(module, result, isTests = false) + } + } + + private fun addDependencyMetaFile( + module: JpsModule, + result: MutableList, + isTests: Boolean + ) { + val dependencyBuildTarget = kotlinContext.targetsBinding[ModuleBuildTarget(module, isTests)] + + if (dependencyBuildTarget != this@KotlinJsModuleBuildTarget && + dependencyBuildTarget is KotlinJsModuleBuildTarget && + dependencyBuildTarget.sources.isNotEmpty() + ) { + val metaFile = dependencyBuildTarget.outputMetaFile + if (metaFile.exists()) { + result.add(metaFile.absolutePath) + } + } + } + + override fun createCacheStorage(paths: BuildDataPaths) = + JpsIncrementalJsCache(jpsModuleBuildTarget, paths, kotlinContext.fileToPathConverter) + + override fun updateCaches( + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + jpsIncrementalCache: JpsIncrementalCache, + files: List, + changesCollector: ChangesCollector, + environment: JpsCompilerEnvironment + ) { + super.updateCaches(dirtyFilesHolder, jpsIncrementalCache, files, changesCollector, environment) + + val incrementalResults = environment.services[IncrementalResultsConsumer::class.java] as IncrementalResultsConsumerImpl + + val jsCache = jpsIncrementalCache as IncrementalJsCache + jsCache.header = incrementalResults.headerMetadata + + jsCache.compareAndUpdate(incrementalResults, changesCollector) + jsCache.clearCacheForRemovedClasses(changesCollector) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJvmModuleBuildTarget.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJvmModuleBuildTarget.kt new file mode 100644 index 00000000000..2464d4f46f3 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJvmModuleBuildTarget.kt @@ -0,0 +1,376 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.targets + +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.text.StringUtil +import com.intellij.openapi.vfs.StandardFileSystems +import com.intellij.util.containers.ContainerUtil +import com.intellij.util.io.URLUtil +import gnu.trove.THashSet +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.builders.java.JavaBuilderUtil +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.* +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsSdkDependency +import org.jetbrains.jps.service.JpsServiceManager +import org.jetbrains.kotlin.build.GeneratedFile +import org.jetbrains.kotlin.build.GeneratedJvmClass +import org.jetbrains.kotlin.build.JvmBuildMetaInfo +import org.jetbrains.kotlin.build.JvmSourceRoot +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment +import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner +import org.jetbrains.kotlin.config.IncrementalCompilation +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.incremental.* +import org.jetbrains.kotlin.incremental.components.ExpectActualTracker +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.jps.build.KotlinBuilder +import org.jetbrains.kotlin.jps.build.KotlinCompileContext +import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalJvmCache +import org.jetbrains.kotlin.jps.model.k2JvmCompilerArguments +import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings +import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache +import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents +import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder +import org.jetbrains.kotlin.modules.TargetId +import org.jetbrains.kotlin.utils.keysToMap +import org.jetbrains.org.objectweb.asm.ClassReader +import java.io.File +import java.io.IOException +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths + +private const val JVM_BUILD_META_INFO_FILE_NAME = "jvm-build-meta-info.txt" + +class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleBuildTarget: ModuleBuildTarget) : + KotlinModuleBuildTarget(kotlinContext, jpsModuleBuildTarget) { + + override val isIncrementalCompilationEnabled: Boolean + get() = IncrementalCompilation.isEnabledForJvm() + + override fun createCacheStorage(paths: BuildDataPaths) = + JpsIncrementalJvmCache(jpsModuleBuildTarget, paths, kotlinContext.fileToPathConverter) + + override val buildMetaInfoFactory + get() = JvmBuildMetaInfo + + override val buildMetaInfoFileName + get() = JVM_BUILD_META_INFO_FILE_NAME + + override val targetId: TargetId + get() { + val moduleName = module.k2JvmCompilerArguments.moduleName + return if (moduleName != null) TargetId(moduleName, jpsModuleBuildTarget.targetType.typeId) + else super.targetId + } + + override fun makeServices( + builder: Services.Builder, + incrementalCaches: Map, JpsIncrementalCache>, + lookupTracker: LookupTracker, + exceptActualTracer: ExpectActualTracker + ) { + super.makeServices(builder, incrementalCaches, lookupTracker, exceptActualTracer) + + with(builder) { + register( + IncrementalCompilationComponents::class.java, + @Suppress("UNCHECKED_CAST") + IncrementalCompilationComponentsImpl( + incrementalCaches.mapKeys { it.key.targetId } as Map + ) + ) + } + } + + override fun compileModuleChunk( + commonArguments: CommonCompilerArguments, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + environment: JpsCompilerEnvironment + ): Boolean { + require(chunk.representativeTarget == this) + + if (chunk.targets.size > 1) { + environment.messageCollector.report( + CompilerMessageSeverity.STRONG_WARNING, + "Circular dependencies are only partially supported. " + + "The following modules depend on each other: ${chunk.presentableShortName}. " + + "Kotlin will compile them, but some strange effect may happen" + ) + } + + val filesSet = dirtyFilesHolder.allDirtyFiles + + val moduleFile = generateChunkModuleDescription(dirtyFilesHolder) + if (moduleFile == null) { + if (KotlinBuilder.LOG.isDebugEnabled) { + KotlinBuilder.LOG.debug( + "Not compiling, because no files affected: " + chunk.presentableShortName + ) + } + + // No Kotlin sources found + return false + } + + val module = chunk.representativeTarget.module + + if (KotlinBuilder.LOG.isDebugEnabled) { + val totalRemovedFiles = dirtyFilesHolder.allRemovedFilesFiles.size + KotlinBuilder.LOG.debug( + "Compiling to JVM ${filesSet.size} files" + + (if (totalRemovedFiles == 0) "" else " ($totalRemovedFiles removed files)") + + " in " + chunk.presentableShortName + ) + } + + try { + val compilerRunner = JpsKotlinCompilerRunner() + compilerRunner.runK2JvmCompiler( + commonArguments, + module.k2JvmCompilerArguments, + module.kotlinCompilerSettings, + environment, + moduleFile + ) + } finally { + if (System.getProperty(DELETE_MODULE_FILE_PROPERTY) != "false") { + moduleFile.delete() + } + } + + return true + } + + override fun registerOutputItems(outputConsumer: ModuleLevelBuilder.OutputConsumer, outputItems: List) { + if (kotlinContext.isInstrumentationEnabled) { + val (classFiles, nonClassFiles) = outputItems.partition { it is GeneratedJvmClass } + super.registerOutputItems(outputConsumer, nonClassFiles) + + for (output in classFiles) { + val bytes = output.outputFile.readBytes() + val binaryContent = BinaryContent(bytes) + val compiledClass = CompiledClass(output.outputFile, output.sourceFiles, ClassReader(bytes).className, binaryContent) + outputConsumer.registerCompiledClass(jpsModuleBuildTarget, compiledClass) + } + } else { + super.registerOutputItems(outputConsumer, outputItems) + } + } + + private fun generateChunkModuleDescription(dirtyFilesHolder: KotlinDirtySourceFilesHolder): File? { + val builder = KotlinModuleXmlBuilder() + + var hasDirtySources = false + + val targets = chunk.targets + + val outputDirs = targets.map { it.outputDir }.toSet() + + for (target in targets) { + target as KotlinJvmModuleBuildTarget + + val outputDir = target.outputDir + val friendDirs = target.friendOutputDirs + + val sources = target.collectSourcesToCompile(dirtyFilesHolder) + + if (sources.logFiles()) { + hasDirtySources = true + } + + val kotlinModuleId = target.targetId + val allFiles = sources.allFiles + val commonSourceFiles = sources.crossCompiledFiles + + builder.addModule( + kotlinModuleId.name, + outputDir.absolutePath, + preprocessSources(allFiles), + target.findSourceRoots(dirtyFilesHolder.context), + target.findClassPathRoots(), + preprocessSources(commonSourceFiles), + target.findModularJdkRoot(), + kotlinModuleId.type, + isTests, + // this excludes the output directories from the class path, to be removed for true incremental compilation + outputDirs, + friendDirs + ) + } + + if (!hasDirtySources) return null + + val scriptFile = createTempFileForChunkModuleDesc() + FileUtil.writeToFile(scriptFile, builder.asText().toString()) + return scriptFile + } + + /** + * Internal API for source level code preprocessors. + * + * Currently used in https://plugins.jetbrains.com/plugin/13355-spot-profiler-for-java + */ + interface SourcesPreprocessor { + /** + * Preprocess some sources and return path to the resulting file. + * This function should be pure and should return the same output for given input + * (required for incremental compilation). + */ + fun preprocessSources(srcFiles: List): List + } + + fun preprocessSources(srcFiles: List): List { + var result = srcFiles + JpsServiceManager.getInstance().getExtensions(SourcesPreprocessor::class.java).forEach { + result = it.preprocessSources(result) + } + return result + } + + private fun createTempFileForChunkModuleDesc(): File { + val readableSuffix = buildString { + append(StringUtil.sanitizeJavaIdentifier(chunk.representativeTarget.module.name)) + if (chunk.containsTests) { + append("-test") + } + } + + fun createTempFile(dir: Path?, prefix: String?, suffix: String?): Path = + if (dir != null) Files.createTempFile(dir, prefix, suffix) else Files.createTempFile(prefix, suffix) + + val dir = System.getProperty("kotlin.jps.dir.for.module.files")?.let { Paths.get(it) }?.takeIf { Files.isDirectory(it) } + return try { + createTempFile(dir, "kjps", readableSuffix + ".script.xml") + } catch (e: IOException) { + // sometimes files cannot be created, because file name is too long (Windows, Mac OS) + // see https://bugs.openjdk.java.net/browse/JDK-8148023 + try { + createTempFile(dir, "kjps", ".script.xml") + } catch (e: IOException) { + val message = buildString { + append("Could not create module file when building chunk $chunk") + if (dir != null) { + append(" in dir $dir") + } + } + throw RuntimeException(message, e) + } + }.toFile() + } + + private fun findClassPathRoots(): Collection { + return allDependencies.classes().roots.filter { file -> + if (!file.exists()) { + val extension = file.extension + + // Don't filter out files, we want to report warnings about absence through the common place + if (extension != "class" && extension != "jar") { + return@filter false + } + } + + true + } + } + + private fun findModularJdkRoot(): File? { + // List of paths to JRE modules in the following format: + // jrt:///Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home!/java.base + val urls = JpsJavaExtensionService.dependencies(module) + .satisfying { dependency -> dependency is JpsSdkDependency } + .classes().urls + + val url = urls.firstOrNull { it.startsWith(StandardFileSystems.JRT_PROTOCOL_PREFIX) } ?: return null + + return File(url.substringAfter(StandardFileSystems.JRT_PROTOCOL_PREFIX).substringBeforeLast(URLUtil.JAR_SEPARATOR)) + } + + private fun findSourceRoots(context: CompileContext): List { + val roots = context.projectDescriptor.buildRootIndex.getTargetRoots(jpsModuleBuildTarget, context) + val result = ContainerUtil.newArrayList() + for (root in roots) { + val file = root.rootFile + val prefix = root.packagePrefix + if (file.exists()) { + result.add(JvmSourceRoot(file, if (prefix.isEmpty()) null else prefix)) + } + } + return result + } + + override fun updateCaches( + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + jpsIncrementalCache: JpsIncrementalCache, + files: List, + changesCollector: ChangesCollector, + environment: JpsCompilerEnvironment + ) { + super.updateCaches(dirtyFilesHolder, jpsIncrementalCache, files, changesCollector, environment) + + updateIncrementalCache(files, jpsIncrementalCache as IncrementalJvmCache, changesCollector, null) + } + + override val globalLookupCacheId: String + get() = "jvm" + + override fun updateChunkMappings( + localContext: CompileContext, + chunk: ModuleChunk, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + outputItems: Map>, + incrementalCaches: Map, JpsIncrementalCache> + ) { + val previousMappings = localContext.projectDescriptor.dataManager.mappings + val callback = JavaBuilderUtil.getDependenciesRegistrar(localContext) + + val targetDirtyFiles: Map> = chunk.targets.keysToMap { + val files = HashSet() + files.addAll(dirtyFilesHolder.getRemovedFiles(it)) + files.addAll(dirtyFilesHolder.getDirtyFiles(it).keys) + files + } + + fun getOldSourceFiles(target: ModuleBuildTarget, generatedClass: GeneratedJvmClass): Set { + val cache = incrementalCaches[kotlinContext.targetsBinding[target]] ?: return emptySet() + cache as JpsIncrementalJvmCache + + val className = generatedClass.outputClass.className + if (!cache.isMultifileFacade(className)) return emptySet() + + val name = previousMappings.getName(className.internalName) + return previousMappings.getClassSources(name)?.toSet() ?: emptySet() + } + + for ((target, outputs) in outputItems) { + for (output in outputs) { + if (output !is GeneratedJvmClass) continue + + val sourceFiles = THashSet(FileUtil.FILE_HASHING_STRATEGY) + sourceFiles.addAll(getOldSourceFiles(target, output)) + sourceFiles.removeAll(targetDirtyFiles[target] ?: emptySet()) + sourceFiles.addAll(output.sourceFiles) + + callback.associate( + FileUtil.toSystemIndependentName(output.outputFile.canonicalPath), + sourceFiles.map { FileUtil.toSystemIndependentName(it.canonicalPath) }, + ClassReader(output.outputClass.fileContents) + ) + } + } + + val allCompiled = dirtyFilesHolder.allDirtyFiles + JavaBuilderUtil.registerFilesToCompile(localContext, allCompiled) + JavaBuilderUtil.registerSuccessfullyCompiled(localContext, allCompiled) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinModuleBuildTarget.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinModuleBuildTarget.kt new file mode 100644 index 00000000000..b12c39078c0 --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinModuleBuildTarget.kt @@ -0,0 +1,375 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.targets + +import org.jetbrains.jps.ModuleChunk +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.CompileContext +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.incremental.ModuleLevelBuilder +import org.jetbrains.jps.incremental.ProjectBuildException +import org.jetbrains.jps.model.java.JpsJavaClasspathKind +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.build.BuildMetaInfo +import org.jetbrains.kotlin.build.BuildMetaInfoFactory +import org.jetbrains.kotlin.build.GeneratedFile +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment +import org.jetbrains.kotlin.config.ApiVersion +import org.jetbrains.kotlin.config.LanguageVersion +import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.incremental.ChangesCollector +import org.jetbrains.kotlin.incremental.ExpectActualTrackerImpl +import org.jetbrains.kotlin.incremental.components.ExpectActualTracker +import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.jps.build.* +import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache +import org.jetbrains.kotlin.jps.incremental.loadDiff +import org.jetbrains.kotlin.jps.incremental.localCacheVersionManager +import org.jetbrains.kotlin.jps.model.productionOutputFilePath +import org.jetbrains.kotlin.jps.model.testOutputFilePath +import org.jetbrains.kotlin.modules.TargetId +import org.jetbrains.kotlin.progress.CompilationCanceledException +import org.jetbrains.kotlin.progress.CompilationCanceledStatus +import org.jetbrains.kotlin.utils.addIfNotNull +import java.io.File + +/** + * Properties and actions for Kotlin test / production module build target. + */ +abstract class KotlinModuleBuildTarget internal constructor( + val kotlinContext: KotlinCompileContext, + val jpsModuleBuildTarget: ModuleBuildTarget +) { + /** + * Note: beware of using this context for getting compilation round dependent data: + * for example groovy can provide temp source roots with stubs, and it will be visible + * only in round local compile context. + * + * TODO(1.2.80): got rid of jpsGlobalContext and replace it with kotlinContext + */ + val jpsGlobalContext: CompileContext + get() = kotlinContext.jpsContext + + // Initialized in KotlinCompileContext.loadTargets + lateinit var chunk: KotlinChunk + + abstract val globalLookupCacheId: String + + abstract val isIncrementalCompilationEnabled: Boolean + + open fun isEnabled(chunkCompilerArguments: CommonCompilerArguments): Boolean = true + + @Suppress("LeakingThis") + val localCacheVersionManager = localCacheVersionManager( + kotlinContext.dataPaths.getTargetDataRoot(jpsModuleBuildTarget), + isIncrementalCompilationEnabled + ) + + val initialLocalCacheAttributesDiff: CacheAttributesDiff<*> = localCacheVersionManager.loadDiff() + + val module: JpsModule + get() = jpsModuleBuildTarget.module + + val isTests: Boolean + get() = jpsModuleBuildTarget.isTests + + open val targetId: TargetId + get() { + // Since IDEA 2016 each gradle source root is imported as a separate module. + // One gradle module X is imported as two JPS modules: + // 1. X-production with one production target; + // 2. X-test with one test target. + // This breaks kotlin code since internal members' names are mangled using module name. + // For example, a declaration of a function 'f' in 'X-production' becomes 'fXProduction', but a call 'f' in 'X-test' becomes 'fXTest()'. + // The workaround is to replace a name of such test target with the name of corresponding production module. + // See KT-11993. + val name = relatedProductionModule?.name ?: jpsModuleBuildTarget.id + return TargetId(name, jpsModuleBuildTarget.targetType.typeId) + } + + val outputDir by lazy { + val explicitOutputPath = if (isTests) module.testOutputFilePath else module.productionOutputFilePath + val explicitOutputDir = explicitOutputPath?.let { File(it).absoluteFile.parentFile } + return@lazy explicitOutputDir + ?: jpsModuleBuildTarget.outputDir + ?: throw ProjectBuildException("No output directory found for " + this) + } + + val friendBuildTargets: List> + get() { + val result = mutableListOf>() + + if (isTests) { + result.addIfNotNull(kotlinContext.targetsBinding[module.productionBuildTarget]) + result.addIfNotNull(kotlinContext.targetsBinding[relatedProductionModule?.productionBuildTarget]) + } + + return result.filter { it.sources.isNotEmpty() } + } + + val friendOutputDirs: List + get() = friendBuildTargets.mapNotNull { + JpsJavaExtensionService.getInstance().getOutputDirectory(it.module, false) + } + + private val relatedProductionModule: JpsModule? + get() = JpsJavaExtensionService.getInstance().getTestModuleProperties(module)?.productionModule + + data class Dependency( + val src: KotlinModuleBuildTarget<*>, + val target: KotlinModuleBuildTarget<*>, + val exported: Boolean + ) + + // TODO(1.2.80): try replace allDependencies with KotlinChunk.collectDependentChunksRecursivelyExportedOnly + @Deprecated("Consider using precalculated KotlinChunk.collectDependentChunksRecursivelyExportedOnly") + val allDependencies by lazy { + JpsJavaExtensionService.dependencies(module).recursively().exportedOnly() + .includedIn(JpsJavaClasspathKind.compile(isTests)) + } + + /** + * All sources of this target (including non dirty). + * + * Lazy initialization is required since value is required only in rare cases. + * + * Before first round initialized lazily based on global context. + * This is required for friend build targets, when friends are not compiled in this build run. + * + * Lazy value will be invalidated on each round (should be recalculated based on round local context). + * Update required since source roots can be changed, for example groovy can provide new temporary source roots with stubs. + * + * Ugly delegation to lazy is used to capture local compile context and reset calculated value. + */ + val sources: Map + get() = _sources.value + + @Volatile + private var _sources: Lazy> = lazy { computeSourcesList(jpsGlobalContext) } + + fun nextRound(localContext: CompileContext) { + _sources = lazy { computeSourcesList(localContext) } + } + + private fun computeSourcesList(localContext: CompileContext): Map { + val result = mutableMapOf() + val moduleExcludes = module.excludeRootsList.urls.mapTo(java.util.HashSet(), JpsPathUtil::urlToFile) + + val compilerExcludes = JpsJavaExtensionService.getInstance() + .getOrCreateCompilerConfiguration(module.project) + .compilerExcludes + + val buildRootIndex = localContext.projectDescriptor.buildRootIndex + val roots = buildRootIndex.getTargetRoots(jpsModuleBuildTarget, localContext) + roots.forEach { rootDescriptor -> + val isCrossCompiled = rootDescriptor is KotlinIncludedModuleSourceRoot + + rootDescriptor.root.walkTopDown() + .onEnter { file -> file !in moduleExcludes } + .forEach { file -> + if (!compilerExcludes.isExcluded(file) && file.isFile && file.isKotlinSourceFile) { + result[file] = Source(file, isCrossCompiled) + } + } + + } + + return result + } + + /** + * @property isCrossCompiled sources that are cross-compiled to multiple targets + */ + class Source( + val file: File, + val isCrossCompiled: Boolean + ) + + fun isFromIncludedSourceRoot(file: File): Boolean = sources[file]?.isCrossCompiled == true + + val sourceFiles: Collection + get() = sources.keys + + override fun toString() = jpsModuleBuildTarget.toString() + + /** + * Called for `ModuleChunk.representativeTarget` + */ + abstract fun compileModuleChunk( + commonArguments: CommonCompilerArguments, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + environment: JpsCompilerEnvironment + ): Boolean + + open fun registerOutputItems(outputConsumer: ModuleLevelBuilder.OutputConsumer, outputItems: List) { + for (output in outputItems) { + outputConsumer.registerOutputFile(jpsModuleBuildTarget, output.outputFile, output.sourceFiles.map { it.path }) + } + } + + protected fun reportAndSkipCircular(environment: JpsCompilerEnvironment): Boolean { + if (chunk.targets.size > 1) { + // 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 + environment.messageCollector.report( + CompilerMessageSeverity.STRONG_WARNING, + "Circular dependencies are not supported. The following modules depend on each other: " + + chunk.presentableShortName + " " + + "Kotlin is not compiled for these modules" + ) + + return true + } + + return false + } + + open fun doAfterBuild() { + } + + open val hasCaches: Boolean = true + + abstract fun createCacheStorage(paths: BuildDataPaths): JpsIncrementalCache + + /** + * Called for `ModuleChunk.representativeTarget` + */ + open fun updateChunkMappings( + localContext: CompileContext, + chunk: ModuleChunk, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + outputItems: Map>, + incrementalCaches: Map, JpsIncrementalCache> + ) { + // by default do nothing + } + + open fun updateCaches( + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + jpsIncrementalCache: JpsIncrementalCache, + files: List, + changesCollector: ChangesCollector, + environment: JpsCompilerEnvironment + ) { + val changedAndRemovedFiles = dirtyFilesHolder.getDirtyFiles(jpsModuleBuildTarget).keys + + dirtyFilesHolder.getRemovedFiles(jpsModuleBuildTarget) + val expectActualTracker = environment.services[ExpectActualTracker::class.java] as ExpectActualTrackerImpl + + jpsIncrementalCache.updateComplementaryFiles(changedAndRemovedFiles, expectActualTracker) + } + + open fun makeServices( + builder: Services.Builder, + incrementalCaches: Map, JpsIncrementalCache>, + lookupTracker: LookupTracker, + exceptActualTracer: ExpectActualTracker + ) { + with(builder) { + register(LookupTracker::class.java, lookupTracker) + register(ExpectActualTracker::class.java, exceptActualTracer) + register(CompilationCanceledStatus::class.java, object : CompilationCanceledStatus { + override fun checkCanceled() { + if (jpsGlobalContext.cancelStatus.isCanceled) throw CompilationCanceledException() + } + }) + } + } + + /** + * Should be used only for particular target in chunk (jvm) + * + * Should not be cached since may be vary in different rounds. + */ + protected fun collectSourcesToCompile( + dirtyFilesHolder: KotlinDirtySourceFilesHolder + ) = SourcesToCompile( + sources = when { + chunk.representativeTarget.isIncrementalCompilationEnabled -> + dirtyFilesHolder.getDirtyFiles(jpsModuleBuildTarget).values + else -> sources.values + }, + removedFiles = dirtyFilesHolder.getRemovedFiles(jpsModuleBuildTarget) + ) + + inner class SourcesToCompile( + sources: Collection, + val removedFiles: Collection + ) { + val allFiles = sources.map { it.file } + val crossCompiledFiles = sources.filter { it.isCrossCompiled }.map { it.file } + + /** + * @return true, if there are removed files or files to compile + */ + fun logFiles(): Boolean { + val hasRemovedSources = removedFiles.isNotEmpty() + val hasDirtyOrRemovedSources = allFiles.isNotEmpty() || hasRemovedSources + + if (hasDirtyOrRemovedSources) { + val logger = jpsGlobalContext.loggingManager.projectBuilderLogger + if (logger.isEnabled) { + logger.logCompiledFiles(allFiles, KotlinBuilder.KOTLIN_BUILDER_NAME, "Compiling files:") + } + } + + return hasDirtyOrRemovedSources + } + } + + abstract val buildMetaInfoFactory: BuildMetaInfoFactory + + abstract val buildMetaInfoFileName: String + + fun isVersionChanged(chunk: KotlinChunk, buildMetaInfo: BuildMetaInfo): Boolean { + val file = chunk.buildMetaInfoFile(jpsModuleBuildTarget) + if (!file.exists()) return false + + val prevBuildMetaInfo = + try { + buildMetaInfoFactory.deserializeFromString(file.readText()) ?: return false + } catch (e: Exception) { + KotlinBuilder.LOG.error("Could not deserialize build meta info", e) + return false + } + + val prevLangVersion = LanguageVersion.fromVersionString(prevBuildMetaInfo.languageVersionString) + val prevApiVersion = ApiVersion.parse(prevBuildMetaInfo.apiVersionString) + + val reasonToRebuild = when { + chunk.langVersion != prevLangVersion -> "Language version was changed ($prevLangVersion -> ${chunk.langVersion})" + chunk.apiVersion != prevApiVersion -> "Api version was changed ($prevApiVersion -> ${chunk.apiVersion})" + prevLangVersion != LanguageVersion.KOTLIN_1_0 && prevBuildMetaInfo.isEAP && !buildMetaInfo.isEAP -> { + // If EAP->Non-EAP build with IC, then rebuild all kotlin + "Last build was compiled with EAP-plugin" + } + else -> null + } + + if (reasonToRebuild != null) { + KotlinBuilder.LOG.info("$reasonToRebuild. Performing non-incremental rebuild (kotlin only)") + return true + } + + return false + } + + private fun checkRepresentativeTarget(chunk: KotlinChunk) { + check(chunk.representativeTarget == this) + } + + private fun checkRepresentativeTarget(chunk: ModuleChunk) { + check(chunk.representativeTarget() == jpsModuleBuildTarget) + } + + private fun checkRepresentativeTarget(chunk: List>) { + check(chunk.first() == this) + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinTargetsIndex.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinTargetsIndex.kt new file mode 100644 index 00000000000..7457f3fe9dc --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinTargetsIndex.kt @@ -0,0 +1,179 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.targets + +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.jps.model.java.JpsJavaClasspathKind +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.jps.build.KotlinBuilder +import org.jetbrains.kotlin.jps.build.KotlinChunk +import org.jetbrains.kotlin.jps.build.KotlinCompileContext +import org.jetbrains.kotlin.jps.build.ModuleBuildTarget +import org.jetbrains.kotlin.jps.model.platform +import org.jetbrains.kotlin.platform.DefaultIdeTargetPlatformKindProvider +import org.jetbrains.kotlin.platform.IdePlatformKind +import org.jetbrains.kotlin.platform.idePlatformKind +import org.jetbrains.kotlin.platform.impl.* +import org.jetbrains.kotlin.utils.LibraryUtils +import kotlin.system.measureTimeMillis + +class KotlinTargetsIndex( + val byJpsTarget: Map>, + val chunks: List, + val chunksByJpsRepresentativeTarget: Map +) + +internal class KotlinTargetsIndexBuilder internal constructor( + private val uninitializedContext: KotlinCompileContext +) { + private val byJpsModuleBuildTarget = mutableMapOf>() + private val isKotlinJsStdlibJar = mutableMapOf() + private val chunks = mutableListOf() + + fun build(): KotlinTargetsIndex { + val time = measureTimeMillis { + val jpsContext = uninitializedContext.jpsContext + + // visit all kotlin build targets + jpsContext.projectDescriptor.buildTargetIndex.getSortedTargetChunks(jpsContext).forEach { chunk -> + val moduleBuildTargets = chunk.targets.mapNotNull { + if (it is ModuleBuildTarget) ensureLoaded(it) + else null + } + + if (moduleBuildTargets.isNotEmpty()) { + val kotlinChunk = KotlinChunk(uninitializedContext, moduleBuildTargets) + moduleBuildTargets.forEach { + it.chunk = kotlinChunk + } + + chunks.add(kotlinChunk) + } + } + + calculateChunkDependencies() + } + + KotlinBuilder.LOG.info("KotlinTargetsIndex created in $time ms") + + return KotlinTargetsIndex( + byJpsModuleBuildTarget, + chunks, + chunks.associateBy { it.representativeTarget.jpsModuleBuildTarget } + ) + } + + private fun calculateChunkDependencies() { + chunks.forEach { chunk -> + val dependencies = mutableSetOf() + + chunk.targets.forEach { + dependencies.addAll(calculateTargetDependencies(it)) + } + + chunk.dependencies = dependencies.toList() + chunk.dependencies.forEach { dependency -> + dependency.target.chunk._dependent!!.add(dependency) + } + } + + chunks.forEach { + it.dependent = it._dependent!!.toList() + it._dependent = null + } + } + + private fun calculateTargetDependencies(srcTarget: KotlinModuleBuildTarget<*>): List { + val dependencies = mutableListOf() + val classpathKind = JpsJavaClasspathKind.compile(srcTarget.isTests) + + // TODO(1.2.80): Ask for JPS API + // Unfortunately JPS has no API for accessing "exported" flag while enumerating module dependencies, + // but has API for getting all and exported only dependent modules. + // So, lets first get set of all dependent targets, then remove exported only. + val dependentTargets = mutableSetOf>() + + JpsJavaExtensionService.dependencies(srcTarget.module) + .includedIn(classpathKind) + .processModules { destModule -> + val destKotlinTarget = byJpsModuleBuildTarget[ModuleBuildTarget(destModule, srcTarget.isTests)] + if (destKotlinTarget != null) { + dependentTargets.add(destKotlinTarget) + } + } + + JpsJavaExtensionService.dependencies(srcTarget.module) + .includedIn(classpathKind) + .exportedOnly() + .processModules { module -> + val destKotlinTarget = byJpsModuleBuildTarget[ModuleBuildTarget(module, srcTarget.isTests)] + if (destKotlinTarget != null) { + dependentTargets.remove(destKotlinTarget) + dependencies.add(KotlinModuleBuildTarget.Dependency(srcTarget, destKotlinTarget, true)) + } + } + + dependentTargets.forEach { destTarget -> + dependencies.add(KotlinModuleBuildTarget.Dependency(srcTarget, destTarget, false)) + } + + if (srcTarget.isTests) { + val srcProductionTarget = byJpsModuleBuildTarget[ModuleBuildTarget(srcTarget.module, false)] + if (srcProductionTarget != null) { + dependencies.add(KotlinModuleBuildTarget.Dependency(srcTarget, srcProductionTarget, true)) + } + } + + return dependencies + } + + + private fun ensureLoaded(target: ModuleBuildTarget): KotlinModuleBuildTarget<*> { + return byJpsModuleBuildTarget.computeIfAbsent(target) { + val platform = target.module.platform?.idePlatformKind ?: detectTargetPlatform(target) + + when { + platform.isCommon -> KotlinCommonModuleBuildTarget(uninitializedContext, target) + platform.isJavaScript -> KotlinJsModuleBuildTarget(uninitializedContext, target) + platform.isJvm -> KotlinJvmModuleBuildTarget(uninitializedContext, target) + else -> KotlinUnsupportedModuleBuildTarget(uninitializedContext, target) + } + } + } + + /** + * Compatibility for KT-14082 + * todo: remove when all projects migrated to facets + */ + private fun detectTargetPlatform(target: ModuleBuildTarget): IdePlatformKind<*> { + if (hasJsStdLib(target)) return JsIdePlatformKind + + return DefaultIdeTargetPlatformKindProvider.defaultPlatform.idePlatformKind + } + + private fun hasJsStdLib(target: ModuleBuildTarget): Boolean { + JpsJavaExtensionService.dependencies(target.module) + .recursively() + .exportedOnly() + .includedIn(JpsJavaClasspathKind.compile(target.isTests)) + .libraries + .forEach { library -> + for (root in library.getRoots(JpsOrderRootType.COMPILED)) { + val url = root.url + + val isKotlinJsLib = isKotlinJsStdlibJar.computeIfAbsent(url) { + LibraryUtils.isKotlinJavascriptStdLibrary(JpsPathUtil.urlToFile(url)) + } + + if (isKotlinJsLib) return true + } + } + + return false + } +} \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinUnsupportedModuleBuildTarget.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinUnsupportedModuleBuildTarget.kt new file mode 100644 index 00000000000..a1154e6fc1c --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinUnsupportedModuleBuildTarget.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.targets + +import org.jetbrains.jps.builders.storage.BuildDataPaths +import org.jetbrains.jps.incremental.ModuleBuildTarget +import org.jetbrains.kotlin.build.BuildMetaInfo +import org.jetbrains.kotlin.build.BuildMetaInfoFactory +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment +import org.jetbrains.kotlin.jps.build.KotlinCompileContext +import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder +import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache +import org.jetbrains.kotlin.jps.model.platform +import org.jetbrains.kotlin.platform.idePlatformKind + +class KotlinUnsupportedModuleBuildTarget( + kotlinContext: KotlinCompileContext, + jpsModuleBuildTarget: ModuleBuildTarget +) : KotlinModuleBuildTarget(kotlinContext, jpsModuleBuildTarget) { + val kind = module.platform?.idePlatformKind?.name + + private fun shouldNotBeCalled(): Nothing = error("Should not be called") + + override fun isEnabled(chunkCompilerArguments: CommonCompilerArguments): Boolean { + return false + } + + override val isIncrementalCompilationEnabled: Boolean + get() = false + + override val hasCaches: Boolean + get() = false + + override val globalLookupCacheId: String + get() = shouldNotBeCalled() + + override fun compileModuleChunk( + commonArguments: CommonCompilerArguments, + dirtyFilesHolder: KotlinDirtySourceFilesHolder, + environment: JpsCompilerEnvironment + ): Boolean { + shouldNotBeCalled() + } + + override fun createCacheStorage(paths: BuildDataPaths): JpsIncrementalCache { + shouldNotBeCalled() + } + + override val buildMetaInfoFactory: BuildMetaInfoFactory + get() = shouldNotBeCalled() + + override val buildMetaInfoFileName: String + get() = shouldNotBeCalled() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/new.kt new file mode 100644 index 00000000000..969d9f4d5cd --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/new.kt @@ -0,0 +1,20 @@ +package test + +class ClassWithAddedCompanionObject { + public fun unchangedFun() {} + companion object {} +} + +class ClassWithRemovedCompanionObject { + public fun unchangedFun() {} +} + +class ClassWithChangedCompanionObject { + public fun unchangedFun() {} + companion object SecondName {} +} + +class ClassWithChangedVisibilityForCompanionObject { + public fun unchangedFun() {} + private companion object {} +} diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/old.kt new file mode 100644 index 00000000000..93907babbb4 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/old.kt @@ -0,0 +1,21 @@ +package test + +class ClassWithAddedCompanionObject { + public fun unchangedFun() {} +} + +class ClassWithRemovedCompanionObject { + public fun unchangedFun() {} + companion object {} +} + +class ClassWithChangedCompanionObject { + public fun unchangedFun() {} + companion object FirstName {} +} + +class ClassWithChangedVisibilityForCompanionObject { + public fun unchangedFun() {} + public companion object {} +} + diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/result.out new file mode 100644 index 00000000000..4b1b2fd2f9e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithCompanionObjectChanged/result.out @@ -0,0 +1,15 @@ +REMOVED test/ClassWithChangedCompanionObject.FirstName +REMOVED test/ClassWithRemovedCompanionObject.Companion +ADDED test/ClassWithAddedCompanionObject.Companion +ADDED test/ClassWithChangedCompanionObject.SecondName +PROTO DIFFERENCE in test/ClassWithAddedCompanionObject: COMPANION_OBJECT_NAME, NESTED_CLASS_NAME_LIST +CHANGES in test/ClassWithAddedCompanionObject: CLASS_SIGNATURE, MEMBERS + [Companion] +PROTO DIFFERENCE in test/ClassWithChangedCompanionObject: COMPANION_OBJECT_NAME, NESTED_CLASS_NAME_LIST +CHANGES in test/ClassWithChangedCompanionObject: CLASS_SIGNATURE, MEMBERS + [FirstName, SecondName] +PROTO DIFFERENCE in test/ClassWithChangedVisibilityForCompanionObject.Companion: FLAGS +CHANGES in test/ClassWithChangedVisibilityForCompanionObject.Companion: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithRemovedCompanionObject: COMPANION_OBJECT_NAME, NESTED_CLASS_NAME_LIST +CHANGES in test/ClassWithRemovedCompanionObject: CLASS_SIGNATURE, MEMBERS + [Companion] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/new.kt new file mode 100644 index 00000000000..cdd184116b8 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/new.kt @@ -0,0 +1,25 @@ +package test + +class ClassWithPrimaryConstructorChanged constructor(arg: String) { + public fun unchangedFun() {} +} + +class ClassWithPrimaryConstructorVisibilityChanged private constructor() { + public fun unchangedFun() {} +} + +class ClassWithSecondaryConstructorsAdded() { + constructor(arg: Int): this() {} + constructor(arg: String): this() {} + public fun unchangedFun() {} +} + +class ClassWithSecondaryConstructorsRemoved() { + public fun unchangedFun() {} +} + +class ClassWithSecondaryConstructorVisibilityChanged() { + private constructor(arg: Int): this() {} + public fun unchangedFun() {} +} + diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/old.kt new file mode 100644 index 00000000000..86eda90550d --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/old.kt @@ -0,0 +1,24 @@ +package test + +class ClassWithPrimaryConstructorChanged constructor() { + public fun unchangedFun() {} +} + +class ClassWithPrimaryConstructorVisibilityChanged constructor() { + public fun unchangedFun() {} +} + +class ClassWithSecondaryConstructorsAdded { + public fun unchangedFun() {} +} + +class ClassWithSecondaryConstructorsRemoved() { + public constructor(arg: Int): this() {} + constructor(arg: String): this() {} + public fun unchangedFun() {} +} + +class ClassWithSecondaryConstructorVisibilityChanged() { + protected constructor(arg: Int): this() {} + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/result.out new file mode 100644 index 00000000000..c6d44c58290 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithConstructorChanged/result.out @@ -0,0 +1,10 @@ +PROTO DIFFERENCE in test/ClassWithPrimaryConstructorChanged: CONSTRUCTOR_LIST +CHANGES in test/ClassWithPrimaryConstructorChanged: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithPrimaryConstructorVisibilityChanged: CONSTRUCTOR_LIST +CHANGES in test/ClassWithPrimaryConstructorVisibilityChanged: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithSecondaryConstructorVisibilityChanged: CONSTRUCTOR_LIST +CHANGES in test/ClassWithSecondaryConstructorVisibilityChanged: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithSecondaryConstructorsAdded: CONSTRUCTOR_LIST +CHANGES in test/ClassWithSecondaryConstructorsAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithSecondaryConstructorsRemoved: CONSTRUCTOR_LIST +CHANGES in test/ClassWithSecondaryConstructorsRemoved: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/new.kt new file mode 100644 index 00000000000..2eb9659e801 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/new.kt @@ -0,0 +1,31 @@ +package test + +class ClassWithFunAdded { + fun added() {} + public fun unchangedFun() {} +} + +class ClassWithFunRemoved { + public fun unchangedFun() {} +} + +class ClassWithValAndFunAddedAndRemoved { + public val valAdded: String = "" + fun funAdded() {} + public fun unchangedFun() {} +} + +class ClassWithValConvertedToVar { + public var value: Int = 10 + public fun unchangedFun() {} +} + +class ClassWithChangedVisiblityForFun1 { + private fun foo() {} + public fun unchangedFun() {} +} + +class ClassWithChangedVisiblityForFun2 { + protected fun foo() {} + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/old.kt new file mode 100644 index 00000000000..e8ca9bd1db5 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/old.kt @@ -0,0 +1,33 @@ +package test + +class ClassWithFunAdded { + public fun unchangedFun() {} +} + +class ClassWithFunRemoved { + fun removed() {} + public fun unchangedFun() {} +} + +class ClassWithValAndFunAddedAndRemoved { + public val valRemoved: Int = 10 + fun funRemoved() {} + public fun unchangedFun() {} +} + +class ClassWithValConvertedToVar { + public val value: Int = 10 + public fun unchangedFun() {} +} + +class ClassWithChangedVisiblityForFun1 { + protected fun foo() {} + public fun unchangedFun() {} +} + +class ClassWithChangedVisiblityForFun2 { + private fun foo() {} + public fun unchangedFun() {} +} + + diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/result.out new file mode 100644 index 00000000000..893ef9db992 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithFunAndValChanged/result.out @@ -0,0 +1,18 @@ +PROTO DIFFERENCE in test/ClassWithChangedVisiblityForFun1: FUNCTION_LIST +CHANGES in test/ClassWithChangedVisiblityForFun1: MEMBERS + [foo] +PROTO DIFFERENCE in test/ClassWithChangedVisiblityForFun2: FUNCTION_LIST +CHANGES in test/ClassWithChangedVisiblityForFun2: MEMBERS + [foo] +PROTO DIFFERENCE in test/ClassWithFunAdded: FUNCTION_LIST +CHANGES in test/ClassWithFunAdded: MEMBERS + [added] +PROTO DIFFERENCE in test/ClassWithFunRemoved: FUNCTION_LIST +CHANGES in test/ClassWithFunRemoved: MEMBERS + [removed] +PROTO DIFFERENCE in test/ClassWithValAndFunAddedAndRemoved: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/ClassWithValAndFunAddedAndRemoved: MEMBERS + [funAdded, funRemoved, valAdded, valRemoved] +PROTO DIFFERENCE in test/ClassWithValConvertedToVar: PROPERTY_LIST +CHANGES in test/ClassWithValConvertedToVar: MEMBERS + [value] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/new.kt new file mode 100644 index 00000000000..02acd55cbcf --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/new.kt @@ -0,0 +1,15 @@ +package test + +class ClassWithNestedClasses { + class NestedClassAdded {} + inner class InnerClass {} + inner class InnerClassAdded {} + public fun unchangedFun() {} +} + +class ClassWithChangedVisibilityForNestedClasses { + private class NestedClass {} + protected inner class InnerClass {} + public fun unchangedFun() {} +} + diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/old.kt new file mode 100644 index 00000000000..35d66d1a9e6 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/old.kt @@ -0,0 +1,14 @@ +package test + +class ClassWithNestedClasses { + class NestedClassRemoved {} + inner class InnerClass {} + public fun unchangedFun() {} +} + +class ClassWithChangedVisibilityForNestedClasses { + class NestedClass {} + inner class InnerClass {} + public fun unchangedFun() {} +} + diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/result.out new file mode 100644 index 00000000000..a9cac338305 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWithNestedClassesChanged/result.out @@ -0,0 +1,10 @@ +REMOVED test/ClassWithNestedClasses.NestedClassRemoved +ADDED test/ClassWithNestedClasses.InnerClassAdded +ADDED test/ClassWithNestedClasses.NestedClassAdded +PROTO DIFFERENCE in test/ClassWithChangedVisibilityForNestedClasses.InnerClass: FLAGS +CHANGES in test/ClassWithChangedVisibilityForNestedClasses.InnerClass: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithChangedVisibilityForNestedClasses.NestedClass: FLAGS +CHANGES in test/ClassWithChangedVisibilityForNestedClasses.NestedClass: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassWithNestedClasses: NESTED_CLASS_NAME_LIST +CHANGES in test/ClassWithNestedClasses: MEMBERS + [InnerClassAdded, NestedClassAdded, NestedClassRemoved] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/new.kt new file mode 100644 index 00000000000..ae88ae50272 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/new.kt @@ -0,0 +1,7 @@ +package test + +enum class EnumClassWithChanges { + CONST_1, + CONST_3, + CONST_4 +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/old.kt new file mode 100644 index 00000000000..764e08538ad --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/old.kt @@ -0,0 +1,6 @@ +package test + +enum class EnumClassWithChanges { + CONST_1, + CONST_2 +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/result-js.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/result-js.out new file mode 100644 index 00000000000..1b76c1cf0c8 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/result-js.out @@ -0,0 +1,5 @@ +REMOVED test/EnumClassWithChanges.CONST_2 +ADDED test/EnumClassWithChanges.CONST_3 +ADDED test/EnumClassWithChanges.CONST_4 +PROTO DIFFERENCE in test/EnumClassWithChanges: ENUM_ENTRY_LIST +CHANGES in test/EnumClassWithChanges: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/result.out new file mode 100644 index 00000000000..83215375ccf --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/classWitnEnumChanged/result.out @@ -0,0 +1,2 @@ +PROTO DIFFERENCE in test/EnumClassWithChanges: ENUM_ENTRY_LIST +CHANGES in test/EnumClassWithChanges: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/new.kt new file mode 100644 index 00000000000..b8fdf2c6d41 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/new.kt @@ -0,0 +1,17 @@ +package test + +class A { + fun argumentAdded(x: Int = 1) {} + fun argumentRemoved() {} + + fun valueAdded(x: Int = 3) {} + fun valueRemoved(x: Int) {} + fun valueChanged(x: Int = 6) {} +} + +class ConstructorValueAdded(x: Int = 7) +class ConstructorValueRemoved(x: Int) +class ConstructorValueChanged(x: Int = 20) + +class ConstructorArgumentAdded(x: Int = 9) +class ConstructorArgumentRemoved() \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/old.kt new file mode 100644 index 00000000000..e4bca5f4515 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/old.kt @@ -0,0 +1,17 @@ +package test + +class A { + fun argumentAdded() {} + fun argumentRemoved(x: Int = 2) {} + + fun valueAdded(x: Int) {} + fun valueRemoved(x: Int = 4) {} + fun valueChanged(x: Int = 5) {} +} + +class ConstructorValueAdded(x: Int) +class ConstructorValueRemoved(x: Int = 8) +class ConstructorValueChanged(x: Int = 19) + +class ConstructorArgumentAdded() +class ConstructorArgumentRemoved(x: Int = 10) \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/result.out new file mode 100644 index 00000000000..9ff9602f773 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/defaultValues/result.out @@ -0,0 +1,11 @@ +PROTO DIFFERENCE in test/A: FUNCTION_LIST +CHANGES in test/A: MEMBERS + [argumentAdded, argumentRemoved, valueAdded, valueRemoved] +PROTO DIFFERENCE in test/ConstructorArgumentAdded: CONSTRUCTOR_LIST +CHANGES in test/ConstructorArgumentAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ConstructorArgumentRemoved: CONSTRUCTOR_LIST +CHANGES in test/ConstructorArgumentRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ConstructorValueAdded: CONSTRUCTOR_LIST +CHANGES in test/ConstructorValueAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ConstructorValueRemoved: CONSTRUCTOR_LIST +CHANGES in test/ConstructorValueRemoved: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/new.kt new file mode 100644 index 00000000000..b3b358a2685 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/new.kt @@ -0,0 +1,22 @@ +package test + +annotation class Ann1 +annotation class Ann2 + +class A { + @Ann1 + @Ann2 + fun annotationListBecameNotEmpty() {} + + fun annotationListBecameEmpty() {} + + @Ann1 + @Ann2 + fun annotationAdded() {} + + @Ann1 + fun annotationRemoved() {} + + @Ann2 + fun annotationReplaced() {} +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/old.kt new file mode 100644 index 00000000000..555cf728821 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/old.kt @@ -0,0 +1,26 @@ +package test + +annotation class Ann1 +annotation class Ann2 + +class A { + fun annotationListBecameNotEmpty() {} + + @Ann1 + @Ann2 + fun annotationListBecameEmpty() { + } + + @Ann1 + fun annotationAdded() { + } + + @Ann1 + @Ann2 + fun annotationRemoved() { + } + + @Ann1 + fun annotationReplaced() { + } +} diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/result-js.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/result-js.out new file mode 100644 index 00000000000..bab37471ef4 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/result-js.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/A: FUNCTION_LIST +CHANGES in test/A: MEMBERS + [annotationAdded, annotationListBecameEmpty, annotationListBecameNotEmpty, annotationRemoved, annotationReplaced] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/result.out new file mode 100644 index 00000000000..b5e1a1ed171 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersAnnotationListChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/A: FUNCTION_LIST +CHANGES in test/A: MEMBERS + [annotationListBecameEmpty, annotationListBecameNotEmpty] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/new.kt new file mode 100644 index 00000000000..e9da791aa13 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/new.kt @@ -0,0 +1,85 @@ +package test + +abstract class A { + abstract val abstractFlagAddedVal: String + val abstractFlagRemovedVal: String = "" + abstract val abstractFlagUnchangedVal: String + abstract fun abstractFlagAddedFun() + fun abstractFlagRemovedFun() {} + abstract fun abstractFlagUnchangedFun() + + final val finalFlagAddedVal = "" + val finalFlagRemovedVal = "" + final val finalFlagUnchangedVal = "" + final fun finalFlagAddedFun() {} + fun finalFlagRemovedFun() {} + final fun finalFlagUnchangedFun() {} + + @Suppress("INAPPLICABLE_INFIX_MODIFIER") + infix fun infixFlagAddedFun() {} + fun infixFlagRemovedFun() {} + @Suppress("INAPPLICABLE_INFIX_MODIFIER") + infix fun infixFlagUnchangedFun() {} + + inline fun inlineFlagAddedFun() {} + fun inlineFlagRemovedFun() {} + inline fun inlineFlagUnchangedFun() {} + + internal val internalFlagAddedVal = "" + val internalFlagRemovedVal = "" + internal val internalFlagUnchangedVal = "" + internal fun internalFlagAddedFun() {} + fun internalFlagRemovedFun() {} + internal fun internalFlagUnchangedFun() {} + + lateinit var lateinitFlagAddedVal: String + var lateinitFlagRemovedVal: String = "" + lateinit var lateinitFlagUnchangedVal: String + + open val openFlagAddedVal = "" + val openFlagRemovedVal = "" + open val openFlagUnchangedVal = "" + open fun openFlagAddedFun() {} + fun openFlagRemovedFun() {} + open fun openFlagUnchangedFun() {} + + @Suppress("INAPPLICABLE_OPERATOR_MODIFIER") + operator fun operatorFlagAddedFun() {} + fun operatorFlagRemovedFun() {} + @Suppress("INAPPLICABLE_OPERATOR_MODIFIER") + operator fun operatorFlagUnchangedFun() {} + + private val privateFlagAddedVal = "" + val privateFlagRemovedVal = "" + private val privateFlagUnchangedVal = "" + private fun privateFlagAddedFun() {} + fun privateFlagRemovedFun() {} + private fun privateFlagUnchangedFun() {} + + protected val protectedFlagAddedVal = "" + val protectedFlagRemovedVal = "" + protected val protectedFlagUnchangedVal = "" + protected fun protectedFlagAddedFun() {} + fun protectedFlagRemovedFun() {} + protected fun protectedFlagUnchangedFun() {} + + public val publicFlagAddedVal = "" + val publicFlagRemovedVal = "" + public val publicFlagUnchangedVal = "" + public fun publicFlagAddedFun() {} + fun publicFlagRemovedFun() {} + public fun publicFlagUnchangedFun() {} + + tailrec fun tailrecFlagAddedFun() {} + fun tailrecFlagRemovedFun() {} + tailrec fun tailrecFlagUnchangedFun() {} + + val noFlagsUnchangedVal = "" + fun noFlagsUnchangedFun() {} +} + +object O { + const val constFlagAddedVal = "" + val constFlagRemovedVal = "" + const val constFlagUnchangedVal = "" +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/old.kt new file mode 100644 index 00000000000..8eaad77a5d1 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/old.kt @@ -0,0 +1,85 @@ +package test + +abstract class A { + val abstractFlagAddedVal: String = "" + abstract val abstractFlagRemovedVal: String + abstract val abstractFlagUnchangedVal: String + fun abstractFlagAddedFun() {} + abstract fun abstractFlagRemovedFun() + abstract fun abstractFlagUnchangedFun() + + val finalFlagAddedVal = "" + final val finalFlagRemovedVal = "" + final val finalFlagUnchangedVal = "" + fun finalFlagAddedFun() {} + final fun finalFlagRemovedFun() {} + final fun finalFlagUnchangedFun() {} + + fun infixFlagAddedFun() {} + @Suppress("INAPPLICABLE_INFIX_MODIFIER") + infix fun infixFlagRemovedFun() {} + @Suppress("INAPPLICABLE_INFIX_MODIFIER") + infix fun infixFlagUnchangedFun() {} + + fun inlineFlagAddedFun() {} + inline fun inlineFlagRemovedFun() {} + inline fun inlineFlagUnchangedFun() {} + + val internalFlagAddedVal = "" + internal val internalFlagRemovedVal = "" + internal val internalFlagUnchangedVal = "" + fun internalFlagAddedFun() {} + internal fun internalFlagRemovedFun() {} + internal fun internalFlagUnchangedFun() {} + + var lateinitFlagAddedVal = "" + lateinit var lateinitFlagRemovedVal: String + lateinit var lateinitFlagUnchangedVal: String + + val openFlagAddedVal = "" + open val openFlagRemovedVal = "" + open val openFlagUnchangedVal = "" + fun openFlagAddedFun() {} + open fun openFlagRemovedFun() {} + open fun openFlagUnchangedFun() {} + + fun operatorFlagAddedFun() {} + @Suppress("INAPPLICABLE_OPERATOR_MODIFIER") + operator fun operatorFlagRemovedFun() {} + @Suppress("INAPPLICABLE_OPERATOR_MODIFIER") + operator fun operatorFlagUnchangedFun() {} + + val privateFlagAddedVal = "" + private val privateFlagRemovedVal = "" + private val privateFlagUnchangedVal = "" + fun privateFlagAddedFun() {} + private fun privateFlagRemovedFun() {} + private fun privateFlagUnchangedFun() {} + + val protectedFlagAddedVal = "" + protected val protectedFlagRemovedVal = "" + protected val protectedFlagUnchangedVal = "" + fun protectedFlagAddedFun() {} + protected fun protectedFlagRemovedFun() {} + protected fun protectedFlagUnchangedFun() {} + + val publicFlagAddedVal = "" + public val publicFlagRemovedVal = "" + public val publicFlagUnchangedVal = "" + fun publicFlagAddedFun() {} + public fun publicFlagRemovedFun() {} + public fun publicFlagUnchangedFun() {} + + fun tailrecFlagAddedFun() {} + tailrec fun tailrecFlagRemovedFun() {} + tailrec fun tailrecFlagUnchangedFun() {} + + val noFlagsUnchangedVal = "" + fun noFlagsUnchangedFun() {} +} + +object O { + val constFlagAddedVal = "" + const val constFlagRemovedVal = "" + const val constFlagUnchangedVal = "" +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/result.out new file mode 100644 index 00000000000..1516040346b --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/membersFlagsChanged/result.out @@ -0,0 +1,6 @@ +PROTO DIFFERENCE in test/A: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/A: MEMBERS + [abstractFlagAddedFun, abstractFlagAddedVal, abstractFlagRemovedFun, abstractFlagRemovedVal, infixFlagAddedFun, infixFlagRemovedFun, inlineFlagAddedFun, inlineFlagRemovedFun, internalFlagAddedFun, internalFlagAddedVal, internalFlagRemovedFun, internalFlagRemovedVal, lateinitFlagAddedVal, lateinitFlagRemovedVal, openFlagAddedFun, openFlagAddedVal, openFlagRemovedFun, openFlagRemovedVal, operatorFlagAddedFun, operatorFlagRemovedFun, privateFlagAddedFun, privateFlagAddedVal, privateFlagRemovedFun, privateFlagRemovedVal, protectedFlagAddedFun, protectedFlagAddedVal, protectedFlagRemovedFun, protectedFlagRemovedVal, tailrecFlagAddedFun, tailrecFlagRemovedFun] +PROTO DIFFERENCE in test/O: PROPERTY_LIST +CHANGES in test/O: MEMBERS + [constFlagAddedVal, constFlagRemovedVal] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/new.kt new file mode 100644 index 00000000000..e70454ffb41 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/new.kt @@ -0,0 +1,9 @@ +package test + +class Base { + class Nested1 { + class Nested2 { + fun added() {} + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/old.kt new file mode 100644 index 00000000000..d3aacfa415c --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/old.kt @@ -0,0 +1,9 @@ +package test + +class Base { + class Nested1 { + class Nested2 { + fun removed() {} + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/result.out new file mode 100644 index 00000000000..595aff44280 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/nestedClassMembersChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/Base.Nested1.Nested2: FUNCTION_LIST +CHANGES in test/Base.Nested1.Nested2: MEMBERS + [added, removed] diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/new.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/new.kt new file mode 100644 index 00000000000..7971271f92c --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/new.kt @@ -0,0 +1,7 @@ +package test + +sealed class Base { + class A : Base() + class B : Base() + class C : Base() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/old.kt b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/old.kt new file mode 100644 index 00000000000..c5cd9afb81d --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/old.kt @@ -0,0 +1,6 @@ +package test + +sealed class Base { + class A : Base() + class B : Base() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/result.out b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/result.out new file mode 100644 index 00000000000..4df937b2273 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classMembersOnlyChanged/sealedClassImplAdded/result.out @@ -0,0 +1,4 @@ +ADDED test/Base.C +PROTO DIFFERENCE in test/Base: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base: CLASS_SIGNATURE, MEMBERS + [C] diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/new.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/new.kt new file mode 100644 index 00000000000..c3f0b8f68a6 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/new.kt @@ -0,0 +1,15 @@ +package test + +class ClassWithPrivateFunAdded { + private fun privateFun() {} + val s = "20" +} + +class ClassWithPrivateFunRemoved { + public fun unchangedFun() {} +} + +class ClassWithPrivateFunSignatureChanged { + private fun privateFun(arg: Int) {} + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/old.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/old.kt new file mode 100644 index 00000000000..79ad31fa40e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/old.kt @@ -0,0 +1,15 @@ +package test + +class ClassWithPrivateFunAdded { + val s = "20" +} + +class ClassWithPrivateFunRemoved { + private fun privateFun() {} + public fun unchangedFun() {} +} + +class ClassWithPrivateFunSignatureChanged { + private fun privateFun(arg: String) {} + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/result.out b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/result.out new file mode 100644 index 00000000000..3fad652b4c3 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateFunChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/ClassWithPrivateFunAdded: FUNCTION_LIST +PROTO DIFFERENCE in test/ClassWithPrivateFunRemoved: FUNCTION_LIST +PROTO DIFFERENCE in test/ClassWithPrivateFunSignatureChanged: FUNCTION_LIST diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/new.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/new.kt new file mode 100644 index 00000000000..6d08e307d8d --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/new.kt @@ -0,0 +1,12 @@ +package test + +class ClassWithPrivatePrimaryConstructorAdded private constructor() { + private constructor(arg: Int) : this() {} +} + +class ClassWithPrivatePrimaryConstructorRemoved { + private constructor(arg: Int) {} +} + +class ClassWithPrivatePrimaryConstructorChanged private constructor(arg: String) { +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/old.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/old.kt new file mode 100644 index 00000000000..05b24c69e56 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/old.kt @@ -0,0 +1,12 @@ +package test + +class ClassWithPrivatePrimaryConstructorAdded { + private constructor(arg: Int) {} +} + +class ClassWithPrivatePrimaryConstructorRemoved private constructor() { + private constructor(arg: Int) : this() {} +} + +class ClassWithPrivatePrimaryConstructorChanged private constructor() { +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/result.out b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/result.out new file mode 100644 index 00000000000..afa4553e11b --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivatePrimaryConstructorChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/ClassWithPrivatePrimaryConstructorAdded: CONSTRUCTOR_LIST +PROTO DIFFERENCE in test/ClassWithPrivatePrimaryConstructorChanged: CONSTRUCTOR_LIST +PROTO DIFFERENCE in test/ClassWithPrivatePrimaryConstructorRemoved: CONSTRUCTOR_LIST diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/new.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/new.kt new file mode 100644 index 00000000000..7cf273358f7 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/new.kt @@ -0,0 +1,15 @@ +package test + +class ClassWithPrivateSecondaryConstructorsAdded() { + private constructor(arg: Int) : this() {} + private constructor(arg: String) : this() {} +} + +class ClassWithPrivateSecondaryConstructorsAdded2() { + private constructor(arg: Int) : this() {} + private constructor(arg: String) : this() {} + constructor(arg: Float) : this() {} +} + +class ClassWithPrivateSecondaryConstructorsRemoved() { +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/old.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/old.kt new file mode 100644 index 00000000000..53b981e8996 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/old.kt @@ -0,0 +1,13 @@ +package test + +class ClassWithPrivateSecondaryConstructorsAdded { +} + +class ClassWithPrivateSecondaryConstructorsAdded2() { + constructor(arg: Float) : this() {} +} + +class ClassWithPrivateSecondaryConstructorsRemoved() { + private constructor(arg: Int): this() {} + private constructor(arg: String): this() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/result.out b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/result.out new file mode 100644 index 00000000000..bacb315a8bd --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateSecondaryConstructorChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/ClassWithPrivateSecondaryConstructorsAdded: CONSTRUCTOR_LIST +PROTO DIFFERENCE in test/ClassWithPrivateSecondaryConstructorsAdded2: CONSTRUCTOR_LIST +PROTO DIFFERENCE in test/ClassWithPrivateSecondaryConstructorsRemoved: CONSTRUCTOR_LIST diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/new.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/new.kt new file mode 100644 index 00000000000..178a89088c6 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/new.kt @@ -0,0 +1,21 @@ +package test + +class ClassWithPrivateValAdded { + private val x: Int = 100 + public fun unchangedFun() {} +} + +class ClassWithPrivateValRemoved { + public fun unchangedFun() {} +} + +class ClassWithPrivateValSignatureChanged { + private val x: String = "X" + public fun unchangedFun() {} +} + +class ClassWithGetterForPrivateValChanged { + private val x: Int + get() = 200 + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/old.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/old.kt new file mode 100644 index 00000000000..5576e86c988 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/old.kt @@ -0,0 +1,20 @@ +package test + +class ClassWithPrivateValAdded { + public fun unchangedFun() {} +} + +class ClassWithPrivateValRemoved { + private val x: Int = 100 + public fun unchangedFun() {} +} + +class ClassWithPrivateValSignatureChanged { + private val x: Int = 100 + public fun unchangedFun() {} +} + +class ClassWithGetterForPrivateValChanged { + private val x: Int = 100 + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/result.out b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/result.out new file mode 100644 index 00000000000..93c2d0dff6e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateValChanged/result.out @@ -0,0 +1,4 @@ +PROTO DIFFERENCE in test/ClassWithGetterForPrivateValChanged: PROPERTY_LIST +PROTO DIFFERENCE in test/ClassWithPrivateValAdded: PROPERTY_LIST +PROTO DIFFERENCE in test/ClassWithPrivateValRemoved: PROPERTY_LIST +PROTO DIFFERENCE in test/ClassWithPrivateValSignatureChanged: PROPERTY_LIST diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/new.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/new.kt new file mode 100644 index 00000000000..9024562066d --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/new.kt @@ -0,0 +1,22 @@ +package test + +class ClassWithPrivateVarAdded { + private var x: Int = 100 + public fun unchangedFun() {} +} + +class ClassWithPrivateVarRemoved { + public fun unchangedFun() {} +} + +class ClassWithPrivateVarSignatureChanged { + private var x: String = "X" + public fun unchangedFun() {} +} + +class ClassWithGetterAndSetterForPrivateVarChanged { + private var x: Int + get() = 200 + set(value) {} + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/old.kt b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/old.kt new file mode 100644 index 00000000000..ad239436f24 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/old.kt @@ -0,0 +1,20 @@ +package test + +class ClassWithPrivateVarAdded { + public fun unchangedFun() {} +} + +class ClassWithPrivateVarRemoved { + private var x: Int = 100 + public fun unchangedFun() {} +} + +class ClassWithPrivateVarSignatureChanged { + private var x: Int = 100 + public fun unchangedFun() {} +} + +class ClassWithGetterAndSetterForPrivateVarChanged { + private var x: Int = 100 + public fun unchangedFun() {} +} diff --git a/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/result.out b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/result.out new file mode 100644 index 00000000000..379b7b4213e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classPrivateOnlyChange/classWithPrivateVarChanged/result.out @@ -0,0 +1,4 @@ +PROTO DIFFERENCE in test/ClassWithGetterAndSetterForPrivateVarChanged: PROPERTY_LIST +PROTO DIFFERENCE in test/ClassWithPrivateVarAdded: PROPERTY_LIST +PROTO DIFFERENCE in test/ClassWithPrivateVarRemoved: PROPERTY_LIST +PROTO DIFFERENCE in test/ClassWithPrivateVarSignatureChanged: PROPERTY_LIST diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/new.kt new file mode 100644 index 00000000000..fc7bee7454c --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/new.kt @@ -0,0 +1,20 @@ +package test + +annotation class Ann1 +annotation class Ann2 + +@Ann1 +@Ann2 +class AnnotationListBecomeNotEmpty + +class AnnotationListBecomeEmpty + +@Ann1 +@Ann2 +class AnnotationAdded + +@Ann1 +class AnnotationRemoved + +@Ann2 +class AnnotationReplaced diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/old.kt new file mode 100644 index 00000000000..517cdb5d01a --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/old.kt @@ -0,0 +1,20 @@ +package test + +annotation class Ann1 +annotation class Ann2 + +class AnnotationListBecomeNotEmpty + +@Ann1 +@Ann2 +class AnnotationListBecomeEmpty + +@Ann1 +class AnnotationAdded + +@Ann1 +@Ann2 +class AnnotationRemoved + +@Ann1 +class AnnotationReplaced diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/result-js.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/result-js.out new file mode 100644 index 00000000000..78f93fce59a --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/result-js.out @@ -0,0 +1,10 @@ +PROTO DIFFERENCE in test/AnnotationAdded: JS_EXT_CLASS_ANNOTATION_LIST +CHANGES in test/AnnotationAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationListBecomeEmpty: FLAGS, JS_EXT_CLASS_ANNOTATION_LIST +CHANGES in test/AnnotationListBecomeEmpty: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationListBecomeNotEmpty: FLAGS, JS_EXT_CLASS_ANNOTATION_LIST +CHANGES in test/AnnotationListBecomeNotEmpty: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationRemoved: JS_EXT_CLASS_ANNOTATION_LIST +CHANGES in test/AnnotationRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationReplaced: JS_EXT_CLASS_ANNOTATION_LIST +CHANGES in test/AnnotationReplaced: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/result.out new file mode 100644 index 00000000000..7ceb65bf463 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classAnnotationListChanged/result.out @@ -0,0 +1,4 @@ +PROTO DIFFERENCE in test/AnnotationListBecomeEmpty: FLAGS +CHANGES in test/AnnotationListBecomeEmpty: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationListBecomeNotEmpty: FLAGS +CHANGES in test/AnnotationListBecomeNotEmpty: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/new.kt new file mode 100644 index 00000000000..5ea958883c3 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/new.kt @@ -0,0 +1,5 @@ +package test + +open class A { + fun f() {} +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/old.kt new file mode 100644 index 00000000000..926842376c9 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/old.kt @@ -0,0 +1,3 @@ +package test + +class A \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/result.out new file mode 100644 index 00000000000..9113a0027fd --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsAndMembersChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/A: FLAGS, FUNCTION_LIST +CHANGES in test/A: CLASS_SIGNATURE, MEMBERS + [f] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/new.kt new file mode 100644 index 00000000000..3ecb27bbb47 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/new.kt @@ -0,0 +1,55 @@ +package test + +abstract class AbstractFlagAdded +class AbstractFlagRemoved +abstract class AbstractFlagUnchanged + +annotation class AnnotationFlagAdded +class AnnotationFlagRemoved +annotation class AnnotationFlagUnchanged + +data class DataFlagAdded(val x: Int) +class DataFlagRemoved(val x: Int) +data class DataFlagUnchanged(val x: Int) + +enum class EnumFlagAdded +class EnumFlagRemoved +enum class EnumFlagUnchanged + +final class FinalFlagAdded +class FinalFlagRemoved +final class FinalFlagUnchanged + +class InnerClassHolder { + inner class InnerFlagAdded + class InnerFlagRemoved + inner class InnerFlagUnchanged +} + +internal class InternalFlagAdded +class InternalFlagRemoved +internal class InternalFlagUnchanged + +open class OpenFlagAdded +class OpenFlagRemoved +open class OpenFlagUnchanged + +private class PrivateFlagAdded +class PrivateFlagRemoved +private class PrivateFlagUnchanged + +class ProtectedClassHolder { + protected class ProtectedFlagAdded + class ProtectedFlagRemoved + protected class ProtectedFlagUnchanged +} + +public class PublicFlagAdded +class PublicFlagRemoved +public class PublicFlagUnchanged + +sealed class SealedFlagAdded +class SealedFlagRemoved +sealed class SealedFlagUnchanged + +class UnchangedNoFlags \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/old.kt new file mode 100644 index 00000000000..756c07a80ee --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/old.kt @@ -0,0 +1,55 @@ +package test + +class AbstractFlagAdded +abstract class AbstractFlagRemoved +abstract class AbstractFlagUnchanged + +class AnnotationFlagAdded +annotation class AnnotationFlagRemoved +annotation class AnnotationFlagUnchanged + +class DataFlagAdded(val x: Int) +data class DataFlagRemoved(val x: Int) +data class DataFlagUnchanged(val x: Int) + +class EnumFlagAdded +enum class EnumFlagRemoved +enum class EnumFlagUnchanged + +class FinalFlagAdded +final class FinalFlagRemoved +final class FinalFlagUnchanged + +class InnerClassHolder { + class InnerFlagAdded + inner class InnerFlagRemoved + inner class InnerFlagUnchanged +} + +class InternalFlagAdded +internal class InternalFlagRemoved +internal class InternalFlagUnchanged + +class OpenFlagAdded +open class OpenFlagRemoved +open class OpenFlagUnchanged + +class PrivateFlagAdded +private class PrivateFlagRemoved +private class PrivateFlagUnchanged + +class ProtectedClassHolder { + class ProtectedFlagAdded + protected class ProtectedFlagRemoved + protected class ProtectedFlagUnchanged +} + +class PublicFlagAdded +public class PublicFlagRemoved +public class PublicFlagUnchanged + +class SealedFlagAdded +sealed class SealedFlagRemoved +sealed class SealedFlagUnchanged + +class UnchangedNoFlags \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/result-js.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/result-js.out new file mode 100644 index 00000000000..95f7d8309bc --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/result-js.out @@ -0,0 +1,46 @@ +PROTO DIFFERENCE in test/AbstractFlagAdded: FLAGS +CHANGES in test/AbstractFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AbstractFlagRemoved: FLAGS +CHANGES in test/AbstractFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationFlagAdded: FLAGS, SUPERTYPE_LIST +CHANGES in test/AnnotationFlagAdded: CLASS_SIGNATURE, PARENTS + [kotlin.Annotation, kotlin.Any] +PROTO DIFFERENCE in test/AnnotationFlagRemoved: FLAGS, SUPERTYPE_LIST +CHANGES in test/AnnotationFlagRemoved: CLASS_SIGNATURE, PARENTS + [kotlin.Annotation, kotlin.Any] +PROTO DIFFERENCE in test/DataFlagAdded: FLAGS, FUNCTION_LIST +CHANGES in test/DataFlagAdded: CLASS_SIGNATURE, MEMBERS + [component1, copy, equals, hashCode, toString] +PROTO DIFFERENCE in test/DataFlagRemoved: FLAGS, FUNCTION_LIST +CHANGES in test/DataFlagRemoved: CLASS_SIGNATURE, MEMBERS + [component1, copy, equals, hashCode, toString] +PROTO DIFFERENCE in test/EnumFlagAdded: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST +CHANGES in test/EnumFlagAdded: CLASS_SIGNATURE, PARENTS + [kotlin.Any, kotlin.Enum] +PROTO DIFFERENCE in test/EnumFlagRemoved: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST +CHANGES in test/EnumFlagRemoved: CLASS_SIGNATURE, PARENTS + [kotlin.Any, kotlin.Enum] +PROTO DIFFERENCE in test/InnerClassHolder.InnerFlagAdded: FLAGS +CHANGES in test/InnerClassHolder.InnerFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/InnerClassHolder.InnerFlagRemoved: FLAGS +CHANGES in test/InnerClassHolder.InnerFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/InternalFlagAdded: FLAGS +CHANGES in test/InternalFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/InternalFlagRemoved: FLAGS +CHANGES in test/InternalFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/OpenFlagAdded: FLAGS +CHANGES in test/OpenFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/OpenFlagRemoved: FLAGS +CHANGES in test/OpenFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/PrivateFlagAdded: FLAGS +CHANGES in test/PrivateFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/PrivateFlagRemoved: FLAGS +CHANGES in test/PrivateFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ProtectedClassHolder.ProtectedFlagAdded: FLAGS +CHANGES in test/ProtectedClassHolder.ProtectedFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ProtectedClassHolder.ProtectedFlagRemoved: FLAGS +CHANGES in test/ProtectedClassHolder.ProtectedFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/SealedFlagAdded: CONSTRUCTOR_LIST, FLAGS +CHANGES in test/SealedFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/SealedFlagRemoved: CONSTRUCTOR_LIST, FLAGS +CHANGES in test/SealedFlagRemoved: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/result.out new file mode 100644 index 00000000000..f00772bb93a --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classFlagsChanged/result.out @@ -0,0 +1,46 @@ +PROTO DIFFERENCE in test/AbstractFlagAdded: FLAGS +CHANGES in test/AbstractFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AbstractFlagRemoved: FLAGS +CHANGES in test/AbstractFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/AnnotationFlagAdded: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST +CHANGES in test/AnnotationFlagAdded: CLASS_SIGNATURE, PARENTS + [kotlin.Annotation, kotlin.Any] +PROTO DIFFERENCE in test/AnnotationFlagRemoved: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST +CHANGES in test/AnnotationFlagRemoved: CLASS_SIGNATURE, PARENTS + [kotlin.Annotation, kotlin.Any] +PROTO DIFFERENCE in test/DataFlagAdded: FLAGS, FUNCTION_LIST +CHANGES in test/DataFlagAdded: CLASS_SIGNATURE, MEMBERS + [component1, copy, equals, hashCode, toString] +PROTO DIFFERENCE in test/DataFlagRemoved: FLAGS, FUNCTION_LIST +CHANGES in test/DataFlagRemoved: CLASS_SIGNATURE, MEMBERS + [component1, copy, equals, hashCode, toString] +PROTO DIFFERENCE in test/EnumFlagAdded: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST +CHANGES in test/EnumFlagAdded: CLASS_SIGNATURE, PARENTS + [kotlin.Any, kotlin.Enum] +PROTO DIFFERENCE in test/EnumFlagRemoved: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST +CHANGES in test/EnumFlagRemoved: CLASS_SIGNATURE, PARENTS + [kotlin.Any, kotlin.Enum] +PROTO DIFFERENCE in test/InnerClassHolder.InnerFlagAdded: CONSTRUCTOR_LIST, FLAGS +CHANGES in test/InnerClassHolder.InnerFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/InnerClassHolder.InnerFlagRemoved: CONSTRUCTOR_LIST, FLAGS +CHANGES in test/InnerClassHolder.InnerFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/InternalFlagAdded: FLAGS +CHANGES in test/InternalFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/InternalFlagRemoved: FLAGS +CHANGES in test/InternalFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/OpenFlagAdded: FLAGS +CHANGES in test/OpenFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/OpenFlagRemoved: FLAGS +CHANGES in test/OpenFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/PrivateFlagAdded: FLAGS +CHANGES in test/PrivateFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/PrivateFlagRemoved: FLAGS +CHANGES in test/PrivateFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ProtectedClassHolder.ProtectedFlagAdded: FLAGS +CHANGES in test/ProtectedClassHolder.ProtectedFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ProtectedClassHolder.ProtectedFlagRemoved: FLAGS +CHANGES in test/ProtectedClassHolder.ProtectedFlagRemoved: CLASS_SIGNATURE +PROTO DIFFERENCE in test/SealedFlagAdded: CONSTRUCTOR_LIST, FLAGS +CHANGES in test/SealedFlagAdded: CLASS_SIGNATURE +PROTO DIFFERENCE in test/SealedFlagRemoved: CONSTRUCTOR_LIST, FLAGS +CHANGES in test/SealedFlagRemoved: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/new.kt new file mode 100644 index 00000000000..9d081c29471 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/new.kt @@ -0,0 +1,6 @@ +package test + +import kotlin.annotation.* + +class ClassWithTypeParameterListChanged { +} diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/old.kt new file mode 100644 index 00000000000..b52cabd2939 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/old.kt @@ -0,0 +1,4 @@ +package test + +class ClassWithTypeParameterListChanged { +} diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/result.out new file mode 100644 index 00000000000..804a5af5aae --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classTypeParameterListChanged/result.out @@ -0,0 +1,2 @@ +PROTO DIFFERENCE in test/ClassWithTypeParameterListChanged: TYPE_PARAMETER_LIST +CHANGES in test/ClassWithTypeParameterListChanged: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/new.kt new file mode 100644 index 00000000000..7632cc8272e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/new.kt @@ -0,0 +1,4 @@ +package test + +class ClassWithSuperTypeListChanged : Throwable() { +} diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/old.kt new file mode 100644 index 00000000000..9228402497c --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/old.kt @@ -0,0 +1,6 @@ +package test + +class ClassWithSuperTypeListChanged { +} + + diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/result.out new file mode 100644 index 00000000000..b1c4bef6ae7 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/classWithSuperTypeListChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/ClassWithSuperTypeListChanged: SUPERTYPE_LIST +CHANGES in test/ClassWithSuperTypeListChanged: CLASS_SIGNATURE, PARENTS + [kotlin.Any, kotlin.Throwable] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/new.kt new file mode 100644 index 00000000000..ade1f6fb033 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/new.kt @@ -0,0 +1,7 @@ +package test + +open class Base { + class Nested1 { + class Nested2 + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/old.kt new file mode 100644 index 00000000000..bdc78a8f032 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/old.kt @@ -0,0 +1,7 @@ +package test + +open class Base { + class Nested1 { + class Nested2 : Base() + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/result.out new file mode 100644 index 00000000000..d6e8eed1c39 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/nestedClassSignatureChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/Base.Nested1.Nested2: SUPERTYPE_LIST +CHANGES in test/Base.Nested1.Nested2: CLASS_SIGNATURE, PARENTS + [kotlin.Any, test.Base] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/new.kt new file mode 100644 index 00000000000..5c4d97e0232 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/new.kt @@ -0,0 +1,9 @@ +package test + +sealed class Base1 +class Impl1 : Base1() +class Impl11 : Base1() + +sealed class Base2 +class Impl2 : Base2() +class Impl22 : Base2() diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/old.kt new file mode 100644 index 00000000000..bfb054c9fbb --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/old.kt @@ -0,0 +1,8 @@ +package test + +sealed class Base1 +class Impl1 : Base1() + +sealed class Base2 +class Impl2 : Base2() +class Impl22 diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/result.out new file mode 100644 index 00000000000..9c70f14d0aa --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplAdded/result.out @@ -0,0 +1,8 @@ +ADDED test/Impl11 +PROTO DIFFERENCE in test/Base1: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base1: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base2: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Impl22: SUPERTYPE_LIST +CHANGES in test/Impl22: CLASS_SIGNATURE, PARENTS + [kotlin.Any, test.Base2] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/new.kt new file mode 100644 index 00000000000..bfb054c9fbb --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/new.kt @@ -0,0 +1,8 @@ +package test + +sealed class Base1 +class Impl1 : Base1() + +sealed class Base2 +class Impl2 : Base2() +class Impl22 diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/old.kt new file mode 100644 index 00000000000..5c4d97e0232 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/old.kt @@ -0,0 +1,9 @@ +package test + +sealed class Base1 +class Impl1 : Base1() +class Impl11 : Base1() + +sealed class Base2 +class Impl2 : Base2() +class Impl22 : Base2() diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/result.out new file mode 100644 index 00000000000..2fa142e3f9b --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassImplRemoved/result.out @@ -0,0 +1,8 @@ +REMOVED test/Impl11 +PROTO DIFFERENCE in test/Base1: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base1: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base2: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Impl22: SUPERTYPE_LIST +CHANGES in test/Impl22: CLASS_SIGNATURE, PARENTS + [kotlin.Any, test.Base2] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/new.kt new file mode 100644 index 00000000000..17258934aca --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/new.kt @@ -0,0 +1,12 @@ +package test + +sealed class Base1 { + class Nested1 : Base1() + class Nested2 : Base1() +} + +sealed class Base2 { + class Nested1 : Base2() + class Nested2 : Base2() +} + diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/old.kt new file mode 100644 index 00000000000..bc57072314f --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/old.kt @@ -0,0 +1,11 @@ +package test + +sealed class Base1 { + class Nested1 : Base1() +} + +sealed class Base2 { + class Nested1 : Base2() + class Nested2 +} + diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/result.out new file mode 100644 index 00000000000..e64c6353c17 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAdded/result.out @@ -0,0 +1,9 @@ +ADDED test/Base1.Nested2 +PROTO DIFFERENCE in test/Base1: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base1: CLASS_SIGNATURE, MEMBERS + [Nested2] +PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base2: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Base2.Nested2: SUPERTYPE_LIST +CHANGES in test/Base2.Nested2: CLASS_SIGNATURE, PARENTS + [kotlin.Any, test.Base2] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/new.kt new file mode 100644 index 00000000000..4f3c46b44e1 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/new.kt @@ -0,0 +1,22 @@ +package test + +sealed class Base1 { + sealed class Nested1 : Base1() { + sealed class Nested2 : Nested1() { + class Nested3 : Nested2() + } + } +} + +sealed class Base2 { + sealed class Nested1 : Base2() { + class Nested2 : Nested1() + class Nested3 : Nested1() + } +} + +sealed class Base3 { + sealed class Nested1 : Base3() { + class Nested2 : Nested1() + } +} diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/old.kt new file mode 100644 index 00000000000..026fe02139b --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/old.kt @@ -0,0 +1,19 @@ +package test + +sealed class Base1 { + sealed class Nested1 : Base1() { + sealed class Nested2 : Nested1() + } +} + +sealed class Base2 { + sealed class Nested1 : Base2() { + class Nested2 : Nested1() + } +} + +sealed class Base3 { + sealed class Nested1 : Base3() { + class Nested2 + } +} diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/result.out new file mode 100644 index 00000000000..24ddda10d1c --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplAddedDeep/result.out @@ -0,0 +1,13 @@ +ADDED test/Base1.Nested1.Nested2.Nested3 +ADDED test/Base2.Nested1.Nested3 +PROTO DIFFERENCE in test/Base1.Nested1.Nested2: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base1.Nested1.Nested2: CLASS_SIGNATURE, MEMBERS + [Nested3] +PROTO DIFFERENCE in test/Base2.Nested1: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base2.Nested1: CLASS_SIGNATURE, MEMBERS + [Nested3] +PROTO DIFFERENCE in test/Base3.Nested1: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base3.Nested1: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Base3.Nested1.Nested2: SUPERTYPE_LIST +CHANGES in test/Base3.Nested1.Nested2: CLASS_SIGNATURE, PARENTS + [kotlin.Any, test.Base3.Nested1] diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/new.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/new.kt new file mode 100644 index 00000000000..bc57072314f --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/new.kt @@ -0,0 +1,11 @@ +package test + +sealed class Base1 { + class Nested1 : Base1() +} + +sealed class Base2 { + class Nested1 : Base2() + class Nested2 +} + diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/old.kt b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/old.kt new file mode 100644 index 00000000000..17258934aca --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/old.kt @@ -0,0 +1,12 @@ +package test + +sealed class Base1 { + class Nested1 : Base1() + class Nested2 : Base1() +} + +sealed class Base2 { + class Nested1 : Base2() + class Nested2 : Base2() +} + diff --git a/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/result.out b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/result.out new file mode 100644 index 00000000000..c3d77972774 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/classSignatureChange/sealedClassNestedImplRemoved/result.out @@ -0,0 +1,9 @@ +REMOVED test/Base1.Nested2 +PROTO DIFFERENCE in test/Base1: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base1: CLASS_SIGNATURE, MEMBERS + [Nested2] +PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST +CHANGES in test/Base2: CLASS_SIGNATURE +PROTO DIFFERENCE in test/Base2.Nested2: SUPERTYPE_LIST +CHANGES in test/Base2.Nested2: CLASS_SIGNATURE, PARENTS + [kotlin.Any, test.Base2] diff --git a/jps/jps-plugin/testData/comparison/jsOnly/externals/new.kt b/jps/jps-plugin/testData/comparison/jsOnly/externals/new.kt new file mode 100644 index 00000000000..feddad90bfc --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jsOnly/externals/new.kt @@ -0,0 +1,15 @@ +package test + +external class ExternalClass { + fun addedExternalFun() + val addedExternalVal: Int +} + +external class ClassBecameExternal +class ClassBecameNonExternal + +external fun addedExternalFun() +external val addedExternalVal: Int + +external fun funBecameExternal() +fun funBecameNonExternal() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/jsOnly/externals/old.kt b/jps/jps-plugin/testData/comparison/jsOnly/externals/old.kt new file mode 100644 index 00000000000..9a729477c7b --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jsOnly/externals/old.kt @@ -0,0 +1,15 @@ +package test + +external class ExternalClass { + fun removedExternalFun() + val removedExternalVal: Int +} + +class ClassBecameExternal +external class ClassBecameNonExternal + +external fun removedExternalFun() +external val removedExternalVal: Int + +fun funBecameExternal() {} +external fun funBecameNonExternal() diff --git a/jps/jps-plugin/testData/comparison/jsOnly/externals/result.out b/jps/jps-plugin/testData/comparison/jsOnly/externals/result.out new file mode 100644 index 00000000000..756d19153db --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jsOnly/externals/result.out @@ -0,0 +1,10 @@ +PROTO DIFFERENCE in test/ClassBecameExternal: FLAGS +CHANGES in test/ClassBecameExternal: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ClassBecameNonExternal: FLAGS +CHANGES in test/ClassBecameNonExternal: CLASS_SIGNATURE +PROTO DIFFERENCE in test/ExternalClass: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/ExternalClass: MEMBERS + [addedExternalFun, addedExternalVal, removedExternalFun, removedExternalVal] +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/MainKt: MEMBERS + [addedExternalFun, addedExternalVal, funBecameExternal, funBecameNonExternal, removedExternalFun, removedExternalVal] diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/new.kt b/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/new.kt new file mode 100644 index 00000000000..c63738c81cf --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/new.kt @@ -0,0 +1,3 @@ +package test + +public fun main() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/old.kt b/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/old.kt new file mode 100644 index 00000000000..36ad2f44f6d --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/old.kt @@ -0,0 +1,13 @@ +package test + +public class TestPackage { + public fun main() {} +} + +public class MainKt { + companion object { + @JvmStatic + public fun main() { + } + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/result.out b/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/result.out new file mode 100644 index 00000000000..8ea00e6c854 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/classToFileFacade/result.out @@ -0,0 +1,3 @@ +REMOVED test/MainKt.Companion +REMOVED test/TestPackage +CHANGES in test/MainKt: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/new.kt b/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/new.kt new file mode 100644 index 00000000000..5ebb80f3de4 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/new.kt @@ -0,0 +1,7 @@ +package test + +abstract class A { + external fun externalFlagAddedFun() + fun externalFlagRemovedFun() {} + external fun externalFlagUnchangedFun() +} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/old.kt b/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/old.kt new file mode 100644 index 00000000000..ad26c6d328f --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/old.kt @@ -0,0 +1,7 @@ +package test + +abstract class A { + fun externalFlagAddedFun() {} + external fun externalFlagRemovedFun() + external fun externalFlagUnchangedFun() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/result.out b/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/result.out new file mode 100644 index 00000000000..99d221eacdb --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/membersFlagsChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/A: FUNCTION_LIST +CHANGES in test/A: MEMBERS + [externalFlagAddedFun, externalFlagRemovedFun] diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/new1.kt b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/new1.kt new file mode 100644 index 00000000000..22064b47da0 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/new1.kt @@ -0,0 +1,15 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass +package test + +public fun unchangedFun1() {} + +public fun publicAddedFun1() {} + +private fun addedFun1(): Int = 10 + +private val addedVal1: String = "A" + +private val changedVal1: String = "" + +private fun changedFun1(arg: String) {} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/new2.kt b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/new2.kt new file mode 100644 index 00000000000..dc7dce42888 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/new2.kt @@ -0,0 +1,13 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass +package test + +public fun unchangedFun2() {} + +private fun addedFun2(): Int = 10 + +private val addedVal2: String = "A" + +private val changedVal2: String = "" + +private fun changedFun2(arg: String) {} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/old1.kt b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/old1.kt new file mode 100644 index 00000000000..11fff787118 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/old1.kt @@ -0,0 +1,13 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass +package test + +public fun unchangedFun1() {} + +private fun removedFun1(): Int = 10 + +private val removedVal1: String = "A" + +private val changedVal1: Int = 20 + +private fun changedFun1(arg: Int) {} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/old2.kt b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/old2.kt new file mode 100644 index 00000000000..2c794b1fbe0 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/old2.kt @@ -0,0 +1,13 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass +package test + +public fun unchangedFun2() {} + +private fun removedFun2(): Int = 10 + +private val removedVal2: String = "A" + +private val changedVal2: Int = 20 + +private fun changedFun2(arg: Int) {} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/result.out b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/result.out new file mode 100644 index 00000000000..ad6c3735fc7 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeMultifileClassChanged/result.out @@ -0,0 +1,5 @@ +SKIPPED test/Utils +PROTO DIFFERENCE in test/Utils__Main1Kt: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/Utils__Main1Kt: MEMBERS + [publicAddedFun1] +PROTO DIFFERENCE in test/Utils__Main2Kt: FUNCTION_LIST, PROPERTY_LIST diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/new.kt b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/new.kt new file mode 100644 index 00000000000..bee5fee69eb --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/new.kt @@ -0,0 +1,13 @@ +package test + +public class TestPackage { + public fun main() {} +} + +public class MainKt { + companion object { + @JvmStatic + public fun main() { + } + } +} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/old.kt b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/old.kt new file mode 100644 index 00000000000..81ffc604d8c --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/old.kt @@ -0,0 +1,3 @@ +package test + +public fun main() {} diff --git a/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/result.out b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/result.out new file mode 100644 index 00000000000..aa5d9b93998 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/jvmOnly/packageFacadeToClass/result.out @@ -0,0 +1,3 @@ +ADDED test/MainKt.Companion +ADDED test/TestPackage +CHANGES in test/MainKt: CLASS_SIGNATURE diff --git a/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/new.kt b/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/new.kt new file mode 100644 index 00000000000..928941e3ec0 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/new.kt @@ -0,0 +1,8 @@ +package test + +fun argumentAdded(x: Int = 1) {} +fun argumentRemoved() {} + +fun valueAdded(x: Int = 3) {} +fun valueRemoved(x: Int) {} +fun valueChanged(x: Int = 6) {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/old.kt b/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/old.kt new file mode 100644 index 00000000000..5b95a0ab6a0 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/old.kt @@ -0,0 +1,8 @@ +package test + +fun argumentAdded() {} +fun argumentRemoved(x: Int = 2) {} + +fun valueAdded(x: Int) {} +fun valueRemoved(x: Int = 4) {} +fun valueChanged(x: Int = 5) {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/result.out b/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/result.out new file mode 100644 index 00000000000..7ddbb07ea53 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/defaultValues/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST +CHANGES in test/MainKt: MEMBERS + [argumentAdded, argumentRemoved, valueAdded, valueRemoved] diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/new.kt b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/new.kt new file mode 100644 index 00000000000..51b46517e9a --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/new.kt @@ -0,0 +1,20 @@ +package test + +annotation class Ann1 +annotation class Ann2 + +@Ann1 +@Ann2 +fun annotationListBecameNotEmpty() {} + +fun annotationListBecameEmpty() {} + +@Ann1 +@Ann2 +fun annotationAdded() {} + +@Ann1 +fun annotationRemoved() {} + +@Ann2 +fun annotationReplaced() {} diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/old.kt b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/old.kt new file mode 100644 index 00000000000..3d39ec4b409 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/old.kt @@ -0,0 +1,20 @@ +package test + +annotation class Ann1 +annotation class Ann2 + +fun annotationListBecameNotEmpty() {} + +@Ann1 +@Ann2 +fun annotationListBecameEmpty() {} + +@Ann1 +fun annotationAdded() {} + +@Ann1 +@Ann2 +fun annotationRemoved() {} + +@Ann1 +fun annotationReplaced() {} diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/result-js.out b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/result-js.out new file mode 100644 index 00000000000..fb07de09253 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/result-js.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST +CHANGES in test/MainKt: MEMBERS + [annotationAdded, annotationListBecameEmpty, annotationListBecameNotEmpty, annotationRemoved, annotationReplaced] diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/result.out b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/result.out new file mode 100644 index 00000000000..5a48016fb07 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersAnnotationListChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST +CHANGES in test/MainKt: MEMBERS + [annotationListBecameEmpty, annotationListBecameNotEmpty] diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/new.kt b/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/new.kt new file mode 100644 index 00000000000..a2d58035891 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/new.kt @@ -0,0 +1,55 @@ +package test + +const val constFlagAddedVal = "" +val constFlagRemovedVal = "" +const val constFlagUnchangedVal = "" + +external fun externalFlagAddedFun() +fun externalFlagRemovedFun() {} +external fun externalFlagUnchangedFun() + +@Suppress("INAPPLICABLE_INFIX_MODIFIER") +infix fun infixFlagAddedFun() {} +fun infixFlagRemovedFun() {} +@Suppress("INAPPLICABLE_INFIX_MODIFIER") +infix fun infixFlagUnchangedFun() {} + +inline fun inlineFlagAddedFun() {} +fun inlineFlagRemovedFun() {} +inline fun inlineFlagUnchangedFun() {} + +internal val internalFlagAddedVal = "" +val internalFlagRemovedVal = "" +internal val internalFlagUnchangedVal = "" +internal fun internalFlagAddedFun() {} +fun internalFlagRemovedFun() {} +internal fun internalFlagUnchangedFun() {} + +@Suppress("INAPPLICABLE_OPERATOR_MODIFIER") +operator fun operatorFlagAddedFun() {} +fun operatorFlagRemovedFun() {} +@Suppress("INAPPLICABLE_OPERATOR_MODIFIER") +operator fun operatorFlagUnchangedFun() {} + +private val privateFlagAddedVal = "" +val privateFlagRemovedVal = "" +private val privateFlagUnchangedVal = "" +private fun privateFlagAddedFun() {} +fun privateFlagRemovedFun() {} +private fun privateFlagUnchangedFun() {} + +public val publicFlagAddedVal = "" +val publicFlagRemovedVal = "" +public val publicFlagUnchangedVal = "" +public fun publicFlagAddedFun() {} +fun publicFlagRemovedFun() {} +public fun publicFlagUnchangedFun() {} + +tailrec fun tailrecFlagAddedFun() {} +fun tailrecFlagRemovedFun() {} +tailrec fun tailrecFlagUnchangedFun() {} + +val noFlagsUnchangedVal = "" +fun noFlagsUnchangedFun() {} + + diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/old.kt b/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/old.kt new file mode 100644 index 00000000000..9799a641449 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/old.kt @@ -0,0 +1,53 @@ +package test + +val constFlagAddedVal = "" +const val constFlagRemovedVal = "" +const val constFlagUnchangedVal = "" + +fun externalFlagAddedFun() {} +external fun externalFlagRemovedFun() +external fun externalFlagUnchangedFun() + +fun infixFlagAddedFun() {} +@Suppress("INAPPLICABLE_INFIX_MODIFIER") +infix fun infixFlagRemovedFun() {} +@Suppress("INAPPLICABLE_INFIX_MODIFIER") +infix fun infixFlagUnchangedFun() {} + +fun inlineFlagAddedFun() {} +inline fun inlineFlagRemovedFun() {} +inline fun inlineFlagUnchangedFun() {} + +val internalFlagAddedVal = "" +internal val internalFlagRemovedVal = "" +internal val internalFlagUnchangedVal = "" +fun internalFlagAddedFun() {} +internal fun internalFlagRemovedFun() {} +internal fun internalFlagUnchangedFun() {} + +fun operatorFlagAddedFun() {} +@Suppress("INAPPLICABLE_OPERATOR_MODIFIER") +operator fun operatorFlagRemovedFun() {} +@Suppress("INAPPLICABLE_OPERATOR_MODIFIER") +operator fun operatorFlagUnchangedFun() {} + +val privateFlagAddedVal = "" +private val privateFlagRemovedVal = "" +private val privateFlagUnchangedVal = "" +fun privateFlagAddedFun() {} +private fun privateFlagRemovedFun() {} +private fun privateFlagUnchangedFun() {} + +val publicFlagAddedVal = "" +public val publicFlagRemovedVal = "" +public val publicFlagUnchangedVal = "" +fun publicFlagAddedFun() {} +public fun publicFlagRemovedFun() {} +public fun publicFlagUnchangedFun() {} + +fun tailrecFlagAddedFun() {} +tailrec fun tailrecFlagRemovedFun() {} +tailrec fun tailrecFlagUnchangedFun() {} + +val noFlagsUnchangedVal = "" +fun noFlagsUnchangedFun() {} diff --git a/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/result.out b/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/result.out new file mode 100644 index 00000000000..81287d37eea --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/membersFlagsChanged/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/MainKt: MEMBERS + [constFlagAddedVal, constFlagRemovedVal, externalFlagAddedFun, externalFlagRemovedFun, infixFlagAddedFun, infixFlagRemovedFun, inlineFlagAddedFun, inlineFlagRemovedFun, internalFlagAddedFun, internalFlagAddedVal, internalFlagRemovedFun, internalFlagRemovedVal, operatorFlagAddedFun, operatorFlagRemovedFun, privateFlagAddedFun, privateFlagAddedVal, privateFlagRemovedFun, privateFlagRemovedVal, tailrecFlagAddedFun, tailrecFlagRemovedFun] diff --git a/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/new.kt b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/new.kt new file mode 100644 index 00000000000..9f98bc5a4b9 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/new.kt @@ -0,0 +1,11 @@ +package test + +public fun unchangedFun() {} + +private fun addedFun(): Int = 10 + +private val addedVal: String = "A" + +private val changedVal: String = "" + +private fun changedFun(arg: String) {} diff --git a/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/old.kt b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/old.kt new file mode 100644 index 00000000000..d84e45cd33e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/old.kt @@ -0,0 +1,11 @@ +package test + +public fun unchangedFun() {} + +private fun removedFun(): Int = 10 + +private val removedVal: String = "A" + +private val changedVal: Int = 20 + +private fun changedFun(arg: Int) {} diff --git a/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/result.out b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/result.out new file mode 100644 index 00000000000..8fe203691c2 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePrivateOnlyChanges/result.out @@ -0,0 +1 @@ +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST, PROPERTY_LIST diff --git a/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/new.kt b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/new.kt new file mode 100644 index 00000000000..e8d2d04161e --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/new.kt @@ -0,0 +1,13 @@ +package test + +public fun unchangedFun() {} + +public fun addedFun(): Int = 10 + +public val addedVal: String = "A" + +public val changedVal: String = "" + +internal fun changedFun(arg: String) {} + +private fun privateAddedFun() {} diff --git a/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/old.kt b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/old.kt new file mode 100644 index 00000000000..70876015aa5 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/old.kt @@ -0,0 +1,13 @@ +package test + +public fun unchangedFun() {} + +public fun removedFun(): Int = 10 + +public val removedVal: String = "A" + +public val changedVal: Int = 20 + +internal fun changedFun(arg: Int) {} + +private fun privateRemovedFun() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/result.out b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/result.out new file mode 100644 index 00000000000..0757a3f0fe6 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/packageMembers/packageFacadePublicChanges/result.out @@ -0,0 +1,3 @@ +PROTO DIFFERENCE in test/MainKt: FUNCTION_LIST, PROPERTY_LIST +CHANGES in test/MainKt: MEMBERS + [addedFun, addedVal, changedFun, changedVal, removedFun, removedVal] diff --git a/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/new.kt b/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/new.kt new file mode 100644 index 00000000000..0889792a218 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/new.kt @@ -0,0 +1,40 @@ +package test + +class UnchangedClassWithFunOnly { + public fun unchangedPublicFun() {} + protected fun unchangedProtectedFun() {} + internal fun unchangedInternalFun() {} + private fun unchangedPrivateFun() {} +} + +class UnchangedClassWithValOnly { + public val unchangedPublicVal = 10 + protected val unchangedProtectedVal = 10 + internal val unchangedInternalVal = 10 + private val unchangedPrivateVal = 10 +} + +class UnchangedClassWithVarOnly { + public var unchangedPublicVar = 20 + protected var unchangedProtectedVar = 20 + internal var unchangedInternalVar = 20 + private var unchangedPrivateVar = 20 +} + +class UnchangedClass { + public val unchangedPublicVal = 10 + protected val unchangedProtectedVal = 10 + internal val unchangedInternalVal = 10 + private val unchangedPrivateVal = 10 + + public var unchangedPublicVar = 20 + protected var unchangedProtectedVar = 20 + internal var unchangedInternalVar = 20 + private var unchangedPrivateVar = 20 + + public fun unchangedPublicFun() {} + protected fun unchangedProtectedFun() {} + internal fun unchangedInternalFun() {} + private fun unchangedPrivateFun() {} +} + diff --git a/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/old.kt b/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/old.kt new file mode 100644 index 00000000000..0889792a218 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/old.kt @@ -0,0 +1,40 @@ +package test + +class UnchangedClassWithFunOnly { + public fun unchangedPublicFun() {} + protected fun unchangedProtectedFun() {} + internal fun unchangedInternalFun() {} + private fun unchangedPrivateFun() {} +} + +class UnchangedClassWithValOnly { + public val unchangedPublicVal = 10 + protected val unchangedProtectedVal = 10 + internal val unchangedInternalVal = 10 + private val unchangedPrivateVal = 10 +} + +class UnchangedClassWithVarOnly { + public var unchangedPublicVar = 20 + protected var unchangedProtectedVar = 20 + internal var unchangedInternalVar = 20 + private var unchangedPrivateVar = 20 +} + +class UnchangedClass { + public val unchangedPublicVal = 10 + protected val unchangedProtectedVal = 10 + internal val unchangedInternalVal = 10 + private val unchangedPrivateVal = 10 + + public var unchangedPublicVar = 20 + protected var unchangedProtectedVar = 20 + internal var unchangedInternalVar = 20 + private var unchangedPrivateVar = 20 + + public fun unchangedPublicFun() {} + protected fun unchangedProtectedFun() {} + internal fun unchangedInternalFun() {} + private fun unchangedPrivateFun() {} +} + diff --git a/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/result.out b/jps/jps-plugin/testData/comparison/unchanged/unchangedClass/result.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/new.kt b/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/new.kt new file mode 100644 index 00000000000..0625597c878 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/new.kt @@ -0,0 +1,13 @@ +package test + +public fun unchangedFun() {} + +private fun unchangedPrivateFun(): Int = 10 + +public val unchangedVal: Int = 10 + +public var unchangedVar: Int = 20 + +private val unchangedPrivateVal: Int = 10 + +private var unchangedPrivateVar: Int = 20 diff --git a/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/old.kt b/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/old.kt new file mode 100644 index 00000000000..0625597c878 --- /dev/null +++ b/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/old.kt @@ -0,0 +1,13 @@ +package test + +public fun unchangedFun() {} + +private fun unchangedPrivateFun(): Int = 10 + +public val unchangedVal: Int = 10 + +public var unchangedVar: Int = 20 + +private val unchangedPrivateVal: Int = 10 + +private var unchangedPrivateVar: Int = 20 diff --git a/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/result.out b/jps/jps-plugin/testData/comparison/unchanged/unchangedPackageFacade/result.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/kotlinProject.iml b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/kotlinProject.iml new file mode 100644 index 00000000000..a441b33e10b --- /dev/null +++ b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/kotlinProject.ipr b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/src/src.kt b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/src/src.kt new file mode 100644 index 00000000000..a35e5b25181 --- /dev/null +++ b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/src/src.kt @@ -0,0 +1,15 @@ +fun foo() { } + +internal fun internalBar() {} + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation() + +@Target(AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFunctionAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() diff --git a/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/test/test.kt b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/test/test.kt new file mode 100644 index 00000000000..9d74548c058 --- /dev/null +++ b/jps/jps-plugin/testData/general/AccessToInternalInProductionFromTests/test/test.kt @@ -0,0 +1,25 @@ +@file:InternalFileAnnotation + +@InternalFunctionAnnotation +fun test() { + foo() + internalBar() + + @InternalClassAnnotation + class Local { + @InternalFunctionAnnotation + fun foo() {} + } +} + +@InternalClassAnnotation +class Class { + @InternalFunctionAnnotation + fun foo() {} + + @InternalClassAnnotation + class Nested { + @InternalFunctionAnnotation + fun foo() {} + } +} diff --git a/jps/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml b/jps/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr b/jps/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt b/jps/jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt new file mode 100644 index 00000000000..2c990ada4c7 --- /dev/null +++ b/jps/jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt @@ -0,0 +1,3 @@ +package foo + +class Bar diff --git a/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/kotlinProject.iml b/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/kotlinProject.ipr b/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/src/utils.kt b/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/src/utils.kt new file mode 100644 index 00000000000..30a67601741 --- /dev/null +++ b/jps/jps-plugin/testData/general/CheckIsCancelledIsCalledOftenEnough/src/utils.kt @@ -0,0 +1,3 @@ +package foo + +fun square(a: Int): Int = a*a \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/kotlinProject.iml b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/kotlinProject.iml new file mode 100644 index 00000000000..5559c7ad919 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/kotlinProject.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/kotlinProject.ipr new file mode 100644 index 00000000000..03619a4f72c --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/module2.iml new file mode 100644 index 00000000000..eace69878a2 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/src/JSecond.java b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/src/JSecond.java new file mode 100644 index 00000000000..e034bf38792 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/src/JSecond.java @@ -0,0 +1,5 @@ +public class JSecond { + public static void main(String[] args) { + new JFirst().foo(); + } +} diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/src/kt1.kt b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/src/kt1.kt new file mode 100644 index 00000000000..90c4941858e --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/module2/src/kt1.kt @@ -0,0 +1,7 @@ +package kt1 + +fun foo() {} + +fun bar() { + kt2.bar() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/src/JFirst.java b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/src/JFirst.java new file mode 100644 index 00000000000..12140d2a7e4 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/src/JFirst.java @@ -0,0 +1,11 @@ +public class JFirst { + JSecond s = null; + + public void foo() { + + } + + public static void main(String[] args) { + System.out.println(1); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/src/kt2.kt b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/src/kt2.kt new file mode 100644 index 00000000000..96dfcda26c4 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesDifferentPackages/src/kt2.kt @@ -0,0 +1,7 @@ +package kt2 + +fun foo() { + kt1.foo() +} + +fun bar() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt new file mode 100644 index 00000000000..109a31fe488 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt @@ -0,0 +1,10 @@ +'internal open val member: Int defined in test.ClassBB1' has no access to 'internal abstract val member: Int defined in test.ClassB1', so it cannot override it at line 14, column 14 +'public' subclass exposes its 'internal' supertype InternalClass1 at line 8, column 36 +'public' subclass exposes its 'internal' supertype InternalClass2 at line 18, column 36 +'public' subclass exposes its 'internal' supertype InternalClass2 at line 19, column 15 +Cannot access 'InternalClass1': it is internal in 'test' at line 5, column 13 +Cannot access 'InternalClass1': it is internal in 'test' at line 8, column 36 +Cannot access 'InternalClass2': it is internal in 'test' at line 19, column 15 +Cannot access 'InternalClassAnnotation': it is internal in 'test' at line 10, column 2 +Cannot access 'InternalFileAnnotation': it is internal in 'test' at line 1, column 7 +Cannot access 'member': it is invisible (private in a supertype) in 'ClassAA1' at line 27, column 25 diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/module1.iml b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/module1.iml new file mode 100644 index 00000000000..c9205eae762 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/module1.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt new file mode 100644 index 00000000000..9a7bdb153a3 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt @@ -0,0 +1,19 @@ +package test + +internal open class InternalClass1 + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() + +abstract class ClassA1(internal val member: Int) + +abstract class ClassB1 { + internal abstract val member: Int +} + +class ClassD: InternalClass2() \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/module2.iml new file mode 100644 index 00000000000..ecdc9e147ae --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/additional.kt b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/additional.kt new file mode 100644 index 00000000000..e7ebf8914c0 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/additional.kt @@ -0,0 +1,9 @@ +package test + +internal open class InternalClass2 + +abstract class ClassA2(internal val member: Int) + +abstract class ClassB2 { + internal abstract val member: Int +} diff --git a/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt new file mode 100644 index 00000000000..ece01121bd2 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt @@ -0,0 +1,31 @@ +@file:InternalFileAnnotation + +package test + +import test.InternalClass1 + +// InternalClass1, ClassA1, ClassB1 are in module1 +class ClassInheritedFromInternal1: InternalClass1() + +@InternalClassAnnotation +class ClassAA1 : ClassA1(10) + +class ClassBB1 : ClassB1() { + internal override val member = 10 +} + +// InternalClass2, ClassA2, ClassB2 are in module2 +class ClassInheritedFromInternal2: InternalClass2() + +class ClassAA2 : ClassA2(10) + +class ClassBB2 : ClassB2() { + internal override val member = 10 +} + +fun f() { + val x1 = ClassAA1().member + val x2 = ClassAA2().member +} + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/kotlinProject.iml b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/kotlinProject.iml new file mode 100644 index 00000000000..5559c7ad919 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/kotlinProject.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/kotlinProject.ipr new file mode 100644 index 00000000000..809737b0b76 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/module2/module2.iml new file mode 100644 index 00000000000..eace69878a2 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/module2/src/JSecond.java b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/module2/src/JSecond.java new file mode 100644 index 00000000000..e034bf38792 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/module2/src/JSecond.java @@ -0,0 +1,5 @@ +public class JSecond { + public static void main(String[] args) { + new JFirst().foo(); + } +} diff --git a/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/src/JFirst.java b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/src/JFirst.java new file mode 100644 index 00000000000..12140d2a7e4 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesNoKotlinFiles/src/JFirst.java @@ -0,0 +1,11 @@ +public class JFirst { + JSecond s = null; + + public void foo() { + + } + + public static void main(String[] args) { + System.out.println(1); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module1/module1.iml b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module1/module1.iml new file mode 100644 index 00000000000..c9205eae762 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module1/module1.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module1/src/a.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module1/src/a.kt new file mode 100644 index 00000000000..8311da66012 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module1/src/a.kt @@ -0,0 +1,7 @@ +package test + +fun a() { + +} + +val a = "" diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module2/module2.iml new file mode 100644 index 00000000000..ecdc9e147ae --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module2/src/b.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module2/src/b.kt new file mode 100644 index 00000000000..b04c387135d --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackage/module2/src/b.kt @@ -0,0 +1,7 @@ +package test + +fun b() { + +} + +var b = b() diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/module1.iml b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/module1.iml new file mode 100644 index 00000000000..a28a2f8285e --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/module1.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/src/a.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/src/a.kt new file mode 100644 index 00000000000..4da8772ebba --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/src/a.kt @@ -0,0 +1,9 @@ +package test + +fun a() { + +} + +internal fun funA() {} + +val a = "" diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/test/test_a_1.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/test/test_a_1.kt new file mode 100644 index 00000000000..e3526b4ac21 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/test/test_a_1.kt @@ -0,0 +1,3 @@ +package test + +internal fun testFunA() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/test/test_a_2.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/test/test_a_2.kt new file mode 100644 index 00000000000..028f7dbaa66 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module1/test/test_a_2.kt @@ -0,0 +1,6 @@ +package test + +fun foo() { + funA() + testFunA() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/module2.iml new file mode 100644 index 00000000000..a2e977d345b --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/module2.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/src/b.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/src/b.kt new file mode 100644 index 00000000000..395d5075411 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/src/b.kt @@ -0,0 +1,9 @@ +package test + +fun b() { + +} + +internal fun funB() {} + +var b = b() diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/test/test_b_1.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/test/test_b_1.kt new file mode 100644 index 00000000000..d6360452cef --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/test/test_b_1.kt @@ -0,0 +1,3 @@ +package test + +internal fun testFunB() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/test/test_b_2.kt b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/test/test_b_2.kt new file mode 100644 index 00000000000..b2dc2d25119 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesSamePackageWithTests/module2/test/test_b_2.kt @@ -0,0 +1,6 @@ +package test + +fun bar() { + funB() + testFunB() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/errors.txt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/errors.txt new file mode 100644 index 00000000000..24037a41f50 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/errors.txt @@ -0,0 +1,4 @@ +Cannot access 'funA': it is internal in 'test' at line 4, column 5 +Cannot access 'funB': it is internal in 'test' at line 4, column 5 +Cannot access 'testFunA': it is internal in 'test' at line 5, column 5 +Cannot access 'testFunB': it is internal in 'test' at line 5, column 5 \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/module1.iml b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/module1.iml new file mode 100644 index 00000000000..a28a2f8285e --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/module1.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/src/a.kt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/src/a.kt new file mode 100644 index 00000000000..4da8772ebba --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/src/a.kt @@ -0,0 +1,9 @@ +package test + +fun a() { + +} + +internal fun funA() {} + +val a = "" diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/test/test_a_1.kt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/test/test_a_1.kt new file mode 100644 index 00000000000..e3526b4ac21 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/test/test_a_1.kt @@ -0,0 +1,3 @@ +package test + +internal fun testFunA() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/test/test_a_2.kt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/test/test_a_2.kt new file mode 100644 index 00000000000..fb8416d39d3 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module1/test/test_a_2.kt @@ -0,0 +1,6 @@ +package test + +fun foo() { + funB() + testFunB() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/module2.iml new file mode 100644 index 00000000000..a2e977d345b --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/module2.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/src/b.kt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/src/b.kt new file mode 100644 index 00000000000..395d5075411 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/src/b.kt @@ -0,0 +1,9 @@ +package test + +fun b() { + +} + +internal fun funB() {} + +var b = b() diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/test/test_b_1.kt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/test/test_b_1.kt new file mode 100644 index 00000000000..d6360452cef --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/test/test_b_1.kt @@ -0,0 +1,3 @@ +package test + +internal fun testFunB() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/test/test_b_2.kt b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/test/test_b_2.kt new file mode 100644 index 00000000000..e9ce5c96421 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependenciesWrongInternalFromTests/module2/test/test_b_2.kt @@ -0,0 +1,6 @@ +package test + +fun bar() { + funA() + testFunA() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/kotlinProject.ipr b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/module1.iml b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/module1.iml new file mode 100644 index 00000000000..e9637fef0b3 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/module1.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/src/module1/JavaClass.java b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/src/module1/JavaClass.java new file mode 100644 index 00000000000..6bec9cbc7a6 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/src/module1/JavaClass.java @@ -0,0 +1,6 @@ +package module1; + +public class JavaClass { + public static void newJavaMethod() {} + public static void oldJavaMethod() {} +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/src/module1/b.kt b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/src/module1/b.kt new file mode 100644 index 00000000000..eed0941fbaf --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module1/src/module1/b.kt @@ -0,0 +1,11 @@ +package module1 + +import module2.* + +fun foo() { + JavaClass.oldJavaMethod() + JavaClass.newJavaMethod() + + KotlinObject.oldKotlinMethod() + KotlinObject.newKotlinMethod() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/module2.iml b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/module2.iml new file mode 100644 index 00000000000..bdec3f1d34a --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/module2.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/src/module2/KotlinObject.kt b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/src/module2/KotlinObject.kt new file mode 100644 index 00000000000..fa757e1de93 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/src/module2/KotlinObject.kt @@ -0,0 +1,9 @@ +package module2 + +public object KotlinObject { + public fun oldKotlinMethod() { + } + + public fun newKotlinMethod() { + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/src/module2/a.kt b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/src/module2/a.kt new file mode 100644 index 00000000000..10ecb462c1d --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/module2/src/module2/a.kt @@ -0,0 +1,11 @@ +package module2 + +import module1.* + +fun bar() { + JavaClass.oldJavaMethod() + JavaClass.newJavaMethod() + + KotlinObject.oldKotlinMethod() + KotlinObject.newKotlinMethod() +} diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module1/JavaClass.java b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module1/JavaClass.java new file mode 100644 index 00000000000..3ee75e14976 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module1/JavaClass.java @@ -0,0 +1,5 @@ +package lib.module1; + +public class JavaClass { + public static void oldJavaMethod() {} +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module1/b.kt b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module1/b.kt new file mode 100644 index 00000000000..2d7a7f20b33 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module1/b.kt @@ -0,0 +1,9 @@ +package lib.module1 + +import lib.module2.* + +fun foo() { + JavaClass.oldJavaMethod() + + KotlinObject.oldKotlinMethod() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module2/KotlinObject.kt b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module2/KotlinObject.kt new file mode 100644 index 00000000000..cb5a7f55c77 --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module2/KotlinObject.kt @@ -0,0 +1,6 @@ +package lib.module2 + +public object KotlinObject { + public fun oldKotlinMethod() { + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module2/a.kt b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module2/a.kt new file mode 100644 index 00000000000..ff5c408f39b --- /dev/null +++ b/jps/jps-plugin/testData/general/CircularDependencyWithReferenceToOldVersionLib/oldModuleLib/src/lib/module2/a.kt @@ -0,0 +1,9 @@ +package lib.module2 + +import lib.module1.* + +fun bar() { + JavaClass.oldJavaMethod() + + KotlinObject.oldKotlinMethod() +} diff --git a/jps/jps-plugin/testData/general/CodeInKotlinPackage/kotlinProject.iml b/jps/jps-plugin/testData/general/CodeInKotlinPackage/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/CodeInKotlinPackage/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/CodeInKotlinPackage/kotlinProject.ipr b/jps/jps-plugin/testData/general/CodeInKotlinPackage/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/CodeInKotlinPackage/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CodeInKotlinPackage/src/test1.kt b/jps/jps-plugin/testData/general/CodeInKotlinPackage/src/test1.kt new file mode 100644 index 00000000000..d68bb3a92ee --- /dev/null +++ b/jps/jps-plugin/testData/general/CodeInKotlinPackage/src/test1.kt @@ -0,0 +1,5 @@ +package kotlin.forever + +fun foo() { + +} diff --git a/jps/jps-plugin/testData/general/CustomDestination/kotlinProject.iml b/jps/jps-plugin/testData/general/CustomDestination/kotlinProject.iml new file mode 100644 index 00000000000..6d20898bff3 --- /dev/null +++ b/jps/jps-plugin/testData/general/CustomDestination/kotlinProject.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CustomDestination/kotlinProject.ipr b/jps/jps-plugin/testData/general/CustomDestination/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/CustomDestination/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/CustomDestination/src/A.kt b/jps/jps-plugin/testData/general/CustomDestination/src/A.kt new file mode 100644 index 00000000000..fb7337ede5b --- /dev/null +++ b/jps/jps-plugin/testData/general/CustomDestination/src/A.kt @@ -0,0 +1 @@ +class A \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/kotlinProject.iml b/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/kotlinProject.iml new file mode 100644 index 00000000000..d04ecd6e02e --- /dev/null +++ b/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/kotlinProject.ipr b/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/kotlinProject.ipr new file mode 100644 index 00000000000..001ea3380cd --- /dev/null +++ b/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/src/main.kt b/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/src/main.kt new file mode 100644 index 00000000000..bf1bc16df8e --- /dev/null +++ b/jps/jps-plugin/testData/general/DefaultLanguageVersionCustomApiVersion/src/main.kt @@ -0,0 +1,5 @@ +package test + +fun main(args: Array) { + arrayListOf(1, 2, 3).fill(0) +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/kotlinProject.ipr b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/kotlinProject.ipr new file mode 100644 index 00000000000..d324e31411d --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/kotlinProject.ipr @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/module.iml b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/module.iml new file mode 100644 index 00000000000..eff2a2bb0bf --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/module.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/A.kt b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/A.kt new file mode 100644 index 00000000000..3314395f737 --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/A.kt @@ -0,0 +1,6 @@ +package module + +public interface A { + fun oldFun(): Int = 1 + fun newFun(): Int = 42 +} diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/B.kt b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/B.kt new file mode 100644 index 00000000000..80f01b0be85 --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/B.kt @@ -0,0 +1,9 @@ +package module + +public class B(private val c: C) { + fun foo() { + val a = c.getA() + a.oldFun() + a.newFun() + } +} diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/C.java b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/C.java new file mode 100644 index 00000000000..0716f11da8f --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/module/src/module/C.java @@ -0,0 +1,5 @@ +package module; + +public interface C { + A getA(); +} diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/A.kt b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/A.kt new file mode 100644 index 00000000000..a54a9569787 --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/A.kt @@ -0,0 +1,5 @@ +package module + +public interface A { + fun oldFun(): Int = 1 +} diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/B.kt b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/B.kt new file mode 100644 index 00000000000..74aad6e1f3f --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/B.kt @@ -0,0 +1,8 @@ +package module + +public class B(private val c: C) { + fun foo() { + val a = c.getA() + a.oldFun() + } +} diff --git a/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/C.java b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/C.java new file mode 100644 index 00000000000..0716f11da8f --- /dev/null +++ b/jps/jps-plugin/testData/general/DependencyToOldKotlinLib/oldModuleLib/src/module/C.java @@ -0,0 +1,5 @@ +package module; + +public interface C { + A getA(); +} diff --git a/jps/jps-plugin/testData/general/DevKitProject/kotlinProject.iml b/jps/jps-plugin/testData/general/DevKitProject/kotlinProject.iml new file mode 100644 index 00000000000..e025b203cd5 --- /dev/null +++ b/jps/jps-plugin/testData/general/DevKitProject/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DevKitProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/DevKitProject/kotlinProject.ipr new file mode 100644 index 00000000000..cacdb365adc --- /dev/null +++ b/jps/jps-plugin/testData/general/DevKitProject/kotlinProject.ipr @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/DevKitProject/resources/META-INF/plugin.xml b/jps/jps-plugin/testData/general/DevKitProject/resources/META-INF/plugin.xml new file mode 100644 index 00000000000..736cd1df218 --- /dev/null +++ b/jps/jps-plugin/testData/general/DevKitProject/resources/META-INF/plugin.xml @@ -0,0 +1,35 @@ + + com.your.company.unique.plugin.id + Plugin display name here + 1.0 + YourCompany + + + most HTML tags may be used + ]]> + + + most HTML tags may be used + ]]> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DevKitProject/src/test.kt b/jps/jps-plugin/testData/general/DevKitProject/src/test.kt new file mode 100644 index 00000000000..adb5b33c573 --- /dev/null +++ b/jps/jps-plugin/testData/general/DevKitProject/src/test.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/kotlinProject.iml b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/kotlinProject.iml new file mode 100644 index 00000000000..a441b33e10b --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/kotlinProject.ipr b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/src/Src.java b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/src/Src.java new file mode 100644 index 00000000000..9afa4b2097c --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/src/Src.java @@ -0,0 +1,2 @@ +class Src { +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/test/test.kt b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/test/test.kt new file mode 100644 index 00000000000..c133c83fce7 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCaches/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + val x = 5 + 5 +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/kotlinProject.iml b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/kotlinProject.iml new file mode 100644 index 00000000000..3b1ba79ed61 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/kotlinProject.ipr b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/kotlinProject.ipr new file mode 100644 index 00000000000..809737b0b76 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/module2/module2.iml b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/module2/module2.iml new file mode 100644 index 00000000000..eace69878a2 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/module2/src/B.java b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/module2/src/B.java new file mode 100644 index 00000000000..66dd24ce675 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/module2/src/B.java @@ -0,0 +1,2 @@ +public class B { +} diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/src/A.java b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/src/A.java new file mode 100644 index 00000000000..61ff2abcc95 --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/src/A.java @@ -0,0 +1,2 @@ +public class A { +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/src/utils.kt b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/src/utils.kt new file mode 100644 index 00000000000..67d276629bf --- /dev/null +++ b/jps/jps-plugin/testData/general/DoNotCreateUselessKotlinIncrementalCachesForDependentTargets/src/utils.kt @@ -0,0 +1 @@ +fun f(): String = "f()" \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/EAPToReleaseIC/kotlinProject.iml b/jps/jps-plugin/testData/general/EAPToReleaseIC/kotlinProject.iml new file mode 100644 index 00000000000..d04ecd6e02e --- /dev/null +++ b/jps/jps-plugin/testData/general/EAPToReleaseIC/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/EAPToReleaseIC/kotlinProject.ipr b/jps/jps-plugin/testData/general/EAPToReleaseIC/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/EAPToReleaseIC/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/EAPToReleaseIC/src/Bar.kt b/jps/jps-plugin/testData/general/EAPToReleaseIC/src/Bar.kt new file mode 100644 index 00000000000..f577138fb1c --- /dev/null +++ b/jps/jps-plugin/testData/general/EAPToReleaseIC/src/Bar.kt @@ -0,0 +1,6 @@ +package test + +class Bar() { + fun bar() { + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/EAPToReleaseIC/src/Foo.kt b/jps/jps-plugin/testData/general/EAPToReleaseIC/src/Foo.kt new file mode 100644 index 00000000000..494c3dea241 --- /dev/null +++ b/jps/jps-plugin/testData/general/EAPToReleaseIC/src/Foo.kt @@ -0,0 +1,7 @@ +package test + +class Foo() { + fun foo() { + Bar().bar() + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/kotlinProject.iml b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/kotlinProject.ipr b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/kotlinProject.ipr new file mode 100644 index 00000000000..da39ecb6ab2 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/kotlinProject.ipr @@ -0,0 +1,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/Excluded.kt b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/Excluded.kt new file mode 100644 index 00000000000..06d7528e228 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/Excluded.kt @@ -0,0 +1 @@ +class Excluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/dir/YetAnotherExcluded.kt b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/dir/YetAnotherExcluded.kt new file mode 100644 index 00000000000..4b5f5c0c428 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/dir/YetAnotherExcluded.kt @@ -0,0 +1 @@ +class YetAnotherExcluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/dir/bar.kt b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/dir/bar.kt new file mode 100644 index 00000000000..4a643c4dde8 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/dir/bar.kt @@ -0,0 +1 @@ +class Bar \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/foo.kt b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/foo.kt new file mode 100644 index 00000000000..43c42f1453b --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFileUsingCompilerSettings/src/foo.kt @@ -0,0 +1 @@ +class Foo \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/kotlinProject.iml b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/kotlinProject.iml new file mode 100644 index 00000000000..54f25b2ccec --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/kotlinProject.ipr b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/src/exclude/Excluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/src/exclude/Excluded.kt new file mode 100644 index 00000000000..06d7528e228 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/src/exclude/Excluded.kt @@ -0,0 +1 @@ +class Excluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/src/foo.kt b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/src/foo.kt new file mode 100644 index 00000000000..43c42f1453b --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderInSourceRoot/src/foo.kt @@ -0,0 +1 @@ +class Foo \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/kotlinProject.iml b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/kotlinProject.ipr b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/kotlinProject.ipr new file mode 100644 index 00000000000..852485b023c --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/kotlinProject.ipr @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/Excluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/Excluded.kt new file mode 100644 index 00000000000..06d7528e228 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/Excluded.kt @@ -0,0 +1 @@ +class Excluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/subdir/YetAnotherExcluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/subdir/YetAnotherExcluded.kt new file mode 100644 index 00000000000..4b5f5c0c428 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/subdir/YetAnotherExcluded.kt @@ -0,0 +1 @@ +class YetAnotherExcluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/subdir/bar.kt b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/subdir/bar.kt new file mode 100644 index 00000000000..4a643c4dde8 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/dir/subdir/bar.kt @@ -0,0 +1 @@ +class Bar \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/foo.kt b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/foo.kt new file mode 100644 index 00000000000..43c42f1453b --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderNonRecursivelyUsingCompilerSettings/src/foo.kt @@ -0,0 +1 @@ +class Foo \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/kotlinProject.iml b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/kotlinProject.ipr b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/kotlinProject.ipr new file mode 100644 index 00000000000..9b497ed5475 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/bar.kt b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/bar.kt new file mode 100644 index 00000000000..4a643c4dde8 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/bar.kt @@ -0,0 +1 @@ +class Bar \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/Excluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/Excluded.kt new file mode 100644 index 00000000000..06d7528e228 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/Excluded.kt @@ -0,0 +1 @@ +class Excluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/YetAnotherExcluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/YetAnotherExcluded.kt new file mode 100644 index 00000000000..4b5f5c0c428 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/YetAnotherExcluded.kt @@ -0,0 +1 @@ +class YetAnotherExcluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/subdir/Excluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/subdir/Excluded.kt new file mode 100644 index 00000000000..06d7528e228 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/subdir/Excluded.kt @@ -0,0 +1 @@ +class Excluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/subdir/YetAnotherExcluded.kt b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/subdir/YetAnotherExcluded.kt new file mode 100644 index 00000000000..4b5f5c0c428 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/exclude/subdir/YetAnotherExcluded.kt @@ -0,0 +1 @@ +class YetAnotherExcluded \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/foo.kt b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/foo.kt new file mode 100644 index 00000000000..43c42f1453b --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeFolderRecursivelyUsingCompilerSettings/src/foo.kt @@ -0,0 +1 @@ +class Foo \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/kotlinProject.iml b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/kotlinProject.iml new file mode 100644 index 00000000000..5cff40145f7 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/kotlinProject.ipr b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/kotlinProject.ipr new file mode 100644 index 00000000000..35b084995b6 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/foo.kt b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/foo.kt new file mode 100644 index 00000000000..43c42f1453b --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/foo.kt @@ -0,0 +1 @@ +class Foo \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/module2/module2.iml b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/module2/module2.iml new file mode 100644 index 00000000000..3b1ba79ed61 --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/module2/module2.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/module2/src/foo.kt b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/module2/src/foo.kt new file mode 100644 index 00000000000..43c42f1453b --- /dev/null +++ b/jps/jps-plugin/testData/general/ExcludeModuleFolderInSourceRootOfAnotherModule/src/module2/src/foo.kt @@ -0,0 +1 @@ +class Foo \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/FileDoesNotExistWarning/kotlinProject.ipr b/jps/jps-plugin/testData/general/FileDoesNotExistWarning/kotlinProject.ipr new file mode 100644 index 00000000000..04d418ca179 --- /dev/null +++ b/jps/jps-plugin/testData/general/FileDoesNotExistWarning/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/FileDoesNotExistWarning/module.iml b/jps/jps-plugin/testData/general/FileDoesNotExistWarning/module.iml new file mode 100644 index 00000000000..4c925d6cab7 --- /dev/null +++ b/jps/jps-plugin/testData/general/FileDoesNotExistWarning/module.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/FileDoesNotExistWarning/src/Bar.kt b/jps/jps-plugin/testData/general/FileDoesNotExistWarning/src/Bar.kt new file mode 100644 index 00000000000..2c990ada4c7 --- /dev/null +++ b/jps/jps-plugin/testData/general/FileDoesNotExistWarning/src/Bar.kt @@ -0,0 +1,3 @@ +package foo + +class Bar diff --git a/jps/jps-plugin/testData/general/GetDependentTargets/expected.txt b/jps/jps-plugin/testData/general/GetDependentTargets/expected.txt new file mode 100644 index 00000000000..19377f83f9f --- /dev/null +++ b/jps/jps-plugin/testData/general/GetDependentTargets/expected.txt @@ -0,0 +1,42 @@ +Targets dependent on Module 'a' production: +Module 'a' tests +Module 'b' production +Module 'b' tests +Module 'b2' production +Module 'b2' tests +Module 'c' production +Module 'c' tests +--------- +Targets dependent on Module 'a' tests: +Module 'b' tests +Module 'b2' tests +Module 'c' tests +--------- +Targets dependent on Module 'b2' production: +Module 'b2' tests +Module 'c2' production +Module 'c2' tests +--------- +Targets dependent on Module 'b2' tests: +Module 'c2' tests +--------- +Targets dependent on Module 'c2' production: +Module 'c2' tests +--------- +Targets dependent on Module 'c2' tests: + +--------- +Targets dependent on Module 'b' production: +Module 'b' tests +Module 'c' production +Module 'c' tests +--------- +Targets dependent on Module 'b' tests: +Module 'c' tests +--------- +Targets dependent on Module 'c' production: +Module 'c' tests +--------- +Targets dependent on Module 'c' tests: + +--------- diff --git a/jps/jps-plugin/testData/general/GetDependentTargets/src/foo.kt b/jps/jps-plugin/testData/general/GetDependentTargets/src/foo.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/GetDependentTargets/src/foo.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/GetDependentTargets/test/test.kt b/jps/jps-plugin/testData/general/GetDependentTargets/test/test.kt new file mode 100644 index 00000000000..839220d1002 --- /dev/null +++ b/jps/jps-plugin/testData/general/GetDependentTargets/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + +} diff --git a/jps/jps-plugin/testData/general/Help/kotlinProject.iml b/jps/jps-plugin/testData/general/Help/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/Help/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/Help/kotlinProject.ipr b/jps/jps-plugin/testData/general/Help/kotlinProject.ipr new file mode 100644 index 00000000000..102bdf0ea20 --- /dev/null +++ b/jps/jps-plugin/testData/general/Help/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/Help/src/test.kt b/jps/jps-plugin/testData/general/Help/src/test.kt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt b/jps/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt new file mode 100644 index 00000000000..a0692a54537 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt @@ -0,0 +1,8 @@ +'internal open val member: Int defined in test.ClassBB1' has no access to 'internal abstract val member: Int defined in test.ClassB1', so it cannot override it at line 14, column 14 +'public' subclass exposes its 'internal' supertype InternalClass1 at line 8, column 36 +'public' subclass exposes its 'internal' supertype InternalClass2 at line 18, column 36 +Cannot access 'InternalClass1': it is internal in 'test' at line 5, column 13 +Cannot access 'InternalClass1': it is internal in 'test' at line 8, column 36 +Cannot access 'InternalClassAnnotation': it is internal in 'test' at line 10, column 2 +Cannot access 'InternalTestAnnotation': it is internal in 'test' at line 1, column 7 +Cannot access 'member': it is invisible (private in a supertype) in 'ClassAA1' at line 27, column 25 diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/kotlinProject.ipr b/jps/jps-plugin/testData/general/InternalFromAnotherModule/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/module1/module1.iml b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module1/module1.iml new file mode 100644 index 00000000000..3b1ba79ed61 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module1/module1.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt new file mode 100644 index 00000000000..e2fc0309302 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt @@ -0,0 +1,19 @@ +package test +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalTestAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() + +private class PrivateClass1 + +internal open class InternalClass1 + +abstract class ClassA1(internal val member: Int) + +abstract class ClassB1 { + internal abstract val member: Int +} + diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/module2.iml b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/module2.iml new file mode 100644 index 00000000000..ecdc9e147ae --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/additional.kt b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/additional.kt new file mode 100644 index 00000000000..e7ebf8914c0 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/additional.kt @@ -0,0 +1,9 @@ +package test + +internal open class InternalClass2 + +abstract class ClassA2(internal val member: Int) + +abstract class ClassB2 { + internal abstract val member: Int +} diff --git a/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt new file mode 100644 index 00000000000..155a4c3a341 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt @@ -0,0 +1,31 @@ +@file:InternalTestAnnotation + +package test + +import test.InternalClass1 + +// InternalClass1, ClassA1, ClassB1 are in module1 +class ClassInheritedFromInternal1: InternalClass1() + +@InternalClassAnnotation +class ClassAA1 : ClassA1(10) + +class ClassBB1 : ClassB1() { + internal override val member = 10 +} + +// InternalClass2, ClassA2, ClassB2 are in module2 +class ClassInheritedFromInternal2: InternalClass2() + +class ClassAA2 : ClassA2(10) + +class ClassBB2 : ClassB2() { + internal override val member = 10 +} + +fun f() { + val x1 = ClassAA1().member + val x2 = ClassAA2().member +} + + diff --git a/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/kotlinProject.ipr b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module1/module1.iml b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module1/module1.iml new file mode 100644 index 00000000000..3b1ba79ed61 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module1/module1.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module1/src/foo.kt b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module1/src/foo.kt new file mode 100644 index 00000000000..830308321e1 --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module1/src/foo.kt @@ -0,0 +1,27 @@ +package test1 + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation1() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation1() + +@Target(AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFunctionAnnotation1() + +internal open class InternalClass1 + +abstract class ClassA1(internal val member: Int) + +abstract class ClassB1 { + internal abstract val member: Int + internal fun func() = 1 +} + +internal val internalProp = 1 + +internal fun internalFun() {} + diff --git a/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module2/module2.iml b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module2/module2.iml new file mode 100644 index 00000000000..427f7bce96f --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module2/module2.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module2/test/bar.kt b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module2/test/bar.kt new file mode 100644 index 00000000000..22519ed79af --- /dev/null +++ b/jps/jps-plugin/testData/general/InternalFromSpecialRelatedModule/module2/test/bar.kt @@ -0,0 +1,33 @@ +@file:InternalFileAnnotation1 + +package test2 + +import test1.* + +internal class FromInternalClass1: InternalClass1() + +@InternalClassAnnotation1 +class FromClassA1 : ClassA1(10) { + @InternalClassAnnotation1 + class Nested { + @InternalFunctionAnnotation1 + fun foo() {} + } +} + +class FromClassB1 : ClassB1() { + internal override val member = 10 +} + +@InternalFunctionAnnotation1 +fun foo() {} + +fun box() { + internalProp + internalFun() + + InternalClass1() + FromClassA1().member + FromClassB1().member + FromClassB1().func() +} diff --git a/jps/jps-plugin/testData/general/JKJInheritanceProject/kotlinProject.iml b/jps/jps-plugin/testData/general/JKJInheritanceProject/kotlinProject.iml new file mode 100644 index 00000000000..5d6f3a17863 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJInheritanceProject/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/JKJInheritanceProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/JKJInheritanceProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJInheritanceProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JKJInheritanceProject/src/java/JFirst.java b/jps/jps-plugin/testData/general/JKJInheritanceProject/src/java/JFirst.java new file mode 100644 index 00000000000..681465bd981 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJInheritanceProject/src/java/JFirst.java @@ -0,0 +1,7 @@ +package java; + +public class JFirst { + public void foo() { + + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JKJInheritanceProject/src/java/JSecond.java b/jps/jps-plugin/testData/general/JKJInheritanceProject/src/java/JSecond.java new file mode 100644 index 00000000000..8642080e27e --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJInheritanceProject/src/java/JSecond.java @@ -0,0 +1,7 @@ +package java; + +public class JSecond extends kt.KFirst { + public void bar() { + foo(); + } +} diff --git a/jps/jps-plugin/testData/general/JKJInheritanceProject/src/kotlin/KFirst.kt b/jps/jps-plugin/testData/general/JKJInheritanceProject/src/kotlin/KFirst.kt new file mode 100644 index 00000000000..0b2d2794572 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJInheritanceProject/src/kotlin/KFirst.kt @@ -0,0 +1,5 @@ +package kt + +open class KFirst(): java.JFirst() { + +} diff --git a/jps/jps-plugin/testData/general/JKJProject/kotlinProject.iml b/jps/jps-plugin/testData/general/JKJProject/kotlinProject.iml new file mode 100644 index 00000000000..10db71f5cd2 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJProject/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JKJProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/JKJProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JKJProject/src/java/JFirst.java b/jps/jps-plugin/testData/general/JKJProject/src/java/JFirst.java new file mode 100644 index 00000000000..bcdc7cbd4f7 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJProject/src/java/JFirst.java @@ -0,0 +1,7 @@ +package java; + +public class JFirst { + public void foo() { + new myproject.kotlin.KFirst().foo(); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JKJProject/src/java/JSecond.java b/jps/jps-plugin/testData/general/JKJProject/src/java/JSecond.java new file mode 100644 index 00000000000..8d126964842 --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJProject/src/java/JSecond.java @@ -0,0 +1,7 @@ +package java; + +public class JSecond { + public void foo() { + + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JKJProject/src/kotlin/KFirst.kt b/jps/jps-plugin/testData/general/JKJProject/src/kotlin/KFirst.kt new file mode 100644 index 00000000000..d3f96de0f7f --- /dev/null +++ b/jps/jps-plugin/testData/general/JKJProject/src/kotlin/KFirst.kt @@ -0,0 +1,7 @@ +package myproject.kotlin + +class KFirst() { + fun foo() { + java.JSecond().foo() + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JpsDaemonIC/kotlinProject.iml b/jps/jps-plugin/testData/general/JpsDaemonIC/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/JpsDaemonIC/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/JpsDaemonIC/kotlinProject.ipr b/jps/jps-plugin/testData/general/JpsDaemonIC/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps/jps-plugin/testData/general/JpsDaemonIC/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/JpsDaemonIC/src/Foo.kt b/jps/jps-plugin/testData/general/JpsDaemonIC/src/Foo.kt new file mode 100644 index 00000000000..5ff6c09c578 --- /dev/null +++ b/jps/jps-plugin/testData/general/JpsDaemonIC/src/Foo.kt @@ -0,0 +1 @@ +class Foo() \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/JpsDaemonIC/src/main.kt b/jps/jps-plugin/testData/general/JpsDaemonIC/src/main.kt new file mode 100644 index 00000000000..27c36e10d47 --- /dev/null +++ b/jps/jps-plugin/testData/general/JpsDaemonIC/src/main.kt @@ -0,0 +1,3 @@ +fun main() { + Foo() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/Jre9/kotlinProject.iml b/jps/jps-plugin/testData/general/Jre9/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/Jre9/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/Jre9/kotlinProject.ipr b/jps/jps-plugin/testData/general/Jre9/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/Jre9/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/Jre9/src/test.kt b/jps/jps-plugin/testData/general/Jre9/src/test.kt new file mode 100644 index 00000000000..a03a648dfd4 --- /dev/null +++ b/jps/jps-plugin/testData/general/Jre9/src/test.kt @@ -0,0 +1,14 @@ +import java.nio.file.Path +import java.util.stream.IntStream +import java.util.function.Consumer + +class Foo : Consumer { + override fun accept(path: Path) {} +} + +fun foo(s: IntStream): List { + println(s.boxed()) + Any() + if (s.count() == 0L) throw Exception() + return object : ArrayList() {} +} diff --git a/jps/jps-plugin/testData/general/KJCircularProject/kotlinProject.iml b/jps/jps-plugin/testData/general/KJCircularProject/kotlinProject.iml new file mode 100644 index 00000000000..d04ecd6e02e --- /dev/null +++ b/jps/jps-plugin/testData/general/KJCircularProject/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJCircularProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/KJCircularProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJCircularProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJCircularProject/src/java/JFirst.java b/jps/jps-plugin/testData/general/KJCircularProject/src/java/JFirst.java new file mode 100644 index 00000000000..5f400f48562 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJCircularProject/src/java/JFirst.java @@ -0,0 +1,11 @@ +package java; + +public class JFirst { + public void foo() { + new myproject.kotlin.KFirst().foo(); + } + + public void bar() { + new myproject.kotlin.KFirst().bar(); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJCircularProject/src/kotlin/KFirst.kt b/jps/jps-plugin/testData/general/KJCircularProject/src/kotlin/KFirst.kt new file mode 100644 index 00000000000..0641836f93f --- /dev/null +++ b/jps/jps-plugin/testData/general/KJCircularProject/src/kotlin/KFirst.kt @@ -0,0 +1,9 @@ +package myproject.kotlin + +class KFirst() { + fun foo() { + java.JFirst().bar() + } + + fun bar() {} +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJKInheritanceProject/kotlinProject.iml b/jps/jps-plugin/testData/general/KJKInheritanceProject/kotlinProject.iml new file mode 100644 index 00000000000..864e89613d7 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKInheritanceProject/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KJKInheritanceProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/KJKInheritanceProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKInheritanceProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJKInheritanceProject/src/java/JFirst.java b/jps/jps-plugin/testData/general/KJKInheritanceProject/src/java/JFirst.java new file mode 100644 index 00000000000..987a5777332 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKInheritanceProject/src/java/JFirst.java @@ -0,0 +1,4 @@ +package java; + +public class JFirst extends kt.KFirst { +} diff --git a/jps/jps-plugin/testData/general/KJKInheritanceProject/src/kotlin/KFirst.kt b/jps/jps-plugin/testData/general/KJKInheritanceProject/src/kotlin/KFirst.kt new file mode 100644 index 00000000000..8a5eaf4c6de --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKInheritanceProject/src/kotlin/KFirst.kt @@ -0,0 +1,6 @@ +package kt + +open class KFirst() { + fun foo() { + } +} diff --git a/jps/jps-plugin/testData/general/KJKInheritanceProject/src/kotlin/KSecond.kt b/jps/jps-plugin/testData/general/KJKInheritanceProject/src/kotlin/KSecond.kt new file mode 100644 index 00000000000..a36c93094f3 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKInheritanceProject/src/kotlin/KSecond.kt @@ -0,0 +1,7 @@ +package kt + +class KSecond(): java.JFirst() { + fun bar() { + foo() + } +} diff --git a/jps/jps-plugin/testData/general/KJKProject/kotlinProject.iml b/jps/jps-plugin/testData/general/KJKProject/kotlinProject.iml new file mode 100644 index 00000000000..864e89613d7 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKProject/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KJKProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/KJKProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJKProject/src/java/JFirst.java b/jps/jps-plugin/testData/general/KJKProject/src/java/JFirst.java new file mode 100644 index 00000000000..1f4b4e26910 --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKProject/src/java/JFirst.java @@ -0,0 +1,7 @@ +package java; + +public class JFirst { + public void foo() { + new myproject.kotlin.KSecond().foo(); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJKProject/src/kotlin/KFirst.kt b/jps/jps-plugin/testData/general/KJKProject/src/kotlin/KFirst.kt new file mode 100644 index 00000000000..536328b73dc --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKProject/src/kotlin/KFirst.kt @@ -0,0 +1,7 @@ +package myproject.kotlin + +class KFirst() { + fun foo() { + java.JFirst().foo() + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KJKProject/src/kotlin/KSecond.kt b/jps/jps-plugin/testData/general/KJKProject/src/kotlin/KSecond.kt new file mode 100644 index 00000000000..af0f67ec98f --- /dev/null +++ b/jps/jps-plugin/testData/general/KJKProject/src/kotlin/KSecond.kt @@ -0,0 +1,7 @@ +package myproject.kotlin + +class KSecond() { + fun foo() { + + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaProject/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaProject/kotlinProject.iml new file mode 100644 index 00000000000..d04ecd6e02e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaProject/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaProject/src/Test.java b/jps/jps-plugin/testData/general/KotlinJavaProject/src/Test.java new file mode 100644 index 00000000000..1c47016bd6d --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaProject/src/Test.java @@ -0,0 +1,6 @@ +import test.*; +class A { + public static void main(String[] args) { + new Foo().foo(); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaProject/src/kotlinFile.kt b/jps/jps-plugin/testData/general/KotlinJavaProject/src/kotlinFile.kt new file mode 100644 index 00000000000..cdf55aa68be --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaProject/src/kotlinFile.kt @@ -0,0 +1,7 @@ +package test + +class Foo() { + fun foo() { + + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/expected-output.txt new file mode 100644 index 00000000000..ab908429b52 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/expected-output.txt @@ -0,0 +1,9 @@ +kotlinProject/ + kotlinProject/ + package1/ + package1.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + kotlin.js + kotlin.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/src/Class1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/src/Class1.kt new file mode 100644 index 00000000000..0e406383c52 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/src/Class1.kt @@ -0,0 +1,3 @@ +package package1 + +class Class1 \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/src/Class2.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/src/Class2.kt new file mode 100644 index 00000000000..7df6ade3cc8 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptChangePackage/src/Class2.kt @@ -0,0 +1,3 @@ +package package2 + +class Class2 \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module1/module1.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module1/module1.iml new file mode 100644 index 00000000000..3b1ba79ed61 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module1/module1.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module1/src/foo.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module1/src/foo.kt new file mode 100644 index 00000000000..830308321e1 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module1/src/foo.kt @@ -0,0 +1,27 @@ +package test1 + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation1() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation1() + +@Target(AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFunctionAnnotation1() + +internal open class InternalClass1 + +abstract class ClassA1(internal val member: Int) + +abstract class ClassB1 { + internal abstract val member: Int + internal fun func() = 1 +} + +internal val internalProp = 1 + +internal fun internalFun() {} + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module2/module2.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module2/module2.iml new file mode 100644 index 00000000000..3535f0fb297 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module2/module2.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module2/test/bar.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module2/test/bar.kt new file mode 100644 index 00000000000..22519ed79af --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptInternalFromSpecialRelatedModule/module2/test/bar.kt @@ -0,0 +1,33 @@ +@file:InternalFileAnnotation1 + +package test2 + +import test1.* + +internal class FromInternalClass1: InternalClass1() + +@InternalClassAnnotation1 +class FromClassA1 : ClassA1(10) { + @InternalClassAnnotation1 + class Nested { + @InternalFunctionAnnotation1 + fun foo() {} + } +} + +class FromClassB1 : ClassB1() { + internal override val member = 10 +} + +@InternalFunctionAnnotation1 +fun foo() {} + +fun box() { + internalProp + internalFun() + + InternalClass1() + FromClassA1().member + FromClassB1().member + FromClassB1().func() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProject/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/expected-output.txt new file mode 100644 index 00000000000..541f661545e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/expected-output.txt @@ -0,0 +1,8 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + kotlin.js + kotlin.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProject/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProject/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/src/test1.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProject/src/test1.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/assets/resource.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/assets/resource.txt new file mode 100755 index 00000000000..30d74d25844 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/assets/resource.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/expected-output.txt new file mode 100644 index 00000000000..ed929602d07 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/expected-output.txt @@ -0,0 +1,9 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + kotlin.js + kotlin.meta.js + resource.txt \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/kotlinProject.iml new file mode 100644 index 00000000000..2bc53878496 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/kotlinProject.ipr new file mode 100644 index 00000000000..cfe9e11ba2e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/src/Main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/src/Main.kt new file mode 100755 index 00000000000..174582e286c --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectNewSourceRootTypes/src/Main.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + println("Hello") +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/expected-output.txt new file mode 100644 index 00000000000..2d80d94ec34 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/expected-output.txt @@ -0,0 +1,16 @@ +my_js/ + lib/ + kotlin.js + kotlin.meta.js + myproject/ + root-package.kjsm + myproject.js + myproject.meta.js +my_test-js/ + lib/ + kotlin.js + kotlin.meta.js + myproject-tests/ + root-package.kjsm + myproject-tests.js + myproject-tests.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/kotlinProject.iml new file mode 100644 index 00000000000..2b070ee7b93 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/kotlinProject.iml @@ -0,0 +1,32 @@ + + + + + + $MODULE_DIR$/target/my_js/myproject.js + $MODULE_DIR$/target/my_test-js/myproject-tests.js + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/main.kt new file mode 100644 index 00000000000..adb5b33c573 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/main.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/main/kotlin/main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/main/kotlin/main.kt new file mode 100644 index 00000000000..adb5b33c573 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/main/kotlin/main.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/test/kotlin/test.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/test/kotlin/test.kt new file mode 100644 index 00000000000..442858bd7b3 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithCustomOutputPaths/src/test/kotlin/test.kt @@ -0,0 +1,3 @@ +fun test() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/expected-output.txt new file mode 100644 index 00000000000..b0ae98fc0c7 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/expected-output.txt @@ -0,0 +1,18 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + META-INF-ex/ + file2.js + dir/ + file1.js + file0.js + jslib-example.js + jslib-example.meta.js + kotlin.js + kotlin.meta.js + res0.js + resdir/ + res1.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/LibraryExample.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/LibraryExample.kt new file mode 100644 index 00000000000..28569346084 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/LibraryExample.kt @@ -0,0 +1,8 @@ +package library.sample + +public fun pairAdd(p: Pair): Int = p.first + p.second + +public fun pairMul(p: Pair): Int = p.first * p.second + +public data class IntHolder(val value: Int) + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF-ex/file2.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF-ex/file2.js new file mode 100644 index 00000000000..fa48e44e0bd --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF-ex/file2.js @@ -0,0 +1 @@ +// file2.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..9ed17555cdc --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.9.1 +Created-By: 1.7.0_72-b14 (Oracle Corporation) +Built-By: JetBrains +Implementation-Vendor: JetBrains +Implementation-Version: snapshot +Specification-Title: Kotlin JavaScript Lib + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/ignored0.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/ignored0.js new file mode 100644 index 00000000000..909c0013f88 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/ignored0.js @@ -0,0 +1 @@ +// ignored0.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/ignoredDir/ignored1.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/ignoredDir/ignored1.js new file mode 100644 index 00000000000..3bccb9f3229 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/ignoredDir/ignored1.js @@ -0,0 +1 @@ +// ignored1.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources-ex/file4.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources-ex/file4.js new file mode 100644 index 00000000000..198bed92695 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources-ex/file4.js @@ -0,0 +1 @@ +// file4.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources/res0.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources/res0.js new file mode 100644 index 00000000000..e69df221fdd --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources/res0.js @@ -0,0 +1 @@ +// res0.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources/resdir/res1.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources/resdir/res1.js new file mode 100644 index 00000000000..feb4eaecdb3 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/resources/resdir/res1.js @@ -0,0 +1 @@ +// res1.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md new file mode 100644 index 00000000000..9e82278e756 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md @@ -0,0 +1,6 @@ +# jslib-example + +Path to sources: `compiler/testData/cli/js/jslib` + +The archive compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar should be updated after +changing some files in source folder. \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/dir/file1.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/dir/file1.js new file mode 100644 index 00000000000..4b868025b44 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/dir/file1.js @@ -0,0 +1 @@ +// file1.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/file0.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/file0.js new file mode 100644 index 00000000000..a269fd47e90 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/file0.js @@ -0,0 +1 @@ +// file0.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js new file mode 100644 index 00000000000..68154be1e35 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js @@ -0,0 +1,44 @@ +if (typeof kotlin === 'undefined') { + throw new Error("Error loading module 'LibraryExample'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'LibraryExample'."); +} +var LibraryExample = function (_, Kotlin) { + 'use strict'; + function pairAdd(p) { + return p.first + p.second | 0; + } + function pairMul(p) { + return Kotlin.imul(p.first, p.second); + } + function IntHolder(value) { + this.value = value; + } + IntHolder.$metadata$ = { + kind: Kotlin.Kind.CLASS, + simpleName: 'IntHolder', + interfaces: [] + }; + IntHolder.prototype.component1 = function () { + return this.value; + }; + IntHolder.prototype.copy_za3lpa$ = function (value) { + return new IntHolder(value === void 0 ? this.value : value); + }; + IntHolder.prototype.toString = function () { + return 'IntHolder(value=' + Kotlin.toString(this.value) + ')'; + }; + IntHolder.prototype.hashCode = function () { + var result = 0; + result = result * 31 + Kotlin.hashCode(this.value) | 0; + return result; + }; + IntHolder.prototype.equals = function (other) { + return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value)))); + }; + var package$library = _.library || (_.library = {}); + var package$sample = package$library.sample || (package$library.sample = {}); + package$sample.pairAdd_1fzo63$ = pairAdd; + package$sample.pairMul_1fzo63$ = pairMul; + package$sample.IntHolder = IntHolder; + Kotlin.defineModule('LibraryExample', _); + return _; +}(typeof LibraryExample === 'undefined' ? {} : LibraryExample, kotlin); diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.meta.js b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.meta.js new file mode 100644 index 00000000000..5dd2ffc566e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.meta.js @@ -0,0 +1 @@ +// Kotlin.kotlin_module_metadata(1, "LibraryExample", "H4sIAAAAAAAAAJVW227TQBB1fF1Pb64LJTUgRBEgbiWkCIEESC19KJWQgIoPcJ1tsqmzG9ZO0v4Ar0h9QP2UfAGf0N+BcS5O0tRu6gfvaHdmzlzOjq2490FxFa94Rv4Nn0LXHsmnRHE9sMD49oOz2NVBdRTPPCNK11aSs4cwD+aRiEPGQWXChUQBdKI4hUQNffVcvIabqZol6WFIgxjUeuQ6I318Fxw1sVK7tjp0rtf9tg96K2ZhlvOXsJo6n6fHTSpZg/LYzzToBV3/2aLyBNQWy1J7BzdAE7IKWmczAK0iGqAFUeSuXowZ36qjJaZa19YS0yfgpCGZ0udVGmWh7MNGqgqBkAJT5TSazASA8VgyHrFgJvwNWBoP/bgm8yv9CBbSIJJEr1OSlgxnCakIRs90mkO3gQzbMX34AGCEmBXWxhi95gLRaPqSRYJn1vw5rKT6dkQRmgfZHXqBSacdakqBbYlZtvqFYMKE6ywnmAn3IwLkXaVeQayjmhRcRGB06EE1zG/wZY2L2tVZGvcebl00NWkbaTkTEycGRD0zqx4H+mrTHNgcq1AP3zhosbCSn/FTWJ4aOVnobyZSnMMGHwrZ8JEU+RjPwE0xCN5QKnn21NmC9asvej7ebw3+FMAK2YH0cXaZkd9ohhTszzzeFWGFylGZtvgJGG0/bFHQ8DhBbDQFR5BXoAeiidbIez+MwNoWIqQ+B0PENXRBan5U+yQqFEgs9pOpUwVzsFpNn8mtSgUKTdC/otzf+dIK3Y9jgZtJ4EUFdzSUNUdHOVnNwQqDdXGwLhcVb8e76yx5askou47jLbq6i3L/XSJdouCxm3Pcr/M6I79IUS2rJX2buKZjJBZ7tmMl6+5fbW/FISiqZYI8NfqbBdy0UTTLxJnz9GKhpO+ea2g03zs/L6C4gKKF4veBSwQ8JSpMDdpkdM7OygMpOhGVWYR5C2tjvhe4iNkhC/z+MMlFKSHKyNI4pHFQy7d4DIuTUyUrqERxmIAe0+PMOzXxSam3Mz8pd8BOGT199T9A8eLwQcbJCMk4y/Qp46AfmVsdIY+ovGbxWEivsFgDs/+fMh3/Dty79MdnbFzMkMbEJ8LnyIQeCzJK6g1U/wOSAB0W3QkAAA=="); diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example/library/sample/sample.kjsm b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example/library/sample/sample.kjsm new file mode 100644 index 00000000000..f53578c8ac0 Binary files /dev/null and b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example/library/sample/sample.kjsm differ diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/src/test1.kt new file mode 100644 index 00000000000..ee0be644f22 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/src/test1.kt @@ -0,0 +1,7 @@ +import library.sample.pairAdd + +fun foo() { + val p = Pair(10, 20) + val x = pairAdd(p) + println("x=$x") +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/expected-output.txt new file mode 100644 index 00000000000..541f661545e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/expected-output.txt @@ -0,0 +1,8 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + kotlin.js + kotlin.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/src/test1.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsStdlib/src/test1.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrc/emptySrc.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrc/emptySrc.iml new file mode 100644 index 00000000000..9e63df53537 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrc/emptySrc.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrc/src/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrc/src/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/emptySrcEmptyTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/emptySrcEmptyTests.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/emptySrcEmptyTests.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/src/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/src/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/test/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcEmptyTests/test/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcMissingTests/emptySrcMissingTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcMissingTests/emptySrcMissingTests.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcMissingTests/emptySrcMissingTests.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcMissingTests/src/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptySrcMissingTests/src/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptyTests/emptyTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptyTests/emptyTests.iml new file mode 100644 index 00000000000..966eb57b22c --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptyTests/emptyTests.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptyTests/test/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/emptyTests/test/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/kotlinProject.iml new file mode 100644 index 00000000000..5f2d0c9a429 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/kotlinProject.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/kotlinProject.ipr new file mode 100644 index 00000000000..585c3fbb608 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/kotlinProject.ipr @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrc/missingSrc.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrc/missingSrc.iml new file mode 100644 index 00000000000..9e63df53537 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrc/missingSrc.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcEmptyTests/missingSrcEmptyTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcEmptyTests/missingSrcEmptyTests.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcEmptyTests/missingSrcEmptyTests.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcEmptyTests/test/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcEmptyTests/test/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcMissingTests/missingSrcMissingTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcMissingTests/missingSrcMissingTests.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingSrcMissingTests/missingSrcMissingTests.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingTests/missingTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingTests/missingTests.iml new file mode 100644 index 00000000000..966eb57b22c --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/missingTests/missingTests.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/src/Main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/src/Main.kt new file mode 100644 index 00000000000..ff9c5e0b940 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/src/Main.kt @@ -0,0 +1,4 @@ +fun main() { + srcEmptyTestsSrc() + srcMissingTestsSrc() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/src/SrcEmptyTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/src/SrcEmptyTests.kt new file mode 100644 index 00000000000..cc763116f77 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/src/SrcEmptyTests.kt @@ -0,0 +1 @@ +fun srcEmptyTestsSrc() {} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/srcEmptyTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/srcEmptyTests.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/srcEmptyTests.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/test/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcEmptyTests/test/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcMissingTests/src/SrcMissingTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcMissingTests/src/SrcMissingTests.kt new file mode 100644 index 00000000000..c7d5b4972fc --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcMissingTests/src/SrcMissingTests.kt @@ -0,0 +1 @@ +fun srcMissingTestsSrc() {} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcMissingTests/srcMissingTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcMissingTests/srcMissingTests.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/srcMissingTests/srcMissingTests.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/test/MainTest.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/test/MainTest.kt new file mode 100644 index 00000000000..61c73ddab94 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/test/MainTest.kt @@ -0,0 +1,4 @@ +fun test() { + testsEmptySrcTest() + testsMissingSrcTest() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/src/dummy b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/src/dummy new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/test/TestsEmptySrc.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/test/TestsEmptySrc.kt new file mode 100644 index 00000000000..39589622fc5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/test/TestsEmptySrc.kt @@ -0,0 +1 @@ +fun testsEmptySrcTest() {} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/testsEmptySrc.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/testsEmptySrc.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsEmptySrc/testsEmptySrc.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsMissingSrc/test/TestsMissingSrc.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsMissingSrc/test/TestsMissingSrc.kt new file mode 100644 index 00000000000..f2d092bab0c --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsMissingSrc/test/TestsMissingSrc.kt @@ -0,0 +1 @@ +fun testsMissingSrcTest() {} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsMissingSrc/testsMissingSrc.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsMissingSrc/testsMissingSrc.iml new file mode 100644 index 00000000000..0ab15714c75 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithEmptyDependencies/testsMissingSrc/testsMissingSrc.iml @@ -0,0 +1,12 @@ + + + + + + i + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/expected-output.txt new file mode 100644 index 00000000000..b0ae98fc0c7 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/expected-output.txt @@ -0,0 +1,18 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + META-INF-ex/ + file2.js + dir/ + file1.js + file0.js + jslib-example.js + jslib-example.meta.js + kotlin.js + kotlin.meta.js + res0.js + resdir/ + res1.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/src/test1.kt new file mode 100644 index 00000000000..ee0be644f22 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibrary/src/test1.kt @@ -0,0 +1,7 @@ +import library.sample.pairAdd + +fun foo() { + val p = Pair(10, 20) + val x = pairAdd(p) + println("x=$x") +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/expected-output.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/kotlinProject.ipr new file mode 100644 index 00000000000..12af7dde89a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/src/test1.kt new file mode 100644 index 00000000000..f1204a3d82e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryAndErrors/src/test1.kt @@ -0,0 +1,7 @@ +import library.sample.pairAdd + +fun foo() { + val p = Pair1(10, 20) + val x = pairAdd(p) + println("x=$x") +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/expected-output.txt new file mode 100644 index 00000000000..f1738e23acb --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/expected-output.txt @@ -0,0 +1,18 @@ +kotlinProject/ + custom/ + META-INF-ex/ + file2.js + dir/ + file1.js + file0.js + jslib-example.js + jslib-example.meta.js + kotlin.js + kotlin.meta.js + res0.js + resdir/ + res1.js + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/kotlinProject.ipr new file mode 100644 index 00000000000..8fed56d0828 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/kotlinProject.ipr @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/src/test1.kt new file mode 100644 index 00000000000..ee0be644f22 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryCustomOutputDir/src/test1.kt @@ -0,0 +1,7 @@ +import library.sample.pairAdd + +fun foo() { + val p = Pair(10, 20) + val x = pairAdd(p) + println("x=$x") +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/expected-output.txt new file mode 100644 index 00000000000..cb855b4fc58 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/expected-output.txt @@ -0,0 +1,5 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/kotlinProject.ipr new file mode 100644 index 00000000000..12af7dde89a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/src/test1.kt new file mode 100644 index 00000000000..ee0be644f22 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithLibraryNoCopy/src/test1.kt @@ -0,0 +1,7 @@ +import library.sample.pairAdd + +fun foo() { + val p = Pair(10, 20) + val x = pairAdd(p) + println("x=$x") +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/kotlinProject.ipr new file mode 100644 index 00000000000..16a88d84040 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/kotlinProject.ipr @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/src/pkg/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/src/pkg/test1.kt new file mode 100644 index 00000000000..112bd39189a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMap/src/pkg/test1.kt @@ -0,0 +1,7 @@ +package pkg + +var log = "" + +fun foo(x: String) { + log += "$x;" +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/kotlinProject.ipr new file mode 100644 index 00000000000..8ad5a239b86 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/src/pkg/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/src/pkg/test1.kt new file mode 100644 index 00000000000..112bd39189a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithSourceMapRelativePaths/src/pkg/test1.kt @@ -0,0 +1,7 @@ +package pkg + +var log = "" + +fun foo(x: String) { + log += "$x;" +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/kotlinProject.iml new file mode 100644 index 00000000000..350676073d1 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/kotlinProject.ipr new file mode 100644 index 00000000000..0c363fe68d2 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/src/Main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/src/Main.kt new file mode 100644 index 00000000000..bc18855ddf8 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/src/Main.kt @@ -0,0 +1,6 @@ +fun main() { +} + +internal fun internalFun() {} + +internal val internalVal = 10 diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/tests/MainTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/tests/MainTests.kt new file mode 100644 index 00000000000..ad63f184bce --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTests/tests/MainTests.kt @@ -0,0 +1,5 @@ +fun testMain() { + main() + internalFun() + var a = internalVal +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/kotlinProject.iml new file mode 100644 index 00000000000..62e30d76009 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/kotlinProject.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/kotlinProject.ipr new file mode 100644 index 00000000000..6c1fe3fe02d --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/kotlinProject.ipr @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/src/Main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/src/Main.kt new file mode 100644 index 00000000000..d922182462e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/src/Main.kt @@ -0,0 +1,3 @@ +fun main() { + srcOnly() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/srcOnly/src/SrcOnly.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/srcOnly/src/SrcOnly.kt new file mode 100644 index 00000000000..51563329121 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/srcOnly/src/SrcOnly.kt @@ -0,0 +1 @@ +fun srcOnly() {} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/srcOnly/srcOnly.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/srcOnly/srcOnly.iml new file mode 100644 index 00000000000..c90834f2d60 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/srcOnly/srcOnly.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/tests/MainTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/tests/MainTests.kt new file mode 100644 index 00000000000..882f75a9953 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/tests/MainTests.kt @@ -0,0 +1,5 @@ +fun testMain() { + main() + srcOnly() + testsOnly() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/testsOnly/tests/TestsOnly.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/testsOnly/tests/TestsOnly.kt new file mode 100644 index 00000000000..b9c5f8d81ae --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/testsOnly/tests/TestsOnly.kt @@ -0,0 +1 @@ +fun testsOnly() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/testsOnly/testsOnly.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/testsOnly/testsOnly.iml new file mode 100644 index 00000000000..d732721923c --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies/testsOnly/testsOnly.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/kotlinProject.iml new file mode 100644 index 00000000000..f3d9af241fb --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/kotlinProject.ipr new file mode 100644 index 00000000000..6a444a0b5a8 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/src/Main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/src/Main.kt new file mode 100644 index 00000000000..d4f0711d3f5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/src/Main.kt @@ -0,0 +1,7 @@ +import src.* +import test.* + +fun main() { + srcAndTests() + ambiguous() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/src/SrcAndTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/src/SrcAndTests.kt new file mode 100644 index 00000000000..6bee19ef6ee --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/src/SrcAndTests.kt @@ -0,0 +1,5 @@ +package src + +fun srcAndTests() {} + +fun ambiguous() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/src/test.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/src/test.kt new file mode 100644 index 00000000000..b7533d96c37 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/src/test.kt @@ -0,0 +1,3 @@ +package test + +private fun dummy() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/srcAndTests.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/srcAndTests.iml new file mode 100644 index 00000000000..fc6e2c7a9cf --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/srcAndTests.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/tests/SrcAndTestsTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/tests/SrcAndTestsTests.kt new file mode 100644 index 00000000000..7b7f50ed9b5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/srcAndTests/tests/SrcAndTestsTests.kt @@ -0,0 +1,9 @@ +package test + +import src.srcAndTests + +fun testSrcAndTests() { + srcAndTests() +} + +fun ambiguous() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/tests/MainTests.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/tests/MainTests.kt new file mode 100644 index 00000000000..a4442b1ed71 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency/tests/MainTests.kt @@ -0,0 +1,8 @@ +import src.* +import test.* + +fun testMain() { + main() + srcAndTests() + testSrcAndTests() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/expected-output.txt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/expected-output.txt new file mode 100644 index 00000000000..a48c2449988 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/expected-output.txt @@ -0,0 +1,17 @@ +kotlinProject/ + kotlinProject/ + root-package.kjsm + kotlinProject.js + kotlinProject.meta.js + lib/ + kotlin.js + kotlin.meta.js +module2/ + lib/ + kotlin.js + kotlin.meta.js + module2/ + module2/ + module2.kjsm + module2.js + module2.meta.js \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/kotlinProject.iml new file mode 100644 index 00000000000..11fe0ade95d --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/kotlinProject.ipr new file mode 100644 index 00000000000..b02ca501ac3 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/module2/module2.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/module2/module2.iml new file mode 100644 index 00000000000..e9637fef0b3 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/module2/module2.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/module2/src/module2.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/module2/src/module2.kt new file mode 100644 index 00000000000..3a30f60150a --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/module2/src/module2.kt @@ -0,0 +1,5 @@ +package module2 + +fun foo() {} + +public class Module2Class \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/src/test1.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/src/test1.kt new file mode 100644 index 00000000000..8f001cc1b99 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoModules/src/test1.kt @@ -0,0 +1,5 @@ +import module2.Module2Class + +fun foo() { + val tmp = Module2Class() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/kotlinProject.iml new file mode 100644 index 00000000000..3776f58cd73 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/kotlinProject.ipr new file mode 100644 index 00000000000..30c1d27da77 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/src/Main.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/src/Main.kt new file mode 100644 index 00000000000..4ec96fd4e15 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/src/Main.kt @@ -0,0 +1,4 @@ +fun main() { + src() + src2() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/src/Src.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/src/Src.kt new file mode 100644 index 00000000000..840b4c4a485 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/src/Src.kt @@ -0,0 +1,3 @@ +fun src() { + src2() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/src2/Src2.kt b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/src2/Src2.kt new file mode 100644 index 00000000000..2e9a4c8ea07 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/src2/Src2.kt @@ -0,0 +1,3 @@ +fun src2() { + src() +} diff --git a/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/srcs.iml b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/srcs.iml new file mode 100644 index 00000000000..cdfacea2bb6 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinJavaScriptProjectWithTwoSrcModuleDependency/srcs/srcs.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProject/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProject/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProject/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProject/src/test1.kt b/jps/jps-plugin/testData/general/KotlinProject/src/test1.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProject/src/test1.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/src/test1.kt b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/src/test1.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/src/test1.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/src/test2.kt b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/src/test2.kt new file mode 100644 index 00000000000..6ec77d22887 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectTwoFilesInOnePackage/src/test2.kt @@ -0,0 +1,3 @@ +fun bar() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/kotlinProject.ipr new file mode 100644 index 00000000000..7dc391eaceb --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/kotlinProject.ipr @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/produciton_module/produciton_module.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/produciton_module/produciton_module.iml new file mode 100644 index 00000000000..786d75db373 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/produciton_module/produciton_module.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/produciton_module/src/foo.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/produciton_module/src/foo.kt new file mode 100644 index 00000000000..f3b2ebc5254 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/produciton_module/src/foo.kt @@ -0,0 +1,3 @@ +fun foo() { + +} diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/test_module/test/test.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/test_module/test/test.kt new file mode 100644 index 00000000000..798f616299e --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/test_module/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + foo() +} diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/test_module/test_module.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/test_module/test_module.iml new file mode 100644 index 00000000000..62cd41c3ccb --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyOutputDirInSomeModules/test_module/test_module.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/errors.txt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/errors.txt new file mode 100644 index 00000000000..2c6966278ba --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/errors.txt @@ -0,0 +1 @@ +Output directory not specified for Module 'kotlinProject' production at line -1, column -1 diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.iml new file mode 100644 index 00000000000..43ffa57d1e2 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/src/foo.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/src/foo.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/src/foo.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/test/test.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/test/test.kt new file mode 100644 index 00000000000..839220d1002 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + +} diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/kotlinProject.iml new file mode 100644 index 00000000000..43ffa57d1e2 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/kotlinProject.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/test/test.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/test/test.kt new file mode 100644 index 00000000000..839220d1002 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDirWithoutSrcDir/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + +} diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.iml new file mode 100644 index 00000000000..3e989c372d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/src/foo.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/src/foo.kt new file mode 100644 index 00000000000..a2c4e958bb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/src/foo.kt @@ -0,0 +1,3 @@ +fun foo() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/test/test.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/test/test.kt new file mode 100644 index 00000000000..839220d1002 --- /dev/null +++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + +} diff --git a/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/kotlinProject.iml b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/kotlinProject.iml new file mode 100644 index 00000000000..2d09c426ff0 --- /dev/null +++ b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/kotlinProject.ipr b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/src/Bar.kt b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/src/Bar.kt new file mode 100644 index 00000000000..f577138fb1c --- /dev/null +++ b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/src/Bar.kt @@ -0,0 +1,6 @@ +package test + +class Bar() { + fun bar() { + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/src/Foo.kt b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/src/Foo.kt new file mode 100644 index 00000000000..494c3dea241 --- /dev/null +++ b/jps/jps-plugin/testData/general/LanguageOrApiVersionChanged/src/Foo.kt @@ -0,0 +1,7 @@ +package test + +class Foo() { + fun foo() { + Bar().bar() + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ManyFiles/kotlinProject.iml b/jps/jps-plugin/testData/general/ManyFiles/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFiles/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ManyFiles/kotlinProject.ipr b/jps/jps-plugin/testData/general/ManyFiles/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFiles/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ManyFiles/src/Bar.kt b/jps/jps-plugin/testData/general/ManyFiles/src/Bar.kt new file mode 100644 index 00000000000..2c990ada4c7 --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFiles/src/Bar.kt @@ -0,0 +1,3 @@ +package foo + +class Bar diff --git a/jps/jps-plugin/testData/general/ManyFiles/src/boo.kt b/jps/jps-plugin/testData/general/ManyFiles/src/boo.kt new file mode 100644 index 00000000000..e9a050624da --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFiles/src/boo.kt @@ -0,0 +1,6 @@ +package boo + +import foo.Bar + +fun boo(bar: Bar) { +} diff --git a/jps/jps-plugin/testData/general/ManyFiles/src/main.kt b/jps/jps-plugin/testData/general/ManyFiles/src/main.kt new file mode 100644 index 00000000000..cfcbc18690b --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFiles/src/main.kt @@ -0,0 +1,8 @@ +package foo + +import boo.boo + +fun main(args: Array) { + val bar = Bar() + boo(bar) +} diff --git a/jps/jps-plugin/testData/general/ManyFilesForPackage/kotlinProject.iml b/jps/jps-plugin/testData/general/ManyFilesForPackage/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFilesForPackage/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ManyFilesForPackage/kotlinProject.ipr b/jps/jps-plugin/testData/general/ManyFilesForPackage/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFilesForPackage/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ManyFilesForPackage/src/Bar.kt b/jps/jps-plugin/testData/general/ManyFilesForPackage/src/Bar.kt new file mode 100644 index 00000000000..ae9e0be1836 --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFilesForPackage/src/Bar.kt @@ -0,0 +1,5 @@ +package foo + +class Bar + +fun other() {} diff --git a/jps/jps-plugin/testData/general/ManyFilesForPackage/src/boo.kt b/jps/jps-plugin/testData/general/ManyFilesForPackage/src/boo.kt new file mode 100644 index 00000000000..e9a050624da --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFilesForPackage/src/boo.kt @@ -0,0 +1,6 @@ +package boo + +import foo.Bar + +fun boo(bar: Bar) { +} diff --git a/jps/jps-plugin/testData/general/ManyFilesForPackage/src/main.kt b/jps/jps-plugin/testData/general/ManyFilesForPackage/src/main.kt new file mode 100644 index 00000000000..cfcbc18690b --- /dev/null +++ b/jps/jps-plugin/testData/general/ManyFilesForPackage/src/main.kt @@ -0,0 +1,8 @@ +package foo + +import boo.boo + +fun main(args: Array) { + val bar = Bar() + boo(bar) +} diff --git a/jps/jps-plugin/testData/general/PureJavaProject/kotlinProject.iml b/jps/jps-plugin/testData/general/PureJavaProject/kotlinProject.iml new file mode 100644 index 00000000000..d04ecd6e02e --- /dev/null +++ b/jps/jps-plugin/testData/general/PureJavaProject/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/PureJavaProject/kotlinProject.ipr b/jps/jps-plugin/testData/general/PureJavaProject/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/PureJavaProject/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/PureJavaProject/src/Test.java b/jps/jps-plugin/testData/general/PureJavaProject/src/Test.java new file mode 100644 index 00000000000..fc22b4f6f3b --- /dev/null +++ b/jps/jps-plugin/testData/general/PureJavaProject/src/Test.java @@ -0,0 +1,5 @@ +class A { + public static void main(String[] args) { + System.out.println("Hello"); + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/kotlinProject.iml b/jps/jps-plugin/testData/general/ReexportedDependency/kotlinProject.iml new file mode 100644 index 00000000000..d0e6f385eb5 --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/kotlinProject.ipr b/jps/jps-plugin/testData/general/ReexportedDependency/kotlinProject.ipr new file mode 100644 index 00000000000..79176c748e4 --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/kotlinProject.ipr @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/J.class b/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/J.class new file mode 100644 index 00000000000..7acb6f1e525 Binary files /dev/null and b/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/J.class differ diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/J.java b/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/J.java new file mode 100644 index 00000000000..bfa3c7fce0e --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/J.java @@ -0,0 +1,9 @@ +package j; + +import java.lang.String; + +public class J { + public String foo() { + return ""; + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/annotations.xml b/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/annotations.xml new file mode 100644 index 00000000000..fed8e0dba5a --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module2/lib/j/annotations.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module2/module2.iml b/jps/jps-plugin/testData/general/ReexportedDependency/module2/module2.iml new file mode 100644 index 00000000000..053fd136108 --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module2/src/JSecond.java b/jps/jps-plugin/testData/general/ReexportedDependency/module2/src/JSecond.java new file mode 100644 index 00000000000..3e46ffeedad --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module2/src/JSecond.java @@ -0,0 +1,2 @@ +public class JSecond { +} diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module2/src/my.kt b/jps/jps-plugin/testData/general/ReexportedDependency/module2/src/my.kt new file mode 100644 index 00000000000..ad29e527067 --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module2/src/my.kt @@ -0,0 +1 @@ +class K2 \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module3/module3.iml b/jps/jps-plugin/testData/general/ReexportedDependency/module3/module3.iml new file mode 100644 index 00000000000..ec820d23084 --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module3/module3.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/module3/src/m3.kt b/jps/jps-plugin/testData/general/ReexportedDependency/module3/src/m3.kt new file mode 100644 index 00000000000..3310c2c0f0f --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/module3/src/m3.kt @@ -0,0 +1,8 @@ +fun f() { + JSecond() + K2() + println("Hi") + takeNN(j.J().foo()) +} + +fun takeNN(a: Any) {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/ReexportedDependency/src/main.kt b/jps/jps-plugin/testData/general/ReexportedDependency/src/main.kt new file mode 100644 index 00000000000..da493d01c7d --- /dev/null +++ b/jps/jps-plugin/testData/general/ReexportedDependency/src/main.kt @@ -0,0 +1,7 @@ +fun main() { + f() + JSecond() + K2() + println("Hi") + takeNN(j.J().foo()) +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/RelocatableCaches/kotlinProject.iml b/jps/jps-plugin/testData/general/RelocatableCaches/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps/jps-plugin/testData/general/RelocatableCaches/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/RelocatableCaches/kotlinProject.ipr b/jps/jps-plugin/testData/general/RelocatableCaches/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps/jps-plugin/testData/general/RelocatableCaches/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/RelocatableCaches/src/Foo.kt b/jps/jps-plugin/testData/general/RelocatableCaches/src/Foo.kt new file mode 100644 index 00000000000..0ac80e28778 --- /dev/null +++ b/jps/jps-plugin/testData/general/RelocatableCaches/src/Foo.kt @@ -0,0 +1,9 @@ +open class Foo() { + companion object { + const val CONST = 0 + } + + inline fun bar() = 1 +} + +class FooChild() : Foo() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/RelocatableCaches/src/main.kt b/jps/jps-plugin/testData/general/RelocatableCaches/src/main.kt new file mode 100644 index 00000000000..2e5d000513e --- /dev/null +++ b/jps/jps-plugin/testData/general/RelocatableCaches/src/main.kt @@ -0,0 +1,8 @@ +import utils.* + +fun main() { + Foo().bar() + Foo.CONST + util1() + util2() +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/RelocatableCaches/src/utils/utils_part1.kt b/jps/jps-plugin/testData/general/RelocatableCaches/src/utils/utils_part1.kt new file mode 100644 index 00000000000..c83e13459bd --- /dev/null +++ b/jps/jps-plugin/testData/general/RelocatableCaches/src/utils/utils_part1.kt @@ -0,0 +1,6 @@ +@file:JvmMultifileClass +@file:JvmName("Utils") + +package utils + +fun util1() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/RelocatableCaches/src/utils/utils_part2.kt b/jps/jps-plugin/testData/general/RelocatableCaches/src/utils/utils_part2.kt new file mode 100644 index 00000000000..0b1c8be0204 --- /dev/null +++ b/jps/jps-plugin/testData/general/RelocatableCaches/src/utils/utils_part2.kt @@ -0,0 +1,6 @@ +@file:JvmMultifileClass +@file:JvmName("Utils") + +package utils + +fun util2() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/kotlinProject.ipr b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/kotlinProject.ipr new file mode 100644 index 00000000000..c1a403dd047 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/kotlinProject.ipr @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/module1.iml b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/module1.iml new file mode 100644 index 00000000000..0e80071dec9 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/module1.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/JavaDependency.java b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/JavaDependency.java new file mode 100644 index 00000000000..a62f5d9cb15 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/JavaDependency.java @@ -0,0 +1,6 @@ +package good.prefix; + +public class JavaDependency { + public void bar() {} +} + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/JavaTest.java b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/JavaTest.java new file mode 100644 index 00000000000..3274d3549d7 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/JavaTest.java @@ -0,0 +1,6 @@ +package good.prefix; + +public class JavaTest extends JavaDependency { + +} + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/inBadPrefix.kt b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/inBadPrefix.kt new file mode 100644 index 00000000000..609e07b4c73 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/inBadPrefix.kt @@ -0,0 +1,4 @@ +package bad.prefix + +class KotlinTestInBadPrefix + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/isGoodPrefix.kt b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/isGoodPrefix.kt new file mode 100644 index 00000000000..90c847137fa --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/isGoodPrefix.kt @@ -0,0 +1,3 @@ +package good.prefix + +class KotlinTestInGoodPrefix \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/test/other/otherTest.kt b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/test/other/otherTest.kt new file mode 100644 index 00000000000..d27a3ac6bf5 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module1/src/test/other/otherTest.kt @@ -0,0 +1,9 @@ +package test.other + +import bad.prefix.KotlinTestInBadPrefix +import good.prefix.KotlinTestInGoodPrefix +import good.prefix.JavaTest; + +val goodTest = KotlinTestInGoodPrefix() +val badTest = KotlinTestInBadPrefix() +val javaTest = JavaTest().bar() diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/module2.iml b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/module2.iml new file mode 100644 index 00000000000..5517bfe3dd6 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/module2.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt new file mode 100644 index 00000000000..54cd6bd4c70 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt @@ -0,0 +1,11 @@ +package some + +import bad.prefix.KotlinTestInBadPrefix +import good.prefix.KotlinTestInGoodPrefix +import good.prefix.JavaTest; + +val goodTest = KotlinTestInGoodPrefix() +val badTest = KotlinTestInBadPrefix() +val javaTest = JavaTest().bar() + + diff --git a/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/test/JavaRef.java b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/test/JavaRef.java new file mode 100644 index 00000000000..cecb63b8131 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/test/JavaRef.java @@ -0,0 +1,9 @@ +package test; + +import good.prefix.JavaTest; + +public class JavaRef { + public void foo(JavaTest javaTest) { + + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefix/kotlinProject.iml b/jps/jps-plugin/testData/general/SourcePackagePrefix/kotlinProject.iml new file mode 100644 index 00000000000..cbc89b8246b --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefix/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefix/kotlinProject.ipr b/jps/jps-plugin/testData/general/SourcePackagePrefix/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefix/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefix/src/OtherJava.java b/jps/jps-plugin/testData/general/SourcePackagePrefix/src/OtherJava.java new file mode 100644 index 00000000000..0bb1d196b40 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefix/src/OtherJava.java @@ -0,0 +1,4 @@ +package xxx; + +public class OtherJava { +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefix/src/Test.java b/jps/jps-plugin/testData/general/SourcePackagePrefix/src/Test.java new file mode 100644 index 00000000000..7588040949b --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefix/src/Test.java @@ -0,0 +1,7 @@ +package xxx; + +public class Test { + String test(OtherJava otherJava) { + return ""; + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefix/src/test.kt b/jps/jps-plugin/testData/general/SourcePackagePrefix/src/test.kt new file mode 100644 index 00000000000..1059b01fe47 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefix/src/test.kt @@ -0,0 +1,3 @@ +package xxx + +val test = Test().test(null) \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/kotlinProject.iml b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/kotlinProject.iml new file mode 100644 index 00000000000..cbc89b8246b --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/kotlinProject.ipr b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/src/JavaWithInner.java b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/src/JavaWithInner.java new file mode 100644 index 00000000000..d210fa6a2d7 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/src/JavaWithInner.java @@ -0,0 +1,14 @@ +package xxx; + +import xxx.JavaWithInner.TableRenderer.TableRow; + +public class JavaWithInner { + public static class TableRenderer{ + public interface TableRow { + } + } + + public static class TextRenderer implements TableRow { + public void method() {} + } +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/src/test.kt b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/src/test.kt new file mode 100644 index 00000000000..eaca9b80696 --- /dev/null +++ b/jps/jps-plugin/testData/general/SourcePackagePrefixWithInnerClasses/src/test.kt @@ -0,0 +1,3 @@ +package xxx + +val test = JavaWithInner.TextRenderer().method() \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/TestDependencyLibrary/kotlinProject.iml b/jps/jps-plugin/testData/general/TestDependencyLibrary/kotlinProject.iml new file mode 100644 index 00000000000..a441b33e10b --- /dev/null +++ b/jps/jps-plugin/testData/general/TestDependencyLibrary/kotlinProject.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/TestDependencyLibrary/kotlinProject.ipr b/jps/jps-plugin/testData/general/TestDependencyLibrary/kotlinProject.ipr new file mode 100644 index 00000000000..90747786771 --- /dev/null +++ b/jps/jps-plugin/testData/general/TestDependencyLibrary/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/TestDependencyLibrary/src/src.kt b/jps/jps-plugin/testData/general/TestDependencyLibrary/src/src.kt new file mode 100644 index 00000000000..2d1ad72754c --- /dev/null +++ b/jps/jps-plugin/testData/general/TestDependencyLibrary/src/src.kt @@ -0,0 +1 @@ +fun foo() { } \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/TestDependencyLibrary/test/test.kt b/jps/jps-plugin/testData/general/TestDependencyLibrary/test/test.kt new file mode 100644 index 00000000000..e3cac1c58f9 --- /dev/null +++ b/jps/jps-plugin/testData/general/TestDependencyLibrary/test/test.kt @@ -0,0 +1,3 @@ +fun test() { + println("a") +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/WrongArgument/kotlinProject.iml b/jps/jps-plugin/testData/general/WrongArgument/kotlinProject.iml new file mode 100644 index 00000000000..a0cbe548242 --- /dev/null +++ b/jps/jps-plugin/testData/general/WrongArgument/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/jps-plugin/testData/general/WrongArgument/kotlinProject.ipr b/jps/jps-plugin/testData/general/WrongArgument/kotlinProject.ipr new file mode 100644 index 00000000000..a9c7f866ea1 --- /dev/null +++ b/jps/jps-plugin/testData/general/WrongArgument/kotlinProject.ipr @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-plugin/testData/general/WrongArgument/src/test.kt b/jps/jps-plugin/testData/general/WrongArgument/src/test.kt new file mode 100644 index 00000000000..e69de29bb2d