[Gradle, JS] Divide allowSinglePlatform

^KT-40527 fixed
This commit is contained in:
Ilya Goncharov
2020-07-21 15:27:54 +03:00
parent af367b01ec
commit 2d60d2c0e6
5 changed files with 35 additions and 18 deletions
@@ -18,7 +18,8 @@ import javax.swing.Icon
class CreateModuleOrTargetPopup private constructor(
private val target: Module?,
private val allowMultiplatform: Boolean,
private val allowSinglePlatformJs: Boolean,
private val allowSinglePlatformJsBrowser: Boolean,
private val allowSinglePlatformJsNode: Boolean,
private val allowAndroid: Boolean,
private val allowIos: Boolean,
private val createTarget: (TargetConfigurator) -> Unit,
@@ -42,10 +43,8 @@ class CreateModuleOrTargetPopup private constructor(
if (allowMultiplatform) +MppModuleConfigurator
+JvmSinglePlatformModuleConfigurator
if (allowAndroid) +AndroidSinglePlatformModuleConfigurator
if (allowSinglePlatformJs) {
+BrowserJsSinglePlatformModuleConfigurator
+NodeJsSinglePlatformModuleConfigurator
}
if (allowSinglePlatformJsBrowser) +BrowserJsSinglePlatformModuleConfigurator
if (allowSinglePlatformJsNode) +NodeJsSinglePlatformModuleConfigurator
if (allowIos) +IOSSinglePlatformModuleConfigurator
}
) {
@@ -108,7 +107,8 @@ class CreateModuleOrTargetPopup private constructor(
fun create(
target: Module?,
allowMultiplatform: Boolean,
allowSinglePlatformJs: Boolean,
allowSinglePlatformJsBrowser: Boolean,
allowSinglePlatformJsNode: Boolean,
allowAndroid: Boolean,
allowIos: Boolean,
createTarget: (TargetConfigurator) -> Unit,
@@ -116,7 +116,8 @@ class CreateModuleOrTargetPopup private constructor(
) = CreateModuleOrTargetPopup(
target = target,
allowMultiplatform = allowMultiplatform,
allowSinglePlatformJs = allowSinglePlatformJs,
allowSinglePlatformJsBrowser = allowSinglePlatformJsBrowser,
allowSinglePlatformJsNode = allowSinglePlatformJsNode,
allowAndroid = allowAndroid,
allowIos = allowIos,
createTarget = createTarget,
@@ -37,7 +37,8 @@ class ModulesEditorComponent(
moduleCreator.create(
target = null, // The empty tree case
allowMultiplatform = isMppProject,
allowSinglePlatformJs = isMppProject,
allowSinglePlatformJsBrowser = isMppProject,
allowSinglePlatformJsNode = isMppProject,
allowAndroid = isMppProject,
allowIos = isMppProject,
allModules = value ?: emptyList(),
@@ -5,10 +5,7 @@ import com.intellij.openapi.actionSystem.ActionToolbarPosition
import com.intellij.openapi.ui.Messages
import com.intellij.ui.ToolbarDecorator
import org.jetbrains.kotlin.tools.projectWizard.KotlinNewProjectWizardBundle
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.AndroidSinglePlatformModuleConfigurator
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.IOSSinglePlatformModuleConfigurator
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.BrowserJsSinglePlatformModuleConfigurator
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.MppModuleConfigurator
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.*
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.withAllSubModules
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.ModuleKind
@@ -36,9 +33,16 @@ class ModulesEditorToolbarDecorator(
allowMultiplatform = isMultiplatformProject()
&& isRootModule
&& allModules.none { it.configurator == MppModuleConfigurator },
allowSinglePlatformJs = isMultiplatformProject()
&& isRootModule
&& allModules.none { it.configurator == BrowserJsSinglePlatformModuleConfigurator },
allowSinglePlatformJsBrowser = allowSinglePlatformJs(
configurator = BrowserJsSinglePlatformModuleConfigurator,
allModules = allModules,
isRootModule = isRootModule
),
allowSinglePlatformJsNode = allowSinglePlatformJs(
configurator = NodeJsSinglePlatformModuleConfigurator,
allModules = allModules,
isRootModule = isRootModule
),
allowAndroid = isRootModule
&& isMultiplatformProject()
&& allModules.none { it.configurator == AndroidSinglePlatformModuleConfigurator },
@@ -108,6 +112,15 @@ class ModulesEditorToolbarDecorator(
setMoveUpAction(null)
}
private fun allowSinglePlatformJs(
configurator: JsSinglePlatformModuleConfigurator,
allModules: List<Module>,
isRootModule: Boolean
) =
isMultiplatformProject()
&& isRootModule
&& allModules.none { it.configurator == configurator }
private val selectedModule
get() = tree.selectedSettingItem.safeAs<Module>()
@@ -35,7 +35,8 @@ class NewModuleCreator {
fun create(
target: Module?,
allowMultiplatform: Boolean,
allowSinglePlatformJs: Boolean,
allowSinglePlatformJsBrowser: Boolean,
allowSinglePlatformJsNode: Boolean,
allowAndroid: Boolean,
allowIos: Boolean,
allModules: List<Module>,
@@ -43,7 +44,8 @@ class NewModuleCreator {
) = CreateModuleOrTargetPopup.create(
target = target,
allowMultiplatform = allowMultiplatform,
allowSinglePlatformJs = allowSinglePlatformJs,
allowSinglePlatformJsBrowser = allowSinglePlatformJsBrowser,
allowSinglePlatformJsNode = allowSinglePlatformJsNode,
allowAndroid = allowAndroid,
allowIos = allowIos,
createTarget = { targetConfigurator ->
@@ -90,7 +90,7 @@ enum class JsTarget {
}
abstract class JsSinglePlatformModuleConfigurator(
private val jsTarget: JsTarget
jsTarget: JsTarget
) : JSConfigurator, ModuleConfiguratorWithTests, SinglePlatformModuleConfigurator,
ModuleConfiguratorWithSettings {
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =