Get rid of grandparent for alignment.

This commit is contained in:
Dmitry Trofimov
2014-02-04 14:15:41 +04:00
parent 62476fa88f
commit 3529094fd2
@@ -142,23 +142,30 @@ public class PyBlock implements ASTBlock {
Indent childIndent = Indent.getNoneIndent();
Alignment childAlignment = null;
//First we are going to set-up possible alignment to parents
PyBlock p = !breaksAlignment(parentType) ? myParent : null;
while (p != null) {
ASTNode pNode = p.getNode();
if (ourListElementTypes.contains(pNode.getElementType())) {
if (needListAlignment(child) && !isEmptyList(_node.getPsi()) && !isInControlStatement()) {
if (parentType == PyElementTypes.BINARY_EXPRESSION && !isInControlStatement()) {
//Setup alignments for binary expression
childAlignment = getAlignmentForChildren();
PyBlock p = myParent; //Check grandparents
while (p != null) {
ASTNode pNode = p.getNode();
if (ourListElementTypes.contains(pNode.getElementType())) {
if (needListAlignment(child) && !isEmptyList(_node.getPsi())) {
childAlignment = p.getChildAlignment();
break;
}
}
else if (pNode == PyElementTypes.BINARY_EXPRESSION) {
childAlignment = p.getChildAlignment();
}
if (!breaksAlignment(pNode.getElementType())) {
p = p.myParent;
}
else {
break;
}
}
if (!breaksAlignment(pNode.getElementType())) {
p = p.myParent;
}
else {
break;
}
}
if (childType == PyElementTypes.STATEMENT_LIST) {
@@ -193,14 +200,6 @@ public class PyBlock implements ASTBlock {
PyStatementPart.class);
childIndent = parens != null ? Indent.getNormalIndent() : Indent.getContinuationIndent();
}
else {
if (grandparentType == PyElementTypes.BINARY_EXPRESSION && myParent != null) {
childAlignment = myParent.getAlignmentForChildren();
}
else {
childAlignment = getAlignmentForChildren();
}
}
}
if (parentType == PyElementTypes.LIST_LITERAL_EXPRESSION || parentType == PyElementTypes.LIST_COMP_EXPRESSION) {