Show delegated methods when "Show inherited" enabled in file structure view

This commit is contained in:
Nikolay Krasko
2014-05-28 21:59:59 +04:00
parent 582c5874b7
commit be6d68741b
5 changed files with 33 additions and 4 deletions
@@ -20,6 +20,7 @@ import com.intellij.ide.util.treeView.smartTree.TreeElement
import com.intellij.ide.util.InheritedMembersNodeProvider
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
import org.jetbrains.jet.lang.psi.JetDeclaration
import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
import java.util.ArrayList
@@ -47,11 +48,15 @@ public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<Tr
val defaultType = descriptor.getDefaultType()
for (memberDescriptor in defaultType.getMemberScope().getAllDescriptors()) {
if (memberDescriptor !is CallableMemberDescriptor) continue
if (memberDescriptor.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) continue
val superTypeMember = DescriptorToDeclarationUtil.getDeclaration(project, memberDescriptor, context)
if (superTypeMember is NavigatablePsiElement) {
children.add(JetStructureViewElement(superTypeMember, memberDescriptor, true))
when (memberDescriptor.getKind()) {
CallableMemberDescriptor.Kind.FAKE_OVERRIDE,
CallableMemberDescriptor.Kind.DELEGATION -> {
val superTypeMember = DescriptorToDeclarationUtil.getDeclaration(project, memberDescriptor, context)
if (superTypeMember is NavigatablePsiElement) {
children.add(JetStructureViewElement(superTypeMember, memberDescriptor, true))
}
}
}
}
@@ -0,0 +1,9 @@
trait Some {
fun first()
fun second()
}
class ClassSome: Some {
override fun first() {}
override fun second() {}
}
@@ -0,0 +1,7 @@
-InheritedDelegationMethods.kt
-Test
equals(Any?): Boolean location=→Any
first(): Unit location=→Some
hashCode(): Int location=→Any
second(): Unit location=→Some
toString(): String location=→Any
@@ -0,0 +1,3 @@
class Test: Some by ClassSome()
// WITH_INHERITED
@@ -56,6 +56,11 @@ public class KotlinFileStructureTestGenerated extends AbstractKotlinFileStructur
doTest("idea/testData/structureView/fileStructure/EmptyFile.kt");
}
@TestMetadata("InheritedDelegationMethods.kt")
public void testInheritedDelegationMethods() throws Exception {
doTest("idea/testData/structureView/fileStructure/InheritedDelegationMethods.kt");
}
@TestMetadata("InheritedInnerClasses.kt")
public void testInheritedInnerClasses() throws Exception {
doTest("idea/testData/structureView/fileStructure/InheritedInnerClasses.kt");