several more cases of inconsistent indentation (PY-1947)

This commit is contained in:
Dmitry Jemerov
2011-05-18 12:47:41 +02:00
parent 341ba29ac0
commit 9e5e7b3169
2 changed files with 25 additions and 3 deletions
@@ -141,7 +141,7 @@ public class PyBlock implements ASTBlock {
childIndent = Indent.getNoneIndent();
}
else {
childIndent = Indent.getContinuationIndent();
childIndent = Indent.getNormalIndent();
}
}
else if (parentType == PyElementTypes.ARGUMENT_LIST) {
@@ -152,7 +152,7 @@ public class PyBlock implements ASTBlock {
childIndent = Indent.getNormalIndent();
}
}
else if (parentType == PyElementTypes.DICT_LITERAL_EXPRESSION) {
else if (parentType == PyElementTypes.DICT_LITERAL_EXPRESSION || parentType == PyElementTypes.SET_LITERAL_EXPRESSION) {
if (childType == PyTokenTypes.RBRACE) {
childIndent = Indent.getNoneIndent();
}
@@ -211,7 +211,9 @@ public class PyBlock implements ASTBlock {
private boolean needListAlignment(ASTNode child) {
IElementType childType = child.getElementType();
if (PyTokenTypes.OPEN_BRACES.contains(childType)) {
ASTNode firstGrandchild = child.getFirstChildNode();
IElementType firstGrandchildType = firstGrandchild == null ? null : firstGrandchild.getElementType();
if (PyTokenTypes.OPEN_BRACES.contains(childType) || PyTokenTypes.OPEN_BRACES.contains(firstGrandchildType)) {
return false;
}
if (PyTokenTypes.CLOSE_BRACES.contains(childType)) {
@@ -192,6 +192,26 @@ public class PyIndentTest extends PyLightFixtureTestCase {
" <caret>params=1)");
}
public void testEnterInSet() { // PY-1947
doTest("test_set = {<caret>'some_value'}",
"test_set = {\n" +
" <caret>'some_value'}");
}
public void testEnterInList() { // PY-1947
doTest("test_list = [<caret>'some_value']",
"test_list = [\n" +
" <caret>'some_value']");
}
public void testEnterInDictInTuple() { // PY-1947
doTest("td = ({<caret>})",
"td = ({\n" +
" <caret>\n" +
"})");
}
public void testIndentAfterComment() { // PY-641
doTest("def foo():\n #some_call()<caret>\n another_call()", "def foo():\n #some_call()\n <caret>\n another_call()");
}