IDEA-105132 Swap adjoined if-statements intention. Invokes on "else" keyword

This commit is contained in:
Dmitry Batkovich
2014-06-11 15:13:02 +04:00
parent d4d7c04321
commit aac112074d
13 changed files with 238 additions and 0 deletions
@@ -0,0 +1,16 @@
// "Swap If Statements" "true"
class A {
void m() {
if (otherCondition) {
doAnotherAction();
} else if (someCondition) {
doSomeAction();
} else {
defaultAction();
}
}
}
@@ -0,0 +1,20 @@
// "Swap If Statements" "true"
class A {
void m() {
if (a) {
System.out.println(1);
} else if (c) {
System.out.println(3);
} else if (b) {
System.out.println(2);
} else if (d) {
System.out.println(4);
} else {
System.out.println(5);
}
}
}
@@ -0,0 +1,12 @@
// "Swap If Statements" "true"
class A {
void m() {
if (cond2) m2();
else if (cond1) m1();
else if (cond3) m3();
}
}
@@ -0,0 +1,16 @@
// "Swap If Statements" "true"
class A {
void m() {
if (someCondition) {
doSomeAction();
} e<caret>lse if (otherCondition) {
doAnotherAction();
} else {
defaultAction();
}
}
}
@@ -0,0 +1,20 @@
// "Swap If Statements" "true"
class A {
void m() {
if (a) {
System.out.println(1);
} else if (b) {
System.out.println(2);
} el<caret>se if (c) {
System.out.println(3);
} else if (d) {
System.out.println(4);
} else {
System.out.println(5);
}
}
}
@@ -0,0 +1,10 @@
// "Swap If Statements" "false"
class A {
void m() {
if (someCondition) {
doSomeAction();
} e<caret>lse {
defaultAction();
}
}
}
@@ -0,0 +1,12 @@
// "Swap If Statements" "true"
class A {
void m() {
if (cond1) m1();
el<caret>se if (cond2) m2();
else if (cond3) m3();
}
}