Skip to content

Commit

Permalink
Fixed patcher lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unthrottled committed Jul 15, 2024
1 parent 4d1ede7 commit 658d31b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/main/kotlin/io/unthrottled/doki/icon/ColorPatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ private fun buildThemeColorPatcher(themeLookAndFeel: UIThemeLookAndFeelInfo): Sv
val themeLookAndFeelMethods = themeLookAndFeel.javaClass.methods
val themeGetter = themeLookAndFeelMethods.firstOrNull { method -> method.name == "getTheme" }
val theme = themeGetter?.invoke(themeLookAndFeel)
val themeClassMethods = theme?.javaClass?.methods ?: return null
val colorPatcherGetter = themeClassMethods.firstOrNull { method -> method.name == "getColorPatcher" }
val themeClassMethods = theme?.javaClass?.methods
val colorPatcherGetter = themeClassMethods?.firstOrNull { method -> method.name == "getColorPatcher" }
val colorPatcherProvider = colorPatcherGetter?.invoke(theme)
val colorPatcherMethods = colorPatcherProvider?.javaClass?.methods ?: return null
val attr = colorPatcherMethods.firstOrNull { method -> method.name == "attributeForPath" }
val digest = colorPatcherMethods.firstOrNull { method -> method.name == "digest" }
val getAttributeForPath = colorPatcherMethods.firstOrNull { method -> method.name == "attributeForPath" }
val getDigest = colorPatcherMethods.firstOrNull { method -> method.name == "digest" }
return object : SvgElementColorPatcherProvider, Logging {
override fun attributeForPath(path: String): SvgAttributePatcher? =
runSafelyWithResult({
val patcherForPath = attr?.invoke(colorPatcherProvider, path) ?: return@runSafelyWithResult null
val patcherForPath =
getAttributeForPath?.invoke(colorPatcherProvider, path)
?: return@runSafelyWithResult null
val patchColorsMethod =
patcherForPath.javaClass
.methods.firstOrNull { method -> method.name == "patchColors" } ?: return@runSafelyWithResult null
Expand All @@ -54,7 +56,7 @@ private fun buildThemeColorPatcher(themeLookAndFeel: UIThemeLookAndFeelInfo): Sv

override fun digest(): LongArray =
runSafelyWithResult({
digest?.invoke(colorPatcherProvider) as LongArray
getDigest?.invoke(colorPatcherProvider) as LongArray
}) { digestError ->
logger().warn("Unable to get digest", digestError)
longArrayOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ import com.intellij.notification.NotificationListener
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ex.ApplicationInfoEx
import com.intellij.openapi.fileEditor.impl.HTMLEditorProvider
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.util.BuildNumber
import com.intellij.openapi.wm.impl.IdeBackgroundUtil
import com.intellij.ui.ColorUtil
import com.intellij.ui.JBColor
import com.intellij.util.ui.UIUtil
import io.unthrottled.doki.config.ThemeConfig
import io.unthrottled.doki.icon.DokiIcons
import io.unthrottled.doki.promotions.WeebService
import io.unthrottled.doki.themes.Background
import io.unthrottled.doki.themes.DokiTheme
import io.unthrottled.doki.themes.ThemeManager
Expand Down

0 comments on commit 658d31b

Please sign in to comment.