From 8d14f18ec080c70c252ae2eb0da3099b76ad7d77 Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Mon, 22 Feb 2010 10:21:07 +0100 Subject: [PATCH] Add an accessor to get the flat scope list from ScopeChain. Done-with: Erik Verbruggen --- src/libs/qmljs/qmljsinterpreter.cpp | 25 +++++++++++-------- src/libs/qmljs/qmljsinterpreter.h | 5 +++- .../qmljseditor/qmljscodecompletion.cpp | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 2ea8eb71b62..edef78562b6 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -745,22 +745,27 @@ void ScopeChain::QmlComponentChain::add(QList<const ObjectValue *> *list) const void ScopeChain::update() { - all.clear(); + _all.clear(); - all += globalScope; + _all += globalScope; foreach (QmlComponentChain *parent, qmlComponentScope.instantiatingComponents) - parent->add(&all); + parent->add(&_all); if (qmlComponentScope.rootObject) - all += qmlComponentScope.rootObject; - all += qmlScopeObjects; - all += qmlComponentScope.functionScopes; + _all += qmlComponentScope.rootObject; + _all += qmlScopeObjects; + _all += qmlComponentScope.functionScopes; if (qmlComponentScope.ids) - all += qmlComponentScope.ids; + _all += qmlComponentScope.ids; if (qmlTypes) - all += qmlTypes; - all += jsScopes; + _all += qmlTypes; + _all += jsScopes; +} + +QList<const ObjectValue *> ScopeChain::all() const +{ + return _all; } @@ -819,7 +824,7 @@ void Context::setTypeEnvironment(const QmlJS::Document *doc, const ObjectValue * const Value *Context::lookup(const QString &name) { - QList<const ObjectValue *> scopes = _scopeChain.all; + QList<const ObjectValue *> scopes = _scopeChain.all(); for (int index = scopes.size() - 1; index != -1; --index) { const ObjectValue *scope = scopes.at(index); diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h index 91e60573c4e..ace0444e345 100644 --- a/src/libs/qmljs/qmljsinterpreter.h +++ b/src/libs/qmljs/qmljsinterpreter.h @@ -249,7 +249,10 @@ public: // rebuilds the flat list of all scopes void update(); - QList<const ObjectValue *> all; + QList<const ObjectValue *> all() const; + +private: + QList<const ObjectValue *> _all; }; class QMLJS_EXPORT Context diff --git a/src/plugins/qmljseditor/qmljscodecompletion.cpp b/src/plugins/qmljseditor/qmljscodecompletion.cpp index 46e91114c05..0d6e4e44a27 100644 --- a/src/plugins/qmljseditor/qmljscodecompletion.cpp +++ b/src/plugins/qmljseditor/qmljscodecompletion.cpp @@ -189,7 +189,7 @@ public: _properties.clear(); _currentObject = 0; - foreach (const Interpreter::ObjectValue *scope, _context->scopeChain().all) + foreach (const Interpreter::ObjectValue *scope, _context->scopeChain().all()) enumerateProperties(scope); return _properties; -- GitLab