Commit 3cb9173c authored by Günther Wagner's avatar Günther Wagner Committed by Christian Hergert

Show progress information from LSP

parent a0b55f4f
......@@ -26,6 +26,7 @@
#include <gio/gunixoutputstream.h>
#include <glib-unix.h>
#include <libide-core.h>
#include <jsonrpc-glib.h>
struct _RustAnalyzerService
{
......@@ -163,6 +164,54 @@ rust_analyzer_service_set_client (RustAnalyzerService *self,
}
}
static void
_handle_notification (IdeLspClient *client,
gchar *method,
GVariant *params)
{
g_autoptr(IdeNotification) notification = NULL;
IdeNotifications *notifications = NULL;
IdeContext *context = NULL;
const gchar *message = NULL;
const gchar *token = NULL;
const gchar *kind = NULL;
if (!ide_str_equal0 (method, "$/progress"))
return;
JSONRPC_MESSAGE_PARSE (params, "token", JSONRPC_MESSAGE_GET_STRING (&token));
if (!ide_str_equal0 (token, "rustAnalyzer/startup"))
return;
JSONRPC_MESSAGE_PARSE (params, "value", "{", "kind", JSONRPC_MESSAGE_GET_STRING (&kind), "message", JSONRPC_MESSAGE_GET_STRING (&message), "}");
context = ide_object_get_context (IDE_OBJECT (client));
notifications = ide_object_get_child_typed (IDE_OBJECT (context), IDE_TYPE_NOTIFICATIONS);
notification = ide_notifications_find_by_id (notifications, "org.gnome-builder.rust-analyzer.startup");
if (notification == NULL)
{
notification = ide_notification_new ();
ide_notification_set_id (notification, "org.gnome-builder.rust-analyzer.startup");
ide_notification_set_title (notification, message);
ide_notification_set_has_progress (notification, TRUE);
ide_notification_set_progress_is_imprecise (notification, TRUE);
ide_notification_set_icon_name (notification, "system-run-symbolic");
ide_notification_attach (notification, IDE_OBJECT (context));
}
else
{
ide_notification_set_title (notification, message);
if (ide_str_equal0 (kind, "end"))
{
ide_notification_set_has_progress (notification, FALSE);
ide_notification_set_icon_name (notification, NULL);
ide_notification_withdraw_in_seconds (notification, 3);
}
}
}
void
rust_analyzer_service_lsp_started (IdeSubprocessSupervisor *supervisor,
IdeSubprocess *subprocess,
......@@ -186,6 +235,7 @@ rust_analyzer_service_lsp_started (IdeSubprocessSupervisor *supervisor,
}
client = ide_lsp_client_new (io_stream);
g_signal_connect (client, "notification", G_CALLBACK (_handle_notification), NULL);
rust_analyzer_service_set_client (self, client);
ide_object_append (IDE_OBJECT (self), IDE_OBJECT (client));
ide_lsp_client_add_language (client, "rust");
......
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