mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 07:40:42 +07:00
SplitIfAction and ExtractIfConditionAction code unified
Fixes IDEA-152047 Better "Split into 2 if's" result for else-if cases
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
void foo(boolean a, boolean b, boolean c) {
|
||||
if (a) {
|
||||
if (b) {
|
||||
System.out.println("ab");
|
||||
} else if (c) {
|
||||
System.out.println("ac");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
void foo(boolean a, boolean b, boolean c, boolean d, boolean e) {
|
||||
/*c3*/
|
||||
/*c4*/
|
||||
if (a &&/*c1*/ b) {
|
||||
if (c &&/*c2*/ d) {
|
||||
System.out.println("abcd");
|
||||
} else if (e) {
|
||||
System.out.println("abe");
|
||||
} else {
|
||||
System.out.println("ab");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
void foo(boolean a, boolean b, boolean c, boolean d, boolean e) {
|
||||
/*c3*/
|
||||
if (a &&/*c1*/ b) {
|
||||
if (c &&/*c2*/ d) {
|
||||
System.out.println("abcd");
|
||||
} else if (e) {
|
||||
System.out.println("abe");
|
||||
} else if (a && /*c4*/ c) {
|
||||
System.out.println("ac");
|
||||
}
|
||||
} else if (a && /*c4*/ c) {
|
||||
System.out.println("ac");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
class C {
|
||||
void foo() {
|
||||
//comment
|
||||
if (a) {
|
||||
call();
|
||||
} else if (b) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class C {
|
||||
void foo() {
|
||||
//comment
|
||||
if (a /*inside*/ || c) {
|
||||
call();
|
||||
} else if (b) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
public class SplitCondition {
|
||||
private static void appendString(StringBuilder builder, boolean condition) {
|
||||
if (condition) {
|
||||
if (builder.length() > 0) {
|
||||
}
|
||||
}
|
||||
if (condition) {
|
||||
if (builder.length() > 0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
void foo(boolean a, boolean b, boolean c) {
|
||||
if (a &<caret>& b) {
|
||||
System.out.println("ab");
|
||||
} else if(a && c) {
|
||||
System.out.println("ac");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
void foo(boolean a, boolean b, boolean c, boolean d, boolean e) {
|
||||
if (a &&/*c1*/ b &<caret>& c &&/*c2*/ d) {
|
||||
System.out.println("abcd");
|
||||
} else if(a /*c3*/ && b && e) {
|
||||
System.out.println("abe");
|
||||
} else if(a && /*c4*/ b) {
|
||||
System.out.println("ab");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
void foo(boolean a, boolean b, boolean c, boolean d, boolean e) {
|
||||
if (a &&/*c1*/ b &<caret>& c &&/*c2*/ d) {
|
||||
System.out.println("abcd");
|
||||
} else if(a /*c3*/ && b && e) {
|
||||
System.out.println("abe");
|
||||
} else if(a && /*c4*/ c) {
|
||||
System.out.println("ac");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a |<caret>| //comment
|
||||
if (a |<caret>| //comment
|
||||
b) {
|
||||
call();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a /*inside*/ || c |<caret>| //comment
|
||||
b) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user