forked from qt-creator/qt-creator
QmlJS: Compute link in SemanticHightlighter thread instead of lazily.
It's used very often, so lazy computation (potentially in the gui thread) was too expensive. Reviewed-by: Kai Koehne
This commit is contained in:
@@ -556,13 +556,6 @@ QList<AST::Node *> SemanticInfo::astPath(int cursorPosition) const
|
|||||||
|
|
||||||
LookupContext::Ptr SemanticInfo::lookupContext(const QList<QmlJS::AST::Node *> &path) const
|
LookupContext::Ptr SemanticInfo::lookupContext(const QList<QmlJS::AST::Node *> &path) const
|
||||||
{
|
{
|
||||||
// create and link context if necessary
|
|
||||||
if (!m_context) {
|
|
||||||
Interpreter::Context *ctx = new Interpreter::Context;
|
|
||||||
Link link(ctx, document, snapshot, ModelManagerInterface::instance()->importPaths());
|
|
||||||
m_context = QSharedPointer<const QmlJS::Interpreter::Context>(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return LookupContext::create(document, snapshot, *m_context, path);
|
return LookupContext::create(document, snapshot, *m_context, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1896,6 +1889,10 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
|
|||||||
semanticInfo.snapshot = snapshot;
|
semanticInfo.snapshot = snapshot;
|
||||||
semanticInfo.document = doc;
|
semanticInfo.document = doc;
|
||||||
|
|
||||||
|
Interpreter::Context *ctx = new Interpreter::Context;
|
||||||
|
Link link(ctx, doc, snapshot, ModelManagerInterface::instance()->importPaths());
|
||||||
|
semanticInfo.m_context = QSharedPointer<const QmlJS::Interpreter::Context>(ctx);
|
||||||
|
|
||||||
QStringList importPaths;
|
QStringList importPaths;
|
||||||
if (m_modelManager)
|
if (m_modelManager)
|
||||||
importPaths = m_modelManager->importPaths();
|
importPaths = m_modelManager->importPaths();
|
||||||
|
@@ -114,6 +114,8 @@ public: // attributes
|
|||||||
QTextCursor end;
|
QTextCursor end;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SemanticHighlighter;
|
||||||
|
|
||||||
class SemanticInfo
|
class SemanticInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -145,8 +147,9 @@ public: // attributes
|
|||||||
QList<QmlJS::DiagnosticMessage> semanticMessages;
|
QList<QmlJS::DiagnosticMessage> semanticMessages;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// created lazily
|
QSharedPointer<const QmlJS::Interpreter::Context> m_context;
|
||||||
mutable QSharedPointer<const QmlJS::Interpreter::Context> m_context;
|
|
||||||
|
friend class SemanticHighlighter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SemanticHighlighter: public QThread
|
class SemanticHighlighter: public QThread
|
||||||
|
Reference in New Issue
Block a user