Call Hierarchy: Support secondary constructors
This commit is contained in:
@@ -26,10 +26,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import kotlin.Function1;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.JetProperty;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||
|
||||
public class HierarchyUtils {
|
||||
@@ -40,6 +37,7 @@ public class HierarchyUtils {
|
||||
input instanceof PsiClass ||
|
||||
input instanceof JetFile ||
|
||||
input instanceof JetNamedFunction ||
|
||||
input instanceof JetSecondaryConstructor ||
|
||||
input instanceof JetClassOrObject ||
|
||||
input instanceof JetProperty;
|
||||
}
|
||||
|
||||
+6
-6
@@ -36,10 +36,7 @@ import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
@@ -188,7 +185,7 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (element instanceof JetNamedFunction) {
|
||||
else if (element instanceof JetNamedFunction || element instanceof JetSecondaryConstructor) {
|
||||
elementText = renderNamedFunction((FunctionDescriptor) descriptor);
|
||||
}
|
||||
else if (element instanceof JetProperty) {
|
||||
@@ -213,7 +210,10 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
|
||||
}
|
||||
|
||||
private static String renderNamedFunction(FunctionDescriptor descriptor) {
|
||||
String name = descriptor.getName().asString();
|
||||
DeclarationDescriptor descriptorForName = descriptor instanceof ConstructorDescriptor
|
||||
? descriptor.getContainingDeclaration()
|
||||
: descriptor;
|
||||
String name = descriptorForName.getName().asString();
|
||||
String paramTypes = StringUtil.join(
|
||||
descriptor.getValueParameters(),
|
||||
new Function<ValueParameterDescriptor, String>() {
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
<node text="KA.KA() ()" base="true">
|
||||
<node text="KClient ()"/>
|
||||
<node text="KClient.bar() ()"/>
|
||||
<node text="KClient.getBar() ()"/>
|
||||
<node text="KClient ()"/>
|
||||
<node text="JA.JA() ()"/>
|
||||
<node text="JA.newKA() ()"/>
|
||||
<node text="JA ()"/>
|
||||
<node text="JA.JA(Int) ()"/>
|
||||
<node text="JA2 ()"/>
|
||||
</node>
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
open class JA() {
|
||||
open class JA: KA {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
constructor(a: Int): super() {
|
||||
|
||||
}
|
||||
|
||||
public var name: String = KA().getName()
|
||||
|
||||
public open fun newKA(): KA? {
|
||||
return KA()
|
||||
}
|
||||
}
|
||||
|
||||
class JA2: KA() {
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<node text="B.B(String) ()" base="true">
|
||||
<node text="JJ.JJ() ()"/>
|
||||
<node text="JJ.test() ()"/>
|
||||
<node text="B.B() ()"/>
|
||||
<node text="A.A(Int) ()"/>
|
||||
<node text="C ()"/>
|
||||
<node text="test() ()"/>
|
||||
</node>
|
||||
@@ -0,0 +1,23 @@
|
||||
open class B {
|
||||
constructor(): this("") {
|
||||
|
||||
}
|
||||
|
||||
<caret>constructor(s: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class A : B {
|
||||
constructor(a: Int) : super("") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class C: B("") {
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
B("")
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class JJ extends B {
|
||||
JJ() {
|
||||
super("");
|
||||
}
|
||||
|
||||
static void test() {
|
||||
new B("");
|
||||
}
|
||||
}
|
||||
@@ -391,6 +391,12 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
doCallerHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinSecondaryConstructor")
|
||||
public void testKotlinSecondaryConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructor/");
|
||||
doCallerHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinUnresolvedFunction")
|
||||
public void testKotlinUnresolvedFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinUnresolvedFunction/");
|
||||
|
||||
Reference in New Issue
Block a user