Fix IDEA-177647 Convert String to StringBuilder intention produces wrong code

This commit is contained in:
Tagir Valeev
2017-08-17 17:49:45 +07:00
parent 7878a20a75
commit f73a5572c0
3 changed files with 56 additions and 9 deletions

View File

@@ -0,0 +1,16 @@
// "Convert variable 'str1' from String to StringBuilder" "true"
public class IntentionBug {
public static void main(String[] args) {
/*1*/
/*2*/
StringBuilder str1 = new StringBuilder();
for (char i = 'a'; i < 'd'; i++) {
str1.append(i).append((char) (i + 1));
str1.append(i).append((char) (i + 1));
str1.append(1).append(2).append(3);
str1.append(1 + 2 + 3);
}
System.out.println(str1);
}
}

View File

@@ -0,0 +1,14 @@
// "Convert variable 'str1' from String to StringBuilder" "true"
public class IntentionBug {
public static void main(String[] args) {
String str1 = "";
for (char i = 'a'; i < 'd'; i++) {
str1 = str1 <caret>+ i + (char) (i + 1);
str1 = /*1*/str1/*2*/+ i + (char) (i + 1);
str1 = str1+1+2+3;
str1 = str1+(1+2+3);
}
System.out.println(str1);
}
}