[gnome-builder] buffer: add helper to get symbols for current document
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] buffer: add helper to get symbols for current document
- Date: Sun, 29 Mar 2015 08:02:59 +0000 (UTC)
commit efffab2324fb12195d70783cb71aef99234d5cf2
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 29 00:57:17 2015 -0700
buffer: add helper to get symbols for current document
libide/ide-buffer.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++
libide/ide-buffer.h | 7 +++++
2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 8bfdbb7..6bce698 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -1805,3 +1805,75 @@ ide_buffer_get_symbol_at_location_finish (IdeBuffer *self,
return g_task_propagate_pointer (task, error);
}
+
+static void
+ide_buffer__symbol_provider_get_symbols_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ IdeSymbolResolver *symbol_resolver = (IdeSymbolResolver *)object;
+ g_autoptr(GPtrArray) symbols = NULL;
+ g_autoptr(GTask) task = user_data;
+ GError *error = NULL;
+
+ g_assert (G_IS_TASK (task));
+
+ symbols = ide_symbol_resolver_get_symbols_finish (symbol_resolver, result, &error);
+
+ if (symbols == NULL)
+ {
+ g_task_return_error (task, error);
+ return;
+ }
+
+ g_task_return_pointer (task, g_ptr_array_ref (symbols), (GDestroyNotify)g_ptr_array_unref);
+}
+
+void
+ide_buffer_get_symbols_async (IdeBuffer *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
+ g_autoptr(GTask) task = NULL;
+
+ g_return_if_fail (IDE_IS_BUFFER (self));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ task = g_task_new (self, cancellable, callback, user_data);
+
+ if (priv->symbol_resolver == NULL)
+ {
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Symbol resolver is not supported."));
+ return;
+ }
+
+ ide_symbol_resolver_get_symbols_async (priv->symbol_resolver,
+ priv->file,
+ cancellable,
+ ide_buffer__symbol_provider_get_symbols_cb,
+ g_object_ref (task));
+}
+
+/**
+ * ide_buffer_get_symbols_finish:
+ *
+ * Returns: (transfer container) (element-type IdeSymbol*): A #GPtrArray if successful;
+ * otherwise %NULL.
+ */
+GPtrArray *
+ide_buffer_get_symbols_finish (IdeBuffer *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ GTask *task = (GTask *)result;
+
+ g_return_val_if_fail (IDE_IS_BUFFER (self), NULL);
+ g_return_val_if_fail (G_IS_TASK (task), NULL);
+
+ return g_task_propagate_pointer (task, error);
+}
diff --git a/libide/ide-buffer.h b/libide/ide-buffer.h
index 0ba2105..1f3637e 100644
--- a/libide/ide-buffer.h
+++ b/libide/ide-buffer.h
@@ -97,6 +97,13 @@ void ide_buffer_get_symbol_at_location_async (IdeBuffer
IdeSymbol *ide_buffer_get_symbol_at_location_finish (IdeBuffer *self,
GAsyncResult *result,
GError **error);
+void ide_buffer_get_symbols_async (IdeBuffer *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+GPtrArray *ide_buffer_get_symbols_finish (IdeBuffer *self,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]