Minor: inline method in KotlinStructureViewElement and rewrite with when
This commit is contained in:
+11
-18
@@ -72,11 +72,7 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getChildrenBase(): Collection<StructureViewTreeElement> {
|
override fun getChildrenBase(): Collection<StructureViewTreeElement> {
|
||||||
return childrenDeclarations.map { KotlinStructureViewElement(it, false) }
|
val children = when (element) {
|
||||||
}
|
|
||||||
|
|
||||||
private val childrenDeclarations: List<KtDeclaration>
|
|
||||||
get() = when (element) {
|
|
||||||
is KtFile -> element.declarations
|
is KtFile -> element.declarations
|
||||||
is KtClass -> element.getStructureDeclarations()
|
is KtClass -> element.getStructureDeclarations()
|
||||||
is KtClassOrObject -> element.declarations
|
is KtClassOrObject -> element.declarations
|
||||||
@@ -84,6 +80,9 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
|||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return children.map { KotlinStructureViewElement(it, false) }
|
||||||
|
}
|
||||||
|
|
||||||
private fun PsiElement.collectLocalDeclarations(): List<KtDeclaration> {
|
private fun PsiElement.collectLocalDeclarations(): List<KtDeclaration> {
|
||||||
val result = mutableListOf<KtDeclaration>()
|
val result = mutableListOf<KtDeclaration>()
|
||||||
|
|
||||||
@@ -103,20 +102,14 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
|||||||
private fun isPublic(descriptor: DeclarationDescriptor?) =
|
private fun isPublic(descriptor: DeclarationDescriptor?) =
|
||||||
(descriptor as? DeclarationDescriptorWithVisibility)?.visibility == Visibilities.PUBLIC
|
(descriptor as? DeclarationDescriptorWithVisibility)?.visibility == Visibilities.PUBLIC
|
||||||
|
|
||||||
private fun countDescriptor(): DeclarationDescriptor? {
|
private fun countDescriptor(): DeclarationDescriptor? = when {
|
||||||
if (!(element.isValid && element is KtDeclaration)) {
|
!element.isValid -> null
|
||||||
return null
|
element !is KtDeclaration -> null
|
||||||
}
|
element is KtAnonymousInitializer -> null
|
||||||
|
else -> runReadAction {
|
||||||
if (element is KtAnonymousInitializer) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return runReadAction {
|
|
||||||
if (!DumbService.isDumb(element.getProject())) {
|
if (!DumbService.isDumb(element.getProject())) {
|
||||||
return@runReadAction element.resolveToDescriptorIfAny()
|
element.resolveToDescriptorIfAny()
|
||||||
}
|
} else null
|
||||||
null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user