diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt new file mode 100644 index 00000000000..1c15f8eb146 --- /dev/null +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.run.multiplatform + +import com.intellij.execution.Location +import com.intellij.execution.PsiLocation +import com.intellij.execution.actions.MultipleRunLocationsProvider +import com.intellij.openapi.module.Module +import org.jetbrains.kotlin.config.KotlinModuleKind +import org.jetbrains.kotlin.idea.caches.project.implementingModules +import org.jetbrains.kotlin.idea.caches.project.isNewMPPModule +import org.jetbrains.kotlin.idea.configuration.toModuleGroup +import org.jetbrains.kotlin.idea.facet.KotlinFacet + +class KotlinMultiplatformRunLocationsProvider : MultipleRunLocationsProvider() { + override fun getLocationDisplayName(locationCreatedFrom: Location<*>, originalLocation: Location<*>): String? { + val module = locationCreatedFrom.module ?: return null + return "[${compactedGradleProjectId(module) ?: module.name}]" + } + + override fun getAlternativeLocations(originalLocation: Location<*>): List> { + val originalModule = originalLocation.module ?: return emptyList() + return modulesToRunFrom(originalModule).map { PsiLocation(originalLocation.project, it, originalLocation.psiElement) } + } +} + +private fun compactedGradleProjectId(module: Module): String? { + if (module.isNewMPPModule) { + // TODO: more robust way to get compilation/sourceSet name + return module.name.substringAfterLast('_') + } else { + return module.toModuleGroup().baseModule.name + } +} + +private fun modulesToRunFrom(originalModule: Module): List { + val modules = originalModule.implementingModules + return if (originalModule.isNewMPPModule) { + modules.filter { KotlinFacet.get(it)?.configuration?.settings?.kind == KotlinModuleKind.COMPILATION_AND_SOURCE_SET_HOLDER } + } else { + modules + } +} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt.181 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt.181 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt.as33 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/multiplatform/KotlinMultiplatformRunLocationsProvider.kt.as33 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/src/META-INF/jvm.xml b/idea/src/META-INF/jvm.xml index 88b203d467d..f62d455e259 100644 --- a/idea/src/META-INF/jvm.xml +++ b/idea/src/META-INF/jvm.xml @@ -107,6 +107,8 @@ + + diff --git a/idea/src/META-INF/jvm.xml.181 b/idea/src/META-INF/jvm.xml.181 new file mode 100644 index 00000000000..88b203d467d --- /dev/null +++ b/idea/src/META-INF/jvm.xml.181 @@ -0,0 +1,172 @@ + + + + + + + + org.jetbrains.kotlin.idea.JvmPluginStartupComponent + + + + + + org.jetbrains.kotlin.idea.compiler.KotlinCompilerManager + + + org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent + + + org.jetbrains.kotlin.idea.scratch.ui.ScratchFileHook + + + org.jetbrains.kotlin.idea.scratch.ScratchFileModuleInfoProvider + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/idea/src/META-INF/jvm.xml.as33 b/idea/src/META-INF/jvm.xml.as33 new file mode 100644 index 00000000000..88b203d467d --- /dev/null +++ b/idea/src/META-INF/jvm.xml.as33 @@ -0,0 +1,172 @@ + + + + + + + + org.jetbrains.kotlin.idea.JvmPluginStartupComponent + + + + + + org.jetbrains.kotlin.idea.compiler.KotlinCompilerManager + + + org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent + + + org.jetbrains.kotlin.idea.scratch.ui.ScratchFileHook + + + org.jetbrains.kotlin.idea.scratch.ScratchFileModuleInfoProvider + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +