forked from qt-creator/qt-creator
CppEditor: Move plugin class definition to .cpp
Also remove the globale instance variable which is not used anymore. Change-Id: Ia054f79570b2fb650db31bd8560a08b0c9fe4c8c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -67,6 +67,8 @@
|
|||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
@@ -181,26 +183,35 @@ public:
|
|||||||
CppProjectUpdaterFactory m_cppProjectUpdaterFactory;
|
CppProjectUpdaterFactory m_cppProjectUpdaterFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
static CppEditorPlugin *m_instance = nullptr;
|
|
||||||
static QHash<FilePath, FilePath> m_headerSourceMapping;
|
static QHash<FilePath, FilePath> m_headerSourceMapping;
|
||||||
|
|
||||||
CppEditorPlugin::CppEditorPlugin()
|
class CppEditorPlugin final : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
m_instance = this;
|
Q_OBJECT
|
||||||
}
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CppEditor.json")
|
||||||
|
|
||||||
CppEditorPlugin::~CppEditorPlugin()
|
public:
|
||||||
{
|
~CppEditorPlugin() final
|
||||||
|
{
|
||||||
destroyCppQuickFixes();
|
destroyCppQuickFixes();
|
||||||
delete d;
|
delete d;
|
||||||
d = nullptr;
|
d = nullptr;
|
||||||
m_instance = nullptr;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CppEditorPlugin *CppEditorPlugin::instance()
|
private:
|
||||||
{
|
void initialize() final;
|
||||||
return m_instance;
|
void extensionsInitialized() final;
|
||||||
}
|
|
||||||
|
void setupMenus();
|
||||||
|
void addPerSymbolActions();
|
||||||
|
void addActionsForSelections();
|
||||||
|
void addPerFileActions();
|
||||||
|
void addGlobalActions();
|
||||||
|
void registerVariables();
|
||||||
|
void registerTests();
|
||||||
|
|
||||||
|
CppEditorPluginPrivate *d = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
void CppEditorPlugin::initialize()
|
void CppEditorPlugin::initialize()
|
||||||
{
|
{
|
||||||
@@ -540,7 +551,7 @@ void CppEditorPluginPrivate::inspectCppCodeModel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::clearHeaderSourceCache()
|
void clearHeaderSourceCache()
|
||||||
{
|
{
|
||||||
m_headerSourceMapping.clear();
|
m_headerSourceMapping.clear();
|
||||||
}
|
}
|
||||||
@@ -774,3 +785,5 @@ FilePath correspondingHeaderOrSource(const FilePath &filePath, bool *wasHeader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
|
|
||||||
|
#include "cppeditorplugin.moc"
|
||||||
|
|||||||
@@ -3,38 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
|
||||||
|
|
||||||
namespace CppEditor::Internal {
|
namespace CppEditor::Internal {
|
||||||
|
|
||||||
class CppEditorPluginPrivate;
|
void clearHeaderSourceCache();
|
||||||
|
|
||||||
class CppEditorPlugin : public ExtensionSystem::IPlugin
|
} // CppEditor::Internal
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CppEditor.json")
|
|
||||||
|
|
||||||
public:
|
|
||||||
CppEditorPlugin();
|
|
||||||
~CppEditorPlugin() override;
|
|
||||||
|
|
||||||
static CppEditorPlugin *instance();
|
|
||||||
|
|
||||||
static void clearHeaderSourceCache();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize() override;
|
|
||||||
void extensionsInitialized() override;
|
|
||||||
|
|
||||||
void setupMenus();
|
|
||||||
void addPerSymbolActions();
|
|
||||||
void addActionsForSelections();
|
|
||||||
void addPerFileActions();
|
|
||||||
void addGlobalActions();
|
|
||||||
void registerVariables();
|
|
||||||
void registerTests();
|
|
||||||
|
|
||||||
CppEditorPluginPrivate *d = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ void CppFileSettingsWidget::apply()
|
|||||||
*m_settings = rc;
|
*m_settings = rc;
|
||||||
m_settings->toSettings(Core::ICore::settings());
|
m_settings->toSettings(Core::ICore::settings());
|
||||||
m_settings->applySuffixesToMimeDB();
|
m_settings->applySuffixesToMimeDB();
|
||||||
CppEditorPlugin::clearHeaderSourceCache();
|
clearHeaderSourceCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setComboText(QComboBox *cb, const QString &text, int defaultIndex = 0)
|
static inline void setComboText(QComboBox *cb, const QString &text, int defaultIndex = 0)
|
||||||
@@ -600,7 +600,7 @@ public:
|
|||||||
if (m_settings.useGlobalSettings() != m_wasGlobal
|
if (m_settings.useGlobalSettings() != m_wasGlobal
|
||||||
|| s.headerSearchPaths != m_initialSettings.headerSearchPaths
|
|| s.headerSearchPaths != m_initialSettings.headerSearchPaths
|
||||||
|| s.sourceSearchPaths != m_initialSettings.sourceSearchPaths) {
|
|| s.sourceSearchPaths != m_initialSettings.sourceSearchPaths) {
|
||||||
CppEditorPlugin::clearHeaderSourceCache();
|
clearHeaderSourceCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ void HeaderSourceTest::test()
|
|||||||
createTempFile(headerPath);
|
createTempFile(headerPath);
|
||||||
|
|
||||||
bool wasHeader;
|
bool wasHeader;
|
||||||
CppEditorPlugin::clearHeaderSourceCache();
|
clearHeaderSourceCache();
|
||||||
QCOMPARE(correspondingHeaderOrSource(sourcePath, &wasHeader), headerPath);
|
QCOMPARE(correspondingHeaderOrSource(sourcePath, &wasHeader), headerPath);
|
||||||
QVERIFY(!wasHeader);
|
QVERIFY(!wasHeader);
|
||||||
CppEditorPlugin::clearHeaderSourceCache();
|
clearHeaderSourceCache();
|
||||||
QCOMPARE(correspondingHeaderOrSource(headerPath, &wasHeader), sourcePath);
|
QCOMPARE(correspondingHeaderOrSource(headerPath, &wasHeader), sourcePath);
|
||||||
QVERIFY(wasHeader);
|
QVERIFY(wasHeader);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user