forked from qt-creator/qt-creator
CppEditor: Remove RefactoringEngine
Another useless indirection. Change-Id: Icfcc0704a1056d8002a674edbe74b946cb56ff27 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -26,7 +26,6 @@ add_qtc_plugin(ClangCodeModel
|
||||
clangpreprocessorassistproposalitem.cpp clangpreprocessorassistproposalitem.h
|
||||
clangprojectsettings.cpp clangprojectsettings.h
|
||||
clangprojectsettingswidget.cpp clangprojectsettingswidget.h clangprojectsettingswidget.ui
|
||||
clangrefactoringengine.cpp clangrefactoringengine.h
|
||||
clangtextmark.cpp clangtextmark.h
|
||||
clanguiheaderondiskmanager.cpp clanguiheaderondiskmanager.h
|
||||
clangutils.cpp clangutils.h
|
||||
|
||||
@@ -59,8 +59,6 @@ QtcPlugin {
|
||||
"clangprojectsettingswidget.cpp",
|
||||
"clangprojectsettingswidget.h",
|
||||
"clangprojectsettingswidget.ui",
|
||||
"clangrefactoringengine.cpp",
|
||||
"clangrefactoringengine.h",
|
||||
"clangtextmark.cpp",
|
||||
"clangtextmark.h",
|
||||
"clanguiheaderondiskmanager.cpp",
|
||||
|
||||
@@ -826,7 +826,7 @@ public:
|
||||
class LocalRefsData {
|
||||
public:
|
||||
LocalRefsData(quint64 id, TextDocument *doc, const QTextCursor &cursor,
|
||||
CppEditor::RefactoringEngineInterface::RenameCallback &&callback)
|
||||
CppEditor::RenameCallback &&callback)
|
||||
: id(id), document(doc), cursor(cursor), callback(std::move(callback)),
|
||||
uri(DocumentUri::fromFilePath(doc->filePath())), revision(doc->document()->revision())
|
||||
{}
|
||||
@@ -840,7 +840,7 @@ public:
|
||||
const quint64 id;
|
||||
const QPointer<TextDocument> document;
|
||||
const QTextCursor cursor;
|
||||
CppEditor::RefactoringEngineInterface::RenameCallback callback;
|
||||
CppEditor::RenameCallback callback;
|
||||
const DocumentUri uri;
|
||||
const int revision;
|
||||
};
|
||||
@@ -2187,7 +2187,7 @@ void ClangdClient::switchDeclDef(TextDocument *document, const QTextCursor &curs
|
||||
}
|
||||
|
||||
void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cursor,
|
||||
CppEditor::RefactoringEngineInterface::RenameCallback &&callback)
|
||||
CppEditor::RenameCallback &&callback)
|
||||
{
|
||||
QTC_ASSERT(documentOpen(document), openDocument(document));
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <cppeditor/baseeditordocumentparser.h>
|
||||
#include <cppeditor/cppcodemodelsettings.h>
|
||||
#include <cppeditor/refactoringengineinterface.h>
|
||||
#include <cppeditor/cursorineditor.h>
|
||||
#include <languageclient/client.h>
|
||||
#include <utils/link.h>
|
||||
#include <utils/optional.h>
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
Utils::ProcessLinkCallback &&callback);
|
||||
|
||||
void findLocalUsages(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
||||
CppEditor::RefactoringEngineInterface::RenameCallback &&callback);
|
||||
CppEditor::RenameCallback &&callback);
|
||||
|
||||
void gatherHelpItemForTooltip(
|
||||
const LanguageServerProtocol::HoverRequest::Response &hoverResponse,
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "clangeditordocumentprocessor.h"
|
||||
#include "clangdlocatorfilters.h"
|
||||
#include "clangprojectsettings.h"
|
||||
#include "clangrefactoringengine.h"
|
||||
#include "clangutils.h"
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
@@ -49,7 +48,6 @@
|
||||
#include <cppeditor/cppprojectfile.h>
|
||||
#include <cppeditor/cpptoolsreuse.h>
|
||||
#include <cppeditor/editordocumenthandle.h>
|
||||
#include <cppeditor/symbolfinder.h>
|
||||
|
||||
#include <languageclient/languageclientmanager.h>
|
||||
|
||||
@@ -104,7 +102,7 @@ static const QList<TextEditor::TextDocument *> allCppDocuments()
|
||||
return Utils::qobject_container_cast<TextEditor::TextDocument *>(documents);
|
||||
}
|
||||
|
||||
ClangModelManagerSupport::ClangModelManagerSupport() : m_refactoringEngine(new RefactoringEngine)
|
||||
ClangModelManagerSupport::ClangModelManagerSupport()
|
||||
{
|
||||
QTC_CHECK(!m_instance);
|
||||
m_instance = this;
|
||||
@@ -189,10 +187,8 @@ void ClangModelManagerSupport::followSymbol(const CppEditor::CursorInEditor &dat
|
||||
return;
|
||||
}
|
||||
|
||||
SymbolFinder finder;
|
||||
CppModelManager::builtinFollowSymbol().findLink(data, std::move(processLinkCallback),
|
||||
resolveTarget, CppModelManager::instance()->snapshot(),
|
||||
data.editorWidget()->semanticInfo().doc, &finder, inNextSplit);
|
||||
CppModelManager::followSymbol(data, std::move(processLinkCallback), resolveTarget, inNextSplit,
|
||||
CppModelManager::Backend::Builtin);
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::switchDeclDef(const CppEditor::CursorInEditor &data,
|
||||
@@ -205,15 +201,52 @@ void ClangModelManagerSupport::switchDeclDef(const CppEditor::CursorInEditor &da
|
||||
return;
|
||||
}
|
||||
|
||||
SymbolFinder finder;
|
||||
CppModelManager::builtinFollowSymbol().switchDeclDef(data, std::move(processLinkCallback),
|
||||
CppModelManager::instance()->snapshot(), data.editorWidget()->semanticInfo().doc,
|
||||
&finder);
|
||||
CppModelManager::switchDeclDef(data, std::move(processLinkCallback),
|
||||
CppModelManager::Backend::Builtin);
|
||||
}
|
||||
|
||||
CppEditor::RefactoringEngineInterface &ClangModelManagerSupport::refactoringEngineInterface()
|
||||
void ClangModelManagerSupport::startLocalRenaming(const CppEditor::CursorInEditor &data,
|
||||
const CppEditor::ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
return *m_refactoringEngine;
|
||||
if (ClangdClient * const client = clientForFile(data.filePath());
|
||||
client && client->reachable()) {
|
||||
client->findLocalUsages(data.textDocument(), data.cursor(),
|
||||
std::move(renameSymbolsCallback));
|
||||
return;
|
||||
}
|
||||
|
||||
CppModelManager::startLocalRenaming(data, projectPart,
|
||||
std::move(renameSymbolsCallback), CppModelManager::Backend::Builtin);
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::globalRename(const CppEditor::CursorInEditor &cursor,
|
||||
CppEditor::UsagesCallback &&callback,
|
||||
const QString &replacement)
|
||||
{
|
||||
if (ClangdClient * const client = clientForFile(cursor.filePath());
|
||||
client && client->isFullyIndexed()) {
|
||||
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
||||
client->openDocument(cursor.textDocument()));
|
||||
client->findUsages(cursor.textDocument(), cursor.cursor(), replacement);
|
||||
return;
|
||||
}
|
||||
CppModelManager::globalRename(cursor, std::move(callback), replacement,
|
||||
CppModelManager::Backend::Builtin);
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::findUsages(const CppEditor::CursorInEditor &cursor,
|
||||
CppEditor::UsagesCallback &&callback) const
|
||||
{
|
||||
if (ClangdClient * const client = clientForFile(cursor.filePath());
|
||||
client && client->isFullyIndexed()) {
|
||||
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
||||
client->openDocument(cursor.textDocument()));
|
||||
client->findUsages(cursor.textDocument(), cursor.cursor(), {});
|
||||
|
||||
return;
|
||||
}
|
||||
CppModelManager::findUsages(cursor, std::move(callback), CppModelManager::Backend::Builtin);
|
||||
}
|
||||
|
||||
std::unique_ptr<CppEditor::AbstractOverviewModel> ClangModelManagerSupport::createOverviewModel()
|
||||
|
||||
@@ -68,7 +68,6 @@ public:
|
||||
TextEditor::BaseHoverHandler *createHoverHandler() override { return nullptr; }
|
||||
CppEditor::BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
||||
TextEditor::TextDocument *baseTextDocument) override;
|
||||
CppEditor::RefactoringEngineInterface &refactoringEngineInterface() override;
|
||||
std::unique_ptr<CppEditor::AbstractOverviewModel> createOverviewModel() override;
|
||||
bool supportsOutline(const TextEditor::TextDocument *document) const override;
|
||||
bool supportsLocalUses(const TextEditor::TextDocument *document) const override;
|
||||
@@ -93,6 +92,13 @@ private:
|
||||
bool inNextSplit) override;
|
||||
void switchDeclDef(const CppEditor::CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback) override;
|
||||
void startLocalRenaming(const CppEditor::CursorInEditor &data,
|
||||
const CppEditor::ProjectPart *projectPart,
|
||||
CppEditor::RenameCallback &&renameSymbolsCallback) override;
|
||||
void globalRename(const CppEditor::CursorInEditor &cursor, CppEditor::UsagesCallback &&callback,
|
||||
const QString &replacement) override;
|
||||
void findUsages(const CppEditor::CursorInEditor &cursor,
|
||||
CppEditor::UsagesCallback &&callback) const override;
|
||||
|
||||
void onEditorOpened(Core::IEditor *editor);
|
||||
void onCurrentEditorChanged(Core::IEditor *newCurrent);
|
||||
@@ -128,7 +134,6 @@ private:
|
||||
void watchForInternalChanges();
|
||||
|
||||
UiHeaderOnDiskManager m_uiHeaderOnDiskManager;
|
||||
std::unique_ptr<CppEditor::RefactoringEngineInterface> m_refactoringEngine;
|
||||
|
||||
QHash<ProjectExplorer::Project *, ClangProjectSettings *> m_projectSettings;
|
||||
Utils::FutureSynchronizer m_generatorSynchronizer;
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangrefactoringengine.h"
|
||||
|
||||
#include "clangdclient.h"
|
||||
#include "clangmodelmanagersupport.h"
|
||||
|
||||
#include <cppeditor/cppmodelmanager.h>
|
||||
#include <languageclient/languageclientsymbolsupport.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
void RefactoringEngine::startLocalRenaming(const CppEditor::CursorInEditor &data,
|
||||
const CppEditor::ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(data.filePath());
|
||||
if (client && client->reachable()) {
|
||||
client->findLocalUsages(data.textDocument(), data.cursor(),
|
||||
std::move(renameSymbolsCallback));
|
||||
return;
|
||||
}
|
||||
|
||||
CppEditor::CppModelManager::builtinRefactoringEngine()
|
||||
->startLocalRenaming(data, projectPart, std::move(renameSymbolsCallback));
|
||||
}
|
||||
|
||||
void RefactoringEngine::globalRename(const CppEditor::CursorInEditor &cursor,
|
||||
CppEditor::UsagesCallback &&callback,
|
||||
const QString &replacement)
|
||||
{
|
||||
ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||
if (!client || !client->isFullyIndexed()) {
|
||||
CppEditor::CppModelManager::builtinRefactoringEngine()
|
||||
->globalRename(cursor, std::move(callback), replacement);
|
||||
return;
|
||||
}
|
||||
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
||||
client->openDocument(cursor.textDocument()));
|
||||
client->findUsages(cursor.textDocument(), cursor.cursor(), replacement);
|
||||
}
|
||||
|
||||
void RefactoringEngine::findUsages(const CppEditor::CursorInEditor &cursor,
|
||||
CppEditor::UsagesCallback &&callback) const
|
||||
{
|
||||
ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||
if (!client || !client->isFullyIndexed()) {
|
||||
CppEditor::CppModelManager::builtinRefactoringEngine()
|
||||
->findUsages(cursor, std::move(callback));
|
||||
return;
|
||||
}
|
||||
QTC_ASSERT(client->documentOpen(cursor.textDocument()),
|
||||
client->openDocument(cursor.textDocument()));
|
||||
client->findUsages(cursor.textDocument(), cursor.cursor(), {});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
@@ -1,58 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cppeditor/refactoringengineinterface.h>
|
||||
#include <cppeditor/cppcursorinfo.h>
|
||||
|
||||
#include <QFutureWatcher>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
class RefactoringClientInterface;
|
||||
class RefactoringServerInterface;
|
||||
}
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class RefactoringEngine : public CppEditor::RefactoringEngineInterface
|
||||
{
|
||||
public:
|
||||
void startLocalRenaming(const CppEditor::CursorInEditor &data,
|
||||
const CppEditor::ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback) override;
|
||||
void globalRename(const CppEditor::CursorInEditor &cursor, CppEditor::UsagesCallback &&callback,
|
||||
const QString &replacement) override;
|
||||
void findUsages(const CppEditor::CursorInEditor &cursor,
|
||||
CppEditor::UsagesCallback &&callback) const override;
|
||||
|
||||
private:
|
||||
using FutureCursorWatcher = QFutureWatcher<CppEditor::CursorInfo>;
|
||||
std::unique_ptr<FutureCursorWatcher> m_watcher;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangRefactoring
|
||||
Reference in New Issue
Block a user