mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pull up conflicts: method2abstract used private method moved to superclass (IDEA-56133)
This commit is contained in:
@@ -63,9 +63,9 @@ public class PullUpConflictsUtil {
|
||||
}
|
||||
|
||||
public static MultiMap<PsiElement, String> checkConflicts(final MemberInfo[] infos,
|
||||
PsiClass subclass,
|
||||
final PsiClass subclass,
|
||||
@Nullable PsiClass superClass,
|
||||
PsiPackage targetPackage,
|
||||
final PsiPackage targetPackage,
|
||||
PsiDirectory targetDirectory,
|
||||
final InterfaceContainmentVerifier interfaceContainmentVerifier,
|
||||
boolean movedMembers2Super) {
|
||||
@@ -143,6 +143,31 @@ public class PullUpConflictsUtil {
|
||||
}
|
||||
RefactoringConflictsUtil.analyzeModuleConflicts(subclass.getProject(), checkModuleConflictsList,
|
||||
new UsageInfo[0], targetRepresentativeElement, conflicts);
|
||||
for (final PsiMethod abstractMethod : abstractMethods) {
|
||||
abstractMethod.accept(new ClassMemberReferencesVisitor(subclass) {
|
||||
@Override
|
||||
protected void visitClassMemberReferenceElement(PsiMember classMember, PsiJavaCodeReferenceElement classMemberReference) {
|
||||
if (classMember != null && willBeMoved(classMember, movedMembers)) {
|
||||
boolean isAccessible = false;
|
||||
if (classMember.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
isAccessible = true;
|
||||
}
|
||||
else if (classMember.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) &&
|
||||
!Comparing.strEqual(targetPackage.getQualifiedName(), StringUtil.getPackageName(subclass.getQualifiedName()))) {
|
||||
isAccessible = true;
|
||||
}
|
||||
if (isAccessible) {
|
||||
String message = RefactoringUIUtil.getDescription(abstractMethod, false) +
|
||||
" uses " +
|
||||
RefactoringUIUtil.getDescription(classMember, true) +
|
||||
" which won't be accessible from the subclass.";
|
||||
message = CommonRefactoringUtil.capitalize(message);
|
||||
conflicts.putValue(classMember, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public abstract class Test {
|
||||
abstract void x();
|
||||
|
||||
private void xx(){}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class TestSubclass extends Test {
|
||||
@java.lang.Override
|
||||
void x() {
|
||||
xx();
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class Test {
|
||||
void x() {
|
||||
xx();
|
||||
}
|
||||
|
||||
private void xx(){}
|
||||
}
|
||||
@@ -47,6 +47,13 @@ public class ExtractSuperClassTest extends CodeInsightTestCase {
|
||||
new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class));
|
||||
}
|
||||
|
||||
public void testConflictMoveAbstractWithPrivateMethod() throws Exception {
|
||||
doTest("Test", "TestSubclass",
|
||||
new String[] {"Method <b><code>x()</code></b> uses method <b><code>Test.xx()</code></b> which won't be accessible from the subclass."},
|
||||
new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class, true),
|
||||
new RefactoringTestUtil.MemberDescriptor("xx", PsiMethod.class));
|
||||
}
|
||||
|
||||
public void testConflictUsingPackageLocalMethod() throws Exception {
|
||||
doTest("a.Test", "TestSubclass",
|
||||
new String[] {"method <b><code>Sup.foo()</code></b> won't be accessible"},
|
||||
|
||||
Reference in New Issue
Block a user