mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IG: consider any reference to super method a call (IDEA-168979)
This commit is contained in:
+26
-2
@@ -426,10 +426,16 @@ public class MethodCallUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClass(PsiClass aClass) {}
|
||||
public void visitClass(PsiClass aClass) {
|
||||
// anonymous and inner classes inside methods are visited to reduce false positives
|
||||
super.visitClass(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLambdaExpression(PsiLambdaExpression expression) {}
|
||||
public void visitLambdaExpression(PsiLambdaExpression expression) {
|
||||
// lambda's are visited to reduce false positives
|
||||
super.visitLambdaExpression(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIfStatement(PsiIfStatement statement) {
|
||||
@@ -452,6 +458,24 @@ public class MethodCallUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
|
||||
if (mySuperCallFound) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression qualifier = expression.getQualifierExpression();
|
||||
if (qualifier instanceof PsiSuperExpression) {
|
||||
final PsiElement target = expression.resolve();
|
||||
if (target instanceof PsiMethod) {
|
||||
if (MethodSignatureUtil.isSuperMethod((PsiMethod)target, myMethod)) {
|
||||
mySuperCallFound = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visitMethodReferenceExpression(expression);
|
||||
}
|
||||
|
||||
boolean isSuperCallFound() {
|
||||
return mySuperCallFound;
|
||||
}
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ class B extends A {
|
||||
}
|
||||
class C extends FinalizeCallsSuperFinalize {
|
||||
@Override
|
||||
protected void <warning descr="Method 'finalize()' does not call 'super.finalize()'">finalize</warning>() {
|
||||
new Object() {
|
||||
protected void <warning descr="Method 'finalize()' does not call 'super.finalize()'">finalize</warning>() throws Throwable {
|
||||
new C() {
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
|
||||
+7
@@ -33,4 +33,11 @@ class D extends C {
|
||||
public void <warning descr="Method 'setUp()' does not call 'super.setUp()'">setUp</warning>() {
|
||||
|
||||
}
|
||||
}
|
||||
class E extends C {
|
||||
@Override
|
||||
public void setUp() {
|
||||
Runnable r = super::setUp;
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+6
@@ -20,4 +20,10 @@ class Suppressed extends TestCase {
|
||||
@SuppressWarnings("SetUpDoesntCallSuperSetUp")
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
}
|
||||
class Lambda extends TestCase {
|
||||
protected void tearDown() throws Exception {
|
||||
Runnable r = () -> { try { super.tearDown(); } catch (Exception e) {} };
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user