User: rednesto Date: 16 Jul 24 12:31 Revision: da8086f5e32f197e4542a2f6676dd5a221769898 Summary: Merge branch 'refs/heads/2023.2' into 2023.3 TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9477&personal=false Index: src/main/kotlin/creator/custom/CustomPlatformStep.kt =================================================================== --- src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision 613bb4d5650646c6217083a085632ad7e2018ee0) +++ src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision da8086f5e32f197e4542a2f6676dd5a221769898) @@ -32,6 +32,7 @@ import com.demonwav.mcdev.creator.modalityState import com.demonwav.mcdev.util.toTypedArray import com.demonwav.mcdev.util.virtualFileOrError +import com.intellij.codeInsight.CodeInsightSettings import com.intellij.codeInsight.actions.ReformatCodeProcessor import com.intellij.ide.projectView.ProjectView import com.intellij.ide.wizard.AbstractNewProjectWizardStep @@ -125,6 +126,7 @@ private var hasTemplateErrors: Boolean = true private var properties = mutableMapOf>() + private var creatorContext = CreatorContext(propertyGraph, properties, context) init { Disposer.register(context.disposable) { @@ -288,6 +290,7 @@ private fun createOptionsPanelInBackground(template: LoadedTemplate, placeholder: Placeholder) { properties = mutableMapOf() + creatorContext = creatorContext.copy(properties = properties) if (!template.isValid) { return @@ -297,8 +300,7 @@ ?: return thisLogger().error("Could not find wizard base data") properties["PROJECT_NAME"] = ExternalCreatorProperty( - graph = propertyGraph, - properties = properties, + context = creatorContext, graphProperty = baseData.nameProperty, valueType = String::class.java ) @@ -398,7 +400,7 @@ reporter.fatal("Duplicate property name ${descriptor.name}") } - val prop = CreatorPropertyFactory.createFromType(descriptor.type, descriptor, propertyGraph, properties) + val prop = CreatorPropertyFactory.createFromType(descriptor.type, descriptor, creatorContext) if (prop == null) { reporter.fatal("Unknown template property type ${descriptor.type}") } @@ -411,7 +413,7 @@ return null } - val factory = Consumer { panel -> prop.buildUi(panel, context) } + val factory = Consumer { panel -> prop.buildUi(panel) } val order = descriptor.order ?: 0 return factory to order } @@ -531,8 +533,19 @@ val psiFiles = files.asSequence() .filter { (desc, _) -> desc.reformat != false } .mapNotNull { (_, file) -> psiManager.findFile(file) } - ReformatCodeProcessor(project, psiFiles.toTypedArray(), null, false).run() + + val processor = ReformatCodeProcessor(project, psiFiles.toTypedArray(), null, false) + psiFiles.forEach(processor::setDoNotKeepLineBreaks) + + val insightSettings = CodeInsightSettings.getInstance() + val oldSecondReformat = insightSettings.ENABLE_SECOND_REFORMAT + insightSettings.ENABLE_SECOND_REFORMAT = true + try { + processor.run() + } finally { + insightSettings.ENABLE_SECOND_REFORMAT = oldSecondReformat - } + } + } private fun openFilesInEditor( project: Project, Index: src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt (revision 613bb4d5650646c6217083a085632ad7e2018ee0) +++ src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt (revision da8086f5e32f197e4542a2f6676dd5a221769898) @@ -22,10 +22,9 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.ComboboxSpeedSearch import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindItem @@ -35,10 +34,9 @@ abstract class SimpleCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map>, + context: CreatorContext, valueType: Class -) : CreatorProperty(descriptor, graph, properties, valueType) { +) : CreatorProperty(descriptor, context, valueType) { private val options: Map? = makeOptionsList() @@ -80,7 +78,7 @@ override val graphProperty: GraphProperty by lazy { graph.property(defaultValue) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { if (isDropdown) { if (graphProperty.get() !in options!!.keys) { graphProperty.set(defaultValue) @@ -112,11 +110,11 @@ } }.propertyVisibility() } else { - buildSimpleUi(panel, context) + buildSimpleUi(panel) } } - abstract fun buildSimpleUi(panel: Panel, context: WizardContext) + abstract fun buildSimpleUi(panel: Panel) private inner class DropdownAutoRenderer : DefaultListCellRenderer() {