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

@@ -29,9 +29,9 @@
#include "clangmodelmanagersupport.h"
#include <coreplugin/helpmanager.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolsreuse.h>
#include <cpptools/editordocumenthandle.h>
#include <cppeditor/cppmodelmanager.h>
#include <cppeditor/cpptoolsreuse.h>
#include <cppeditor/editordocumenthandle.h>
#include <texteditor/texteditor.h>
#include <utils/qtcassert.h>
@@ -51,11 +51,11 @@ using namespace TextEditor;
namespace ClangCodeModel {
namespace Internal {
static CppTools::BaseEditorDocumentProcessor *editorDocumentProcessor(TextEditorWidget *editorWidget)
static CppEditor::BaseEditorDocumentProcessor *editorDocumentProcessor(TextEditorWidget *editorWidget)
{
const QString filePath = editorWidget->textDocument()->filePath().toString();
auto cppModelManager = CppTools::CppModelManager::instance();
CppTools::CppEditorDocumentHandle *editorHandle = cppModelManager->cppEditorDocument(filePath);
auto cppModelManager = CppEditor::CppModelManager::instance();
CppEditor::CppEditorDocumentHandle *editorHandle = cppModelManager->cppEditorDocument(filePath);
if (editorHandle)
return editorHandle->processor();
@@ -76,17 +76,17 @@ static TextMarks diagnosticTextMarksAt(TextEditorWidget *editorWidget, int posit
return processor->diagnosticTextMarksAt(line, column);
}
static QFuture<CppTools::ToolTipInfo> editorDocumentHandlesToolTipInfo(
static QFuture<CppEditor::ToolTipInfo> editorDocumentHandlesToolTipInfo(
TextEditorWidget *editorWidget, int pos)
{
const QByteArray textCodecName = editorWidget->textDocument()->codec()->name();
if (CppTools::BaseEditorDocumentProcessor *processor = editorDocumentProcessor(editorWidget)) {
if (CppEditor::BaseEditorDocumentProcessor *processor = editorDocumentProcessor(editorWidget)) {
int line, column;
if (Utils::Text::convertPosition(editorWidget->document(), pos, &line, &column))
return processor->toolTipInfo(textCodecName, line, column + 1);
}
return QFuture<CppTools::ToolTipInfo>();
return QFuture<CppEditor::ToolTipInfo>();
}
ClangHoverHandler::~ClangHoverHandler()
@@ -116,21 +116,21 @@ void ClangHoverHandler::identifyMatch(TextEditorWidget *editorWidget,
}
// Check for tooltips (async)
QFuture<CppTools::ToolTipInfo> future = editorDocumentHandlesToolTipInfo(editorWidget, pos);
QFuture<CppEditor::ToolTipInfo> future = editorDocumentHandlesToolTipInfo(editorWidget, pos);
if (QTC_GUARD(future.isRunning())) {
qCDebug(hoverLog) << "Requesting tooltip info at" << pos;
m_reportPriority = report;
m_futureWatcher.reset(new QFutureWatcher<CppTools::ToolTipInfo>());
m_futureWatcher.reset(new QFutureWatcher<CppEditor::ToolTipInfo>());
QTextCursor tc(editorWidget->document());
tc.setPosition(pos);
const QStringList fallback = CppTools::identifierWordsUnderCursor(tc);
const QStringList fallback = CppEditor::identifierWordsUnderCursor(tc);
QObject::connect(m_futureWatcher.data(),
&QFutureWatcherBase::finished,
[this, fallback]() {
if (m_futureWatcher->isCanceled()) {
m_reportPriority(Priority_None);
} else {
CppTools::ToolTipInfo info = m_futureWatcher->result();
CppEditor::ToolTipInfo info = m_futureWatcher->result();
qCDebug(hoverLog)
<< "Appending word-based fallback lookup" << fallback;
info.qDocIdCandidates += fallback;
@@ -172,7 +172,7 @@ static const char *helpItemCategoryAsString(Core::HelpItem::Category category)
}
#undef RETURN_TEXT_FOR_CASE
void ClangHoverHandler::processToolTipInfo(const CppTools::ToolTipInfo &info)
void ClangHoverHandler::processToolTipInfo(const CppEditor::ToolTipInfo &info)
{
qCDebug(hoverLog) << "Processing tooltip info" << info.text;