ClangFormat: Hide plugin class definition in .cpp

Change-Id: I37017641a55287b5049d99064a2ca77c6a7dc201
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-19 14:45:08 +01:00
parent 3f4dc07aea
commit fc706838ef
4 changed files with 40 additions and 54 deletions

View File

@@ -10,7 +10,7 @@ add_qtc_plugin(ClangFormat
clangformatconstants.h clangformatconstants.h
clangformatfile.cpp clangformatfile.h clangformatfile.cpp clangformatfile.h
clangformatindenter.cpp clangformatindenter.h clangformatindenter.cpp clangformatindenter.h
clangformatplugin.cpp clangformatplugin.h clangformatplugin.cpp
clangformatsettings.cpp clangformatsettings.h clangformatsettings.cpp clangformatsettings.h
clangformattr.h clangformattr.h
clangformatutils.cpp clangformatutils.h clangformatutils.cpp clangformatutils.h

View File

@@ -46,7 +46,6 @@ QtcPlugin {
"clangformatindenter.cpp", "clangformatindenter.cpp",
"clangformatindenter.h", "clangformatindenter.h",
"clangformatplugin.cpp", "clangformatplugin.cpp",
"clangformatplugin.h",
"clangformatsettings.cpp", "clangformatsettings.cpp",
"clangformatsettings.h", "clangformatsettings.h",
"clangformattr.h", "clangformattr.h",

View File

@@ -1,8 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd. // Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "clangformatplugin.h"
#include "clangformatconfigwidget.h" #include "clangformatconfigwidget.h"
#include "clangformatconstants.h" #include "clangformatconstants.h"
#include "clangformatglobalconfigwidget.h" #include "clangformatglobalconfigwidget.h"
@@ -21,6 +19,8 @@
#include <cppeditor/cppcodestylepreferencesfactory.h> #include <cppeditor/cppcodestylepreferencesfactory.h>
#include <cppeditor/cppeditorconstants.h> #include <cppeditor/cppeditorconstants.h>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <texteditor/icodestylepreferences.h> #include <texteditor/icodestylepreferences.h>
@@ -36,7 +36,7 @@ using namespace Utils;
namespace ClangFormat { namespace ClangFormat {
class ClangFormatStyleFactory : public CppCodeStylePreferencesFactory class ClangFormatStyleFactory final : public CppCodeStylePreferencesFactory
{ {
public: public:
Indenter *createIndenter(QTextDocument *doc) const override Indenter *createIndenter(QTextDocument *doc) const override
@@ -57,13 +57,18 @@ public:
} }
}; };
ClangFormatPlugin::~ClangFormatPlugin() class ClangFormatPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClangFormat.json")
~ClangFormatPlugin() final
{ {
TextEditorSettings::unregisterCodeStyleFactory(CppEditor::Constants::CPP_SETTINGS_ID); TextEditorSettings::unregisterCodeStyleFactory(CppEditor::Constants::CPP_SETTINGS_ID);
delete m_factory; delete m_factory;
} }
void ClangFormatPlugin::initialize() void initialize() final
{ {
TextEditorSettings::unregisterCodeStyleFactory(CppEditor::Constants::CPP_SETTINGS_ID); TextEditorSettings::unregisterCodeStyleFactory(CppEditor::Constants::CPP_SETTINGS_ID);
m_factory = new ClangFormatStyleFactory; m_factory = new ClangFormatStyleFactory;
@@ -90,4 +95,9 @@ void ClangFormatPlugin::initialize()
#endif #endif
} }
TextEditor::ICodeStylePreferencesFactory *m_factory = nullptr;
};
} // ClangFormat } // ClangFormat
#include "clangformatplugin.moc"

View File

@@ -1,23 +0,0 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <extensionsystem/iplugin.h>
namespace TextEditor { class ICodeStylePreferencesFactory; }
namespace ClangFormat {
class ClangFormatPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClangFormat.json")
~ClangFormatPlugin() override;
void initialize() final;
TextEditor::ICodeStylePreferencesFactory *m_factory = nullptr;
};
} // namespace ClangTools