C++ indenter: Fix error recovery in function definitions.

Task-number: QTCREATORBUG-1517
This commit is contained in:
Christian Kamm
2010-09-24 15:58:23 +02:00
parent 1b46f422ce
commit 17e0886c69
2 changed files with 16 additions and 2 deletions

View File

@@ -160,7 +160,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
if (tryExpression(true))
break;
switch (kind) {
case T_RBRACE:
case T_RBRACE: leave(true); continue;
case T_SEMICOLON: leave(true); break;
case T_EQUAL: enter(initializer); break;
case T_LBRACE: enter(defun_open); break;
@@ -251,7 +251,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
if (tryStatement())
break;
switch (kind) {
case T_RBRACE: leave(); continue; // always nested in declaration_start
case T_RBRACE: leave(); leave(); break; // always nested in declaration_start
} break;
case switch_statement:

View File

@@ -49,6 +49,7 @@ private Q_SLOTS:
void nestedInitializer();
void forStatement();
void templateSingleline();
void macrosNoSemicolon2();
};
struct Line {
@@ -952,6 +953,19 @@ void tst_CodeFormatter::templateSingleline()
checkIndent(data);
}
void tst_CodeFormatter::macrosNoSemicolon2()
{
QList<Line> data;
data
<< Line("FOO(ABC)")
<< Line("{")
<< Line(" BAR(FOO)")
<< Line("}")
<< Line("int i;")
;
checkIndent(data);
}
QTEST_APPLESS_MAIN(tst_CodeFormatter)
#include "tst_codeformatter.moc"