QmlJS: Completion for attached properties.

This commit is contained in:
Christian Kamm
2011-02-10 17:03:52 +01:00
parent 187ae1e94a
commit 490f2797f6
7 changed files with 128 additions and 12 deletions

View File

@@ -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

View File

@@ -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;