Type Hierarchy: Support Kotlin class constructors
#KT-22925 Fixed #KT-22926 Fixed
This commit is contained in:
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
|||||||
import org.jetbrains.kotlin.idea.util.module
|
import org.jetbrains.kotlin.idea.util.module
|
||||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
|
import org.jetbrains.kotlin.psi.KtConstructor
|
||||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
@@ -66,6 +67,7 @@ class KotlinTypeHierarchyProvider : JavaTypeHierarchyProvider() {
|
|||||||
|
|
||||||
return when (target) {
|
return when (target) {
|
||||||
is PsiClass -> target
|
is PsiClass -> target
|
||||||
|
is KtConstructor<*> -> getOriginalPsiClassOrCreateLightClass(target.getContainingClassOrObject(), module)
|
||||||
is KtClassOrObject -> getOriginalPsiClassOrCreateLightClass(target, module)
|
is KtClassOrObject -> getOriginalPsiClassOrCreateLightClass(target, module)
|
||||||
is KtNamedFunction -> { // Factory methods
|
is KtNamedFunction -> { // Factory methods
|
||||||
val functionName = target.name
|
val functionName = target.name
|
||||||
|
|||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<node text="A ()" base="true">
|
||||||
|
<node text="B ()" />
|
||||||
|
<node text="C ()" />
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
open class A constructor(a: Int)
|
||||||
|
|
||||||
|
class B: A<caret>(1)
|
||||||
|
class C: A(1)
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<node text="A ()" base="true">
|
||||||
|
<node text="B ()" />
|
||||||
|
<node text="C ()" />
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
open class A constructor(a: Int)
|
||||||
|
|
||||||
|
class B: <caret>A(1)
|
||||||
|
class C: A(1)
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<node text="A ()" base="true">
|
||||||
|
<node text="B ()" />
|
||||||
|
<node text="C ()" />
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
open class A {
|
||||||
|
constructor(a: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B: A<caret>(1)
|
||||||
|
class C: A(1)
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<node text="A ()" base="true">
|
||||||
|
<node text="B ()" />
|
||||||
|
<node text="C ()" />
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
open class A {
|
||||||
|
constructor(a: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B: <caret>A(1)
|
||||||
|
class C: A(1)
|
||||||
@@ -267,6 +267,18 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
|||||||
doSubClassHierarchyTest(fileName);
|
doSubClassHierarchyTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ConstructorCallCaretAfter")
|
||||||
|
public void testConstructorCallCaretAfter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/ConstructorCallCaretAfter/");
|
||||||
|
doSubClassHierarchyTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ConstructorCallCaretBefore")
|
||||||
|
public void testConstructorCallCaretBefore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/ConstructorCallCaretBefore/");
|
||||||
|
doSubClassHierarchyTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("MultiTypeAlias")
|
@TestMetadata("MultiTypeAlias")
|
||||||
public void testMultiTypeAlias() throws Exception {
|
public void testMultiTypeAlias() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/MultiTypeAlias/");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/MultiTypeAlias/");
|
||||||
@@ -285,6 +297,18 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
|||||||
doSubClassHierarchyTest(fileName);
|
doSubClassHierarchyTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondaryConstructorCallCaretAfter")
|
||||||
|
public void testSecondaryConstructorCallCaretAfter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/SecondaryConstructorCallCaretAfter/");
|
||||||
|
doSubClassHierarchyTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondaryConstructorCallCaretBefore")
|
||||||
|
public void testSecondaryConstructorCallCaretBefore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/SecondaryConstructorCallCaretBefore/");
|
||||||
|
doSubClassHierarchyTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TraitFromClass")
|
@TestMetadata("TraitFromClass")
|
||||||
public void testTraitFromClass() throws Exception {
|
public void testTraitFromClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/TraitFromClass/");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/class/sub/TraitFromClass/");
|
||||||
|
|||||||
Reference in New Issue
Block a user