PY-17674 Add linefeed before right brace in dict literals when it's preceded by colon

Rules about literal braces is considered earlier than those for colons
in spacing builder.
This commit is contained in:
Mikhail Golubev
2015-11-17 12:55:40 +03:00
parent 75dff6418f
commit cde29bdae2
4 changed files with 31 additions and 2 deletions
@@ -99,6 +99,8 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.afterInside(RARROW, ANNOTATION).spaces(1)
.between(allButLambda(), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES)
.afterInside(LBRACE, DICT_LITERAL_EXPRESSION).spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_AFTER_LEFT_BRACE)
.beforeInside(RBRACE, DICT_LITERAL_EXPRESSION).spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_BEFORE_RIGHT_BRACE)
.before(COLON).spaceIf(pySettings.SPACE_BEFORE_PY_COLON)
.after(COMMA).spaceIf(commonSettings.SPACE_AFTER_COMMA)
@@ -115,8 +117,6 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.withinPairInside(LPAR, RPAR, PARENTHESIZED_EXPRESSION).spaces(0)
.before(LBRACKET).spaceIf(pySettings.SPACE_BEFORE_LBRACKET)
.afterInside(LBRACE, DICT_LITERAL_EXPRESSION).spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_AFTER_LEFT_BRACE)
.beforeInside(RBRACE, DICT_LITERAL_EXPRESSION).spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_BEFORE_RIGHT_BRACE)
.withinPair(LBRACE, RBRACE).spaceIf(pySettings.SPACE_WITHIN_BRACES)
.withinPair(LBRACKET, RBRACKET).spaceIf(commonSettings.SPACE_WITHIN_BRACKETS)
@@ -0,0 +1,11 @@
incoming_invite_post_schema = {
"definitions": {
"player": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
},}
}
}
@@ -0,0 +1,12 @@
incoming_invite_post_schema = {
"definitions": {
"player": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
},
}
}
}
@@ -612,6 +612,12 @@ public class PyFormatterTest extends PyTestCase {
getPythonCodeStyleSettings().DICT_NEW_LINE_BEFORE_RIGHT_BRACE = true;
doTest();
}
// PY-17674
public void testForceNewLineBeforeRightBraceInDictAfterColon() {
getPythonCodeStyleSettings().DICT_NEW_LINE_BEFORE_RIGHT_BRACE = true;
doTest();
}
// PY-16393
public void testHangingIndentDetectionIgnoresComments() {