[java-refactoring] Better vararg handling in change signature

1. Properly handle non-vararg call sites
2. Update callsites when vararg type was changed to non-vararg or vice versa (without reordering, etc.)
Fixes IDEA-318626 Change signature incorrectly wraps/unwraps arguments when changing between varargs and arrays

GitOrigin-RevId: 3372a144be4363fef2c40e8968a07d8ed6b916a6
This commit is contained in:
Tagir Valeev
2023-04-28 09:59:55 +02:00
committed by intellij-monorepo-bot
parent 04f87958b9
commit be6a068d76
16 changed files with 175 additions and 61 deletions

View File

@@ -0,0 +1,8 @@
public class X
{
void doSo<caret>mething(int x, String[] args) { /* ... */ }
void use() {
doSomething(0, new String[]{"one", "two"});
}
}

View File

@@ -0,0 +1,8 @@
public class X
{
void doSomething(int x, String... args) { /* ... */ }
void use() {
doSomething(0, "one", "two");
}
}

View File

@@ -0,0 +1,8 @@
class X {
<caret>X(String... args) {}
X(int x) {
this();
}
}
class Y extends X {}

View File

@@ -0,0 +1,12 @@
class X {
X(String[] args) {}
X(int x) {
this(new String[]{});
}
}
class Y extends X {
Y() {
super(new String[]{});
}
}

View File

@@ -0,0 +1,7 @@
public enum X
{
A(0, "foo", "bar"),
B(0, new String[]{"one", "two"});
<caret>X(int x, String... args) { /* ... */ }
}

View File

@@ -0,0 +1,7 @@
public enum X
{
A(0, new String[]{"foo", "bar"}),
B(0, new String[]{"one", "two"});
X(int x, String[] args) { /* ... */ }
}

View File

@@ -0,0 +1,9 @@
public class X
{
void doSo<caret>mething(int x, String... args) { /* ... */ }
void use() {
doSomething(0, "foo", "bar");
doSomething(0, new String[]{"one", "two"});
}
}

View File

@@ -0,0 +1,9 @@
public class X
{
void doSome<caret>thing(int x, String... args) { /* ... */ }
void use() {
doSomething(0, "foo", "bar");
doSomething(0, new String[]{"one", "two"});
}
}

View File

@@ -0,0 +1,9 @@
public class X
{
void doSomething(String[] args, int x) { /* ... */ }
void use() {
doSomething(new String[]{"foo", "bar"}, 0);
doSomething(new String[]{"one", "two"}, 0);
}
}

View File

@@ -0,0 +1,9 @@
public class X
{
void doSomething(int x, String[] args) { /* ... */ }
void use() {
doSomething(0, new String[]{"foo", "bar"});
doSomething(0, new String[]{"one", "two"});
}
}