| Summary: | [quick assist] Convert Immutable to Mutable (String to StringBuffer) | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Mohamed ZERGAOUI <xmlizer> |
| Component: | UI | Assignee: | Martin Aeschlimann <martinae> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P4 | CC: | martinae |
| Version: | 3.0 | Keywords: | helpwanted |
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Mohamed ZERGAOUI
This is more a quick assist than a refactoring. This is an example
<pre>
...
String s = "";
for(int i = 0; i < MAX; i++) {
switch (i % 3) {
case 0 :
s += "a";
break;
case 1 :
s += "b";
break;
case 2 :
default :
s = "c" + s;
}
}
System.out.println(s);
...
</pre>
and when you select "s" and choose the quick assist "convert to StringBuffer"
or "convert to StringBuilder" (for 1.5)
you'll have
<pre>
...
StringBuffer s = new StringBuffer("");
for(int i = 0; i < MAX; i++) {
switch (i % 3) {
case 0 :
s.append("a");
break;
case 1 :
s.append("b");
break;
case 2 :
default :
s.insert(0, "c");
}
}
System.out.println(s);
...
</pre>
Is there any push in this direction ? There are no plans at the moment for such a feature. Help is welcome to add this as a new quick assist. |