diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinStructureViewElement.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinStructureViewElement.kt index 2f3dcebb4a2..41b7517fc75 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinStructureViewElement.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/structureView/KotlinStructureViewElement.kt @@ -72,11 +72,7 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement, } override fun getChildrenBase(): Collection { - return childrenDeclarations.map { KotlinStructureViewElement(it, false) } - } - - private val childrenDeclarations: List - get() = when (element) { + val children = when (element) { is KtFile -> element.declarations is KtClass -> element.getStructureDeclarations() is KtClassOrObject -> element.declarations @@ -84,6 +80,9 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement, else -> emptyList() } + return children.map { KotlinStructureViewElement(it, false) } + } + private fun PsiElement.collectLocalDeclarations(): List { val result = mutableListOf() @@ -103,20 +102,14 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement, private fun isPublic(descriptor: DeclarationDescriptor?) = (descriptor as? DeclarationDescriptorWithVisibility)?.visibility == Visibilities.PUBLIC - private fun countDescriptor(): DeclarationDescriptor? { - if (!(element.isValid && element is KtDeclaration)) { - return null - } - - if (element is KtAnonymousInitializer) { - return null - } - - return runReadAction { + private fun countDescriptor(): DeclarationDescriptor? = when { + !element.isValid -> null + element !is KtDeclaration -> null + element is KtAnonymousInitializer -> null + else -> runReadAction { if (!DumbService.isDumb(element.getProject())) { - return@runReadAction element.resolveToDescriptorIfAny() - } - null + element.resolveToDescriptorIfAny() + } else null } } }