2020-02-20 10:13:14 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2019 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
|
|
|
|
|
|
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
|