mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
extract method: stop at lambda body during exceptions collecting (IDEA-144938)
This commit is contained in:
@@ -92,6 +92,9 @@ public class ExceptionUtil {
|
||||
// filter class declaration in code
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else if (element instanceof PsiLambdaExpression) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else if (element instanceof PsiMethodCallExpression) {
|
||||
PsiReferenceExpression methodRef = ((PsiMethodCallExpression)element).getMethodExpression();
|
||||
JavaResolveResult result = methodRef.advancedResolve(false);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import java.io.IOException;
|
||||
class Issue {
|
||||
|
||||
public static void main(String[] args) {
|
||||
<selection>swallow(() -> {
|
||||
throw new IOException();
|
||||
});</selection>
|
||||
}
|
||||
|
||||
private static void swallow(ThrowsUnchecked r) {
|
||||
try {
|
||||
r.doAction();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ThrowsUnchecked {
|
||||
void doAction() throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import java.io.IOException;
|
||||
class Issue {
|
||||
|
||||
public static void main(String[] args) {
|
||||
newMethod();
|
||||
}
|
||||
|
||||
private static void newMethod() {
|
||||
swallow(() -> {
|
||||
throw new IOException();
|
||||
});
|
||||
}
|
||||
|
||||
private static void swallow(ThrowsUnchecked r) {
|
||||
try {
|
||||
r.doAction();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ThrowsUnchecked {
|
||||
void doAction() throws IOException;
|
||||
}
|
||||
@@ -711,6 +711,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSkipThrowsDeclaredInLambda() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testChangedReturnType() throws Exception {
|
||||
doTestReturnTypeChanged(PsiType.getJavaLangObject(getPsiManager(), GlobalSearchScope.allScope(getProject())));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user