forked from qt-creator/qt-creator
C++ indenter: Fix indent in body of function with default argument.
Change-Id: I9d4f5b3ae7b8a59f8350cf756979a3a430398112 Reviewed-on: http://codereview.qt.nokia.com/206 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -194,6 +194,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
||||
case T_LBRACE: enter(brace_list_open); break;
|
||||
case T_RBRACE: leave(true); continue;
|
||||
case T_SEMICOLON: leave(); continue;
|
||||
case T_RPAREN: leave(); continue;
|
||||
default: enter(assign_open); continue;
|
||||
} break;
|
||||
|
||||
@@ -216,6 +217,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
||||
switch (kind) {
|
||||
case T_RBRACE: leave(true); continue;
|
||||
case T_SEMICOLON: leave(); continue;
|
||||
case T_RPAREN: leave(); continue;
|
||||
default: tryExpression(); break;
|
||||
} break;
|
||||
|
||||
|
@@ -120,6 +120,7 @@ private Q_SLOTS:
|
||||
void caseBody5();
|
||||
void caseBody6();
|
||||
void blockBraces1();
|
||||
void functionDefaultArgument();
|
||||
};
|
||||
|
||||
struct Line {
|
||||
@@ -1893,6 +1894,18 @@ void tst_CodeFormatter::blockBraces1()
|
||||
checkIndent(data, codeStyle);
|
||||
}
|
||||
|
||||
void tst_CodeFormatter::functionDefaultArgument()
|
||||
{
|
||||
QList<Line> data;
|
||||
data << Line("void foo(int a = 3) {")
|
||||
<< Line(" if (a)")
|
||||
<< Line(" int a;")
|
||||
<< Line("}")
|
||||
<< Line("int b;")
|
||||
;
|
||||
checkIndent(data);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_CodeFormatter)
|
||||
|
||||
#include "tst_codeformatter.moc"
|
||||
|
Reference in New Issue
Block a user