mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 02:38:59 +07:00
IDEA-167466 String concatenation in loop inspection: provide additional quick-fix to introduce a new StringBuilder;
String concatenation in loop is enabled by default now
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// "Introduce new StringBuilder to update variable 's'" "true"
|
||||
|
||||
public class Main {
|
||||
void test(boolean b) {
|
||||
String s = "";
|
||||
if (b) {
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
for(int i = 0; i<10; i++) {
|
||||
if(sBuilder.indexOf("a") > 0) {
|
||||
System.out.println(sBuilder);
|
||||
break;
|
||||
}
|
||||
sBuilder.append(i);
|
||||
}
|
||||
s = sBuilder.toString();
|
||||
}
|
||||
s = s.trim();
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Introduce new StringBuilder to update variable 's'" "true"
|
||||
|
||||
public class Main {
|
||||
void test(String s) {
|
||||
StringBuilder sBuilder = new StringBuilder(s);
|
||||
for(int i = 0; i<10; i++) {
|
||||
sBuilder.append(i);
|
||||
}
|
||||
s = sBuilder.toString();
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Introduce new StringBuilder to update variable 's'" "true"
|
||||
|
||||
public class Main {
|
||||
void test(boolean b) {
|
||||
String s = "";
|
||||
if (b)
|
||||
for(int i=0; i<10; i++) {
|
||||
if(s.indexOf("a") > 0) {
|
||||
System.out.println(s);
|
||||
break;
|
||||
}
|
||||
s+<caret>=i;
|
||||
}
|
||||
s = s.trim();
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Introduce new StringBuilder to update variable 's'" "true"
|
||||
|
||||
public class Main {
|
||||
void test(String s) {
|
||||
for(int i=0; i<10; i++) {
|
||||
s+<caret>=i;
|
||||
}
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user