Show delegated methods when "Show inherited" enabled in file structure view
This commit is contained in:
+9
-4
@@ -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
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user