2023-01-20 07:09:01 +01:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#include "copilotplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "copilotclient.h"
|
|
|
|
|
#include "copilotoptionspage.h"
|
|
|
|
|
#include "copilotsettings.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2023-03-02 13:56:11 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
|
2023-03-09 11:08:57 +01:00
|
|
|
#include <languageclient/languageclientmanager.h>
|
|
|
|
|
|
2023-03-02 13:56:11 +01:00
|
|
|
#include <texteditor/texteditor.h>
|
2023-01-20 07:09:01 +01:00
|
|
|
|
|
|
|
|
using namespace Utils;
|
2023-03-02 13:56:11 +01:00
|
|
|
using namespace Core;
|
2023-01-20 07:09:01 +01:00
|
|
|
|
|
|
|
|
namespace Copilot {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
void CopilotPlugin::initialize()
|
|
|
|
|
{
|
2023-03-02 13:56:11 +01:00
|
|
|
CopilotSettings::instance().readSettings(ICore::settings());
|
2023-01-20 07:09:01 +01:00
|
|
|
|
2023-03-09 11:08:57 +01:00
|
|
|
restartClient();
|
2023-01-20 07:09:01 +01:00
|
|
|
|
2023-03-09 11:08:57 +01:00
|
|
|
connect(&CopilotSettings::instance(),
|
|
|
|
|
&CopilotSettings::applied,
|
|
|
|
|
this,
|
|
|
|
|
&CopilotPlugin::restartClient);
|
2023-01-20 07:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CopilotPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
CopilotOptionsPage::instance().init();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 11:08:57 +01:00
|
|
|
void CopilotPlugin::restartClient()
|
|
|
|
|
{
|
|
|
|
|
LanguageClient::LanguageClientManager::shutdownClient(m_client);
|
|
|
|
|
m_client = new CopilotClient(CopilotSettings::instance().nodeJsPath.filePath(),
|
|
|
|
|
CopilotSettings::instance().distPath.filePath());
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 07:09:01 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Copilot
|