forked from qt-creator/qt-creator
QmlJS indenter: Fix break/continue/throw in if statement without braces.
Reviewed-by: Roberto Raggi
This commit is contained in:
@@ -643,6 +643,14 @@ bool CodeFormatter::tryStatement()
|
|||||||
enter(empty_statement);
|
enter(empty_statement);
|
||||||
leave(true);
|
leave(true);
|
||||||
return true;
|
return true;
|
||||||
|
case Break:
|
||||||
|
case Continue:
|
||||||
|
leave(true);
|
||||||
|
return true;
|
||||||
|
case Throw:
|
||||||
|
enter(throw_statement);
|
||||||
|
enter(expression);
|
||||||
|
return true;
|
||||||
case Return:
|
case Return:
|
||||||
enter(return_statement);
|
enter(return_statement);
|
||||||
enter(expression);
|
enter(expression);
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ public: // must be public to make Q_GADGET introspection work
|
|||||||
substatement_open, // The brace that opens a substatement block.
|
substatement_open, // The brace that opens a substatement block.
|
||||||
|
|
||||||
return_statement, // After 'return'
|
return_statement, // After 'return'
|
||||||
|
throw_statement, // After 'throw'
|
||||||
|
|
||||||
statement_with_condition, // After the 'for', 'while', 'catch', ... token
|
statement_with_condition, // After the 'for', 'while', 'catch', ... token
|
||||||
statement_with_condition_paren_open, // While inside the (...)
|
statement_with_condition_paren_open, // While inside the (...)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ private Q_SLOTS:
|
|||||||
// void whitesmithsStyle();
|
// void whitesmithsStyle();
|
||||||
void expressionContinuation();
|
void expressionContinuation();
|
||||||
void objectLiteral();
|
void objectLiteral();
|
||||||
|
void keywordStatement();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Line {
|
struct Line {
|
||||||
@@ -896,6 +897,26 @@ void tst_QMLCodeFormatter::objectLiteral()
|
|||||||
checkIndent(data);
|
checkIndent(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMLCodeFormatter::keywordStatement()
|
||||||
|
{
|
||||||
|
QList<Line> data;
|
||||||
|
data << Line("function shuffle() {")
|
||||||
|
<< Line(" if (1)")
|
||||||
|
<< Line(" break")
|
||||||
|
<< Line(" if (1)")
|
||||||
|
<< Line(" continue")
|
||||||
|
<< Line(" if (1)")
|
||||||
|
<< Line(" throw 1")
|
||||||
|
<< Line(" if (1)")
|
||||||
|
<< Line(" return")
|
||||||
|
<< Line(" if (1)")
|
||||||
|
<< Line(" return 1")
|
||||||
|
<< Line(" var x = 2")
|
||||||
|
<< Line("}")
|
||||||
|
;
|
||||||
|
checkIndent(data);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QMLCodeFormatter)
|
QTEST_APPLESS_MAIN(tst_QMLCodeFormatter)
|
||||||
#include "tst_qmlcodeformatter.moc"
|
#include "tst_qmlcodeformatter.moc"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user