diff --git a/build.gradle.kts b/build.gradle.kts index 3b9ed3b..e9281a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,9 +16,9 @@ plugins { // Gradle Qodana Plugin id("org.jetbrains.qodana") version "0.1.13" // detekt linter - read more: https://detekt.github.io/detekt/gradle.html - id("io.gitlab.arturbosch.detekt") version "1.22.0" + id("io.gitlab.arturbosch.detekt") version "1.23.1" // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle - id("org.jlleitschuh.gradle.ktlint") version "11.3.2" + id("org.jlleitschuh.gradle.ktlint") version "12.0.3" } group = properties("pluginGroup") @@ -132,11 +132,11 @@ tasks { throw GradleException("Plugin description section not found in README.md:\n$start ... $end") } subList(indexOf(start) + 1, indexOf(end)) - }.joinToString("\n").run { markdownToHTML(this) } + }.joinToString("\n").run { markdownToHTML(this) }, ) changeNotes.set( - projectDir.resolve("RELEASE-NOTES.md").readText().run { markdownToHTML(this) } + projectDir.resolve("RELEASE-NOTES.md").readText().run { markdownToHTML(this) }, ) } diff --git a/gradle.properties b/gradle.properties index 777eb40..08c96ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,19 +2,19 @@ pluginGroup = io.unthrottled.doki.icons pluginName = Doki Theme Icons -pluginVersion = 88.5-1.1.0 +pluginVersion = 88.5-1.2.0 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 233.8264.8 -pluginUntilBuild = 233.* +pluginSinceBuild = 233.11799.241 +pluginUntilBuild = 241.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension platformType = IU -platformVersion = 2023.3.2 +platformVersion = 2024.1 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = Pythonid:233.13135.103 +platformPlugins = Pythonid:241.14494.314 # Gradle Releases -> https://github.com/gradle/gradle/releases gradleVersion = 8.5 diff --git a/src/main/kotlin/icons/DokiThemeIconz.kt b/src/main/kotlin/icons/DokiThemeIconz.kt index d3b5916..ed30fd6 100644 --- a/src/main/kotlin/icons/DokiThemeIconz.kt +++ b/src/main/kotlin/icons/DokiThemeIconz.kt @@ -34,6 +34,5 @@ object DokiThemeIconz { val EXPANDED = load("doki/icons/chevron_down_13x13.svg") } - private fun load(path: String): Icon = - IconLoader.getIcon(path, DokiThemeIconz::class.java) + private fun load(path: String): Icon = IconLoader.getIcon(path, DokiThemeIconz::class.java) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeIcons.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeIcons.kt index 9d1c07a..9f126bc 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeIcons.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeIcons.kt @@ -6,7 +6,6 @@ import io.unthrottled.doki.icons.jetbrains.tools.toOptional import java.util.Optional object DokiThemeIcons { - fun getVersion(): Optional = PluginManagerCore.getPlugin(PluginId.getId(Constants.PLUGIN_ID)) .toOptional() diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeInformation.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeInformation.kt index 2801962..f696109 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeInformation.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/DokiThemeInformation.kt @@ -6,5 +6,5 @@ data class DokiThemeInformation( val displayName: String, val group: String, val listName: String, - val colors: Map + val colors: Map, ) diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/PluginMaster.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/PluginMaster.kt index c88c4ca..fb37159 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/PluginMaster.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/PluginMaster.kt @@ -16,11 +16,11 @@ import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentMap class PluginMaster : ProjectManagerListener, Disposable, Logging { - companion object { init { ExperimentalUIFixer.fixExperimentalUI() } + val instance: PluginMaster get() = ApplicationManager.getApplication().getService(PluginMaster::class.java) } @@ -62,9 +62,8 @@ class PluginMaster : ProjectManagerListener, Disposable, Logging { } internal data class ProjectListeners( - private val project: Project + private val project: Project, ) : Disposable { - override fun dispose() { } } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/actions/ShowUpdateNotification.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/actions/ShowUpdateNotification.kt index f390c81..38ced0d 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/actions/ShowUpdateNotification.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/actions/ShowUpdateNotification.kt @@ -7,13 +7,12 @@ import io.unthrottled.doki.icons.jetbrains.DokiThemeIcons.getVersion import io.unthrottled.doki.icons.jetbrains.onboarding.UpdateNotification class ShowUpdateNotification : AnAction(), DumbAware { - override fun actionPerformed(e: AnActionEvent) { getVersion() .ifPresent { UpdateNotification.display( e.project!!, - it + it, ) } } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/Config.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/Config.kt index 074dc33..0428934 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/Config.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/Config.kt @@ -13,7 +13,7 @@ fun Application.getConfig(): Config = this.getService(Config::class.java) @State( name = "doki-theme-icon-config", - storages = [Storage("doki-theme-icons.xml")] + storages = [Storage("doki-theme-icons.xml")], ) class Config : PersistentStateComponent, Cloneable { companion object { @@ -32,8 +32,7 @@ class Config : PersistentStateComponent, Cloneable { var isMyIcons: Boolean = false var syncWithDokiTheme: Boolean = true - override fun getState(): Config? = - createCopy(this) + override fun getState(): Config? = createCopy(this) override fun loadState(state: Config) { copyBean(state, this) diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconConfigListener.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconConfigListener.kt index 56a13b8..5cb5646 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconConfigListener.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconConfigListener.kt @@ -9,5 +9,9 @@ interface IconConfigListener : EventListener { val TOPIC: Topic = Topic(IconConfigListener::class.java) } - fun iconConfigUpdated(previousState: IconSettingsModel, newState: IconSettingsModel) + + fun iconConfigUpdated( + previousState: IconSettingsModel, + newState: IconSettingsModel, + ) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconSettings.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconSettings.kt index fccfffd..67e29da 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconSettings.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/config/IconSettings.kt @@ -37,7 +37,7 @@ data class IconSettingsModel( var isNamedFolderIcons: Boolean, var isMyIcons: Boolean, var currentThemeId: String, - var syncWithDokiTheme: Boolean + var syncWithDokiTheme: Boolean, ) object IconSettings { @@ -52,29 +52,33 @@ object IconSettings { isGlyphIcons = Config.instance.isGlyphIcon, isNamedFolderIcons = Config.instance.isNamedFolderIcons, isMyIcons = Config.instance.isMyIcons, - currentThemeId = IconThemeManager.instance.getThemeById( - Config.instance.currentThemeId - ).orElseGet { - IconThemeManager.instance.defaultTheme - }.id, - syncWithDokiTheme = Config.instance.syncWithDokiTheme + currentThemeId = + IconThemeManager.instance.getThemeById( + Config.instance.currentThemeId, + ).orElseGet { + IconThemeManager.instance.defaultTheme + }.id, + syncWithDokiTheme = Config.instance.syncWithDokiTheme, ) fun createThemeComboBoxModel(settingsSupplier: () -> IconSettingsModel): ComboBox { - val themeList = IconThemeManager.instance.allThemes - .sortedBy { theme -> theme.listName } - .map { ThemeComboItem(it) } - val themeComboBox = ComboBox( - DefaultComboBoxModel( - Vector( - themeList - ) + val themeList = + IconThemeManager.instance.allThemes + .sortedBy { theme -> theme.listName } + .map { ThemeComboItem(it) } + val themeComboBox = + ComboBox( + DefaultComboBoxModel( + Vector( + themeList, + ), + ), ) - ) - themeComboBox.model.selectedItem = themeList.find { - it.id == settingsSupplier().currentThemeId - } + themeComboBox.model.selectedItem = + themeList.find { + it.id == settingsSupplier().currentThemeId + } themeComboBox.addActionListener { settingsSupplier().currentThemeId = (themeComboBox.model.selectedItem as ThemeComboItem).id diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/ErrorReporter.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/ErrorReporter.kt index 39ca0a7..71a26f7 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/ErrorReporter.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/ErrorReporter.kt @@ -39,24 +39,24 @@ class ErrorReporter : ErrorReportSubmitter() { events: Array, additionalInfo: String?, parentComponent: Component, - consumer: Consumer + consumer: Consumer, ): Boolean { ApplicationManager.getApplication() .executeOnPooledThread { Sentry.setUser( User().apply { this.id = Config.instance.userId - } + }, ) runSafely({ Sentry.init { options: SentryOptions -> options.dsn = RestClient.performGet( - "https://jetbrains.assets.unthrottled.io/doki-theme-icons/sentry-dsn.txt" + "https://jetbrains.assets.unthrottled.io/doki-theme-icons/sentry-dsn.txt", ) .map { it.trim() } .orElse( - "https://3d3ed43aea294f4eb101f1e7714b0678@o403546.ingest.sentry.io/6684182" + "https://3d3ed43aea294f4eb101f1e7714b0678@o403546.ingest.sentry.io/6684182", ) } }) { @@ -71,12 +71,13 @@ class ErrorReporter : ErrorReportSubmitter() { this.level = SentryLevel.ERROR this.serverName = getAppName().second this.setExtra("Additional Info", additionalInfo ?: "None") - } + }, ).apply { - this.message = Message().apply { - this.message = it.throwableText - } - } + this.message = + Message().apply { + this.message = it.throwableText + } + }, ) } consumer.consume(SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)) @@ -103,10 +104,11 @@ class ErrorReporter : ErrorReportSubmitter() { } private fun getJRE(properties: Properties): String { - val javaVersion = properties.getProperty( - "java.runtime.version", - properties.getProperty("java.version", "unknown") - ) + val javaVersion = + properties.getProperty( + "java.runtime.version", + properties.getProperty("java.version", "unknown"), + ) val arch = properties.getProperty("os.arch", "") return IdeBundle.message("about.box.jre", javaVersion, arch) } @@ -117,8 +119,9 @@ class ErrorReporter : ErrorReportSubmitter() { return IdeBundle.message("about.box.vm", vmVersion, vmVendor) } - private fun getGC() = ManagementFactory.getGarbageCollectorMXBeans().stream() - .map { it.name }.collect(Collectors.joining(",")) + private fun getGC() = + ManagementFactory.getGarbageCollectorMXBeans().stream() + .map { it.name }.collect(Collectors.joining(",")) private fun getBuildInfo(appInfo: ApplicationInfo): String { var buildInfo = IdeBundle.message("about.box.build.number", appInfo.build.asString()) diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PlatformHacker.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PlatformHacker.kt index 14d8772..1b291be 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PlatformHacker.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PlatformHacker.kt @@ -10,7 +10,6 @@ import javassist.expr.ExprEditor import javassist.expr.MethodCall object PlatformHacker : Logging { - init { IconPathReplacementComponent.installComponents() hackPlatform() @@ -31,20 +30,21 @@ object PlatformHacker : Logging { val cp = ClassPool(true) cp.insertClassPath( ClassClassPath( - Class.forName("com.intellij.execution.ui.RunState") - ) + Class.forName("com.intellij.execution.ui.RunState"), + ), ) val ctClass = cp.get("com.intellij.execution.ui.StopWithDropDownAction") - val doPaintText = ctClass.getDeclaredMethods("update")[0] - doPaintText.instrument( - object : ExprEditor() { - override fun edit(m: MethodCall?) { - if (m?.methodName == "toStrokeIcon") { - m.replace("{ \$_ = \$1; }") + ctClass.getDeclaredMethods("update").forEach { doPaintText -> + doPaintText.instrument( + object : ExprEditor() { + override fun edit(m: MethodCall?) { + if (m?.methodName == "toStrokeIcon") { + m.replace("{ \$_ = \$1; }") + } } - } - } - ) + }, + ) + } ctClass.toClass() }) { logger().warn("Unable to hack 'fixEXPUIStopButton' for raisins", it) @@ -56,20 +56,21 @@ object PlatformHacker : Logging { val cp = ClassPool(true) cp.insertClassPath( ClassClassPath( - Class.forName("com.intellij.execution.ui.RunState") - ) + Class.forName("com.intellij.execution.ui.RunState"), + ), ) val ctClass = cp.get("com.intellij.execution.ui.RunWidgetButtonLook") - val doPaintText = ctClass.getDeclaredMethods("paintIcon")[0] - doPaintText.instrument( - object : ExprEditor() { - override fun edit(m: MethodCall?) { - if (m?.methodName == "toStrokeIcon") { - m.replace("{ \$_ = \$1; }") + ctClass.getDeclaredMethods("paintIcon").forEach { doPaintText -> + doPaintText.instrument( + object : ExprEditor() { + override fun edit(m: MethodCall?) { + if (m?.methodName == "toStrokeIcon") { + m.replace("{ \$_ = \$1; }") + } } - } - } - ) + }, + ) + } ctClass.toClass() }) { logger().warn("Unable to hack 'fixEXPUIRunWidget' for raisins", it) @@ -79,20 +80,21 @@ object PlatformHacker : Logging { val cp = ClassPool(true) cp.insertClassPath( ClassClassPath( - Class.forName("com.intellij.execution.ui.RunState") - ) + Class.forName("com.intellij.execution.ui.RunState"), + ), ) val ctClass = cp.get("com.intellij.execution.ui.RedesignedRunConfigurationSelector") - val doPaintText = ctClass.getDeclaredMethods("update")[0] - doPaintText.instrument( - object : ExprEditor() { - override fun edit(m: MethodCall?) { - if (m?.methodName == "toStrokeIcon") { - m.replace("{ \$_ = \$1; }") + ctClass.getDeclaredMethods("update").forEach { doPaintText -> + doPaintText.instrument( + object : ExprEditor() { + override fun edit(m: MethodCall?) { + if (m?.methodName == "toStrokeIcon") { + m.replace("{ \$_ = \$1; }") + } } - } - } - ) + }, + ) + } ctClass.toClass() }) { logger().warn("Unable to hack 'fixEXPUIRunWidget' try two for raisins", it) @@ -104,20 +106,21 @@ object PlatformHacker : Logging { val cp = ClassPool(true) cp.insertClassPath( ClassClassPath( - Class.forName("com.intellij.openapi.wm.impl.SideStack") - ) + Class.forName("com.intellij.openapi.wm.impl.SideStack"), + ), ) val ctClass = cp.get("com.intellij.openapi.wm.impl.SquareStripeButtonLook") - val doPaintText = ctClass.getDeclaredMethods("paintIcon")[0] - doPaintText.instrument( - object : ExprEditor() { - override fun edit(m: MethodCall?) { - if (m?.methodName == "toStrokeIcon") { - m.replace("{ \$_ = \$1; }") + ctClass.getDeclaredMethods("paintIcon").forEach { doPaintText -> + doPaintText.instrument( + object : ExprEditor() { + override fun edit(m: MethodCall?) { + if (m?.methodName == "toStrokeIcon") { + m.replace("{ \$_ = \$1; }") + } } - } - } - ) + }, + ) + } ctClass.toClass() }) { logger().warn("Unable to hack 'fixEXPUIButton' for raisins", it) diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PluginService.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PluginService.kt index 73b8ec5..ed2e248 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PluginService.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/PluginService.kt @@ -24,26 +24,30 @@ const val DOKI_THEME_COMMUNITY_PLUGIN_ID = "io.acari.DDLCTheme" private const val DOKI_THEME_ULTIMATE_PLUGIN_ID = "io.unthrottled.DokiTheme" object PluginService : Logging { - private val objectMapper by lazy { ObjectMapper() } - fun isMotivatorInstalled(): Boolean = PluginManagerCore.isPluginInstalled( - PluginId.getId(MOTIVATOR_PLUGIN_ID) - ) + fun isMotivatorInstalled(): Boolean = + PluginManagerCore.isPluginInstalled( + PluginId.getId(MOTIVATOR_PLUGIN_ID), + ) - fun isDokiThemeInstalled(): Boolean = PluginManagerCore.isPluginInstalled( - PluginId.getId(DOKI_THEME_COMMUNITY_PLUGIN_ID) - ) || PluginManagerCore.isPluginInstalled( - PluginId.getId(DOKI_THEME_ULTIMATE_PLUGIN_ID) - ) + fun isDokiThemeInstalled(): Boolean = + PluginManagerCore.isPluginInstalled( + PluginId.getId(DOKI_THEME_COMMUNITY_PLUGIN_ID), + ) || + PluginManagerCore.isPluginInstalled( + PluginId.getId(DOKI_THEME_ULTIMATE_PLUGIN_ID), + ) - fun isAmiiInstalled(): Boolean = PluginManagerCore.isPluginInstalled( - PluginId.getId(AMII_PLUGIN_ID) - ) + fun isAmiiInstalled(): Boolean = + PluginManagerCore.isPluginInstalled( + PluginId.getId(AMII_PLUGIN_ID), + ) - fun isRandomizerInstalled(): Boolean = PluginManagerCore.isPluginInstalled( - PluginId.getId(RANDOMIZER_PLUGIN_ID) - ) + fun isRandomizerInstalled(): Boolean = + PluginManagerCore.isPluginInstalled( + PluginId.getId(RANDOMIZER_PLUGIN_ID), + ) private val PLUGIN_MANAGER_URL by lazy { ApplicationInfoImpl.getInstanceEx() @@ -54,7 +58,7 @@ object PluginService : Logging { private data class CompatibleUpdateRequest( val build: String, - val pluginXMLIds: List + val pluginXMLIds: List, ) /** @@ -70,24 +74,23 @@ object PluginService : Logging { val externalPluginId: String = "", @get:JsonProperty("pluginXmlId") val pluginId: String = "", - val version: String = "" + val version: String = "", ) - private fun getLastCompatiblePluginUpdate( - ids: Set - ): List { + private fun getLastCompatiblePluginUpdate(ids: Set): List { return try { if (ids.isEmpty()) { return emptyList() } - val data = objectMapper.writeValueAsString( - CompatibleUpdateRequest( - ApplicationInfoImpl.getInstanceEx() - .build.asString(), - ids.map { it.idString } + val data = + objectMapper.writeValueAsString( + CompatibleUpdateRequest( + ApplicationInfoImpl.getInstanceEx() + .build.asString(), + ids.map { it.idString }, + ), ) - ) HttpRequests .post(Urls.newFromEncoded(COMPATIBLE_UPDATE_URL).toExternalForm(), HttpRequests.JSON_CONTENT_TYPE) .productNameAsUserAgent() @@ -107,9 +110,10 @@ object PluginService : Logging { Callable { runSafelyWithResult({ val pluginId = PluginId.getId(AMII_PLUGIN_ID) - val lastCompatiblePluginUpdate = getLastCompatiblePluginUpdate( - Collections.singleton(pluginId) - ) + val lastCompatiblePluginUpdate = + getLastCompatiblePluginUpdate( + Collections.singleton(pluginId), + ) lastCompatiblePluginUpdate.firstOrNull { pluginNode -> pluginNode.pluginId == AMII_PLUGIN_ID } != null @@ -117,7 +121,7 @@ object PluginService : Logging { logger().warn("Unable to check to see if AMII can be installed", it) false } - } + }, ).get() } } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/RestClient.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/RestClient.kt index 5d35bd3..5515a28 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/RestClient.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/integrations/RestClient.kt @@ -14,7 +14,6 @@ import java.util.Optional import java.util.concurrent.Callable object RestClient : Logging { - fun performGet(url: String): Optional = ApplicationManager.getApplication().executeOnPooledThread( Callable { @@ -26,7 +25,7 @@ object RestClient : Logging { logger().warn("Unable to complete request for $url for raisins.", it) Optional.empty() } - } + }, ).get() } @@ -35,7 +34,7 @@ object RestTools { fun performRequest( url: String, - bodyExtractor: (InputStream) -> T + bodyExtractor: (InputStream) -> T, ): Optional { log.info("Attempting to download remote asset: $url") return runSafelyWithResult({ diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/laf/LAFIconReplacementComponent.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/laf/LAFIconReplacementComponent.kt index 9f1cb3a..a2ac44e 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/laf/LAFIconReplacementComponent.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/laf/LAFIconReplacementComponent.kt @@ -15,7 +15,6 @@ import javax.swing.SwingUtilities import javax.swing.UIManager object LAFIconReplacementComponent : IconConfigListener, ThemeManagerListener { - private val connection = ApplicationManager.getApplication().messageBus.connect() fun initialize() { @@ -31,11 +30,14 @@ object LAFIconReplacementComponent : IconConfigListener, ThemeManagerListener { } setTreeIcons( collapsed = DokiThemeIconz.Tree.COLLAPSED, - expanded = DokiThemeIconz.Tree.EXPANDED + expanded = DokiThemeIconz.Tree.EXPANDED, ) } - private fun setTreeIcons(collapsed: Icon, expanded: Icon) { + private fun setTreeIcons( + collapsed: Icon, + expanded: Icon, + ) { val defaults = UIManager.getLookAndFeelDefaults() defaults[DokiThemeIconz.Tree.COLLAPSED_KEY] = collapsed defaults[DokiThemeIconz.Tree.SELECTED_COLLAPSED_KEY] = collapsed @@ -48,7 +50,10 @@ object LAFIconReplacementComponent : IconConfigListener, ThemeManagerListener { connection.dispose() } - override fun iconConfigUpdated(previousState: IconSettingsModel, newState: IconSettingsModel) { + override fun iconConfigUpdated( + previousState: IconSettingsModel, + newState: IconSettingsModel, + ) { if (newState.isUIIcons != previousState.isUIIcons) { if (newState.isUIIcons) { installLAFIcons() @@ -61,7 +66,7 @@ object LAFIconReplacementComponent : IconConfigListener, ThemeManagerListener { private fun removeLAFIcons() { setTreeIcons( collapsed = LafIconLookup.getSelectedIcon("treeCollapsed"), - expanded = LafIconLookup.getSelectedIcon("treeExpanded") + expanded = LafIconLookup.getSelectedIcon("treeExpanded"), ) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ApplicationLifecycleListener.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ApplicationLifecycleListener.kt index 933cbd0..4a968e6 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ApplicationLifecycleListener.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ApplicationLifecycleListener.kt @@ -6,7 +6,6 @@ import io.unthrottled.doki.icons.jetbrains.PluginMaster import io.unthrottled.doki.icons.jetbrains.integrations.PlatformHacker class ApplicationLifecycleListener : AppLifecycleListener, DumbAware { - companion object { init { PlatformHacker.toString() diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/IDEPluginInstallListener.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/IDEPluginInstallListener.kt index 7ab8315..d1ff1cf 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/IDEPluginInstallListener.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/IDEPluginInstallListener.kt @@ -8,13 +8,12 @@ import io.unthrottled.doki.icons.jetbrains.PluginMaster import io.unthrottled.doki.icons.jetbrains.tools.Logging class IDEPluginInstallListener : DynamicPluginListener, Logging { - override fun beforePluginLoaded(pluginDescriptor: IdeaPluginDescriptor) { } override fun beforePluginUnload( pluginDescriptor: IdeaPluginDescriptor, - isUpdate: Boolean + isUpdate: Boolean, ) { } @@ -31,7 +30,7 @@ class IDEPluginInstallListener : DynamicPluginListener, Logging { override fun pluginUnloaded( pluginDescriptor: IdeaPluginDescriptor, - isUpdate: Boolean + isUpdate: Boolean, ) { } } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectListener.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectListener.kt index 079de01..3840e0d 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectListener.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectListener.kt @@ -8,14 +8,12 @@ import io.unthrottled.doki.icons.jetbrains.tools.Logging internal class ProjectListener : ProjectManagerListener, Logging { - override fun projectClosed(project: Project) { PluginMaster.instance.projectClosed(project) } } internal class PluginPostStartUpActivity : ProjectActivity { - override suspend fun execute(project: Project) { PluginMaster.instance.handleProjectOpened(project) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectRefreshListener.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectRefreshListener.kt index 78b1730..21f561d 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectRefreshListener.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/listeners/ProjectRefreshListener.kt @@ -7,10 +7,9 @@ import io.unthrottled.doki.icons.jetbrains.config.IconConfigListener import io.unthrottled.doki.icons.jetbrains.config.IconSettingsModel class ProjectRefreshListener : IconConfigListener { - override fun iconConfigUpdated( previousState: IconSettingsModel, - newState: IconSettingsModel + newState: IconSettingsModel, ) { LafManager.getInstance().updateUI() refreshProjects() diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UpdateNotification.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UpdateNotification.kt index 88680c0..5146658 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UpdateNotification.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UpdateNotification.kt @@ -18,19 +18,18 @@ import org.intellij.lang.annotations.Language @Language("HTML") private fun buildUpdateMessage(): String = """ - What's New?
-
    -
  • Added initial 2023.3 build support.
  • -
-
See the documentation for features, usages, and configurations. -
The changelog is available for more details. -

- Thanks for downloading! - + What's New?
+
    +
  • Added initial 2023.3 build support.
  • +
+
See the documentation for features, usages, and configurations. +
The changelog is available for more details. +

+ Thanks for downloading! + """.trimIndent() object UpdateNotification { - private const val UPDATE_CHANNEL_NAME = "$PLUGIN_NAME Updates" private val notificationGroup = NotificationGroupManager.getInstance() @@ -38,15 +37,16 @@ object UpdateNotification { fun display( project: Project, - newVersion: String + newVersion: String, ) { - val updateNotification = notificationGroup.createNotification( - buildUpdateMessage(), - NotificationType.INFORMATION - ) - .setTitle("$PLUGIN_NAME updated to v$newVersion") - .setIcon(PLUGIN_ICON) - .setListener(NotificationListener.UrlOpeningListener(false)) + val updateNotification = + notificationGroup.createNotification( + buildUpdateMessage(), + NotificationType.INFORMATION, + ) + .setTitle("$PLUGIN_NAME updated to v$newVersion") + .setIcon(PLUGIN_ICON) + .setListener(NotificationListener.UrlOpeningListener(false)) showNotification(project, updateNotification) } @@ -54,13 +54,13 @@ object UpdateNotification { fun sendMessage( title: String, message: String, - project: Project? = null + project: Project? = null, ) { showRegularNotification( title, message, project = project, - listener = defaultListener + listener = defaultListener, ) } @@ -70,11 +70,11 @@ object UpdateNotification { title: String = "", content: String, project: Project? = null, - listener: NotificationListener? = defaultListener + listener: NotificationListener? = defaultListener, ) { notificationGroup.createNotification( content, - NotificationType.INFORMATION + NotificationType.INFORMATION, ).setIcon(PLUGIN_ICON) .setTitle(title) .setListener(listener ?: defaultListener) @@ -83,18 +83,19 @@ object UpdateNotification { private fun showNotification( project: Project, - updateNotification: Notification + updateNotification: Notification, ) { try { val (ideFrame, notificationPosition) = fetchBalloonParameters(project) - val balloon = NotificationsManagerImpl.createBalloon( - ideFrame, - updateNotification, - true, - false, - BalloonLayoutData.fullContent(), - Disposer.newDisposable() - ) + val balloon = + NotificationsManagerImpl.createBalloon( + ideFrame, + updateNotification, + true, + false, + BalloonLayoutData.fullContent(), + Disposer.newDisposable(), + ) balloon.show(notificationPosition, Balloon.Position.atLeft) } catch (e: Throwable) { updateNotification.notify(project) diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UserOnBoarding.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UserOnBoarding.kt index fa14c9b..794a358 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UserOnBoarding.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/onboarding/UserOnBoarding.kt @@ -11,7 +11,6 @@ import java.util.Optional import java.util.UUID object UserOnBoarding { - fun attemptToPerformNewUpdateActions(project: Project) { getNewVersion().ifPresent { newVersion -> Config.instance.version = newVersion diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/DokiIconPathPatcher.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/DokiIconPathPatcher.kt index e7b5fdf..4599f5b 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/DokiIconPathPatcher.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/DokiIconPathPatcher.kt @@ -10,16 +10,15 @@ import io.unthrottled.doki.icons.jetbrains.tools.logger data class PathMapping( val originalPath: String, val iconName: String, - val isOddBall: Boolean? + val isOddBall: Boolean?, ) class DokiIconPathPatcher(private val mappingFile: String) : IconPathPatcher(), Logging { - private val pathMappings: Map = readJsonFromResources>( "/", mappingFile, - object : TypeToken>() {}.type + object : TypeToken>() {}.type, ) .map { def -> def.associate { @@ -34,20 +33,20 @@ class DokiIconPathPatcher(private val mappingFile: String) : IconPathPatcher(), override fun patchPath( path: String, - classLoader: ClassLoader? - ): String? = pathMappings[ - if (path.startsWith('/')) { - path - } else { - "/$path" - } - ] + classLoader: ClassLoader?, + ): String? = + pathMappings[ + if (path.startsWith('/')) { + path + } else { + "/$path" + }, + ] override fun getContextClassLoader( path: String, - originalClassLoader: ClassLoader? - ): ClassLoader? = - javaClass.classLoader + originalClassLoader: ClassLoader?, + ): ClassLoader? = javaClass.classLoader override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/ExperimentalUIFixer.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/ExperimentalUIFixer.kt index 65b89b1..a587a48 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/ExperimentalUIFixer.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/ExperimentalUIFixer.kt @@ -6,7 +6,6 @@ import com.intellij.ui.ExperimentalUI import io.unthrottled.doki.icons.jetbrains.tools.runSafely object ExperimentalUIFixer { - init { fixExperimentalUI() } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/IconPathReplacementComponent.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/IconPathReplacementComponent.kt index ffcb0a6..1d35570 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/IconPathReplacementComponent.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/path/IconPathReplacementComponent.kt @@ -11,7 +11,7 @@ import io.unthrottled.doki.icons.jetbrains.config.IconSettingsModel data class IconReplacementPack( val iconPatcher: DokiIconPathPatcher, val iconSettingsExtractor: (IconSettingsModel) -> Boolean, - val iconConfigExtractor: (Config) -> Boolean + val iconConfigExtractor: (Config) -> Boolean, ) object IconPathReplacementComponent : IconConfigListener { @@ -20,28 +20,28 @@ object IconPathReplacementComponent : IconConfigListener { IconReplacementPack( DokiIconPathPatcher("alex-icons.path.mappings.json"), { it.isMyIcons }, - { it.isMyIcons } + { it.isMyIcons }, ), IconReplacementPack( DokiIconPathPatcher("ui-icons.path.mappings.json"), { it.isUIIcons }, - { it.isUIIcons } + { it.isUIIcons }, ), IconReplacementPack( DokiIconPathPatcher("node.path.mappings.json"), { it.isUIIcons }, - { it.isUIIcons } + { it.isUIIcons }, ), IconReplacementPack( DokiIconPathPatcher("file-icons.path.mappings.json"), { it.isUIIcons }, - { it.isUIIcons } + { it.isUIIcons }, ), IconReplacementPack( DokiIconPathPatcher("glyph-icons.path.mappings.json"), { it.isGlyphIcons }, - { it.isGlyphIcon } - ) + { it.isGlyphIcon }, + ), ) private val connection = ApplicationManager.getApplication().messageBus.connect() @@ -69,10 +69,14 @@ object IconPathReplacementComponent : IconConfigListener { } } - override fun iconConfigUpdated(previousState: IconSettingsModel, newState: IconSettingsModel) { - val hasChanged = iconInstallPacs.any { - it.iconSettingsExtractor(previousState) != it.iconSettingsExtractor(newState) - } + override fun iconConfigUpdated( + previousState: IconSettingsModel, + newState: IconSettingsModel, + ) { + val hasChanged = + iconInstallPacs.any { + it.iconSettingsExtractor(previousState) != it.iconSettingsExtractor(newState) + } if (!hasChanged) { return } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/shared/Functions.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/shared/Functions.kt index fb3890d..1a4302a 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/shared/Functions.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/shared/Functions.kt @@ -5,6 +5,7 @@ fun toLongArray(bytArray: ByteArray): LongArray { bytArray.forEachIndexed { index, byte -> digest[index] = byte.toLong() } return digest } + fun toByteArray(longArray: LongArray): ByteArray { val digest = ByteArray(longArray.size) longArray.forEachIndexed { index, byte -> digest[index] = byte.toByte() } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/ComposedSVGColorizerProvider.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/ComposedSVGColorizerProvider.kt index 4db8ff3..47f207c 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/ComposedSVGColorizerProvider.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/ComposedSVGColorizerProvider.kt @@ -7,9 +7,8 @@ import io.unthrottled.doki.icons.jetbrains.themes.DokiThemePayload import io.unthrottled.doki.icons.jetbrains.tools.runSafelyWithResult class ComposedSVGColorizer( - private val patchers: List + private val patchers: List, ) : Patcher { - override fun patchColors(attributes: MutableMap) { patchers.forEach { it.patchColors(attributes) @@ -20,17 +19,18 @@ class ComposedSVGColorizer( @Suppress("UnstableApiUsage") class ComposedSVGColorizerProvider( dokiThemePayload: DokiThemePayload, - otherSvgPatcherProvider: PatcherProvider + otherSvgPatcherProvider: PatcherProvider, ) : PatcherProvider { private val colorizer = SVGColorizerProvider(dokiThemePayload.dokiTheme) private val replacer = SVGColorPaletteReplacer(dokiThemePayload.dokiTheme) - private val patcherProviders = listOf( - otherSvgPatcherProvider, - colorizer, - replacer, - dokiThemePayload.colorPatcher - ) - .distinct() + private val patcherProviders = + listOf( + otherSvgPatcherProvider, + colorizer, + replacer, + dokiThemePayload.colorPatcher, + ) + .distinct() private val digest: LongArray @@ -53,12 +53,11 @@ class ComposedSVGColorizerProvider( }) { null } - } + }, ) } object ComposedSVGColorizerProviderFactory { - fun createForTheme(dokiThemePayload: DokiThemePayload): PatcherProvider { val otherSvgPatcherProvider = SvgLoaderHacker.collectOtherPatcher() return ComposedSVGColorizerProvider(dokiThemePayload, otherSvgPatcherProvider) diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SVGColorizerProvider.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SVGColorizerProvider.kt index 5119c14..b0768f6 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SVGColorizerProvider.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SVGColorizerProvider.kt @@ -16,13 +16,12 @@ import java.awt.Color import kotlin.math.ceil class SVGColorPaletteReplacer(private val dokiTheme: DokiTheme) : PatcherProvider, Logging { - companion object { private val iconTemplate: Map = AssetTools.readJsonFromResources>( "/doki/generated", "icon.palette.template.json", - object : TypeToken>() {}.type + object : TypeToken>() {}.type, ).orElseGet { emptyMap() } @@ -41,37 +40,39 @@ class SVGColorPaletteReplacer(private val dokiTheme: DokiTheme) : PatcherProvide logger().error( """Hey silly maintainer, you forgot to give theme |"${dokiTheme.listName}:${dokiTheme.id}" color "$namedColor", pls fix - """.trimMargin() + """.trimMargin(), ) } newColor }.toMutableMap().apply { // todo: document deez - this["#000000"] = JBColor.namedColor( - "Panel.background", - ColorUtil.fromHex(dokiTheme.colors["baseBackground"]!!) - ) - .toHexString() - this["#776bc4"] = ColorUtil.darker( - ColorUtil.fromHex(dokiTheme.colors["iconSecondaryBlend"]!!), - SECONDARY_BLEND_DARKENING - ) - .toHexString() + this["#000000"] = + JBColor.namedColor( + "Panel.background", + ColorUtil.fromHex(dokiTheme.colors["baseBackground"]!!), + ) + .toHexString() + this["#776bc4"] = + ColorUtil.darker( + ColorUtil.fromHex(dokiTheme.colors["iconSecondaryBlend"]!!), + SECONDARY_BLEND_DARKENING, + ) + .toHexString() } override fun attributeForPath(path: String): SvgAttributePatcher? = PalletPatcher( - newPalette + newPalette, ) private val digest = toLongArray(("pallet" + dokiTheme.id + dokiTheme.version).toByteArray(Charsets.UTF_8)) + override fun digest(): LongArray = digest } class PalletPatcher( - private val newPalette: Map + private val newPalette: Map, ) : Patcher { - companion object { private const val HEX_STRING_LENGTH = 7 } @@ -122,7 +123,6 @@ class PalletPatcher( } class SVGColorizerProvider(private val dokiTheme: DokiTheme) : PatcherProvider { - override fun attributeForPath(path: String): SvgAttributePatcher? = SVGColorizer(dokiTheme) private val digest = @@ -132,17 +132,14 @@ class SVGColorizerProvider(private val dokiTheme: DokiTheme) : PatcherProvider { } class SVGColorizer(private val dokiTheme: DokiTheme) : Patcher { - override fun patchColors(attributes: MutableMap) { patchChildren( - attributes + attributes, ) } @Suppress("MagicNumber") - private fun patchChildren( - attributes: MutableMap - ) { + private fun patchChildren(attributes: MutableMap) { patchAccent(attributes["accentTint"], attributes) { it.toHexString() } @@ -186,7 +183,7 @@ class SVGColorizer(private val dokiTheme: DokiTheme) : Patcher { private fun patchAccent( attribute: String?, attributes: MutableMap, - colorDecorator: (Color) -> String + colorDecorator: (Color) -> String, ) { when (attribute) { "fill" -> attributes["fill"] = colorDecorator(getAccentColor()) @@ -200,15 +197,11 @@ class SVGColorizer(private val dokiTheme: DokiTheme) : Patcher { } } - private fun getAccentColor() = - dokiTheme.colors["accentColor"]!!.toColor() + private fun getAccentColor() = dokiTheme.colors["accentColor"]!!.toColor() - private fun getIconAccentContrastColor() = - JBColor.namedColor("Doki.Icon.Accent.Contrast.color", Color.WHITE) + private fun getIconAccentContrastColor() = JBColor.namedColor("Doki.Icon.Accent.Contrast.color", Color.WHITE) - private fun getThemedStartColor() = - JBColor.namedColor("Doki.startColor", Color.CYAN).toHexString() + private fun getThemedStartColor() = JBColor.namedColor("Doki.startColor", Color.CYAN).toHexString() - private fun getThemedStopColor() = - JBColor.namedColor("Doki.stopColor", Color.CYAN).toHexString() + private fun getThemedStopColor() = JBColor.namedColor("Doki.stopColor", Color.CYAN).toHexString() } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SvgLoaderHacker.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SvgLoaderHacker.kt index 8ffd9b9..72ffa95 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SvgLoaderHacker.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/svg/SvgLoaderHacker.kt @@ -11,23 +11,22 @@ object NoOptPatcher : Patcher val emptyLongArray = LongArray(0) -val noOptPatcherProvider = object : PatcherProvider { - - override fun attributeForPath(path: String): SvgAttributePatcher { - return NoOptPatcher +val noOptPatcherProvider = + object : PatcherProvider { + override fun attributeForPath(path: String): SvgAttributePatcher { + return NoOptPatcher + } + + override fun digest(): LongArray { + return emptyLongArray + } } - override fun digest(): LongArray { - return emptyLongArray - } -} - object SvgLoaderHacker { - fun collectOtherPatcher(): PatcherProvider = Optional.ofNullable( SVGLoader::class.java.declaredFields - .firstOrNull { it.name == "colorPatcherProvider" } + .firstOrNull { it.name == "colorPatcherProvider" }, ) .map { ourColorPatcherField -> ourColorPatcherField.isAccessible = true diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/themes/IconThemeManager.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/themes/IconThemeManager.kt index 7133093..8800552 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/themes/IconThemeManager.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/themes/IconThemeManager.kt @@ -25,7 +25,7 @@ import java.util.Optional class DokiTheme( private val dokiThemeInformation: DokiThemeInformation, - val version: String + val version: String, ) { val id: String get() = dokiThemeInformation.id @@ -39,11 +39,10 @@ class DokiTheme( data class DokiThemePayload( val dokiTheme: DokiTheme, - val colorPatcher: SVGLoader.SvgElementColorPatcherProvider + val colorPatcher: SVGLoader.SvgElementColorPatcherProvider, ) interface ThemeManagerListener : EventListener { - fun onDokiThemeActivated(dokiThemePayload: DokiThemePayload) fun onDokiThemeRemoved() @@ -65,17 +64,18 @@ class IconThemeManager : LafManagerListener, Disposable, IconConfigListener, Log connection.subscribe(LafManagerListener.TOPIC, this) connection.subscribe(IconConfigListener.TOPIC, this) val currentVersion = DokiThemeIcons.getVersion().orElse("69") - themeMap = AssetTools.readJsonFromResources>( - "/doki/generated", - "doki-theme-definitions.json", - object : TypeToken>() {}.type - ).map { themes -> - themes - .map { DokiTheme(it, currentVersion) } - .associateBy { it.id } - }.orElseGet { - emptyMap() - } + themeMap = + AssetTools.readJsonFromResources>( + "/doki/generated", + "doki-theme-definitions.json", + object : TypeToken>() {}.type, + ).map { themes -> + themes + .map { DokiTheme(it, currentVersion) } + .associateBy { it.id } + }.orElseGet { + emptyMap() + } } fun init() { @@ -93,32 +93,33 @@ class IconThemeManager : LafManagerListener, Disposable, IconConfigListener, Log userSetTheme } private val userSetTheme: Optional - get() = LafManager.getInstance().installedLookAndFeels - .filterIsInstance() - .firstOrNull { - it.getId() == Config.instance.currentThemeId - }.toOptional() - .map { - val themeId = it.getId() - DokiThemePayload( - themeMap[themeId] ?: error("Expecting theme with ID $themeId to be present"), - it.theme.colorPatcher ?: noOptPatcherProvider - ) - }.or { - val themeId = Config.instance.currentThemeId - DokiThemePayload( - themeMap[themeId] ?: error("Expecting theme with ID $themeId to be present"), - LafManager.getInstance().currentUIThemeLookAndFeel - .toOptional() - .filter { it is UIThemeLookAndFeelInfoImpl } - .map { - val uiTheme = it as UIThemeLookAndFeelInfoImpl - uiTheme.theme.colorPatcher ?: noOptPatcherProvider - }.orElse( - noOptPatcherProvider - ) - ).toOptional() - } + get() = + LafManager.getInstance().installedLookAndFeels + .filterIsInstance() + .firstOrNull { + it.getId() == Config.instance.currentThemeId + }.toOptional() + .map { + val themeId = it.getId() + DokiThemePayload( + themeMap[themeId] ?: error("Expecting theme with ID $themeId to be present"), + it.theme.colorPatcher ?: noOptPatcherProvider, + ) + }.or { + val themeId = Config.instance.currentThemeId + DokiThemePayload( + themeMap[themeId] ?: error("Expecting theme with ID $themeId to be present"), + LafManager.getInstance().currentUIThemeLookAndFeel + .toOptional() + .filter { it is UIThemeLookAndFeelInfoImpl } + .map { + val uiTheme = it as UIThemeLookAndFeelInfoImpl + uiTheme.theme.colorPatcher ?: noOptPatcherProvider + }.orElse( + noOptPatcherProvider, + ), + ).toOptional() + } val allThemes: List get() = themeMap.values.toList() @@ -126,11 +127,11 @@ class IconThemeManager : LafManagerListener, Disposable, IconConfigListener, Log return currentLaf.toOptional() .filter { it is UIThemeLookAndFeelInfoImpl } .map { it as UIThemeLookAndFeelInfoImpl } - .filter { themeMap.containsKey(it.getId()) } + .filter { themeMap.containsKey(it.id) } .map { DokiThemePayload( - themeMap[it.getId()]!!, - it.theme.colorPatcher ?: noOptPatcherProvider + themeMap[it.id]!!, + it.theme.colorPatcher ?: noOptPatcherProvider, ) } } @@ -160,12 +161,11 @@ class IconThemeManager : LafManagerListener, Disposable, IconConfigListener, Log } } - fun getThemeById(currentThemeId: String): Optional = - themeMap[currentThemeId].toOptional() + fun getThemeById(currentThemeId: String): Optional = themeMap[currentThemeId].toOptional() override fun iconConfigUpdated( previousState: IconSettingsModel, - newState: IconSettingsModel + newState: IconSettingsModel, ) { val currentThemeId = newState.currentThemeId if (previousState.currentThemeId != currentThemeId) { diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/AssetTools.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/AssetTools.kt index b4c4ef4..6356be5 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/AssetTools.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/AssetTools.kt @@ -14,17 +14,17 @@ object AssetTools : Logging { fun readJsonFromResources( basePath: String, filePath: String, - type: Type + type: Type, ): Optional { return runSafelyWithResult({ ResourceUtil.getResourceAsStream( AssetTools::class.java.classLoader, basePath, - filePath + filePath, ).use { inputStream -> gson.fromJson( InputStreamReader(inputStream, StandardCharsets.UTF_8), - type + type, ).toOptional() } }) { diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/BalloonTools.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/BalloonTools.kt index e39bbbd..679eab9 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/BalloonTools.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/BalloonTools.kt @@ -8,13 +8,15 @@ import java.awt.Point object BalloonTools { private const val NOTIFICATION_Y_OFFSET = 20 + fun fetchBalloonParameters(project: Project): Pair { val ideFrame = getIDEFrame(project) val frameBounds = ideFrame.component.bounds - val notificationPosition = RelativePoint( - ideFrame.component, - Point(frameBounds.x, NOTIFICATION_Y_OFFSET) - ) + val notificationPosition = + RelativePoint( + ideFrame.component, + Point(frameBounds.x, NOTIFICATION_Y_OFFSET), + ) return Pair(ideFrame, notificationPosition) } @@ -22,5 +24,5 @@ object BalloonTools { ( WindowManager.getInstance().getIdeFrame(project) ?: WindowManager.getInstance().allProjectFrames.first() - ) + ) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/PluginMessageBundle.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/PluginMessageBundle.kt index c64373f..105d0ee 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/PluginMessageBundle.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/PluginMessageBundle.kt @@ -8,14 +8,17 @@ import org.jetbrains.annotations.PropertyKey private const val BUNDLE = "messages.MyBundle" object PluginMessageBundle : DynamicBundle(BUNDLE) { - @Suppress("SpreadOperator") @JvmStatic - fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = - getMessage(key, *params) + fun message( + @PropertyKey(resourceBundle = BUNDLE) key: String, + vararg params: Any, + ) = getMessage(key, *params) @Suppress("SpreadOperator", "unused") @JvmStatic - fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = - getLazyMessage(key, *params) + fun messagePointer( + @PropertyKey(resourceBundle = BUNDLE) key: String, + vararg params: Any, + ) = getLazyMessage(key, *params) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/ToolBox.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/ToolBox.kt index ab8142f..7b2e973 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/ToolBox.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/ToolBox.kt @@ -6,14 +6,20 @@ import java.io.InputStream import java.util.Optional import java.util.stream.Stream -fun runSafely(runner: () -> Unit, onError: (Throwable) -> Unit): Unit = +fun runSafely( + runner: () -> Unit, + onError: (Throwable) -> Unit, +): Unit = try { runner() } catch (e: Throwable) { onError(e) } -fun runSafelyWithResult(runner: () -> T, onError: (Throwable) -> T): T = +fun runSafelyWithResult( + runner: () -> T, + onError: (Throwable) -> T, +): T = try { runner() } catch (e: Throwable) { @@ -24,20 +30,22 @@ fun T?.toOptional() = Optional.ofNullable(this) fun T?.toStream(): Stream = Stream.of(this) -fun Optional.doOrElse(present: (T) -> Unit, notThere: () -> Unit) = - this.map { - it to true - }.map { - it.toOptional() - }.orElseGet { - (null to false).toOptional() - }.ifPresent { - if (it.second) { - present(it.first) - } else { - notThere() - } +fun Optional.doOrElse( + present: (T) -> Unit, + notThere: () -> Unit, +) = this.map { + it to true +}.map { + it.toOptional() +}.orElseGet { + (null to false).toOptional() +}.ifPresent { + if (it.second) { + present(it.first) + } else { + notThere() } +} fun InputStream.readAllTheBytes(): ByteArray = IOUtils.toByteArray(this) @@ -46,11 +54,12 @@ interface Logging fun T.logger(): Logger = Logger.getInstance(this::class.java) inline fun T.toArray(): Array = arrayOf(this) + inline fun T.toList(): List = listOf(this) fun allOf( o1: Optional, - o2: Optional + o2: Optional, ): Optional> = o1.flatMap { t -> o2.map { u -> diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/WhenComparator.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/WhenComparator.kt index c34bb16..e5d6abd 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/WhenComparator.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tools/WhenComparator.kt @@ -2,13 +2,16 @@ package io.unthrottled.doki.icons.jetbrains.tools interface WhenComparator { fun test(other: T): Boolean + operator fun contains(other: T) = test(other) } -fun > lt(value: T) = object : WhenComparator { - override fun test(other: T) = other < value -} +fun > lt(value: T) = + object : WhenComparator { + override fun test(other: T) = other < value + } -fun > gt(value: T) = object : WhenComparator { - override fun test(other: T) = other > value -} +fun > gt(value: T) = + object : WhenComparator { + override fun test(other: T) = other > value + } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedFileIconProvider.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedFileIconProvider.kt index ba0e9cf..c033980 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedFileIconProvider.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedFileIconProvider.kt @@ -5,7 +5,6 @@ import io.unthrottled.doki.icons.jetbrains.Constants import javax.swing.Icon object NamedFileIconProvider : IconProvider { - override fun getIcon(virtualFileInfo: VirtualFileInfo): Icon? { return NamedIconMappingLocator.locateMapping(virtualFileInfo) .map { IconLoader.getIcon("${Constants.DOKI_ICONS_BASE_PATH}/${it.iconName}", javaClass) } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedIconMapping.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedIconMapping.kt index ad17e63..b997116 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedIconMapping.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/NamedIconMapping.kt @@ -8,21 +8,21 @@ import io.unthrottled.doki.icons.jetbrains.tools.toOptional import java.util.Optional enum class NamedIconMappings( - val fileName: String + val fileName: String, ) { - FILE("files.named.mappings.json") + FILE("files.named.mappings.json"), } data class SerializedNamedIconMapping( val name: String, val mappingPattern: String, - val iconName: String + val iconName: String, ) data class NamedIconMapping( val name: String, val mappingRegex: Regex, - val iconName: String + val iconName: String, ) object NamedIconMappingLocator { @@ -35,19 +35,18 @@ object NamedIconMappingLocator { } object NamedIconMappingFactory : Logging { - fun create(namedIconMapping: NamedIconMappings): List = AssetTools.readJsonFromResources>( "/", namedIconMapping.fileName, - object : TypeToken>() {}.type + object : TypeToken>() {}.type, ) .map { serializedNamedIconMappings -> serializedNamedIconMappings.map { NamedIconMapping( name = it.name, mappingRegex = Regex(it.mappingPattern), - iconName = it.iconName + iconName = it.iconName, ) } } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/OptimisticNameProvider.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/OptimisticNameProvider.kt index 7631fb0..6a27035 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/OptimisticNameProvider.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/OptimisticNameProvider.kt @@ -4,11 +4,9 @@ import com.intellij.openapi.project.Project import io.unthrottled.doki.icons.jetbrains.tools.toOptional import java.util.Optional -fun Project.nameProvider(): OptimisticNameProvider = - this.getService(OptimisticNameProvider::class.java) - -class OptimisticNameProvider(private val project: Project) { +fun Project.nameProvider(): OptimisticNameProvider = this.getService(OptimisticNameProvider::class.java) +class OptimisticNameProvider() { private val priorityList = SchwiftyList() fun findMapping(fileName: String): Optional { diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyList.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyList.kt index 21c1946..cb7c44e 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyList.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyList.kt @@ -8,9 +8,8 @@ internal class SchwiftyNode( var parent: SchwiftyNode? = null, var child: SchwiftyNode? = null, private val onNewHead: (SchwiftyNode) -> Unit, - private val onNewTail: (SchwiftyNode) -> Unit + private val onNewTail: (SchwiftyNode) -> Unit, ) { - fun bumpPriority() { val myParent = parent if (myParent != null) { @@ -43,7 +42,6 @@ internal class SchwiftyNode( } class SchwiftyList { - private var head: SchwiftyNode? = null private var tail: SchwiftyNode? = null @@ -62,16 +60,17 @@ class SchwiftyList { } fun enqueue(itemToAdd: T): T { - val schwiftyNode = SchwiftyNode( - itemToAdd, - null, - null, - { - this.head = it + val schwiftyNode = + SchwiftyNode( + itemToAdd, + null, + null, + { + this.head = it + }, + ) { + this.tail = it } - ) { - this.tail = it - } val currentTail = tail if (currentTail == null) { head = schwiftyNode diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/TreeNamedIconProvider.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/TreeNamedIconProvider.kt index 845c662..2d1c94f 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/TreeNamedIconProvider.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/TreeNamedIconProvider.kt @@ -11,8 +11,10 @@ import io.unthrottled.doki.icons.jetbrains.tools.toOptional import javax.swing.Icon class TreeNamedIconProvider : IconProvider(), DumbAware { - - override fun getIcon(element: PsiElement, flags: Int): Icon? = + override fun getIcon( + element: PsiElement, + flags: Int, + ): Icon? = when (element) { is PsiDirectory -> getDirectoryIcon(element) is PsiFile -> getFileIcon(element) @@ -28,11 +30,12 @@ class TreeNamedIconProvider : IconProvider(), DumbAware { private fun provideIcon( configOption: Boolean, element: PsiElement, - function: (t: VirtualFileInfo) -> Icon? - ): Icon? = configOption.toOptional() - .filter { it } - .flatMap { PsiUtilCore.getVirtualFile(element).toOptional() } - .map { VirtualFileInfo(element, it) } - .map(function) - .orElseGet { null } + function: (t: VirtualFileInfo) -> Icon?, + ): Icon? = + configOption.toOptional() + .filter { it } + .flatMap { PsiUtilCore.getVirtualFile(element).toOptional() } + .map { VirtualFileInfo(element, it) } + .map(function) + .orElseGet { null } } diff --git a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/VirtualFileInfo.kt b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/VirtualFileInfo.kt index 46ada88..2fc8c08 100644 --- a/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/VirtualFileInfo.kt +++ b/src/main/kotlin/io/unthrottled/doki/icons/jetbrains/tree/VirtualFileInfo.kt @@ -5,7 +5,7 @@ import com.intellij.psi.PsiElement class VirtualFileInfo( val psiElement: PsiElement, - private val virtualFile: VirtualFile + private val virtualFile: VirtualFile, ) { val name: String? get() = virtualFile.name diff --git a/src/test/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyListTest.kt b/src/test/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyListTest.kt index f4eae3c..86c65a2 100644 --- a/src/test/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyListTest.kt +++ b/src/test/kotlin/io/unthrottled/doki/icons/jetbrains/tree/SchwiftyListTest.kt @@ -4,7 +4,6 @@ import org.assertj.core.api.Assertions import org.junit.Test internal class SchwiftyListTest { - @Test fun shouldPreferItemsFound() { val schwiftyList = SchwiftyList() @@ -14,7 +13,7 @@ internal class SchwiftyListTest { it === "Zero Two" }.orElseGet { "Best Girl" - } + }, ).isEqualTo("Best Girl") schwiftyList.enqueue("Ryuko") @@ -27,7 +26,7 @@ internal class SchwiftyListTest { it === "Zero Two" }.orElseGet { "Best Girl" - } + }, ).isEqualTo("Best Girl") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -36,7 +35,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Ryuko" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Ryuko") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -46,7 +45,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Ryuko" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Ryuko") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -55,7 +54,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Kokkoro" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Kokkoro") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -64,7 +63,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Kokkoro" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Kokkoro") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -73,7 +72,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Ryuko" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Ryuko") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -82,7 +81,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Ryuko" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Ryuko") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -91,7 +90,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseGet { "Best Girl" } + }.orElseGet { "Best Girl" }, ).isEqualTo("Best Girl") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -102,7 +101,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(3) predicateCount = 0 @@ -111,7 +110,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -120,7 +119,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -129,7 +128,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Kokkoro" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Kokkoro") Assertions.assertThat(predicateCount).isEqualTo(3) predicateCount = 0 @@ -138,7 +137,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Kokkoro" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Kokkoro") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -147,7 +146,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -156,7 +155,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Kokkoro" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Kokkoro") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -165,7 +164,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Kokkoro" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Kokkoro") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0 @@ -174,7 +173,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Ryuko" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Ryuko") Assertions.assertThat(predicateCount).isEqualTo(3) predicateCount = 0 @@ -183,7 +182,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(3) predicateCount = 0 @@ -192,7 +191,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(2) predicateCount = 0 @@ -201,7 +200,7 @@ internal class SchwiftyListTest { schwiftyList.first { predicateCount++ it === "Zero Two" - }.orElseThrow() + }.orElseThrow(), ).isEqualTo("Zero Two") Assertions.assertThat(predicateCount).isEqualTo(1) predicateCount = 0