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") +}