diff --git a/idea/idea-jvm/resources/messages/KotlinJvmBundle.properties b/idea/idea-jvm/resources/messages/KotlinJvmBundle.properties index 49f84bddfb6..82dc33cea53 100644 --- a/idea/idea-jvm/resources/messages/KotlinJvmBundle.properties +++ b/idea/idea-jvm/resources/messages/KotlinJvmBundle.properties @@ -105,8 +105,8 @@ create.kotlin.javascript.library=Create Kotlin JavaScript Library javascript.library.creation=JavaScript Library Creation java.runtime.library.creation=Java Runtime Library Creation presentable.type.js.files=JS files -kotlin.project.with.a.javascript.target.based.on.the.intellij.idea.build.system=Kotlin project with a JavaScript target based on the IntelliJ IDEA build system -kotlin.project.with.a.jvm.target.based.on.the.intellij.idea.build.system=Kotlin project with a JVM target based on the IntelliJ IDEA build system +kotlin.project.with.a.javascript.target.based.on.the.intellij.idea.build.system=Kotlin module with a JavaScript target based on the IntelliJ IDEA build system +kotlin.project.with.a.jvm.target.based.on.the.intellij.idea.build.system=Kotlin module with a JVM target based on the IntelliJ IDEA build system command.action.add.injection.comment=Add injection comment command.action.add.injection.annotation=Add injection annotation command.action.remove.injection.in.code.instructions=remove injection in-code instructions diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt index 1163ae79c1b..512b3c78a78 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt @@ -9,6 +9,7 @@ import com.intellij.ide.util.projectWizard.ModuleBuilder import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.extensions.Extensions +import com.intellij.openapi.roots.ui.configuration.actions.NewModuleAction import com.intellij.platform.ProjectTemplate import com.intellij.platform.ProjectTemplatesFactory import com.intellij.platform.templates.BuilderBasedTemplate @@ -31,30 +32,40 @@ class KotlinTemplatesFactory : ProjectTemplatesFactory() { override fun getGroupWeight(group: String?): Int = 1 override fun createTemplates(group: String?, context: WizardContext?): Array { - val result = mutableListOf( - BuilderBasedTemplate( - KotlinModuleBuilder( - JvmPlatforms.unspecifiedJvmPlatform, - "JVM | IDEA", - KotlinJvmBundle.message("presentable.name.jvm.idea"), - KotlinJvmBundle.message("kotlin.project.with.a.jvm.target.based.on.the.intellij.idea.build.system"), - KotlinIcons.SMALL_LOGO - ) - ), - - BuilderBasedTemplate( - KotlinModuleBuilder( - JsPlatforms.defaultJsPlatform, - "JS | IDEA", - KotlinJvmBundle.message("presentable.name.js.idea"), - KotlinJvmBundle.message("kotlin.project.with.a.javascript.target.based.on.the.intellij.idea.build.system"), - KotlinIcons.JS + val result = mutableListOf() + if (isNewModuleAction()) { + result.add( + BuilderBasedTemplate( + KotlinModuleBuilder( + JvmPlatforms.unspecifiedJvmPlatform, + "JVM | IDEA", + KotlinJvmBundle.message("presentable.name.jvm.idea"), + KotlinJvmBundle.message("kotlin.project.with.a.jvm.target.based.on.the.intellij.idea.build.system"), + KotlinIcons.SMALL_LOGO + ) ) ) - ) + result.add( + BuilderBasedTemplate( + KotlinModuleBuilder( + JsPlatforms.defaultJsPlatform, + "JS | IDEA", + KotlinJvmBundle.message("presentable.name.js.idea"), + KotlinJvmBundle.message("kotlin.project.with.a.javascript.target.based.on.the.intellij.idea.build.system"), + KotlinIcons.JS + ) + ) + ) + } @Suppress("DEPRECATION") result.addAll(Extensions.getExtensions(EP_NAME).map { BuilderBasedTemplate(it) }) return result.toTypedArray() } + + private fun isNewModuleAction(): Boolean { + return Thread.currentThread().stackTrace.any { element -> + element.className == NewModuleAction::class.java.name + } + } }