Merge CppTools into CppEditor

There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.

Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-08-30 10:58:08 +02:00
parent 3e1fa0f170
commit 284817fae6
525 changed files with 3705 additions and 4179 deletions

View File

@@ -30,8 +30,8 @@
#include "clangmodelmanagersupport.h"
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cppfollowsymbolundercursor.h>
#include <cppeditor/cppmodelmanager.h>
#include <cppeditor/cppfollowsymbolundercursor.h>
#include <texteditor/texteditor.h>
#include <clangsupport/tokeninfocontainer.h>
@@ -150,7 +150,7 @@ static Utils::Link linkAtCursor(const QTextCursor &cursor,
}
static ::Utils::ProcessLinkCallback extendedCallback(::Utils::ProcessLinkCallback &&callback,
const CppTools::SymbolInfo &result)
const CppEditor::SymbolInfo &result)
{
// If globalFollowSymbol finds nothing follow to the declaration.
return [original_callback = std::move(callback), result](const ::Utils::Link &link) {
@@ -169,12 +169,12 @@ static bool isSameInvocationContext(const Utils::FilePath &filePath)
&& Core::EditorManager::currentDocument()->filePath() == filePath;
}
void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
void ClangFollowSymbol::findLink(const CppEditor::CursorInEditor &data,
::Utils::ProcessLinkCallback &&processLinkCallback,
bool resolveTarget,
const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
CppTools::SymbolFinder *symbolFinder,
CppEditor::SymbolFinder *symbolFinder,
bool inNextSplit)
{
ClangdClient * const client
@@ -202,7 +202,7 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
static_cast<uint>(column),
processor);
if (link == Utils::Link()) {
CppTools::FollowSymbolUnderCursor followSymbol;
CppEditor::FollowSymbolUnderCursor followSymbol;
return followSymbol.findLink(data,
std::move(processLinkCallback),
false,
@@ -214,7 +214,7 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
return processLinkCallback(link);
}
QFuture<CppTools::SymbolInfo> infoFuture
QFuture<CppEditor::SymbolInfo> infoFuture
= processor->requestFollowSymbol(static_cast<int>(line),
static_cast<int>(column));
@@ -230,11 +230,11 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
callback=std::move(processLinkCallback)]() mutable {
if (m_watcher->isCanceled() || !isSameInvocationContext(filePath))
return callback(Utils::Link());
CppTools::SymbolInfo result = m_watcher->result();
CppEditor::SymbolInfo result = m_watcher->result();
// We did not fail but the result is empty
if (result.fileName.isEmpty() || result.isResultOnlyForFallBack) {
const CppTools::RefactoringEngineInterface &refactoringEngine
= *CppTools::CppModelManager::instance();
const CppEditor::RefactoringEngineInterface &refactoringEngine
= *CppEditor::CppModelManager::instance();
refactoringEngine.globalFollowSymbol(data,
extendedCallback(std::move(callback), result),
snapshot,
@@ -251,11 +251,11 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
m_watcher->setFuture(infoFuture);
}
void ClangFollowSymbol::switchDeclDef(const CppTools::CursorInEditor &data,
void ClangFollowSymbol::switchDeclDef(const CppEditor::CursorInEditor &data,
Utils::ProcessLinkCallback &&processLinkCallback,
const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
CppTools::SymbolFinder *symbolFinder)
CppEditor::SymbolFinder *symbolFinder)
{
ClangdClient * const client
= ClangModelManagerSupport::instance()->clientForFile(data.filePath());
@@ -264,7 +264,7 @@ void ClangFollowSymbol::switchDeclDef(const CppTools::CursorInEditor &data,
std::move(processLinkCallback));
return;
}
CppTools::CppModelManager::builtinFollowSymbol().switchDeclDef(
CppEditor::CppModelManager::builtinFollowSymbol().switchDeclDef(
data, std::move(processLinkCallback), snapshot, documentFromSemanticInfo,
symbolFinder);
}