diff --git a/src/libs/qmljs/qmljsscopebuilder.cpp b/src/libs/qmljs/qmljsscopebuilder.cpp index 7a3bcfd86a588d4465a35f4586944f539d734d80..80b3fbb7d74bfac2972ef6077dd7f7a01285ea84 100644 --- a/src/libs/qmljs/qmljsscopebuilder.cpp +++ b/src/libs/qmljs/qmljsscopebuilder.cpp @@ -106,14 +106,7 @@ void ScopeBuilder::setQmlScopeObject(Node *node) // check if the object has a Qt.PropertyChanges ancestor prototype = scopeObject->prototype(_context); - while (prototype) { - if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) { - if (qmlMetaObject->className() == QLatin1String("PropertyChanges") - && qmlMetaObject->packageName() == QLatin1String("Qt")) - break; - } - prototype = prototype->prototype(_context); - } + prototype = isPropertyChangesObject(_context, prototype); // find the target script binding if (prototype) { UiObjectInitializer *initializer = 0; @@ -169,3 +162,19 @@ const Value *ScopeBuilder::scopeObjectLookup(AST::UiQualifiedId *id) return result; } + + +const ObjectValue *ScopeBuilder::isPropertyChangesObject(Context *context, + const ObjectValue *object) +{ + const ObjectValue *prototype = object; + while (prototype) { + if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) { + if (qmlMetaObject->className() == QLatin1String("PropertyChanges") + && qmlMetaObject->packageName() == QLatin1String("Qt")) + return prototype; + } + prototype = prototype->prototype(context); + } + return 0; +} diff --git a/src/libs/qmljs/qmljsscopebuilder.h b/src/libs/qmljs/qmljsscopebuilder.h index 34485039bf2ebcc2879adb131aa4baf4d3023bc5..7141eee25c7068b5f60f6a202404226e81ce4387 100644 --- a/src/libs/qmljs/qmljsscopebuilder.h +++ b/src/libs/qmljs/qmljsscopebuilder.h @@ -14,6 +14,7 @@ namespace AST { namespace Interpreter { class Context; class Value; + class ObjectValue; } class QMLJS_EXPORT ScopeBuilder @@ -26,6 +27,8 @@ public: void push(const QList<AST::Node *> &nodes); void pop(); + static const Interpreter::ObjectValue *isPropertyChangesObject(Interpreter::Context *context, const Interpreter::ObjectValue *object); + private: void setQmlScopeObject(AST::Node *node); const Interpreter::Value *scopeObjectLookup(AST::UiQualifiedId *id); diff --git a/src/plugins/qmljseditor/qmljscodecompletion.cpp b/src/plugins/qmljseditor/qmljscodecompletion.cpp index 56a9a4396301394382adb8bdb9daa939f3d34fa1..adbd80e0ca647877066893a3ed6b37ab2ffc4b53 100644 --- a/src/plugins/qmljseditor/qmljscodecompletion.cpp +++ b/src/plugins/qmljseditor/qmljscodecompletion.cpp @@ -38,6 +38,7 @@ #include <qmljs/qmljsscanner.h> #include <qmljs/qmljsevaluate.h> #include <qmljs/qmljscompletioncontextfinder.h> +#include <qmljs/qmljsscopebuilder.h> #include <texteditor/basetexteditor.h> @@ -687,6 +688,11 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) addCompletions(enumerateProperties(qmlScopeType), symbolIcon); addCompletions(enumerateProperties(context.scopeChain().qmlTypes), symbolIcon); + + if (ScopeBuilder::isPropertyChangesObject(&context, qmlScopeType) + && context.scopeChain().qmlScopeObjects.size() == 2) { + addCompletions(enumerateProperties(context.scopeChain().qmlScopeObjects.first()), symbolIcon); + } } if (contextFinder.isInRhsOfBinding() && qmlScopeType) {