CppEditor: Make local renaming more robust again

This will update the use selections synchronously again in case the user
triggered "Rename Symbol Under Cursor", just as before

    commit 89bd4ee
    C++: Base parsing on editor document instead of widget

Change-Id: I8d4d3dcc7140a61f9ac611a505db09dc96a17740
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-08-26 11:20:39 +02:00
parent ec5ea375e0
commit 7bfe231897
4 changed files with 83 additions and 65 deletions

View File

@@ -342,21 +342,12 @@ void CppEditorWidget::renameUsages(const QString &replacement)
void CppEditorWidget::renameSymbolUnderCursor()
{
updateSemanticInfo(d->m_cppEditorDocument->recalculateSemanticInfo());
d->m_useSelectionsUpdater.abortSchedule();
updateSemanticInfo(d->m_cppEditorDocument->recalculateSemanticInfo(),
/*updateUseSelectionSynchronously=*/ true);
// Trigger once the use selections updater is finished and thus has updated
// the use selections for the local renaming
QSharedPointer<QMetaObject::Connection> connection(new QMetaObject::Connection);
*connection.data() = connect(&d->m_useSelectionsUpdater, &CppUseSelectionsUpdater::finished,
[this, connection] () {
QObject::disconnect(*connection);
if (!d->m_localRenaming.start()) // Rename local symbol
renameUsages(); // Rename non-local symbol or macro
});
d->m_useSelectionsUpdater.update();
if (!d->m_localRenaming.start()) // Rename local symbol
renameUsages(); // Rename non-local symbol or macro
}
void CppEditorWidget::updatePreprocessorButtonTooltip()
@@ -618,15 +609,20 @@ bool CppEditorWidget::openCppEditorAt(const Link &link, bool inNextSplit)
flags);
}
void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
bool updateUseSelectionSynchronously)
{
if (semanticInfo.revision != documentRevision())
return;
d->m_lastSemanticInfo = semanticInfo;
if (!d->m_localRenaming.isActive())
d->m_useSelectionsUpdater.update();
if (!d->m_localRenaming.isActive()) {
const CppUseSelectionsUpdater::CallType type = updateUseSelectionSynchronously
? CppUseSelectionsUpdater::Synchronous
: CppUseSelectionsUpdater::Asynchronous;
d->m_useSelectionsUpdater.update(type);
}
// schedule a check for a decl/def link
updateFunctionDeclDefLink();