diff --git a/build.gradle.kts b/build.gradle.kts index 8ebf7b29b..7dbff4133 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,8 @@ +import io.gitlab.arturbosch.detekt.Detekt import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent import org.jetbrains.changelog.Changelog +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.net.URL import java.time.Year @@ -10,18 +12,18 @@ fun properties(key: String) = project.findProperty(key).toString() /// Plugins plugins { // Compilation - id("org.jetbrains.kotlin.jvm") version "1.8.22" // See also `gradle.properties` - id("org.jetbrains.intellij") version "1.14.2" + id("org.jetbrains.kotlin.jvm") version "1.9.10" // Use latest version, ignoring `gradle.properties` + id("org.jetbrains.intellij") version "1.15.0" // Tests/coverage - id("org.jetbrains.kotlinx.kover") version "0.7.2" + id("org.jetbrains.kotlinx.kover") version "0.7.3" // Static analysis - id("io.gitlab.arturbosch.detekt") version "1.23.0" // See also `gradle.properties` + id("io.gitlab.arturbosch.detekt") version "1.23.1" // See also `gradle.properties` // Documentation - id("org.jetbrains.changelog") version "2.1.0" - id("org.jetbrains.dokka") version "1.8.20" + id("org.jetbrains.changelog") version "2.2.0" + id("org.jetbrains.dokka") version "1.9.0" } @@ -57,14 +59,14 @@ tasks { sourceCompatibility = properties("javaVersion") targetCompatibility = properties("javaVersion") } - withType { + withType { kotlinOptions { jvmTarget = properties("javaVersion") apiVersion = properties("kotlinApiVersion") languageVersion = properties("kotlinVersion") } } - withType { + withType { jvmTarget = properties("javaVersion") } @@ -136,7 +138,7 @@ tasks { // Documentation dokkaHtml.configure { - notCompatibleWithConfigurationCache("Not sure why") + notCompatibleWithConfigurationCache("cf. https://github.com/Kotlin/dokka/issues/1217") pluginsMapConfiguration.set( mapOf( diff --git a/gradle.properties b/gradle.properties index 7b457e0ab..1ad74a934 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,40 +3,43 @@ group=com.fwdekker version=3.0.0-beta.3 # Compatibility -# * If latest is 20xx.y, then support at least [20xx-1].[y+1] -# e.g., if latest is 2020.3, support at least 2019.4 (aka 2020.1). -# See also https://data.services.jetbrains.com/products?fields=name,releases.version,releases.build&code=IC,CL. -# * For `intellijVersion`, use the oldest supported version, because that's what the plugin will be compiled against. -pluginSinceBuild=222.0 -intellijVersion=2022.2 -pluginVerifierIdeVersions=IC-2022.2.5, IC-2022.3.3, IC-2023.1.3, CL-2022.2.5, CL-2022.3.3, CL-2023.1.4 +# * `pluginSinceBuild`: +# If latest is 20xx.y, then support at least [20xx-1].[y+1]. For example, if latest is 2020.3, support at least +# 2019.4 (aka 2020.1). +# * `intellijVersion`: +# Use the oldest supported version, because that's what the plugin will be compiled against. +# * `pluginVerifierIdeVersions`: +# For every supported version minor release, include both the IC and the CL release with the highest patch version +# See also https://data.services.jetbrains.com/products?fields=name,releases.version,releases.build&code=IC,CL. +pluginSinceBuild=223.0 +intellijVersion=2022.3 +pluginVerifierIdeVersions=IC-2022.3.3, IC-2023.1.5, IC-2023.2.2, CL-2022.3.3, CL-2023.1.5, CL-2023.2.2 # Targets -# * Java -# * Java version should be the one used by the oldest Randomness-supported version of IntelliJ, as listed in -# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions +# * Java: +# Java version should be the one used by the oldest Randomness-supported version of IntelliJ. See also +# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions. # # * Kotlin # * `kotlinVersion` is the same as `kotlinApiVersion`. -# * Kotlin should also be updated in `plugins` block. -# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version listed in -# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library +# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version. See also +# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library. javaVersion=17 -kotlinVersion=1.6 -kotlinApiVersion=1.6 +kotlinVersion=1.7 +kotlinApiVersion=1.7 # Dependencies # * Detekt should also be updated in `plugins` block. # * RgxGen should also be updated in `StringSchemeEditor` link. assertjSwingVersion=3.17.1 dateparserVersion=1.0.11 -detektVersion=1.23.0 +detektVersion=1.23.1 emojiVersion=5.1.1 -junitVersion=5.9.3 -junitRunnerVersion=1.9.3 -kotestVersion=5.6.2 +junitVersion=5.10.0 +junitRunnerVersion=1.10.0 +kotestVersion=5.7.2 rgxgenVersion=1.4 -uuidGeneratorVersion=3.3.0 +uuidGeneratorVersion=4.3.0 # Gradle org.gradle.caching=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index dba0b0839..7bb2df6ba 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt b/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt index 4b75ae9c6..37663ff6e 100644 --- a/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt +++ b/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt @@ -106,7 +106,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) { * @param event carries contextual information */ override fun getChildren(event: AnActionEvent?) = - PersistentSettings.default.state.templates.map { TemplateGroupAction(it) }.toTypedArray() + + Settings.DEFAULT.templates.map { TemplateGroupAction(it) }.toTypedArray() + Separator() + TemplateSettingsAction() } @@ -121,7 +121,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) { * @param event carries contextual information */ override fun getChildren(event: AnActionEvent?) = - PersistentSettings.default.state.templates.map { TemplateSettingsAction(it) }.toTypedArray() + + Settings.DEFAULT.templates.map { TemplateSettingsAction(it) }.toTypedArray() + Separator() + TemplateSettingsAction() } diff --git a/src/main/kotlin/com/fwdekker/randomness/State.kt b/src/main/kotlin/com/fwdekker/randomness/State.kt index a3fdac798..81b4f6ea5 100644 --- a/src/main/kotlin/com/fwdekker/randomness/State.kt +++ b/src/main/kotlin/com/fwdekker/randomness/State.kt @@ -25,7 +25,7 @@ abstract class State { * @see applyContext */ @get:Transient - var context: Box = Box({ PersistentSettings.default.state }) + var context: Box = Box({ Settings.DEFAULT }) protected set diff --git a/src/main/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditor.kt b/src/main/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditor.kt index deb254ab4..dbff9880c 100644 --- a/src/main/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditor.kt +++ b/src/main/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditor.kt @@ -7,11 +7,12 @@ import com.fwdekker.randomness.array.ArrayDecorator.Companion.MIN_MIN_COUNT import com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_AFFIX_DECORATOR_DESCRIPTORS import com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_SEPARATORS import com.fwdekker.randomness.ui.JIntSpinner +import com.fwdekker.randomness.ui.LiteralPredicate import com.fwdekker.randomness.ui.UIConstants import com.fwdekker.randomness.ui.bindCurrentText import com.fwdekker.randomness.ui.bindIntValue import com.fwdekker.randomness.ui.bindSpinners -import com.fwdekker.randomness.ui.indentedRowRange +import com.fwdekker.randomness.ui.decoratedRowRange import com.fwdekker.randomness.ui.isEditable import com.fwdekker.randomness.ui.loadMnemonic import com.fwdekker.randomness.ui.withFixedWidth @@ -19,11 +20,12 @@ import com.fwdekker.randomness.ui.withName import com.intellij.openapi.ui.ComboBox import com.intellij.ui.dsl.builder.BottomGap import com.intellij.ui.dsl.builder.Cell -import com.intellij.ui.dsl.builder.TopGap import com.intellij.ui.dsl.builder.bindSelected import com.intellij.ui.dsl.builder.panel import com.intellij.ui.dsl.builder.selected +import com.intellij.ui.layout.ComponentPredicate import com.intellij.ui.layout.and +import com.intellij.ui.layout.or import com.intellij.ui.layout.selected import javax.swing.JCheckBox @@ -32,20 +34,18 @@ import javax.swing.JCheckBox * Component for editing an [ArrayDecorator]. * * @param scheme the scheme to edit - * @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top, and - * the user cannot disable the array decorator; [apply] always enables the array decorator. + * @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top, + * components are additionally indented, and the user cannot disable the array decorator; does not affect the value of + * [ArrayDecorator.enabled] */ class ArrayDecoratorEditor( scheme: ArrayDecorator, private val embedded: Boolean = false, ) : SchemeEditor(scheme) { override val rootComponent = panel { - separator(Bundle("array.title")) - .topGap(TopGap.MEDIUM) - .visible(!embedded) - - indentedRowRange(indented = !embedded) { + decoratedRowRange(title = if (!embedded) Bundle("array.title") else null, indent = !embedded) { lateinit var enabledCheckBox: Cell + lateinit var isEnabled: ComponentPredicate row { checkBox(Bundle("array.ui.enabled")) @@ -53,9 +53,10 @@ class ArrayDecoratorEditor( .withName("arrayEnabled") .bindSelected(scheme::enabled) .also { enabledCheckBox = it } + .also { isEnabled = enabledCheckBox.selected.or(LiteralPredicate(embedded)) } }.visible(!embedded) - indentedRowRange(indented = !embedded) { + decoratedRowRange(indent = !embedded) { lateinit var minCountSpinner: JIntSpinner lateinit var maxCountSpinner: JIntSpinner @@ -86,7 +87,7 @@ class ArrayDecoratorEditor( .also { separatorEnabledCheckBox = it.component } cell(ComboBox(PRESET_SEPARATORS)) - .enabledIf(enabledCheckBox.selected.and(separatorEnabledCheckBox.selected)) + .enabledIf(isEnabled.and(separatorEnabledCheckBox.selected)) .isEditable(true) .withName("arraySeparator") .bindCurrentText(scheme::separator) @@ -96,14 +97,14 @@ class ArrayDecoratorEditor( AffixDecoratorEditor( scheme.affixDecorator, PRESET_AFFIX_DECORATOR_DESCRIPTORS, - enabledIf = enabledCheckBox.selected, + enabledIf = isEnabled, enableMnemonic = false, namePrefix = "array", ) .also { decoratorEditors += it } .let { cell(it.rootComponent) } } - }.enabledIf(enabledCheckBox.selected) + }.enabledIf(isEnabled) } } diff --git a/src/main/kotlin/com/fwdekker/randomness/string/StringSchemeEditor.kt b/src/main/kotlin/com/fwdekker/randomness/string/StringSchemeEditor.kt index d9e36554e..f5ac2146d 100644 --- a/src/main/kotlin/com/fwdekker/randomness/string/StringSchemeEditor.kt +++ b/src/main/kotlin/com/fwdekker/randomness/string/StringSchemeEditor.kt @@ -12,7 +12,6 @@ import com.fwdekker.randomness.ui.withName import com.fwdekker.randomness.ui.withSimpleRenderer import com.intellij.openapi.ui.ComboBox import com.intellij.ui.dsl.builder.BottomGap -import com.intellij.ui.dsl.builder.EMPTY_LABEL import com.intellij.ui.dsl.builder.bindItem import com.intellij.ui.dsl.builder.bindSelected import com.intellij.ui.dsl.builder.bindText @@ -38,14 +37,14 @@ class StringSchemeEditor(scheme: StringScheme = StringScheme()) : SchemeEditor List