show icon of class initializer
#KT-11775 Fixed
This commit is contained in:
@@ -23,8 +23,8 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.ui.RowIcon
|
||||
import com.intellij.util.PlatformIcons
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.KtLightClassForDecompiledDeclaration
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -40,7 +40,7 @@ class KotlinIconProvider : IconProvider(), DumbAware {
|
||||
}
|
||||
|
||||
val result = psiElement.getBaseIcon()
|
||||
if (flags and Iconable.ICON_FLAG_VISIBILITY > 0 && result != null && psiElement is KtModifierListOwner) {
|
||||
if (flags and Iconable.ICON_FLAG_VISIBILITY > 0 && result != null && (psiElement is KtModifierListOwner && psiElement !is KtClassInitializer)) {
|
||||
val list = psiElement.modifierList
|
||||
return createRowIcon(result, getVisibilityIcon(list))
|
||||
}
|
||||
@@ -114,6 +114,7 @@ class KotlinIconProvider : IconProvider(), DumbAware {
|
||||
KotlinIcons.PARAMETER
|
||||
}
|
||||
is KtProperty -> if (isVar) KotlinIcons.FIELD_VAR else KotlinIcons.FIELD_VAL
|
||||
is KtClassInitializer -> KotlinIcons.CLASS_INITIALIZER
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public interface KotlinIcons {
|
||||
Icon PARAMETER = PlatformIcons.PARAMETER_ICON;
|
||||
Icon FIELD_VAL = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/field_value.png");
|
||||
Icon FIELD_VAR = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/field_variable.png");
|
||||
Icon CLASS_INITIALIZER = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/classInitializerKotlin.png");
|
||||
|
||||
Icon LAUNCH = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin_launch_configuration.png");
|
||||
}
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@ import com.intellij.navigation.ItemPresentation
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.ui.Queryable
|
||||
import com.intellij.psi.NavigatablePsiElement
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
@@ -89,11 +90,11 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
||||
is KtFile -> element.declarations
|
||||
is KtClass -> element.getPrimaryConstructorParameters().filter { it.hasValOrVar() } + element.declarations
|
||||
is KtClassOrObject -> element.declarations
|
||||
is KtFunction -> element.collectLocalDeclarations()
|
||||
is KtFunction, is KtClassInitializer -> element.collectLocalDeclarations()
|
||||
else -> emptyList()
|
||||
}
|
||||
|
||||
private fun KtFunction.collectLocalDeclarations(): List<KtDeclaration> {
|
||||
private fun PsiElement.collectLocalDeclarations(): List<KtDeclaration> {
|
||||
val result = mutableListOf<KtDeclaration>()
|
||||
|
||||
acceptChildren(object : KtTreeVisitorVoid() {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -2,4 +2,6 @@
|
||||
-foo(): Unit
|
||||
bar(): Unit
|
||||
-X
|
||||
-<class initializer>
|
||||
quux(): Unit
|
||||
xyzzy(): Unit
|
||||
|
||||
@@ -2,6 +2,11 @@ fun foo() {
|
||||
fun bar() { }
|
||||
|
||||
class X {
|
||||
init {
|
||||
fun quux() {
|
||||
}
|
||||
}
|
||||
|
||||
fun xyzzy() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user