IDEA-104469 Groovy: remove line feed from method call if necessary during removing parameters

This commit is contained in:
Max Medvedev
2013-04-04 10:48:41 +04:00
parent a90132321a
commit 3b748a1d3d
4 changed files with 25 additions and 2 deletions
@@ -186,7 +186,7 @@ public class GrArgumentListImpl extends GroovyPsiElementImpl implements GrArgume
}
@Override
public PsiElement addAfter(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException {
public PsiElement addAfter(@NotNull PsiElement element, @Nullable PsiElement anchor) throws IncorrectOperationException {
if (element instanceof GrExpression || element instanceof GrNamedArgument) {
final boolean insertComma = getAllArguments().length != 0;
@@ -215,12 +215,20 @@ public class GrArgumentListImpl extends GroovyPsiElementImpl implements GrArgume
if (element instanceof GrExpression || element instanceof GrNamedArgument) {
ASTNode prev = TreeUtil.skipElementsBack(child.getTreePrev(), TokenSets.WHITE_SPACES_OR_COMMENTS);
if (prev != null && prev.getElementType() == mCOMMA) {
final ASTNode pprev = prev.getTreePrev();
if (pprev != null && TokenSets.WHITE_SPACES_SET.contains(pprev.getElementType())) {
super.deleteChildInternal(pprev);
}
super.deleteChildInternal(prev);
}
else {
ASTNode next = TreeUtil.skipElements(child.getTreeNext(), TokenSets.WHITE_SPACES_OR_COMMENTS);
if (next != null && next.getElementType() == mCOMMA) {
deleteChildInternal(next);
final ASTNode nnext = next.getTreeNext();
if (nnext != null && TokenSets.WHITE_SPACES_SET.contains(nnext.getElementType())) {
super.deleteChildInternal(nnext);
}
super.deleteChildInternal(next);
}
}
}
@@ -253,6 +253,10 @@ public class ChangeSignatureTest extends ChangeSignatureTestCase {
doTest(null, 'a\'bc', null, [], [], false)
}
void testLineFeedInCommandArgs() {
doTest(new SimpleInfo(1))
}
private PsiType createType(String typeText) {
return JavaPsiFacade.getElementFactory(project).createTypeByFQClassName(typeText, GlobalSearchScope.allScope(project));
@@ -0,0 +1,6 @@
def fo<caret>o(def a, def b) {
print b
}
foo 'abc',
'cde'
@@ -0,0 +1,5 @@
def foo(def b) {
print b
}
foo 'cde'