From 7398a8149dc74111465fdda3610f7bd3850d640f Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 4 Sep 2018 01:59:50 +0300 Subject: [PATCH] Do not use ApplicationExtensionDescriptor in JPS (KT-26542) The 'ExtensionPointName' class that ApplicationExtensionDescriptor uses is missing in the JPS classpath. Now we don't use it unless the IDEA Application is properly initialized. --- .../kotlin/platform/IdePlatformKind.kt | 19 +++++++++---------- ...kLibraryValidatorWithDynamicDescription.kt | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt index 1f5495ce506..a22ddd36636 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/platform/IdePlatformKind.kt @@ -27,19 +27,18 @@ abstract class IdePlatformKind> { override fun equals(other: Any?): Boolean = javaClass == other?.javaClass override fun hashCode(): Int = javaClass.hashCode() - companion object : ApplicationExtensionDescriptor>( - "org.jetbrains.kotlin.idePlatformKind", IdePlatformKind::class.java - ) { + companion object { + // We can't use the ApplicationExtensionDescriptor class directly because it's missing in the JPS process + private val extension = ApplicationManager.getApplication()?.let { + ApplicationExtensionDescriptor("org.jetbrains.kotlin.idePlatformKind", IdePlatformKind::class.java) + } + // For using only in JPS - private val JPS_KINDS = listOf(JvmIdePlatformKind, JsIdePlatformKind, CommonIdePlatformKind) + private val JPS_KINDS get() = listOf(JvmIdePlatformKind, JsIdePlatformKind, CommonIdePlatformKind) val ALL_KINDS by lazy { - if (ApplicationManager.getApplication() == null) { - return@lazy JPS_KINDS - } - - val kinds = getInstances() - require(kinds.isNotEmpty()) { "Platform list is empty" } + val kinds = extension?.getInstances() ?: return@lazy JPS_KINDS + require(kinds.isNotEmpty()) { "Platform kind list is empty" } kinds } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/facet/FrameworkLibraryValidatorWithDynamicDescription.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/facet/FrameworkLibraryValidatorWithDynamicDescription.kt index 4afb52bd799..150f382258d 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/facet/FrameworkLibraryValidatorWithDynamicDescription.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/facet/FrameworkLibraryValidatorWithDynamicDescription.kt @@ -70,7 +70,7 @@ class FrameworkLibraryValidatorWithDynamicDescription( val targetPlatform = getPlatform() if (checkLibraryIsConfigured(targetPlatform)) { - val conflictingPlatforms = IdePlatformKind.getInstances() + val conflictingPlatforms = IdePlatformKind.ALL_KINDS .filter { !it.isCommon && it.name != targetPlatform.name && checkLibraryIsConfigured(it) } if (conflictingPlatforms.isNotEmpty()) {