mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Extract common conjunct from if-else chain in ExtractIfConditionAction
Fixes IDEA-179499 New inspection: Should break out common conjunct from "if / else if"
This commit is contained in:
+4
-6
@@ -1,15 +1,13 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a)
|
||||
if (a) {
|
||||
if (b) {
|
||||
System.out.println("a&b");//first comment
|
||||
} else {
|
||||
if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
} else if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
else if (c) {
|
||||
} else if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Extract if (a)" "true"
|
||||
class Test {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
/*2*/
|
||||
if (a) {
|
||||
if (b) {
|
||||
System.out.println("a&b");//first comment
|
||||
} else if (c) {
|
||||
System.out.println("a&c"); // three
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Extract if (a)" "true"
|
||||
class Test {
|
||||
void f(boolean a, boolean b, boolean c, boolean d){
|
||||
//a
|
||||
if (a) {
|
||||
if (b) {
|
||||
System.out.println("a&b");//first comment
|
||||
} else if (c) {
|
||||
System.out.println("a&c");//ac
|
||||
} else {
|
||||
System.out.println("a");//a
|
||||
}
|
||||
} else if (d) {
|
||||
System.out.println("d");//d
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Extract if (a)" "true"
|
||||
class Test {
|
||||
void f(boolean a, boolean b, boolean c, boolean d){
|
||||
//a
|
||||
if (a) {
|
||||
if (b) {
|
||||
System.out.println("a&b");//first comment
|
||||
} else {
|
||||
System.out.println("a");//a
|
||||
}
|
||||
} else if (a && c) {
|
||||
System.out.println("a&c");//ac
|
||||
} else if (a && d) {
|
||||
System.out.println("a&d");//ad
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a)
|
||||
if (a) {
|
||||
if (b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
System.out.println("c");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract if (a)" "true"
|
||||
class Test {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (<caret>a && b)
|
||||
System.out.println("a&b");//first comment
|
||||
else if (a && c/*2*/) {
|
||||
System.out.println("a&c"); // three
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Extract if (a)" "true"
|
||||
class Test {
|
||||
void f(boolean a, boolean b, boolean c, boolean d){
|
||||
if (<caret>a && b)
|
||||
System.out.println("a&b");//first comment
|
||||
else if (a && c) {
|
||||
System.out.println("a&c");//ac
|
||||
}
|
||||
else if (a) {
|
||||
System.out.println("a");//a
|
||||
}
|
||||
else if (d) {
|
||||
System.out.println("d");//d
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Extract if (a)" "true"
|
||||
class Test {
|
||||
void f(boolean a, boolean b, boolean c, boolean d){
|
||||
if (<caret>a && b)
|
||||
System.out.println("a&b");//first comment
|
||||
else if (a) {
|
||||
System.out.println("a");//a
|
||||
}
|
||||
else if (a && c) {
|
||||
System.out.println("a&c");//ac
|
||||
}
|
||||
else if (a && d) {
|
||||
System.out.println("a&d");//ad
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user