introduce parameter: do not insert additional arg when selection was in the self call (IDEA-66896)

This commit is contained in:
anna
2012-04-16 09:21:10 +02:00
parent 488e3c72b6
commit 584cf8b16b
8 changed files with 88 additions and 3 deletions
@@ -0,0 +1,9 @@
class Test {
void foo(boolean flag, int i, final int anObject) {
if (flag) {
foo(false, i, anObject);
}
System.out.println();
foo(false, i, anObject);
}
}
@@ -0,0 +1,9 @@
class Test {
void foo(boolean flag, final String anObject, int... i) {
if (flag) {
foo(false, anObject, i);
}
System.out.println();
foo(flag, anObject, i);
}
}
@@ -0,0 +1,6 @@
class Test {
void foo(final String anObject, int... i) {
foo(anObject, 1);
foo(anObject, 3);
}
}
@@ -0,0 +1,9 @@
class Test {
void foo(boolean flag, int i) {
if (flag) {
foo(false, i, <selection>i + 1</selection>);
}
System.out.println();
foo(false, i);
}
}
@@ -0,0 +1,9 @@
class Test {
void foo(boolean flag, int... i) {
if (flag) {
foo(false, <selection>""</selection>, i);
}
System.out.println();
foo(flag, i);
}
}
@@ -0,0 +1,6 @@
class Test {
void foo(int... i) {
foo(<selection>""</selection>, 1);
foo(3);
}
}
@@ -283,6 +283,18 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, true);
}
public void testSelfReference() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
public void testSelfReferenceVarargs() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
public void testSelfReferenceVarargs1() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
private void doTestThroughHandler() throws Exception {
configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
boolean enabled = true;