From c1b3f0b1203d0465ba7fb475becd5a18339fa39e Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Tue, 26 Jan 2010 16:21:03 +0100 Subject: [PATCH] Coding style. --- src/libs/qmljs/qmljsbind.cpp | 19 +++++++++++-------- src/libs/qmljs/qmljsbind.h | 4 ++-- src/libs/qmljs/qmljsmetatypesystem.cpp | 2 +- src/plugins/qmljseditor/qmlcodecompletion.cpp | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/libs/qmljs/qmljsbind.cpp b/src/libs/qmljs/qmljsbind.cpp index 56e78be2d2c..61863631be8 100644 --- a/src/libs/qmljs/qmljsbind.cpp +++ b/src/libs/qmljs/qmljsbind.cpp @@ -35,8 +35,10 @@ using namespace QmlJS; using namespace QmlJS::AST; using namespace QmlJS::Interpreter; -Bind::Bind(Interpreter::Engine *interp) - : _interp(interp), +Bind::Bind(Document::Ptr doc, const Snapshot &snapshot, Interpreter::Engine *interp) + : _doc(doc), + _snapshot(snapshot), + _interp(interp), _interestingMember(0), _currentObjectValue(0), _typeEnvironment(0), @@ -50,14 +52,12 @@ Bind::~Bind() { } -Interpreter::ObjectValue *Bind::operator()(Document::Ptr doc, const Snapshot &snapshot, UiObjectMember *member) +Interpreter::ObjectValue *Bind::operator()(UiObjectMember *member) { - UiProgram *program = doc->qmlProgram(); + UiProgram *program = _doc->qmlProgram(); if (!program) return 0; - _doc = doc; - _snapshot = snapshot; _interestingMember = member; _currentObjectValue = 0; @@ -128,10 +128,13 @@ bool Bind::visit(UiImport *ast) ObjectValue *namespaceObject; if (ast->asToken.isValid()) { // with namespace we insert an object in the type env. to hold the imported types - namespaceObject = _interp->newObject(0); + namespaceObject = _interp->newObject(/*prototype */ 0); + if (!ast->importId) return false; // this should never happen, but better be safe than sorry + _typeEnvironment->setProperty(ast->importId->asString(), namespaceObject); + } else { // without namespace we insert all types directly into the type env. namespaceObject = _typeEnvironment; } @@ -148,7 +151,7 @@ bool Bind::visit(UiImport *ast) if (ast->versionToken.isValid()) { const QString versionString = _doc->source().mid(ast->versionToken.offset, ast->versionToken.length); - int dotIdx = versionString.indexOf('.'); + const int dotIdx = versionString.indexOf(QLatin1Char('.')); if (dotIdx == -1) { // only major (which is probably invalid, but let's handle it anyway) majorVersion = versionString.toInt(); diff --git a/src/libs/qmljs/qmljsbind.h b/src/libs/qmljs/qmljsbind.h index df59c45d5fc..2eb01712681 100644 --- a/src/libs/qmljs/qmljsbind.h +++ b/src/libs/qmljs/qmljsbind.h @@ -39,10 +39,10 @@ namespace QmlJS { class QMLJS_EXPORT Bind: protected AST::Visitor { public: - Bind(Interpreter::Engine *interp); + Bind(Document::Ptr doc, const Snapshot &snapshot, Interpreter::Engine *interp); virtual ~Bind(); - Interpreter::ObjectValue* operator()(Document::Ptr doc, const Snapshot &snapshot, AST::UiObjectMember *member); + Interpreter::ObjectValue* operator()(AST::UiObjectMember *member); protected: void accept(AST::Node *node); diff --git a/src/libs/qmljs/qmljsmetatypesystem.cpp b/src/libs/qmljs/qmljsmetatypesystem.cpp index 03e39bc704f..09c223b29f4 100644 --- a/src/libs/qmljs/qmljsmetatypesystem.cpp +++ b/src/libs/qmljs/qmljsmetatypesystem.cpp @@ -63,7 +63,7 @@ QList<QmlObjectValue *> MetaTypeSystem::staticTypesForImport(const QString &pref { QMap<QString, QmlObjectValue *> objectValuesByName; - foreach (QmlObjectValue *qmlObjectValue, _importedTypes[prefix]) { + foreach (QmlObjectValue *qmlObjectValue, _importedTypes.value(prefix)) { if (qmlObjectValue->majorVersion() < majorVersion || (qmlObjectValue->majorVersion() == majorVersion && qmlObjectValue->minorVersion() <= minorVersion)) { // we got a candidate. diff --git a/src/plugins/qmljseditor/qmlcodecompletion.cpp b/src/plugins/qmljseditor/qmlcodecompletion.cpp index dfd8f3adabd..e844d179e22 100644 --- a/src/plugins/qmljseditor/qmlcodecompletion.cpp +++ b/src/plugins/qmljseditor/qmlcodecompletion.cpp @@ -821,8 +821,8 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) scope->setProperty(QLatin1String("parent"), parentItem); #endif - Bind bind(&interp); - scope = bind(qmlDocument, snapshot, declaringMember); + Bind bind(qmlDocument, snapshot, &interp); + scope = bind(declaringMember); } // Search for the operator that triggered the completion. -- GitLab