mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move instance method with method ref: ensure qualifier is not deleted
IDEA-181919
This commit is contained in:
+7
-2
@@ -500,8 +500,13 @@ public class MoveInstanceMethodProcessor extends BaseRefactoringProcessor{
|
||||
}
|
||||
}
|
||||
}
|
||||
//Target is a field, replace target.m -> m
|
||||
qualifier.delete();
|
||||
if (expression instanceof PsiMethodReferenceExpression) {
|
||||
qualifier.replace(factory.createExpressionFromText("this", null));
|
||||
}
|
||||
else {
|
||||
//Target is a field, replace target.m -> m
|
||||
qualifier.delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (myTargetVariable.equals(resolved)) {
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Source {
|
||||
public void f<caret>oo(Destination destination) {
|
||||
Consumer<String> doSomething = destination::doSomething;
|
||||
}
|
||||
}
|
||||
|
||||
class Destination {
|
||||
public void doSomething(String s) {
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Source {
|
||||
}
|
||||
|
||||
class Destination {
|
||||
public void doSomething(String s) {
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
Consumer<String> doSomething = this::doSomething;
|
||||
}
|
||||
}
|
||||
+4
@@ -116,6 +116,10 @@ public class MoveInstanceMethodTest extends LightRefactoringTestCase {
|
||||
doTest(false, 0);
|
||||
}
|
||||
|
||||
public void testMethodReferenceWithThisTarget() {
|
||||
BaseRefactoringProcessor.ConflictsInTestsException.withIgnoredConflicts(() -> doTest(true, 0));
|
||||
}
|
||||
|
||||
public void testMethodReferenceToExpandToLambda() {
|
||||
BaseRefactoringProcessor.ConflictsInTestsException.withIgnoredConflicts(() -> doTest(true, 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user