Move try-with-resources data flow test to right place

This commit is contained in:
Roman Shevchenko
2012-10-10 13:03:57 +02:00
parent 4dd466fde6
commit b13e8b0d7a
5 changed files with 32 additions and 19 deletions
@@ -23,21 +23,4 @@ class C {
System.out.println(r);
}
}
interface MyResourceProvider {
MyResource getResource();
}
void m3() throws Exception {
MyResourceProvider provider = null;
try (MyResource r = <warning descr="Method invocation 'provider.getResource()' may produce 'java.lang.NullPointerException'">provider.getResource()</warning>) {
System.out.println(r);
}
}
void m4() {
try (MyResource r = null) {
System.out.println(r);
}
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>12</line>
<description>Method invocation &lt;code&gt;provider.getResource()&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;</description>
</problem>
</problems>
@@ -0,0 +1,22 @@
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);
}
}
}
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.compiler.JavacQuirksInspection;
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.defUse.DefUseInspection;
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
@@ -147,7 +146,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
public void testNumericLiterals() throws Exception { doTest(false, false); }
public void testMultiCatch() throws Exception { doTest(false, false); }
public void testTryWithResources() throws Exception { doTest(false, false); }
public void testTryWithResourcesWarn() throws Exception { doTest(true, false, new DefUseInspection(), new DataFlowInspection()); }
public void testTryWithResourcesWarn() throws Exception { doTest(true, false, new DefUseInspection()); }
public void testSafeVarargsApplicability() throws Exception { doTest(true, false); }
public void testUncheckedGenericsArrayCreation() throws Exception { doTest(true, false); }
public void testPreciseRethrow() throws Exception { doTest(false, false); }
@@ -114,6 +114,7 @@ public class DataFlowInspectionTest extends InspectionTestCase {
public void testIDEADEV13153() { doTest15(); }
public void testIDEADEV13156() { doTest15(); }
public void testSwitchEnumCases() { doTest15(); }
public void testTryWithResources() { doTest15(true); }
//public void testSCR15406() { doTest(); } // added by cdr, 2005
//public void testIDEADEV11033() { doTest15(); } // added by max, 2007