2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 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"
|
2023-08-22 15:28:19 +02:00
|
|
|
#include "languageclientsettings.h"
|
2023-01-19 18:16:35 +01:00
|
|
|
#include "languageclienttr.h"
|
2019-03-27 14:05:30 +01:00
|
|
|
|
2021-04-19 11:00:37 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
|
2023-08-22 15:28:19 +02:00
|
|
|
#include <projectexplorer/projectpanelfactory.h>
|
|
|
|
|
|
2021-04-19 11:00:37 +02:00
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:28:36 +01:00
|
|
|
void LanguageClientPlugin::initialize()
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
2021-04-19 11:00:37 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
|
2023-08-22 15:28:19 +02:00
|
|
|
auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
|
|
|
|
|
panelFactory->setPriority(35);
|
|
|
|
|
panelFactory->setDisplayName(Tr::tr("Language Server"));
|
|
|
|
|
panelFactory->setCreateWidgetFunction(
|
|
|
|
|
[](ProjectExplorer::Project *project) { return new ProjectSettingsWidget(project); });
|
|
|
|
|
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
|
|
|
|
|
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,
|
2023-01-19 18:16:35 +01:00
|
|
|
Tr::tr("Generic StdIO Language Server"),
|
2021-02-08 11:24:28 +01:00
|
|
|
[]() { 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);
|
|
|
|
|
|
2023-01-19 18:16:35 +01:00
|
|
|
auto inspectAction = new QAction(Tr::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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LanguageClientPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
LanguageClientSettings::init();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:31:00 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag LanguageClientPlugin::aboutToShutdown()
|
|
|
|
|
{
|
|
|
|
|
LanguageClientManager::shutdown();
|
2023-05-23 11:02:15 +02:00
|
|
|
if (LanguageClientManager::isShutdownFinished())
|
2018-09-13 15:31:00 +02:00
|
|
|
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,
|
2023-05-23 11:02:15 +02:00
|
|
|
this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished);
|
2018-09-13 15:31:00 +02:00
|
|
|
return ExtensionSystem::IPlugin::AsynchronousShutdown;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
} // namespace LanguageClient
|