delete catch fix: introduce ARM

This commit is contained in:
Anna Kozlova
2014-01-02 11:55:51 +01:00
parent ef71e0bc15
commit eb258ae064
3 changed files with 34 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ public class DeleteCatchFix implements IntentionAction {
if (!FileModificationService.getInstance().prepareFileForWrite(myCatchParameter.getContainingFile())) return;
final PsiTryStatement tryStatement = ((PsiCatchSection)myCatchParameter.getDeclarationScope()).getTryStatement();
if (tryStatement.getCatchBlocks().length == 1 && tryStatement.getFinallyBlock() == null) {
if (tryStatement.getCatchBlocks().length == 1 && tryStatement.getFinallyBlock() == null && tryStatement.getResourceList() == null) {
// unwrap entire try statement
final PsiCodeBlock tryBlock = tryStatement.getTryBlock();
PsiElement lastAddedStatement = null;

View File

@@ -0,0 +1,16 @@
// "Delete catch for 'java.lang.ClassNotFoundException'" "true"
import java.io.*;
class Cl implements AutoCloseable {
public void close() throws IOException {
in.close();
}
}
class a {
void f() throws IOException {
try (Cl c = new Cl()) {
c.close();
}
}
}

View File

@@ -0,0 +1,17 @@
// "Delete catch for 'java.lang.ClassNotFoundException'" "true"
import java.io.*;
class Cl implements AutoCloseable {
public void close() throws IOException {
in.close();
}
}
class a {
void f() throws IOException {
try (Cl c = new Cl()) {
c.close();
} catch (<caret>ClassNotFoundException e) {
}
}
}