mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not add exceptions to containing methods when element is selected inside lambda
This commit is contained in:
+3
-3
@@ -72,10 +72,10 @@ public class AddRuntimeExceptionToThrowsAction implements IntentionAction {
|
||||
PsiClassType exception = getRuntimeExceptionAtCaret(editor, file);
|
||||
if (exception == null) return false;
|
||||
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(elementAtCaret(editor, file), PsiMethod.class);
|
||||
if (method == null || !method.getThrowsList().isPhysical()) return false;
|
||||
PsiElement element = PsiTreeUtil.getParentOfType(elementAtCaret(editor, file), PsiMethod.class, PsiLambdaExpression.class);
|
||||
if (element == null || element instanceof PsiLambdaExpression || !((PsiMethod)element).getThrowsList().isPhysical()) return false;
|
||||
|
||||
return !isMethodThrows(method, exception);
|
||||
return !isMethodThrows((PsiMethod)element, exception);
|
||||
}
|
||||
|
||||
private static PsiClassType getRuntimeExceptionAtCaret(Editor editor, PsiFile file) {
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Add Runtime Exception(s) to Method Signature" "false"
|
||||
class a {
|
||||
int f() {
|
||||
Runnable r = () -> {
|
||||
throw new RuntimeException()<caret>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
|
||||
Reference in New Issue
Block a user