[gnome-builder] symbol: add basic symbol resolver interface methods



commit c7b8384265e99604e302538bd3661f0f9ba29334
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 27 03:23:34 2015 -0700

    symbol: add basic symbol resolver interface methods
    
    More will come, but this is just a basic "give me a symbol at this
    location" type of operation.

 libide/ide-internal.h        |    1 +
 libide/ide-symbol-resolver.c |   49 ++++++++++++++++++++++++++++++++++++++++++
 libide/ide-symbol-resolver.h |    9 +++++++
 3 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-internal.h b/libide/ide-internal.h
index b4f473e..86eeba6 100644
--- a/libide/ide-internal.h
+++ b/libide/ide-internal.h
@@ -97,6 +97,7 @@ void                _ide_source_view_set_count         (IdeSourceView         *s
                                                         guint                  count);
 void                _ide_source_view_set_modifier      (IdeSourceView         *self,
                                                         gunichar               modifier);
+IdeSymbol          *_ide_symbol_new                    (const gchar           *name);
 IdeUnsavedFile     *_ide_unsaved_file_new              (GFile                 *file,
                                                         GBytes                *content,
                                                         const gchar           *temp_path,
diff --git a/libide/ide-symbol-resolver.c b/libide/ide-symbol-resolver.c
index c0f1c73..8adb48f 100644
--- a/libide/ide-symbol-resolver.c
+++ b/libide/ide-symbol-resolver.c
@@ -29,3 +29,52 @@ static void
 ide_symbol_resolver_init (IdeSymbolResolver *self)
 {
 }
+
+/**
+ * ide_symbol_resolver_lookup_symbol_async:
+ * @self: An #IdeSymbolResolver.
+ * @location: An #IdeSourceLocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: (scope async): A callback to execute upon completion.
+ * @user_data: user data for @callback.
+ *
+ * Asynchronously requests that @self determine the symbol existing at the source location
+ * denoted by @self. @callback should call ide_symbol_resolver_lookup_symbol_finish() to
+ * retrieve the result.
+ */
+void
+ide_symbol_resolver_lookup_symbol_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_CLASS (self)->
+    lookup_symbol_async (self, location, cancellable, callback, user_data);
+}
+
+/**
+ * ide_symbol_resolver_lookup_symbol_finish:
+ * @self: An #IdeSymbolResolver.
+ * @result: A #GAsyncResult provided to the callback.
+ * @error: (out): A location for an @error or %NULL.
+ *
+ * Completes an asynchronous call to lookup a symbol using
+ * ide_symbol_resolver_lookup_symbol_async().
+ *
+ * Returns: (transfer full) (nullable): An #IdeSymbol if successful; otherwise %NULL.
+ */
+IdeSymbol *
+ide_symbol_resolver_lookup_symbol_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_CLASS (self)->lookup_symbol_finish (self, result, error);
+}
diff --git a/libide/ide-symbol-resolver.h b/libide/ide-symbol-resolver.h
index ddb79f2..9c53254 100644
--- a/libide/ide-symbol-resolver.h
+++ b/libide/ide-symbol-resolver.h
@@ -30,6 +30,15 @@ G_DECLARE_DERIVABLE_TYPE (IdeSymbolResolver, ide_symbol_resolver, IDE, SYMBOL_RE
 struct _IdeSymbolResolverClass
 {
   IdeObjectClass parent;
+
+  void       (*lookup_symbol_async)  (IdeSymbolResolver    *self,
+                                      IdeSourceLocation    *location,
+                                      GCancellable         *cancellable,
+                                      GAsyncReadyCallback   callback,
+                                      gpointer              user_data);
+  IdeSymbol *(*lookup_symbol_finish) (IdeSymbolResolver    *self,
+                                      GAsyncResult         *result,
+                                      GError              **error);
 };
 
 void       ide_symbol_resolver_lookup_symbol_async  (IdeSymbolResolver    *self,


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