CppCheck: Hide plugin class definition in .cpp

Change-Id: I960ec6e0e4d63cf0edf7af55d191ba666f44739b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-12 17:48:01 +01:00
parent a3bad897af
commit bc14d32a8c
4 changed files with 35 additions and 59 deletions

View File

@@ -8,7 +8,7 @@ add_qtc_plugin(Cppcheck
cppcheckdiagnosticsmodel.cpp cppcheckdiagnosticsmodel.h
cppcheckdiagnosticview.cpp cppcheckdiagnosticview.h
cppcheckmanualrundialog.cpp cppcheckmanualrundialog.h
cppcheckplugin.cpp cppcheckplugin.h
cppcheckplugin.cpp
cppcheckrunner.cpp cppcheckrunner.h
cppchecksettings.cpp cppchecksettings.h
cppchecktextmark.cpp cppchecktextmark.h

View File

@@ -24,7 +24,6 @@ QtcPlugin {
"cppcheckmanualrundialog.cpp",
"cppcheckmanualrundialog.h",
"cppcheckplugin.cpp",
"cppcheckplugin.h",
"cppcheckrunner.cpp",
"cppcheckrunner.h",
"cppchecksettings.cpp",

View File

@@ -1,8 +1,6 @@
// Copyright (C) 2018 Sergey Morozov
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppcheckplugin.h"
#include "cppcheckconstants.h"
#include "cppcheckdiagnosticview.h"
#include "cppchecksettings.h"
@@ -13,6 +11,14 @@
#include "cppcheckdiagnosticsmodel.h"
#include "cppcheckmanualrundialog.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <debugger/analyzer/analyzerconstants.h>
#include <debugger/debuggermainwindow.h>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/kitaspects.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
@@ -20,12 +26,6 @@
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <debugger/analyzer/analyzerconstants.h>
#include <debugger/debuggermainwindow.h>
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
@@ -139,30 +139,36 @@ void CppcheckPluginPrivate::updateManualRunAction()
manualRunAction->setEnabled(canRun);
}
CppcheckPlugin::CppcheckPlugin() = default;
CppcheckPlugin::~CppcheckPlugin() = default;
void CppcheckPlugin::initialize()
class CppcheckPlugin final : public ExtensionSystem::IPlugin
{
d.reset(new CppcheckPluginPrivate);
using namespace Core;
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Cppcheck.json")
void initialize() final
{
auto action = new QAction(Tr::tr("Cppcheck..."), this);
menu->addAction(ActionManager::registerAction(action, Constants::MANUAL_RUN_ACTION),
Debugger::Constants::G_ANALYZER_TOOLS);
connect(action, &QAction::triggered,
d.get(), &CppcheckPluginPrivate::startManualRun);
d->manualRunAction = action;
d.reset(new CppcheckPluginPrivate);
using namespace Core;
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
{
auto action = new QAction(Tr::tr("Cppcheck..."), this);
menu->addAction(ActionManager::registerAction(action, Constants::MANUAL_RUN_ACTION),
Debugger::Constants::G_ANALYZER_TOOLS);
connect(action, &QAction::triggered,
d.get(), &CppcheckPluginPrivate::startManualRun);
d->manualRunAction = action;
}
using ProjectExplorer::ProjectExplorerPlugin;
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::runActionsUpdated,
d.get(), &CppcheckPluginPrivate::updateManualRunAction);
d->updateManualRunAction();
}
using ProjectExplorer::ProjectExplorerPlugin;
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::runActionsUpdated,
d.get(), &CppcheckPluginPrivate::updateManualRunAction);
d->updateManualRunAction();
}
std::unique_ptr<CppcheckPluginPrivate> d;
};
} // Cppcheck::Internal
#include "cppcheckplugin.moc"

View File

@@ -1,29 +0,0 @@
// Copyright (C) 2018 Sergey Morozov
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <extensionsystem/iplugin.h>
#include <memory>
namespace Cppcheck::Internal {
class CppcheckPluginPrivate;
class CppcheckPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Cppcheck.json")
public:
CppcheckPlugin();
~CppcheckPlugin() override;
private:
void initialize() final;
std::unique_ptr<CppcheckPluginPrivate> d;
};
} // Cppcheck