diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java index 4dd7965cdffd..eb4988779fb3 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java @@ -1612,26 +1612,6 @@ public class ControlFlowAnalyzer extends JavaElementVisitor { } } - ConditionChecker checker = ConditionCheckManager.findConditionChecker(resolved); - if (checker != null) { - ValueConstraint[] constraints = getAnyArgConstraints(params); - int checkedParam = checker.getCheckedParameterIndex(); - if (checkedParam >= constraints.length) { - return Collections.emptyList(); - } - - ConditionChecker.Type type = checker.getConditionCheckType(); - if (type == ASSERT_IS_NULL_METHOD || type == ASSERT_IS_NOT_NULL_METHOD) { - constraints[checkedParam] = type == ASSERT_IS_NOT_NULL_METHOD ? ValueConstraint.NULL_VALUE : ValueConstraint.NOT_NULL_VALUE; - return Collections.singletonList(new MethodContract(constraints, ValueConstraint.THROW_EXCEPTION)); - } else if (type == IS_NOT_NULL_METHOD || type == IS_NULL_METHOD) { - constraints[checkedParam] = ValueConstraint.NULL_VALUE; - return Collections.singletonList(new MethodContract(constraints, type == IS_NULL_METHOD ? ValueConstraint.TRUE_VALUE : ValueConstraint.FALSE_VALUE)); - } else { //assertTrue or assertFalse - constraints[checkedParam] = type == ASSERT_FALSE_METHOD ? ValueConstraint.TRUE_VALUE : ValueConstraint.FALSE_VALUE; - return Collections.singletonList(new MethodContract(constraints, ValueConstraint.THROW_EXCEPTION)); - } - } } return Collections.emptyList(); diff --git a/java/java-indexing-impl/src/com/intellij/codeInsight/ConditionCheckManager.java b/java/java-indexing-impl/src/com/intellij/codeInsight/ConditionCheckManager.java index 1fec41cea4e6..df9ca37c0d83 100644 --- a/java/java-indexing-impl/src/com/intellij/codeInsight/ConditionCheckManager.java +++ b/java/java-indexing-impl/src/com/intellij/codeInsight/ConditionCheckManager.java @@ -28,6 +28,7 @@ import java.util.List; /** * @author Johnny Clark * Creation Date: 8/3/12 + * todo remove in IDEA 15 */ @State( name = "ConditionCheckManager", diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java deleted file mode 100644 index e47839622256..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java +++ /dev/null @@ -1,9 +0,0 @@ -class AssertFalse { - void bar() { - final boolean b = call(); - if (Assertions.assertFalse(b)) { - if(b) {} - } - } - boolean call() {return true;} -} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java deleted file mode 100644 index deaf3fdbcdf3..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.lang.*; - -class AssertIsNotNull { - void bar() { - final Object o = call(); - Assertions.assertIsNotNull(o); - if(o == null) {} - } - Object call() {return new Object();} -} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java deleted file mode 100644 index 45d6cdc5b2ca..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.lang.*; - -class AssertIsNull { - void bar() { - final Object o = call(); - Assertions.assertIsNull(o); - if(o == null) {} - } - Object call() {return new Object();} -} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java deleted file mode 100644 index 870da1286648..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java +++ /dev/null @@ -1,9 +0,0 @@ -class AssertTrue { - void bar() { - final boolean b = call(); - if (Assertions.assertTrue(b)) { - if(b) {} - } - } - boolean call() {return true;} -} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java b/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java deleted file mode 100644 index 878c4b3fa423..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java +++ /dev/null @@ -1,16 +0,0 @@ -class IsNotNullCheck { - void bar() { - final Value v = call(); - if (Value.isNotNull(v)) { - if(v == null) {} - } - } - void bar2() { - final Value v = call(); - System.out.println(v.hashCode()); - if (Value.isNotNull(v)) { - - } - } - Value call() {return new Value();} -} diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java b/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java deleted file mode 100644 index c4737b511098..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java +++ /dev/null @@ -1,10 +0,0 @@ -class IsNullCheck { - void bar() { - final Value v = call(); - if (Value.isNull(v)) { - return; - } - if(v == null) {} - } - Value call() {return new Value();} -} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index cf17f95c4289..22407dc7f661 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -16,17 +16,10 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; -import com.intellij.codeInsight.ConditionCheckManager; -import com.intellij.codeInsight.ConditionChecker; import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiMethod; import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; /** * @author peter @@ -205,65 +198,6 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { public void testHonorGetterAnnotation() { doTest(); } - public void testIsNullCheck() throws Exception { - ConditionCheckManager.getInstance(myModule.getProject()).getIsNullCheckMethods().add( - buildConditionChecker("Value", "isNull", ConditionChecker.Type.IS_NULL_METHOD, - "public class Value { public static boolean isNull(Value o) {if (o == null) return true; else return false;} }")); - doTest(); - } - - public void testIsNotNullCheck() throws Exception { - ConditionCheckManager.getInstance(myModule.getProject()).getIsNotNullCheckMethods().add( - buildConditionChecker("Value", "isNotNull", ConditionChecker.Type.IS_NOT_NULL_METHOD, - "public class Value { public static boolean isNotNull(Value o) {if (o == null) return false; else return true;} }")); - doTest(); - } - - public void testAssertTrue() throws Exception { - ConditionCheckManager.getInstance(myModule.getProject()).getAssertTrueMethods().add( - buildConditionChecker("Assertions", "assertTrue", ConditionChecker.Type.ASSERT_TRUE_METHOD, - "public class Assertions { public static boolean assertTrue(boolean b) {if(!b) throw new Exception();} }")); - doTest(); - } - - public void testAssertFalse() throws Exception { - ConditionCheckManager.getInstance(myModule.getProject()).getAssertFalseMethods().add( - buildConditionChecker("Assertions", "assertFalse", ConditionChecker.Type.ASSERT_FALSE_METHOD, - "public class Assertions { public static boolean assertFalse(boolean b) {if(b) throw new Exception();} }")); - doTest(); - } - - public void testAssertIsNull() throws Exception { - ConditionCheckManager.getInstance(myModule.getProject()).getAssertIsNullMethods().add( - buildConditionChecker("Assertions", "assertIsNull", ConditionChecker.Type.ASSERT_IS_NULL_METHOD, - "public class Assertions { public static boolean assertIsNull(Object o) {if(o != null) throw new Exception();} }")); - doTest(); - } - - public void testAssertIsNotNull() throws Exception { - ConditionCheckManager.getInstance(myModule.getProject()).getAssertIsNotNullMethods().add( - buildConditionChecker("Assertions", "assertIsNotNull", ConditionChecker.Type.ASSERT_IS_NOT_NULL_METHOD, - "public class Assertions { public static boolean assertIsNotNull(Object o) {if(o == null) throw new Exception();} }")); - doTest(); - } - - @Nullable - private ConditionChecker buildConditionChecker(String className, String methodName, ConditionChecker.Type type, String classText) - throws IOException { - myFixture.addClass(classText); - PsiClass psiClass = myFixture.findClass(className); - PsiMethod psiMethod = null; - PsiMethod[] methods = psiClass.getMethods(); - for (PsiMethod tempPsiMethod : methods) { - if (tempPsiMethod.getName().equals(methodName)) { - psiMethod = tempPsiMethod; - break; - } - } - assert psiMethod != null; - return new ConditionChecker.FromPsiBuilder(psiMethod, psiMethod.getParameterList().getParameters()[0], type).build(); - } - public void testIgnoreAssertions() { final DataFlowInspection inspection = new DataFlowInspection(); inspection.IGNORE_ASSERT_STATEMENTS = true;