[Compatibility] Restore KotlinFacetSettings.getTargetPlatform()

Original commit: ef39e2a68f
This commit is contained in:
Dmitry Savvinov
2019-05-23 13:07:00 +03:00
parent 9be3d90cb6
commit 60b239b52d
2 changed files with 21 additions and 1 deletions
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
import org.jetbrains.kotlin.platform.IdePlatformKind
import org.jetbrains.kotlin.platform.TargetPlatformVersion
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.compat.toIdePlatform
import org.jetbrains.kotlin.utils.DescriptionAware
@Deprecated("Use IdePlatformKind instead.", level = DeprecationLevel.ERROR)
@@ -194,6 +195,16 @@ class KotlinFacetSettings {
return IdePlatformKind.platformByCompilerArguments(compilerArguments)
}
@Suppress("DEPRECATION_ERROR")
@Deprecated(
message = "This accessor is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
replaceWith = ReplaceWith("targetPlatform"),
level = DeprecationLevel.ERROR
)
fun getPlatform(): org.jetbrains.kotlin.platform.IdePlatform<*, *>? {
return platform?.toIdePlatform()
}
var coroutineSupport: LanguageFeature.State?
get() {
val languageVersion = languageLevel ?: return LanguageFeature.Coroutines.defaultState
@@ -7,6 +7,7 @@
package org.jetbrains.kotlin.platform.compat
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.platform.CommonPlatforms
import org.jetbrains.kotlin.platform.IdePlatform
import org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind
@@ -46,7 +47,6 @@ fun OldPlatform.toNewPlatform(): NewPlatform = when (this) {
)
}
fun IdePlatform<*, *>.toNewPlatform(): NewPlatform = when (this) {
is CommonIdePlatformKind.Platform -> CommonPlatforms.defaultCommonPlatform
is JvmIdePlatformKind.Platform -> JvmPlatforms.jvmPlatformByTargetVersion(this.version)
@@ -54,3 +54,12 @@ fun IdePlatform<*, *>.toNewPlatform(): NewPlatform = when (this) {
is NativeIdePlatformKind.Platform -> KonanPlatforms.defaultKonanPlatform
else -> error("Unknown platform $this")
}
fun NewPlatform.toIdePlatform(): IdePlatform<*, *> = when (val single = singleOrNull()) {
null -> CommonIdePlatformKind.Platform
is JdkPlatform -> JvmIdePlatformKind.Platform(single.targetVersion)
is JvmPlatform -> JvmIdePlatformKind.Platform(JvmTarget.DEFAULT)
is JsPlatform -> JsIdePlatformKind.Platform
is KonanPlatform -> NativeIdePlatformKind.Platform
else -> error("Unknown platform $single")
}