mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
lambda -> meth ref: varargs
This commit is contained in:
@@ -125,8 +125,15 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
if (argumentList == null) {
|
||||
return false;
|
||||
}
|
||||
int offset = parameters.length - psiMethod.getParameterList().getParametersCount();
|
||||
|
||||
final int calledParametersCount = psiMethod.getParameterList().getParametersCount();
|
||||
final PsiExpression[] expressions = argumentList.getExpressions();
|
||||
|
||||
final int offset = parameters.length - calledParametersCount;
|
||||
if (expressions.length > calledParametersCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < expressions.length; i++) {
|
||||
if (!resolvesToParameter(expressions[i], parameters[i + offset])) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
class Example {
|
||||
public void m(String... s) {
|
||||
}
|
||||
|
||||
{
|
||||
Runnable r = this::m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
class Example {
|
||||
public void m(String... s) {
|
||||
}
|
||||
|
||||
{
|
||||
Runnable r = () -> <caret>m();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.function.Function;
|
||||
class Example {
|
||||
|
||||
public String m(String... s) {
|
||||
return "";
|
||||
}
|
||||
|
||||
{
|
||||
Function<String, String> r = (s) -> m(s, s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user