Add exception to method signature fix made aware of try-with-resources

This commit is contained in:
Roman Shevchenko
2011-03-01 20:34:18 +01:00
parent a5a7e6846a
commit 77f94dbece
7 changed files with 73 additions and 0 deletions
@@ -314,6 +314,9 @@ public class ExceptionUtil {
PsiClassType exception = getUnhandledException(throwStatement, null);
if (exception != null) return Collections.singletonList(exception);
}
else if (element instanceof PsiResourceVariable) {
return getUnhandledCloserExceptions((PsiResourceVariable)element, null);
}
return Collections.emptyList();
}
@@ -30,6 +30,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -175,6 +176,7 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
return QuickFixBundle.message("add.exception.to.throws.family");
}
@Nullable
private static PsiElement findElement(PsiElement element, PsiMethod topElement) {
if (element == null) return null;
List<PsiClassType> unhandledExceptions = ExceptionUtil.getUnhandledExceptions(element);