2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2018-07-13 12:33:46 +02:00
|
|
|
|
|
|
|
|
#include "languageclientplugin.h"
|
|
|
|
|
|
2021-04-19 11:00:37 +02:00
|
|
|
#include "client.h"
|
2019-03-27 14:05:30 +01:00
|
|
|
#include "languageclientmanager.h"
|
|
|
|
|
|
2021-04-19 11:00:37 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QMenu>
|
2018-09-13 15:31:00 +02:00
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
2019-03-27 14:05:30 +01:00
|
|
|
static LanguageClientPlugin *m_instance = nullptr;
|
|
|
|
|
|
|
|
|
|
LanguageClientPlugin::LanguageClientPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
2022-05-11 14:01:49 +02:00
|
|
|
qRegisterMetaType<LanguageServerProtocol::JsonRpcMessage>();
|
2019-03-27 14:05:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LanguageClientPlugin::~LanguageClientPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_instance = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LanguageClientPlugin *LanguageClientPlugin::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
bool LanguageClientPlugin::initialize(const QStringList & /*arguments*/, QString * /*errorString*/)
|
|
|
|
|
{
|
2021-04-19 11:00:37 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
|
2019-03-27 14:05:30 +01:00
|
|
|
LanguageClientManager::init();
|
2021-02-08 11:24:28 +01:00
|
|
|
LanguageClientSettings::registerClientType({Constants::LANGUAGECLIENT_STDIO_SETTINGS_ID,
|
|
|
|
|
tr("Generic StdIO Language Server"),
|
|
|
|
|
[]() { return new StdIOSettings; }});
|
2021-04-19 11:00:37 +02:00
|
|
|
|
|
|
|
|
//register actions
|
2022-01-24 17:06:54 +01:00
|
|
|
ActionContainer *toolsDebugContainer = ActionManager::actionContainer(
|
|
|
|
|
Core::Constants::M_TOOLS_DEBUG);
|
|
|
|
|
|
|
|
|
|
auto inspectAction = new QAction(tr("Inspect Language Clients..."), this);
|
2021-04-19 11:00:37 +02:00
|
|
|
connect(inspectAction, &QAction::triggered, this, &LanguageClientManager::showInspector);
|
2022-01-24 17:06:54 +01:00
|
|
|
toolsDebugContainer->addAction(
|
2021-04-19 11:00:37 +02:00
|
|
|
ActionManager::registerAction(inspectAction, "LanguageClient.InspectLanguageClients"));
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LanguageClientPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
LanguageClientSettings::init();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:31:00 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag LanguageClientPlugin::aboutToShutdown()
|
|
|
|
|
{
|
|
|
|
|
LanguageClientManager::shutdown();
|
|
|
|
|
if (LanguageClientManager::clients().isEmpty())
|
|
|
|
|
return ExtensionSystem::IPlugin::SynchronousShutdown;
|
2019-03-27 14:05:30 +01:00
|
|
|
QTC_ASSERT(LanguageClientManager::instance(),
|
|
|
|
|
return ExtensionSystem::IPlugin::SynchronousShutdown);
|
2018-09-13 15:31:00 +02:00
|
|
|
connect(LanguageClientManager::instance(), &LanguageClientManager::shutdownFinished,
|
2022-04-04 17:27:49 +02:00
|
|
|
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished, Qt::QueuedConnection);
|
2018-09-13 15:31:00 +02:00
|
|
|
return ExtensionSystem::IPlugin::AsynchronousShutdown;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
} // namespace LanguageClient
|