Kotlin Facet: Fix reading of v1 configuration

Favor language/api version specified in <versionInfo> element
in case it differs from the one in
<option name="_commonCompilerArguments">

#KT-16861 Fixed

Original commit: 2bb7bdfc3f
This commit is contained in:
Alexey Sedunov
2017-03-16 02:48:27 +03:00
parent 416a5027df
commit fcd77261d0
@@ -33,7 +33,10 @@ private fun readV1Config(element: Element): KotlinFacetSettings {
return KotlinFacetSettings().apply {
val useProjectSettings = element.getOptionValue("useProjectSettings")?.toBoolean()
val targetPlatformName = element.getOptionBody("versionInfo")?.getOptionValue("targetPlatformName")
val versionInfoElement = element.getOptionBody("versionInfo")
val targetPlatformName = versionInfoElement?.getOptionValue("targetPlatformName")
val languageLevel = versionInfoElement?.getOptionValue("languageLevel")
val apiLevel = versionInfoElement?.getOptionValue("apiLevel")
val targetPlatform = TargetPlatformKind.ALL_PLATFORMS.firstOrNull { it.description == targetPlatformName }
?: TargetPlatformKind.Jvm[JvmTarget.DEFAULT]
@@ -57,6 +60,14 @@ private fun readV1Config(element: Element): KotlinFacetSettings {
is K2JSCompilerArguments -> jsArgumentsElement?.let { XmlSerializer.deserializeInto(compilerArguments, it) }
}
if (languageLevel != null) {
compilerArguments.languageVersion = languageLevel
}
if (apiLevel != null) {
compilerArguments.apiVersion = apiLevel
}
if (useProjectSettings != null) {
this.useProjectSettings = useProjectSettings
}