mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move static members: process anonymous class creation (IDEADEV-39807)
This commit is contained in:
+12
-5
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.intellij.refactoring.move.moveMembers;
|
||||
|
||||
import com.intellij.codeInsight.ChangeContextUtil;
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -377,10 +376,18 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
else if (scope instanceof PsiNewExpression) {
|
||||
final PsiMethod refElement = ((PsiNewExpression)scope).resolveConstructor();
|
||||
if (refElement != null) {
|
||||
if (!RefactoringHierarchyUtil.willBeInTargetClass(refElement, membersToMove, newContext, false)) {
|
||||
checkAccessibility(refElement, newContext, null, member, conflicts);
|
||||
final PsiNewExpression newExpression = (PsiNewExpression)scope;
|
||||
final PsiAnonymousClass anonymousClass = newExpression.getAnonymousClass();
|
||||
if (anonymousClass != null) {
|
||||
if (!RefactoringHierarchyUtil.willBeInTargetClass(anonymousClass, membersToMove, newContext, false)){
|
||||
checkAccessibility(anonymousClass, newContext, anonymousClass, member, conflicts);
|
||||
}
|
||||
} else {
|
||||
final PsiMethod refElement = newExpression.resolveConstructor();
|
||||
if (refElement != null) {
|
||||
if (!RefactoringHierarchyUtil.willBeInTargetClass(refElement, membersToMove, newContext, false)) {
|
||||
checkAccessibility(refElement, newContext, null, member, conflicts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ public class MoveMembersTest extends MultiFileTestCase {
|
||||
doTest("C", "B", 0);
|
||||
}
|
||||
|
||||
public void testProtectedConstructor() throws Exception {
|
||||
doTest("pack1.A", "pack1.C", 0);
|
||||
}
|
||||
|
||||
public void testOtherPackageImport() throws Exception {
|
||||
doTest("pack1.ClassWithStaticMethod", "pack2.OtherClass", 1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package pack1;
|
||||
|
||||
public class A {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package pack1;
|
||||
|
||||
public class C {
|
||||
public static void foo() {
|
||||
new B(){};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package pack2;
|
||||
|
||||
public class B {
|
||||
protected B(){}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package pack1;
|
||||
|
||||
public class A {
|
||||
public static void foo() {
|
||||
new B(){};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package pack1;
|
||||
|
||||
public class C {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package pack2;
|
||||
|
||||
public class B {
|
||||
protected B(){}
|
||||
}
|
||||
Reference in New Issue
Block a user