IDEA-178774 Unroll loop intention action

This commit is contained in:
Tagir Valeev
2017-09-12 09:25:51 +07:00
parent 13a641fd64
commit 94a5fea51d
16 changed files with 313 additions and 1 deletions
@@ -0,0 +1,17 @@
// "Unroll loop" "true"
class Test {
void test(Object y) {
System.out.println((Object) "one");
if (!(Math.random() > 0.5)) {
System.out.println((Object) 1);
if (!(Math.random() > 0.5)) {
System.out.println((Object) 1.0);
if (!(Math.random() > 0.5)) {
System.out.println((Object) 1.0f);
if (!(Math.random() > 0.5)) {
}
}
}
}
}
}
@@ -0,0 +1,19 @@
// "Unroll loop" "true"
import java.util.*;
class Test {
void test() {
if (!"foo".isEmpty()) {
System.out.println("foo");
}
if (!"bar".isEmpty()) {
System.out.println("bar");
}
if (!"baz".isEmpty()) {
System.out.println("baz");
}
if (!"".isEmpty()) {
System.out.println("");
}
}
}
@@ -0,0 +1,9 @@
// "Unroll loop" "true"
class Test {
void test() {
System.out.println(1);
System.out.println(2);
System.out.println(3);
System.out.println(4);
}
}
@@ -0,0 +1,11 @@
// "Unroll loop" "true"
class Test {
void test() {
foo(true);
unresolved(!true);
foo(false);
unresolved(!false);
}
void foo(boolean b) {}
}
@@ -0,0 +1,11 @@
// "Unroll loop" "false"
class Test {
void test() {
fo<caret>r(Object x : new Object[] {"one", 1, 1.0, 1.0f}) {
if(Math.random() > 0.5) break;
System.out.println(x);
}
}
void foo(boolean b) {}
}
@@ -0,0 +1,9 @@
// "Unroll loop" "true"
class Test {
void test(Object y) {
fo<caret>r(Object x : new Object[] {"one", 1, 1.0, 1.0f}) {
System.out.println(x);
if(Math.random() > 0.5) break;
}
}
}
@@ -0,0 +1,12 @@
// "Unroll loop" "true"
import java.util.*;
class Test {
void test() {
fo<caret>r(String s : Arrays.asList("foo", "bar", "baz", "")) {
if(!s.isEmpty()) {
System.out.println(s);
}
}
}
}
@@ -0,0 +1,8 @@
// "Unroll loop" "true"
class Test {
void test() {
fo<caret>r(int i : new int[] {1,2,3,4}) {
System.out.println(i);
}
}
}
@@ -0,0 +1,12 @@
// "Unroll loop" "true"
class Test {
void test() {
boolean steps = {true, false};
fo<caret>r(boolean step : steps) {
foo(step);
unresolved(!step);
}
}
void foo(boolean b) {}
}