Collect local declarations under properties (KT-14215); improve presentation of object declarations

#KT-14215 Fixed
This commit is contained in:
Dmitry Jemerov
2016-11-18 12:11:55 +01:00
parent 45077023bb
commit f4ce63f6d7
6 changed files with 39 additions and 2 deletions
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.KotlinDescriptorIconProvider
import org.jetbrains.kotlin.psi.KtAnonymousInitializer
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.psi.KtObjectDeclaration
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.renderer.DescriptorRenderer.Companion.ONLY_NAMES_WITH_SHORT_TYPES
import org.jetbrains.kotlin.resolve.DescriptorUtils.getAllOverriddenDeclarations
@@ -82,6 +83,10 @@ internal class KotlinStructureElementPresentation(
}
private fun getElementText(navigatablePsiElement: NavigatablePsiElement, descriptor: DeclarationDescriptor?): String? {
if (navigatablePsiElement is KtObjectDeclaration && navigatablePsiElement.isObjectLiteral()) {
return "object" + (navigatablePsiElement.getSuperTypeList()?.text?.let { " : $it" } ?: "")
}
if (descriptor != null) {
return ONLY_NAMES_WITH_SHORT_TYPES.render(descriptor)
}
@@ -90,7 +90,7 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
is KtFile -> element.declarations
is KtClass -> element.getStructureDeclarations()
is KtClassOrObject -> element.declarations
is KtFunction, is KtClassInitializer -> element.collectLocalDeclarations()
is KtFunction, is KtClassInitializer, is KtProperty -> element.collectLocalDeclarations()
else -> emptyList()
}