mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-175510 "Constant conditions & exceptions" inspection provides non-sensical quick fix in some cases
This commit is contained in:
+1
@@ -293,6 +293,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
}
|
||||
|
||||
private static boolean isNullLiteral(PsiExpression qualifier) {
|
||||
if (qualifier instanceof PsiTypeCastExpression) return isNullLiteral(((PsiTypeCastExpression)qualifier).getOperand());
|
||||
return qualifier instanceof PsiLiteralExpression && ((PsiLiteralExpression)qualifier).getValue() == null;
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Foo {
|
||||
void main() {
|
||||
foo(<warning descr="Argument '(String) null' might be null">(String) nu<caret>ll</warning>);
|
||||
}
|
||||
|
||||
static void foo(@NotNull String s) {}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiField;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -524,4 +525,9 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoNonSensicalFixesOnCastedNull() {
|
||||
doTest();
|
||||
assertEmpty(ContainerUtil.findAll(myFixture.getAvailableIntentions(), i -> i.getText().contains("null")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user