diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-01-12 14:35:54 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-01-12 15:40:36 +0100 |
commit | 20f0088ec9ec7f8f61ace67f6b9e99d21ad72d0d (patch) | |
tree | 9e4aefd4d0a981851f134fcdbcbe829eabad5c8c /src/plugins/qmljseditor | |
parent | bd704d49268ecfb399b05d74a3a16593e672bbd4 (diff) | |
download | qt-creator-20f0088ec9ec7f8f61ace67f6b9e99d21ad72d0d.tar.gz |
QmlJS: Fix completion of locally defined properties.
Task-number: QTCREATORBUG-3490
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r-- | src/plugins/qmljseditor/qmljscodecompletion.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/qmljseditor/qmljscodecompletion.cpp b/src/plugins/qmljseditor/qmljscodecompletion.cpp index 37d8e8e595..dce84351c7 100644 --- a/src/plugins/qmljseditor/qmljscodecompletion.cpp +++ b/src/plugins/qmljseditor/qmljscodecompletion.cpp @@ -41,6 +41,7 @@ #include <qmljs/qmljsinterpreter.h> #include <qmljs/qmljslookupcontext.h> #include <qmljs/qmljsscanner.h> +#include <qmljs/qmljsbind.h> #include <qmljs/qmljscompletioncontextfinder.h> #include <qmljs/qmljsscopebuilder.h> @@ -786,8 +787,20 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) CompletionContextFinder contextFinder(startPositionCursor); const Interpreter::ObjectValue *qmlScopeType = 0; - if (contextFinder.isInQmlContext()) - qmlScopeType = context->lookupType(document.data(), contextFinder.qmlObjectTypeName()); + if (contextFinder.isInQmlContext()) { + // ### this should use semanticInfo.declaringMember instead, but that may also return functions + for (int i = path.size() - 1; i >= 0; --i) { + AST::Node *node = path[i]; + if (AST::cast<AST::UiObjectDefinition *>(node) || AST::cast<AST::UiObjectBinding *>(node)) { + qmlScopeType = document->bind()->findQmlObject(node); + if (qmlScopeType) + break; + } + } + // fallback to getting the base type object + if (!qmlScopeType) + qmlScopeType = context->lookupType(document.data(), contextFinder.qmlObjectTypeName()); + } if (contextFinder.isInStringLiteral()) { // get the text of the literal up to the cursor position |