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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-01-31 12:15:43 +01:00
|
|
|
#include "client.h"
|
2019-09-18 14:43:08 +02:00
|
|
|
#include "languageclient_global.h"
|
2018-09-10 15:15:37 +02:00
|
|
|
#include "languageclientsettings.h"
|
2019-04-05 10:05:25 +02:00
|
|
|
#include "locatorfilter.h"
|
2018-07-13 12:33:46 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/id.h>
|
|
|
|
|
|
|
|
|
|
#include <languageserverprotocol/diagnostics.h>
|
|
|
|
|
#include <languageserverprotocol/languagefeatures.h>
|
|
|
|
|
#include <languageserverprotocol/textsynchronization.h>
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
class IEditor;
|
|
|
|
|
class IDocument;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer { class Project; }
|
|
|
|
|
|
|
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
|
|
|
|
class LanguageClientMark;
|
|
|
|
|
|
2019-09-18 14:43:08 +02:00
|
|
|
class LANGUAGECLIENT_EXPORT LanguageClientManager : public QObject
|
2018-07-13 12:33:46 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2018-11-14 01:21:20 +01:00
|
|
|
LanguageClientManager(const LanguageClientManager &other) = delete;
|
|
|
|
|
LanguageClientManager(LanguageClientManager &&other) = delete;
|
2018-07-13 12:33:46 +02:00
|
|
|
~LanguageClientManager() override;
|
|
|
|
|
|
|
|
|
|
static void init();
|
|
|
|
|
|
2019-01-31 12:15:43 +01:00
|
|
|
static void startClient(Client *client);
|
2019-07-24 13:40:12 +02:00
|
|
|
static Client *startClient(BaseSettings *setting, ProjectExplorer::Project *project = nullptr);
|
2019-01-31 12:15:43 +01:00
|
|
|
static QVector<Client *> clients();
|
2018-07-13 12:33:46 +02:00
|
|
|
|
2019-01-31 12:15:43 +01:00
|
|
|
static void addExclusiveRequest(const LanguageServerProtocol::MessageId &id, Client *client);
|
|
|
|
|
static void reportFinished(const LanguageServerProtocol::MessageId &id, Client *byClient);
|
2018-07-13 12:33:46 +02:00
|
|
|
|
2019-05-09 09:13:54 +02:00
|
|
|
static void shutdownClient(Client *client);
|
2019-01-31 12:15:43 +01:00
|
|
|
static void deleteClient(Client *client);
|
2018-09-13 13:39:01 +02:00
|
|
|
|
2018-09-13 15:31:00 +02:00
|
|
|
static void shutdown();
|
|
|
|
|
|
|
|
|
|
static LanguageClientManager *instance();
|
|
|
|
|
|
2019-09-11 11:15:39 +02:00
|
|
|
static QList<Client *> clientsSupportingDocument(const TextEditor::TextDocument *doc);
|
2018-11-23 09:45:51 +01:00
|
|
|
|
2019-03-27 15:09:08 +01:00
|
|
|
static void applySettings();
|
|
|
|
|
static QList<BaseSettings *> currentSettings();
|
2019-09-18 14:50:42 +02:00
|
|
|
static void registerClientSettings(BaseSettings *settings);
|
2019-10-17 10:03:57 +02:00
|
|
|
static void enableClientSettings(const QString &settingsId);
|
2019-05-09 09:13:54 +02:00
|
|
|
static QVector<Client *> clientForSetting(const BaseSettings *setting);
|
2019-03-15 11:25:48 +01:00
|
|
|
static const BaseSettings *settingForClient(Client *setting);
|
2019-09-11 11:15:39 +02:00
|
|
|
static Client *clientForDocument(TextEditor::TextDocument *document);
|
2019-09-10 08:03:58 +02:00
|
|
|
static Client *clientForFilePath(const Utils::FilePath &filePath);
|
|
|
|
|
static Client *clientForUri(const LanguageServerProtocol::DocumentUri &uri);
|
|
|
|
|
static void reOpenDocumentWithClient(TextEditor::TextDocument *document, Client *client);
|
2019-03-27 15:09:08 +01:00
|
|
|
|
2018-09-13 15:31:00 +02:00
|
|
|
signals:
|
|
|
|
|
void shutdownFinished();
|
|
|
|
|
|
2018-07-13 12:33:46 +02:00
|
|
|
private:
|
2019-03-27 14:05:30 +01:00
|
|
|
LanguageClientManager(QObject *parent);
|
2018-07-13 12:33:46 +02:00
|
|
|
|
2019-03-12 12:53:13 +01:00
|
|
|
void editorOpened(Core::IEditor *editor);
|
2019-03-12 12:46:38 +01:00
|
|
|
void documentOpened(Core::IDocument *document);
|
2019-09-10 08:03:58 +02:00
|
|
|
void openDocumentWithClient(TextEditor::TextDocument *document, Client *client);
|
2019-03-12 12:46:38 +01:00
|
|
|
void documentClosed(Core::IDocument *document);
|
2018-07-13 12:33:46 +02:00
|
|
|
void documentContentsSaved(Core::IDocument *document);
|
|
|
|
|
void documentWillSave(Core::IDocument *document);
|
2019-09-10 08:03:58 +02:00
|
|
|
void findLinkAt(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
2019-01-21 14:28:13 +01:00
|
|
|
Utils::ProcessLinkCallback callback, const bool resolveTarget);
|
2019-09-10 08:03:58 +02:00
|
|
|
void findUsages(TextEditor::TextDocument *document, const QTextCursor &cursor);
|
2018-07-13 12:33:46 +02:00
|
|
|
|
|
|
|
|
void projectAdded(ProjectExplorer::Project *project);
|
|
|
|
|
void projectRemoved(ProjectExplorer::Project *project);
|
|
|
|
|
|
2019-01-31 12:15:43 +01:00
|
|
|
QVector<Client *> reachableClients();
|
2018-07-13 12:33:46 +02:00
|
|
|
void sendToAllReachableServers(const LanguageServerProtocol::IContent &content);
|
|
|
|
|
|
2019-01-31 12:15:43 +01:00
|
|
|
void clientFinished(Client *client);
|
2018-07-13 12:33:46 +02:00
|
|
|
|
2018-09-13 15:31:00 +02:00
|
|
|
bool m_shuttingDown = false;
|
2019-01-31 12:15:43 +01:00
|
|
|
QVector<Client *> m_clients;
|
2019-03-27 15:09:08 +01:00
|
|
|
QList<BaseSettings *> m_currentSettings; // owned
|
2019-05-09 09:13:54 +02:00
|
|
|
QMap<QString, QVector<Client *>> m_clientsForSetting;
|
2019-09-11 11:15:39 +02:00
|
|
|
QHash<TextEditor::TextDocument *, QPointer<Client>> m_clientForDocument;
|
2019-01-31 12:15:43 +01:00
|
|
|
QHash<LanguageServerProtocol::MessageId, QList<Client *>> m_exclusiveRequests;
|
2019-04-05 10:05:25 +02:00
|
|
|
DocumentLocatorFilter m_currentDocumentLocatorFilter;
|
2019-04-30 11:05:43 +02:00
|
|
|
WorkspaceLocatorFilter m_workspaceLocatorFilter;
|
|
|
|
|
WorkspaceClassLocatorFilter m_workspaceClassLocatorFilter;
|
|
|
|
|
WorkspaceMethodLocatorFilter m_workspaceMethodLocatorFilter;
|
2018-07-13 12:33:46 +02:00
|
|
|
};
|
|
|
|
|
} // namespace LanguageClient
|