[gnome-builder] gettext: rewrite xgettext diagnostic provider



commit db83cee0101378ae4453ee8456305461ddc04061
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jan 13 17:45:56 2018 -0800

    gettext: rewrite xgettext diagnostic provider
    
    This simplifies the gettext provider as we don't need to use the task
    cache, or any indirect diagnostics helper objects. We can just shove
    the contents into stdin of xgettext and process the reply asynchronously
    using the line reader.

 .../gettext/ide-gettext-diagnostic-provider.c      | 551 ++++++---------------
 .../gettext/ide-gettext-diagnostic-provider.h      |   3 +-
 2 files changed, 154 insertions(+), 400 deletions(-)
---
diff --git a/src/plugins/gettext/ide-gettext-diagnostic-provider.c 
b/src/plugins/gettext/ide-gettext-diagnostic-provider.c
index 30d8b913b..ff4f5968d 100644
--- a/src/plugins/gettext/ide-gettext-diagnostic-provider.c
+++ b/src/plugins/gettext/ide-gettext-diagnostic-provider.c
@@ -1,6 +1,7 @@
 /* ide-gettext-diagnostic-provider.c
  *
  * Copyright © 2016 Daiki Ueno <dueno src gnome org>
+ * Copyright © 2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,176 +20,124 @@
 #define G_LOG_DOMAIN "ide-gettext-diagnostic-provider"
 
 #include <dazzle.h>
+#include <errno.h>
 #include <glib/gi18n.h>
 #include <stdlib.h>
 
 #include "ide-gettext-diagnostic-provider.h"
 
-struct _IdeGettextDiagnostics
-{
-  GObject         parent_instance;
-  IdeDiagnostics *diagnostics;
-  gint64          sequence;
-};
-
 struct _IdeGettextDiagnosticProvider
 {
-  IdeObject     parent_instance;
-  DzlTaskCache *diagnostics_cache;
-};
-
-typedef struct
-{
-  IdeFile *file;
-  IdeUnsavedFile *unsaved_file;
-} TranslationUnit;
-
-static void diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface);
-
-G_DEFINE_TYPE (IdeGettextDiagnostics, ide_gettext_diagnostics, G_TYPE_OBJECT)
-G_DEFINE_TYPE_EXTENDED (IdeGettextDiagnosticProvider,
-                        ide_gettext_diagnostic_provider,
-                        IDE_TYPE_OBJECT,
-                        0,
-                        G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER,
-                                               diagnostic_provider_iface_init))
-
-enum {
-  PROP_0,
-  PROP_DIAGNOSTICS,
-  PROP_SEQUENCE,
-  N_PROPS
+  IdeObject parent_instance;
 };
 
-static GParamSpec *properties [N_PROPS];
-
-static void
-ide_gettext_diagnostics_set_property (GObject      *object,
-                                      guint         prop_id,
-                                      const GValue *value,
-                                      GParamSpec   *pspec)
+static const gchar *
+id_to_xgettext_language (const gchar *id)
 {
-  IdeGettextDiagnostics *self = IDE_GETTEXT_DIAGNOSTICS (object);
+  static const struct {
+    const gchar *id;
+    const gchar *lang;
+  } id_to_lang[] = {
+    { "awk", "awk" },
+    { "c", "C" },
+    { "chdr", "C" },
+    { "cpp", "C++" },
+    { "js", "JavaScript" },
+    { "lisp", "Lisp" },
+    { "objc", "ObjectiveC" },
+    { "perl", "Perl" },
+    { "php", "PHP" },
+    { "python", "Python" },
+    { "sh", "Shell" },
+    { "tcl", "Tcl" },
+    { "vala", "Vala" }
+  };
 
-  switch (prop_id)
+  if (id != NULL)
     {
-    case PROP_DIAGNOSTICS:
-      self->diagnostics = g_value_dup_boxed (value);
-      break;
-
-    case PROP_SEQUENCE:
-      self->sequence = g_value_get_uint64 (value);
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
+      for (guint i = 0; i < G_N_ELEMENTS (id_to_lang); i++)
+        {
+          if (dzl_str_equal0 (id, id_to_lang[i].id))
+            return id_to_lang[i].lang;
+        }
     }
-}
 
-static void
-ide_gettext_diagnostics_finalize (GObject *object)
-{
-  IdeGettextDiagnostics *self = IDE_GETTEXT_DIAGNOSTICS (object);
-
-  g_clear_pointer (&self->diagnostics, ide_diagnostics_unref);
-
-  G_OBJECT_CLASS (ide_gettext_diagnostics_parent_class)->finalize (object);
+  return NULL;
 }
 
-static void
-ide_gettext_diagnostics_class_init (IdeGettextDiagnosticsClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  object_class->finalize = ide_gettext_diagnostics_finalize;
-  object_class->set_property = ide_gettext_diagnostics_set_property;
-
-  properties [PROP_DIAGNOSTICS] =
-    g_param_spec_boxed ("diagnostics",
-                        "Diagnostics",
-                        "Diagnostics",
-                        IDE_TYPE_DIAGNOSTICS,
-                        (G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
-
-  properties [PROP_SEQUENCE] =
-    g_param_spec_uint64 ("sequence",
-                         "Sequence",
-                         "The document sequence number",
-                         0,
-                         G_MAXUINT64,
-                         0,
-                         (G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
-
-  g_object_class_install_properties (object_class, N_PROPS, properties);
-}
 
 static void
-ide_gettext_diagnostics_init (IdeGettextDiagnostics *self)
+ide_gettext_diagnostic_provider_communicate_cb (GObject      *object,
+                                                GAsyncResult *result,
+                                                gpointer      user_data)
 {
-}
+  IdeSubprocess *subprocess = (IdeSubprocess *)object;
+  g_autoptr(GTask) task = user_data;
+  g_autoptr(IdeDiagnostics) ret = NULL;
+  g_autoptr(GError) error = NULL;
+  g_autofree gchar *stderr_buf = NULL;
+  g_autofree gchar *stdout_buf = NULL;
+  IdeLineReader reader;
+  IdeFile *file;
+  gchar *line;
+  gsize len;
 
-static void
-translation_unit_free (TranslationUnit *unit)
-{
-  if (unit != NULL)
+  g_assert (IDE_IS_SUBPROCESS (subprocess));
+  g_assert (G_IS_ASYNC_RESULT (result));
+  g_assert (G_IS_TASK (task));
+
+  if (!ide_subprocess_communicate_utf8_finish (subprocess, result, &stdout_buf, &stderr_buf, &error))
     {
-      g_clear_object (&unit->file);
-      g_clear_pointer (&unit->unsaved_file, ide_unsaved_file_unref);
-      g_slice_free (TranslationUnit, unit);
+      g_task_return_error (task, g_steal_pointer (&error));
+      return;
     }
-}
-
-static IdeUnsavedFile *
-get_unsaved_file (IdeGettextDiagnosticProvider *self,
-                  IdeFile                      *file)
-{
-  g_autoptr(GPtrArray) array = NULL;
-  IdeUnsavedFiles *unsaved_files;
-  IdeContext *context;
 
-  g_assert (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (self));
+  file = g_task_get_task_data (task);
+  g_assert (file != NULL);
   g_assert (IDE_IS_FILE (file));
 
-  context = ide_object_get_context (IDE_OBJECT (self));
-  unsaved_files = ide_context_get_unsaved_files (context);
-  array = ide_unsaved_files_to_array (unsaved_files);
+  ret = ide_diagnostics_new (NULL);
+
+  ide_line_reader_init (&reader, stderr_buf, -1);
 
-  for (guint i = 0; i < array->len; i++)
+  while (NULL != (line = ide_line_reader_next (&reader, &len)))
     {
-      IdeUnsavedFile *unsaved_file = g_ptr_array_index (array, i);
-      GFile *ufile = ide_unsaved_file_get_file (unsaved_file);
-      GFile *ifile = ide_file_get_file (file);
+      g_autoptr(IdeDiagnostic) diag = NULL;
+      g_autoptr(IdeSourceLocation) loc = NULL;
+      guint64 lineno;
 
-      g_assert (G_IS_FILE (ufile));
-      g_assert (G_IS_FILE (ifile));
+      line[len] = '\0';
 
-      if (g_file_equal (ufile, ifile))
-        return ide_unsaved_file_ref (unsaved_file);
-    }
+      /* Lines that we want to parse should look something like this:
+       * "standard input:195: ASCII double quote used instead of Unicode"
+       */
 
-  return NULL;
-}
+      if (!g_str_has_prefix (line, "standard input:"))
+        continue;
 
-static void
-get_diagnostics_cb (GObject      *source_object,
-                    GAsyncResult *res,
-                    gpointer      user_data)
-{
-  DzlTaskCache *cache = DZL_TASK_CACHE (source_object);
-  g_autoptr(GTask) task = user_data;
-  g_autoptr(IdeGettextDiagnostics) diags = NULL;
-  g_autoptr(GError) error = NULL;
+      line += strlen ("standard input:");
+      if (!g_ascii_isdigit (*line))
+        continue;
 
-  g_assert (DZL_IS_TASK_CACHE (cache));
-  g_assert (G_IS_TASK (task));
+      lineno = g_ascii_strtoull (line, &line, 10);
+      if ((lineno == G_MAXUINT64 && errno == ERANGE) || ((lineno == 0) && errno == EINVAL))
+        continue;
+      if (lineno > 0)
+        lineno--;
+
+      if (!g_str_has_prefix (line, ": "))
+        continue;
 
-  diags = dzl_task_cache_get_finish (cache, res, &error);
+      line += strlen (": ");
+
+      loc = ide_source_location_new (file, lineno, 0, 0);
+      diag = ide_diagnostic_new (IDE_DIAGNOSTIC_WARNING, line, loc);
+      ide_diagnostics_add (ret, diag);
+    }
 
-  if (diags == NULL)
-    g_task_return_error (task, g_steal_pointer (&error));
-  else
-    g_task_return_pointer (task, g_steal_pointer (&diags), g_object_unref);
+  g_task_return_pointer (task,
+                         g_steal_pointer (&ret),
+                         (GDestroyNotify)ide_diagnostics_unref);
 }
 
 static void
@@ -200,9 +149,14 @@ ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
                                                 gpointer               user_data)
 {
   IdeGettextDiagnosticProvider *self = (IdeGettextDiagnosticProvider *)provider;
-  g_autoptr(IdeUnsavedFile) unsaved_file = NULL;
-  IdeGettextDiagnostics *cached;
+  g_autoptr(IdeSubprocessLauncher) launcher = NULL;
+  g_autoptr(IdeSubprocess) subprocess = NULL;
+  g_autoptr(GBytes) contents = NULL;
   g_autoptr(GTask) task = NULL;
+  g_autoptr(GError) error = NULL;
+  GtkSourceLanguage *language;
+  const gchar *lang_id;
+  const gchar *xgettext_id;
 
   g_assert (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (self));
   g_assert (IDE_IS_FILE (file));
@@ -211,24 +165,63 @@ ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
 
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_source_tag (task, ide_gettext_diagnostic_provider_diagnose_async);
+  g_task_set_priority (task, G_PRIORITY_LOW);
+  g_task_set_task_data (task, g_object_ref (file), g_object_unref);
 
-  if (NULL != (cached = dzl_task_cache_peek (self->diagnostics_cache, file)))
+  /* Figure out what language xgettext should use */
+  if (!(language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (buffer))) ||
+      !(lang_id = gtk_source_language_get_id (language)) ||
+      !(xgettext_id = id_to_xgettext_language (lang_id)))
     {
-      unsaved_file = get_unsaved_file (self, file);
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_NOT_SUPPORTED,
+                               "Language %s is not supported",
+                               lang_id);
+      return;
+    }
 
-      if (unsaved_file == NULL || (cached->sequence >= ide_unsaved_file_get_sequence (unsaved_file)))
-        {
-          g_task_return_pointer (task, g_object_ref (cached), g_object_unref);
-          return;
-        }
+  /* Return an empty set if we failed to locate any buffer contents */
+  if (!(contents = ide_buffer_get_content (buffer)) || g_bytes_get_size (contents) == 0)
+    {
+      g_task_return_pointer (task,
+                             ide_diagnostics_new (NULL),
+                             (GDestroyNotify)ide_diagnostics_unref);
+      return;
     }
 
-  dzl_task_cache_get_async (self->diagnostics_cache,
-                            file,
-                            TRUE,
-                            cancellable,
-                            get_diagnostics_cb,
-                            g_steal_pointer (&task));
+  launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDIN_PIPE |
+                                          G_SUBPROCESS_FLAGS_STDOUT_SILENCE |
+                                          G_SUBPROCESS_FLAGS_STDERR_PIPE);
+
+  ide_subprocess_launcher_push_argv (launcher, "xgettext");
+  ide_subprocess_launcher_push_argv (launcher, "--check=ellipsis-unicode");
+  ide_subprocess_launcher_push_argv (launcher, "--check=quote-unicode");
+  ide_subprocess_launcher_push_argv (launcher, "--check=space-ellipsis");
+  ide_subprocess_launcher_push_argv (launcher, "--from-code=UTF-8");
+  ide_subprocess_launcher_push_argv (launcher, "-k_");
+  ide_subprocess_launcher_push_argv (launcher, "-kN_");
+  ide_subprocess_launcher_push_argv (launcher, "-L");
+  ide_subprocess_launcher_push_argv (launcher, xgettext_id);
+  ide_subprocess_launcher_push_argv (launcher, "-o");
+  ide_subprocess_launcher_push_argv (launcher, "-");
+  ide_subprocess_launcher_push_argv (launcher, "-");
+
+  /* Spawn the process of fail immediately */
+  if (!(subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error)))
+    {
+      g_task_return_error (task, g_steal_pointer (&error));
+      return;
+    }
+
+  /* Write the buffer contents to the subprocess and wait for the result
+   * from xgettext. We'll parse the result after the process exits.
+   */
+  ide_subprocess_communicate_utf8_async (subprocess,
+                                         (const gchar *)g_bytes_get_data (contents, NULL),
+                                         cancellable,
+                                         ide_gettext_diagnostic_provider_communicate_cb,
+                                         g_steal_pointer (&task));
 }
 
 static IdeDiagnostics *
@@ -236,16 +229,11 @@ ide_gettext_diagnostic_provider_diagnose_finish (IdeDiagnosticProvider  *provide
                                                  GAsyncResult           *result,
                                                  GError                **error)
 {
-  GTask *task = (GTask *)result;
-  g_autoptr(IdeGettextDiagnostics) object = NULL;
-
-  g_return_val_if_fail (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (provider), NULL);
-  g_return_val_if_fail (G_IS_TASK (task), NULL);
-
-  if (NULL == (object = g_task_propagate_pointer (task, error)))
-    return NULL;
+  g_assert (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (provider));
+  g_assert (G_IS_TASK (result));
+  g_assert (g_task_is_valid (G_TASK (result), provider));
 
-  return ide_diagnostics_ref (object->diagnostics);
+  return g_task_propagate_pointer (G_TASK (result), error);
 }
 
 static void
@@ -255,251 +243,18 @@ diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
   iface->diagnose_finish = ide_gettext_diagnostic_provider_diagnose_finish;
 }
 
-static void
-ide_gettext_diagnostic_provider_dispose (GObject *object)
-{
-  IdeGettextDiagnosticProvider *self = IDE_GETTEXT_DIAGNOSTIC_PROVIDER (object);
-
-  g_clear_object (&self->diagnostics_cache);
-
-  G_OBJECT_CLASS (ide_gettext_diagnostic_provider_parent_class)->dispose (object);
-}
+G_DEFINE_TYPE_WITH_CODE (IdeGettextDiagnosticProvider,
+                         ide_gettext_diagnostic_provider,
+                         IDE_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER,
+                                                diagnostic_provider_iface_init))
 
 static void
 ide_gettext_diagnostic_provider_class_init (IdeGettextDiagnosticProviderClass *klass)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  object_class->dispose = ide_gettext_diagnostic_provider_dispose;
-}
-
-static void
-subprocess_wait_cb (GObject      *object,
-                    GAsyncResult *res,
-                    gpointer      user_data)
-{
-  GSubprocess *subprocess = (GSubprocess *)object;
-  g_autofree gchar *input_prefix = NULL;
-  g_autoptr(IdeDiagnostics) local_diags = NULL;
-  g_autoptr(GTask) task = user_data;
-  g_autoptr(GPtrArray) array = NULL;
-  g_autoptr(GDataInputStream) stderr_data_input = NULL;
-  GInputStream *stderr_input = NULL;
-  g_autoptr(IdeGettextDiagnostics) diags = NULL;
-  g_autoptr(GError) error = NULL;
-  TranslationUnit *unit;
-
-  g_assert (G_IS_SUBPROCESS (subprocess));
-  g_assert (G_IS_TASK (task));
-
-  unit = g_task_get_task_data (task);
-
-  g_assert (unit != NULL);
-
-  if (!g_subprocess_wait_finish (subprocess, res, &error))
-    {
-      g_task_return_error (task, g_steal_pointer (&error));
-      return;
-    }
-
-  array = g_ptr_array_new_with_free_func ((GDestroyNotify)ide_diagnostic_unref);
-  if (g_subprocess_get_exit_status (subprocess) == 0)
-    goto out;
-
-  stderr_input = g_subprocess_get_stderr_pipe (subprocess);
-  stderr_data_input = g_data_input_stream_new (stderr_input);
-  input_prefix = g_strdup_printf ("%s:", ide_unsaved_file_get_temp_path (unit->unsaved_file));
-
-  for (;;)
-    {
-      g_autofree gchar *line = NULL;
-      gsize length;
-
-      line = g_data_input_stream_read_line (stderr_data_input,
-                                            &length,
-                                            g_task_get_cancellable (task),
-                                            &error);
-      if (line == NULL)
-        break;
-
-      if (g_str_has_prefix (line, input_prefix))
-        {
-          gchar *p = line + strlen (input_prefix);
-
-          if (g_ascii_isdigit (*p))
-            {
-              gulong line_number = strtoul (p, &p, 10);
-              IdeSourceLocation *loc;
-              IdeDiagnostic *diag;
-
-              loc = ide_source_location_new (unit->file,
-                                             line_number - 1,
-                                             0,
-                                             0);
-              diag = ide_diagnostic_new (IDE_DIAGNOSTIC_WARNING,
-                                         g_strstrip (p + 1),
-                                         loc);
-              g_ptr_array_add (array, diag);
-            }
-        }
-    }
-
- out:
-  local_diags = ide_diagnostics_new (g_steal_pointer (&array));
-  diags = g_object_new (IDE_TYPE_GETTEXT_DIAGNOSTICS,
-                        "diagnostics", local_diags,
-                        "sequence", ide_unsaved_file_get_sequence (unit->unsaved_file),
-                        NULL);
-  g_task_return_pointer (task, g_steal_pointer (&diags), g_object_unref);
-}
-
-static const gchar *
-id_to_xgettext_language (const gchar *id)
-{
-  static const struct {
-    const gchar *id;
-    const gchar *lang;
-  } id_to_lang[] = {
-    { "awk", "awk" },
-    { "c", "C" },
-    { "chdr", "C" },
-    { "cpp", "C++" },
-    { "js", "JavaScript" },
-    { "lisp", "Lisp" },
-    { "objc", "ObjectiveC" },
-    { "perl", "Perl" },
-    { "php", "PHP" },
-    { "python", "Python" },
-    { "sh", "Shell" },
-    { "tcl", "Tcl" },
-    { "vala", "Vala" }
-  };
-  gsize i;
-
-  if (id != NULL)
-    {
-      for (i = 0; i < G_N_ELEMENTS (id_to_lang); i++)
-        if (strcmp (id, id_to_lang[i].id) == 0)
-          return id_to_lang[i].lang;
-    }
-
-  return NULL;
-}
-
-static void
-populate_cache (DzlTaskCache  *cache,
-                gconstpointer  key,
-                GTask         *task,
-                gpointer       user_data)
-{
-  IdeGettextDiagnosticProvider *self = user_data;
-  g_autoptr(IdeUnsavedFile) unsaved_file = NULL;
-  g_autoptr(GSubprocess) subprocess = NULL;
-  GtkSourceLanguage *language;
-  const gchar *language_id;
-  const gchar *xgettext_lang;
-  const gchar *temp_path;
-  TranslationUnit *unit;
-  IdeFile *file = (IdeFile *)key;
-  GCancellable *cancellable;
-  g_autoptr(GError) error = NULL;
-  g_autoptr(GPtrArray) args = NULL;
-
-  g_assert (DZL_IS_TASK_CACHE (cache));
-  g_assert (IDE_IS_FILE (file));
-  g_assert (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (self));
-
-  cancellable = g_task_get_cancellable (task);
-  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
-
-  if (NULL == (unsaved_file = get_unsaved_file (self, file)))
-    {
-      g_task_return_new_error (task,
-                               G_IO_ERROR,
-                               G_IO_ERROR_NOT_FOUND,
-                               "Failed to locate file contents");
-      return;
-    }
-
-  if (NULL == (language = ide_file_get_language (file)) ||
-      NULL == (language_id = gtk_source_language_get_id (language)) ||
-      NULL == (xgettext_lang = id_to_xgettext_language (language_id)))
-    {
-      g_task_return_new_error (task,
-                               G_IO_ERROR,
-                               G_IO_ERROR_NOT_SUPPORTED,
-                               "Failed to determine language type");
-      return;
-    }
-
-  if (!ide_unsaved_file_persist (unsaved_file, cancellable, &error))
-    {
-      g_task_return_error (task, g_steal_pointer (&error));
-      return;
-    }
-
-  temp_path = ide_unsaved_file_get_temp_path (unsaved_file);
-
-  g_assert (temp_path != NULL);
-
-  args = g_ptr_array_new ();
-  g_ptr_array_add (args, "xgettext");
-  g_ptr_array_add (args, "--check=ellipsis-unicode");
-  g_ptr_array_add (args, "--check=quote-unicode");
-  g_ptr_array_add (args, "--check=space-ellipsis");
-  g_ptr_array_add (args, "-k_");
-  g_ptr_array_add (args, "-kN_");
-  g_ptr_array_add (args, "-L");
-  g_ptr_array_add (args, (gchar *)xgettext_lang);
-  g_ptr_array_add (args, "-o");
-  g_ptr_array_add (args, "-");
-  g_ptr_array_add (args, (gchar *)temp_path);
-  g_ptr_array_add (args, NULL);
-
-#ifdef IDE_ENABLE_TRACE
-  {
-    g_autofree gchar *str = NULL;
-    str = g_strjoinv (" ", (gchar **)args->pdata);
-    IDE_TRACE_MSG ("Launching '%s'", str);
-  }
-#endif
-
-  subprocess = g_subprocess_newv ((const gchar * const *)args->pdata,
-                                  G_SUBPROCESS_FLAGS_STDIN_PIPE
-                                  | G_SUBPROCESS_FLAGS_STDOUT_PIPE
-                                  | G_SUBPROCESS_FLAGS_STDERR_PIPE,
-                                  &error);
-
-  if (subprocess == NULL)
-    {
-      g_task_return_error (task, g_steal_pointer (&error));
-      return;
-    }
-
-  unit = g_slice_new0 (TranslationUnit);
-  unit->file = g_object_ref (file);
-  unit->unsaved_file = ide_unsaved_file_ref (unsaved_file);
-  g_task_set_task_data (task, unit, (GDestroyNotify)translation_unit_free);
-
-  g_subprocess_wait_async (subprocess,
-                           cancellable,
-                           subprocess_wait_cb,
-                           g_object_ref (task));
 }
 
 static void
 ide_gettext_diagnostic_provider_init (IdeGettextDiagnosticProvider *self)
 {
-  self->diagnostics_cache = dzl_task_cache_new ((GHashFunc)ide_file_hash,
-                                                (GEqualFunc)ide_file_equal,
-                                                g_object_ref,
-                                                g_object_unref,
-                                                g_object_ref,
-                                                g_object_unref,
-                                                20 * 1000L,
-                                                populate_cache,
-                                                self,
-                                                NULL);
-
-  dzl_task_cache_set_name (self->diagnostics_cache, "gettext diagnostic cache");
 }
diff --git a/src/plugins/gettext/ide-gettext-diagnostic-provider.h 
b/src/plugins/gettext/ide-gettext-diagnostic-provider.h
index 927585ee6..9dc4e08bb 100644
--- a/src/plugins/gettext/ide-gettext-diagnostic-provider.h
+++ b/src/plugins/gettext/ide-gettext-diagnostic-provider.h
@@ -1,6 +1,7 @@
 /* ide-gettext-diagnostic-provider.h
  *
  * Copyright © 2016 Daiki Ueno <dueno src gnome org>
+ * Copyright © 2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,10 +23,8 @@
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_GETTEXT_DIAGNOSTICS (ide_gettext_diagnostics_get_type ())
 #define IDE_TYPE_GETTEXT_DIAGNOSTIC_PROVIDER (ide_gettext_diagnostic_provider_get_type ())
 
-G_DECLARE_FINAL_TYPE (IdeGettextDiagnostics, ide_gettext_diagnostics, IDE, GETTEXT_DIAGNOSTICS, GObject)
 G_DECLARE_FINAL_TYPE (IdeGettextDiagnosticProvider, ide_gettext_diagnostic_provider, IDE, 
GETTEXT_DIAGNOSTIC_PROVIDER, IdeObject)
 
 G_END_DECLS


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