Commit e9c43b3e authored by Roberto Raggi's avatar Roberto Raggi

Cache the LookupContext.

parent 1c078ec2
......@@ -966,8 +966,7 @@ void CPPEditor::markSymbols(Symbol *canonicalSymbol, const SemanticInfo &info)
if (canonicalSymbol) {
TranslationUnit *unit = info.doc->translationUnit();
LookupContext context(info.doc, info.snapshot); // ### remove me
const QList<int> references = m_modelManager->references(canonicalSymbol, context);
const QList<int> references = m_modelManager->references(canonicalSymbol, info.context);
foreach (int index, references) {
unsigned line, column;
unit->getTokenPosition(index, &line, &column);
......@@ -2055,6 +2054,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
Document::Ptr doc;
QList<Document::DiagnosticMessage> diagnosticMessages;
QList<SemanticInfo::Use> typeUsages;
LookupContext context;
if (! source.force && revision == source.revision) {
m_mutex.lock();
......@@ -2062,6 +2062,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
doc = m_lastSemanticInfo.doc;
diagnosticMessages = m_lastSemanticInfo.diagnosticMessages;
typeUsages = m_lastSemanticInfo.typeUsages;
context = m_lastSemanticInfo.context;
m_mutex.unlock();
}
......@@ -2072,7 +2073,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
doc = snapshot.documentFromSource(preprocessedCode, source.fileName);
doc->check();
LookupContext context(doc, snapshot);
context = LookupContext(doc, snapshot);
if (TranslationUnit *unit = doc->translationUnit()) {
CheckUndefinedSymbols checkUndefinedSymbols(unit, context);
......@@ -2102,6 +2103,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
semanticInfo.forced = source.force;
semanticInfo.diagnosticMessages = diagnosticMessages;
semanticInfo.typeUsages = typeUsages;
semanticInfo.context = context;
return semanticInfo;
}
......@@ -33,6 +33,7 @@
#include "cppeditorenums.h"
#include "cppquickfix.h"
#include <cplusplus/CppDocument.h>
#include <cplusplus/LookupContext.h>
#include <texteditor/basetexteditor.h>
#include <QtCore/QThread>
......@@ -86,8 +87,9 @@ public:
bool hasQ: 1;
bool hasD: 1;
bool forced: 1;
CPlusPlus::Snapshot snapshot;
CPlusPlus::Document::Ptr doc;
CPlusPlus::Snapshot snapshot; // ### remove
CPlusPlus::Document::Ptr doc; // ### remove
CPlusPlus::LookupContext context;
LocalUseMap localUses; // ### rename
QList<Use> typeUsages;
QList<CPlusPlus::Document::DiagnosticMessage> diagnosticMessages;
......
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