mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 05:51:25 +07:00
Surround with try-catch: disable in resources
There's another fix 'Add catch to try' and this is most likely what people want. Having too many fixes is confusing. GitOrigin-RevId: c6c03bf52a9b59a14e7e8025e0fa525de7872630
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f801cdb18f
commit
47b9916057
@@ -26,8 +26,13 @@ public class SurroundWithTryCatchFix implements IntentionAction {
|
||||
private PsiElement myElement;
|
||||
|
||||
public SurroundWithTryCatchFix(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiExpression &&
|
||||
PsiTreeUtil.getParentOfType(element, PsiResourceListElement.class, false, PsiStatement.class) != null) {
|
||||
// We are inside resource list: there's already a suggestion to add a catch to this try.
|
||||
// Suggesting wrapping with another try-catch is confusing
|
||||
return;
|
||||
}
|
||||
if (element instanceof PsiStatement ||
|
||||
element instanceof PsiResourceVariable ||
|
||||
(element instanceof PsiExpression &&
|
||||
!(element instanceof PsiMethodReferenceExpression) &&
|
||||
CodeBlockSurrounder.canSurround(ExpressionUtils.getTopLevelExpression((PsiExpression)element)))) {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// "Surround with try/catch" "true"
|
||||
class C {
|
||||
static class E1 extends Exception { }
|
||||
|
||||
static class MyResource implements AutoCloseable {
|
||||
public void close() throws E1 { }
|
||||
}
|
||||
|
||||
void m() {
|
||||
try {
|
||||
try (MyResource r = new MyResource()) {
|
||||
}
|
||||
} catch (E1 e1) {
|
||||
<selection>e1.printStackTrace();</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Surround with try/catch" "true"
|
||||
// "Surround with try/catch" "false"
|
||||
class C {
|
||||
static class E1 extends Exception { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user