Remove unnecessary StringBuilder usages
authorBas Leijdekkers <basleijdekkers@gmail.com>
Thu, 2 Feb 2012 09:30:11 +0000 (10:30 +0100)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Thu, 2 Feb 2012 09:30:11 +0000 (10:30 +0100)
12 files changed:
platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java
platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java
platform/lang-impl/src/com/intellij/extapi/psi/StubPath.java
platform/platform-api/src/com/intellij/openapi/util/DimensionService.java
platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java
platform/util/src/com/intellij/ui/ColorUtil.java
platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsChangeDetailsManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java
plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java
plugins/svn4idea/src/org/jetbrains/idea/svn17/dialogs/UpgradeFormatDialog.java
plugins/svn4ideaOld/src/org/jetbrains/idea/svn/dialogs/UpgradeFormatDialog.java

index c38b1e3f54befb8f49e80981d7c73c794a021526..d854b6cbbd607045068feb1456fbe5f70aedd11f 100644 (file)
@@ -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);
             }
           }
index 0a7c42517dd77f59c5d91ac20d01e3dcb44c1504..cd22a9b403f687b6012c9d846396c87c122283d8 100644 (file)
@@ -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;
     }
   }
 
index 3ba3c7b77b211e803b2f76e682072bfba86e7cef..0ebd2584561d04a4637eef14994f051030d4375f 100644 (file)
@@ -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 + ")";
   }
 }
index 770d0256fe7e85b095a5345737c57b306e56deb5..2f19b937e14bcd78c6090fdc781719d934022d6b 100644 (file)
@@ -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;
   }
 }
index 75a098b5906b5e987ffdc267e751399bfdeb9b54..7b74cbcfbbc333fe7d9fca530f167130bb9183b3 100644 (file)
@@ -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;
     }
   }
index c1adf1b264689a3cfa847d794eae34852b877a2f..034adec7b502d8c39fba2b8b21ba90611a557d46 100644 (file)
@@ -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;
   }
 
   /**
index feb9988d3c32105270b00f8b0138ea103bcdfa84..f8ae000b3b939c26d94b82e8e6445f4eb5c70121 100644 (file)
@@ -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
index 0de56dc1eaf54d689612bbe2ac11de7d0320e46b..ddf8e002b5c9df0112a3bc0c80658b60c4edd02f 100644 (file)
@@ -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) {
index f843dadf15adcfd86853d9a9f9a922bb46a8d263..28b3c17313abd722c527a3868cc08ddbfbb11cab 100644 (file)
@@ -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);
 
index 5d5bf6fe591da5f1b3750591d4870c62299f36f1..f60ceea8ff7c31bda7e83dacc7561af5cd2b10e3 100644 (file)
@@ -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
index ce2580e197ce5f363e8b77c4c4a769084a31d521..890300075daca1e90aa26906ae572c48799ffe2b 100644 (file)
@@ -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);
index 8146e78bf67a52c5b9cc1e850a80d2af61aea0f4..bd5d8a3de3b23d6e5bf09f81819723e57880f765 100644 (file)
@@ -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);