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

@@ -1,6 +1,6 @@
add_qtc_plugin(Cppcheck
DEPENDS Qt5::Widgets
PLUGIN_DEPENDS Core Debugger CppTools ProjectExplorer TextEditor
PLUGIN_DEPENDS Core Debugger CppEditor ProjectExplorer TextEditor
SOURCES
cppcheckconstants.h
cppcheckdiagnostic.cpp cppcheckdiagnostic.h

View File

@@ -4,7 +4,7 @@ QtcPlugin {
name: "Cppcheck"
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "CppEditor" }
Depends { name: "Debugger" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }

View File

@@ -3,7 +3,7 @@ QTC_LIB_DEPENDS += \
extensionsystem \
utils
QTC_PLUGIN_DEPENDS += \
cpptools \
cppeditor \
debugger \
projectexplorer \
texteditor

View File

@@ -28,7 +28,7 @@
#include <projectexplorer/selectablefilesmodel.h>
#include <cpptools/projectinfo.h>
#include <cppeditor/projectinfo.h>
#include <utils/qtcassert.h>

View File

@@ -33,7 +33,7 @@
#include <coreplugin/progressmanager/futureprogress.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <cpptools/cppmodelmanager.h>
#include <cppeditor/cppmodelmanager.h>
#include <utils/algorithm.h>
#include <utils/macroexpander.h>
@@ -123,7 +123,7 @@ void CppcheckTool::updateArguments()
m_runner->reconfigure(m_options.binary, arguments.join(' '));
}
QStringList CppcheckTool::additionalArguments(const CppTools::ProjectPart &part) const
QStringList CppcheckTool::additionalArguments(const CppEditor::ProjectPart &part) const
{
QStringList result;
@@ -204,22 +204,22 @@ void CppcheckTool::check(const Utils::FilePaths &files)
if (filtered.isEmpty())
return;
const CppTools::ProjectInfo::ConstPtr info
= CppTools::CppModelManager::instance()->projectInfo(m_project);
const CppEditor::ProjectInfo::ConstPtr info
= CppEditor::CppModelManager::instance()->projectInfo(m_project);
if (!info)
return;
const QVector<CppTools::ProjectPart::ConstPtr> parts = info->projectParts();
const QVector<CppEditor::ProjectPart::ConstPtr> parts = info->projectParts();
if (parts.size() == 1) {
QTC_ASSERT(parts.first(), return);
addToQueue(filtered, *parts.first());
return;
}
std::map<CppTools::ProjectPart::ConstPtr, Utils::FilePaths> groups;
std::map<CppEditor::ProjectPart::ConstPtr, Utils::FilePaths> groups;
for (const Utils::FilePath &file : qAsConst(filtered)) {
const QString stringed = file.toString();
for (const CppTools::ProjectPart::ConstPtr &part : parts) {
using CppTools::ProjectFile;
for (const CppEditor::ProjectPart::ConstPtr &part : parts) {
using CppEditor::ProjectFile;
QTC_ASSERT(part, continue);
const auto match = [stringed](const ProjectFile &pFile){return pFile.path == stringed;};
if (Utils::contains(part->files, match))
@@ -231,7 +231,7 @@ void CppcheckTool::check(const Utils::FilePaths &files)
addToQueue(group.second, *group.first);
}
void CppcheckTool::addToQueue(const Utils::FilePaths &files, const CppTools::ProjectPart &part)
void CppcheckTool::addToQueue(const Utils::FilePaths &files, const CppEditor::ProjectPart &part)
{
const QString key = part.id();
if (!m_cachedAdditionalArguments.contains(key))

View File

@@ -38,7 +38,7 @@ class FilePath;
using FilePaths = QList<FilePath>;
}
namespace CppTools {
namespace CppEditor {
class ProjectPart;
}
@@ -75,8 +75,8 @@ public:
private:
void updateArguments();
void addToQueue(const Utils::FilePaths &files, const CppTools::ProjectPart &part);
QStringList additionalArguments(const CppTools::ProjectPart &part) const;
void addToQueue(const Utils::FilePaths &files, const CppEditor::ProjectPart &part);
QStringList additionalArguments(const CppEditor::ProjectPart &part) const;
CppcheckDiagnosticManager &m_manager;
CppcheckOptions m_options;

View File

@@ -27,7 +27,7 @@
#include "cppchecktool.h"
#include "cppchecktrigger.h"
#include <cpptools/cppmodelmanager.h>
#include <cppeditor/cppmodelmanager.h>
#include <utils/qtcassert.h>
@@ -46,7 +46,7 @@ CppcheckTrigger::CppcheckTrigger(CppcheckTextMarkManager &marks, CppcheckTool &t
{
using EditorManager = Core::EditorManager;
using SessionManager = ProjectExplorer::SessionManager;
using CppModelManager = CppTools::CppModelManager;
using CppModelManager = CppEditor::CppModelManager;
connect(EditorManager::instance(), &EditorManager::editorOpened,
this, [this](Core::IEditor *editor) {checkEditors({editor});});
@@ -75,8 +75,8 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
if (!m_currentProject)
return;
using CppModelManager = CppTools::CppModelManager;
const CppTools::ProjectInfo::ConstPtr info
using CppModelManager = CppEditor::CppModelManager;
const CppEditor::ProjectInfo::ConstPtr info
= CppModelManager::instance()->projectInfo(m_currentProject);
if (!info)
return;