ModelManagerSupport: Get rid of UsagesCallback from findUsages()

It's not used currently.

Change-Id: Ic3625b0f3c53c09089a361453f29ac639692cffb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-06-02 00:42:28 +02:00
parent b9f0663741
commit 8cd9a2dd12
8 changed files with 12 additions and 25 deletions

View File

@@ -223,8 +223,7 @@ void ClangModelManagerSupport::globalRename(const CppEditor::CursorInEditor &cur
CppModelManager::globalRename(cursor, replacement, CppModelManager::Backend::Builtin); CppModelManager::globalRename(cursor, replacement, CppModelManager::Backend::Builtin);
} }
void ClangModelManagerSupport::findUsages(const CppEditor::CursorInEditor &cursor, void ClangModelManagerSupport::findUsages(const CppEditor::CursorInEditor &cursor) const
CppEditor::UsagesCallback &&callback) const
{ {
if (ClangdClient * const client = clientForFile(cursor.filePath()); if (ClangdClient * const client = clientForFile(cursor.filePath());
client && client->isFullyIndexed()) { client && client->isFullyIndexed()) {
@@ -234,7 +233,7 @@ void ClangModelManagerSupport::findUsages(const CppEditor::CursorInEditor &curso
return; return;
} }
CppModelManager::findUsages(cursor, std::move(callback), CppModelManager::Backend::Builtin); CppModelManager::findUsages(cursor, CppModelManager::Backend::Builtin);
} }
void ClangModelManagerSupport::switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) void ClangModelManagerSupport::switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit)

View File

@@ -91,8 +91,7 @@ private:
const CppEditor::ProjectPart *projectPart, const CppEditor::ProjectPart *projectPart,
CppEditor::RenameCallback &&renameSymbolsCallback) override; CppEditor::RenameCallback &&renameSymbolsCallback) override;
void globalRename(const CppEditor::CursorInEditor &cursor, const QString &replacement) override; void globalRename(const CppEditor::CursorInEditor &cursor, const QString &replacement) override;
void findUsages(const CppEditor::CursorInEditor &cursor, void findUsages(const CppEditor::CursorInEditor &cursor) const override;
CppEditor::UsagesCallback &&callback) const override;
void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) override; void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) override;
void onEditorOpened(Core::IEditor *editor); void onEditorOpened(Core::IEditor *editor);

View File

@@ -193,8 +193,7 @@ void BuiltinModelManagerSupport::globalRename(const CursorInEditor &data,
} }
} }
void BuiltinModelManagerSupport::findUsages(const CursorInEditor &data, void BuiltinModelManagerSupport::findUsages(const CursorInEditor &data) const
UsagesCallback &&) const
{ {
CppModelManager *modelManager = CppModelManager::instance(); CppModelManager *modelManager = CppModelManager::instance();
if (!modelManager) if (!modelManager)

View File

@@ -59,7 +59,7 @@ private:
const ProjectPart *projectPart, const ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) override; RenameCallback &&renameSymbolsCallback) override;
void globalRename(const CursorInEditor &data, const QString &replacement) override; void globalRename(const CursorInEditor &data, const QString &replacement) override;
void findUsages(const CursorInEditor &data, UsagesCallback &&) const override; void findUsages(const CursorInEditor &data) const override;
void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) override; void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) override;
QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider; QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider;

View File

@@ -792,23 +792,16 @@ void CppEditorWidget::findUsages()
void CppEditorWidget::findUsages(QTextCursor cursor) void CppEditorWidget::findUsages(QTextCursor cursor)
{ {
// 'this' in cursorInEditor is never used (and must never be used) asynchronously. // 'this' in cursorInEditor is never used (and must never be used) asynchronously.
const CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, const CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, textDocument()};
textDocument()};
QPointer<CppEditorWidget> cppEditorWidget = this; QPointer<CppEditorWidget> cppEditorWidget = this;
d->m_modelManager->findUsages(cursorInEditor, d->m_modelManager->findUsages(cursorInEditor);
[=](const Usages &usages) {
if (!cppEditorWidget)
return;
findRenameCallback(cppEditorWidget.data(), cursor, usages);
});
} }
void CppEditorWidget::renameUsages(const QString &replacement, QTextCursor cursor) void CppEditorWidget::renameUsages(const QString &replacement, QTextCursor cursor)
{ {
if (cursor.isNull()) if (cursor.isNull())
cursor = textCursor(); cursor = textCursor();
CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, textDocument()};
textDocument()};
QPointer<CppEditorWidget> cppEditorWidget = this; QPointer<CppEditorWidget> cppEditorWidget = this;
d->m_modelManager->globalRename(cursorInEditor, replacement); d->m_modelManager->globalRename(cursorInEditor, replacement);
} }

View File

@@ -322,10 +322,9 @@ void CppModelManager::globalRename(const CursorInEditor &data, const QString &re
instance()->modelManagerSupport(backend)->globalRename(data, replacement); instance()->modelManagerSupport(backend)->globalRename(data, replacement);
} }
void CppModelManager::findUsages(const CursorInEditor &data, void CppModelManager::findUsages(const CursorInEditor &data, Backend backend)
UsagesCallback &&showUsagesCallback, Backend backend)
{ {
instance()->modelManagerSupport(backend)->findUsages(data, std::move(showUsagesCallback)); instance()->modelManagerSupport(backend)->findUsages(data);
} }
void CppModelManager::switchHeaderSource(bool inNextSplit, Backend backend) void CppModelManager::switchHeaderSource(bool inNextSplit, Backend backend)

View File

@@ -181,8 +181,7 @@ public:
Backend backend = Backend::Best); Backend backend = Backend::Best);
static void globalRename(const CursorInEditor &data, const QString &replacement, static void globalRename(const CursorInEditor &data, const QString &replacement,
Backend backend = Backend::Best); Backend backend = Backend::Best);
static void findUsages(const CursorInEditor &data, UsagesCallback &&showUsagesCallback, static void findUsages(const CursorInEditor &data, Backend backend = Backend::Best);
Backend backend = Backend::Best);
static void switchHeaderSource(bool inNextSplit, Backend backend = Backend::Best); static void switchHeaderSource(bool inNextSplit, Backend backend = Backend::Best);
static Core::ILocatorFilter *createAuxiliaryCurrentDocumentFilter(); static Core::ILocatorFilter *createAuxiliaryCurrentDocumentFilter();

View File

@@ -74,8 +74,7 @@ public:
const ProjectPart *projectPart, const ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) = 0; RenameCallback &&renameSymbolsCallback) = 0;
virtual void globalRename(const CursorInEditor &data, const QString &replacement) = 0; virtual void globalRename(const CursorInEditor &data, const QString &replacement) = 0;
virtual void findUsages(const CursorInEditor &data, virtual void findUsages(const CursorInEditor &data) const = 0;
UsagesCallback &&showUsagesCallback) const = 0;
virtual void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) = 0; virtual void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) = 0;
}; };