change signature: do not add comma if only one parameter added
authoranna <Anna.Kozlova@jetbrains.com>
Tue, 14 Sep 2010 15:47:33 +0000 (19:47 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Wed, 15 Sep 2010 11:53:33 +0000 (15:53 +0400)
java/java-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureUtil.java

index f23cabd6143b1ce44dfd1626cbe6ad549cbc7b26..665d3d574c487d4a344a04a92fbd77a495aa7f31 100644 (file)
@@ -72,19 +72,21 @@ public class ChangeSignatureUtil {
           }
         }
       } else {
           }
         }
       } else {
-        PsiElement anchor = null;
-        if (index == 0) {
-          anchor = list.getFirstChild();
-        } else {
-          anchor = elements.get(index - 1);
-        }
-        final PsiElement psi = Factory
-          .createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, SharedImplUtil.findCharTableByTree(list.getNode()), list.getManager())
-          .getPsi();
-        if (anchor != null) {
-          list.addAfter(psi, anchor);
-        } else {
-          list.add(psi);
+        if (newElements.size() > 1) {
+          PsiElement anchor;
+          if (index == 0) {
+            anchor = list.getFirstChild();
+          } else {
+            anchor = elements.get(index - 1);
+          }
+          final PsiElement psi = Factory
+            .createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, SharedImplUtil.findCharTableByTree(list.getNode()), list.getManager())
+            .getPsi();
+          if (anchor != null) {
+            list.addAfter(psi, anchor);
+          } else {
+            list.add(psi);
+          }
         }
       }
       index++;
         }
       }
       index++;