diff options
| author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-10-06 13:50:04 +0200 |
|---|---|---|
| committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-10-06 15:35:01 +0200 |
| commit | c2d890f65e3d1975022aec4a70a93c53e43f38bc (patch) | |
| tree | 7fb1f413ab0dde703a6d1b8c9c7f7cd76045118a | |
| parent | a36dc1d41ea46f1881dedb7ff8893a4c71077771 (diff) | |
| download | qt-creator-c2d890f65e3d1975022aec4a70a93c53e43f38bc.tar.gz | |
C++ indenter: Don't get confused on 'for (a in b)'.
Reviewed-by: Roberto Raggi
Reviewed-by: Erik Verbruggen
| -rw-r--r-- | src/plugins/cpptools/cppcodeformatter.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index 3a7462be9b..3c13d10f58 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -317,12 +317,14 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) switch (kind) { case T_SEMICOLON: turnInto(for_statement_condition); break; case T_LPAREN: enter(condition_paren_open); break; + case T_RPAREN: turnInto(for_statement_expression); continue; } break; case for_statement_condition: switch (kind) { case T_SEMICOLON: turnInto(for_statement_expression); break; case T_LPAREN: enter(condition_paren_open); break; + case T_RPAREN: turnInto(for_statement_expression); continue; } break; case for_statement_expression: diff --git a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp index 155a28810a..0b240fa107 100644 --- a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp +++ b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp @@ -33,6 +33,7 @@ private Q_SLOTS: void classAccess(); void ternary(); void objcAtDeclarations(); + void objcCallAndFor(); void braceList(); void bug1(); void bug2(); @@ -666,6 +667,24 @@ void tst_CodeFormatter::objcAtDeclarations() checkIndent(data); } +void tst_CodeFormatter::objcCallAndFor() +{ + QList<Line> data; + data << Line("void foo() {") + << Line(" NSArray *windows = [NSApp windows];") + << Line(" for (NSWindow *window in windows) {") + << Line(" NSArray *drawers = [window drawers];") + << Line(" for (NSDrawer *drawer in drawers) {") + << Line(" NSArray *views = [[drawer contentView] subviews];") + << Line(" int x;") + << Line(" }") + << Line(" }") + << Line("}") + << Line("int y;") + ; + checkIndent(data); +} + void tst_CodeFormatter::switch1() { QList<Line> data; |
