mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add instantiating point of the anonymous class as call point only if anonymous class is immediately passed as argument (IDEA-140031)
(cherry picked from commit 08f7813)
This commit is contained in:
@@ -49,14 +49,18 @@ public final class CallerMethodsTreeStructure extends HierarchyTreeStructure {
|
||||
PsiMember enclosingElement = ((CallHierarchyNodeDescriptor)descriptor).getEnclosingElement();
|
||||
HierarchyNodeDescriptor nodeDescriptor = getBaseDescriptor();
|
||||
|
||||
if (isLocalOrAnonymousClass(enclosingElement)) {
|
||||
enclosingElement = CallHierarchyNodeDescriptor.getEnclosingElement(enclosingElement.getParent());
|
||||
} else if (enclosingElement instanceof PsiMethod) {
|
||||
if (enclosingElement instanceof PsiMethod) {
|
||||
PsiClass clazz = enclosingElement.getContainingClass();
|
||||
if (isLocalOrAnonymousClass(clazz)) {
|
||||
enclosingElement = CallHierarchyNodeDescriptor.getEnclosingElement(clazz.getParent());
|
||||
PsiElement parent = clazz.getParent();
|
||||
PsiElement grandParent = parent instanceof PsiNewExpression ? parent.getParent() : null;
|
||||
if (grandParent instanceof PsiExpressionList) {
|
||||
// for created anonymous class that immediately passed as argument use instantiation point as next call point (IDEA-73312)
|
||||
enclosingElement = CallHierarchyNodeDescriptor.getEnclosingElement(grandParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(enclosingElement instanceof PsiMethod) || nodeDescriptor == null) {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
abstract class A {
|
||||
A(int a) {}
|
||||
|
||||
abstract void g();
|
||||
|
||||
void h() {
|
||||
f();
|
||||
}
|
||||
|
||||
void f() {
|
||||
A x = new A(42) {
|
||||
void g() {}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<node text="A.A(int) ()" base="true">
|
||||
<node text="Anonymous in f() in A ()">
|
||||
<node text="A.h() ()"/>
|
||||
</node>
|
||||
</node>
|
||||
@@ -57,10 +57,6 @@ public class JavaCallHierarchyTest extends HierarchyViewTestBase {
|
||||
doJavaCallTypeHierarchyTest("A", "main", "B.java", "A.java");
|
||||
}
|
||||
|
||||
public void testAnonymous() throws Exception {
|
||||
doJavaCallTypeHierarchyTest("A", "A", "A.java");
|
||||
}
|
||||
|
||||
public void testAnonymous2() throws Exception {
|
||||
doJavaCallTypeHierarchyTest("A", "doIt", "A.java");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user