mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not delete finally section when catch section is replaced with throws (IDEA-145842)
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ public class ConvertCatchToThrowsIntention extends Intention {
|
||||
addToThrowsList(throwsList, catchType);
|
||||
final PsiTryStatement tryStatement = catchSection.getTryStatement();
|
||||
final PsiCatchSection[] catchSections = tryStatement.getCatchSections();
|
||||
if (catchSections.length > 1 || tryStatement.getResourceList() != null) {
|
||||
if (catchSections.length > 1 || tryStatement.getResourceList() != null || tryStatement.getFinallyBlock() != null) {
|
||||
catchSection.delete();
|
||||
}
|
||||
else {
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
void f() {
|
||||
try {
|
||||
System.out.println();
|
||||
}
|
||||
cat<caret>ch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
void f() throws Exception {
|
||||
try {
|
||||
System.out.println();
|
||||
} finally {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -26,6 +26,7 @@ public class ConvertCatchToThrowsTest extends IPPTestCase {
|
||||
public void testArmWithSingleCatch() { doTest(); }
|
||||
public void testExistingThrows() { doTest(); }
|
||||
public void testLambda() { doTest(); }
|
||||
public void testLeaveFinallySection() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected String getIntentionName() {
|
||||
|
||||
Reference in New Issue
Block a user