Java inspection: Supported switch in "Move return to computation", preserve comments (IDEA-121153)

This commit is contained in:
Pavel Dolgov
2016-09-06 19:05:05 +03:00
parent 68276bafcf
commit 26983131ac
6 changed files with 150 additions and 18 deletions
@@ -0,0 +1,17 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a[]) {
int n = 0;
for (int i=0; i<a.length; i++) {
if (n < a[i]) n = a[i];
if (n > 100) {
return n; // at the end 1
}
if (n < 0) {
return 0; // at the end 2
/* inline */
}
}
return n;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 's'" "true"
class T {
int f(String a) {
String s = a;
if (s == null) {
return ""; /* return comment */ // end of line
}
else if (s.startsWith("@")) {
return s.substring(1); // return comment
}
else if (s.startsWith("#")) {
return "#"; /* return comment */ /* inline */
}
return s; // return comment
}
}
@@ -0,0 +1,17 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(int a[]) {
int n = 0;
for (int i=0; i<a.length; i++) {
if (n < a[i]) n = a[i];
if (n > 100) {
break; // at the end 1
}
if (n < 0) {
n = 0; // at the end 2
break; /* inline */
}
}
ret<caret>urn n;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 's'" "true"
class T {
int f(String a) {
String s = a;
if (s == null) {
s = ""; // end of line
}
else if (s.startsWith("@")) {
s = s.substring(1);
}
else if (s.startsWith("#")) {
s = "#"; /* inline */
}
ret<caret>urn s; // return comment
}
}