Add catch block fix made aware of try-with-resources

This commit is contained in:
Roman Shevchenko
2011-03-01 20:34:17 +01:00
parent f627677fdd
commit a5a7e6846a
6 changed files with 85 additions and 13 deletions
@@ -0,0 +1,15 @@
// "Add Catch Clause(s)" "true"
import java.io.IOException;
class Test {
static class MyResource implements AutoCloseable {
public void close() throws IOException { }
}
void m() {
try (MyResource r = new MyResource()) {
} catch (IOException e) {
<selection>e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection>
}
}
}
@@ -0,0 +1,19 @@
// "Add Catch Clause(s)" "true"
class Test {
static class E1 extends Exception { }
static class E2 extends Exception { }
static class MyResource implements AutoCloseable {
public void doSomething() throws E1 { }
public void close() throws E2 { }
}
void m() {
try (MyResource r = new MyResource()) {
r.doSomething();
} catch (E1 ignore) {
} catch (E2 e2) {
<selection>e2.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection>
}
}
}
@@ -0,0 +1,13 @@
// "Add Catch Clause(s)" "true"
import java.io.IOException;
class Test {
static class MyResource implements AutoCloseable {
public void close() throws IOException { }
}
void m() {
try (<caret>MyResource r = new MyResource()) {
}
}
}
@@ -0,0 +1,17 @@
// "Add Catch Clause(s)" "true"
class Test {
static class E1 extends Exception { }
static class E2 extends Exception { }
static class MyResource implements AutoCloseable {
public void doSomething() throws E1 { }
public void close() throws E2 { }
}
void m() {
try (<caret>MyResource r = new MyResource()) {
r.doSomething();
} catch (E1 ignore) {
}
}
}