forked from qt-creator/qt-creator
Use the most recent snapshot when searching for the usages of a symbol.
This commit is contained in:
@@ -619,7 +619,9 @@ const Macro *CPPEditor::findCanonicalMacro(const QTextCursor &cursor, Document::
|
||||
|
||||
void CPPEditor::findUsages()
|
||||
{
|
||||
const SemanticInfo info = m_lastSemanticInfo;
|
||||
SemanticInfo info = m_lastSemanticInfo;
|
||||
info.snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
|
||||
info.snapshot.insert(info.doc);
|
||||
|
||||
CanonicalSymbol cs(this, info);
|
||||
Symbol *canonicalSymbol = cs(textCursor());
|
||||
@@ -630,6 +632,28 @@ void CPPEditor::findUsages()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPPEditor::renameUsagesNow(const QString &replacement)
|
||||
{
|
||||
SemanticInfo info = m_lastSemanticInfo;
|
||||
info.snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
|
||||
info.snapshot.insert(info.doc);
|
||||
|
||||
CanonicalSymbol cs(this, info);
|
||||
if (Symbol *canonicalSymbol = cs(textCursor())) {
|
||||
if (canonicalSymbol->identifier() != 0) {
|
||||
if (showWarningMessage()) {
|
||||
Core::EditorManager::instance()->showEditorInfoBar(QLatin1String("CppEditor.Rename"),
|
||||
tr("This change cannot be undone."),
|
||||
tr("Yes, I know what I am doing."),
|
||||
this, SLOT(hideRenameNotification()));
|
||||
}
|
||||
|
||||
m_modelManager->renameUsages(canonicalSymbol, cs.context(), replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPPEditor::renameUsages()
|
||||
{
|
||||
renameUsagesNow();
|
||||
@@ -664,25 +688,6 @@ void CPPEditor::hideRenameNotification()
|
||||
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
|
||||
}
|
||||
|
||||
void CPPEditor::renameUsagesNow(const QString &replacement)
|
||||
{
|
||||
const SemanticInfo info = m_lastSemanticInfo;
|
||||
|
||||
CanonicalSymbol cs(this, info);
|
||||
if (Symbol *canonicalSymbol = cs(textCursor())) {
|
||||
if (canonicalSymbol->identifier() != 0) {
|
||||
if (showWarningMessage()) {
|
||||
Core::EditorManager::instance()->showEditorInfoBar(QLatin1String("CppEditor.Rename"),
|
||||
tr("This change cannot be undone."),
|
||||
tr("Yes, I know what I am doing."),
|
||||
this, SLOT(hideRenameNotification()));
|
||||
}
|
||||
|
||||
m_modelManager->renameUsages(canonicalSymbol, cs.context(), replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPPEditor::markSymbolsNow()
|
||||
{
|
||||
if (m_references.isCanceled())
|
||||
|
||||
@@ -176,9 +176,6 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
const DependencyTable dependencyTable,
|
||||
Symbol *symbol)
|
||||
{
|
||||
QTime tm;
|
||||
tm.start();
|
||||
|
||||
const Identifier *symbolId = symbol->identifier();
|
||||
Q_ASSERT(symbolId != 0);
|
||||
|
||||
@@ -200,7 +197,6 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
files += dependencyTable.filesDependingOn(sourceFile);
|
||||
}
|
||||
files.removeDuplicates();
|
||||
//qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size();
|
||||
|
||||
future.setProgressRange(0, files.size());
|
||||
|
||||
@@ -212,7 +208,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
future.setProgressValue(files.size());
|
||||
}
|
||||
|
||||
static CPlusPlus::DependencyTable dependencyTable(DependencyTable previous, CPlusPlus::Snapshot snapshot)
|
||||
static CPlusPlus::DependencyTable dependencyTable(DependencyTable previous, const CPlusPlus::Snapshot &snapshot)
|
||||
{
|
||||
if (previous.isValidFor(snapshot))
|
||||
return previous;
|
||||
@@ -264,7 +260,6 @@ void CppFindReferences::findAll_helper(Symbol *symbol, const LookupContext &cont
|
||||
|
||||
_resultWindow->popup(true);
|
||||
|
||||
const Snapshot snapshot = _modelManager->snapshot();
|
||||
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
|
||||
|
||||
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
||||
|
||||
Reference in New Issue
Block a user