change signature: highest visibility should not return PUBLIC all at once (IDEA-111739)

This commit is contained in:
Anna Kozlova
2013-08-09 14:21:27 +02:00
parent 7cf4be2861
commit b685972a85
4 changed files with 25 additions and 7 deletions
@@ -50,13 +50,7 @@ public class VisibilityUtil {
@PsiModifier.ModifierConstant
public static String getHighestVisibility(@PsiModifier.ModifierConstant String v1, @PsiModifier.ModifierConstant String v2) {
if(v1.equals(v2)) return v1;
if(PsiModifier.PRIVATE.equals(v1)) return v2;
if(PsiModifier.PUBLIC.equals(v1)) return PsiModifier.PUBLIC;
if(PsiModifier.PRIVATE.equals(v2)) return v1;
return PsiModifier.PUBLIC;
return compare(v1, v2) < 0 ? v1 : v2;
}
public static void escalateVisibility(PsiMember modifierListOwner, PsiElement place) throws IncorrectOperationException {
@@ -0,0 +1,10 @@
class Test {
protected void fo<caret>o() {
}
}
class subclass extends Test {
@Override
protected void foo() {
}
}
@@ -0,0 +1,10 @@
class Test {
void foo() {
}
}
class subclass extends Test {
@Override
protected void foo() {
}
}
@@ -355,6 +355,10 @@ public class ChangeSignatureTest extends LightRefactoringTestCase {
doTest(null, null, "Exception", new SimpleParameterGen(), new SimpleExceptionsGen(), false);
}
public void testVisibilityOfOverriddenMethod() throws Exception {
doTest(PsiModifier.PACKAGE_LOCAL, "foo", "void", new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
}
public void testRemoveExceptions() throws Exception {
doTest(null, null, "void", new SimpleParameterGen(), new SimpleExceptionsGen(), false);
}