use continuation indent for parameters of call in expression part of control statement (PY-8577)

This commit is contained in:
Dmitry Jemerov
2013-01-28 16:56:20 +01:00
parent 4dfef3e4d3
commit 3919f1746b
4 changed files with 15 additions and 1 deletions
@@ -162,7 +162,7 @@ public class PyBlock implements ASTBlock {
childIndent = Indent.getNoneIndent();
}
else {
childIndent = parentType == PyElementTypes.PARAMETER_LIST
childIndent = parentType == PyElementTypes.PARAMETER_LIST || isCallInControlStatement()
? Indent.getContinuationIndent()
: Indent.getNormalIndent();
}
@@ -214,6 +214,10 @@ public class PyBlock implements ASTBlock {
return new PyBlock(this, child, childAlignment, childIndent, wrap, myContext);
}
private boolean isCallInControlStatement() {
return PsiTreeUtil.getParentOfType(_node.getPsi(), PyStatementPart.class, false, PyStatementList.class) != null;
}
private boolean isSliceOperand(ASTNode child) {
if (_node.getPsi() instanceof PySliceExpression) {
PySliceExpression sliceExpression = (PySliceExpression)_node.getPsi();
@@ -0,0 +1,3 @@
for item in really_long_name_of_the_function_with_a_lot_of_patams(
param1, param2, param3):
pass
@@ -0,0 +1,3 @@
for item in really_long_name_of_the_function_with_a_lot_of_patams(
param1, param2, param3):
pass
@@ -255,6 +255,10 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
public void testContinuationIndentForCallInStatementPart() { // PY-8577
doTest();
}
private void doTest() {
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
ApplicationManager.getApplication().runWriteAction(new Runnable() {