summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-02-10 17:03:52 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-02-10 17:04:22 +0100
commit490f2797f636ff49ce0a778610a2532d1277e4d4 (patch)
tree4f8e00de7255515a15d031fce4e3aeceabfff8e7 /src/plugins
parent187ae1e94a1b151c3d82cd47c51b73815df08d49 (diff)
downloadqt-creator-490f2797f636ff49ce0a778610a2532d1277e4d4.tar.gz
QmlJS: Completion for attached properties.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljscodecompletion.cpp19
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp2
3 files changed, 17 insertions, 6 deletions
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index 39c3d9c33b..f967c97da0 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -308,7 +308,7 @@ public:
bool isAttachedProperty = false;
if (! propertyName.isEmpty() && propertyName[0].isUpper()) {
isAttachedProperty = true;
- if (const Interpreter::ObjectValue *qmlTypes = m_context->scopeChain().qmlTypes)
+ if (const Interpreter::ObjectValue *qmlTypes = m_context->scopeChain().qmlAttachedTypes)
scopeObjects += qmlTypes;
}
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;