mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
Move try-with-resources data flow test to right place
This commit is contained in:
-17
@@ -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 <code>provider.getResource()</code> may produce <code>java.lang.NullPointerException</code></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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user