New implementation of CPlusPlus::FindUsages

This commit is contained in:
Roberto Raggi
2010-08-10 14:40:27 +02:00
parent f72a080da4
commit 0f301f8679
6 changed files with 2067 additions and 312 deletions

View File

@@ -739,12 +739,14 @@ void CPPEditor::markSymbolsNow()
setExtraSelections(CodeSemanticsSelection, selections);
}
static QList<int> lazyFindReferences(Scope *scope, QString code, const LookupContext &context)
static QList<int> lazyFindReferences(Scope *scope, QString code, Document::Ptr doc, Snapshot snapshot)
{
TypeOfExpression typeOfExpression;
typeOfExpression.init(context.thisDocument(), context.snapshot(), context.bindings());
if (Symbol *canonicalSymbol = CanonicalSymbol::canonicalSymbol(scope, code, typeOfExpression))
return CppTools::CppModelManagerInterface::instance()->references(canonicalSymbol, context);
snapshot.insert(doc);
typeOfExpression.init(doc, snapshot);
if (Symbol *canonicalSymbol = CanonicalSymbol::canonicalSymbol(scope, code, typeOfExpression)) {
return CppTools::CppModelManagerInterface::instance()->references(canonicalSymbol, typeOfExpression.context());
}
return QList<int>();
}
@@ -758,12 +760,10 @@ void CPPEditor::markSymbols(const QTextCursor &tc, const SemanticInfo &info)
CanonicalSymbol cs(this, info);
QString expression;
if (Scope *scope = cs.getScopeAndExpression(this, info, tc, &expression)) {
LookupContext context(info.doc, info.snapshot);
m_references.cancel();
m_referencesRevision = info.revision;
m_referencesCursorPosition = position();
m_references = QtConcurrent::run(&lazyFindReferences, scope, expression, context);
m_references = QtConcurrent::run(&lazyFindReferences, scope, expression, info.doc, info.snapshot);
m_referencesWatcher.setFuture(m_references);
} else {
const QList<QTextEdit::ExtraSelection> selections = extraSelections(CodeSemanticsSelection);