Unconditionally add alignment to arguments when there is no hanging indent

This commit is contained in:
Mikhail Golubev
2015-01-29 13:03:49 +03:00
parent e4d7a000db
commit 0f6f631210
4 changed files with 15 additions and 8 deletions
@@ -29,7 +29,6 @@ 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;
@@ -514,13 +513,7 @@ public class PyBlock implements ASTBlock {
if (child.getElementType() == PyTokenTypes.COMMA) {
return false;
}
PyArgumentList argList = (PyArgumentList)_node.getPsi();
if (argList != null) {
PyExpression[] arguments = argList.getArguments();
return arguments.length > 1 || hasLineBreaksBefore(child, 1) || (
arguments.length == 1 && PyPsiUtils.getNextComma(arguments[0].getNode()) != null);
}
return false;
return true;
}
if (_node.getElementType() == PyElementTypes.PARAMETER_LIST) {
return !hasHangingIndent(_node.getPsi()) && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS;
@@ -0,0 +1,5 @@
with foo(bar(baz(1
)
)
):
pass
@@ -0,0 +1,5 @@
with foo(bar(baz(1
)
)
):
pass
@@ -477,6 +477,10 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
public void testAlignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument() {
doTest();
}
/**
* This test merely checks that call to {@link com.intellij.psi.codeStyle.CodeStyleManager#reformat(com.intellij.psi.PsiElement)}
* is possible for Python sources.