mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
move instance method when ref was inside anonymous inheritor (EA-87325 - IOE: PsiJavaParserFacadeImpl.createExpressionFromText)
This commit is contained in:
+2
-1
@@ -26,6 +26,7 @@ import com.intellij.refactoring.move.MoveInstanceMembersUtil;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -123,7 +124,7 @@ public class MoveInstanceMethodDialog extends MoveInstanceMethodDialogBase {
|
||||
if (myThisClassesMap.size() == 0) return null;
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));
|
||||
for (PsiClass aClass : myThisClassesMap.keySet()) {
|
||||
final String text = RefactoringBundle.message("move.method.this.parameter.label", aClass.getName());
|
||||
final String text = RefactoringBundle.message("move.method.this.parameter.label", ObjectUtils.notNull(aClass.getName(), ""));
|
||||
panel.add(new TitledSeparator(text, null));
|
||||
|
||||
String suggestedName = MoveInstanceMethodHandler.suggestParameterNameForThisClass(aClass);
|
||||
|
||||
+7
-1
@@ -333,7 +333,13 @@ public class MoveInstanceMethodProcessor extends BaseRefactoringProcessor{
|
||||
}
|
||||
}
|
||||
else {
|
||||
thisArgumentText = classReferencedByThis.getName() + ".this";
|
||||
final String name = classReferencedByThis.getName();
|
||||
if (name != null) {
|
||||
thisArgumentText = name + ".this";
|
||||
}
|
||||
else {
|
||||
thisArgumentText = "this";
|
||||
}
|
||||
}
|
||||
|
||||
if (thisArgumentText != null) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
class A<T> {
|
||||
class B {
|
||||
private String foo;
|
||||
|
||||
public void run() {
|
||||
new B() {
|
||||
@Override
|
||||
public void run() {
|
||||
moo(A.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void m<caret>oo(A a) {
|
||||
System.out.println(foo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
class A<T> {
|
||||
void moo(B b) {
|
||||
System.out.println(b.foo);
|
||||
}
|
||||
|
||||
class B {
|
||||
private String foo;
|
||||
|
||||
public void run() {
|
||||
new B() {
|
||||
@Override
|
||||
public void run() {
|
||||
A.this.moo(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -85,6 +85,10 @@ public class MoveInstanceMethodTest extends LightRefactoringTestCase {
|
||||
doTest(false, 0);
|
||||
}
|
||||
|
||||
public void testUsageInAnonymousClass() throws Exception {
|
||||
doTest(true, 0);
|
||||
}
|
||||
|
||||
public void testMethodReference() throws Exception {
|
||||
try {
|
||||
doTest(true, 0);
|
||||
|
||||
Reference in New Issue
Block a user