mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
[IDEA-295460] ConditionalBreak: Handle else & finite loop
GitOrigin-RevId: 51df8f08a54c35043d45f728e80f10f68543feee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a124d59a71
commit
d5963c01d2
@@ -0,0 +1,15 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
/*1*/
|
||||
/*2*/
|
||||
/*3*/
|
||||
/*7*/
|
||||
/*8*/
|
||||
while (i % 10 != 0 && i < 12) {
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
/*1*/
|
||||
/*2*/
|
||||
/*3*/
|
||||
/*7*/
|
||||
/*8*/
|
||||
do {
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
/*4*/
|
||||
} while (i < 12 && i % 10 != 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
/*1*/
|
||||
/*2*/
|
||||
/*3*/
|
||||
/*7*/
|
||||
/*8*/
|
||||
while (i % 10 != 0 && i < 12) {
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while (i < 12) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
private int variableWithSameName = 1;
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
while (i < 100) {
|
||||
int variableWithAnotherName = -100;
|
||||
i = i + variableWithSameName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while (i < 14) {
|
||||
i++;
|
||||
System.out.println("I'm doing two things in this loop");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while (i < 13) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
boolean isValid = true;
|
||||
boolean isEnabled = true;
|
||||
int i = 1;
|
||||
/*1*/
|
||||
/*2*/
|
||||
/*3*/
|
||||
/*7*/
|
||||
/*8*/
|
||||
while (i % 10 != 0 && (!isValid/*9*/ ||/*10*/ !isEnabled)) {
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
boolean isValid = true;
|
||||
boolean isEnabled = true;
|
||||
int i = 1;
|
||||
/*1*/
|
||||
/*2*/
|
||||
/*3*/
|
||||
/*7*/
|
||||
/*8*/
|
||||
while ((isValid || isEnabled) && i < 12) {
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while (i < 14) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move condition to loop" "false"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
do<caret> {
|
||||
if (i < 100) {
|
||||
break;
|
||||
} else {
|
||||
i = i * 3;
|
||||
}
|
||||
} while(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Move condition to loop" "false"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
annoyingLabel: while(j++ < 100) {
|
||||
while<caret>(true) {
|
||||
i++;
|
||||
if(i < 0) {
|
||||
break annoyingLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
for<caret>(;i % 10 != 0/*7*/;) /*8*/ {
|
||||
if(i >= 12/*1*/)/*2*/ break;/*3*/
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
do {
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
/*4*/
|
||||
if(i >= 12/*1*/)/*2*/ break;/*3*/
|
||||
} while<caret>(i % 10 != 0/*7*/) /*8*/;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
while<caret>(i % 10 != 0/*7*/) /*8*/ {
|
||||
if(i >= 12/*1*/)/*2*/ break;/*3*/
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Move condition to loop" "false"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
do {
|
||||
if(i > 100) break;
|
||||
i = i * 2;
|
||||
} while<caret>(i % 10 != 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
for<caret>(;;) {
|
||||
if (i >= 12) {
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
private int variableWithSameName = 1;
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
while<caret>(true) {
|
||||
if (i >= 100) {
|
||||
break;
|
||||
} else {
|
||||
int variableWithAnotherName = -100;
|
||||
}
|
||||
i = i + variableWithSameName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while<caret>(true) {
|
||||
if (i < 14) {
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
System.out.println("I'm doing two things in this loop");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while<caret> (true) {
|
||||
if (i < 13) {
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
boolean isValid = true;
|
||||
boolean isEnabled = true;
|
||||
int i = 1;
|
||||
while<caret>(i % 10 != 0/*7*/) /*8*/ {
|
||||
if(isValid/*9*/ &&/*10*/ isEnabled/*1*/)/*2*/ break;/*3*/
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
boolean isValid = true;
|
||||
boolean isEnabled = true;
|
||||
int i = 1;
|
||||
while<caret>(isValid || isEnabled/*7*/) /*8*/ {
|
||||
if(i >= 12/*1*/)/*2*/ break;/*3*/
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move condition to loop" "false"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
boolean isValid = true;
|
||||
boolean isEnabled = true;
|
||||
int i = 1;
|
||||
while<caret>(i % 10 != 0 && i < 100/*7*/) /*8*/ {
|
||||
if(isValid/*9*/ ||/*10*/ isEnabled/*1*/)/*2*/ break;/*3*/
|
||||
/*4*/
|
||||
i =/*5*/ i * 2;/*6*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Move condition to loop" "true"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
for<caret>(;;) {
|
||||
if (i >= 14)
|
||||
break;
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Move condition to loop" "false"
|
||||
class Main {
|
||||
private int variableWithSameName = 1;
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
while<caret>(true) {
|
||||
if (i < 100) {
|
||||
break;
|
||||
} else {
|
||||
int variableWithSameName = -100;
|
||||
}
|
||||
i = i + variableWithSameName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Move condition to loop" "false"
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
while<caret>(i % 10 != 0) {
|
||||
i = i * 2;
|
||||
if(i > 100) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user