mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
IDEA-112552 "Replace with lambda" should use expression lambda when possible
This commit is contained in:
@@ -161,10 +161,14 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
|
||||
final PsiStatement[] statements = body.getStatements();
|
||||
PsiElement copy = body.copy();
|
||||
if (statements.length == 1 && statements[0] instanceof PsiReturnStatement) {
|
||||
PsiExpression value = ((PsiReturnStatement)statements[0]).getReturnValue();
|
||||
if (value != null) {
|
||||
copy = value.copy();
|
||||
if (statements.length == 1) {
|
||||
if (statements[0] instanceof PsiReturnStatement) {
|
||||
PsiExpression value = ((PsiReturnStatement)statements[0]).getReturnValue();
|
||||
if (value != null) {
|
||||
copy = value.copy();
|
||||
}
|
||||
} else if (statements[0] instanceof PsiExpressionStatement) {
|
||||
copy = ((PsiExpressionStatement)statements[0]).getExpression().copy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ class Test {
|
||||
|
||||
interface InOutEx extends InOut {
|
||||
InOut bind() {
|
||||
return () -> {
|
||||
foo();
|
||||
};
|
||||
return () -> foo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,6 @@ class Test {
|
||||
}
|
||||
|
||||
InOut bind() {
|
||||
return () -> {
|
||||
InOut.foo();
|
||||
};
|
||||
return () -> InOut.foo();
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,7 @@ class HelloLambda {
|
||||
|
||||
HelloLambda() {
|
||||
x = 1;
|
||||
Runnable r = () -> {
|
||||
System.out.println(x);
|
||||
|
||||
};
|
||||
Runnable r = () -> System.out.println(x);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// "Replace with lambda" "true"
|
||||
class HelloLambda {
|
||||
private final Runnable r = () -> {
|
||||
System.out.println(x);
|
||||
};
|
||||
private final Runnable r = () -> System.out.println(x);
|
||||
private static int x = 0;
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
// "Replace with lambda" "true"
|
||||
class Test {
|
||||
{
|
||||
Runnable r = () -> {
|
||||
System.out.println("");
|
||||
};
|
||||
Runnable r = () -> System.out.println("");
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
// "Replace with lambda" "true"
|
||||
class Test {
|
||||
{
|
||||
Runnable[] r = new Runnable[] {() -> {
|
||||
System.out.println("");
|
||||
}};
|
||||
Runnable[] r = new Runnable[] {() -> System.out.println("")};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user