[gnome-builder] completion: add IdeCompletionProvider::load



commit b757b7c00fa9a426cb73e3663b6e711cbfe014c9
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 28 04:07:11 2016 -0700

    completion: add IdeCompletionProvider::load
    
    This allows us to cleanup our loading of completion providers to after
    the context has been set.

 libide/sourceview/ide-completion-provider.c   |    9 +++++++++
 libide/sourceview/ide-completion-provider.h   |   11 +++++++----
 libide/sourceview/ide-source-view.c           |    2 ++
 plugins/rust-langserv/rust_langserv_plugin.py |    3 +--
 4 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/libide/sourceview/ide-completion-provider.c b/libide/sourceview/ide-completion-provider.c
index a84dc12..9b17993 100644
--- a/libide/sourceview/ide-completion-provider.c
+++ b/libide/sourceview/ide-completion-provider.c
@@ -113,3 +113,12 @@ ide_completion_provider_context_current_word (GtkSourceCompletionContext *contex
 
   return gtk_text_iter_get_slice (&begin, &end);
 }
+
+void
+ide_completion_provider_load (IdeCompletionProvider *self)
+{
+  g_return_if_fail (IDE_IS_COMPLETION_PROVIDER (self));
+
+  if (IDE_COMPLETION_PROVIDER_GET_IFACE (self)->load)
+    IDE_COMPLETION_PROVIDER_GET_IFACE (self)->load (self);
+}
diff --git a/libide/sourceview/ide-completion-provider.h b/libide/sourceview/ide-completion-provider.h
index a5e5841..2818830 100644
--- a/libide/sourceview/ide-completion-provider.h
+++ b/libide/sourceview/ide-completion-provider.h
@@ -25,10 +25,10 @@
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_COMPLETION_PROVIDER             (ide_completion_provider_get_type())
-#define IDE_COMPLETION_PROVIDER(o)               (G_TYPE_CHECK_INSTANCE_CAST((o),    
IDE_TYPE_COMPLETION_PROVIDER, IdeCompletionProvider))
-#define IDE_IS_COMPLETION_PROVIDER(o)            (G_TYPE_CHECK_INSTANCE_TYPE((o),    
IDE_TYPE_COMPLETION_PROVIDER))
-#define IDE_COMPLETION_PROVIDER_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), 
IDE_TYPE_COMPLETION_PROVIDER, IdeCompletionProviderIface))
+#define IDE_TYPE_COMPLETION_PROVIDER         (ide_completion_provider_get_type())
+#define IDE_COMPLETION_PROVIDER(o)           (G_TYPE_CHECK_INSTANCE_CAST((o),    
IDE_TYPE_COMPLETION_PROVIDER, IdeCompletionProvider))
+#define IDE_IS_COMPLETION_PROVIDER(o)        (G_TYPE_CHECK_INSTANCE_TYPE((o),    
IDE_TYPE_COMPLETION_PROVIDER))
+#define IDE_COMPLETION_PROVIDER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), 
IDE_TYPE_COMPLETION_PROVIDER, IdeCompletionProviderInterface))
 
 typedef struct _IdeCompletionProvider          IdeCompletionProvider;
 typedef struct _IdeCompletionProviderInterface IdeCompletionProviderInterface;
@@ -40,12 +40,15 @@ struct _IdeCompletionProviderInterface
   /* Pacify Vala */
   void (*set_context) (IdeCompletionProvider *self,
                        IdeContext            *context);
+
+  void (*load)        (IdeCompletionProvider *self);
 };
 
 GType     ide_completion_provider_get_type                     (void);
 gboolean  ide_completion_provider_context_in_comment           (GtkSourceCompletionContext *context);
 gboolean  ide_completion_provider_context_in_comment_or_string (GtkSourceCompletionContext *context);
 gchar    *ide_completion_provider_context_current_word         (GtkSourceCompletionContext *context);
+void      ide_completion_provider_load                         (IdeCompletionProvider      *self);
 
 G_END_DECLS
 
diff --git a/libide/sourceview/ide-source-view.c b/libide/sourceview/ide-source-view.c
index 9066022..dec5feb 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -1405,6 +1405,8 @@ ide_source_view__completion_provider_added (IdeExtensionSetAdapter *adapter,
   gtk_source_completion_add_provider (completion,
                                       GTK_SOURCE_COMPLETION_PROVIDER (extension),
                                       NULL);
+
+  ide_completion_provider_load (IDE_COMPLETION_PROVIDER (extension));
 }
 
 static void
diff --git a/plugins/rust-langserv/rust_langserv_plugin.py b/plugins/rust-langserv/rust_langserv_plugin.py
index e5dcf0b..f2bbb75 100644
--- a/plugins/rust-langserv/rust_langserv_plugin.py
+++ b/plugins/rust-langserv/rust_langserv_plugin.py
@@ -143,8 +143,7 @@ class RustDiagnosticProvider(Ide.LangservDiagnosticProvider):
         RustService.bind_client(self)
 
 class RustCompletionProvider(Ide.LangservCompletionProvider):
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
+    def do_load(self):
         RustService.bind_client(self)
 
 class RustRenameProvider(Ide.LangservRenameProvider):


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