diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-02-10 17:03:52 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-02-10 17:04:22 +0100 |
commit | 490f2797f636ff49ce0a778610a2532d1277e4d4 (patch) | |
tree | 4f8e00de7255515a15d031fce4e3aeceabfff8e7 /src/plugins/qmljseditor | |
parent | 187ae1e94a1b151c3d82cd47c51b73815df08d49 (diff) | |
download | qt-creator-490f2797f636ff49ce0a778610a2532d1277e4d4.tar.gz |
QmlJS: Completion for attached properties.
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r-- | src/plugins/qmljseditor/qmljscodecompletion.cpp | 19 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsfindreferences.cpp | 2 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/plugins/qmljseditor/qmljscodecompletion.cpp b/src/plugins/qmljseditor/qmljscodecompletion.cpp index 88a7c81206..051debcb69 100644 --- a/src/plugins/qmljseditor/qmljscodecompletion.cpp +++ b/src/plugins/qmljseditor/qmljscodecompletion.cpp @@ -841,10 +841,12 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) bool doGlobalCompletion = true; bool doQmlKeywordCompletion = true; bool doJsKeywordCompletion = true; + bool doQmlTypeCompletion = false; if (contextFinder.isInLhsOfBinding() && qmlScopeType) { doGlobalCompletion = false; doJsKeywordCompletion = false; + doQmlTypeCompletion = true; EnumerateProperties enumerateProperties(context); enumerateProperties.setGlobalCompletion(true); @@ -858,8 +860,6 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) m_completions.append(idPropertyCompletion); addCompletionsPropertyLhs(enumerateProperties(qmlScopeType), symbolIcon, PropertyOrder, contextFinder.isAfterOnInLhsOfBinding()); - if (const Interpreter::ObjectValue *qmlTypes = context->scopeChain().qmlTypes) - addCompletions(enumerateProperties(qmlTypes), symbolIcon, TypeOrder); if (ScopeBuilder::isPropertyChangesObject(context, qmlScopeType) && context->scopeChain().qmlScopeObjects.size() == 2) { @@ -884,6 +884,16 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) } } + if (!contextFinder.isInImport() && !contextFinder.isInQmlContext()) + doQmlTypeCompletion = true; + + if (doQmlTypeCompletion) { + if (const Interpreter::ObjectValue *qmlTypes = context->scopeChain().qmlTypes) { + EnumerateProperties enumerateProperties(context); + addCompletions(enumerateProperties(qmlTypes), symbolIcon, TypeOrder); + } + } + if (doGlobalCompletion) { // It's a global completion. EnumerateProperties enumerateProperties(context); @@ -934,9 +944,10 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) if (value && completionOperator == QLatin1Char('.')) { // member completion EnumerateProperties enumerateProperties(context); - if (contextFinder.isInLhsOfBinding() && qmlScopeType && expressionUnderCursor.text().at(0).isLower()) + if (contextFinder.isInLhsOfBinding() && qmlScopeType) { + enumerateProperties.setEnumerateGeneratedSlots(true); addCompletionsPropertyLhs(enumerateProperties(value), symbolIcon, PropertyOrder, contextFinder.isAfterOnInLhsOfBinding()); - else + } else addCompletions(enumerateProperties(value), symbolIcon, SymbolOrder); } else if (value && completionOperator == QLatin1Char('(') && m_startPosition == editor->position()) { // function completion diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index a92bcbacdb..779e3222d1 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -178,7 +178,7 @@ protected: const ScopeChain &chain = _context->scopeChain(); if (chain.jsScopes.contains(scope) || chain.qmlScopeObjects.contains(scope) - || chain.qmlTypes == scope + || chain.qmlAttachedTypes == scope || chain.globalScope == scope) return false; |