Use LanguageFeature.State enum instead of CoroutineSupport
This commit is contained in:
@@ -63,11 +63,11 @@ enum class LanguageFeature(
|
||||
|
||||
val presentableText get() = if (hintUrl == null) presentableName else "$presentableName (See: $hintUrl)"
|
||||
|
||||
enum class State {
|
||||
ENABLED,
|
||||
ENABLED_WITH_WARNING,
|
||||
ENABLED_WITH_ERROR,
|
||||
DISABLED;
|
||||
enum class State(override val description: String) : DescriptionAware {
|
||||
ENABLED("Enabled"),
|
||||
ENABLED_WITH_WARNING("Enabled with warning"),
|
||||
ENABLED_WITH_ERROR("Disabled"), // TODO: consider dropping this and using DISABLED instead
|
||||
DISABLED("Disabled");
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -129,16 +129,12 @@ private val Module.implementsCommonModule: Boolean
|
||||
|
||||
private fun getExtraLanguageFeatures(
|
||||
targetPlatformKind: TargetPlatformKind<*>,
|
||||
coroutineSupport: CoroutineSupport,
|
||||
coroutineSupport: LanguageFeature.State,
|
||||
compilerSettings: CompilerSettings?,
|
||||
module: Module?
|
||||
): Map<LanguageFeature, LanguageFeature.State> {
|
||||
return mutableMapOf<LanguageFeature, LanguageFeature.State>().apply {
|
||||
when (coroutineSupport) {
|
||||
CoroutineSupport.ENABLED -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED)
|
||||
CoroutineSupport.ENABLED_WITH_WARNING -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED_WITH_WARNING)
|
||||
CoroutineSupport.DISABLED -> put(LanguageFeature.Coroutines, LanguageFeature.State.ENABLED_WITH_ERROR)
|
||||
}
|
||||
put(LanguageFeature.Coroutines, coroutineSupport)
|
||||
if (targetPlatformKind == TargetPlatformKind.Common ||
|
||||
// TODO: this is a dirty hack, parse arguments correctly here
|
||||
compilerSettings?.additionalArguments?.contains(multiPlatformProjectsArg) == true ||
|
||||
|
||||
@@ -50,31 +50,27 @@ sealed class TargetPlatformKind<out Version : TargetPlatformVersion>(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: merge with LanguageFeature.State
|
||||
enum class CoroutineSupport(
|
||||
override val description: String,
|
||||
val compilerArgument: String
|
||||
) : DescriptionAware {
|
||||
ENABLED("Enabled", "enable"),
|
||||
ENABLED_WITH_WARNING("Enabled with warning", "warn"),
|
||||
DISABLED("Disabled", "error");
|
||||
object CoroutineSupport {
|
||||
@JvmStatic
|
||||
fun byCompilerArguments(arguments: CommonCompilerArguments?): LanguageFeature.State =
|
||||
byCompilerArgumentsOrNull(arguments) ?: LanguageFeature.Coroutines.defaultState
|
||||
|
||||
companion object {
|
||||
val DEFAULT = ENABLED_WITH_WARNING
|
||||
fun byCompilerArgumentsOrNull(arguments: CommonCompilerArguments?): LanguageFeature.State? = when {
|
||||
arguments == null -> null
|
||||
arguments.coroutinesEnable -> LanguageFeature.State.ENABLED
|
||||
arguments.coroutinesWarn -> LanguageFeature.State.ENABLED_WITH_WARNING
|
||||
arguments.coroutinesError -> LanguageFeature.State.ENABLED_WITH_ERROR
|
||||
else -> null
|
||||
}
|
||||
|
||||
@JvmStatic fun byCompilerArguments(arguments: CommonCompilerArguments?) = byCompilerArgumentsOrNull(arguments) ?: DEFAULT
|
||||
fun byCompilerArgument(argument: String): LanguageFeature.State =
|
||||
LanguageFeature.State.values().find { getCompilerArgument(it).equals(argument, ignoreCase = true) }
|
||||
?: LanguageFeature.Coroutines.defaultState
|
||||
|
||||
fun byCompilerArgumentsOrNull(arguments: CommonCompilerArguments?) = when {
|
||||
arguments == null -> null
|
||||
arguments.coroutinesEnable -> ENABLED
|
||||
arguments.coroutinesWarn -> ENABLED_WITH_WARNING
|
||||
arguments.coroutinesError -> DISABLED
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun byCompilerArgument(argument: String): CoroutineSupport {
|
||||
return CoroutineSupport.values().find { it.compilerArgument.equals(argument, ignoreCase = true) } ?: DEFAULT
|
||||
}
|
||||
fun getCompilerArgument(state: LanguageFeature.State): String = when (state) {
|
||||
LanguageFeature.State.ENABLED -> "enable"
|
||||
LanguageFeature.State.ENABLED_WITH_WARNING -> "warn"
|
||||
LanguageFeature.State.ENABLED_WITH_ERROR, LanguageFeature.State.DISABLED -> "error"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,13 +111,17 @@ class KotlinFacetSettings {
|
||||
}
|
||||
}
|
||||
|
||||
var coroutineSupport: CoroutineSupport
|
||||
get() = CoroutineSupport.byCompilerArguments(compilerArguments)
|
||||
var coroutineSupport: LanguageFeature.State
|
||||
get() {
|
||||
val languageVersion = languageLevel ?: return LanguageFeature.Coroutines.defaultState
|
||||
if (languageVersion < LanguageFeature.Coroutines.sinceVersion!!) return LanguageFeature.State.DISABLED
|
||||
return CoroutineSupport.byCompilerArguments(compilerArguments)
|
||||
}
|
||||
set(value) {
|
||||
with(compilerArguments!!) {
|
||||
coroutinesEnable = value == CoroutineSupport.ENABLED
|
||||
coroutinesWarn = value == CoroutineSupport.ENABLED_WITH_WARNING
|
||||
coroutinesError = value == CoroutineSupport.DISABLED
|
||||
coroutinesEnable = value == LanguageFeature.State.ENABLED
|
||||
coroutinesWarn = value == LanguageFeature.State.ENABLED_WITH_WARNING
|
||||
coroutinesError = value == LanguageFeature.State.ENABLED_WITH_ERROR || value == LanguageFeature.State.DISABLED
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
@@ -150,7 +150,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
||||
val kotlinFacet = module.getOrCreateFacet(modifiableModelsProvider, false)
|
||||
val platform = detectPlatformByExecutions(mavenProject) ?: detectPlatformByLibraries(mavenProject)
|
||||
|
||||
kotlinFacet.configureFacet(compilerVersion, CoroutineSupport.DEFAULT, platform, modifiableModelsProvider)
|
||||
kotlinFacet.configureFacet(compilerVersion, LanguageFeature.Coroutines.defaultState, platform, modifiableModelsProvider)
|
||||
val configuredPlatform = kotlinFacet.configuration.settings.targetPlatformKind!!
|
||||
val configuration = mavenPlugin.configurationElement
|
||||
val sharedArguments = configuration?.let { getCompilerArgumentsByConfigurationElement(it, configuredPlatform) } ?: emptyList()
|
||||
|
||||
@@ -18,10 +18,7 @@ package org.jetbrains.kotlin.idea.maven
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.config.additionalArgumentsAsList
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
@@ -451,7 +448,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", compilerArguments!!.apiVersion)
|
||||
Assert.assertEquals(true, compilerArguments!!.suppressWarnings)
|
||||
Assert.assertEquals("enable", coroutineSupport.compilerArgument)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals("JVM 1.8", targetPlatformKind!!.description)
|
||||
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals("-cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform",
|
||||
@@ -519,7 +516,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", compilerArguments!!.apiVersion)
|
||||
Assert.assertEquals(true, compilerArguments!!.suppressWarnings)
|
||||
Assert.assertEquals("enable", coroutineSupport.compilerArgument)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
Assert.assertTrue(targetPlatformKind is TargetPlatformKind.JavaScript)
|
||||
with(compilerArguments as K2JSCompilerArguments) {
|
||||
Assert.assertEquals(true, sourceMap)
|
||||
@@ -591,7 +588,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", compilerArguments!!.apiVersion)
|
||||
Assert.assertEquals(true, compilerArguments!!.suppressWarnings)
|
||||
Assert.assertEquals("enable", coroutineSupport.compilerArgument)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals("JVM 1.8", targetPlatformKind!!.description)
|
||||
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals("-cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform",
|
||||
@@ -652,7 +649,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
||||
with (facetSettings) {
|
||||
Assert.assertEquals("JVM 1.8", targetPlatformKind!!.description)
|
||||
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals("enable", coroutineSupport.compilerArgument)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals(
|
||||
listOf("-jdk-home", "c:\\program files\\jdk1.8"),
|
||||
compilerSettings!!.additionalArgumentsAsList
|
||||
|
||||
+10
-5
@@ -55,12 +55,16 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Configurable.NoScroll{
|
||||
private static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<String, String>();
|
||||
private static final List<LanguageFeature.State> languageFeatureStates = Arrays.asList(
|
||||
LanguageFeature.State.ENABLED, LanguageFeature.State.ENABLED_WITH_WARNING, LanguageFeature.State.ENABLED_WITH_ERROR
|
||||
);
|
||||
|
||||
static {
|
||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, "Plain (put to global scope)");
|
||||
@@ -261,7 +265,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fillCoroutineSupportList() {
|
||||
for (CoroutineSupport coroutineSupport : CoroutineSupport.values()) {
|
||||
for (LanguageFeature.State coroutineSupport : languageFeatureStates) {
|
||||
coroutineSupportComboBox.addItem(coroutineSupport);
|
||||
}
|
||||
coroutineSupportComboBox.setRenderer(new DescriptionListCellRenderer());
|
||||
@@ -370,10 +374,11 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
|
||||
commonCompilerArguments.languageVersion = getSelectedLanguageVersion();
|
||||
commonCompilerArguments.apiVersion = getSelectedAPIVersion();
|
||||
CoroutineSupport coroutineSupport = (CoroutineSupport) coroutineSupportComboBox.getSelectedItem();
|
||||
commonCompilerArguments.coroutinesEnable = coroutineSupport == CoroutineSupport.ENABLED;
|
||||
commonCompilerArguments.coroutinesWarn = coroutineSupport == CoroutineSupport.ENABLED_WITH_WARNING;
|
||||
commonCompilerArguments.coroutinesError = coroutineSupport == CoroutineSupport.DISABLED;
|
||||
LanguageFeature.State coroutineSupport = (LanguageFeature.State) coroutineSupportComboBox.getSelectedItem();
|
||||
commonCompilerArguments.coroutinesEnable = coroutineSupport == LanguageFeature.State.ENABLED;
|
||||
commonCompilerArguments.coroutinesWarn = coroutineSupport == LanguageFeature.State.ENABLED_WITH_WARNING;
|
||||
commonCompilerArguments.coroutinesError = coroutineSupport == LanguageFeature.State.ENABLED_WITH_ERROR ||
|
||||
coroutineSupport == LanguageFeature.State.DISABLED;
|
||||
compilerSettings.additionalArguments = additionalArgsOptionsField.getText();
|
||||
compilerSettings.scriptTemplates = scriptTemplatesField.getText();
|
||||
compilerSettings.scriptTemplatesClasspath = scriptTemplatesClasspathField.getText();
|
||||
|
||||
+3
-2
@@ -27,6 +27,7 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.idea.facet.*
|
||||
@@ -138,5 +139,5 @@ private fun findKotlinCoroutinesProperty(project: Project): String {
|
||||
properties.getProperty("kotlin.coroutines")?.let { return it }
|
||||
}
|
||||
|
||||
return CoroutineSupport.DEFAULT.compilerArgument
|
||||
}
|
||||
return CoroutineSupport.getCompilerArgument(LanguageFeature.Coroutines.defaultState)
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class KotlinFacetEditorGeneralTab(
|
||||
|
||||
inner class CoroutineContradictionValidator : FacetEditorValidator() {
|
||||
override fun check(): ValidationResult {
|
||||
val selectedOption = editor.compilerConfigurable.coroutineSupportComboBox.selectedItem as? CoroutineSupport
|
||||
val selectedOption = editor.compilerConfigurable.coroutineSupportComboBox.selectedItem as? LanguageFeature.State
|
||||
?: return ValidationResult.OK
|
||||
val parsedArguments = configuration.settings.compilerArguments?.javaClass?.newInstance()
|
||||
?: return ValidationResult.OK
|
||||
|
||||
@@ -113,7 +113,7 @@ fun Module.getOrCreateFacet(modelsProvider: IdeModifiableModelsProvider, useProj
|
||||
|
||||
fun KotlinFacet.configureFacet(
|
||||
compilerVersion: String,
|
||||
coroutineSupport: CoroutineSupport,
|
||||
coroutineSupport: LanguageFeature.State,
|
||||
platformKind: TargetPlatformKind<*>?, // if null, detect by module dependencies
|
||||
modelsProvider: IdeModifiableModelsProvider
|
||||
) {
|
||||
|
||||
@@ -40,15 +40,18 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
sealed class ChangeCoroutineSupportFix(
|
||||
element: PsiElement,
|
||||
protected val coroutineSupport: CoroutineSupport
|
||||
protected val coroutineSupport: LanguageFeature.State
|
||||
) : KotlinQuickFixAction<PsiElement>(element) {
|
||||
class InModule(element: PsiElement, coroutineSupport: CoroutineSupport) : ChangeCoroutineSupportFix(element, coroutineSupport) {
|
||||
protected val coroutineSupportEnabled: Boolean
|
||||
get() = coroutineSupport == LanguageFeature.State.ENABLED || coroutineSupport == LanguageFeature.State.ENABLED_WITH_WARNING
|
||||
|
||||
class InModule(element: PsiElement, coroutineSupport: LanguageFeature.State) : ChangeCoroutineSupportFix(element, coroutineSupport) {
|
||||
override fun getText() = "${super.getText()} in the current module"
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val module = ModuleUtilCore.findModuleForPsiElement(file) ?: return
|
||||
|
||||
val runtimeUpdateRequired = coroutineSupport != CoroutineSupport.DISABLED &&
|
||||
val runtimeUpdateRequired = coroutineSupportEnabled &&
|
||||
(getRuntimeLibraryVersion(module)?.startsWith("1.0") ?: false)
|
||||
|
||||
if (KotlinPluginUtil.isGradleModule(module)) {
|
||||
@@ -60,9 +63,11 @@ sealed class ChangeCoroutineSupportFix(
|
||||
return
|
||||
}
|
||||
|
||||
val element = KotlinWithGradleConfigurator.changeCoroutineConfiguration(module, coroutineSupport.compilerArgument)
|
||||
element?.let {
|
||||
OpenFileDescriptor(project, it.containingFile.virtualFile, it.textRange.startOffset).navigate(true)
|
||||
val element = KotlinWithGradleConfigurator.changeCoroutineConfiguration(
|
||||
module, CoroutineSupport.getCompilerArgument(coroutineSupport)
|
||||
)
|
||||
if (element != null) {
|
||||
OpenFileDescriptor(project, element.containingFile.virtualFile, element.textRange.startOffset).navigate(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -81,18 +86,19 @@ sealed class ChangeCoroutineSupportFix(
|
||||
|
||||
}
|
||||
|
||||
class InProject(element: PsiElement, coroutineSupport: CoroutineSupport) : ChangeCoroutineSupportFix(element, coroutineSupport) {
|
||||
class InProject(element: PsiElement, coroutineSupport: LanguageFeature.State) : ChangeCoroutineSupportFix(element, coroutineSupport) {
|
||||
override fun getText() = "${super.getText()} in the project"
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
if (coroutineSupport != CoroutineSupport.DISABLED) {
|
||||
if (coroutineSupportEnabled) {
|
||||
if (!checkUpdateRuntime(project, LanguageFeature.Coroutines.sinceApiVersion)) return
|
||||
}
|
||||
|
||||
with (KotlinCommonCompilerArgumentsHolder.getInstance(project).settings) {
|
||||
coroutinesEnable = coroutineSupport == CoroutineSupport.ENABLED
|
||||
coroutinesWarn = coroutineSupport == CoroutineSupport.ENABLED_WITH_WARNING
|
||||
coroutinesError = coroutineSupport == CoroutineSupport.DISABLED
|
||||
with(KotlinCommonCompilerArgumentsHolder.getInstance(project).settings) {
|
||||
coroutinesEnable = coroutineSupport == LanguageFeature.State.ENABLED
|
||||
coroutinesWarn = coroutineSupport == LanguageFeature.State.ENABLED_WITH_WARNING
|
||||
coroutinesError = coroutineSupport == LanguageFeature.State.ENABLED_WITH_ERROR ||
|
||||
coroutineSupport == LanguageFeature.State.DISABLED
|
||||
}
|
||||
ProjectRootManagerEx.getInstanceEx(project).makeRootsChange({}, false, true)
|
||||
}
|
||||
@@ -103,9 +109,9 @@ sealed class ChangeCoroutineSupportFix(
|
||||
|
||||
override fun getText(): String {
|
||||
return when (coroutineSupport) {
|
||||
CoroutineSupport.DISABLED -> "Disable coroutine support"
|
||||
CoroutineSupport.ENABLED_WITH_WARNING -> "Enable coroutine support (with warning)"
|
||||
CoroutineSupport.ENABLED -> "Enable coroutine support"
|
||||
LanguageFeature.State.ENABLED -> "Enable coroutine support"
|
||||
LanguageFeature.State.ENABLED_WITH_WARNING -> "Enable coroutine support (with warning)"
|
||||
LanguageFeature.State.ENABLED_WITH_ERROR, LanguageFeature.State.DISABLED -> "Disable coroutine support"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,11 +120,11 @@ sealed class ChangeCoroutineSupportFix(
|
||||
val newCoroutineSupports = when (diagnostic.factory) {
|
||||
Errors.EXPERIMENTAL_FEATURE_ERROR -> {
|
||||
if (Errors.EXPERIMENTAL_FEATURE_ERROR.cast(diagnostic).a.first != LanguageFeature.Coroutines) return emptyList()
|
||||
listOf(CoroutineSupport.ENABLED_WITH_WARNING, CoroutineSupport.ENABLED)
|
||||
listOf(LanguageFeature.State.ENABLED_WITH_WARNING, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
Errors.EXPERIMENTAL_FEATURE_WARNING -> {
|
||||
if (Errors.EXPERIMENTAL_FEATURE_WARNING.cast(diagnostic).a.first != LanguageFeature.Coroutines) return emptyList()
|
||||
listOf(CoroutineSupport.ENABLED, CoroutineSupport.DISABLED)
|
||||
listOf(LanguageFeature.State.ENABLED, LanguageFeature.State.ENABLED_WITH_ERROR)
|
||||
}
|
||||
else -> return emptyList()
|
||||
}
|
||||
@@ -128,7 +134,7 @@ sealed class ChangeCoroutineSupportFix(
|
||||
|
||||
val configureInProject = (facetSettings == null || facetSettings.useProjectSettings) &&
|
||||
!KotlinPluginUtil.isGradleModule(module)
|
||||
val quickFixConstructor: (PsiElement, CoroutineSupport) -> ChangeCoroutineSupportFix =
|
||||
val quickFixConstructor: (PsiElement, LanguageFeature.State) -> ChangeCoroutineSupportFix =
|
||||
if (configureInProject) ::InProject else ::InModule
|
||||
return newCoroutineSupports.map { quickFixConstructor(diagnostic.psiElement, it) }
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
||||
importProject()
|
||||
|
||||
with (facetSettings) {
|
||||
Assert.assertEquals(CoroutineSupport.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
||||
|
||||
importProject()
|
||||
|
||||
Assert.assertEquals(CoroutineSupport.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals(true, compilerArguments!!.coroutinesEnable)
|
||||
Assert.assertEquals(false, compilerArguments!!.coroutinesWarn)
|
||||
Assert.assertEquals(false, compilerArguments!!.coroutinesError)
|
||||
@@ -272,7 +272,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
||||
importProject()
|
||||
|
||||
with (facetSettings) {
|
||||
Assert.assertEquals(CoroutineSupport.ENABLED, coroutineSupport)
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
assertEquals(TargetPlatformKind.Jvm.Companion.get(JvmTarget.JVM_1_8), settings.getTargetPlatformKind());
|
||||
assertEquals("1.1", arguments.languageVersion);
|
||||
assertEquals("1.0", arguments.apiVersion);
|
||||
assertEquals("warn", CoroutineSupport.byCompilerArguments(arguments).getCompilerArgument());
|
||||
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, CoroutineSupport.byCompilerArguments(arguments));
|
||||
assertEquals("1.7", arguments.jvmTarget);
|
||||
assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().additionalArguments);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
assertEquals(TargetPlatformKind.JavaScript.INSTANCE, settings.getTargetPlatformKind());
|
||||
assertEquals("1.1", arguments.languageVersion);
|
||||
assertEquals("1.0", arguments.apiVersion);
|
||||
assertEquals("warn", CoroutineSupport.byCompilerArguments(arguments).getCompilerArgument());
|
||||
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, CoroutineSupport.byCompilerArguments(arguments));
|
||||
assertEquals("amd", arguments.moduleKind);
|
||||
assertEquals("-version -meta-info", settings.getCompilerSettings().additionalArguments);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
assertEquals(TargetPlatformKind.Jvm.Companion.get(JvmTarget.JVM_1_8), settings.getTargetPlatformKind());
|
||||
assertEquals("1.1", arguments.languageVersion);
|
||||
assertEquals("1.0", arguments.apiVersion);
|
||||
assertEquals("warn", CoroutineSupport.byCompilerArguments(arguments).getCompilerArgument());
|
||||
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, CoroutineSupport.byCompilerArguments(arguments));
|
||||
assertEquals("1.7", arguments.jvmTarget);
|
||||
assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().additionalArguments);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
assertEquals(TargetPlatformKind.JavaScript.INSTANCE, settings.getTargetPlatformKind());
|
||||
assertEquals("1.1", arguments.languageVersion);
|
||||
assertEquals("1.0", arguments.apiVersion);
|
||||
assertEquals("warn", CoroutineSupport.byCompilerArguments(arguments).getCompilerArgument());
|
||||
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, CoroutineSupport.byCompilerArguments(arguments));
|
||||
assertEquals("amd", arguments.moduleKind);
|
||||
assertEquals("-version -meta-info", settings.getCompilerSettings().additionalArguments);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.vfs.JarFileSystem
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||
@@ -68,9 +67,9 @@ class LanguageFeatureQuickFixTest : LightPlatformCodeInsightFixtureTestCase() {
|
||||
resetProjectSettings(LanguageVersion.KOTLIN_1_1)
|
||||
myFixture.configureByText("foo.kt", "suspend fun foo()")
|
||||
|
||||
assertEquals(CoroutineSupport.ENABLED_WITH_WARNING, facet.configuration.settings.coroutineSupport)
|
||||
assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, facet.configuration.settings.coroutineSupport)
|
||||
myFixture.launchAction(myFixture.findSingleIntention("Enable coroutine support in the current module"))
|
||||
assertEquals(CoroutineSupport.ENABLED, facet.configuration.settings.coroutineSupport)
|
||||
assertEquals(LanguageFeature.State.ENABLED, facet.configuration.settings.coroutineSupport)
|
||||
}
|
||||
|
||||
fun testEnableCoroutines_UpdateRuntime() {
|
||||
|
||||
Reference in New Issue
Block a user