Commit f3f3b96c authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Improve performance by avoiding two links in SemanticHighlighter.

Reviewed-by: Roberto Raggi
parent 2e8ec2f9
......@@ -154,10 +154,10 @@ public:
} // end of anonymous namespace
Check::Check(Document::Ptr doc, const Snapshot &snapshot, const QStringList &importPaths)
Check::Check(Document::Ptr doc, const Snapshot &snapshot, const Context *linkedContextNoScope)
: _doc(doc)
, _snapshot(snapshot)
, _link(&_context, doc, snapshot, importPaths)
, _context(*linkedContextNoScope)
, _scopeBuilder(doc, &_context)
, _ignoreTypeErrors(false)
{
......@@ -171,7 +171,6 @@ QList<DiagnosticMessage> Check::operator()()
{
_messages.clear();
Node::accept(_doc->ast(), this);
_messages.append(_link.diagnosticMessages());
return _messages;
}
......
......@@ -32,7 +32,6 @@
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/qmljslink.h>
#include <qmljs/qmljsscopebuilder.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
......@@ -46,7 +45,7 @@ class QMLJS_EXPORT Check: protected AST::Visitor
Q_DECLARE_TR_FUNCTIONS(QmlJS::Check)
public:
Check(Document::Ptr doc, const Snapshot &snapshot, const QStringList &importPaths);
Check(Document::Ptr doc, const Snapshot &snapshot, const Interpreter::Context *linkedContextNoScope);
virtual ~Check();
QList<DiagnosticMessage> operator()();
......@@ -72,7 +71,6 @@ private:
Snapshot _snapshot;
Interpreter::Context _context;
Link _link;
ScopeBuilder _scopeBuilder;
QList<DiagnosticMessage> _messages;
......
......@@ -1892,12 +1892,13 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
Interpreter::Context *ctx = new Interpreter::Context;
Link link(ctx, doc, snapshot, ModelManagerInterface::instance()->importPaths());
semanticInfo.m_context = QSharedPointer<const QmlJS::Interpreter::Context>(ctx);
semanticInfo.semanticMessages = link.diagnosticMessages();
QStringList importPaths;
if (m_modelManager)
importPaths = m_modelManager->importPaths();
Check checker(doc, snapshot, importPaths);
semanticInfo.semanticMessages = checker();
Check checker(doc, snapshot, ctx);
semanticInfo.semanticMessages.append(checker());
return semanticInfo;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment