mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
move instance member (IDEA-78519)
This commit is contained in:
@@ -248,7 +248,7 @@ public class MoveInstanceMethodProcessor extends BaseRefactoringProcessor{
|
|||||||
if (!methodExpression.isReferenceTo(myMethod)) return;
|
if (!methodExpression.isReferenceTo(myMethod)) return;
|
||||||
final PsiExpression oldQualifier = methodExpression.getQualifierExpression();
|
final PsiExpression oldQualifier = methodExpression.getQualifierExpression();
|
||||||
PsiExpression newQualifier = null;
|
PsiExpression newQualifier = null;
|
||||||
|
final PsiClass classReferencedByThis = MoveInstanceMembersUtil.getClassReferencedByThis(methodExpression);
|
||||||
if (myTargetVariable instanceof PsiParameter) {
|
if (myTargetVariable instanceof PsiParameter) {
|
||||||
final int index = myMethod.getParameterList().getParameterIndex((PsiParameter)myTargetVariable);
|
final int index = myMethod.getParameterList().getParameterIndex((PsiParameter)myTargetVariable);
|
||||||
final PsiExpression[] arguments = expression.getArgumentList().getExpressions();
|
final PsiExpression[] arguments = expression.getArgumentList().getExpressions();
|
||||||
@@ -264,7 +264,6 @@ public class MoveInstanceMethodProcessor extends BaseRefactoringProcessor{
|
|||||||
|
|
||||||
PsiExpression newArgument = null;
|
PsiExpression newArgument = null;
|
||||||
|
|
||||||
final PsiClass classReferencedByThis = MoveInstanceMembersUtil.getClassReferencedByThis(methodExpression);
|
|
||||||
if (classReferencedByThis != null) {
|
if (classReferencedByThis != null) {
|
||||||
@NonNls String thisArgumentText = null;
|
@NonNls String thisArgumentText = null;
|
||||||
if (manager.areElementsEquivalent(myMethod.getContainingClass(), classReferencedByThis)) {
|
if (manager.areElementsEquivalent(myMethod.getContainingClass(), classReferencedByThis)) {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
public class A {
|
||||||
|
|
||||||
|
public void m<caret>(B b){
|
||||||
|
System.out.println(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(B b){
|
||||||
|
m(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void m (C c){
|
||||||
|
System.out.println(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class B{}
|
||||||
|
class C{}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
public class A {
|
||||||
|
|
||||||
|
public void show(B b){
|
||||||
|
b.m(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void m (C c){
|
||||||
|
System.out.println(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class B{
|
||||||
|
public void m(A a){
|
||||||
|
System.out.println(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class C{}
|
||||||
@@ -51,6 +51,8 @@ public class MoveInstanceMethodTest extends LightRefactoringTestCase {
|
|||||||
|
|
||||||
public void testThisInAnonymous() throws Exception { doTest(true, 0); }
|
public void testThisInAnonymous() throws Exception { doTest(true, 0); }
|
||||||
|
|
||||||
|
public void testOverloadingMethods() throws Exception { doTest(true, 0); }
|
||||||
|
|
||||||
public void testEscalateVisibility() throws Exception {
|
public void testEscalateVisibility() throws Exception {
|
||||||
doTest(true, 0, VisibilityUtil.ESCALATE_VISIBILITY);
|
doTest(true, 0, VisibilityUtil.ESCALATE_VISIBILITY);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user