2018-07-13 12:33:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2018 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|