2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-02-20 10:13:14 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-02-11 09:32:11 +01:00
|
|
|
#include "dynamiccapabilities.h"
|
|
|
|
|
|
2020-02-20 10:13:14 +01:00
|
|
|
#include <QTime>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
#include <languageserverprotocol/basemessage.h>
|
2021-02-11 09:32:11 +01:00
|
|
|
#include <languageserverprotocol/servercapabilities.h>
|
2020-02-20 10:13:14 +01:00
|
|
|
|
2020-06-18 13:29:52 +02:00
|
|
|
#include <list>
|
|
|
|
|
|
2020-02-20 10:13:14 +01:00
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
2021-07-13 11:00:14 +02:00
|
|
|
class LspLogMessage
|
2020-02-20 10:13:14 +01:00
|
|
|
{
|
2021-07-13 11:00:14 +02:00
|
|
|
public:
|
2021-08-09 10:29:36 +02:00
|
|
|
enum MessageSender { ClientMessage, ServerMessage } sender = ClientMessage;
|
2021-07-13 11:00:14 +02:00
|
|
|
|
|
|
|
|
LspLogMessage();
|
|
|
|
|
LspLogMessage(MessageSender sender,
|
|
|
|
|
const QTime &time,
|
2022-05-10 11:40:56 +02:00
|
|
|
const LanguageServerProtocol::JsonRpcMessage &message);
|
2020-02-20 10:13:14 +01:00
|
|
|
QTime time;
|
2022-05-10 11:40:56 +02:00
|
|
|
LanguageServerProtocol::JsonRpcMessage message;
|
2021-07-13 11:00:14 +02:00
|
|
|
|
|
|
|
|
LanguageServerProtocol::MessageId id() const;
|
|
|
|
|
QString displayText() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
mutable Utils::optional<LanguageServerProtocol::MessageId> m_id;
|
|
|
|
|
mutable Utils::optional<QString> m_displayText;
|
2020-02-20 10:13:14 +01:00
|
|
|
};
|
|
|
|
|
|
2021-02-11 09:32:11 +01:00
|
|
|
struct Capabilities
|
|
|
|
|
{
|
|
|
|
|
LanguageServerProtocol::ServerCapabilities capabilities;
|
|
|
|
|
DynamicCapabilities dynamicCapabilities;
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-10 14:03:45 +01:00
|
|
|
class LspInspector : public QObject
|
2020-02-20 10:13:14 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2021-02-10 14:03:45 +01:00
|
|
|
LspInspector() {}
|
2020-02-20 10:13:14 +01:00
|
|
|
|
2021-02-11 09:54:09 +01:00
|
|
|
QWidget *createWidget(const QString &defaultClient = {});
|
2020-02-20 10:13:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void log(const LspLogMessage::MessageSender sender,
|
|
|
|
|
const QString &clientName,
|
2022-05-10 11:40:56 +02:00
|
|
|
const LanguageServerProtocol::JsonRpcMessage &message);
|
2021-02-11 09:32:11 +01:00
|
|
|
void clientInitialized(const QString &clientName,
|
|
|
|
|
const LanguageServerProtocol::ServerCapabilities &capabilities);
|
|
|
|
|
void updateCapabilities(const QString &clientName,
|
|
|
|
|
const DynamicCapabilities &dynamicCapabilities);
|
2020-02-20 10:13:14 +01:00
|
|
|
|
2020-06-18 13:29:52 +02:00
|
|
|
std::list<LspLogMessage> messages(const QString &clientName) const;
|
2021-02-11 09:32:11 +01:00
|
|
|
Capabilities capabilities(const QString &clientName) const;
|
2020-02-20 10:13:14 +01:00
|
|
|
QList<QString> clients() const;
|
2021-09-09 15:46:08 +02:00
|
|
|
void clear() { m_logs.clear(); }
|
2020-02-20 10:13:14 +01:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void newMessage(const QString &clientName, const LspLogMessage &message);
|
2021-02-11 09:32:11 +01:00
|
|
|
void capabilitiesUpdated(const QString &clientName);
|
2020-02-20 10:13:14 +01:00
|
|
|
|
|
|
|
|
private:
|
2020-06-18 13:29:52 +02:00
|
|
|
QMap<QString, std::list<LspLogMessage>> m_logs;
|
2021-02-11 09:32:11 +01:00
|
|
|
QMap<QString, Capabilities> m_capabilities;
|
2020-02-20 10:13:14 +01:00
|
|
|
int m_logSize = 100; // default log size if no widget is currently visible
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace LanguageClient
|