From f995bedf9feac89e44fae6a2d4abbef0e1136476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Guid=C3=A9e?= Date: Sun, 25 Feb 2024 13:50:37 -0500 Subject: [PATCH 1/5] feat: wip support for kotlin filetypes --- gradle.properties | 2 +- .../JavaProjectViewNodeDecorator.kt | 23 +++++++++++++++++++ src/main/resources/META-INF/plugin.xml | 5 ++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt diff --git a/gradle.properties b/gradle.properties index ca9401e..bb03bed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ pluginSinceBuild=231 pluginUntilBuild=241.* platformType=IC platformVersion=2023.1 -platformPlugins= +platformPlugins=org.jetbrains.kotlin javaVersion=17 gradleVersion=7.3.3 kotlin.stdlib.default.dependency=false diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt new file mode 100644 index 0000000..fc0ed4b --- /dev/null +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt @@ -0,0 +1,23 @@ +package com.github.catppuccin.jetbrains_icons.decorators + +import com.intellij.ide.projectView.PresentationData +import com.intellij.ide.projectView.ProjectViewNode +import com.intellij.ide.projectView.ProjectViewNodeDecorator +import org.jetbrains.kotlin.psi.* + +class JavaProjectViewNodeDecorator : ProjectViewNodeDecorator { + override fun decorate(node: ProjectViewNode<*>, data: PresentationData) { + if (node.virtualFile?.isDirectory == true) return + + val value = node.value + when (value) { + is KtClass -> when { + // value.isInterface() -> + // value.isEnum() -> + // value.isAnnotation() -> + // value.isSealed() -> + // else -> + } + } + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index c4e86b3..9b4e1d1 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -31,6 +31,7 @@ For further help, see also:

LICENSE: MIT

]]> com.intellij.modules.platform + org.jetbrains.kotlin + Date: Thu, 16 May 2024 20:48:33 +0200 Subject: [PATCH 2/5] feat(icons): Add Support for different Icons for Different Java Class Types Signed-off-by: thelooter --- generate/vscode-icons | 2 +- .../JavaProjectViewNodeDecorator.kt | 25 +++++++++++++------ .../jetbrains_icons/util/PsiClassUtils.kt | 10 ++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt diff --git a/generate/vscode-icons b/generate/vscode-icons index 9072c43..7bb1fa7 160000 --- a/generate/vscode-icons +++ b/generate/vscode-icons @@ -1 +1 @@ -Subproject commit 9072c437d896dd8d7f4a8063499517ccd44a489e +Subproject commit 7bb1fa75bd737e3fa20a3c900ceb90aaf73a02e2 diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt index fc0ed4b..5840e3b 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt @@ -1,22 +1,31 @@ package com.github.catppuccin.jetbrains_icons.decorators +import com.github.catppuccin.jetbrains_icons.IconPack +import com.github.catppuccin.jetbrains_icons.util.PsiClassUtils import com.intellij.ide.projectView.PresentationData import com.intellij.ide.projectView.ProjectViewNode import com.intellij.ide.projectView.ProjectViewNodeDecorator +import com.intellij.lang.jvm.JvmModifier +import com.intellij.psi.PsiClass +import org.jetbrains.kotlin.idea.codeInsight.SuperDeclaration import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.isAbstract +import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral class JavaProjectViewNodeDecorator : ProjectViewNodeDecorator { override fun decorate(node: ProjectViewNode<*>, data: PresentationData) { if (node.virtualFile?.isDirectory == true) return - val value = node.value - when (value) { - is KtClass -> when { - // value.isInterface() -> - // value.isEnum() -> - // value.isAnnotation() -> - // value.isSealed() -> - // else -> + val icons = IconPack.instance.icons + + when (val value = node.value) { + + is PsiClass -> when { + value.isInterface -> data.setIcon(icons.java_alt_1) + value.isAnnotationType -> data.setIcon(icons.java_alt_1) + value.isEnum -> data.setIcon(icons.java_alt_3) + value.isRecord -> data.setIcon(icons.java_alt_2) + PsiClassUtils.isAbstract(value) -> data.setIcon(icons.java_alt_1) } } } diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt new file mode 100644 index 0000000..a2675b9 --- /dev/null +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt @@ -0,0 +1,10 @@ +package com.github.catppuccin.jetbrains_icons.util + +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiModifier + +object PsiClassUtils { + fun isAbstract(psiClass: PsiClass): Boolean { + return psiClass.hasModifierProperty(PsiModifier.ABSTRACT) + } +} From 259006117cb97d73fb1c50284d9f54cb861f2c49 Mon Sep 17 00:00:00 2001 From: thelooter Date: Thu, 16 May 2024 23:19:37 +0200 Subject: [PATCH 3/5] Add Option to toggle Java icon colors --- .../decorators/JavaProjectViewNodeDecorator.kt | 2 ++ .../catppuccin/jetbrains_icons/settings/PluginSettings.kt | 4 +++- .../jetbrains_icons/settings/PluginSettingsState.kt | 1 + .../settings/views/SettingsAdditionalSupportView.kt | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt index 5840e3b..2792a57 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt @@ -1,6 +1,7 @@ package com.github.catppuccin.jetbrains_icons.decorators import com.github.catppuccin.jetbrains_icons.IconPack +import com.github.catppuccin.jetbrains_icons.settings.PluginSettingsState import com.github.catppuccin.jetbrains_icons.util.PsiClassUtils import com.intellij.ide.projectView.PresentationData import com.intellij.ide.projectView.ProjectViewNode @@ -14,6 +15,7 @@ import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral class JavaProjectViewNodeDecorator : ProjectViewNodeDecorator { override fun decorate(node: ProjectViewNode<*>, data: PresentationData) { + if (!PluginSettingsState.instance.javaSupport) return if (node.virtualFile?.isDirectory == true) return val icons = IconPack.instance.icons diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt index 3f928c3..a95dcd1 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt @@ -26,13 +26,15 @@ class PluginSettings : Configurable { override fun isModified(): Boolean { val state = PluginSettingsState.instance return packChanged() || - component.additionalSupport.python.isSelected != state.pythonSupport + component.additionalSupport.python.isSelected != state.pythonSupport || + component.additionalSupport.java.isSelected != state.javaSupport } override fun apply() { val state = PluginSettingsState.instance state.pythonSupport = component.additionalSupport.python.isSelected + state.javaSupport = component.additionalSupport.java.isSelected if (packChanged()) { state.variant = component.iconPack.variant diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt index addb3bd..401266a 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt @@ -14,6 +14,7 @@ class PluginSettingsState : PersistentStateComponent { var variant = Variant.MOCHA.id var pythonSupport = true + var javaSupport = true companion object { val instance: PluginSettingsState diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt index 3098342..a770cc3 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt @@ -8,11 +8,14 @@ import javax.swing.JPanel class SettingsAdditionalSupportView : JPanel() { val python = JBCheckBox("Python", PluginSettingsState.instance.pythonSupport) + val java = JBCheckBox("Java filetypes", PluginSettingsState.instance.javaSupport) init { val form = FormBuilder.createFormBuilder() .addComponent(python) .addTooltip("Override the Python plugin icons") + .addComponent(java) + .addTooltip("Use multiple different Icons for Java filetypes") .panel add(form) From 0e3fb906fd3214e3603df64755974321b193e278 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 17 May 2024 23:57:25 +0100 Subject: [PATCH 4/5] refactor: add descriptive wording --- .../settings/views/SettingsAdditionalSupportView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt index a770cc3..2d2a7ea 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt @@ -8,14 +8,14 @@ import javax.swing.JPanel class SettingsAdditionalSupportView : JPanel() { val python = JBCheckBox("Python", PluginSettingsState.instance.pythonSupport) - val java = JBCheckBox("Java filetypes", PluginSettingsState.instance.javaSupport) + val java = JBCheckBox("Java Filetypes", PluginSettingsState.instance.javaSupport) init { val form = FormBuilder.createFormBuilder() .addComponent(python) .addTooltip("Override the Python plugin icons") .addComponent(java) - .addTooltip("Use multiple different Icons for Java filetypes") + .addTooltip("Use different colors for Java filetypes (e.g. Class, Interface, Record, etc.)") .panel add(form) From f2f7be10fee9d50b5d5adf4a836dd2b7a6d75afc Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sat, 18 May 2024 00:23:49 +0100 Subject: [PATCH 5/5] docs(CHANGELOG.md): update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa7c6a..e926945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Added +- Different colors for Java filetypes (e.g. `Class`: Red, `Interface`: Green, `Record`: Mauve, `Enum`: + Yellow and `Annotation`: Green) ([#35](https://github.com/catppuccin/jetbrains-icons/pull/35)) +- Ability to disable different colors for Java filetypes in settings panel. ([#35](https://github.com/catppuccin/jetbrains-icons/pull/35)) + ### Changed ### Deprecated