Java inspection: Fixed handling of break and continue in "Move return to computation" (IDEA-121153)

This commit is contained in:
Pavel Dolgov
2016-09-06 19:05:05 +03:00
parent 30724a89e6
commit 1fea799671
12 changed files with 160 additions and 12 deletions
@@ -0,0 +1,14 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (true) {
n = g();
if(n != 0) return n;
}
}
int g() {
return 1;
}
}
@@ -0,0 +1,15 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (n <= 0) {
n = g();
if (n != 0) return n;
}
return n;
}
int g() {
return 1;
}
}
@@ -5,16 +5,15 @@ class T {
int t = a;
while (t != null) {
if (t == 1) {
n = 10;
return 10;
}
else if (t == 2) {
n = 20;
return 20;
}
else {
t = t + 1;
continue;
}
break;
}
return n;
}
@@ -0,0 +1,15 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (true) {
n = g();
if(n == 0) continue;
else return n;
}
}
int g() {
return 1;
}
}
@@ -0,0 +1,15 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (true) {
n = g();
if(n == 0) continue;
return n;
}
}
int g() {
return 1;
}
}
@@ -0,0 +1,15 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (true) {
n = g();
if(n != 0) break;
}
ret<caret>urn n;
}
int g() {
return 1;
}
}
@@ -0,0 +1,15 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (n <= 0) {
n = g();
if (n != 0) break;
}
ret<caret>urn n;
}
int g() {
return 1;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (true) {
n = g();
if(n == 0) continue;
else break;
}
ret<caret>urn n;
}
int g() {
return 1;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a) {
int n = -1;
while (true) {
n = g();
if(n == 0) continue;
break;
}
ret<caret>urn n;
}
int g() {
return 1;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "false"
class T {
int f(int a) {
int n = -1;
while (n <= 0) {
n = g();
if (n == 0) continue;
n++;
}
ret<caret>urn n;
}
int g() {
return 1;
}
}