C++11: Fix indent of brace initializers in ctor lists.

Change-Id: Ib784df9e17ff2fe6bb249dcf8c2fee7310340f50
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christian Kamm
2012-09-17 13:14:45 +02:00
committed by hjk
parent 8c1a45565c
commit 1aed32d866
3 changed files with 53 additions and 5 deletions

View File

@@ -300,6 +300,13 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
default: tryExpression(); break;
} break;
case braceinit_open:
switch (kind) {
case T_RBRACE: leave(); break;
case T_RPAREN: leave(); continue; // recover?
default: tryExpression(); break;
} break;
case ternary_op:
switch (kind) {
case T_RPAREN:
@@ -340,14 +347,16 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case member_init:
switch (kind) {
case T_LPAREN: enter(member_init_paren_open); break;
case T_RPAREN: leave(); break;
case T_LBRACE:
case T_LPAREN: enter(member_init_nest_open); break;
case T_RBRACE:
case T_RPAREN: leave(); break;
case T_SEMICOLON: leave(); continue; // try to recover
} break;
case member_init_paren_open:
case member_init_nest_open:
switch (kind) {
case T_RBRACE:
case T_RPAREN: leave(); continue;
case T_SEMICOLON: leave(); continue; // try to recover
default: tryExpression(); break;
@@ -765,6 +774,7 @@ bool CodeFormatter::tryExpression(bool alsoExpression)
switch (kind) {
case T_LPAREN: newState = arglist_open; break;
case T_QUESTION: newState = ternary_op; break;
case T_LBRACE: newState = braceinit_open; break;
case T_EQUAL:
case T_AMPER_EQUAL:
@@ -1235,7 +1245,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
case arglist_open:
case condition_paren_open:
case member_init_paren_open:
case member_init_nest_open:
if (!lastToken)
*paddingDepth = nextTokenPosition-*indentDepth;
else

View File

@@ -124,7 +124,7 @@ public: // must be public to make Q_GADGET introspection work
member_init_open, // After ':' that starts a member initialization list.
member_init_expected, // At the start and after every ',' in member_init_open
member_init, // After an identifier in member_init_expected
member_init_paren_open, // After '(' in member_init.
member_init_nest_open, // After '(' or '{' in member_init.
enum_start, // After 'enum'
enum_open, // Brace that opens a enum declaration.
@@ -168,6 +168,7 @@ public: // must be public to make Q_GADGET introspection work
stream_op, // After a '<<' or '>>' in a context where it's likely a stream operator.
stream_op_cont, // When finding another stream operator in stream_op
ternary_op, // The ? : operator
braceinit_open, // after '{' in an expression context
condition_open, // Start of a condition in 'if', 'while', entered after opening paren
condition_paren_open, // After an lparen in a condition