unwrap lambda: ensure declaration is covered in preview (IDEA-201206)

This commit is contained in:
Anna.Kozlova
2018-10-25 16:20:56 +02:00
parent af3e15a689
commit f8c57bfa5a
2 changed files with 16 additions and 0 deletions
@@ -32,6 +32,12 @@ public class JavaLambdaUnwrapper extends JavaUnwrapper {
return e instanceof PsiLambdaExpression;
}
@Override
public PsiElement collectAffectedElements(@NotNull PsiElement e, @NotNull List<PsiElement> toExtract) {
super.collectAffectedElements(e, toExtract);
return JavaAnonymousUnwrapper.findElementToExtractFrom(e);
}
@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
PsiElement from = JavaAnonymousUnwrapper.findElementToExtractFrom(element);
@@ -78,6 +78,16 @@ public class UnwrapLambdaTest extends UnwrapTestCase {
"}\n", 1);
}
public void testUnwrapAssignmentWithCodeBlock() throws Exception {
assertUnwrapped("{\n" +
" Runnable r = () -> {in<caret>t i = 0;};\n" +
"}\n",
"{\n" +
" int i = 0;\n" +
"}\n");
}
public void testUnwrapUnresolved() throws Exception {
assertUnwrapped("{\n" +
" () -> <caret>null;\n" +