disable add catch exception for method references (IDEA-205952)

This commit is contained in:
Anna.Kozlova
2019-01-24 13:59:37 +01:00
parent fb19e2ef13
commit 489bed949a
2 changed files with 19 additions and 1 deletions
@@ -130,7 +130,7 @@ public class AddExceptionToExistingCatchFix extends PsiElementBaseIntentionActio
@Nullable
static Context from(@NotNull PsiElement element) {
if (!element.isValid() || !PsiUtil.isLanguageLevel7OrHigher(element)) return null;
if (!element.isValid() || !PsiUtil.isLanguageLevel7OrHigher(element) || element instanceof PsiMethodReferenceExpression) return null;
List<PsiClassType> unhandledExceptions = new ArrayList<>(ExceptionUtil.getOwnUnhandledExceptions(element));
if (unhandledExceptions.isEmpty()) return null;
List<PsiTryStatement> tryStatements = getTryStatements(element);
@@ -0,0 +1,18 @@
// "Add exception to existing catch clause" "false"
import java.util.*;
class MyTest {
void demo(List<String> strings) {
try {
strings.forEach(this::f<caret>oo);
}
catch (Exception ex) {
// handle
}
}
private void foo(String s) throws Exception {
throw new Exception();
}
}