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