From e3e1c2cb3bb1118e1d403ef03468b179f22ef2e4 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Mon, 6 Apr 2020 21:32:41 +0700 Subject: [PATCH] HMPP: Fix detection of PlatformDependentAnalyzerServices for TargetPlatform --- .../kotlin/idea/project/analyzerServices.kt | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/analyzerServices.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/analyzerServices.kt index 67b3dc12152..43f97b49a55 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/analyzerServices.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/analyzerServices.kt @@ -13,24 +13,32 @@ import org.jetbrains.kotlin.platform.SimplePlatform import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.isCommon import org.jetbrains.kotlin.platform.js.JsPlatform +import org.jetbrains.kotlin.platform.js.isJs import org.jetbrains.kotlin.platform.jvm.JvmPlatform +import org.jetbrains.kotlin.platform.jvm.isJvm import org.jetbrains.kotlin.platform.konan.NativePlatform +import org.jetbrains.kotlin.platform.konan.isNative import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices import java.lang.IllegalStateException fun TargetPlatform.findAnalyzerServices(project: Project): PlatformDependentAnalyzerServices = when { - isCommon() && project.useCompositeAnalysis -> CompositeAnalyzerServices(componentPlatforms.map { it.findAnalyzerServices() }) - isCommon() && !project.useCompositeAnalysis -> CommonPlatformAnalyzerServices - else -> single().findAnalyzerServices() + isCommon() -> { + if (project.useCompositeAnalysis) + CompositeAnalyzerServices(componentPlatforms.map { it.findAnalyzerServices() }) + else + CommonPlatformAnalyzerServices + } + isJvm() -> JvmPlatformAnalyzerServices + isJs() -> JsPlatformAnalyzerServices + isNative() -> NativePlatformAnalyzerServices + else -> throw IllegalStateException("Unknown platform $this") } -fun SimplePlatform.findAnalyzerServices(): PlatformDependentAnalyzerServices { - return when (this) { - is JvmPlatform -> JvmPlatformAnalyzerServices - is JsPlatform -> JsPlatformAnalyzerServices - is NativePlatform -> NativePlatformAnalyzerServices - else -> throw IllegalStateException("Unknown platform $this") - } -} \ No newline at end of file +fun SimplePlatform.findAnalyzerServices(): PlatformDependentAnalyzerServices = when (this) { + is JvmPlatform -> JvmPlatformAnalyzerServices + is JsPlatform -> JsPlatformAnalyzerServices + is NativePlatform -> NativePlatformAnalyzerServices + else -> throw IllegalStateException("Unknown platform $this") +}