Java inspection: Preserve comments from replaced and removed statements in EqualsReplaceableByObjectsCallInspection (IDEA-161076)

This commit is contained in:
Pavel Dolgov
2016-09-16 17:26:41 +03:00
parent 63131ab1b2
commit 40e1b7f91d
7 changed files with 60 additions and 53 deletions
@@ -5,13 +5,13 @@ class T {
for (int i=0; i<a.length; i++) {
if (n < a[i]) n = a[i];
if (n > 100) {
return n; // at the end 1
return /* return 1 */ n /* return 2 */;// at the end 1
}
if (n < 0) {
return 0; // at the end 2
return /* return 1 */ 0 /* return 2 */;// at the end 2
/* inline */
}
}
return n;
return /* return 1 */ n /* return 2 */;
}
}
@@ -3,13 +3,16 @@ class T {
String f(String a) {
String s = a;
if (s == null) {
return ""; /* return comment */ // end of line
return ""; // return comment
// end of line
}
else if (s.startsWith("@")) {
return s.substring(1); // return comment
/* inline 1 *//* inline 2 */
}
else if (s.startsWith("#")) {
return "#"; /* return comment */ /* inline */
return "#"; // return comment
/* inline */
}
return s; // return comment
}
@@ -3,15 +3,15 @@ class T {
int f(int[][] a) {
int n = -1;
myLabel:
for (int i = 0; i < a.length; i++) {
if (a[i].length == 0) {
return -i - 1;
}
for(int j = 0; j < a[i].length; j++) {
n = j;
if (a[i][j] == 0) return n;
}
}
return n;
for (int i = 0; i < a.length; i++) {
if (a[i].length == 0) {
return -i - 1;
}
for(int j = 0; j < a[i].length; j++) {
n = j;
if (a[i][j] == 0) return n;
}
}
return n;
}
}
@@ -12,6 +12,6 @@ class T {
break; /* inline */
}
}
ret<caret>urn n;
ret<caret>urn /* return 1 */ n /* return 2 */;
}
}
@@ -6,7 +6,7 @@ class T {
s = ""; // end of line
}
else if (s.startsWith("@")) {
s = s.substring(1);
s = /* inline 1 */ s.substring(1); /* inline 2 */
}
else if (s.startsWith("#")) {
s = "#"; /* inline */
@@ -3,16 +3,16 @@ class T {
int f(int[][] a) {
int n = -1;
myLabel:
for (int i = 0; i < a.length; i++) {
if (a[i].length == 0) {
n = -i - 1;
break myLabel;
}
for(int j = 0; j < a[i].length; j++) {
n = j;
if (a[i][j] == 0) break myLabel;
}
}
re<caret>turn n;
for (int i = 0; i < a.length; i++) {
if (a[i].length == 0) {
n = -i - 1;
break myLabel;
}
for(int j = 0; j < a[i].length; j++) {
n = j;
if (a[i][j] == 0) break myLabel;
}
}
re<caret>turn n;
}
}