do not replace diamonds without necessity (IDEA-87172)

This commit is contained in:
Anna Kozlova
2012-06-08 16:07:19 +04:00
parent c6953ea96b
commit 78cf87d2c8
9 changed files with 111 additions and 4 deletions
@@ -0,0 +1,22 @@
public class TestCompletion {
public static <T, V> ParallelPipeline<T, V> test(T base, V newStage, T upstream, final ParallelPipeline<T, V> anObject) {
if (base != null){
return anObject;
}
else {
return new ParallelPipeline<>(upstream, newStage);
}
}
void f() {
test(null, null, null, new ParallelPipeline<>(null, null));
}
private static class ParallelPipeline<T, V> {
public ParallelPipeline(T p0, V p1) {
}
}
}
@@ -0,0 +1,22 @@
public class TestCompletion {
public static <T, V> ParallelPipeline<T, V> test(T base, V newStage, T upstream) {
if (base != null){
return <selection>new ParallelPipeline<>(base, newStage)</selection>;
}
else {
return new ParallelPipeline<>(upstream, newStage);
}
}
void f() {
test(null, null, null);
}
private static class ParallelPipeline<T, V> {
public ParallelPipeline(T p0, V p1) {
}
}
}
@@ -275,6 +275,10 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
public void testPreserveDiamondOccurrences() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
public void testSubstituteTypeParams() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}