Revert ' Temporary remove JVM_1_8 target from facet settings'
This commit is contained in:
@@ -31,8 +31,12 @@ sealed class TargetPlatformKind<out Version : DescriptionAware>(
|
||||
) : DescriptionAware {
|
||||
override val description = "$name ${version.description}"
|
||||
|
||||
sealed class Jvm(version: JvmTarget) : TargetPlatformKind<JvmTarget>(version, "JVM") {
|
||||
object JVM_1_6 : Jvm(JvmTarget.JVM_1_6)
|
||||
class Jvm(version: JvmTarget) : TargetPlatformKind<JvmTarget>(version, "JVM") {
|
||||
companion object {
|
||||
val JVM_PLATFORMS by lazy { JvmTarget.values().map(::Jvm) }
|
||||
|
||||
operator fun get(version: JvmTarget) = JVM_PLATFORMS[version.ordinal]
|
||||
}
|
||||
}
|
||||
|
||||
object JavaScript : TargetPlatformKind<NoVersion>(NoVersion, "JavaScript")
|
||||
@@ -40,7 +44,8 @@ sealed class TargetPlatformKind<out Version : DescriptionAware>(
|
||||
object Common : TargetPlatformKind<NoVersion>(NoVersion, "Common (experimental)")
|
||||
|
||||
companion object {
|
||||
val ALL_PLATFORMS: List<TargetPlatformKind<*>> by lazy { listOf(Jvm.JVM_1_6, JavaScript, Common) }
|
||||
|
||||
val ALL_PLATFORMS: List<TargetPlatformKind<*>> by lazy { Jvm.JVM_PLATFORMS + JavaScript + Common }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.idea.maven.project.*
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
@@ -116,7 +117,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
||||
private fun detectPlatformByExecutions(mavenProject: MavenProject): TargetPlatformKind<*>? {
|
||||
return mavenProject.findPlugin(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_ARTIFACT_ID)?.executions?.flatMap { it.goals }?.mapNotNull { goal ->
|
||||
when (goal) {
|
||||
PomFile.KotlinGoals.Compile, PomFile.KotlinGoals.TestCompile -> TargetPlatformKind.Jvm.JVM_1_6
|
||||
PomFile.KotlinGoals.Compile, PomFile.KotlinGoals.TestCompile -> TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
|
||||
PomFile.KotlinGoals.Js, PomFile.KotlinGoals.TestJs -> TargetPlatformKind.JavaScript
|
||||
PomFile.KotlinGoals.MetaData -> TargetPlatformKind.Common
|
||||
else -> null
|
||||
|
||||
+3
-1
@@ -195,7 +195,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fillJvmVersionList() {
|
||||
jvmVersionComboBox.addItem(TargetPlatformKind.Jvm.JVM_1_6.INSTANCE.getVersion().getDescription());
|
||||
for (TargetPlatformKind.Jvm jvm : TargetPlatformKind.Jvm.Companion.getJVM_PLATFORMS()) {
|
||||
jvmVersionComboBox.addItem(jvm.getVersion().getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.AbstractProjec
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
@@ -56,7 +57,7 @@ class KotlinGradleProjectDataService : AbstractProjectDataService<GradleSourceSe
|
||||
val externalProjectNode = ExternalSystemApiUtil.find(projectNode as DataNode<*>, ExternalProjectDataService.KEY)
|
||||
return externalProjectNode?.let {
|
||||
when (it.data.plugins.values.map { it.id }.firstOrNull { it.startsWith("kotlin-platform-") }) {
|
||||
"kotlin-platform-jvm" -> TargetPlatformKind.Jvm.JVM_1_6
|
||||
"kotlin-platform-jvm" -> TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
|
||||
"kotlin-platform-js" -> TargetPlatformKind.JavaScript
|
||||
"kotlin-platform-common" -> TargetPlatformKind.Common
|
||||
else -> null
|
||||
|
||||
@@ -18,16 +18,15 @@ package org.jetbrains.kotlin.idea.facet
|
||||
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.projectRoots.JavaSdk
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.ModuleRootModel
|
||||
import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.util.text.VersionComparatorUtil
|
||||
import org.jetbrains.kotlin.cli.common.arguments.copyBean
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JsCompilerArgumentsHolder
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings
|
||||
@@ -70,7 +69,13 @@ private fun getDefaultTargetPlatform(module: Module, rootModel: ModuleRootModel?
|
||||
if (getRuntimeLibraryVersions(module, rootModel, TargetPlatformKind.Common).isNotEmpty()) {
|
||||
return TargetPlatformKind.Common
|
||||
}
|
||||
return TargetPlatformKind.Jvm.JVM_1_6
|
||||
|
||||
val sdk = ((rootModel ?: ModuleRootManager.getInstance(module))).sdk
|
||||
val sdkVersion = (sdk?.sdkType as? JavaSdk)?.getVersion(sdk!!)
|
||||
return when {
|
||||
sdkVersion == null || sdkVersion >= JavaSdkVersion.JDK_1_8 -> TargetPlatformKind.Jvm[JvmTarget.JVM_1_8]
|
||||
else -> TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDefaultLanguageLevel(
|
||||
@@ -93,7 +98,7 @@ internal fun getLibraryLanguageLevel(
|
||||
rootModel: ModuleRootModel?,
|
||||
targetPlatform: TargetPlatformKind<*>?
|
||||
): LanguageVersion {
|
||||
val minVersion = getRuntimeLibraryVersions(module, rootModel, targetPlatform ?: TargetPlatformKind.Jvm.JVM_1_6)
|
||||
val minVersion = getRuntimeLibraryVersions(module, rootModel, targetPlatform ?: TargetPlatformKind.Jvm[JvmTarget.JVM_1_8])
|
||||
.minWith(VersionComparatorUtil.COMPARATOR)
|
||||
return getDefaultLanguageLevel(module, minVersion)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.idea.caches.resolve
|
||||
|
||||
import com.intellij.openapi.roots.DependencyScope
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
|
||||
class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||
@@ -65,7 +66,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
@@ -77,7 +78,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
@@ -89,7 +90,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
@@ -106,7 +107,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
@@ -130,7 +131,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.caches.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
|
||||
class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
||||
@@ -24,7 +25,7 @@ class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
@@ -36,7 +37,7 @@ class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
@@ -48,7 +49,7 @@ class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
val jvm = module("jvm")
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||
jvm.setPlatformKind(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
jvm.enableMultiPlatform()
|
||||
jvm.addDependency(header)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.junit.Test
|
||||
|
||||
@@ -23,7 +24,7 @@ class QuickFixMultiModuleTest : AbstractQuickFixMultiModuleTest() {
|
||||
|
||||
private fun doMultiPlatformTest(headerName: String = "header",
|
||||
implName: String = "jvm",
|
||||
implKind: TargetPlatformKind<*> = TargetPlatformKind.Jvm.JVM_1_6) {
|
||||
implKind: TargetPlatformKind<*> = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) {
|
||||
val header = module(headerName)
|
||||
header.setPlatformKind(TargetPlatformKind.Common)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user