mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pull up: ensure varargs as last parameter (IDEA-193132)
This commit is contained in:
@@ -408,6 +408,8 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
|
||||
Initializer i2 = fieldsToInitializers.get(field2);
|
||||
if(i1.movedFieldsUsed.contains(field2)) return 1;
|
||||
if(i2.movedFieldsUsed.contains(field1)) return -1;
|
||||
if (i1.usedParameters.stream().anyMatch(p -> p.isVarArgs())) return 1;
|
||||
if (i2.usedParameters.stream().anyMatch(p -> p.isVarArgs())) return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Super {}
|
||||
class Test extends Super{
|
||||
String[] f2;
|
||||
String f<caret>1;
|
||||
|
||||
public Test(String f1, String... f2) {
|
||||
this.f2 = f2;
|
||||
this.f1 = f1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Super {
|
||||
String[] f2;
|
||||
String f1;
|
||||
|
||||
Super(String f1, String... f2) {
|
||||
this.f1 = f1;
|
||||
this.f2 = f2;
|
||||
}
|
||||
}
|
||||
class Test extends Super{
|
||||
|
||||
public Test(String f1, String... f2) {
|
||||
super(f1, f2);
|
||||
}
|
||||
}
|
||||
@@ -185,6 +185,10 @@ public class PullUpTest extends LightRefactoringTestCase {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class));
|
||||
}
|
||||
|
||||
public void testOrderVarargsParameterLast() {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("f2", PsiField.class), new RefactoringTestUtil.MemberDescriptor("f1", PsiField.class));
|
||||
}
|
||||
|
||||
public void testOuterClassRefsNoConflictIfAsAbstract() {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("bar", PsiMethod.class, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user