diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/languageclient/languageclientmanager.cpp | 14 | ||||
-rw-r--r-- | src/plugins/languageclient/languageclientmanager.h | 2 | ||||
-rw-r--r-- | src/plugins/languageclient/languageclientutils.cpp | 13 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/plugins/languageclient/languageclientmanager.cpp b/src/plugins/languageclient/languageclientmanager.cpp index 70d3194c5e..4f0efff178 100644 --- a/src/plugins/languageclient/languageclientmanager.cpp +++ b/src/plugins/languageclient/languageclientmanager.cpp @@ -106,6 +106,13 @@ void LanguageClient::LanguageClientManager::addClient(Client *client) emit managerInstance->clientAdded(client); } +void LanguageClientManager::restartClient(Client *client) +{ + QTC_ASSERT(managerInstance, return); + managerInstance->m_restartingClients.insert(client); + shutdownClient(client); +} + void LanguageClientManager::clientStarted(Client *client) { qCDebug(Log) << "client started: " << client->name() << client; @@ -127,6 +134,13 @@ void LanguageClientManager::clientStarted(Client *client) void LanguageClientManager::clientFinished(Client *client) { QTC_ASSERT(managerInstance, return); + + if (managerInstance->m_restartingClients.remove(client)) { + client->reset(); + client->start(); + return; + } + constexpr int restartTimeoutS = 5; const bool unexpectedFinish = client->state() != Client::Shutdown && client->state() != Client::ShutdownRequested; diff --git a/src/plugins/languageclient/languageclientmanager.h b/src/plugins/languageclient/languageclientmanager.h index 30e8893a46..8b60597dc7 100644 --- a/src/plugins/languageclient/languageclientmanager.h +++ b/src/plugins/languageclient/languageclientmanager.h @@ -42,6 +42,7 @@ public: static Client *startClient(const BaseSettings *setting, ProjectExplorer::Project *project = nullptr); static const QList<Client *> clients(); static void addClient(Client *client); + static void restartClient(Client *client); static void addExclusiveRequest(const LanguageServerProtocol::MessageId &id, Client *client); static void reportFinished(const LanguageServerProtocol::MessageId &id, Client *byClient); @@ -100,6 +101,7 @@ private: QList<Client *> reachableClients(); QList<Client *> m_clients; + QSet<Client *> m_restartingClients; QList<BaseSettings *> m_currentSettings; // owned QMap<QString, QList<Client *>> m_clientsForSetting; QHash<TextEditor::TextDocument *, QPointer<Client>> m_clientForDocument; diff --git a/src/plugins/languageclient/languageclientutils.cpp b/src/plugins/languageclient/languageclientutils.cpp index 4f3966f39c..64ffa4731a 100644 --- a/src/plugins/languageclient/languageclientutils.cpp +++ b/src/plugins/languageclient/languageclientutils.cpp @@ -7,6 +7,7 @@ #include "languageclient_global.h" #include "languageclientmanager.h" #include "languageclientoutline.h" +#include "languageclienttr.h" #include "snippet.h" #include <coreplugin/editormanager/documentmodel.h> @@ -246,7 +247,7 @@ void updateEditorToolBar(Core::IEditor *editor) const QIcon icon = Utils::Icon({{":/languageclient/images/languageclient.png", Utils::Theme::IconsBaseColor}}).icon(); extras->m_popupAction = widget->toolBar()->addAction( - icon, client->name(), [document = QPointer(document)] { + icon, client->name(), [document = QPointer(document), client = QPointer<Client>(client)] { auto menu = new QMenu; auto clientsGroup = new QActionGroup(menu); clientsGroup->setExclusive(true); @@ -265,10 +266,16 @@ void updateEditorToolBar(Core::IEditor *editor) menu->addActions(clientsGroup->actions()); if (!clientsGroup->actions().isEmpty()) menu->addSeparator(); - menu->addAction("Inspect Language Clients", [] { + if (client && client->reachable()) { + menu->addAction(Tr::tr("Restart %1").arg(client->name()), [client] { + if (client && client->reachable()) + LanguageClientManager::restartClient(client); + }); + } + menu->addAction(Tr::tr("Inspect Language Clients"), [] { LanguageClientManager::showInspector(); }); - menu->addAction("Manage...", [] { + menu->addAction(Tr::tr("Manage..."), [] { Core::ICore::showOptionsDialog(Constants::LANGUAGECLIENT_SETTINGS_PAGE); }); menu->popup(QCursor::pos()); |