From 90a44ab1df3eec37b02502e4bc51edfac984c25e Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Thu, 20 Jan 2011 11:29:45 +0100 Subject: [PATCH] QmlJS indenter: Fix object bindings with namespaces. Task-number: QTCREATORBUG-3371 Reviewed-by: Roberto Raggi --- src/libs/qmljs/qmljscodeformatter.cpp | 4 +++- .../qmlcodeformatter/qmlcodeformatter.pro | 1 + .../qmlcodeformatter/tst_qmlcodeformatter.cpp | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp index 023c7286e97..f71bab23872 100644 --- a/src/libs/qmljs/qmljscodeformatter.cpp +++ b/src/libs/qmljs/qmljscodeformatter.cpp @@ -246,8 +246,10 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) case expression_or_objectdefinition: switch (kind) { + case Dot: + case Identifier: break; // need to become an objectdefinition_open in cases like "width: Qt.Foo {" case LeftBrace: turnInto(objectdefinition_open); break; - default: enter(expression); continue; // really? first token already gone! + default: enter(expression); continue; // really? identifier and more tokens might already be gone } break; case expression: diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro index 54797eb7eae..74297ab8119 100644 --- a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro +++ b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro @@ -8,6 +8,7 @@ SRCDIR = ../../../../../src #include($$SRCDIR/../qtcreator.pri) include($$SRCDIR/libs/qmljs/qmljs-lib.pri) include($$SRCDIR/libs/utils/utils-lib.pri) +include($$SRCDIR/libs/languageutils/languageutils-lib.pri) #LIBS += -L$$IDE_LIBRARY_PATH SOURCES += \ diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp index a8b0c422400..c83e7c703fd 100644 --- a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp +++ b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp @@ -53,6 +53,7 @@ private Q_SLOTS: void expressionContinuation(); void objectLiteral(); void keywordStatement(); + void namespacedObjects(); }; struct Line { @@ -961,6 +962,19 @@ void tst_QMLCodeFormatter::keywordStatement() checkIndent(data); } +void tst_QMLCodeFormatter::namespacedObjects() +{ + QList<Line> data; + data << Line("Item {") + << Line(" width: Q.Foo {") + << Line(" Q.Bar {") + << Line(" x: 12") + << Line(" }") + << Line(" }") + ; + checkIndent(data); +} + QTEST_APPLESS_MAIN(tst_QMLCodeFormatter) #include "tst_qmlcodeformatter.moc" -- GitLab