Commit 1c1a7500 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: add server support for message notifications

parent cc1f7c08
...@@ -278,6 +278,15 @@ struct LSPPublishDiagnosticsParams { ...@@ -278,6 +278,15 @@ struct LSPPublishDiagnosticsParams {
QList<LSPDiagnostic> diagnostics; QList<LSPDiagnostic> diagnostics;
}; };
enum class LSPMessageType { Error = 1, Warning = 2, Info = 3, Log = 4 };
struct LSPShowMessageParams {
LSPMessageType type;
QString message;
};
using LSPLogMessageParams = LSPShowMessageParams;
struct LSPSemanticHighlightingToken { struct LSPSemanticHighlightingToken {
quint32 character = 0; quint32 character = 0;
quint16 length = 0; quint16 length = 0;
......
...@@ -687,6 +687,15 @@ static LSPVersionedTextDocumentIdentifier parseVersionedTextDocumentIdentifier(c ...@@ -687,6 +687,15 @@ static LSPVersionedTextDocumentIdentifier parseVersionedTextDocumentIdentifier(c
return ret; return ret;
} }
static LSPShowMessageParams parseMessage(const QJsonObject &result)
{
LSPShowMessageParams ret;
ret.type = static_cast<LSPMessageType>(result.value(QStringLiteral("type")).toInt());
ret.message = result.value(MEMBER_MESSAGE).toString();
return ret;
}
static LSPSemanticHighlightingParams parseSemanticHighlighting(const QJsonObject &result) static LSPSemanticHighlightingParams parseSemanticHighlighting(const QJsonObject &result)
{ {
LSPSemanticHighlightingParams ret; LSPSemanticHighlightingParams ret;
...@@ -1172,6 +1181,10 @@ public: ...@@ -1172,6 +1181,10 @@ public:
emit q->publishDiagnostics(parseDiagnostics(msg[MEMBER_PARAMS].toObject())); emit q->publishDiagnostics(parseDiagnostics(msg[MEMBER_PARAMS].toObject()));
} else if (method == QLatin1String("textDocument/semanticHighlighting")) { } else if (method == QLatin1String("textDocument/semanticHighlighting")) {
emit q->semanticHighlighting(parseSemanticHighlighting(msg[MEMBER_PARAMS].toObject())); emit q->semanticHighlighting(parseSemanticHighlighting(msg[MEMBER_PARAMS].toObject()));
} else if (method == QLatin1String("window/showMessage")) {
emit q->showMessage(parseMessage(msg[MEMBER_PARAMS].toObject()));
} else if (method == QLatin1String("window/logMessage")) {
emit q->logMessage(parseMessage(msg[MEMBER_PARAMS].toObject()));
} else { } else {
qCWarning(LSPCLIENT) << "discarding notification" << method; qCWarning(LSPCLIENT) << "discarding notification" << method;
} }
......
...@@ -146,6 +146,8 @@ public: ...@@ -146,6 +146,8 @@ public:
// notification = signal // notification = signal
Q_SIGNALS: Q_SIGNALS:
void showMessage(const LSPShowMessageParams &);
void logMessage(const LSPLogMessageParams &);
void publishDiagnostics(const LSPPublishDiagnosticsParams &); void publishDiagnostics(const LSPPublishDiagnosticsParams &);
void semanticHighlighting(const LSPSemanticHighlightingParams &); void semanticHighlighting(const LSPSemanticHighlightingParams &);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment