Remove unnecessary StringBuilder usages

This commit is contained in:
Bas Leijdekkers
2012-02-02 10:30:11 +01:00
parent 7dc835726a
commit 7013733394
12 changed files with 41 additions and 66 deletions
@@ -81,16 +81,14 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
final FileElement fileElement = file.loadTreeElement();
node = myNode;
if (node == null) {
String message = new StringBuilder().
append("Failed to bind stub to AST for element ").
append(getClass()).
append(" in ").
append(file.getVirtualFile() == null ? "<unknown file>" : file.getVirtualFile().getPath()).
append("\nFile stub tree:\n").
append(stubTree != null ? StringUtil.trimLog(((PsiFileStubImpl)stubTree.getRoot()).printTree(), 1024) : " is null").
append("\nLoaded file AST:\n").
append(StringUtil.trimLog(DebugUtil.treeToString(fileElement, true), 1024)).
toString();
String message = "Failed to bind stub to AST for element " +
getClass() +
" in " +
(file.getVirtualFile() == null ? "<unknown file>" : file.getVirtualFile().getPath()) +
"\nFile stub tree:\n" +
(stubTree != null ? StringUtil.trimLog(((PsiFileStubImpl)stubTree.getRoot()).printTree(), 1024) : " is null") +
"\nLoaded file AST:\n" +
StringUtil.trimLog(DebugUtil.treeToString(fileElement, true), 1024);
throw new IllegalArgumentException(message);
}
}
@@ -83,12 +83,12 @@ public class ProjectUtil {
final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project);
if (libraryEntry != null) {
if (libraryEntry instanceof JdkOrderEntry) {
url = new StringBuilder(url).append(" - [").append(((JdkOrderEntry)libraryEntry).getJdkName()).append("]").toString();
url = url + " - [" + ((JdkOrderEntry)libraryEntry).getJdkName() + "]";
} else {
url = new StringBuilder(url).append(" - [").append(libraryEntry.getPresentableName()).append("]").toString();
url = url + " - [" + libraryEntry.getPresentableName() + "]";
}
} else {
url = new StringBuilder(url).append(" - [").append(fileForJar.getName()).append("]").toString();
url = url + " - [" + fileForJar.getName() + "]";
}
}
}
@@ -96,8 +96,8 @@ public class ProjectUtil {
final Module module = ModuleUtil.findModuleForFile(file, project);
if (module == null) return url;
return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ?
new StringBuffer().append(url).append(" - [").append(module.getName()).append("]").toString() :
new StringBuffer().append("[").append(module.getName()).append("] - ").append(url).toString();
url + " - [" + module.getName() + "]" :
"[" + module.getName() + "] - " + url;
}
}
@@ -67,12 +67,6 @@ public class StubPath {
}
public String toString() {
return new StringBuilder().
append(myParentPath != null ? myParentPath.toString() : "").
append("::(").
append(myType.toString()).
append(":").
append(myId).
append(")").toString();
return (myParentPath != null ? myParentPath.toString() : "") + "::(" + myType.toString() + ":" + myId + ")";
}
}
@@ -272,11 +272,6 @@ public class DimensionService implements PersistentStateComponent<Element>, Appl
final Point topLeft = frame.getLocation();
Point center = new Point(topLeft.x + frame.getWidth() / 2, topLeft.y + frame.getHeight() / 2);
final Rectangle frameScreen = ScreenUtil.getScreenRectangle(center);
return new StringBuffer(key)
.append('.').append(frameScreen.x)
.append('.').append(frameScreen.y)
.append('.').append(frameScreen.width)
.append('.').append(frameScreen.height)
.toString();
return key + '.' + frameScreen.x + '.' + frameScreen.y + '.' + frameScreen.width + '.' + frameScreen.height;
}
}
@@ -481,7 +481,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
g2d.fillRect(insets.left, insets.top, bounds.width - insets.left - insets.right, bounds.height - insets.top - insets.bottom);
g2d.setColor(getForeground());
final String sizeString = new StringBuilder().append(myWidth).append(" x ").append(myHeight).toString();
final String sizeString = String.valueOf(myWidth) + " x " + myHeight;
FontMetrics fm = g2d.getFontMetrics();
int sizeWidth = fm.stringWidth(sizeString);
@@ -595,46 +595,42 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
private static class PointRenderer extends JLabel implements Renderer<Point> {
public JComponent setValue(@NotNull final Point value) {
setText(new StringBuilder().append(value.x).append(':').append(value.y).toString());
setText(String.valueOf(value.x) + ':' + value.y);
return this;
}
}
private static class DimensionRenderer extends JLabel implements Renderer<Dimension> {
public JComponent setValue(@NotNull final Dimension value) {
setText(new StringBuilder().append(value.width).append(" x ").append(value.height).toString());
setText(String.valueOf(value.width) + " x " + value.height);
return this;
}
}
private static class InsetsRenderer extends JLabel implements Renderer<Insets> {
public JComponent setValue(@NotNull final Insets value) {
setText(new StringBuilder("top: ").append(value.top).append(" left:").append(value.left).append(" bottom:").append(value.bottom)
.append(" right:").append(value.right).toString());
setText("top: " + value.top + " left:" + value.left + " bottom:" + value.bottom + " right:" + value.right);
return this;
}
}
private static class RectangleRenderer extends JLabel implements Renderer<Rectangle> {
public JComponent setValue(@NotNull final Rectangle value) {
setText(new StringBuilder().append(value.x).append(":").append(value.y).append(", ").append(value.width)
.append(" x ").append(value.height).toString());
setText(String.valueOf(value.x) + ":" + value.y + ", " + value.width + " x " + value.height);
return this;
}
}
private static class ColorRenderer extends JLabel implements Renderer<Color> {
public JComponent setValue(@NotNull final Color value) {
setText(new StringBuilder("r:").append(value.getRed()).append(", g:").append(value.getGreen()).append(", b:").append(value.getBlue())
.toString());
setText("r:" + value.getRed() + ", g:" + value.getGreen() + ", b:" + value.getBlue());
return this;
}
}
private static class FontRenderer extends JLabel implements Renderer<Font> {
public JComponent setValue(@NotNull final Font value) {
setText(new StringBuilder(value.getFontName()).append(" (").append(value.getFamily()).append("), ").append(value.getSize()).
append("px").toString());
setText(value.getFontName() + " (" + value.getFamily() + "), " + value.getSize() + "px");
return this;
}
}
@@ -53,11 +53,7 @@ public class ColorUtil {
final String R = Integer.toHexString(c.getRed());
final String G = Integer.toHexString(c.getGreen());
final String B = Integer.toHexString(c.getBlue());
return new StringBuffer()
.append(R.length() < 2 ? "0" : "").append(R)
.append(G.length() < 2 ? "0" : "").append(G)
.append(B.length() < 2 ? "0" : "").append(B)
.toString();
return (R.length() < 2 ? "0" : "") + R + (G.length() < 2 ? "0" : "") + G + (B.length() < 2 ? "0" : "") + B;
}
/**
@@ -96,8 +96,7 @@ public class ShowAllAffectedGenericAction extends AnAction {
}
private static String failedText(VirtualFile virtualFile, VcsRevisionNumber revision) {
return new StringBuilder().append("Show all affected files for ").append(virtualFile.getPath()).append(" at ")
.append(revision.asString()).append(" failed").toString();
return "Show all affected files for " + virtualFile.getPath() + " at " + revision.asString() + " failed";
}
@Override
@@ -303,9 +303,7 @@ public class VcsChangeDetailsManager {
}
private static String changeDescription(Change o) {
return new StringBuilder().append(ChangesUtil.getFilePath(o).getName()).append(" (").append(
o.getBeforeRevision() == null
? "New" : beforeRevisionText(o)).append(")").toString();
return ChangesUtil.getFilePath(o).getName() + " (" + (o.getBeforeRevision() == null ? "New" : beforeRevisionText(o)) + ")";
}
private static String beforeRevisionText(Change o) {
@@ -206,9 +206,10 @@ public class ApplyPatchAction extends DumbAwareAction {
final VirtualFile file,
ApplyPatchForBaseRevisionTexts texts,
boolean readonly) {
final SimpleDiffRequest simpleRequest = new SimpleDiffRequest(project, new StringBuilder().append("Result Of Patch Apply To ")
.append(file.getName()).append(" (").append(file.getParent() == null ? file.getPath() : file.getParent().getPath()).append(")")
.toString());
final SimpleDiffRequest simpleRequest =
new SimpleDiffRequest(project, "Result Of Patch Apply To " + file.getName() + " (" +
(file.getParent() == null ? file.getPath() : file.getParent().getPath()) +
")");
final DocumentImpl patched = new DocumentImpl(texts.getPatched());
patched.setReadOnly(false);
@@ -224,7 +224,7 @@ public class UsersFilterAction extends BasePopupAction {
}
private String getMeText(final String name) {
return new StringBuilder().append("me ( ").append(name).append(" )").toString();
return "me ( " + name + " )";
}
@Override
@@ -81,8 +81,7 @@ public class UpgradeFormatDialog extends DialogWrapper {
}
protected String getTopMessage(final String label) {
return SvnBundle.message(new StringBuilder().append("label.configure.").append(label).append(".label").toString(),
ApplicationNamesInfo.getInstance().getFullProductName());
return SvnBundle.message("label.configure." + label + ".label", ApplicationNamesInfo.getInstance().getFullProductName());
}
@Nullable
@@ -113,11 +112,11 @@ public class UpgradeFormatDialog extends DialogWrapper {
panel.add(topLabel, gb);
gb.gridy += 1;
myUpgradeNoneButton = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".none").toString()));
myUpgradeAutoButton = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto").toString()));
myUpgradeAuto15Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.15format").toString()));
myUpgradeAuto16Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.16format").toString()));
myUpgradeAuto17Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.17format").toString()));
myUpgradeNoneButton = new JRadioButton(SvnBundle.message("radio.configure." + label + ".none"));
myUpgradeAutoButton = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto"));
myUpgradeAuto15Button = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto.15format"));
myUpgradeAuto16Button = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto.16format"));
myUpgradeAuto17Button = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto.17format"));
ButtonGroup group = new ButtonGroup();
group.add(myUpgradeNoneButton);
@@ -78,8 +78,7 @@ public class UpgradeFormatDialog extends DialogWrapper {
}
protected String getTopMessage(final String label) {
return SvnBundle.message(new StringBuilder().append("label.configure.").append(label).append(".label").toString(),
ApplicationNamesInfo.getInstance().getFullProductName());
return SvnBundle.message("label.configure." + label + ".label", ApplicationNamesInfo.getInstance().getFullProductName());
}
@Nullable
@@ -110,10 +109,10 @@ public class UpgradeFormatDialog extends DialogWrapper {
panel.add(topLabel, gb);
gb.gridy += 1;
myUpgradeNoneButton = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".none").toString()));
myUpgradeAutoButton = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto").toString()));
myUpgradeAuto15Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.15format").toString()));
myUpgradeAuto16Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.16format").toString()));
myUpgradeNoneButton = new JRadioButton(SvnBundle.message("radio.configure." + label + ".none"));
myUpgradeAutoButton = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto"));
myUpgradeAuto15Button = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto.15format"));
myUpgradeAuto16Button = new JRadioButton(SvnBundle.message("radio.configure." + label + ".auto.16format"));
ButtonGroup group = new ButtonGroup();
group.add(myUpgradeNoneButton);