[gnome-builder] plugins/stylelint: port to run contexts



commit 719a8d5a484dc3817aa27016c89c0c760755fe44
Author: Christian Hergert <chergert redhat com>
Date:   Thu Sep 22 00:23:19 2022 -0700

    plugins/stylelint: port to run contexts

 .../stylelint/gbp-stylelint-diagnostic-provider.c  | 32 +++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/plugins/stylelint/gbp-stylelint-diagnostic-provider.c 
b/src/plugins/stylelint/gbp-stylelint-diagnostic-provider.c
index e8976a216..9336afda8 100644
--- a/src/plugins/stylelint/gbp-stylelint-diagnostic-provider.c
+++ b/src/plugins/stylelint/gbp-stylelint-diagnostic-provider.c
@@ -33,23 +33,31 @@ struct _GbpStylelintDiagnosticProvider
   IdeDiagnosticTool parent_instance;
 };
 
-static void
-gbp_stylelint_diagnostic_provider_configure_launcher (IdeDiagnosticTool     *tool,
-                                                      IdeSubprocessLauncher *launcher,
-                                                      GFile                 *file,
-                                                      GBytes                *contents,
-                                                      const char            *language_id)
+G_DEFINE_FINAL_TYPE (GbpStylelintDiagnosticProvider, gbp_stylelint_diagnostic_provider, 
IDE_TYPE_DIAGNOSTIC_TOOL)
+
+static gboolean
+gbp_stylelint_diagnostic_provider_prepare_run_context (IdeDiagnosticTool  *tool,
+                                                       IdeRunContext      *run_context,
+                                                       GFile              *file,
+                                                       GBytes             *contents,
+                                                       const char         *language_id,
+                                                       GError            **error)
 {
   GbpStylelintDiagnosticProvider *self = (GbpStylelintDiagnosticProvider *)tool;
 
   g_assert (GBP_IS_STYLELINT_DIAGNOSTIC_PROVIDER (self));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
   g_assert (G_IS_FILE (file));
 
-  ide_subprocess_launcher_push_args (launcher, IDE_STRV_INIT ("--formatter", "json"));
+  if (!IDE_DIAGNOSTIC_TOOL_CLASS (gbp_stylelint_diagnostic_provider_parent_class)->prepare_run_context 
(tool, run_context, file, contents, language_id, error))
+    return FALSE;
+
+  ide_run_context_append_args (run_context, IDE_STRV_INIT ("--formatter", "json"));
   if (contents != NULL)
-    ide_subprocess_launcher_push_args (launcher, IDE_STRV_INIT ("--stdin", "--stdin-filename"));
-  ide_subprocess_launcher_push_argv (launcher, g_file_peek_path (file));
+    ide_run_context_append_args (run_context, IDE_STRV_INIT ("--stdin", "--stdin-filename"));
+  ide_run_context_append_argv (run_context, g_file_peek_path (file));
+
+  return TRUE;
 }
 
 static IdeDiagnosticSeverity
@@ -136,14 +144,12 @@ gbp_stylelint_diagnostic_provider_populate_diagnostics (IdeDiagnosticTool *tool,
     }
 }
 
-G_DEFINE_FINAL_TYPE (GbpStylelintDiagnosticProvider, gbp_stylelint_diagnostic_provider, 
IDE_TYPE_DIAGNOSTIC_TOOL)
-
 static void
 gbp_stylelint_diagnostic_provider_class_init (GbpStylelintDiagnosticProviderClass *klass)
 {
   IdeDiagnosticToolClass *diagnostic_tool_class = IDE_DIAGNOSTIC_TOOL_CLASS (klass);
 
-  diagnostic_tool_class->configure_launcher = gbp_stylelint_diagnostic_provider_configure_launcher;
+  diagnostic_tool_class->prepare_run_context = gbp_stylelint_diagnostic_provider_prepare_run_context;
   diagnostic_tool_class->populate_diagnostics = gbp_stylelint_diagnostic_provider_populate_diagnostics;
 }
 


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