diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-05-04 11:12:45 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-05-04 11:14:35 +0200 |
commit | 02b7eacf4b1884e11c2c8668080af1a3742cbf5e (patch) | |
tree | 615676427277f7ac013888dce3533b0b304a4f46 /src/libs/qmljs/qmljsinterpreter.cpp | |
parent | 6bb08f1bf99c6b051dd47e9ce7b1125e00d77e65 (diff) | |
download | qt-creator-02b7eacf4b1884e11c2c8668080af1a3742cbf5e.tar.gz |
QmlJS: Fix type detection for alias properties.
Task-number: QTCREATORBUG-2306
Diffstat (limited to 'src/libs/qmljs/qmljsinterpreter.cpp')
-rw-r--r-- | src/libs/qmljs/qmljsinterpreter.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index a060fd1c0b..7134633563 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -36,6 +36,7 @@ #include "qmljsbind.h" #include "qmljsscopebuilder.h" #include "qmljstypedescriptionreader.h" +#include "qmljsscopeastpath.h" #include "parser/qmljsast_p.h" #include <languageutils/fakemetaobject.h> @@ -1378,8 +1379,9 @@ QList<const ObjectValue *> ScopeChain::all() const } -Context::Context() - : _engine(new Engine), +Context::Context(const Snapshot &snapshot) + : _snapshot(snapshot), + _engine(new Engine), _qmlScopeObjectIndex(-1), _qmlScopeObjectSet(false) { @@ -1395,6 +1397,11 @@ Engine *Context::engine() const return _engine.data(); } +QmlJS::Snapshot Context::snapshot() const +{ + return _snapshot; +} + const ScopeChain &Context::scopeChain() const { return _scopeChain; @@ -3270,8 +3277,20 @@ bool ASTPropertyReference::getSourceLocation(QString *fileName, int *line, int * const Value *ASTPropertyReference::value(const Context *context) const { if (_ast->expression - && (!_ast->memberType || _ast->memberType->asString() == QLatin1String("variant"))) { - Evaluate check(context); + && (!_ast->memberType || _ast->memberType->asString() == QLatin1String("variant") + || _ast->memberType->asString() == QLatin1String("alias"))) { + + // Adjust the context for the current location - expensive! + // ### Improve efficiency by caching the 'use chain' constructed in ScopeBuilder. + + QmlJS::Document::Ptr doc = _doc->ptr(); + Context localContext(*context); + QmlJS::ScopeBuilder builder(&localContext, doc); + + int offset = _ast->expression->firstSourceLocation().begin(); + builder.push(ScopeAstPath(doc)(offset)); + + Evaluate check(&localContext); return check(_ast->expression); } |