fix alignment after first argument in call (PY-6360)

This commit is contained in:
Dmitry Jemerov
2012-08-15 12:04:12 +02:00
parent adfc447b17
commit b523566c4e
3 changed files with 15 additions and 2 deletions
@@ -55,7 +55,7 @@ public class PyPsiUtils {
}
@Nullable
protected static ASTNode getNextComma(ASTNode after) {
public static ASTNode getNextComma(ASTNode after) {
ASTNode node = after;
PyElementType comma = PyTokenTypes.COMMA;
do {
@@ -15,6 +15,7 @@ import com.jetbrains.python.PyElementTypes;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.PythonDialectsTokenSetProvider;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.impl.PyPsiUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -238,7 +239,11 @@ public class PyBlock implements ASTBlock {
return false;
}
PyArgumentList argList = (PyArgumentList)_node.getPsi();
return argList != null && argList.getArguments().length > 1;
if (argList != null) {
PyExpression[] arguments = argList.getArguments();
return arguments.length > 1 || (arguments.length == 1 && PyPsiUtils.getNextComma(arguments[0].getNode()) != null);
}
return false;
}
if (_node.getElementType() == PyElementTypes.PARAMETER_LIST) {
return mySettings.ALIGN_MULTILINE_PARAMETERS;
@@ -2,6 +2,7 @@ package com.jetbrains.python;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.jetbrains.python.fixtures.PyTestCase;
/**
@@ -295,6 +296,13 @@ public class PyIndentTest extends PyTestCase {
"]");
}
public void testAlignInCall() { // PY-6360
CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
doTest("list(a,<caret>)",
"list(a,\n" +
" <caret>)");
}
/*
TODO: formatter core problem?
public void testAlignListBeforeEquals() throws Exception {