diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp index 7ec947b45258f5182608818dec6ad78956bf0add..07047983a6aa0cc68ef7c24f015ec162b117d163 100644 --- a/src/libs/qmljs/qmljscodeformatter.cpp +++ b/src/libs/qmljs/qmljscodeformatter.cpp @@ -693,6 +693,8 @@ bool CodeFormatter::tryStatement() case List: case Property: case Function: + case Number: + case String: enter(expression); // look at the token again m_tokenIndex -= 1; diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro index 6464c16bb4f788f2bbbe54c585371f8e68cc4267..54797eb7eaecab0efce0c1772435616bd40946fd 100644 --- a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro +++ b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro @@ -12,11 +12,11 @@ include($$SRCDIR/libs/utils/utils-lib.pri) SOURCES += \ tst_qmlcodeformatter.cpp \ - $$SRCDIR/plugins/qmljseditor/qmljseditorcodeformatter.cpp \ + $$SRCDIR/plugins/qmljstools/qmljsqtstylecodeformatter.cpp \ $$SRCDIR/plugins/texteditor/basetextdocumentlayout.cpp HEADERS += \ - $$SRCDIR/plugins/qmljseditor/qmljseditorcodeformatter.h \ - $$SRCDIR/plugins/texteditor/basetextdocumentlayout.h \ + $$SRCDIR/plugins/qmljstools/qmljseditorcodeformatter.h \ + $$SRCDIR/plugins/texteditor/basetextdocumentlayout.h INCLUDEPATH += $$SRCDIR/plugins $$SRCDIR/libs diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp index 9b0d05d12e6b397bfefa8f72e9333f5d5c6c49ce..a8b0c422400003f275f0aa26a7dab25ade42a970 100644 --- a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp +++ b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp @@ -4,9 +4,9 @@ #include <QTextDocument> #include <QTextBlock> -#include <qmljseditor/qmljseditorcodeformatter.h> +#include <qmljstools/qmljsqtstylecodeformatter.h> -using namespace QmlJSEditor; +using namespace QmlJSTools; class tst_QMLCodeFormatter: public QObject { @@ -27,6 +27,7 @@ private Q_SLOTS: void signalDeclarations(); void ifBinding1(); void ifBinding2(); + void ifBinding3(); void ifStatementWithoutBraces1(); void ifStatementWithoutBraces2(); void ifStatementWithBraces1(); @@ -431,6 +432,36 @@ void tst_QMLCodeFormatter::ifBinding2() checkIndent(data); } +void tst_QMLCodeFormatter::ifBinding3() +{ + QList<Line> data; + data << Line("A.Rectangle {") + << Line(" foo: bar") + << Line(" x: if (a) 1") + << Line(" x: if (a)") + << Line(" 1") + << Line(" x: if (a) 1;") + << Line(" x: if (a)") + << Line(" 1;") + << Line(" x: if (a) 1; else 2") + << Line(" x: if (a) 1") + << Line(" else 2") + << Line(" x: if (a) 1;") + << Line(" else 2") + << Line(" x: if (a) 1;") + << Line(" else") + << Line(" 2") + << Line(" x: if (a)") + << Line(" 1") + << Line(" else") + << Line(" 2") + << Line(" x: if (a) 1; else 2;") + << Line(" x: 1") + << Line("}") + ; + checkIndent(data); +} + void tst_QMLCodeFormatter::ifStatementWithoutBraces1() { QList<Line> data;