[gnome-builder] symbolresolver: add API to find references to a location
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] symbolresolver: add API to find references to a location
- Date: Fri, 31 Mar 2017 01:53:28 +0000 (UTC)
commit f15fcb8039cd641e0d74033db348347bc5aac5af
Author: Christian Hergert <chergert redhat com>
Date: Thu Mar 30 19:53:09 2017 -0600
symbolresolver: add API to find references to a location
This vaguely maps to what Language Server Protocol provides as the
textDocument/references operation.
libide/symbols/ide-symbol-resolver.c | 69 ++++++++++++++++++++++++++++++++++
libide/symbols/ide-symbol-resolver.h | 16 ++++++++
2 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/libide/symbols/ide-symbol-resolver.c b/libide/symbols/ide-symbol-resolver.c
index c60b3bf..a5d4218 100644
--- a/libide/symbols/ide-symbol-resolver.c
+++ b/libide/symbols/ide-symbol-resolver.c
@@ -61,10 +61,43 @@ ide_symbol_resolver_real_get_symbol_tree_finish (IdeSymbolResolver *self,
}
static void
+ide_symbol_resolver_real_find_references_async (IdeSymbolResolver *self,
+ IdeSourceLocation *location,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_assert (IDE_IS_SYMBOL_RESOLVER (self));
+ g_assert (location != NULL);
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ g_task_report_new_error (self,
+ callback,
+ user_data,
+ ide_symbol_resolver_real_find_references_async,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Finding references is not supported for this language");
+}
+
+static GPtrArray *
+ide_symbol_resolver_real_find_references_finish (IdeSymbolResolver *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_assert (IDE_IS_SYMBOL_RESOLVER (self));
+ g_assert (G_IS_TASK (result));
+
+ return g_task_propagate_pointer (G_TASK (result), error);
+}
+
+static void
ide_symbol_resolver_default_init (IdeSymbolResolverInterface *iface)
{
iface->get_symbol_tree_async = ide_symbol_resolver_real_get_symbol_tree_async;
iface->get_symbol_tree_finish = ide_symbol_resolver_real_get_symbol_tree_finish;
+ iface->find_references_async = ide_symbol_resolver_real_find_references_async;
+ iface->find_references_finish = ide_symbol_resolver_real_find_references_finish;
}
/**
@@ -166,3 +199,39 @@ ide_symbol_resolver_load (IdeSymbolResolver *self)
if (IDE_SYMBOL_RESOLVER_GET_IFACE (self)->load)
IDE_SYMBOL_RESOLVER_GET_IFACE (self)->load (self);
}
+
+void
+ide_symbol_resolver_find_references_async (IdeSymbolResolver *self,
+ IdeSourceLocation *location,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (IDE_IS_SYMBOL_RESOLVER (self));
+ g_return_if_fail (location != NULL);
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ IDE_SYMBOL_RESOLVER_GET_IFACE (self)->find_references_async (self, location, cancellable, callback,
user_data);
+}
+
+/**
+ * ide_symbol_resolver_find_references_finish:
+ * @self: a #IdeSymbolResolver
+ * @result: a #GAsyncResult
+ * @error: a #GError or %NULL
+ *
+ * Completes an asynchronous request to ide_symbol_resolver_find_references_async().
+ *
+ * Returns: (transfer container) (element-type Ide.SourceLocation): A #GPtrArray
+ * of #IdeSourceLocation if successful; otherwise %NULL and @error is set.
+ */
+GPtrArray *
+ide_symbol_resolver_find_references_finish (IdeSymbolResolver *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (IDE_IS_SYMBOL_RESOLVER (self), NULL);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
+
+ return IDE_SYMBOL_RESOLVER_GET_IFACE (self)->find_references_finish (self, result, error);
+}
diff --git a/libide/symbols/ide-symbol-resolver.h b/libide/symbols/ide-symbol-resolver.h
index e6113a4..9a95d48 100644
--- a/libide/symbols/ide-symbol-resolver.h
+++ b/libide/symbols/ide-symbol-resolver.h
@@ -50,6 +50,14 @@ struct _IdeSymbolResolverInterface
GAsyncResult *result,
GError **error);
void (*load) (IdeSymbolResolver *self);
+ void (*find_references_async) (IdeSymbolResolver *self,
+ IdeSourceLocation *location,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ GPtrArray *(*find_references_finish) (IdeSymbolResolver *self,
+ GAsyncResult *result,
+ GError **error);
};
void ide_symbol_resolver_load (IdeSymbolResolver *self);
@@ -70,6 +78,14 @@ void ide_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver
IdeSymbolTree *ide_symbol_resolver_get_symbol_tree_finish (IdeSymbolResolver *self,
GAsyncResult *result,
GError **error);
+void ide_symbol_resolver_find_references_async (IdeSymbolResolver *self,
+ IdeSourceLocation *location,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+GPtrArray *ide_symbol_resolver_find_references_finish (IdeSymbolResolver *self,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]