Skip to content

Commit

Permalink
fix(java): make getVisibilityIcon Method internal
Browse files Browse the repository at this point in the history
Signed-off-by: thelooter <[email protected]>
  • Loading branch information
thelooter committed Nov 8, 2024
1 parent e22b020 commit 83b0c18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.intellij.ui.LayeredIcon
import com.intellij.ui.RowIcon
import javax.swing.Icon
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.VisibleForTesting

/** Provides icons for Java classes in the IDE. */
class JavaIconProvider : IconProvider() {
Expand Down Expand Up @@ -101,7 +100,7 @@ class JavaIconProvider : IconProvider() {
* @param psiElement The PsiClass to get the visibility icon for.
* @return The visibility icon based on the class's modifier, or null if not applicable.
*/
private fun getVisibilityIcon(psiElement: PsiClass): Icon? =
internal fun getVisibilityIcon(psiElement: PsiClass): Icon? =
when {
psiElement.hasModifierProperty(PsiModifier.PUBLIC) -> AllIcons.Nodes.Public
psiElement.hasModifierProperty(PsiModifier.PRIVATE) -> AllIcons.Nodes.Private
Expand All @@ -110,10 +109,6 @@ class JavaIconProvider : IconProvider() {
else -> null
}

@VisibleForTesting
internal fun getVisibilityIconForTesting(psiElement: PsiClass): Icon? =
getVisibilityIcon(psiElement)

/**
* Gets the appropriate Java icon based on the class type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ class JavaIconProviderTest : LightJavaCodeInsightFixtureTestCase5() {
.trimIndent(),
)

val icon = runInEdtAndGet {
provider.getVisibilityIconForTesting(fixture.findClass("PublicClass"))
}
val icon = runInEdtAndGet { provider.getVisibilityIcon(fixture.findClass("PublicClass")) }

assertEquals(AllIcons.Nodes.Public, icon)
}
Expand All @@ -302,7 +300,7 @@ class JavaIconProviderTest : LightJavaCodeInsightFixtureTestCase5() {
)

val icon = runInEdtAndGet {
provider.getVisibilityIconForTesting(fixture.findClass("OuterClass.PrivateClass"))
provider.getVisibilityIcon(fixture.findClass("OuterClass.PrivateClass"))
}

assertEquals(AllIcons.Nodes.Private, icon)
Expand All @@ -322,7 +320,7 @@ class JavaIconProviderTest : LightJavaCodeInsightFixtureTestCase5() {
)

val icon = runInEdtAndGet {
provider.getVisibilityIconForTesting(fixture.findClass("OuterClass.ProtectedClass"))
provider.getVisibilityIcon(fixture.findClass("OuterClass.ProtectedClass"))
}

assertEquals(AllIcons.Nodes.Protected, icon)
Expand All @@ -340,7 +338,7 @@ class JavaIconProviderTest : LightJavaCodeInsightFixtureTestCase5() {
)

val icon = runInEdtAndGet {
provider.getVisibilityIconForTesting(fixture.findClass("PackagePrivateClass"))
provider.getVisibilityIcon(fixture.findClass("PackagePrivateClass"))
}

assertEquals(AllIcons.Nodes.PackageLocal, icon)
Expand All @@ -352,7 +350,7 @@ class JavaIconProviderTest : LightJavaCodeInsightFixtureTestCase5() {
// Create a mock PsiClass that returns null for its modifier list
val mockClass = mock<PsiClass> { on { modifierList } doReturn null }

val icon = runInEdtAndGet { provider.getVisibilityIconForTesting(mockClass) }
val icon = runInEdtAndGet { provider.getVisibilityIcon(mockClass) }

assertNull(icon)
}
Expand Down

0 comments on commit 83b0c18

Please sign in to comment.