mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable lambda -> methref for qualified new expressions (IDEA-147054)
This commit is contained in:
+5
-1
@@ -124,6 +124,10 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
}
|
||||
if (!(element instanceof PsiMethod)) {
|
||||
LOG.assertTrue(callExpression instanceof PsiNewExpression);
|
||||
if (((PsiNewExpression)callExpression).getQualifier() != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiExpression[] dims = ((PsiNewExpression)callExpression).getArrayDimensions();
|
||||
if (dims.length == 1 && parameters.length == 1){
|
||||
if (!resolvesToParameter(dims[0], parameters[0])) {
|
||||
@@ -170,7 +174,7 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
}
|
||||
|
||||
if (expressions.length == 0 && parameters.length == 0) {
|
||||
return true;
|
||||
return !(callExpression instanceof PsiNewExpression && qualifier != null);
|
||||
}
|
||||
|
||||
final int offset = parameters.length - calledParametersCount;
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
class OuterClass {
|
||||
class InnerClass {
|
||||
public InnerClass() {
|
||||
}
|
||||
}
|
||||
|
||||
public static void foo() {
|
||||
final OuterClass outerClassInstance = new OuterClass();
|
||||
|
||||
doSomethingWithRunnable(() -> outerClassInstance.new Inner<caret>Class());
|
||||
}
|
||||
|
||||
static void doSomethingWithRunnable(Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
class OuterClass {
|
||||
class InnerClass { }
|
||||
|
||||
public static void foo() {
|
||||
final OuterClass outerClassInstance = new OuterClass();
|
||||
|
||||
doSomethingWithRunnable(() -> outerClassInstance.new Inner<caret>Class());
|
||||
}
|
||||
|
||||
static void doSomethingWithRunnable(Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user