[CLI] Drop CommonCompilerArguments.coroutinesState

This commit is contained in:
Dmitriy Novozhilov
2020-12-02 13:22:40 +03:00
committed by TeamCityServer
parent df3b12e13b
commit e991c9d476
19 changed files with 13 additions and 181 deletions
@@ -17,9 +17,6 @@ interface BuildMetaInfo {
val compilerBuildVersion: String
val languageVersionString: String
val apiVersionString: String
val coroutinesEnable: Boolean
val coroutinesWarn: Boolean
val coroutinesError: Boolean
val multiplatformEnable: Boolean
val metadataVersionMajor: Int
val metadataVersionMinor: Int
@@ -35,9 +32,6 @@ abstract class BuildMetaInfoFactory<T : BuildMetaInfo>(private val metaInfoClass
compilerBuildVersion: String,
languageVersionString: String,
apiVersionString: String,
coroutinesEnable: Boolean,
coroutinesWarn: Boolean,
coroutinesError: Boolean,
multiplatformEnable: Boolean,
ownVersion: Int,
coroutinesVersion: Int,
@@ -53,9 +47,6 @@ abstract class BuildMetaInfoFactory<T : BuildMetaInfo>(private val metaInfoClass
compilerBuildVersion = KotlinCompilerVersion.VERSION,
languageVersionString = languageVersion.versionString,
apiVersionString = args.apiVersion ?: languageVersion.versionString,
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
multiplatformEnable = args.multiPlatform,
ownVersion = OWN_VERSION,
coroutinesVersion = COROUTINES_VERSION,
@@ -15,9 +15,6 @@ data class CommonBuildMetaInfo(
override val compilerBuildVersion: String,
override val languageVersionString: String,
override val apiVersionString: String,
override val coroutinesEnable: Boolean,
override val coroutinesWarn: Boolean,
override val coroutinesError: Boolean,
override val multiplatformEnable: Boolean,
override val metadataVersionMajor: Int,
override val metadataVersionMinor: Int,
@@ -32,9 +29,6 @@ data class CommonBuildMetaInfo(
compilerBuildVersion: String,
languageVersionString: String,
apiVersionString: String,
coroutinesEnable: Boolean,
coroutinesWarn: Boolean,
coroutinesError: Boolean,
multiplatformEnable: Boolean,
ownVersion: Int,
coroutinesVersion: Int,
@@ -47,9 +41,6 @@ data class CommonBuildMetaInfo(
compilerBuildVersion = compilerBuildVersion,
languageVersionString = languageVersionString,
apiVersionString = apiVersionString,
coroutinesEnable = coroutinesEnable,
coroutinesWarn = coroutinesWarn,
coroutinesError = coroutinesError,
multiplatformEnable = multiplatformEnable,
metadataVersionMajor = metadataVersion.major,
metadataVersionMinor = metadataVersion.minor,
@@ -15,9 +15,6 @@ data class JsBuildMetaInfo(
override val compilerBuildVersion: String,
override val languageVersionString: String,
override val apiVersionString: String,
override val coroutinesEnable: Boolean,
override val coroutinesWarn: Boolean,
override val coroutinesError: Boolean,
override val multiplatformEnable: Boolean,
override val metadataVersionMajor: Int,
override val metadataVersionMinor: Int,
@@ -32,9 +29,6 @@ data class JsBuildMetaInfo(
compilerBuildVersion: String,
languageVersionString: String,
apiVersionString: String,
coroutinesEnable: Boolean,
coroutinesWarn: Boolean,
coroutinesError: Boolean,
multiplatformEnable: Boolean,
ownVersion: Int,
coroutinesVersion: Int,
@@ -47,9 +41,6 @@ data class JsBuildMetaInfo(
compilerBuildVersion = compilerBuildVersion,
languageVersionString = languageVersionString,
apiVersionString = apiVersionString,
coroutinesEnable = coroutinesEnable,
coroutinesWarn = coroutinesWarn,
coroutinesError = coroutinesError,
multiplatformEnable = multiplatformEnable,
metadataVersionMajor = metadataVersion.major,
metadataVersionMinor = metadataVersion.minor,
@@ -27,9 +27,6 @@ data class JvmBuildMetaInfo(
override val compilerBuildVersion: String,
override val languageVersionString: String,
override val apiVersionString: String,
override val coroutinesEnable: Boolean,
override val coroutinesWarn: Boolean,
override val coroutinesError: Boolean,
override val multiplatformEnable: Boolean,
override val metadataVersionMajor: Int,
override val metadataVersionMinor: Int,
@@ -47,9 +44,6 @@ data class JvmBuildMetaInfo(
compilerBuildVersion: String,
languageVersionString: String,
apiVersionString: String,
coroutinesEnable: Boolean,
coroutinesWarn: Boolean,
coroutinesError: Boolean,
multiplatformEnable: Boolean,
ownVersion: Int,
coroutinesVersion: Int,
@@ -62,9 +56,6 @@ data class JvmBuildMetaInfo(
compilerBuildVersion = compilerBuildVersion,
languageVersionString = languageVersionString,
apiVersionString = apiVersionString,
coroutinesEnable = coroutinesEnable,
coroutinesWarn = coroutinesWarn,
coroutinesError = coroutinesError,
multiplatformEnable = multiplatformEnable,
metadataVersionMajor = metadataVersion.major,
metadataVersionMinor = metadataVersion.minor,
@@ -121,13 +121,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var intellijPluginRoot: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xcoroutines",
valueDescription = "{enable|warn|error}",
description = "Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier"
)
var coroutinesState: String? by NullableStringFreezableVar(DEFAULT)
@Argument(
value = "-Xnew-inference",
description = "Enable new experimental generic type inference algorithm"
@@ -385,17 +378,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
put(LanguageFeature.MultiPlatformProjects, LanguageFeature.State.ENABLED)
}
when (coroutinesState) {
CommonCompilerArguments.ERROR -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED_WITH_ERROR)
CommonCompilerArguments.ENABLE -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED)
CommonCompilerArguments.WARN, CommonCompilerArguments.DEFAULT -> {
}
else -> {
val message = "Invalid value of -Xcoroutines (should be: enable, warn or error): " + coroutinesState
collector.report(CompilerMessageSeverity.ERROR, message, null)
}
}
if (newInference) {
put(LanguageFeature.NewInference, LanguageFeature.State.ENABLED)
put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED)
@@ -525,7 +507,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
configureLanguageFeatures(collector)
)
checkCoroutines(languageVersionSettings, collector)
checkIrSupport(languageVersionSettings, collector)
return languageVersionSettings
@@ -596,17 +577,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
}
}
private fun checkCoroutines(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)) {
if (coroutinesState != DEFAULT) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"-Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond"
)
}
}
}
protected open fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
// backend-specific
}
-2
View File
@@ -30,8 +30,6 @@ where advanced options include:
Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions
-Xcommon-sources=<path> Sources of the common module that need to be compiled together with this module in the multi-platform mode.
Should be a subset of sources passed as free arguments
-Xcoroutines={enable|warn|error}
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
-Xdisable-default-scripting-plugin
Do not enable scripting plugin by default
-Xdisable-phases Disable backend phases
+1 -1
View File
@@ -1,2 +1,2 @@
warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond
warning: flag is not supported by this version of the compiler: -Xcoroutines=enable
OK
+1 -1
View File
@@ -1,2 +1,2 @@
warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond
warning: flag is not supported by this version of the compiler: -Xcoroutines=error
OK
+2 -2
View File
@@ -1,3 +1,3 @@
warning: argument -Xcoroutines is passed multiple times. Only the last value will be used: enable
warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond
warning: flag is not supported by this version of the compiler: -Xcoroutines=error
warning: flag is not supported by this version of the compiler: -Xcoroutines=enable
OK
+1 -1
View File
@@ -1,2 +1,2 @@
warning: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond
warning: flag is not supported by this version of the compiler: -Xcoroutines=warn
OK
-2
View File
@@ -130,8 +130,6 @@ where advanced options include:
Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions
-Xcommon-sources=<path> Sources of the common module that need to be compiled together with this module in the multi-platform mode.
Should be a subset of sources passed as free arguments
-Xcoroutines={enable|warn|error}
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
-Xdisable-default-scripting-plugin
Do not enable scripting plugin by default
-Xdisable-phases Disable backend phases
@@ -195,19 +195,7 @@ private fun readElementsList(element: Element, rootElementName: String, elementN
}
private fun readV2Config(element: Element): KotlinFacetSettings {
return readV2AndLaterConfig(element).apply {
element.getChild("compilerArguments")?.children?.let { args ->
when {
args.any { arg -> arg.attributes[0].value == "coroutinesEnable" && arg.attributes[1].booleanValue } ->
compilerArguments!!.coroutinesState = CommonCompilerArguments.ENABLE
args.any { arg -> arg.attributes[0].value == "coroutinesWarn" && arg.attributes[1].booleanValue } ->
compilerArguments!!.coroutinesState = CommonCompilerArguments.WARN
args.any { arg -> arg.attributes[0].value == "coroutinesError" && arg.attributes[1].booleanValue } ->
compilerArguments!!.coroutinesState = CommonCompilerArguments.ERROR
else -> compilerArguments!!.coroutinesState = CommonCompilerArguments.DEFAULT
}
}
}
return readV2AndLaterConfig(element)
}
private fun readLatestConfig(element: Element): KotlinFacetSettings {
@@ -408,35 +396,10 @@ fun Element.dropVersionsIfNecessary(settings: CommonCompilerArguments) {
}
}
// Special treatment of v2 may be dropped after transition to IDEA 172
private fun KotlinFacetSettings.writeV2Config(element: Element) {
writeLatestConfig(element)
element.getChild("compilerArguments")?.let {
it.getOption("coroutinesState")?.detach()
val coroutineOption = when (compilerArguments?.coroutinesState) {
CommonCompilerArguments.ENABLE -> "coroutinesEnable"
CommonCompilerArguments.WARN -> "coroutinesWarn"
CommonCompilerArguments.ERROR -> "coroutinesError"
else -> null
}
if (coroutineOption != null) {
Element("option").apply {
setAttribute("name", coroutineOption)
setAttribute("value", "true")
it.addContent(this)
}
}
}
}
fun KotlinFacetSettings.serializeFacetSettings(element: Element) {
val versionToWrite = if (version == 2) version else KotlinFacetSettings.CURRENT_VERSION
element.setAttribute("version", versionToWrite.toString())
if (versionToWrite == 2) {
writeV2Config(element)
} else {
writeLatestConfig(element)
}
writeLatestConfig(element)
}
private fun TargetPlatform.serializeComponentPlatforms(): String {
@@ -190,10 +190,6 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
arguments.multiPlatform = configuration?.getChild("multiPlatform")?.text?.trim()?.toBoolean() ?: false
arguments.suppressWarnings = configuration?.getChild("nowarn")?.text?.trim()?.toBoolean() ?: false
configuration?.getChild("experimentalCoroutines")?.text?.trim()?.let {
arguments.coroutinesState = it
}
when (arguments) {
is K2JVMCompilerArguments -> {
arguments.classpath = configuration?.getChild("classpath")?.text
@@ -256,7 +252,6 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
kotlinFacet.configureFacet(
compilerVersion,
LanguageFeature.Coroutines.defaultState,
platform,
modifiableModelsProvider
)
@@ -425,4 +420,4 @@ class KotlinImporterComponent : PersistentStateComponent<KotlinImporterComponent
}
internal val Module.kotlinImporterComponent: KotlinImporterComponent
get() = this.getServiceSafe()
get() = this.getServiceSafe()
@@ -409,7 +409,7 @@ private fun configureLanguageAndApiVersion(
compilerArguments.apiVersion = null
}
facet.configureFacet(languageVersion, LanguageFeature.State.DISABLED, null, modelsProvider)
facet.configureFacet(languageVersion, null, modelsProvider)
if (apiVersion != null) {
facet.configuration.settings.apiLevel = LanguageVersion.fromVersionString(apiVersion)
}
@@ -199,21 +199,6 @@ private fun Module.externalSystemRunTasks(): List<ExternalSystemRunTask> {
fun Module.externalSystemTestRunTasks() = externalSystemRunTasks().filterIsInstance<ExternalSystemTestRunTask>()
fun Module.externalSystemNativeMainRunTasks() = externalSystemRunTasks().filterIsInstance<ExternalSystemNativeMainRunTask>()
@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
)
fun KotlinFacet.configureFacet(
compilerVersion: String?,
coroutineSupport: LanguageFeature.State,
platform: IdePlatform<*, *>,
modelsProvider: IdeModifiableModelsProvider
) {
configureFacet(compilerVersion, coroutineSupport, platform.toNewPlatform(), modelsProvider)
}
fun KotlinFacet.noVersionAutoAdvance() {
configuration.settings.compilerArguments?.let {
it.autoAdvanceLanguageVersion = false
@@ -226,8 +211,7 @@ fun KotlinFacet.noVersionAutoAdvance() {
val commonUIExposedFields = listOf(
CommonCompilerArguments::languageVersion.name,
CommonCompilerArguments::apiVersion.name,
CommonCompilerArguments::suppressWarnings.name,
CommonCompilerArguments::coroutinesState.name
CommonCompilerArguments::suppressWarnings.name
)
private val commonUIHiddenFields = listOf(
CommonCompilerArguments::pluginClasspaths.name,
@@ -18,7 +18,6 @@ import junit.framework.TestCase
import org.jetbrains.kotlin.asJava.elements.KtLightAnnotationForSourceEntry
import org.jetbrains.kotlin.asJava.elements.KtLightPsiArrayInitializerMemberValue
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.idea.completion.test.assertInstanceOf
import org.jetbrains.kotlin.idea.facet.configureFacet
import org.jetbrains.kotlin.idea.facet.getOrCreateFacet
@@ -926,9 +925,9 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
WriteAction.run<Throwable> {
val modelsProvider = IdeModifiableModelsProviderImpl(project)
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider)
facet.configureFacet(version, null, modelsProvider)
modelsProvider.commit()
}
}
}
}
@@ -346,7 +346,6 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
FacetUtilsKt.configureFacet(
facet,
"1.1",
LanguageFeature.State.ENABLED,
platform,
modelsProvider
);
@@ -7,15 +7,12 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.facet.FacetManager
import com.intellij.facet.impl.FacetUtil
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ModuleRootModificationUtil.updateModel
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.JarFileSystem
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments.Companion.DEFAULT
import org.jetbrains.kotlin.config.CompilerSettings.Companion.DEFAULT_ADDITIONAL_ARGUMENTS
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersion
@@ -57,28 +54,6 @@ class UpdateConfigurationQuickFixTest : KotlinLightPlatformCodeInsightFixtureTes
assertEquals(LanguageFeature.State.ENABLED, inlineClassesSupport)
}
fun testEnableCoroutines() {
configureRuntime("mockRuntime11")
resetProjectSettings(LanguageVersion.KOTLIN_1_1)
myFixture.configureByText("foo.kt", "suspend fun foo()")
assertEquals(DEFAULT, KotlinCommonCompilerArgumentsHolder.getInstance(project).settings.coroutinesState)
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, coroutineSupport)
myFixture.launchAction(myFixture.findSingleIntention("Enable coroutine support in the project"))
assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
}
fun testDisableCoroutines() {
configureRuntime("mockRuntime11")
resetProjectSettings(LanguageVersion.KOTLIN_1_1)
myFixture.configureByText("foo.kt", "suspend fun foo()")
assertEquals(DEFAULT, KotlinCommonCompilerArgumentsHolder.getInstance(project).settings.coroutinesState)
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, coroutineSupport)
myFixture.launchAction(myFixture.findSingleIntention("Disable coroutine support in the project"))
assertEquals(LanguageFeature.State.ENABLED_WITH_ERROR, coroutineSupport)
}
fun testIncreaseLangLevel() {
configureRuntime("mockRuntime11")
resetProjectSettings(LanguageVersion.KOTLIN_1_0)
@@ -189,13 +164,9 @@ class UpdateConfigurationQuickFixTest : KotlinLightPlatformCodeInsightFixtureTes
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
languageVersion = version.versionString
apiVersion = version.versionString
coroutinesState = DEFAULT
}
}
private val coroutineSupport: LanguageFeature.State
get() = project.getLanguageVersionSettings().getFeatureSupport(LanguageFeature.Coroutines)
private val inlineClassesSupport: LanguageFeature.State
get() = project.getLanguageVersionSettings().getFeatureSupport(LanguageFeature.InlineClasses)
@@ -53,15 +53,6 @@ internal open class AbstractKotlinCompileArgumentsContributor<T : CommonCompiler
args: T,
flags: Collection<CompilerArgumentsConfigurationFlag>
) {
args.coroutinesState = when (coroutines.get()) {
Coroutines.ENABLE -> CommonCompilerArguments.ENABLE
Coroutines.WARN -> CommonCompilerArguments.WARN
Coroutines.ERROR -> CommonCompilerArguments.ERROR
Coroutines.DEFAULT -> CommonCompilerArguments.DEFAULT
}
logger.kotlinDebug { "args.coroutinesState=${args.coroutinesState}" }
if (logger.isDebugEnabled) {
args.verbose = true
}
@@ -114,4 +105,4 @@ internal open class KotlinJvmCompilerArgumentsContributor(
kotlinOptions.forEach { it?.updateArguments(args) }
}
}
}