Use the most recent snapshot when searching for the usages of a symbol.

This commit is contained in:
Roberto Raggi
2010-08-05 13:59:09 +02:00
parent ccf3244932
commit 672274378b
2 changed files with 26 additions and 26 deletions

View File

@@ -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())