diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java index f315bb44dcb..532af04576d 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java @@ -79,10 +79,6 @@ public abstract class CommonCompilerArguments { @Argument(value = "Xcoroutines=enable") public boolean coroutinesEnable; - @Argument(value = "Xcoroutine-support", description = "Coroutines: produce error/warning/compile silently") - // Possible values: "enabled", "warning", "disabled" - public String coroutineSupport; - @Argument(value = "P", description = "Pass an option to a plugin") @ValueDescription(PLUGIN_OPTION_FORMAT) public String[] pluginOptions; diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt index ad01bd8bec3..df88aaef1f6 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -72,8 +72,13 @@ enum class CoroutineSupport( companion object { val DEFAULT = ENABLED_WITH_WARNING - @JvmStatic fun byCompilerArgument(value: String?) = CoroutineSupport.values().firstOrNull { it.compilerArgument == value } - ?: CoroutineSupport.DEFAULT + @JvmStatic fun byCompilerArguments(arguments: CommonCompilerArguments?) = when { + arguments == null -> DEFAULT + arguments.coroutinesEnable -> ENABLED + arguments.coroutinesWarn -> ENABLED_WITH_WARNING + arguments.coroutinesError -> DISABLED + else -> DEFAULT + } } } @@ -89,9 +94,11 @@ class KotlinCompilerInfo { var compilerSettings: CompilerSettings? = null @get:Transient var coroutineSupport: CoroutineSupport - get() = CoroutineSupport.byCompilerArgument(commonCompilerArguments?.coroutineSupport) + get() = CoroutineSupport.byCompilerArguments(commonCompilerArguments) set(value) { - commonCompilerArguments?.coroutineSupport = value.compilerArgument + commonCompilerArguments?.coroutinesEnable = value == CoroutineSupport.ENABLED + commonCompilerArguments?.coroutinesWarn = value == CoroutineSupport.ENABLED_WITH_WARNING + commonCompilerArguments?.coroutinesError = value == CoroutineSupport.DISABLED } } diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java index 5a3a941cfdd..2a5f3e5361e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java +++ b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * 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. @@ -248,7 +248,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co public boolean isModified() { return ComparingUtils.isModified(generateNoWarningsCheckBox, commonCompilerArguments.suppressWarnings) || (showLanguageVersion && !getSelectedLanguageVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion))) || - !coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArgument(k2jsCompilerArguments.moduleKind)) || + !coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments)) || ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) || ComparingUtils.isModified(scriptTemplatesField, compilerSettings.getScriptTemplates()) || ComparingUtils.isModified(scriptTemplatesClasspathField, compilerSettings.getScriptTemplatesClasspath()) || @@ -287,7 +287,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co if (showLanguageVersion) { commonCompilerArguments.languageVersion = getSelectedLanguageVersion(); } - commonCompilerArguments.coroutineSupport = ((CoroutineSupport) coroutineSupportComboBox.getSelectedItem()).getCompilerArgument(); + CoroutineSupport coroutineSupport = (CoroutineSupport) coroutineSupportComboBox.getSelectedItem(); + commonCompilerArguments.coroutinesEnable = coroutineSupport == CoroutineSupport.ENABLED; + commonCompilerArguments.coroutinesWarn = coroutineSupport == CoroutineSupport.ENABLED_WITH_WARNING; + commonCompilerArguments.coroutinesError = coroutineSupport == CoroutineSupport.DISABLED; compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText()); compilerSettings.setScriptTemplates(scriptTemplatesField.getText()); compilerSettings.setScriptTemplatesClasspath(scriptTemplatesClasspathField.getText()); @@ -322,7 +325,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co if (showLanguageVersion) { languageVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion)); } - coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArgument(commonCompilerArguments.coroutineSupport)); + coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArguments(commonCompilerArguments)); additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments()); scriptTemplatesField.setText(compilerSettings.getScriptTemplates()); scriptTemplatesClasspathField.setText(compilerSettings.getScriptTemplatesClasspath());