summaryrefslogtreecommitdiff
path: root/src/plugins/clangrefactoring
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2016-11-29 12:50:50 +0100
committerMarco Bubke <marco.bubke@qt.io>2016-12-07 11:38:46 +0000
commit105a62825526ed4e6760543cb5681f771688ca67 (patch)
tree01086d8258ed84cd5082c479d212d35e54d13d7a /src/plugins/clangrefactoring
parentf02dddb6c8f2bf0a59203394bb379d369c9ece11 (diff)
downloadqt-creator-105a62825526ed4e6760543cb5681f771688ca67.tar.gz
Clang: Improve ClangRefactoringPlugin initializing
Change-Id: I2e45d588e7a8c50b61b401c6dea9f3cf8db45611 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/clangrefactoring')
-rw-r--r--src/plugins/clangrefactoring/clangrefactoringplugin.cpp59
-rw-r--r--src/plugins/clangrefactoring/clangrefactoringplugin.h11
2 files changed, 37 insertions, 33 deletions
diff --git a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp
index 10dda5d3dc..1b35afe894 100644
--- a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp
+++ b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp
@@ -46,24 +46,34 @@ QString backendProcessPath()
} // anonymous namespace
-std::unique_ptr<RefactoringClient> ClangRefactoringPlugin::refactoringClient;
-std::unique_ptr<ClangBackEnd::RefactoringConnectionClient> ClangRefactoringPlugin::connectionClient;
-std::unique_ptr<RefactoringEngine> ClangRefactoringPlugin::engine;
-std::unique_ptr<QtCreatorSearch> ClangRefactoringPlugin::qtCreatorSearch;
-std::unique_ptr<QtCreatorClangQueryFindFilter> ClangRefactoringPlugin::qtCreatorfindFilter;
+std::unique_ptr<ClangRefactoringPluginData> ClangRefactoringPlugin::d;
+
+class ClangRefactoringPluginData
+{
+public:
+ RefactoringClient refactoringClient;
+ ClangBackEnd::RefactoringConnectionClient connectionClient{&refactoringClient};
+ RefactoringEngine engine{connectionClient.serverProxy(), refactoringClient};
+ QtCreatorSearch qtCreatorSearch{*Core::SearchResultWindow::instance()};
+ QtCreatorClangQueryFindFilter qtCreatorfindFilter{connectionClient.serverProxy(),
+ qtCreatorSearch,
+ refactoringClient};
+};
+
+ClangRefactoringPlugin::ClangRefactoringPlugin()
+{
+}
+
+ClangRefactoringPlugin::~ClangRefactoringPlugin()
+{
+}
bool ClangRefactoringPlugin::initialize(const QStringList & /*arguments*/, QString * /*errorMessage*/)
{
- refactoringClient.reset(new RefactoringClient);
- connectionClient.reset(new ClangBackEnd::RefactoringConnectionClient(refactoringClient.get()));
- engine.reset(new RefactoringEngine(connectionClient->serverProxy(), *refactoringClient));
- qtCreatorSearch.reset(new ClangRefactoring::QtCreatorSearch(*Core::SearchResultWindow::instance()));
- qtCreatorfindFilter.reset(new QtCreatorClangQueryFindFilter(connectionClient->serverProxy(),
- *qtCreatorSearch.get(),
- *refactoringClient));
+ d.reset(new ClangRefactoringPluginData);
- refactoringClient->setRefactoringEngine(engine.get());
- ExtensionSystem::PluginManager::addObject(qtCreatorfindFilter.get());
+ d->refactoringClient.setRefactoringEngine(&d->engine);
+ ExtensionSystem::PluginManager::addObject(&d->qtCreatorfindFilter);
connectBackend();
startBackend();
@@ -78,34 +88,29 @@ void ClangRefactoringPlugin::extensionsInitialized()
ExtensionSystem::IPlugin::ShutdownFlag ClangRefactoringPlugin::aboutToShutdown()
{
- ExtensionSystem::PluginManager::removeObject(qtCreatorfindFilter.get());
- refactoringClient->setRefactoringEngine(nullptr);
-
- connectionClient->finishProcess();
+ ExtensionSystem::PluginManager::removeObject(&d->qtCreatorfindFilter);
+ d->refactoringClient.setRefactoringEngine(nullptr);
- qtCreatorfindFilter.reset();
- engine.reset();
- connectionClient.reset();
- refactoringClient.reset();
+ d.reset();
return SynchronousShutdown;
}
RefactoringEngine &ClangRefactoringPlugin::refactoringEngine()
{
- return *engine;
+ return d->engine;
}
void ClangRefactoringPlugin::startBackend()
{
- connectionClient->setProcessPath(backendProcessPath());
+ d->connectionClient.setProcessPath(backendProcessPath());
- connectionClient->startProcessAndConnectToServerAsynchronously();
+ d->connectionClient.startProcessAndConnectToServerAsynchronously();
}
void ClangRefactoringPlugin::connectBackend()
{
- connect(connectionClient.get(),
+ connect(&d->connectionClient,
&ClangBackEnd::RefactoringConnectionClient::connectedToLocalSocket,
this,
&ClangRefactoringPlugin::backendIsConnected);
@@ -113,7 +118,7 @@ void ClangRefactoringPlugin::connectBackend()
void ClangRefactoringPlugin::backendIsConnected()
{
- engine->setUsable(true);
+ d->engine.setUsable(true);
}
} // namespace ClangRefactoring
diff --git a/src/plugins/clangrefactoring/clangrefactoringplugin.h b/src/plugins/clangrefactoring/clangrefactoringplugin.h
index c321f564d1..c0b90c7668 100644
--- a/src/plugins/clangrefactoring/clangrefactoringplugin.h
+++ b/src/plugins/clangrefactoring/clangrefactoringplugin.h
@@ -39,12 +39,16 @@
namespace ClangRefactoring {
+class ClangRefactoringPluginData;
+
class ClangRefactoringPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClangRefactoring.json")
public:
+ ClangRefactoringPlugin();
+ ~ClangRefactoringPlugin();
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
@@ -57,12 +61,7 @@ private:
void backendIsConnected();
private:
- static std::unique_ptr<ClangBackEnd::RefactoringConnectionClient> connectionClient;
- static std::unique_ptr<RefactoringClient> refactoringClient;
- static std::unique_ptr<RefactoringEngine> engine;
- static std::unique_ptr<QtCreatorClangQueryFindFilter> qtCreatorfindFilter;
- static std::unique_ptr<QtCreatorSearch> qtCreatorSearch;
-
+ static std::unique_ptr<ClangRefactoringPluginData> d;
};
} // namespace ClangRefactoring