mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
Add catch block fix made aware of try-with-resources
This commit is contained in:
+15
@@ -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>
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -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>
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -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()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user