[gnome-builder] symbol-resolver, rename-provider: add load helper API



commit 685eb13c01d6f7fcb31066de30baabb4d32e72ef
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 28 04:15:53 2016 -0700

    symbol-resolver, rename-provider: add load helper API
    
    This allows us to call a load vfunc after things have been setup and
    not require "constructed" which cannot be accessed by PyGObject.

 libide/buffers/ide-buffer.c                   |   52 +++++++++++++++++++++++++
 libide/rename/ide-rename-provider.c           |    9 ++++
 libide/rename/ide-rename-provider.h           |    3 +
 libide/symbols/ide-symbol-resolver.c          |    9 ++++
 libide/symbols/ide-symbol-resolver.h          |    2 +
 plugins/rust-langserv/rust_langserv_plugin.py |    7 +--
 6 files changed, 77 insertions(+), 5 deletions(-)
---
diff --git a/libide/buffers/ide-buffer.c b/libide/buffers/ide-buffer.c
index 6f25ac2..1b45c70 100644
--- a/libide/buffers/ide-buffer.c
+++ b/libide/buffers/ide-buffer.c
@@ -1031,6 +1031,46 @@ ide_buffer_loaded (IdeBuffer *self)
 }
 
 static void
+ide_buffer_load_rename_provider (IdeBuffer           *self,
+                                 GParamSpec          *pspec,
+                                 IdeExtensionAdapter *adapter)
+{
+  IdeRenameProvider *provider;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_BUFFER (self));
+  g_assert (IDE_IS_EXTENSION_ADAPTER (adapter));
+
+  provider = ide_extension_adapter_get_extension (adapter);
+
+  if (provider != NULL)
+    ide_rename_provider_load (provider);
+
+  IDE_EXIT;
+}
+
+static void
+ide_buffer_load_symbol_resolver (IdeBuffer           *self,
+                                 GParamSpec          *pspec,
+                                 IdeExtensionAdapter *adapter)
+{
+  IdeSymbolResolver *resolver;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_BUFFER (self));
+  g_assert (IDE_IS_EXTENSION_ADAPTER (adapter));
+
+  resolver = ide_extension_adapter_get_extension (adapter);
+
+  if (resolver != NULL)
+    ide_symbol_resolver_load (resolver);
+
+  IDE_EXIT;
+}
+
+static void
 ide_buffer_constructed (GObject *object)
 {
   IdeBuffer *self = (IdeBuffer *)object;
@@ -1120,12 +1160,24 @@ ide_buffer_constructed (GObject *object)
                                                              "Rename-Provider-Languages",
                                                              NULL);
 
+  g_signal_connect_object (priv->rename_provider_adapter,
+                           "notify::extension",
+                           G_CALLBACK (ide_buffer_load_rename_provider),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   priv->symbol_resolver_adapter = ide_extension_adapter_new (priv->context,
                                                              NULL,
                                                              IDE_TYPE_SYMBOL_RESOLVER,
                                                              "Symbol-Resolver-Languages",
                                                              NULL);
 
+  g_signal_connect_object (priv->symbol_resolver_adapter,
+                           "notify::extension",
+                           G_CALLBACK (ide_buffer_load_symbol_resolver),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   g_signal_connect (self,
                     "notify::language",
                     G_CALLBACK (ide_buffer_notify_language),
diff --git a/libide/rename/ide-rename-provider.c b/libide/rename/ide-rename-provider.c
index 67246bb..a197365 100644
--- a/libide/rename/ide-rename-provider.c
+++ b/libide/rename/ide-rename-provider.c
@@ -141,3 +141,12 @@ ide_rename_provider_rename_finish (IdeRenameProvider  *self,
 
   IDE_RETURN (ret);
 }
+
+void
+ide_rename_provider_load (IdeRenameProvider *self)
+{
+  g_return_if_fail (IDE_IS_RENAME_PROVIDER (self));
+
+  if (IDE_RENAME_PROVIDER_GET_IFACE (self)->load)
+    IDE_RENAME_PROVIDER_GET_IFACE (self)->load (self);
+}
diff --git a/libide/rename/ide-rename-provider.h b/libide/rename/ide-rename-provider.h
index 1ebed8b..6c73145 100644
--- a/libide/rename/ide-rename-provider.h
+++ b/libide/rename/ide-rename-provider.h
@@ -46,8 +46,11 @@ struct _IdeRenameProviderInterface
   /* Silence Vala */
   void     (*set_context)   (IdeRenameProvider    *self,
                              IdeContext           *context);
+
+  void     (*load)          (IdeRenameProvider    *self);
 };
 
+void      ide_rename_provider_load          (IdeRenameProvider     *self);
 void      ide_rename_provider_rename_async  (IdeRenameProvider     *self,
                                              IdeSourceLocation     *location,
                                              const gchar           *new_name,
diff --git a/libide/symbols/ide-symbol-resolver.c b/libide/symbols/ide-symbol-resolver.c
index 5d6ea9a..986dd32 100644
--- a/libide/symbols/ide-symbol-resolver.c
+++ b/libide/symbols/ide-symbol-resolver.c
@@ -159,3 +159,12 @@ ide_symbol_resolver_get_symbol_tree_finish (IdeSymbolResolver  *self,
 
   return IDE_SYMBOL_RESOLVER_GET_IFACE (self)->get_symbol_tree_finish (self, result, error);
 }
+
+void
+ide_symbol_resolver_load (IdeSymbolResolver *self)
+{
+  g_return_if_fail (IDE_IS_SYMBOL_RESOLVER (self));
+
+  if (IDE_SYMBOL_RESOLVER_GET_IFACE (self)->load)
+    IDE_SYMBOL_RESOLVER_GET_IFACE (self)->load (self);
+}
diff --git a/libide/symbols/ide-symbol-resolver.h b/libide/symbols/ide-symbol-resolver.h
index 83052f9..edac98b 100644
--- a/libide/symbols/ide-symbol-resolver.h
+++ b/libide/symbols/ide-symbol-resolver.h
@@ -50,8 +50,10 @@ struct _IdeSymbolResolverInterface
   IdeSymbolTree *(*get_symbol_tree_finish) (IdeSymbolResolver    *self,
                                             GAsyncResult         *result,
                                             GError              **error);
+  void           (*load)                   (IdeSymbolResolver    *self);
 };
 
+void           ide_symbol_resolver_load                   (IdeSymbolResolver    *self);
 void           ide_symbol_resolver_lookup_symbol_async    (IdeSymbolResolver    *self,
                                                            IdeSourceLocation    *location,
                                                            GCancellable         *cancellable,
diff --git a/plugins/rust-langserv/rust_langserv_plugin.py b/plugins/rust-langserv/rust_langserv_plugin.py
index f2bbb75..9b24ed6 100644
--- a/plugins/rust-langserv/rust_langserv_plugin.py
+++ b/plugins/rust-langserv/rust_langserv_plugin.py
@@ -147,12 +147,9 @@ class RustCompletionProvider(Ide.LangservCompletionProvider):
         RustService.bind_client(self)
 
 class RustRenameProvider(Ide.LangservRenameProvider):
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
+    def do_load(self):
         RustService.bind_client(self)
 
 class RustSymbolResolver(Ide.LangservSymbolResolver):
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
+    def do_load(self):
         RustService.bind_client(self)
-


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