Java: Fixed removing unused variable occurrences from 'for' loop's update and init clauses (IDEA-180217)

This commit is contained in:
Pavel Dolgov
2017-10-11 15:35:05 +03:00
parent 4d1baa29be
commit 24a6c66183
17 changed files with 196 additions and 2 deletions
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case01() {
int i = 10;
for(; (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case01() {
int i;
for(i = 10; (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
int i = 10;
for(foo(); (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
int i;
for(i = 10, foo(); (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,10 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case01() {
for(int i = 10; (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,10 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case02() {
for(int i = 10; i > 0; i--) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,10 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
for(int i = 10; (--i) > 0; foo()) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,10 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
for(int i = 10; i > 0; --i, foo()) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,12 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case01() {
Object <caret>problematic;
int i = 10;
for(problematic = foo; (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,12 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case01() {
Object <caret>problematic;
int i;
for(i = 10, problematic = foo; (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,12 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
Object <caret>problematic;
int i = 10;
for(problematic = foo(); (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,12 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
Object <caret>problematic;
int i;
for(i = 10, problematic = foo(); (--i) > 0; ) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case01() {
Object <caret>problematic;
for(int i = 10; (--i) > 0; problematic = foo) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo = null;
void case02() {
Object <caret>problematic;
for(int i = 10; i > 0; i--, problematic = foo) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
Object <caret>problematic;
for(int i = 10; (--i) > 0; problematic = foo()) {
System.out.println("index = " + i);
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'problematic'" "true"
class C {
Object foo() {return null;}
void case01() {
Object <caret>problematic;
for(int i = 10; i > 0; --i, problematic = foo()) {
System.out.println("index = " + i);
}
}
}