mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expand one line lambda: fix value compatibility check
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ public class ExpandOneLineLambda2CodeBlockIntention extends Intention {
|
||||
final PsiElement body = lambdaExpression.getBody();
|
||||
LOG.assertTrue(body instanceof PsiExpression);
|
||||
String blockText = "{";
|
||||
blockText += ((PsiExpression)body).getType() == PsiType.VOID ? "" : "return ";
|
||||
blockText += PsiType.VOID.equals(LambdaUtil.getFunctionalInterfaceReturnType(lambdaExpression)) ? "" : "return ";
|
||||
blockText += body.getText() + ";}";
|
||||
|
||||
final String resultedLambdaText = lambdaExpression.getParameterList().getText() + "->" + blockText;
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.List;
|
||||
|
||||
class X {
|
||||
void foo(List<String> list){
|
||||
Runnable c = () <caret>-> list.add("");
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.List;
|
||||
|
||||
class X {
|
||||
void foo(List<String> list){
|
||||
Runnable c = () -> {
|
||||
list.add("");
|
||||
};
|
||||
}
|
||||
}
|
||||
+5
@@ -22,6 +22,11 @@ public class ExpandOneLineLambda2CodeBlockIntentionTest extends IPPTestCase {
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVoidCompatibleInExpr() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getIntentionName() {
|
||||
return "Expand lambda expression body to {...}";
|
||||
|
||||
Reference in New Issue
Block a user