Skip to content

Commit

Permalink
feat: differentiate Java files by colour and shape
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham committed Sep 9, 2024
1 parent cc1030b commit 0adea49
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Added

- Differentiate Java files (Annotation, Class, Enum, etc.) by colour and shape in the file tree. If you know how to
implement these icons in the rest of the user interface, please reach out to us via the issue tracker or the
Catppuccin discord!

### Changed

### Deprecated
Expand Down
2 changes: 1 addition & 1 deletion generate/vscode-icons
Submodule vscode-icons updated 150 files
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginGroup=com.github.catppuccin.jetbrains_icons
pluginName=Catppuccin Icons
pluginVersion=1.7.0
pluginVersion=1.8.0
pluginSinceBuild=231
pluginUntilBuild=242.*
platformType=IC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ class IconProvider : IconProvider() {
file.accept(object : JavaRecursiveElementVisitor() {
override fun visitClass(aClass: PsiClass) {
when {
aClass.isAnnotationType -> fileType = "JAVA_ANNOTATION"
aClass.isInterface -> fileType = "JAVA_INTERFACE"
aClass.isEnum -> fileType = "JAVA_ENUM"
aClass.isAnnotationType -> fileType = "JAVA_ANNOTATION"
aClass.isRecord -> fileType = "JAVA_RECORD"
PsiClassUtils.isException(aClass) -> fileType = "JAVA_EXCEPTION"
PsiClassUtils.isSealed(aClass) -> fileType = "JAVA_SEALED"
PsiClassUtils.isFinal(aClass) -> fileType = "JAVA_FINAL"
PsiClassUtils.isAbstract(aClass) -> fileType = "JAVA_ABSTRACT"
}
}
Expand All @@ -87,12 +90,15 @@ class IconProvider : IconProvider() {

private fun provideJavaIcons(): Map<String, Icon> {
return mapOf(
"JAVA_INTERFACE" to icons.java_alt_1,
"JAVA_ENUM" to icons.java_alt_3,
"JAVA_ANNOTATION" to icons.java_alt_1,
"JAVA_RECORD" to icons.java_alt_2,
"JAVA_ABSTRACT" to icons.java_alt_1,
"JAVA_CLASS" to icons.java,
"JAVA_ANNOTATION" to icons.java_annotation,
"JAVA_INTERFACE" to icons.java_interface,
"JAVA_ENUM" to icons.java_enum,
"JAVA_RECORD" to icons.java_record,
"JAVA_EXCEPTION" to icons.java_exception,
"JAVA_ABSTRACT" to icons.java_class_abstract,
"JAVA_SEALED" to icons.java_class_sealed,
"JAVA_FINAL" to icons.java_class_final,
"JAVA_CLASS" to icons.java_class,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@ object PsiClassUtils {
fun isAbstract(psiClass: PsiClass): Boolean {
return psiClass.hasModifierProperty(PsiModifier.ABSTRACT)
}

fun isSealed(psiClass: PsiClass): Boolean {
return psiClass.hasModifierProperty(PsiModifier.SEALED)
}

fun isFinal(psiClass: PsiClass): Boolean {
return psiClass.hasModifierProperty(PsiModifier.FINAL)
}

fun isException(psiClass: PsiClass): Boolean {
return psiClass.name!!.endsWith("com.github.catppuccin.jetbrains_icons.test.Exception")
}
}

0 comments on commit 0adea49

Please sign in to comment.