mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not mark methods as always inverted when they are used as method references (IDEA-133555)
This commit is contained in:
+8
@@ -77,6 +77,14 @@ public class BooleanMethodIsAlwaysInvertedInspectionBase extends GlobalJavaBatch
|
||||
refMethod.putUserData(ALWAYS_INVERTED, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
|
||||
super.visitMethodReferenceExpression(expression);
|
||||
if (expression.isReferenceTo(psiElement)) {
|
||||
refMethod.putUserData(ALWAYS_INVERTED, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
{
|
||||
I ii = this::isFoo;
|
||||
if (!isFoo());
|
||||
}
|
||||
|
||||
boolean isFoo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
interface I {
|
||||
boolean i();
|
||||
}
|
||||
}
|
||||
+15
@@ -1,5 +1,8 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.intellij.codeInspection.booleanIsAlwaysInverted.BooleanMethodIsAlwaysInvertedInspection;
|
||||
|
||||
@@ -61,6 +64,18 @@ public class BooleanMethodInvertedTest extends IGInspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodReferenceIgnored() throws Exception {
|
||||
final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject());
|
||||
final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
|
||||
try {
|
||||
projectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
projectExtension.setLanguageLevel(oldLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user