mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJ-CR-25995 added custom project builder plugin validation instead all available builder ids enum validator
GitOrigin-RevId: 7aa1876c752be6a6a8acd20615dc0d8097e55de9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
41e1490049
commit
dcc1959f38
+1
-3
@@ -27,8 +27,6 @@ import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators;
|
||||
|
||||
|
||||
public class CloudModuleBuilder extends JavaModuleBuilder {
|
||||
|
||||
@@ -62,7 +60,7 @@ public class CloudModuleBuilder extends JavaModuleBuilder {
|
||||
|
||||
@Override
|
||||
public @NonNls String getBuilderId() {
|
||||
return Generators.CLOUD;
|
||||
return "Cloud";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+35
-8
@@ -13,7 +13,11 @@ import com.intellij.ide.wizard.NewProjectWizardStep
|
||||
import com.intellij.internal.statistic.eventLog.EventLogGroup
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData
|
||||
import com.intellij.internal.statistic.eventLog.events.*
|
||||
import com.intellij.internal.statistic.eventLog.validator.ValidationResultType
|
||||
import com.intellij.internal.statistic.eventLog.validator.rules.EventContext
|
||||
import com.intellij.internal.statistic.eventLog.validator.rules.impl.CustomValidationRule
|
||||
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
|
||||
import com.intellij.internal.statistic.utils.getPluginInfo
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.util.lang.JavaVersion
|
||||
@@ -31,7 +35,7 @@ class NewProjectWizardCollector : CounterUsagesCollector() {
|
||||
private val screenNumField = EventFields.Int("screen")
|
||||
private val typedCharsField = IntEventField("typed_chars")
|
||||
private val hitsField = IntEventField("hits")
|
||||
private val generatorTypeField = BoundedStringEventField.enum("generator", *NewProjectWizardConstants.Generators.ALL)
|
||||
private val generatorTypeField = GeneratorEventField("generator")
|
||||
private val languageField = BoundedStringEventField.lowercase("language", *NewProjectWizardConstants.Language.ALL)
|
||||
private val gitField = EventFields.Boolean("git")
|
||||
private val isSucceededField = EventFields.Boolean("project_created")
|
||||
@@ -86,11 +90,11 @@ class NewProjectWizardCollector : CounterUsagesCollector() {
|
||||
@JvmStatic fun logOpen(context: WizardContext) = open.log(context.project,sessionIdField with context.sessionId.id, screenNumField with context.screen)
|
||||
@JvmStatic fun logFinish(context: WizardContext, success: Boolean, duration: Long) = finish.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, isSucceededField with success, EventFields.DurationMs with duration)
|
||||
@JvmStatic fun logSearchChanged(context: WizardContext, chars: Int, results: Int) = search.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, typedCharsField with min(chars, 10), hitsField with results)
|
||||
@JvmStatic fun logLocationChanged(context: WizardContext, generator: String) = location.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logNameChanged(context: WizardContext, generator: String) = name.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logLocationChanged(context: WizardContext, generator: ModuleBuilder?) = location.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logNameChanged(context: WizardContext, generator: ModuleBuilder?) = name.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logLanguageChanged(context: WizardContext, language: String) = languageSelected.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, languageField with language)
|
||||
@JvmStatic fun logGitChanged(context: WizardContext) = gitChanged.log(context.project,screenNumField with context.screen)
|
||||
@JvmStatic fun logGeneratorSelected(context: WizardContext, generator: String) = generatorSelected.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logGeneratorSelected(context: WizardContext, generator: ModuleBuilder?) = generatorSelected.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logCustomTemplateSelected(context: WizardContext) = templateSelected.log(context.project,screenNumField with context.screen)
|
||||
@JvmStatic fun logNext(context: WizardContext, inputMask: Long = -1) = next.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, inputMaskField with inputMask)
|
||||
@JvmStatic fun logPrev(context: WizardContext, inputMask: Long = -1) = prev.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, inputMaskField with inputMask)
|
||||
@@ -100,7 +104,7 @@ class NewProjectWizardCollector : CounterUsagesCollector() {
|
||||
@JvmStatic fun logProjectCreated(project: Project?, context: WizardContext) = projectCreated.log(project,screenNumField with context.screen)
|
||||
@JvmStatic fun logLanguageFinished(context: WizardContext, language: String) = languageFinished.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, languageField with language)
|
||||
@JvmStatic fun logGitFinished(context: WizardContext, git: Boolean) = gitFinish.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, gitField with git)
|
||||
@JvmStatic fun logGeneratorFinished(context: WizardContext, generator: String) = generatorFinished.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logGeneratorFinished(context: WizardContext, generator: ModuleBuilder?) = generatorFinished.log(context.project, sessionIdField with context.sessionId.id,screenNumField with context.screen, generatorTypeField with generator)
|
||||
@JvmStatic fun logAddPlugin(context: WizardContext) = addPlugin.log(context.project,screenNumField with context.screen)
|
||||
@JvmStatic fun logPluginSelected(context: WizardContext, plugin: String) = pluginSelected.log(context.project, sessionIdField with context.sessionId.id, screenNumField with context.screen, pluginField with plugin)
|
||||
|
||||
@@ -114,9 +118,8 @@ class NewProjectWizardCollector : CounterUsagesCollector() {
|
||||
private val Sdk.featureVersion: Int?
|
||||
get() = JavaVersion.tryParse(versionString)?.feature
|
||||
|
||||
private val WizardContext.generator: String
|
||||
get() = (projectBuilder as? ModuleBuilder)?.builderId?.removePrefix(NPW_PREFIX)
|
||||
?: OTHER
|
||||
private val WizardContext.generator: ModuleBuilder?
|
||||
get() = projectBuilder as? ModuleBuilder
|
||||
|
||||
private val NewProjectWizardStep.language: String
|
||||
get() = (this as? LanguageNewProjectWizardData)?.language
|
||||
@@ -212,4 +215,28 @@ class NewProjectWizardCollector : CounterUsagesCollector() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class GeneratorEventField(override val name: String) : PrimitiveEventField<ModuleBuilder?>() {
|
||||
|
||||
override fun addData(fuData: FeatureUsageData, value: ModuleBuilder?) {
|
||||
fuData.addPluginInfo(value?.let { getPluginInfo(it.javaClass) })
|
||||
fuData.addData(name, value?.builderId?.removePrefix(NPW_PREFIX) ?: OTHER)
|
||||
}
|
||||
|
||||
override val validationRule: List<String>
|
||||
get() = listOf("{util#${GeneratorValidationRule.ID}}")
|
||||
}
|
||||
|
||||
class GeneratorValidationRule : CustomValidationRule() {
|
||||
override fun getRuleId(): String = ID
|
||||
|
||||
override fun doValidate(data: String, context: EventContext): ValidationResultType {
|
||||
if (isThirdPartyValue(data) || OTHER == data) return ValidationResultType.ACCEPTED
|
||||
return acceptWhenReportedByPluginFromPluginRepository(context)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ID = "npw_generator"
|
||||
}
|
||||
}
|
||||
}
|
||||
-73
@@ -32,79 +32,6 @@ object NewProjectWizardConstants {
|
||||
const val EMPTY_WEB_PROJECT = "empty-web-project"
|
||||
const val SIMPLE_PROJECT = "simple-project"
|
||||
const val SIMPLE_MODULE = "simple-module"
|
||||
|
||||
const val ALL_REACT = "AllReact"
|
||||
const val ALL_HTML5 = "AllHTML5"
|
||||
const val DJANGO = "django"
|
||||
const val FAST_API = "FastApi"
|
||||
const val FLASK = "Flask"
|
||||
const val MAVEN_ARCHETYPE = "MavenArchetype"
|
||||
|
||||
const val ANGULAR_CLI = "AngularCLI"
|
||||
const val COMPOSER = "Composer"
|
||||
const val CORDOVA = "Cordova"
|
||||
const val DART = "Dart"
|
||||
const val DRUPAL = "Drupal"
|
||||
const val EXPRESS_APP = "ExpressApp"
|
||||
const val HTML5 = "HTML5"
|
||||
const val JOOMLA = "Joomla"
|
||||
const val METEOR = "Meteor"
|
||||
const val NODE_JS = "NodeJS"
|
||||
const val PHP = "PHP"
|
||||
const val PHP_STORM_WORKSHOP = "PhpStormWorkshop"
|
||||
const val R_PROJECT = "R_PROJECT"
|
||||
const val R_PACKAGE = "R_PACKAGE"
|
||||
const val REACT = "React"
|
||||
const val REACT_NATIVE = "ReactNative"
|
||||
const val TWITTER = "TwitterBootstrap"
|
||||
const val VUE_JS = "VueJS"
|
||||
const val WORD_PRESS = "WordPress"
|
||||
|
||||
const val ANDROID = "Android"
|
||||
const val CLOUD = "Cloud"
|
||||
const val COMPOSE = "ComposeModuleBuilder"
|
||||
const val GAUGE = "gauge"
|
||||
const val GRAILS_FORGE = "GrailsForge"
|
||||
const val GRAILS = "Grails"
|
||||
const val GROOVY = "groovy"
|
||||
const val HELIDON = "helidon"
|
||||
const val IDEA_PLUGIN = "idea-plugin"
|
||||
const val JAVAEE = "javaee"
|
||||
const val JAVAFX = "javafx"
|
||||
const val KTOR = "KtorStarter"
|
||||
const val MICRONAUT = "micronaut"
|
||||
const val QUARKUS = "quarkus-jetbrains"
|
||||
const val PUPPET = "Puppet"
|
||||
const val RUBY_GEM = "RubyGem"
|
||||
const val RUBY_ON_RAILS = "RubyOnRails"
|
||||
const val SELENIUM = "selenium"
|
||||
const val SPRING_INITIALIZR = "SpringInitializr"
|
||||
const val YEOMAN = "Yeoman"
|
||||
|
||||
const val FLASH = "Flex"
|
||||
const val KOTLIN_MPP = "kotlin.newProjectWizard.builder"
|
||||
|
||||
const val LEGACY_DART = "DartModuleBuilder"
|
||||
const val LEGACY_GRADLE = "InternalGradleModuleBuilder"
|
||||
const val LEGACY_MAVEN = "InternalMavenModuleBuilder"
|
||||
const val LEGACY_JAVA_EE = "LegacyJavaEE"
|
||||
const val LEGACY_SPRING = "LegacySpring"
|
||||
|
||||
val ALL = arrayOf(
|
||||
EMPTY_PROJECT, EMPTY_WEB_PROJECT, SIMPLE_PROJECT, SIMPLE_MODULE,
|
||||
|
||||
ALL_REACT, ALL_HTML5, DJANGO, FAST_API, FLASK, MAVEN_ARCHETYPE,
|
||||
|
||||
ANGULAR_CLI, COMPOSER, CORDOVA, DART, DRUPAL, EXPRESS_APP, HTML5, JOOMLA, METEOR, NODE_JS, PHP, PHP_STORM_WORKSHOP, R_PROJECT,
|
||||
R_PACKAGE, REACT, REACT_NATIVE, TWITTER, VUE_JS, WORD_PRESS,
|
||||
|
||||
ANDROID, CLOUD, COMPOSE, GAUGE, GRAILS_FORGE, GRAILS, GROOVY, HELIDON, IDEA_PLUGIN, JAVAEE, JAVAFX, KTOR, MICRONAUT, QUARKUS, PUPPET,
|
||||
RUBY_GEM, RUBY_ON_RAILS, SELENIUM, SPRING_INITIALIZR, YEOMAN,
|
||||
|
||||
FLASH, KOTLIN_MPP,
|
||||
|
||||
LEGACY_DART, LEGACY_GRADLE, LEGACY_MAVEN, LEGACY_JAVA_EE, LEGACY_SPRING
|
||||
)
|
||||
}
|
||||
|
||||
const val OTHER = "other"
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ abstract class NewProjectLinkNewProjectWizardStep(parent: NewProjectWizardStep)
|
||||
|
||||
private val builder = if (context.isCreatingNewProject) NewProjectBuilder() else NewModuleBuilder()
|
||||
|
||||
override val builderId: String = builder.builderId!!
|
||||
override val builderId: String = builder.builderId
|
||||
|
||||
override val comment: String by lazy { getComment(builder.presentableName) }
|
||||
|
||||
|
||||
@@ -800,6 +800,7 @@
|
||||
<statistics.counterUsagesCollector implementationClass="com.intellij.application.options.colors.ReaderModeStatsCollector"/>
|
||||
<statistics.counterUsagesCollector implementationClass="com.intellij.diagnostic.IdeErrorDialogUsageCollector"/>
|
||||
<statistics.counterUsagesCollector implementationClass="com.intellij.ide.projectWizard.NewProjectWizardCollector"/>
|
||||
<statistics.validation.customValidationRule implementation="com.intellij.ide.projectWizard.NewProjectWizardCollector$GeneratorValidationRule"/>
|
||||
|
||||
<statistics.collectorExtension implementation="com.intellij.ide.actions.ToolwindowFusEventFields"/>
|
||||
<statistics.collectorExtension implementation="com.intellij.ide.actions.DragEditorTabsFusEventFields"/>
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager
|
||||
import com.intellij.ide.plugins.PluginManager
|
||||
import com.intellij.ide.projectView.actions.MarkRootActionBase
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators
|
||||
import com.intellij.ide.starters.local.*
|
||||
import com.intellij.ide.starters.local.wizard.StarterInitialStep
|
||||
import com.intellij.ide.starters.shared.*
|
||||
@@ -41,7 +40,7 @@ class IdePluginModuleBuilder : StarterModuleBuilder() {
|
||||
|
||||
private val PLUGIN_TYPE_KEY: Key<PluginType> = Key.create("ide.plugin.type")
|
||||
|
||||
override fun getBuilderId(): String = Generators.IDEA_PLUGIN
|
||||
override fun getBuilderId(): String = "idea-plugin"
|
||||
override fun getPresentableName(): String = DevKitBundle.message("module.builder.title")
|
||||
override fun getWeight(): Int = IJ_PLUGIN_WEIGHT
|
||||
override fun getNodeIcon(): Icon = AllIcons.Nodes.Plugin
|
||||
|
||||
@@ -12,16 +12,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class InternalGradleModuleBuilder extends AbstractGradleModuleBuilder {
|
||||
|
||||
@Override
|
||||
public String getBuilderId() {
|
||||
return Generators.LEGACY_GRADLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
|
||||
return new ModuleWizardStep[]{new GradleStructureWizardStep(this, wizardContext)};
|
||||
|
||||
+1
-3
@@ -22,8 +22,6 @@ import org.jetbrains.plugins.groovy.config.wizard.GroovyProjectWizardUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -72,7 +70,7 @@ public final class GroovyAwareModuleBuilder extends JavaModuleBuilder {
|
||||
|
||||
@Override
|
||||
public @NonNls String getBuilderId() {
|
||||
return Generators.GROOVY;
|
||||
return "groovy";
|
||||
}
|
||||
|
||||
public void addGroovySample(@NotNull String path) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.jetbrains.plugins.javaFX.wizard
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators
|
||||
import com.intellij.ide.starters.local.*
|
||||
import com.intellij.ide.starters.local.StandardAssetsProvider
|
||||
import com.intellij.ide.starters.shared.*
|
||||
@@ -16,7 +15,7 @@ import org.jetbrains.plugins.javaFX.JavaFXBundle
|
||||
import javax.swing.Icon
|
||||
|
||||
internal class JavaFxModuleBuilder : StarterModuleBuilder() {
|
||||
override fun getBuilderId(): String = Generators.JAVAFX
|
||||
override fun getBuilderId(): String = "javafx"
|
||||
override fun getNodeIcon(): Icon = AllIcons.Nodes.Module
|
||||
override fun getPresentableName(): String = JavaFXBundle.JAVA_FX
|
||||
override fun getDescription(): String = JavaFXBundle.message("javafx.module.builder.description")
|
||||
|
||||
+1
-3
@@ -2,7 +2,6 @@
|
||||
package org.jetbrains.kotlin.tools.composeProjectWizard
|
||||
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators
|
||||
import com.intellij.ide.starters.local.*
|
||||
import com.intellij.ide.starters.local.StandardAssetsProvider
|
||||
import com.intellij.ide.starters.local.wizard.StarterInitialStep
|
||||
@@ -25,8 +24,7 @@ class ComposeModuleBuilder : StarterModuleBuilder() {
|
||||
val COMPOSE_PLATFORM_KEY: Key<ComposePWInitialStep.ComposePlatform> = Key.create("compose.platform")
|
||||
}
|
||||
|
||||
|
||||
override fun getBuilderId(): String = Generators.COMPOSE
|
||||
override fun getBuilderId(): String = "ComposeModuleBuilder"
|
||||
override fun getPresentableName(): String = ComposeProjectWizardBundle.message("module.presentation.name")
|
||||
override fun getWeight(): Int = KOTLIN_WEIGHT-1
|
||||
override fun getNodeIcon(): Icon = KotlinIcons.Wizard.COMPOSE
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard
|
||||
|
||||
import com.intellij.ide.RecentProjectsManager
|
||||
import com.intellij.ide.actions.NewProjectAction
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators
|
||||
import com.intellij.ide.util.projectWizard.*
|
||||
import com.intellij.ide.wizard.AbstractWizard
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -76,7 +75,7 @@ class NewProjectWizardModuleBuilder : EmptyModuleBuilder() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MODULE_BUILDER_ID = Generators.KOTLIN_MPP
|
||||
const val MODULE_BUILDER_ID = "kotlin.newProjectWizard.builder"
|
||||
private val projectNameValidator = StringValidators.shouldBeValidIdentifier("Project name", setOf('-', '_'))
|
||||
private val INVALID_PROJECT_NAME_MESSAGE
|
||||
@NlsContexts.DialogTitle
|
||||
|
||||
-7
@@ -16,16 +16,9 @@ import org.jetbrains.idea.maven.importing.MavenProjectImporter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class InternalMavenModuleBuilder extends AbstractMavenModuleBuilder {
|
||||
|
||||
@Override
|
||||
public String getBuilderId() {
|
||||
return Generators.LEGACY_MAVEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
|
||||
return new ModuleWizardStep[]{
|
||||
|
||||
+1
-2
@@ -7,7 +7,6 @@ import com.intellij.execution.util.setVisibleRowCount
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardCollector.BuildSystem.logVersionChanged
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.BuildSystem.MAVEN
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.Generators
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardConstants.Language.JAVA
|
||||
import com.intellij.ide.projectWizard.generators.AssetsNewProjectWizardStep
|
||||
import com.intellij.ide.projectWizard.generators.BuildSystemJavaNewProjectWizardData.Companion.buildSystem
|
||||
@@ -66,7 +65,7 @@ import javax.swing.Icon
|
||||
import javax.swing.JList
|
||||
|
||||
class MavenArchetypeNewProjectWizard : GeneratorNewProjectWizard {
|
||||
override val id: String = Generators.MAVEN_ARCHETYPE
|
||||
override val id: String = "MavenArchetype"
|
||||
|
||||
override val name: String = MavenWizardBundle.message("maven.new.project.wizard.archetype.generator.name")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user