Java: Fixed the intention "Invert 'if' condition" in the case of nested 'if' without braces (IDEA-167957)

This commit is contained in:
Pavel Dolgov
2017-02-20 14:36:31 +03:00
parent 008dea7c9a
commit 1b5600e2c4
9 changed files with 137 additions and 19 deletions
@@ -0,0 +1,12 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
if (a) {
if (b) {
return false;
}
return true;
}
return false;
}
}
@@ -0,0 +1,13 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
for (int i = 1; i < 10; i++)
if (a) {
if (b) /* comment 1 */ {
continue;
}
return true; /* comment 2 */
}
return false; /* comment 3 */
}
}
@@ -0,0 +1,14 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
if (a) {
if (b) {
}
else {
return true; // comment
}
}
int x = 1;
return false;
}
}
@@ -0,0 +1,13 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
for (int i = 1; i < 10; i++)
{
if (b) {
continue;
}
return true;
}
return false;
}
}
@@ -0,0 +1,9 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
if (a)
<caret>if (!b)
return true;
return false;
}
}
@@ -0,0 +1,10 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
for (int i = 1; i < 10; i++)
if (a)
<caret>if (!b) /* comment 1 */
return true; /* comment 2 */
return false; /* comment 3 */
}
}
@@ -0,0 +1,10 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
if (a)
<caret>if (!b)
return true; // comment
int x = 1;
return false;
}
}
@@ -0,0 +1,9 @@
// "Invert 'if' condition" "true"
class Main {
boolean method(boolean a, boolean b) {
for (int i = 1; i < 10; i++)
<caret>if (!b)
return true;
return false;
}
}