mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AddExceptionToExistingCatch: simplify: IDEA-CR-30935
This commit is contained in:
+2
-11
@@ -153,10 +153,10 @@ public class AddExceptionToExistingCatchFix extends PsiElementBaseIntentionActio
|
||||
PsiElement parent = element.getParent();
|
||||
List<PsiTryStatement> parents = new SmartList<>();
|
||||
while (parent != null) {
|
||||
if (parent instanceof PsiLambdaExpression || parent instanceof PsiMember) break;
|
||||
if (parent instanceof PsiLambdaExpression || parent instanceof PsiMember || parent instanceof PsiFile) break;
|
||||
if (parent instanceof PsiTryStatement) {
|
||||
PsiTryStatement tryStatement = (PsiTryStatement)parent;
|
||||
if (tryStatement.getFinallyBlock() != current && !isInCatch(current, tryStatement)) {
|
||||
if (tryStatement.getFinallyBlock() != current && !(current instanceof PsiCatchSection)) {
|
||||
parents.add((PsiTryStatement)parent);
|
||||
}
|
||||
}
|
||||
@@ -166,15 +166,6 @@ public class AddExceptionToExistingCatchFix extends PsiElementBaseIntentionActio
|
||||
return parents;
|
||||
}
|
||||
|
||||
private static boolean isInCatch(PsiElement current, PsiTryStatement tryStatement) {
|
||||
for (PsiCatchSection block : tryStatement.getCatchSections()) {
|
||||
if (block == current) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getMessage() {
|
||||
if (myCatches.size() == 1 && myExceptions.size() == 1) {
|
||||
PsiClassType exceptionType = myExceptions.get(0);
|
||||
|
||||
Reference in New Issue
Block a user