diff --git a/java/java-tests/testData/inspection/dataFlow/TryWithResources.java b/java/java-tests/testData/inspection/dataFlow/TryWithResources.java
new file mode 100644
index 000000000000..267e4ca45caf
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/TryWithResources.java
@@ -0,0 +1,49 @@
+import java.lang.Exception;
+
+class Test {
+ static class MyResource implements AutoCloseable {
+ @Override public void close() { }
+ }
+
+ interface MyResourceProvider {
+ MyResource getResource();
+ }
+
+ void m1() throws Exception {
+ MyResourceProvider provider = null;
+ try (MyResource r = provider.getResource()) {
+ System.out.println(r);
+ }
+ }
+
+ void m2() {
+ try (MyResource r = null) {
+ System.out.println(r);
+ }
+ }
+
+ /*static class ResourcefulException1 extends Exception { }
+ static class ResourcefulException2 extends Exception { }
+
+ static class ExceptionalResource implements AutoCloseable {
+ @Override public void close() throws ResourcefulException1 { }
+ }
+
+ ExceptionalResource provideExceptionalResource() throws ResourcefulException2 {
+ return new ExceptionalResource();
+ }
+
+ void m3() {
+ try (ExceptionalResource r = provideExceptionalResource()) {
+ System.out.println(r);
+ }
+ catch (Exception e) {
+ if (e instanceof ResourcefulException1) {
+ System.out.println("1");
+ }
+ else if (e instanceof ResourcefulException2) {
+ System.out.println("2");
+ }
+ }
+ }*/
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/tryWithResources/expected.xml b/java/java-tests/testData/inspection/dataFlow/tryWithResources/expected.xml
deleted file mode 100644
index a0ef40c50007..000000000000
--- a/java/java-tests/testData/inspection/dataFlow/tryWithResources/expected.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- Test.java
- 12
- Method invocation <code>provider.getResource()</code> may produce <code>java.lang.NullPointerException</code>
-
-
diff --git a/java/java-tests/testData/inspection/dataFlow/tryWithResources/src/Test.java b/java/java-tests/testData/inspection/dataFlow/tryWithResources/src/Test.java
deleted file mode 100644
index 5045d8774868..000000000000
--- a/java/java-tests/testData/inspection/dataFlow/tryWithResources/src/Test.java
+++ /dev/null
@@ -1,22 +0,0 @@
-class Test {
- static class MyResource implements AutoCloseable {
- @Override public void close() { }
- }
-
- interface MyResourceProvider {
- MyResource getResource();
- }
-
- void m1() throws Exception {
- MyResourceProvider provider = null;
- try (MyResource r = provider.getResource()) {
- System.out.println(r);
- }
- }
-
- void m2() {
- try (MyResource r = null) {
- System.out.println(r);
- }
- }
-}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java
new file mode 100644
index 000000000000..583ccd54032c
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.JavaTestUtil;
+import com.intellij.codeInspection.dataFlow.DataFlowInspection;
+import com.intellij.testFramework.InspectionTestCase;
+
+/**
+ * @author max
+ * @since Apr 11, 2002
+ */
+public class DataFlowInspectionAncientTest extends InspectionTestCase {
+ @Override
+ protected String getTestDataPath() {
+ return JavaTestUtil.getJavaTestDataPath() + "/inspection";
+ }
+
+ private void doTest() {
+ doTest(false);
+ }
+ private void doTest(boolean lowercase) {
+ doTest("dataFlow/" + getTestName(lowercase), new DataFlowInspection());
+ }
+
+ private void doTest15() {
+ doTest15(false);
+ }
+ private void doTest15(boolean lowercase) {
+ doTest("dataFlow/" + getTestName(lowercase), new DataFlowInspection(), "java 1.5");
+ }
+
+ public void testNpe1() { doTest(true); }
+ public void testCaseAndNpe() { doTest(true); }
+ public void testCce() { doTest(true); }
+ public void testExceptionCFG() { doTest(true); }
+ public void testInst() { doTest(true); }
+ public void testWrongEqualTypes() { doTest(true); }
+ public void testSCR13702() { doTest(); }
+ public void testSCR13626() { doTest(); }
+ public void testSCR13871() { doTest(); }
+ public void testInstanceof() { doTest(); }
+ public void testOrBug() { doTest(true); }
+ public void testSCR14819() { doTest(); }
+ public void testSCR14314() { doTest(); }
+ public void testSCR15162() { doTest(); }
+ public void testCatchParameterCantBeNull() { doTest(); }
+ public void testXor() { doTest(true); }
+ public void testGenericInstanceof() { doTest(); }
+ public void testThisInstanceof() { doTest(true); }
+ public void testAndEq() { doTest(true); }
+ public void testNullableField() { doTest(true); }
+ public void testSCR39950() { doTest(); }
+ public void testScrIDEA1() { doTest(true); }
+ public void testSCR18186() { doTest(); }
+ public void testConstantExpr() { doTest(true); }
+ public void testIDEADEV74518() { doTest(); }
+ public void testIDEADEV74518_2() { doTest(); }
+ public void testIDEADEV77819() { doTest(); }
+ public void testIDEADEV78370() { doTest(); }
+ public void testRegressionByPti() { doTest(); }
+
+ public void testNotNullable() { doTest15(); }
+ public void testNotNullableParameter() { doTest15(); }
+ public void testNotNullableParameter2() { doTest15(); }
+ public void testNullable() { doTest15(); }
+ public void testNullableThroughCast() { doTest15(); }
+ public void testNullableProblemThroughCast() { doTest15(); }
+ public void testNullableThroughVariable() { doTest15(); }
+ public void testNullableThroughVariableShouldNotBeReported() { doTest15(); }
+ public void testNullableAssignment() { doTest15(); }
+ public void testNullableLocalVariable() { doTest15(); }
+ public void testNotNullLocalVariable() { doTest15(); }
+ public void testNullableReturn() { doTest15(); }
+ public void testNullableReturn1() { doTest15(); }
+ public void testFinalFields() { doTest15(true); }
+ public void testNotNullArray() { doTest15(); }
+ public void testFieldsFlashing() { doTest15(); }
+ public void testConditionFalseAndNPE() { doTest15(); }
+ public void testIDEADEV1575() { doTest15(); }
+ public void testAlexBug() { doTest15(); }
+ public void testYoleBug() { doTest15(); }
+ public void testForeachFlow() { doTest15(); }
+ public void testForEachNPE() { doTest15(); }
+ public void testArrayAccessNPE() { doTest15(); }
+ public void testArrayAccessDoesntCancelAnalysis() { doTest15(); }
+ public void testCompileTimeConst() { doTest15(true); }
+ public void testAutoboxing() { doTest15(true); }
+ public void testUnboxingNPE() { doTest15(true); }
+ public void testStrangeArrayIndexOutOfBounds() { doTest15(); }
+ public void testIDEADEV2605() { doTest15(); }
+ public void testConstantsDifferentTypes() { doTest15(); }
+ public void testBoxingNaN() { doTest15(); }
+ public void testBoxingBoolean() { doTest15(true); }
+ public void testCheckedExceptionDominance() { doTest15(); }
+ public void testIDEADEV10489() { doTest15(); }
+ public void testPlusOnStrings() { doTest15(); }
+ public void testSwitchQualifierProducesNPE() {doTest15(); }
+ public void testIDEADEV15583() {doTest15(); }
+ public void testIDEADEV13153() { doTest15(); }
+ public void testIDEADEV13156() { doTest15(); }
+ public void testSwitchEnumCases() { doTest15(); }
+
+ public void testSCR15406() { doTest(); }
+ //public void testIDEADEV11033() { doTest15(); } // added by max, 2007
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index b34f307b7b06..84c794c90758 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -15,106 +15,21 @@
*/
package com.intellij.codeInspection;
-import com.intellij.JavaTestUtil;
+import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
-import com.intellij.testFramework.InspectionTestCase;
+import org.jetbrains.annotations.NonNls;
-/**
- * @author max
- * @since Apr 11, 2002
- */
-public class DataFlowInspectionTest extends InspectionTestCase {
- @Override
- protected String getTestDataPath() {
- return JavaTestUtil.getJavaTestDataPath() + "/inspection";
- }
+public class DataFlowInspectionTest extends LightDaemonAnalyzerTestCase {
+ @NonNls static final String BASE_PATH = "/inspection/dataFlow";
private void doTest() {
- doTest(false);
- }
- private void doTest(boolean lowercase) {
- doTest("dataFlow/" + getTestName(lowercase), new DataFlowInspection());
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
}
- private void doTest15() {
- doTest15(false);
- }
- private void doTest15(boolean lowercase) {
- doTest("dataFlow/" + getTestName(lowercase), new DataFlowInspection(), "java 1.5");
+ @Override
+ protected LocalInspectionTool[] configureLocalInspectionTools() {
+ return new LocalInspectionTool[]{new DataFlowInspection()};
}
- public void testNpe1() { doTest(true); }
- public void testCaseAndNpe() { doTest(true); }
- public void testCce() { doTest(true); }
- public void testExceptionCFG() { doTest(true); }
- public void testInst() { doTest(true); }
- public void testWrongEqualTypes() { doTest(true); }
- public void testSCR13702() { doTest(); }
- public void testSCR13626() { doTest(); }
- public void testSCR13871() { doTest(); }
- public void testInstanceof() { doTest(); }
- public void testOrBug() { doTest(true); }
- public void testSCR14819() { doTest(); }
- public void testSCR14314() { doTest(); }
- public void testSCR15162() { doTest(); }
- public void testCatchParameterCantBeNull() { doTest(); }
- public void testXor() { doTest(true); }
- public void testGenericInstanceof() { doTest(); }
- public void testThisInstanceof() { doTest(true); }
- public void testAndEq() { doTest(true); }
- public void testNullableField() { doTest(true); }
- public void testSCR39950() { doTest(); }
- public void testScrIDEA1() { doTest(true); }
- public void testSCR18186() { doTest(); }
- public void testConstantExpr() { doTest(true); }
- public void testIDEADEV74518() { doTest(); }
- public void testIDEADEV74518_2() { doTest(); }
- public void testIDEADEV77819() { doTest(); }
- public void testIDEADEV78370() { doTest(); }
- public void testRegressionByPti() { doTest(); }
-
- public void testNotNullable() { doTest15(); }
- public void testNotNullableParameter() { doTest15(); }
- public void testNotNullableParameter2() { doTest15(); }
- public void testNullable() { doTest15(); }
- public void testNullableThroughCast() { doTest15(); }
- public void testNullableProblemThroughCast() { doTest15(); }
- public void testNullableThroughVariable() { doTest15(); }
- public void testNullableThroughVariableShouldNotBeReported() { doTest15(); }
- public void testNullableAssignment() { doTest15(); }
- public void testNullableLocalVariable() { doTest15(); }
- public void testNotNullLocalVariable() { doTest15(); }
- public void testNullableReturn() { doTest15(); }
- public void testNullableReturn1() { doTest15(); }
- public void testFinalFields() { doTest15(true); }
- public void testNotNullArray() { doTest15(); }
- public void testFieldsFlashing() { doTest15(); }
- public void testConditionFalseAndNPE() { doTest15(); }
- public void testIDEADEV1575() { doTest15(); }
- public void testAlexBug() { doTest15(); }
- public void testYoleBug() { doTest15(); }
- public void testForeachFlow() { doTest15(); }
- public void testForEachNPE() { doTest15(); }
- public void testArrayAccessNPE() { doTest15(); }
- public void testArrayAccessDoesntCancelAnalysis() { doTest15(); }
- public void testCompileTimeConst() { doTest15(true); }
- public void testAutoboxing() { doTest15(true); }
- public void testUnboxingNPE() { doTest15(true); }
- public void testStrangeArrayIndexOutOfBounds() { doTest15(); }
- public void testIDEADEV2605() { doTest15(); }
- public void testConstantsDifferentTypes() { doTest15(); }
- public void testBoxingNaN() { doTest15(); }
- public void testBoxingBoolean() { doTest15(true); }
- public void testCheckedExceptionDominance() { doTest15(); }
- public void testIDEADEV10489() { doTest15(); }
- public void testPlusOnStrings() { doTest15(); }
- public void testSwitchQualifierProducesNPE() {doTest15(); }
- public void testIDEADEV15583() {doTest15(); }
- public void testIDEADEV13153() { doTest15(); }
- public void testIDEADEV13156() { doTest15(); }
- public void testSwitchEnumCases() { doTest15(); }
- public void testTryWithResources() { doTest15(true); }
-
- public void testSCR15406() { doTest(); }
- //public void testIDEADEV11033() { doTest15(); } // added by max, 2007
+ public void testTryWithResources() { doTest(); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java
index 1e9edcfc87be..07d2bf4fc99e 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java
@@ -22,8 +22,9 @@ import junit.framework.TestSuite;
public class DataFlowInspectionTestSuite {
public static Test suite() {
TestSuite suite = new TestSuite();
- suite.addTestSuite(DataFlowInspectionFixtureTest.class);
suite.addTestSuite(DataFlowInspectionTest.class);
+ suite.addTestSuite(DataFlowInspectionFixtureTest.class);
+ suite.addTestSuite(DataFlowInspectionAncientTest.class);
suite.addTestSuite(SliceTreeTest.class);
return suite;
}