forked from qt-creator/qt-creator
CppEditor: improve quickfix after local renaming
Always update the local usages of the symbol under cursor even if we are currently renaming a local symbol. Otherwise the semantic info is classified as not up to date, which in turns limits the quick fix operation to the ones coming from clangd. As a next step we could make sure the semantic info is valid and up to date before creating the code assist interface by calling a synchronous CppUseSelectionsUpdater::update. But as this will potentially block the ui, it will require some extra handling. Change-Id: Icb9f523a5a21e65a2853e3b98a17c2f45c637825 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -478,8 +478,7 @@ void CppEditorWidget::finalizeInitialization()
|
|||||||
|
|
||||||
// set up the use highlighitng
|
// set up the use highlighitng
|
||||||
connect(this, &CppEditorWidget::cursorPositionChanged, this, [this] {
|
connect(this, &CppEditorWidget::cursorPositionChanged, this, [this] {
|
||||||
if (!d->m_localRenaming.isActive())
|
d->m_useSelectionsUpdater.scheduleUpdate();
|
||||||
d->m_useSelectionsUpdater.scheduleUpdate();
|
|
||||||
|
|
||||||
// Notify selection expander about the changed cursor.
|
// Notify selection expander about the changed cursor.
|
||||||
d->m_cppSelectionChanger.onCursorPositionChanged(textCursor());
|
d->m_cppSelectionChanger.onCursorPositionChanged(textCursor());
|
||||||
@@ -1223,12 +1222,10 @@ void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
|
|||||||
|
|
||||||
d->m_lastSemanticInfo = semanticInfo;
|
d->m_lastSemanticInfo = semanticInfo;
|
||||||
|
|
||||||
if (!d->m_localRenaming.isActive()) {
|
const CppUseSelectionsUpdater::CallType type
|
||||||
const CppUseSelectionsUpdater::CallType type = updateUseSelectionSynchronously
|
= updateUseSelectionSynchronously ? CppUseSelectionsUpdater::CallType::Synchronous
|
||||||
? CppUseSelectionsUpdater::CallType::Synchronous
|
: CppUseSelectionsUpdater::CallType::Asynchronous;
|
||||||
: CppUseSelectionsUpdater::CallType::Asynchronous;
|
d->m_useSelectionsUpdater.update(type);
|
||||||
d->m_useSelectionsUpdater.update(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// schedule a check for a decl/def link
|
// schedule a check for a decl/def link
|
||||||
updateFunctionDeclDefLink();
|
updateFunctionDeclDefLink();
|
||||||
|
@@ -52,7 +52,8 @@ CppUseSelectionsUpdater::RunnerInfo CppUseSelectionsUpdater::update(CallType cal
|
|||||||
auto *cppEditorDocument = qobject_cast<CppEditorDocument *>(cppEditorWidget->textDocument());
|
auto *cppEditorDocument = qobject_cast<CppEditorDocument *>(cppEditorWidget->textDocument());
|
||||||
QTC_ASSERT(cppEditorDocument, return RunnerInfo::FailedToStart);
|
QTC_ASSERT(cppEditorDocument, return RunnerInfo::FailedToStart);
|
||||||
|
|
||||||
m_updateSelections = !CppModelManager::usesClangd(cppEditorDocument);
|
m_updateSelections = !CppModelManager::usesClangd(cppEditorDocument)
|
||||||
|
&& !m_editorWidget->isRenaming();
|
||||||
|
|
||||||
CursorInfoParams params;
|
CursorInfoParams params;
|
||||||
params.semanticInfo = cppEditorWidget->semanticInfo();
|
params.semanticInfo = cppEditorWidget->semanticInfo();
|
||||||
@@ -138,10 +139,6 @@ void CppUseSelectionsUpdater::onFindUsesFinished()
|
|||||||
emit finished(SemanticInfo::LocalUseMap(), false);
|
emit finished(SemanticInfo::LocalUseMap(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_editorWidget->isRenaming()) {
|
|
||||||
emit finished({}, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
processResults(m_runnerWatcher->result());
|
processResults(m_runnerWatcher->result());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user