Wizard: move settings to separate package
This commit is contained in:
+3
-4
@@ -1,15 +1,14 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.PluginsCreator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.ProjectTemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.service.IdeaWizardService
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
+4
-1
@@ -2,9 +2,12 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard.ui
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSettingPropertyReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
|
||||
abstract class Component : Displayable {
|
||||
private val subComponents = mutableListOf<Component>()
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui
|
||||
|
||||
import com.intellij.ui.components.panels.VerticalLayout
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.StringSettingComponent
|
||||
|
||||
+2
@@ -8,6 +8,8 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.components
|
||||
import com.intellij.openapi.Disposable
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.DynamicComponent
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.FocusableComponent
|
||||
|
||||
+4
-5
@@ -4,14 +4,13 @@ import com.intellij.icons.AllIcons
|
||||
import icons.GradleIcons
|
||||
import icons.OpenapiIcons
|
||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.DropDownSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.DropDownSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.KotlinNewProjectWizardBundle
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.components.DropDownComponent
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.UIComponentDelegatingSettingComponent
|
||||
|
||||
@@ -25,7 +24,7 @@ class BuildSystemTypeSettingComponent(
|
||||
override val uiComponent: DropDownComponent<BuildSystemType> = DropDownComponent(
|
||||
ideContext,
|
||||
setting.type.values,
|
||||
labelText = KotlinNewProjectWizardBundle.message("setting.build.system.label"),
|
||||
labelText = "Build System",
|
||||
filter = { value -> read { setting.type.filter(this, reference, value) } },
|
||||
validator = setting.validator,
|
||||
iconProvider = BuildSystemType::icon,
|
||||
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.firstStep
|
||||
|
||||
import TemplateTag
|
||||
import com.intellij.ide.plugins.newui.VerticalLayout
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.util.ui.JBUI
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.ProjectTemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.applyProjectTemplate
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.firstStep
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.DropDownSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.DropDownSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.ProjectTemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
|
||||
+2
-3
@@ -2,10 +2,9 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep.modulesEdi
|
||||
|
||||
import com.intellij.ui.JBColor
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ListSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ListSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
||||
|
||||
import com.intellij.openapi.ui.ComboBox
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.Setting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.Setting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.Displayable
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.DynamicComponent
|
||||
|
||||
+2
-3
@@ -1,11 +1,10 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
||||
|
||||
import com.intellij.ui.components.panels.VerticalLayout
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.isSpecificError
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.KotlinNewProjectWizardBundle
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.DynamicComponent
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.FocusableComponent
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.PanelWithStatusText
|
||||
@@ -19,7 +18,7 @@ class SettingsList(
|
||||
settings: List<SettingReference<*, *>>,
|
||||
private val ideContext: IdeContext
|
||||
) : DynamicComponent(ideContext), ErrorAwareComponent {
|
||||
private val panel = PanelWithStatusText(VerticalLayout(5), KotlinNewProjectWizardBundle.message("editor.no.configurable.settings"))
|
||||
private val panel = PanelWithStatusText(VerticalLayout(5), "This module has no settings to configure")
|
||||
|
||||
var settingComponents: List<SettingComponent<*, *>> = emptyList()
|
||||
private set
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.components.UIComponent
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.components.valueForSetting
|
||||
|
||||
+3
-1
@@ -2,7 +2,9 @@ package org.jetbrains.kotlin.tools.projectWizard
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.core.YamlParsingError
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
import org.yaml.snakeyaml.parser.ParserException
|
||||
import java.nio.file.Path
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PluginSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.IdeaIndependentWizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.Services
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ import java.nio.file.Path
|
||||
abstract class AbstractYamlBuildFileGenerationTest : AbstractBuildFileGenerationTest() {
|
||||
override fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard {
|
||||
val yaml = readSettingsYaml(directory, buildSystem) ?: error("settings.yaml should exists in $directory")
|
||||
return YamlWizard(yaml, projectDirectory.toString(), Plugins.allPlugins, isUnitTestMode = true)
|
||||
return YamlWizard(yaml, projectDirectory, Plugins.allPlugins, isUnitTestMode = true)
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.compute
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.computeM
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemP
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.applyProjectTemplate
|
||||
import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.YamlWizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.parseYaml
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Parser
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.enumParser
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
|
||||
+4
-1
@@ -1,6 +1,8 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.core
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.AnySetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.isSubclassOf
|
||||
@@ -21,7 +23,8 @@ class Context(private val pluginsCreator: PluginsCreator, val eventManager: Even
|
||||
}
|
||||
}
|
||||
|
||||
val settingContext = SettingContext(eventManager::fireListeners)
|
||||
val settingContext =
|
||||
SettingContext(eventManager::fireListeners)
|
||||
val propertyContext = PropertyContext()
|
||||
val taskContext = TaskContext()
|
||||
val plugins = pluginsCreator(this).onEach(::initPlugin)
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.core
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
|
||||
|
||||
class EventManager {
|
||||
private val listeners = mutableListOf<(SettingReference<*, *>?) -> Unit>()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.core
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.Template
|
||||
import java.nio.file.Paths
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.tools.projectWizard.core
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.SettingsOwner
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.enumSettingImpl
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
@@ -10,7 +11,6 @@ import java.nio.file.Path
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.full.isSubclassOf
|
||||
import kotlin.reflect.full.memberProperties
|
||||
|
||||
@@ -33,7 +33,8 @@ abstract class Plugin(override val context: Context) : EntityBase(),
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val reference = property as PluginSettingPropertyReference<V, T>
|
||||
context.settingContext.getPluginSetting(reference)?.let { return it }
|
||||
val setting = PluginSetting(create(reference.path).buildInternal())
|
||||
val setting =
|
||||
PluginSetting(create(reference.path).buildInternal())
|
||||
context.settingContext.setPluginSetting(reference, setting)
|
||||
return setting
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.tools.projectWizard.core.context
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Context
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Plugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
@@ -52,7 +53,7 @@ open class ReadingContext(
|
||||
|
||||
private fun <V : Any> Setting<V, SettingType<V>>.getSavedValueForSetting(): V? {
|
||||
if (!isSavable || this !is PluginSetting<*, *>) return null
|
||||
val serializer = type.serializer.safeAs<SerializerImpl<V>>() ?: return null
|
||||
val serializer = type.serializer.safeAs<SettingSerializer.Serializer<V>>() ?: return null
|
||||
val savedValue = service<SettingSavingWizardService>().getSettingValue(path) ?: return null
|
||||
return serializer.fromString(savedValue)
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.core.context
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Context
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
|
||||
|
||||
|
||||
-446
@@ -1,446 +0,0 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.core.entity
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.Identificator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.ModuleConfigurator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.Template
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
sealed class SettingReference<out V : Any, out T : SettingType<V>> {
|
||||
abstract val path: String
|
||||
abstract val type: KClass<out T>
|
||||
|
||||
abstract fun ReadingContext.getSetting(): Setting<V, T>
|
||||
|
||||
final override fun toString() = path
|
||||
final override fun equals(other: Any?) = other.safeAs<SettingReference<*, *>>()?.path == path
|
||||
final override fun hashCode() = path.hashCode()
|
||||
}
|
||||
|
||||
data class PluginSettingReference<out V : Any, out T : SettingType<V>>(
|
||||
override val path: String,
|
||||
override val type: KClass<@UnsafeVariance T>
|
||||
) : SettingReference<V, T>() {
|
||||
|
||||
constructor(kProperty: KProperty1<out Plugin, PluginSetting<V, T>>, type: KClass<T>) :
|
||||
this(kProperty.path, type)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
constructor(setting: PluginSetting<V, T>) :
|
||||
this(setting.path, setting.type::class as KClass<T>)
|
||||
|
||||
override fun ReadingContext.getSetting(): Setting<V, T> = pluginSetting
|
||||
}
|
||||
|
||||
inline val <V : Any, reified T : SettingType<V>> PluginSetting<V, T>.reference: PluginSettingReference<V, T>
|
||||
get() = PluginSettingReference(path, T::class)
|
||||
|
||||
sealed class ModuleConfiguratorSettingReference<V : Any, T : SettingType<V>> : SettingReference<V, T>() {
|
||||
abstract val descriptor: ModuleConfigurator
|
||||
abstract val moduleId: Identificator
|
||||
abstract val setting: ModuleConfiguratorSetting<V, T>
|
||||
|
||||
override val path: String
|
||||
get() = "${descriptor.id}/$moduleId/${setting.path}"
|
||||
|
||||
override val type: KClass<out T>
|
||||
get() = setting.type::class
|
||||
|
||||
override fun ReadingContext.getSetting(): Setting<V, T> = setting
|
||||
abstract val module: Module?
|
||||
}
|
||||
|
||||
data class ModuleBasedConfiguratorSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: ModuleConfigurator,
|
||||
override val module: Module,
|
||||
override val setting: ModuleConfiguratorSetting<V, T>
|
||||
) : ModuleConfiguratorSettingReference<V, T>() {
|
||||
override val moduleId: Identificator
|
||||
get() = module.identificator
|
||||
}
|
||||
|
||||
data class IdBasedConfiguratorSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: ModuleConfigurator,
|
||||
override val moduleId: Identificator,
|
||||
override val setting: ModuleConfiguratorSetting<V, T>
|
||||
) : ModuleConfiguratorSettingReference<V, T>() {
|
||||
override val module: Module? = null
|
||||
}
|
||||
|
||||
sealed class TemplateSettingReference<V : Any, T : SettingType<V>> : SettingReference<V, T>() {
|
||||
abstract val descriptor: Template
|
||||
abstract val setting: TemplateSetting<V, T>
|
||||
abstract val sourcesetId: Identificator
|
||||
|
||||
override val path: String
|
||||
get() = "${descriptor.id}/$sourcesetId/${setting.path}"
|
||||
|
||||
override val type: KClass<out T>
|
||||
get() = setting.type::class
|
||||
|
||||
override fun ReadingContext.getSetting(): Setting<V, T> = setting
|
||||
abstract val module: Module?
|
||||
}
|
||||
|
||||
data class ModuleBasedTemplateSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: Template,
|
||||
override val module: Module,
|
||||
override val setting: TemplateSetting<V, T>
|
||||
) : TemplateSettingReference<V, T>() {
|
||||
override val sourcesetId: Identificator
|
||||
get() = module.identificator
|
||||
}
|
||||
|
||||
data class IdBasedTemplateSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: Template,
|
||||
override val sourcesetId: Identificator,
|
||||
override val setting: TemplateSetting<V, T>
|
||||
) : TemplateSettingReference<V, T>() {
|
||||
override val module: Module? = null
|
||||
}
|
||||
|
||||
inline val <V : Any, reified T : SettingType<V>> PluginSettingPropertyReference<V, T>.reference: PluginSettingReference<V, T>
|
||||
get() = PluginSettingReference(this, T::class)
|
||||
|
||||
typealias PluginSettingPropertyReference<V, T> = KProperty1<out Plugin, PluginSetting<V, T>>
|
||||
typealias SettingPropertyReference<V, T> = KProperty1<out Plugin, Setting<V, T>>
|
||||
|
||||
class SettingContext(val onUpdated: (SettingReference<*, *>) -> Unit) {
|
||||
private val values = mutableMapOf<String, Any>()
|
||||
private val pluginSettings = mutableMapOf<String, PluginSetting<*, *>>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
operator fun <V : Any, T : SettingType<V>> get(
|
||||
reference: SettingReference<V, T>
|
||||
): V? = values[reference.path] as? V
|
||||
|
||||
operator fun <V : Any, T : SettingType<V>> set(
|
||||
reference: SettingReference<V, T>,
|
||||
newValue: V
|
||||
) {
|
||||
values[reference.path] = newValue
|
||||
onUpdated(reference)
|
||||
}
|
||||
|
||||
|
||||
val allPluginSettings: Collection<PluginSetting<*, *>>
|
||||
get() = pluginSettings.values
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> getPluginSetting(pluginSettingReference: PluginSettingReference<V, T>) =
|
||||
pluginSettings[pluginSettingReference.path] as PluginSetting<V, T>
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> getPluginSetting(pluginSettingReference: PluginSettingPropertyReference<V, T>) =
|
||||
pluginSettings[pluginSettingReference.path] as? PluginSetting<V, T>
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> setPluginSetting(
|
||||
pluginSettingReference: PluginSettingPropertyReference<V, T>,
|
||||
setting: PluginSetting<V, T>
|
||||
) {
|
||||
pluginSettings[pluginSettingReference.path] = setting
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> pluginSettingValue(setting: PluginSetting<V, T>): V? =
|
||||
values[setting.path] as? V
|
||||
}
|
||||
|
||||
|
||||
typealias AnySetting = Setting<*, *>
|
||||
|
||||
interface Setting<out V : Any, out T : SettingType<V>> : Entity, ActivityCheckerOwner, Validatable<V> {
|
||||
val title: String
|
||||
val defaultValue: SettingDefaultValue<V>?
|
||||
val isRequired: Boolean
|
||||
val isSavable: Boolean
|
||||
var neededAtPhase: GenerationPhase
|
||||
val type: T
|
||||
}
|
||||
|
||||
data class InternalSetting<out V : Any, out T : SettingType<V>>(
|
||||
override val path: String,
|
||||
override val title: String,
|
||||
override val defaultValue: SettingDefaultValue<V>?,
|
||||
override val isAvailable: Checker,
|
||||
override val isRequired: Boolean,
|
||||
override val isSavable: Boolean,
|
||||
override var neededAtPhase: GenerationPhase,
|
||||
override val validator: SettingValidator<@UnsafeVariance V>,
|
||||
override val type: T
|
||||
) : Setting<V, T>, EntityWithValue<V>()
|
||||
|
||||
sealed class SettingImpl<out V : Any, out T : SettingType<V>> : Setting<V, T>
|
||||
|
||||
class PluginSetting<out V : Any, out T : SettingType<V>>(
|
||||
internal: InternalSetting<V, T>
|
||||
) : SettingImpl<V, T>(), Setting<V, T> by internal
|
||||
|
||||
class ModuleConfiguratorSetting<out V : Any, out T : SettingType<V>>(
|
||||
internal: InternalSetting<V, T>
|
||||
) : SettingImpl<V, T>(), Setting<V, T> by internal
|
||||
|
||||
class TemplateSetting<out V : Any, out T : SettingType<V>>(
|
||||
internal: InternalSetting<V, T>
|
||||
) : SettingImpl<V, T>(), Setting<V, T> by internal
|
||||
|
||||
|
||||
sealed class SettingDefaultValue<out V : Any> {
|
||||
data class Value<V : Any>(val value: V) : SettingDefaultValue<V>()
|
||||
data class Dynamic<V : Any>(
|
||||
val getter: ReadingContext.(SettingReference<V, SettingType<V>>) -> V
|
||||
) : SettingDefaultValue<V>()
|
||||
}
|
||||
|
||||
|
||||
abstract class SettingBuilder<V : Any, T : SettingType<V>>(
|
||||
private val path: String,
|
||||
private val title: String,
|
||||
private val neededAtPhase: GenerationPhase
|
||||
) {
|
||||
var isAvailable: ReadingContext.() -> Boolean = { true }
|
||||
open var defaultValue: SettingDefaultValue<V>? = null
|
||||
var isSavable: Boolean = false
|
||||
var isRequired: Boolean? = null
|
||||
|
||||
fun value(value: V) = SettingDefaultValue.Value(value)
|
||||
fun dynamic(getter: ReadingContext.(SettingReference<V, SettingType<V>>) -> V) = SettingDefaultValue.Dynamic(getter)
|
||||
|
||||
protected var validator = SettingValidator<V> { ValidationResult.OK }
|
||||
|
||||
fun validate(validator: SettingValidator<V>) {
|
||||
this.validator = this.validator and validator
|
||||
}
|
||||
|
||||
fun validate(validator: ReadingContext.(V) -> ValidationResult) {
|
||||
this.validator = this.validator and settingValidator(validator)
|
||||
}
|
||||
|
||||
|
||||
abstract val type: T
|
||||
|
||||
fun buildInternal() = InternalSetting(
|
||||
path = path,
|
||||
title = title,
|
||||
defaultValue = defaultValue,
|
||||
isAvailable = isAvailable,
|
||||
isRequired = isRequired ?: (defaultValue == null),
|
||||
isSavable = isSavable,
|
||||
neededAtPhase = neededAtPhase,
|
||||
validator = validator,
|
||||
type = type
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
sealed class SettingSerializer<out V : Any>()
|
||||
|
||||
object NonSerializable : SettingSerializer<Nothing>()
|
||||
|
||||
data class SerializerImpl<V : Any>(
|
||||
val fromString: (String) -> V?,
|
||||
val toString: (V) -> String = Any::toString
|
||||
) : SettingSerializer<V>()
|
||||
|
||||
sealed class SettingType<out V : Any> {
|
||||
abstract fun parse(context: ParsingContext, value: Any, name: String): TaskResult<V>
|
||||
open val serializer: SettingSerializer<V> = NonSerializable
|
||||
}
|
||||
|
||||
object StringSettingType : SettingType<String>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String) =
|
||||
value.parseAs<String>(name)
|
||||
|
||||
override val serializer: SettingSerializer<String> = SerializerImpl(fromString = { it })
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
private val title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<String, StringSettingType>(path, title, neededAtPhase) {
|
||||
fun shouldNotBeBlank() {
|
||||
validate(StringValidators.shouldNotBeBlank(title.capitalize()))
|
||||
}
|
||||
|
||||
override val type = StringSettingType
|
||||
}
|
||||
}
|
||||
|
||||
object BooleanSettingType : SettingType<Boolean>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String) =
|
||||
value.parseAs<Boolean>(name)
|
||||
|
||||
override val serializer: SettingSerializer<Boolean> = SerializerImpl(fromString = { it.toBoolean() })
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<Boolean, BooleanSettingType>(path, title, neededAtPhase) {
|
||||
override val type = BooleanSettingType
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DropDownSettingType<V : DisplayableSettingItem>(
|
||||
val values: List<V>,
|
||||
val filter: DropDownSettingTypeFilter<V>,
|
||||
val parser: Parser<V>
|
||||
) : SettingType<V>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<V> = with(context) {
|
||||
computeM {
|
||||
parser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
override val serializer: SettingSerializer<V> = SerializerImpl(fromString = { value ->
|
||||
ComputeContext.runInComputeContextWithState(ParsingState.EMPTY) {
|
||||
parser.parse(this, value, "")
|
||||
}.asNullable?.first
|
||||
})
|
||||
|
||||
class Builder<V : DisplayableSettingItem>(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase,
|
||||
private val parser: Parser<V>
|
||||
) : SettingBuilder<V, DropDownSettingType<V>>(path, title, neededAtPhase) {
|
||||
var values = emptyList<V>()
|
||||
|
||||
var filter: DropDownSettingTypeFilter<V> = { _, _ -> true }
|
||||
|
||||
override val type
|
||||
get() = DropDownSettingType(values, filter, parser)
|
||||
|
||||
|
||||
init {
|
||||
defaultValue = dynamic { reference ->
|
||||
values.first {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
filter(reference as SettingReference<V, DropDownSettingType<V>>, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typealias DropDownSettingTypeFilter <V> =
|
||||
ReadingContext.(SettingReference<V, DropDownSettingType<V>>, V) -> Boolean
|
||||
|
||||
|
||||
class ValueSettingType<V : Any>(
|
||||
private val parser: Parser<V>
|
||||
) : SettingType<V>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<V> = with(context) {
|
||||
computeM {
|
||||
parser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
class Builder<V : Any>(
|
||||
private val path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase,
|
||||
private val parser: Parser<V>
|
||||
) : SettingBuilder<V, ValueSettingType<V>>(path, title, neededAtPhase) {
|
||||
init {
|
||||
validate { value ->
|
||||
if (value is Validatable<*>) (value.validator as SettingValidator<Any>).validate(this, value)
|
||||
else ValidationResult.OK
|
||||
}
|
||||
}
|
||||
|
||||
override val type
|
||||
get() = ValueSettingType(parser)
|
||||
}
|
||||
}
|
||||
|
||||
object VersionSettingType : SettingType<Version>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<Version> = with(context) {
|
||||
computeM {
|
||||
Version.parser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<Version, VersionSettingType>(path, title, neededAtPhase) {
|
||||
override val type
|
||||
get() = VersionSettingType
|
||||
}
|
||||
}
|
||||
|
||||
class ListSettingType<V : Any>(private val parser: Parser<V>) : SettingType<List<V>>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<List<V>> = with(context) {
|
||||
computeM {
|
||||
val (list) = value.parseAs<List<*>>(name)
|
||||
list.mapComputeM { parser.parse(this, it, name) }.sequence()
|
||||
}
|
||||
}
|
||||
|
||||
class Builder<V : Any>(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase,
|
||||
parser: Parser<V>
|
||||
) : SettingBuilder<List<V>, ListSettingType<V>>(path, title, neededAtPhase) {
|
||||
init {
|
||||
validate { values ->
|
||||
values.fold(ValidationResult.OK as ValidationResult) { result, value ->
|
||||
result and when (value) {
|
||||
is Validatable<*> -> (value.validator as SettingValidator<Any>).validate(this, value).withTargetIfNull(value)
|
||||
else -> ValidationResult.OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val type = ListSettingType(parser)
|
||||
}
|
||||
}
|
||||
|
||||
object PathSettingType : SettingType<Path>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<Path> = with(context) {
|
||||
computeM {
|
||||
pathParser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
override val serializer: SettingSerializer<Path> = SerializerImpl(fromString = { Paths.get(it) })
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
private val title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<Path, PathSettingType>(path, title, neededAtPhase) {
|
||||
|
||||
init {
|
||||
validate { pathValue ->
|
||||
if (pathValue.toString().isBlank())
|
||||
ValidationResult.ValidationError("${title.capitalize()} should not be blank")
|
||||
else ValidationResult.OK
|
||||
}
|
||||
}
|
||||
|
||||
fun shouldExists() = validate { pathValue ->
|
||||
if (isUnitTestMode) return@validate ValidationResult.OK
|
||||
if (!Files.exists(pathValue))
|
||||
ValidationResult.ValidationError("File for ${title.capitalize()} should exists")
|
||||
else ValidationResult.OK
|
||||
}
|
||||
|
||||
override val type = PathSettingType
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.tools.projectWizard.core.entity.settings
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ActivityCheckerOwner
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Checker
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.Entity
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.EntityWithValue
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingValidator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.Validatable
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
|
||||
|
||||
typealias AnySetting = Setting<*, *>
|
||||
|
||||
interface Setting<out V : Any, out T : SettingType<V>> : Entity, ActivityCheckerOwner, Validatable<V> {
|
||||
val title: String
|
||||
val defaultValue: SettingDefaultValue<V>?
|
||||
val isRequired: Boolean
|
||||
val isSavable: Boolean
|
||||
var neededAtPhase: GenerationPhase
|
||||
val type: T
|
||||
}
|
||||
|
||||
data class InternalSetting<out V : Any, out T : SettingType<V>>(
|
||||
override val path: String,
|
||||
override val title: String,
|
||||
override val defaultValue: SettingDefaultValue<V>?,
|
||||
override val isAvailable: Checker,
|
||||
override val isRequired: Boolean,
|
||||
override val isSavable: Boolean,
|
||||
override var neededAtPhase: GenerationPhase,
|
||||
override val validator: SettingValidator<@UnsafeVariance V>,
|
||||
override val type: T
|
||||
) : Setting<V, T>, EntityWithValue<V>()
|
||||
|
||||
sealed class SettingImpl<out V : Any, out T : SettingType<V>> :
|
||||
Setting<V, T>
|
||||
|
||||
class PluginSetting<out V : Any, out T : SettingType<V>>(
|
||||
internal: InternalSetting<V, T>
|
||||
) : SettingImpl<V, T>(), Setting<V, T> by internal
|
||||
|
||||
class ModuleConfiguratorSetting<out V : Any, out T : SettingType<V>>(
|
||||
internal: InternalSetting<V, T>
|
||||
) : SettingImpl<V, T>(), Setting<V, T> by internal
|
||||
|
||||
class TemplateSetting<out V : Any, out T : SettingType<V>>(
|
||||
internal: InternalSetting<V, T>
|
||||
) : SettingImpl<V, T>(), Setting<V, T> by internal
|
||||
|
||||
|
||||
sealed class SettingDefaultValue<out V : Any> {
|
||||
data class Value<V : Any>(val value: V) : SettingDefaultValue<V>()
|
||||
data class Dynamic<V : Any>(
|
||||
val getter: ReadingContext.(SettingReference<V, SettingType<V>>) -> V
|
||||
) : SettingDefaultValue<V>()
|
||||
}
|
||||
|
||||
|
||||
sealed class SettingSerializer<out V : Any> {
|
||||
object None : SettingSerializer<Nothing>()
|
||||
data class Serializer<V : Any>(
|
||||
val fromString: (String) -> V?,
|
||||
val toString: (V) -> String = Any::toString
|
||||
) : SettingSerializer<V>()
|
||||
}
|
||||
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.tools.projectWizard.core.entity.settings
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingValidator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settingValidator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
|
||||
abstract class SettingBuilder<V : Any, T : SettingType<V>>(
|
||||
private val path: String,
|
||||
private val title: String,
|
||||
private val neededAtPhase: GenerationPhase
|
||||
) {
|
||||
var isAvailable: ReadingContext.() -> Boolean = { true }
|
||||
open var defaultValue: SettingDefaultValue<V>? = null
|
||||
var isSavable: Boolean = false
|
||||
var isRequired: Boolean? = null
|
||||
|
||||
fun value(value: V) = SettingDefaultValue.Value(value)
|
||||
fun dynamic(getter: ReadingContext.(SettingReference<V, SettingType<V>>) -> V) =
|
||||
SettingDefaultValue.Dynamic(getter)
|
||||
|
||||
protected var validator =
|
||||
SettingValidator<V> { ValidationResult.OK }
|
||||
|
||||
fun validate(validator: SettingValidator<V>) {
|
||||
this.validator = this.validator and validator
|
||||
}
|
||||
|
||||
fun validate(validator: ReadingContext.(V) -> ValidationResult) {
|
||||
this.validator = this.validator and settingValidator(
|
||||
validator
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
abstract val type: T
|
||||
|
||||
fun buildInternal() = InternalSetting(
|
||||
path = path,
|
||||
title = title,
|
||||
defaultValue = defaultValue,
|
||||
isAvailable = isAvailable,
|
||||
isRequired = isRequired ?: (defaultValue == null),
|
||||
isSavable = isSavable,
|
||||
neededAtPhase = neededAtPhase,
|
||||
validator = validator,
|
||||
type = type
|
||||
)
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.tools.projectWizard.core.entity.settings
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.path
|
||||
|
||||
class SettingContext(val onUpdated: (SettingReference<*, *>) -> Unit) {
|
||||
private val values = mutableMapOf<String, Any>()
|
||||
private val pluginSettings = mutableMapOf<String, PluginSetting<*, *>>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
operator fun <V : Any, T : SettingType<V>> get(
|
||||
reference: SettingReference<V, T>
|
||||
): V? = values[reference.path] as? V
|
||||
|
||||
operator fun <V : Any, T : SettingType<V>> set(
|
||||
reference: SettingReference<V, T>,
|
||||
newValue: V
|
||||
) {
|
||||
values[reference.path] = newValue
|
||||
onUpdated(reference)
|
||||
}
|
||||
|
||||
|
||||
val allPluginSettings: Collection<PluginSetting<*, *>>
|
||||
get() = pluginSettings.values
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> getPluginSetting(pluginSettingReference: PluginSettingReference<V, T>) =
|
||||
pluginSettings[pluginSettingReference.path] as PluginSetting<V, T>
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> getPluginSetting(pluginSettingReference: PluginSettingPropertyReference<V, T>) =
|
||||
pluginSettings[pluginSettingReference.path] as? PluginSetting<V, T>
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> setPluginSetting(
|
||||
pluginSettingReference: PluginSettingPropertyReference<V, T>,
|
||||
setting: PluginSetting<V, T>
|
||||
) {
|
||||
pluginSettings[pluginSettingReference.path] = setting
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <V : Any, T : SettingType<V>> pluginSettingValue(setting: PluginSetting<V, T>): V? =
|
||||
values[setting.path] as? V
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.tools.projectWizard.core.entity.settings
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.Identificator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Plugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.ModuleConfigurator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.Template
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
|
||||
sealed class SettingReference<out V : Any, out T : SettingType<V>> {
|
||||
abstract val path: String
|
||||
abstract val type: KClass<out T>
|
||||
|
||||
abstract fun ReadingContext.getSetting(): Setting<V, T>
|
||||
|
||||
final override fun toString() = path
|
||||
final override fun equals(other: Any?) = other.safeAs<SettingReference<*, *>>()?.path == path
|
||||
final override fun hashCode() = path.hashCode()
|
||||
}
|
||||
|
||||
data class PluginSettingReference<out V : Any, out T : SettingType<V>>(
|
||||
override val path: String,
|
||||
override val type: KClass<@UnsafeVariance T>
|
||||
) : SettingReference<V, T>() {
|
||||
|
||||
constructor(kProperty: KProperty1<out Plugin, PluginSetting<V, T>>, type: KClass<T>) :
|
||||
this(kProperty.path, type)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
constructor(setting: PluginSetting<V, T>) :
|
||||
this(setting.path, setting.type::class as KClass<T>)
|
||||
|
||||
override fun ReadingContext.getSetting(): Setting<V, T> = pluginSetting
|
||||
}
|
||||
|
||||
inline val <V : Any, reified T : SettingType<V>> PluginSetting<V, T>.reference: PluginSettingReference<V, T>
|
||||
get() = PluginSettingReference(path, T::class)
|
||||
|
||||
sealed class ModuleConfiguratorSettingReference<V : Any, T : SettingType<V>> : SettingReference<V, T>() {
|
||||
abstract val descriptor: ModuleConfigurator
|
||||
abstract val moduleId: Identificator
|
||||
abstract val setting: ModuleConfiguratorSetting<V, T>
|
||||
|
||||
override val path: String
|
||||
get() = "${descriptor.id}/$moduleId/${setting.path}"
|
||||
|
||||
override val type: KClass<out T>
|
||||
get() = setting.type::class
|
||||
|
||||
override fun ReadingContext.getSetting(): Setting<V, T> = setting
|
||||
abstract val module: Module?
|
||||
}
|
||||
|
||||
data class ModuleBasedConfiguratorSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: ModuleConfigurator,
|
||||
override val module: Module,
|
||||
override val setting: ModuleConfiguratorSetting<V, T>
|
||||
) : ModuleConfiguratorSettingReference<V, T>() {
|
||||
override val moduleId: Identificator
|
||||
get() = module.identificator
|
||||
}
|
||||
|
||||
data class IdBasedConfiguratorSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: ModuleConfigurator,
|
||||
override val moduleId: Identificator,
|
||||
override val setting: ModuleConfiguratorSetting<V, T>
|
||||
) : ModuleConfiguratorSettingReference<V, T>() {
|
||||
override val module: Module? = null
|
||||
}
|
||||
|
||||
sealed class TemplateSettingReference<V : Any, T : SettingType<V>> : SettingReference<V, T>() {
|
||||
abstract val descriptor: Template
|
||||
abstract val setting: TemplateSetting<V, T>
|
||||
abstract val sourcesetId: Identificator
|
||||
|
||||
override val path: String
|
||||
get() = "${descriptor.id}/$sourcesetId/${setting.path}"
|
||||
|
||||
override val type: KClass<out T>
|
||||
get() = setting.type::class
|
||||
|
||||
override fun ReadingContext.getSetting(): Setting<V, T> = setting
|
||||
abstract val module: Module?
|
||||
}
|
||||
|
||||
data class ModuleBasedTemplateSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: Template,
|
||||
override val module: Module,
|
||||
override val setting: TemplateSetting<V, T>
|
||||
) : TemplateSettingReference<V, T>() {
|
||||
override val sourcesetId: Identificator
|
||||
get() = module.identificator
|
||||
}
|
||||
|
||||
data class IdBasedTemplateSettingReference<V : Any, T : SettingType<V>>(
|
||||
override val descriptor: Template,
|
||||
override val sourcesetId: Identificator,
|
||||
override val setting: TemplateSetting<V, T>
|
||||
) : TemplateSettingReference<V, T>() {
|
||||
override val module: Module? = null
|
||||
}
|
||||
|
||||
inline val <V : Any, reified T : SettingType<V>> PluginSettingPropertyReference<V, T>.reference: PluginSettingReference<V, T>
|
||||
get() = PluginSettingReference(this, T::class)
|
||||
|
||||
typealias PluginSettingPropertyReference<V, T> = KProperty1<out Plugin, PluginSetting<V, T>>
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.tools.projectWizard.core.entity.settings
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
sealed class SettingType<out V : Any> {
|
||||
abstract fun parse(context: ParsingContext, value: Any, name: String): TaskResult<V>
|
||||
open val serializer: SettingSerializer<V> = SettingSerializer.None
|
||||
}
|
||||
|
||||
object StringSettingType : SettingType<String>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String) =
|
||||
value.parseAs<String>(name)
|
||||
|
||||
override val serializer: SettingSerializer<String> =
|
||||
SettingSerializer.Serializer(fromString = { it })
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
private val title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<String, StringSettingType>(path, title, neededAtPhase) {
|
||||
fun shouldNotBeBlank() {
|
||||
validate(StringValidators.shouldNotBeBlank(title.capitalize()))
|
||||
}
|
||||
|
||||
override val type = StringSettingType
|
||||
}
|
||||
}
|
||||
|
||||
object BooleanSettingType : SettingType<Boolean>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String) =
|
||||
value.parseAs<Boolean>(name)
|
||||
|
||||
override val serializer: SettingSerializer<Boolean> =
|
||||
SettingSerializer.Serializer(fromString = { it.toBoolean() })
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<Boolean, BooleanSettingType>(path, title, neededAtPhase) {
|
||||
override val type = BooleanSettingType
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DropDownSettingType<V : DisplayableSettingItem>(
|
||||
val values: List<V>,
|
||||
val filter: DropDownSettingTypeFilter<V>,
|
||||
val parser: Parser<V>
|
||||
) : SettingType<V>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<V> = with(context) {
|
||||
computeM {
|
||||
parser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
override val serializer: SettingSerializer<V> =
|
||||
SettingSerializer.Serializer(fromString = { value ->
|
||||
ComputeContext.runInComputeContextWithState(
|
||||
ParsingState.EMPTY
|
||||
) {
|
||||
parser.parse(this, value, "")
|
||||
}.asNullable?.first
|
||||
})
|
||||
|
||||
class Builder<V : DisplayableSettingItem>(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase,
|
||||
private val parser: Parser<V>
|
||||
) : SettingBuilder<V, DropDownSettingType<V>>(path, title, neededAtPhase) {
|
||||
var values = emptyList<V>()
|
||||
|
||||
var filter: DropDownSettingTypeFilter<V> = { _, _ -> true }
|
||||
|
||||
override val type
|
||||
get() = DropDownSettingType(
|
||||
values,
|
||||
filter,
|
||||
parser
|
||||
)
|
||||
|
||||
|
||||
init {
|
||||
defaultValue = dynamic { reference ->
|
||||
values.first {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
filter(reference as SettingReference<V, DropDownSettingType<V>>, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ValueSettingType<V : Any>(
|
||||
private val parser: Parser<V>
|
||||
) : SettingType<V>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<V> = with(context) {
|
||||
computeM {
|
||||
parser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
class Builder<V : Any>(
|
||||
private val path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase,
|
||||
private val parser: Parser<V>
|
||||
) : SettingBuilder<V, ValueSettingType<V>>(path, title, neededAtPhase) {
|
||||
init {
|
||||
validate { value ->
|
||||
if (value is Validatable<*>) (value.validator as SettingValidator<Any>).validate(this, value)
|
||||
else ValidationResult.OK
|
||||
}
|
||||
}
|
||||
|
||||
override val type
|
||||
get() = ValueSettingType(parser)
|
||||
}
|
||||
}
|
||||
|
||||
object VersionSettingType : SettingType<Version>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<Version> = with(context) {
|
||||
computeM {
|
||||
Version.parser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<Version, VersionSettingType>(path, title, neededAtPhase) {
|
||||
override val type
|
||||
get() = VersionSettingType
|
||||
}
|
||||
}
|
||||
|
||||
class ListSettingType<V : Any>(private val parser: Parser<V>) : SettingType<List<V>>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<List<V>> = with(context) {
|
||||
computeM {
|
||||
val (list) = value.parseAs<List<*>>(name)
|
||||
list.mapComputeM { parser.parse(this, it, name) }.sequence()
|
||||
}
|
||||
}
|
||||
|
||||
class Builder<V : Any>(
|
||||
path: String,
|
||||
title: String,
|
||||
neededAtPhase: GenerationPhase,
|
||||
parser: Parser<V>
|
||||
) : SettingBuilder<List<V>, ListSettingType<V>>(path, title, neededAtPhase) {
|
||||
init {
|
||||
validate { values ->
|
||||
values.fold(ValidationResult.OK as ValidationResult) { result, value ->
|
||||
result and when (value) {
|
||||
is Validatable<*> -> (value.validator as SettingValidator<Any>).validate(this, value).withTargetIfNull(value)
|
||||
else -> ValidationResult.OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val type = ListSettingType(parser)
|
||||
}
|
||||
}
|
||||
|
||||
object PathSettingType : SettingType<Path>() {
|
||||
override fun parse(context: ParsingContext, value: Any, name: String): TaskResult<Path> = with(context) {
|
||||
computeM {
|
||||
pathParser.parse(this, value, name)
|
||||
}
|
||||
}
|
||||
|
||||
override val serializer: SettingSerializer<Path> =
|
||||
SettingSerializer.Serializer(fromString = { Paths.get(it) })
|
||||
|
||||
class Builder(
|
||||
path: String,
|
||||
private val title: String,
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<Path, PathSettingType>(path, title, neededAtPhase) {
|
||||
|
||||
init {
|
||||
validate { pathValue ->
|
||||
if (pathValue.toString().isBlank())
|
||||
ValidationResult.ValidationError("${title.capitalize()} should not be blank")
|
||||
else ValidationResult.OK
|
||||
}
|
||||
}
|
||||
|
||||
fun shouldExists() = validate { pathValue ->
|
||||
if (isUnitTestMode) return@validate ValidationResult.OK
|
||||
if (!Files.exists(pathValue))
|
||||
ValidationResult.ValidationError("File for ${title.capitalize()} should exists")
|
||||
else ValidationResult.OK
|
||||
}
|
||||
|
||||
override val type = PathSettingType
|
||||
}
|
||||
}
|
||||
|
||||
typealias DropDownSettingTypeFilter <V> = ReadingContext.(SettingReference<V, DropDownSettingType<V>>, V) -> Boolean
|
||||
+4
-4
@@ -9,16 +9,16 @@ import org.jetbrains.kotlin.tools.projectWizard.Versions
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PluginSettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.AndroidConfigIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.AndroidPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModuleConfigurationData
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModuleType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.javaPackage
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.kotlinVersionKind
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.library.MavenArtifact
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.cached
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.enumSettingImpl
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.KotlinBuildSystemPluginIR
|
||||
|
||||
+2
-1
@@ -6,7 +6,8 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.DependencyType
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.KotlinBuildSystemPluginIR
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.StringValidators
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.FileSystemWizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.PomIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.BuildSystemAvailabilityWizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.FileSystemWizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ProjectImportingWizardService
|
||||
@@ -113,7 +113,7 @@ data class BuildFileData(
|
||||
enum class BuildSystemType(override val text: String) : DisplayableSettingItem {
|
||||
GradleKotlinDsl("Gradle (Kotlin DSL)"),
|
||||
GradleGroovyDsl("Gradle (Groovy DSL)"),
|
||||
Jps("IDEA Build System"),
|
||||
Jps("IDEA Build System"),
|
||||
Maven("Maven")
|
||||
|
||||
;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.FileSystemWizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.PluginManagementRepositoryIR
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package org.jetbrains.kotlin.tools.projectWizard.projectTemplates
|
||||
import TemplateTag
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.buildList
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||
|
||||
+4
-1
@@ -3,10 +3,13 @@ package org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.GeneratedIdentificator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.Identificator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.IdentificatorOwner
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.Template
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.tools.projectWizard.templates
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.asPath
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.buildList
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.TemplateSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.TemplateSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.multiplatform.TargetConfigurationIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.multiplatform.addWithJavaIntoJvmTarget
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.tools.projectWizard.WizardRunConfiguration
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.TemplateSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.TemplateSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.*
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.enumSettingImpl
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.DependencyIR
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.context.WritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.SettingSavingWizardService
|
||||
@@ -59,7 +60,7 @@ abstract class Wizard(createPlugins: PluginsCreator, val servicesManager: Servic
|
||||
if (setting.neededAtPhase !in phases) continue
|
||||
if (!setting.isSavable) continue
|
||||
if (!setting.isAvailable(valuesReadingContext)) continue
|
||||
val serializer = setting.type.serializer as? SerializerImpl<Any> ?: continue
|
||||
val serializer = setting.type.serializer as? SettingSerializer.Serializer<Any> ?: continue
|
||||
service<SettingSavingWizardService>().saveSettingValue(
|
||||
setting.path,
|
||||
serializer.toString(setting.reference.settingValue)
|
||||
|
||||
Reference in New Issue
Block a user