[gnome-builder] langserv: propagate file changes



commit 196e5c15b5d7e69d2f7d04c37f6f058c29cce3a0
Author: Christian Hergert <chergert redhat com>
Date:   Sun Oct 23 21:17:42 2016 -0700

    langserv: propagate file changes
    
    This notifies the Language Server that we have changed the file on disk.

 libide/langserv/ide-langserv-client.c |   53 ++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/libide/langserv/ide-langserv-client.c b/libide/langserv/ide-langserv-client.c
index 1bf6188..ae0f289 100644
--- a/libide/langserv/ide-langserv-client.c
+++ b/libide/langserv/ide-langserv-client.c
@@ -81,12 +81,50 @@ ide_langserv_client_clear_diagnostics (IdeLangservClient *self,
   IdeLangservClientPrivate *priv = ide_langserv_client_get_instance_private (self);
   g_autoptr(GFile) file = NULL;
 
+  IDE_ENTRY;
+
   g_assert (IDE_IS_LANGSERV_CLIENT (self));
   g_assert (uri != NULL);
 
-  file = g_file_new_for_uri (uri);
+  IDE_TRACE_MSG ("Clearing diagnostics for %s", uri);
 
+  file = g_file_new_for_uri (uri);
   g_hash_table_remove (priv->diagnostics_by_file, file);
+
+  IDE_EXIT;
+}
+
+static void
+ide_langserv_client_buffer_saved (IdeLangservClient *self,
+                                  IdeBuffer         *buffer,
+                                  IdeBufferManager  *buffer_manager)
+{
+  g_autoptr(JsonNode) params = NULL;
+  g_autofree gchar *uri = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_LANGSERV_CLIENT (self));
+  g_assert (IDE_IS_BUFFER (buffer));
+  g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
+
+  uri = ide_buffer_get_uri (buffer);
+
+  params = JCON_NEW (
+    "changes", "[",
+      "{",
+        "uri", JCON_STRING (uri),
+        "type", JCON_INT (FILE_CHANGE_TYPE_CHANGED),
+      "}",
+    "]"
+  );
+
+  ide_langserv_client_notification_async (self,
+                                          "workspace/didChangeWatchedFiles",
+                                          g_steal_pointer (&params),
+                                          NULL, NULL, NULL);
+
+  IDE_EXIT;
 }
 
 static void
@@ -98,6 +136,8 @@ ide_langserv_client_buffer_loaded (IdeLangservClient *self,
   g_autoptr(JsonNode) params = NULL;
   g_autofree gchar *uri = NULL;
 
+  IDE_ENTRY;
+
   g_assert (IDE_IS_LANGSERV_CLIENT (self));
   g_assert (IDE_IS_BUFFER (buffer));
   g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
@@ -114,6 +154,8 @@ ide_langserv_client_buffer_loaded (IdeLangservClient *self,
                                      "textDocument/didOpen",
                                      g_steal_pointer (&params),
                                      NULL, NULL, NULL);
+
+  IDE_EXIT;
 }
 
 static void
@@ -125,6 +167,8 @@ ide_langserv_client_buffer_unloaded (IdeLangservClient *self,
   g_autoptr(JsonNode) params = NULL;
   g_autofree gchar *uri = NULL;
 
+  IDE_ENTRY;
+
   g_assert (IDE_IS_LANGSERV_CLIENT (self));
   g_assert (IDE_IS_BUFFER (buffer));
   g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
@@ -141,6 +185,8 @@ ide_langserv_client_buffer_unloaded (IdeLangservClient *self,
                                      "textDocument/didClose",
                                      g_steal_pointer (&params),
                                      NULL, NULL, NULL);
+
+  IDE_EXIT;
 }
 
 static void
@@ -536,6 +582,11 @@ ide_langserv_client_init (IdeLangservClient *self)
                                    self,
                                    G_CONNECT_SWAPPED);
   egg_signal_group_connect_object (priv->buffer_manager_signals,
+                                   "buffer-saved",
+                                   G_CALLBACK (ide_langserv_client_buffer_saved),
+                                   self,
+                                   G_CONNECT_SWAPPED);
+  egg_signal_group_connect_object (priv->buffer_manager_signals,
                                    "buffer-unloaded",
                                    G_CALLBACK (ide_langserv_client_buffer_unloaded),
                                    self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]