From c65a028f74daef79192ae94f682bc5f98aec1931 Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Tue, 26 Jan 2010 09:54:02 +0100 Subject: [PATCH] Added the user components to the global completion and fixed completion for the `parent' property. --- src/plugins/qmljseditor/qmlcodecompletion.cpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/plugins/qmljseditor/qmlcodecompletion.cpp b/src/plugins/qmljseditor/qmlcodecompletion.cpp index 199f5f69fa9..2fe7c2f5f8f 100644 --- a/src/plugins/qmljseditor/qmlcodecompletion.cpp +++ b/src/plugins/qmljseditor/qmlcodecompletion.cpp @@ -855,7 +855,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) else if (AST::UiObjectBinding *binding = AST::cast<AST::UiObjectBinding *>(parentMember)) parentItemName = qualifiedNameId(binding->qualifiedTypeNameId); - Interpreter::ObjectValue *parentItem = newComponent(&interp, declaringItemName, userComponents); + Interpreter::ObjectValue *parentItem = newComponent(&interp, parentItemName, userComponents); if (! parentItem) parentItem = interp.newQmlObject(QLatin1String("Item")); @@ -871,21 +871,13 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) m_startPosition != editor->position())) { // It's a global completion. // Process the visible user defined components. - foreach (QmlJS::Document::Ptr doc, snapshot) { - const QFileInfo fileInfo(doc->fileName()); - - if (fileInfo.suffix() != QLatin1String("qml")) - continue; - else if (fileInfo.absolutePath() != currentFilePath) // ### FIXME includ `imported' components - continue; - - const QString componentName = fileInfo.baseName(); - if (! componentName.isEmpty() && componentName.at(0).isUpper()) { - TextEditor::CompletionItem item(this); - item.text = componentName; - item.icon = componentIcon; - m_completions.append(item); - } + QHashIterator<QString, Document::Ptr> componentIt(userComponents); + while (componentIt.hasNext()) { + componentIt.next(); + TextEditor::CompletionItem item(this); + item.text = componentIt.key(); + item.icon = componentIcon; + m_completions.append(item); } EnumerateProperties enumerateProperties; -- GitLab