// undo the continuation indent of the expression
*indentDepth = parentState.savedIndentDepth;
*savedIndentDepth = *indentDepth;
+ } else {
+ // always align to function keyword
+ *indentDepth = tokenPosition;
+ *savedIndentDepth = *indentDepth;
}
break;
void objectBinding();
void arrayBinding();
void functionDeclaration();
- void functionExpression();
+ void functionExpression1();
+ void functionExpression2();
void propertyDeclarations();
void signalDeclarations();
void ifBinding1();
checkIndent(data);
}
-void tst_QMLCodeFormatter::functionExpression()
+void tst_QMLCodeFormatter::functionExpression1()
{
QList<Line> data;
data << Line("Rectangle {")
checkIndent(data);
}
+void tst_QMLCodeFormatter::functionExpression2()
+{
+ QList<Line> data;
+ data << Line("Rectangle {")
+ << Line(" function foo(a, b, c) {")
+ << Line(" foo(1, 123456, function() {")
+ << Line(" b;")
+ << Line(" })")
+ << Line(" foo(1, 123456, function()")
+ << Line(" {")
+ << Line(" b;")
+ << Line(" })")
+ << Line(" foobar(1, 123456,")
+ << Line(" function () {")
+ << Line(" b;")
+ << Line(" })")
+ << Line(" var x = doo_foobar(")
+ << Line(" function () {")
+ << Line(" b;")
+ << Line(" })")
+ << Line(" }")
+ << Line("}")
+ ;
+ checkIndent(data);
+}
+
void tst_QMLCodeFormatter::propertyDeclarations()
{
QList<Line> data;