Get rid of coroutinesWarn/coroutinesEnable/coroutinesError
Use a single coroutinesState instead. Change the coroutines state in
some tests from "warn" to "enable"/"error" to test that deserialization
of older config files works ("warn" is the default value, so it wasn't
testing anything here)
Original commit: be54e4b93b
This commit is contained in:
@@ -55,11 +55,10 @@ object CoroutineSupport {
|
|||||||
fun byCompilerArguments(arguments: CommonCompilerArguments?): LanguageFeature.State =
|
fun byCompilerArguments(arguments: CommonCompilerArguments?): LanguageFeature.State =
|
||||||
byCompilerArgumentsOrNull(arguments) ?: LanguageFeature.Coroutines.defaultState
|
byCompilerArgumentsOrNull(arguments) ?: LanguageFeature.Coroutines.defaultState
|
||||||
|
|
||||||
fun byCompilerArgumentsOrNull(arguments: CommonCompilerArguments?): LanguageFeature.State? = when {
|
fun byCompilerArgumentsOrNull(arguments: CommonCompilerArguments?): LanguageFeature.State? = when (arguments?.coroutinesState) {
|
||||||
arguments == null -> null
|
CommonCompilerArguments.ENABLE -> LanguageFeature.State.ENABLED
|
||||||
arguments.coroutinesEnable -> LanguageFeature.State.ENABLED
|
CommonCompilerArguments.WARN -> LanguageFeature.State.ENABLED_WITH_WARNING
|
||||||
arguments.coroutinesWarn -> LanguageFeature.State.ENABLED_WITH_WARNING
|
CommonCompilerArguments.ERROR -> LanguageFeature.State.ENABLED_WITH_ERROR
|
||||||
arguments.coroutinesError -> LanguageFeature.State.ENABLED_WITH_ERROR
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ object CoroutineSupport {
|
|||||||
class KotlinFacetSettings {
|
class KotlinFacetSettings {
|
||||||
companion object {
|
companion object {
|
||||||
// Increment this when making serialization-incompatible changes to configuration data
|
// Increment this when making serialization-incompatible changes to configuration data
|
||||||
val CURRENT_VERSION = 2
|
val CURRENT_VERSION = 3
|
||||||
val DEFAULT_VERSION = 0
|
val DEFAULT_VERSION = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +117,10 @@ class KotlinFacetSettings {
|
|||||||
return CoroutineSupport.byCompilerArguments(compilerArguments)
|
return CoroutineSupport.byCompilerArguments(compilerArguments)
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
with(compilerArguments!!) {
|
compilerArguments!!.coroutinesState = when (value) {
|
||||||
coroutinesEnable = value == LanguageFeature.State.ENABLED
|
LanguageFeature.State.ENABLED -> CommonCompilerArguments.ENABLE
|
||||||
coroutinesWarn = value == LanguageFeature.State.ENABLED_WITH_WARNING
|
LanguageFeature.State.ENABLED_WITH_WARNING -> CommonCompilerArguments.WARN
|
||||||
coroutinesError = value == LanguageFeature.State.ENABLED_WITH_ERROR || value == LanguageFeature.State.DISABLED
|
LanguageFeature.State.ENABLED_WITH_ERROR, LanguageFeature.State.DISABLED -> CommonCompilerArguments.ERROR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ private fun readV1Config(element: Element): KotlinFacetSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun readV2Config(element: Element): KotlinFacetSettings {
|
private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings {
|
||||||
return KotlinFacetSettings().apply {
|
return KotlinFacetSettings().apply {
|
||||||
element.getAttributeValue("useProjectSettings")?.let { useProjectSettings = it.toBoolean() }
|
element.getAttributeValue("useProjectSettings")?.let { useProjectSettings = it.toBoolean() }
|
||||||
val platformName = element.getAttributeValue("platform")
|
val platformName = element.getAttributeValue("platform")
|
||||||
@@ -101,6 +101,25 @@ private fun readV2Config(element: Element): KotlinFacetSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun readLatestConfig(element: Element): KotlinFacetSettings {
|
||||||
|
return readV2AndLaterConfig(element)
|
||||||
|
}
|
||||||
|
|
||||||
fun deserializeFacetSettings(element: Element): KotlinFacetSettings {
|
fun deserializeFacetSettings(element: Element): KotlinFacetSettings {
|
||||||
val version =
|
val version =
|
||||||
try {
|
try {
|
||||||
@@ -112,6 +131,7 @@ fun deserializeFacetSettings(element: Element): KotlinFacetSettings {
|
|||||||
return when (version) {
|
return when (version) {
|
||||||
1 -> readV1Config(element)
|
1 -> readV1Config(element)
|
||||||
2 -> readV2Config(element)
|
2 -> readV2Config(element)
|
||||||
|
KotlinFacetSettings.CURRENT_VERSION -> readLatestConfig(element)
|
||||||
else -> KotlinFacetSettings() // Reset facet configuration if versions don't match
|
else -> KotlinFacetSettings() // Reset facet configuration if versions don't match
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user