[gnome-builder] buffer: add helper to get rename provider



commit b3e38e8e3c45604d3f15cdba9cefcb0a425284f3
Author: Christian Hergert <chergert redhat com>
Date:   Tue Oct 25 23:00:11 2016 -0700

    buffer: add helper to get rename provider

 libide/buffers/ide-buffer.c |   36 +++++++++++++++++++++++++++++++++++-
 libide/buffers/ide-buffer.h |    1 +
 2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/libide/buffers/ide-buffer.c b/libide/buffers/ide-buffer.c
index 85b664a..79c73a2 100644
--- a/libide/buffers/ide-buffer.c
+++ b/libide/buffers/ide-buffer.c
@@ -39,6 +39,7 @@
 #include "highlighting/ide-highlight-engine.h"
 #include "highlighting/ide-highlighter.h"
 #include "plugins/ide-extension-adapter.h"
+#include "rename/ide-rename-provider.h"
 #include "sourceview/ide-source-iter.h"
 #include "sourceview/ide-source-style-scheme.h"
 #include "symbols/ide-symbol-resolver.h"
@@ -74,6 +75,7 @@ typedef struct
   IdeBufferChangeMonitor *change_monitor;
   IdeDiagnostician       *diagnostician;
   IdeHighlightEngine     *highlight_engine;
+  IdeExtensionAdapter    *rename_provider_adapter;
   IdeExtensionAdapter    *symbol_resolver_adapter;
   gchar                  *title;
 
@@ -985,7 +987,10 @@ ide_buffer_notify_language (IdeBuffer  *self,
   if ((language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (self))))
     lang_id = gtk_source_language_get_id (language);
 
-  if (priv->symbol_resolver_adapter)
+  if (priv->rename_provider_adapter != NULL)
+    ide_extension_adapter_set_value (priv->rename_provider_adapter, lang_id);
+
+  if (priv->symbol_resolver_adapter != NULL)
     ide_extension_adapter_set_value (priv->symbol_resolver_adapter, lang_id);
 
   ide_diagnostician_set_language (priv->diagnostician, language);
@@ -1227,6 +1232,12 @@ ide_buffer_constructed (GObject *object)
 
   priv->highlight_engine = ide_highlight_engine_new (self);
 
+  priv->rename_provider_adapter = ide_extension_adapter_new (priv->context,
+                                                             NULL,
+                                                             IDE_TYPE_RENAME_PROVIDER,
+                                                             "Rename-Provider-Languages",
+                                                             NULL);
+
   priv->symbol_resolver_adapter = ide_extension_adapter_new (priv->context,
                                                              NULL,
                                                              IDE_TYPE_SYMBOL_RESOLVER,
@@ -1294,6 +1305,7 @@ ide_buffer_dispose (GObject *object)
   g_clear_object (&priv->diagnostician);
   g_clear_object (&priv->file);
   g_clear_object (&priv->highlight_engine);
+  g_clear_object (&priv->rename_provider_adapter);
   g_clear_object (&priv->symbol_resolver_adapter);
 
   if (priv->context != NULL)
@@ -2540,6 +2552,7 @@ ide_buffer_reclaim_timeout (gpointer data)
 
   priv->reclamation_handler = 0;
 
+  g_clear_object (&priv->rename_provider_adapter);
   g_clear_object (&priv->symbol_resolver_adapter);
 
   buffer_manager = ide_context_get_buffer_manager (priv->context);
@@ -2638,6 +2651,27 @@ ide_buffer_get_selection_bounds (IdeBuffer   *self,
 }
 
 /**
+ * ide_buffer_get_rename_provider:
+ *
+ * Gets the #IdeRenameProvider for this buffer, or %NULL.
+ *
+ * Returns: (nullable) (transfer none): An #IdeRenameProvider or %NULL if there
+ *   is no #IdeRenameProvider that can statisfy the buffer.
+ */
+IdeRenameProvider *
+ide_buffer_get_rename_provider (IdeBuffer *self)
+{
+  IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
+
+  g_return_val_if_fail (IDE_IS_BUFFER (self), NULL);
+
+  if (priv->rename_provider_adapter != NULL)
+    return ide_extension_adapter_get_extension (priv->rename_provider_adapter);
+
+  return NULL;
+}
+
+/**
  * ide_buffer_get_symbol_resolver:
  * @self: A #IdeBuffer.
  *
diff --git a/libide/buffers/ide-buffer.h b/libide/buffers/ide-buffer.h
index 88a33a1..5a6c49f 100644
--- a/libide/buffers/ide-buffer.h
+++ b/libide/buffers/ide-buffer.h
@@ -90,6 +90,7 @@ void                ide_buffer_rehighlight                   (IdeBuffer
 void                ide_buffer_get_selection_bounds          (IdeBuffer            *self,
                                                               GtkTextIter          *insert,
                                                               GtkTextIter          *selection);
+IdeRenameProvider  *ide_buffer_get_rename_provider           (IdeBuffer            *self);
 IdeSymbolResolver  *ide_buffer_get_symbol_resolver           (IdeBuffer            *self);
 void                ide_buffer_get_symbol_at_location_async  (IdeBuffer            *self,
                                                               const GtkTextIter    *location,


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