mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
escalate visibility for moved class (IDEA-119683)
This commit is contained in:
@@ -250,6 +250,23 @@ public class MoveInnerProcessor extends BaseRefactoringProcessor {
|
||||
reference.bindToElement(newClass);
|
||||
}
|
||||
|
||||
for (UsageInfo usage : usages) {
|
||||
final PsiElement element = usage.getElement();
|
||||
final PsiElement parent = element != null ? element.getParent() : null;
|
||||
if (parent instanceof PsiNewExpression) {
|
||||
final PsiMethod resolveConstructor = ((PsiNewExpression)parent).resolveConstructor();
|
||||
for (PsiMethod method : newClass.getConstructors()) {
|
||||
if (resolveConstructor == method) {
|
||||
final PsiElement place = usage.getElement();
|
||||
if (place != null) {
|
||||
VisibilityUtil.escalateVisibility(method, place);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (field != null) {
|
||||
final PsiExpression paramAccessExpression = factory.createExpressionFromText(myParameterNameOuterClass, null);
|
||||
for (final PsiMethod constructor : newClass.getConstructors()) {
|
||||
|
||||
@@ -42,16 +42,6 @@ public class MoveJavaInnerHandler implements MoveInnerHandler {
|
||||
if (makePublic) {
|
||||
PsiUtil.setModifierProperty(newClass, PsiModifier.PUBLIC, true);
|
||||
}
|
||||
|
||||
final PsiMethod[] constructors = newClass.getConstructors();
|
||||
for (PsiMethod constructor : constructors) {
|
||||
final PsiModifierList modifierList = constructor.getModifierList();
|
||||
modifierList.setModifierProperty(PsiModifier.PRIVATE, false);
|
||||
modifierList.setModifierProperty(PsiModifier.PROTECTED, false);
|
||||
if (makePublic && !newClass.isEnum()) {
|
||||
modifierList.setModifierProperty(PsiModifier.PUBLIC, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
newClass = (PsiClass)options.getTargetContainer().add(innerClass);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package p;
|
||||
|
||||
class A {
|
||||
public void test() {
|
||||
B.foo();
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package p;
|
||||
|
||||
class B {
|
||||
private B() {
|
||||
System.out.println("Constructor");
|
||||
}
|
||||
|
||||
static void foo(){}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package p;
|
||||
|
||||
class A {
|
||||
public void test() {
|
||||
B.foo();
|
||||
}
|
||||
|
||||
private class B {
|
||||
private B() {
|
||||
System.out.println("Constructor");
|
||||
}
|
||||
|
||||
static void foo(){}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,10 @@ public class MoveInnerTest extends MultiFileTestCase {
|
||||
doTest(createAction("p.A.B", "B", false, null, false, false, null));
|
||||
}
|
||||
|
||||
public void testConstructorUtilClassVisibility() throws Exception {
|
||||
doTest(createAction("p.A.B", "B", false, null, false, false, null));
|
||||
}
|
||||
|
||||
public void testFieldAccessInSuper() throws Exception {
|
||||
doTest(createAction("p.A.B", "B", true, "a", false, false, null));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user