[Compatibility] Restore KotlinFacetSettings.getTargetPlatform()
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user