QmlJS: Enforce Context always being linked.

The default way of creating a Context is through Link.

Change-Id: Ia81f7ce90ba2b33d02eed432a61be836d404bedd
Reviewed-on: http://codereview.qt.nokia.com/1041
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-07-01 13:41:40 +02:00
parent f691d3824a
commit 9ea0380a4d
8 changed files with 50 additions and 67 deletions

View File

@@ -812,13 +812,12 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
}
// find the scope for the name we're searching
Context context(snapshot);
Document::Ptr doc = snapshot.document(fileName);
if (!doc)
return;
Link link(&context, snapshot, ModelManagerInterface::instance()->importPaths());
link();
Link link(snapshot, ModelManagerInterface::instance()->importPaths());
Context context = link();
ScopeBuilder builder(&context, doc);
builder.initializeRootScope();

View File

@@ -132,9 +132,8 @@ SemanticInfo SemanticHighlighter::semanticInfo(const SemanticHighlighterSource &
semanticInfo.snapshot = snapshot;
semanticInfo.document = doc;
QmlJS::Interpreter::Context *ctx = new QmlJS::Interpreter::Context(snapshot);
QmlJS::Link link(ctx, snapshot, QmlJS::ModelManagerInterface::instance()->importPaths());
link(doc, &semanticInfo.semanticMessages);
QmlJS::Link link(snapshot, QmlJS::ModelManagerInterface::instance()->importPaths());
QmlJS::Interpreter::Context *ctx = new QmlJS::Interpreter::Context(link(doc, &semanticInfo.semanticMessages));
semanticInfo.m_context = QSharedPointer<const QmlJS::Interpreter::Context>(ctx);
QmlJS::Check checker(doc, ctx);