Skip to content
Snippets Groups Projects
Commit 7e3294a8 authored by Christian Kamm's avatar Christian Kamm
Browse files

C++ indenter: Don't get confused on 'for (a in b)'.

Reviewed-by: Roberto Raggi
Reviewed-by: Erik Verbruggen
(cherry picked from commit c2d890f6)
parent 074cfd67
No related branches found
No related tags found
No related merge requests found
...@@ -317,12 +317,14 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) ...@@ -317,12 +317,14 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
switch (kind) { switch (kind) {
case T_SEMICOLON: turnInto(for_statement_condition); break; case T_SEMICOLON: turnInto(for_statement_condition); break;
case T_LPAREN: enter(condition_paren_open); break; case T_LPAREN: enter(condition_paren_open); break;
case T_RPAREN: turnInto(for_statement_expression); continue;
} break; } break;
case for_statement_condition: case for_statement_condition:
switch (kind) { switch (kind) {
case T_SEMICOLON: turnInto(for_statement_expression); break; case T_SEMICOLON: turnInto(for_statement_expression); break;
case T_LPAREN: enter(condition_paren_open); break; case T_LPAREN: enter(condition_paren_open); break;
case T_RPAREN: turnInto(for_statement_expression); continue;
} break; } break;
case for_statement_expression: case for_statement_expression:
......
...@@ -33,6 +33,7 @@ private Q_SLOTS: ...@@ -33,6 +33,7 @@ private Q_SLOTS:
void classAccess(); void classAccess();
void ternary(); void ternary();
void objcAtDeclarations(); void objcAtDeclarations();
void objcCallAndFor();
void braceList(); void braceList();
void bug1(); void bug1();
void bug2(); void bug2();
...@@ -666,6 +667,24 @@ void tst_CodeFormatter::objcAtDeclarations() ...@@ -666,6 +667,24 @@ void tst_CodeFormatter::objcAtDeclarations()
checkIndent(data); 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() void tst_CodeFormatter::switch1()
{ {
QList<Line> data; QList<Line> data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment