Commit ce4d1873 authored by Christian Hergert's avatar Christian Hergert
Browse files

clang: port various API to IdeTask

The service still needs DzlTaskCache, but we can use IdeTask
for lots of other stuff that will interact with widgets/etc.
parent cd6ae66a
...@@ -43,7 +43,7 @@ build_request_free (gpointer data) ...@@ -43,7 +43,7 @@ build_request_free (gpointer data)
} }
static void static void
ide_clang_code_indexer_index_file_worker (GTask *task, ide_clang_code_indexer_index_file_worker (IdeTask *task,
gpointer source_object, gpointer source_object,
gpointer task_data, gpointer task_data,
GCancellable *cancellable) GCancellable *cancellable)
...@@ -54,7 +54,7 @@ ide_clang_code_indexer_index_file_worker (GTask *task, ...@@ -54,7 +54,7 @@ ide_clang_code_indexer_index_file_worker (GTask *task,
g_autofree gchar *path = NULL; g_autofree gchar *path = NULL;
enum CXErrorCode code; enum CXErrorCode code;
g_assert (G_IS_TASK (task)); g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_CLANG_CODE_INDEXER (source_object)); g_assert (IDE_IS_CLANG_CODE_INDEXER (source_object));
g_assert (br != NULL); g_assert (br != NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
...@@ -78,13 +78,13 @@ ide_clang_code_indexer_index_file_worker (GTask *task, ...@@ -78,13 +78,13 @@ ide_clang_code_indexer_index_file_worker (GTask *task,
&unit); &unit);
if (code != CXError_Success) if (code != CXError_Success)
g_task_return_new_error (task, ide_task_return_new_error (task,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_FAILED, G_IO_ERROR_FAILED,
"Failed to index \"%s\"", "Failed to index \"%s\"",
path); path);
else else
g_task_return_pointer (task, ide_task_return_pointer (task,
ide_clang_code_index_entries_new (g_steal_pointer (&index), ide_clang_code_index_entries_new (g_steal_pointer (&index),
g_steal_pointer (&unit), g_steal_pointer (&unit),
path), path),
...@@ -100,20 +100,21 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer, ...@@ -100,20 +100,21 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer,
gpointer user_data) gpointer user_data)
{ {
IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer; IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer;
g_autoptr(GTask) task = NULL; g_autoptr(IdeTask) task = NULL;
BuildRequest *br; BuildRequest *br;
g_assert (IDE_IS_CLANG_CODE_INDEXER (self)); g_assert (IDE_IS_CLANG_CODE_INDEXER (self));
g_assert (G_IS_FILE (file)); g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_clang_code_indexer_index_file_async); ide_task_set_source_tag (task, ide_clang_code_indexer_index_file_async);
g_task_set_priority (task, G_PRIORITY_LOW); ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
if (!g_file_is_native (file)) if (!g_file_is_native (file))
{ {
g_task_return_new_error (task, ide_task_return_new_error (task,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED, G_IO_ERROR_NOT_SUPPORTED,
"Only native files are supported"); "Only native files are supported");
...@@ -123,11 +124,9 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer, ...@@ -123,11 +124,9 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer,
br = g_slice_new0 (BuildRequest); br = g_slice_new0 (BuildRequest);
br->build_flags = g_strdupv ((gchar **)args); br->build_flags = g_strdupv ((gchar **)args);
br->file = g_object_ref (file); br->file = g_object_ref (file);
g_task_set_task_data (task, br, build_request_free); ide_task_set_task_data (task, br, build_request_free);
ide_thread_pool_push_task (IDE_THREAD_POOL_INDEXER, ide_task_run_in_thread (task, ide_clang_code_indexer_index_file_worker);
task,
ide_clang_code_indexer_index_file_worker);
} }
static IdeCodeIndexEntries * static IdeCodeIndexEntries *
...@@ -136,9 +135,9 @@ ide_clang_code_indexer_index_file_finish (IdeCodeIndexer *indexer, ...@@ -136,9 +135,9 @@ ide_clang_code_indexer_index_file_finish (IdeCodeIndexer *indexer,
GError **error) GError **error)
{ {
g_assert (IDE_IS_CLANG_CODE_INDEXER (indexer)); g_assert (IDE_IS_CLANG_CODE_INDEXER (indexer));
g_assert (G_IS_TASK (result)); g_assert (IDE_IS_TASK (result));
return g_task_propagate_pointer (G_TASK (result), error); return ide_task_propagate_pointer (IDE_TASK (result), error);
} }
static void static void
...@@ -148,28 +147,28 @@ ide_clang_code_indexer_generate_key_cb (GObject *object, ...@@ -148,28 +147,28 @@ ide_clang_code_indexer_generate_key_cb (GObject *object,
{ {
IdeClangService *service = (IdeClangService *)object; IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL; g_autoptr(IdeClangTranslationUnit) unit = NULL;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autofree gchar *key = NULL; g_autofree gchar *key = NULL;
IdeSourceLocation *location; IdeSourceLocation *location;
g_assert (IDE_IS_CLANG_SERVICE (service)); g_assert (IDE_IS_CLANG_SERVICE (service));
g_assert (G_IS_ASYNC_RESULT (result)); g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task)); g_assert (IDE_IS_TASK (task));
if (!(unit = ide_clang_service_get_translation_unit_finish (service, result, &error))) if (!(unit = ide_clang_service_get_translation_unit_finish (service, result, &error)))
{ {
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
return; return;
} }
location = g_task_get_task_data (task); location = ide_task_get_task_data (task);
g_assert (location != NULL); g_assert (location != NULL);
if (!(key = ide_clang_translation_unit_generate_key (unit, location))) if (!(key = ide_clang_translation_unit_generate_key (unit, location)))
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Key not found"); ide_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Key not found");
else else
g_task_return_pointer (task, g_steal_pointer (&key), g_free); ide_task_return_pointer (task, g_steal_pointer (&key), g_free);
} }
static void static void
...@@ -180,7 +179,7 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer, ...@@ -180,7 +179,7 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
gpointer user_data) gpointer user_data)
{ {
IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer; IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer;
g_autoptr(GTask) task = NULL; g_autoptr(IdeTask) task = NULL;
IdeClangService *service; IdeClangService *service;
IdeContext *context; IdeContext *context;
...@@ -193,11 +192,11 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer, ...@@ -193,11 +192,11 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
* can be referenced across compilation units. * can be referenced across compilation units.
*/ */
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_clang_code_indexer_generate_key_async); ide_task_set_source_tag (task, ide_clang_code_indexer_generate_key_async);
g_task_set_priority (task, G_PRIORITY_LOW); ide_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_task_data (task, ide_task_set_task_data (task,
ide_source_location_ref (location), ide_source_location_ref (location),
(GDestroyNotify)ide_source_location_unref); (GDestroyNotify)ide_source_location_unref);
...@@ -221,9 +220,9 @@ ide_clang_code_indexer_generate_key_finish (IdeCodeIndexer *self, ...@@ -221,9 +220,9 @@ ide_clang_code_indexer_generate_key_finish (IdeCodeIndexer *self,
GError **error) GError **error)
{ {
g_assert (IDE_IS_CODE_INDEXER (self)); g_assert (IDE_IS_CODE_INDEXER (self));
g_assert (G_IS_TASK (result)); g_assert (IDE_IS_TASK (result));
return g_task_propagate_pointer (G_TASK (result), error); return ide_task_propagate_pointer (IDE_TASK (result), error);
} }
static void static void
......
...@@ -50,7 +50,7 @@ get_translation_unit_cb (GObject *object, ...@@ -50,7 +50,7 @@ get_translation_unit_cb (GObject *object,
{ {
IdeClangService *service = (IdeClangService *)object; IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) tu = NULL; g_autoptr(IdeClangTranslationUnit) tu = NULL;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
IdeDiagnostics *diagnostics; IdeDiagnostics *diagnostics;
IdeFile *target; IdeFile *target;
...@@ -60,11 +60,11 @@ get_translation_unit_cb (GObject *object, ...@@ -60,11 +60,11 @@ get_translation_unit_cb (GObject *object,
if (!tu) if (!tu)
{ {
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
return; return;
} }
target = g_task_get_task_data (task); target = ide_task_get_task_data (task);
g_assert (IDE_IS_FILE (target)); g_assert (IDE_IS_FILE (target));
gfile = ide_file_get_file (target); gfile = ide_file_get_file (target);
...@@ -72,7 +72,7 @@ get_translation_unit_cb (GObject *object, ...@@ -72,7 +72,7 @@ get_translation_unit_cb (GObject *object,
diagnostics = ide_clang_translation_unit_get_diagnostics_for_file (tu, gfile); diagnostics = ide_clang_translation_unit_get_diagnostics_for_file (tu, gfile);
g_task_return_pointer (task, ide_task_return_pointer (task,
ide_diagnostics_ref (diagnostics), ide_diagnostics_ref (diagnostics),
(GDestroyNotify)ide_diagnostics_unref); (GDestroyNotify)ide_diagnostics_unref);
} }
...@@ -99,7 +99,7 @@ ide_clang_diagnostic_provider_diagnose__file_find_other_cb (GObject *object ...@@ -99,7 +99,7 @@ ide_clang_diagnostic_provider_diagnose__file_find_other_cb (GObject *object
{ {
IdeFile *file = (IdeFile *)object; IdeFile *file = (IdeFile *)object;
g_autoptr(IdeFile) other = NULL; g_autoptr(IdeFile) other = NULL;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
IdeClangService *service; IdeClangService *service;
IdeContext *context; IdeContext *context;
...@@ -116,7 +116,7 @@ ide_clang_diagnostic_provider_diagnose__file_find_other_cb (GObject *object ...@@ -116,7 +116,7 @@ ide_clang_diagnostic_provider_diagnose__file_find_other_cb (GObject *object
ide_clang_service_get_translation_unit_async (service, ide_clang_service_get_translation_unit_async (service,
file, file,
0, 0,
g_task_get_cancellable (task), ide_task_get_cancellable (task),
get_translation_unit_cb, get_translation_unit_cb,
g_object_ref (task)); g_object_ref (task));
} }
...@@ -130,12 +130,12 @@ ide_clang_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider, ...@@ -130,12 +130,12 @@ ide_clang_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
gpointer user_data) gpointer user_data)
{ {
IdeClangDiagnosticProvider *self = (IdeClangDiagnosticProvider *)provider; IdeClangDiagnosticProvider *self = (IdeClangDiagnosticProvider *)provider;
g_autoptr(GTask) task = NULL; g_autoptr(IdeTask) task = NULL;
g_return_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (self)); g_return_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (self));
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
g_task_set_task_data (task, g_object_ref (file), g_object_unref); ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
if (is_header (file)) if (is_header (file))
{ {
...@@ -166,12 +166,12 @@ ide_clang_diagnostic_provider_diagnose_finish (IdeDiagnosticProvider *provider, ...@@ -166,12 +166,12 @@ ide_clang_diagnostic_provider_diagnose_finish (IdeDiagnosticProvider *provider,
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
GTask *task = (GTask *)result; IdeTask *task = (IdeTask *)result;
g_return_val_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (provider), NULL); g_return_val_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (provider), NULL);
g_return_val_if_fail (G_IS_TASK (task), NULL); g_return_val_if_fail (IDE_IS_TASK (task), NULL);
return g_task_propagate_pointer (task, error); return ide_task_propagate_pointer (task, error);
} }
static void static void
......
...@@ -174,7 +174,7 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node, ...@@ -174,7 +174,7 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
IdeClangSymbolNode *self = (IdeClangSymbolNode *)symbol_node; IdeClangSymbolNode *self = (IdeClangSymbolNode *)symbol_node;
g_autoptr(IdeFile) ifile = NULL; g_autoptr(IdeFile) ifile = NULL;
g_autoptr(GFile) gfile = NULL; g_autoptr(GFile) gfile = NULL;
g_autoptr(GTask) task = NULL; g_autoptr(IdeTask) task = NULL;
g_auto(CXString) cxfilename = {0}; g_auto(CXString) cxfilename = {0};
IdeContext *context; IdeContext *context;
const gchar *filename; const gchar *filename;
...@@ -185,9 +185,9 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node, ...@@ -185,9 +185,9 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
g_return_if_fail (IDE_IS_CLANG_SYMBOL_NODE (self)); g_return_if_fail (IDE_IS_CLANG_SYMBOL_NODE (self));
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_clang_symbol_node_get_location_async); ide_task_set_source_tag (task, ide_clang_symbol_node_get_location_async);
g_task_set_priority (task, G_PRIORITY_LOW); ide_task_set_priority (task, G_PRIORITY_LOW);
cxloc = clang_getCursorLocation (self->cursor); cxloc = clang_getCursorLocation (self->cursor);
clang_getFileLocation (cxloc, &file, &line, &line_offset, NULL); clang_getFileLocation (cxloc, &file, &line, &line_offset, NULL);
...@@ -202,7 +202,7 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node, ...@@ -202,7 +202,7 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
gfile = g_file_new_for_path (filename); gfile = g_file_new_for_path (filename);
ifile = ide_file_new (context, gfile); ifile = ide_file_new (context, gfile);
g_task_return_pointer (task, ide_task_return_pointer (task,
ide_source_location_new (ifile, line-1, line_offset-1, 0), ide_source_location_new (ifile, line-1, line_offset-1, 0),
(GDestroyNotify)ide_source_location_unref); (GDestroyNotify)ide_source_location_unref);
} }
...@@ -213,9 +213,9 @@ ide_clang_symbol_node_get_location_finish (IdeSymbolNode *symbol_node, ...@@ -213,9 +213,9 @@ ide_clang_symbol_node_get_location_finish (IdeSymbolNode *symbol_node,
GError **error) GError **error)
{ {
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_NODE (symbol_node), NULL); g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_NODE (symbol_node), NULL);
g_return_val_if_fail (G_IS_TASK (result), NULL); g_return_val_if_fail (IDE_IS_TASK (result), NULL);
return g_task_propagate_pointer (G_TASK (result), error); return ide_task_propagate_pointer (IDE_TASK (result), error);
} }
static void static void
......
...@@ -39,21 +39,21 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object, ...@@ -39,21 +39,21 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object,
{ {
IdeClangService *service = (IdeClangService *)object; IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL; g_autoptr(IdeClangTranslationUnit) unit = NULL;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
g_autoptr(IdeSymbol) symbol = NULL; g_autoptr(IdeSymbol) symbol = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
IdeSourceLocation *location; IdeSourceLocation *location;
g_assert (IDE_IS_CLANG_SERVICE (service)); g_assert (IDE_IS_CLANG_SERVICE (service));
g_assert (G_IS_TASK (task)); g_assert (IDE_IS_TASK (task));
location = g_task_get_task_data (task); location = ide_task_get_task_data (task);
unit = ide_clang_service_get_translation_unit_finish (service, result, &error); unit = ide_clang_service_get_translation_unit_finish (service, result, &error);
if (unit == NULL) if (unit == NULL)
{ {
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
return; return;
} }
...@@ -61,11 +61,11 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object, ...@@ -61,11 +61,11 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object,
if (symbol == NULL) if (symbol == NULL)
{ {
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
return; return;
} }
g_task_return_pointer (task, g_steal_pointer (&symbol), (GDestroyNotify)ide_symbol_unref); ide_task_return_pointer (task, g_steal_pointer (&symbol), (GDestroyNotify)ide_symbol_unref);
} }
static void static void
...@@ -79,7 +79,7 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver, ...@@ -79,7 +79,7 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
IdeClangService *service = NULL; IdeClangService *service = NULL;
IdeContext *context; IdeContext *context;
IdeFile *file; IdeFile *file;
g_autoptr(GTask) task = NULL; g_autoptr(IdeTask) task = NULL;
IDE_ENTRY; IDE_ENTRY;
...@@ -90,9 +90,9 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver, ...@@ -90,9 +90,9 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
service = ide_context_get_service_typed (context, IDE_TYPE_CLANG_SERVICE); service = ide_context_get_service_typed (context, IDE_TYPE_CLANG_SERVICE);
file = ide_source_location_get_file (location); file = ide_source_location_get_file (location);
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
g_task_set_priority (task, G_PRIORITY_LOW); ide_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_task_data (task, ide_source_location_ref (location), ide_task_set_task_data (task, ide_source_location_ref (location),
(GDestroyNotify)ide_source_location_unref); (GDestroyNotify)ide_source_location_unref);
ide_clang_service_get_translation_unit_async (service, ide_clang_service_get_translation_unit_async (service,
...@@ -111,14 +111,14 @@ ide_clang_symbol_resolver_lookup_symbol_finish (IdeSymbolResolver *resolver, ...@@ -111,14 +111,14 @@ ide_clang_symbol_resolver_lookup_symbol_finish (IdeSymbolResolver *resolver,
GError **error) GError **error)
{ {
IdeSymbol *ret; IdeSymbol *ret;
GTask *task = (GTask *)result; IdeTask *task = (IdeTask *)result;
IDE_ENTRY; IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (resolver), NULL); g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (resolver), NULL);
g_return_val_if_fail (G_IS_TASK (task), NULL); g_return_val_if_fail (IDE_IS_TASK (task), NULL);
ret = g_task_propagate_pointer (task, error); ret = ide_task_propagate_pointer (task, error);
IDE_RETURN (ret); IDE_RETURN (ret);
} }
...@@ -130,15 +130,15 @@ ide_clang_symbol_resolver_get_symbol_tree_cb2 (GObject *object, ...@@ -130,15 +130,15 @@ ide_clang_symbol_resolver_get_symbol_tree_cb2 (GObject *object,
{ {
IdeClangTranslationUnit *unit = (IdeClangTranslationUnit *)object; IdeClangTranslationUnit *unit = (IdeClangTranslationUnit *)object;
g_autoptr(IdeSymbolTree) ret = NULL; g_autoptr(IdeSymbolTree) ret = NULL;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
ret = ide_clang_translation_unit_get_symbol_tree_finish (unit, result, &error); ret = ide_clang_translation_unit_get_symbol_tree_finish (unit, result, &error);
if (ret == NULL) if (ret == NULL)
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
else else
g_task_return_pointer (task, g_steal_pointer (&ret), g_object_unref); ide_task_return_pointer (task, g_steal_pointer (&ret), g_object_unref);
} }
static void static void
...@@ -148,29 +148,29 @@ ide_clang_symbol_resolver_get_symbol_tree_cb (GObject *object, ...@@ -148,29 +148,29 @@ ide_clang_symbol_resolver_get_symbol_tree_cb (GObject *object,
{ {
IdeClangService *service = (IdeClangService *)object; IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL; g_autoptr(IdeClangTranslationUnit) unit = NULL;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
GFile *file; GFile *file;
IDE_ENTRY; IDE_ENTRY;
g_assert (IDE_IS_CLANG_SERVICE (service)); g_assert (IDE_IS_CLANG_SERVICE (service));
g_assert (G_IS_TASK (task)); g_assert (IDE_IS_TASK (task));
unit = ide_clang_service_get_translation_unit_finish (service, result, &error); unit = ide_clang_service_get_translation_unit_finish (service, result, &error);
if (unit == NULL) if (unit == NULL)
{ {
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT; IDE_EXIT;
} }
file = g_task_get_task_data (task); file = ide_task_get_task_data (task);
g_assert (G_IS_FILE (file)); g_assert (G_IS_FILE (file));
ide_clang_translation_unit_get_symbol_tree_async (unit, ide_clang_translation_unit_get_symbol_tree_async (unit,
file, file,
g_task_get_cancellable (task), ide_task_get_cancellable (task),
ide_clang_symbol_resolver_get_symbol_tree_cb2, ide_clang_symbol_resolver_get_symbol_tree_cb2,
g_object_ref (task)); g_object_ref (task));