Skip to content

Commit e7019a9

Browse files
committed
feat: update icons
1 parent 3660a11 commit e7019a9

File tree

9 files changed

+77
-34
lines changed

9 files changed

+77
-34
lines changed

src/main/kotlin/com/github/xepozz/testo/TestoIcons.kt

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,60 @@ object TestoIcons {
1414
object PHP {
1515
@JvmField
1616
val FILE = IconLoader.getIcon("/icons/php/file.svg", this::class.java)
17+
1718
@JvmField
1819
val CLASS = IconLoader.getIcon("/icons/php/class.svg", this::class.java)
20+
1921
@JvmField
2022
val CLASS_ABSTRACT = IconLoader.getIcon("/icons/php/classAbstract.svg", this::class.java)
21-
}
2223

23-
val TEST_FILE = LayeredIcon.layeredIcon {
24-
arrayOf(
25-
PHP.FILE,
26-
AllIcons.Nodes.JunitTestMark,
27-
)
28-
}
29-
val FINAL_TESTO_CLASS = LayeredIcon.layeredIcon {
30-
arrayOf(
31-
PHP.CLASS,
32-
AllIcons.Nodes.FinalMark,
33-
AllIcons.Nodes.JunitTestMark,
34-
)
24+
@JvmField
25+
val FUNCTION = IconLoader.getIcon("/icons/php/function.svg", this::class.java)
3526
}
36-
val ABSTRACT_TESTO_CLASS = LayeredIcon.layeredIcon {
37-
arrayOf(
38-
PHP.CLASS_ABSTRACT,
39-
AllIcons.Nodes.JunitTestMark,
40-
)
27+
28+
object Layered {
29+
@JvmField
30+
val FILE = LayeredIcon.layeredIcon {
31+
arrayOf(
32+
PHP.FILE,
33+
AllIcons.Nodes.JunitTestMark,
34+
)
35+
}
36+
37+
@JvmField
38+
val FUNCTION = LayeredIcon.layeredIcon {
39+
arrayOf(
40+
PHP.FUNCTION,
41+
AllIcons.Nodes.JunitTestMark,
42+
)
43+
}
44+
45+
object Class {
46+
@JvmField
47+
val CLASS = LayeredIcon.layeredIcon {
48+
arrayOf(
49+
PHP.CLASS,
50+
AllIcons.Nodes.JunitTestMark,
51+
)
52+
}
53+
54+
@JvmField
55+
val CLASS_FINAL = LayeredIcon.layeredIcon {
56+
arrayOf(
57+
PHP.CLASS,
58+
AllIcons.Nodes.FinalMark,
59+
AllIcons.Nodes.JunitTestMark,
60+
)
61+
}
62+
63+
@JvmField
64+
val CLASS_ABSTRACT = LayeredIcon.layeredIcon {
65+
arrayOf(
66+
PHP.CLASS_ABSTRACT,
67+
AllIcons.Nodes.JunitTestMark,
68+
)
69+
}
70+
}
4171
}
72+
4273
}

src/main/kotlin/com/github/xepozz/testo/mixin.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ fun PsiElement.isTestoClass() = when (this) {
2121
}
2222

2323
fun PsiFile.isTestoFile() = when (this) {
24-
is PhpFile -> name.endsWith("Test") ||
25-
PsiTreeUtil.findChildrenOfType(this, PhpClass::class.java)
26-
.any { it.isTestoClass() } ||
27-
PsiTreeUtil.findChildrenOfType(this, Function::class.java)
28-
.any { it.isTestoMethod() }
29-
24+
is PhpFile -> name.endsWith("Test") || isTestoClassFile() || isTestoFunctionFile()
3025
else -> false
3126
}
3227

28+
fun PhpFile.isTestoClassFile() = PsiTreeUtil.findChildrenOfType(this, PhpClass::class.java)
29+
.any { it.isTestoClass() }
30+
31+
fun PhpFile.isTestoFunctionFile() = PsiTreeUtil.findChildrenOfType(this, Function::class.java)
32+
.any { it.isTestoMethod() }
33+
3334
fun <T> Sequence<T>.takeWhileInclusive(predicate: (T) -> Boolean) = sequence {
3435
with(iterator()) {
3536
while (hasNext()) {

src/main/kotlin/com/github/xepozz/testo/ui/TestoIconProvider.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class TestoIconProvider : IconProvider() {
1616

1717
if (!phpFile.isTestoFile()) return null
1818

19-
val phpClass = PsiTreeUtil.findChildOfType(phpFile, PhpClass::class.java)
19+
val phpClasses = PsiTreeUtil.findChildrenOfType(phpFile, PhpClass::class.java)
2020

2121
return when {
22-
phpClass == null -> TestoIcons.TEST_FILE
23-
phpClass.modifier.isAbstract -> TestoIcons.ABSTRACT_TESTO_CLASS
24-
phpClass.modifier.isFinal -> TestoIcons.FINAL_TESTO_CLASS
25-
else -> TestoIcons.TEST_FILE
22+
phpClasses.isEmpty() -> TestoIcons.Layered.FUNCTION
23+
phpClasses.size > 1 -> TestoIcons.Layered.FILE
24+
phpClasses.first().modifier.isAbstract -> TestoIcons.Layered.Class.CLASS_ABSTRACT
25+
phpClasses.first().modifier.isFinal -> TestoIcons.Layered.Class.CLASS_FINAL
26+
else -> TestoIcons.Layered.Class.CLASS
2627
}
2728
}
2829
}
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 2 additions & 1 deletion
Loading
Lines changed: 3 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)