Codebase list gnome-builder / 672815a
plugins/stylelint: port to run contexts Christian Hergert 1 year, 7 months ago
1 changed file(s) with 19 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
3232 IdeDiagnosticTool parent_instance;
3333 };
3434
35 static void
36 gbp_stylelint_diagnostic_provider_configure_launcher (IdeDiagnosticTool *tool,
37 IdeSubprocessLauncher *launcher,
38 GFile *file,
39 GBytes *contents,
40 const char *language_id)
35 G_DEFINE_FINAL_TYPE (GbpStylelintDiagnosticProvider, gbp_stylelint_diagnostic_provider, IDE_TYPE_DIAGNOSTIC_TOOL)
36
37 static gboolean
38 gbp_stylelint_diagnostic_provider_prepare_run_context (IdeDiagnosticTool *tool,
39 IdeRunContext *run_context,
40 GFile *file,
41 GBytes *contents,
42 const char *language_id,
43 GError **error)
4144 {
4245 GbpStylelintDiagnosticProvider *self = (GbpStylelintDiagnosticProvider *)tool;
4346
4447 g_assert (GBP_IS_STYLELINT_DIAGNOSTIC_PROVIDER (self));
45 g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
48 g_assert (IDE_IS_RUN_CONTEXT (run_context));
4649 g_assert (G_IS_FILE (file));
4750
48 ide_subprocess_launcher_push_args (launcher, IDE_STRV_INIT ("--formatter", "json"));
51 if (!IDE_DIAGNOSTIC_TOOL_CLASS (gbp_stylelint_diagnostic_provider_parent_class)->prepare_run_context (tool, run_context, file, contents, language_id, error))
52 return FALSE;
53
54 ide_run_context_append_args (run_context, IDE_STRV_INIT ("--formatter", "json"));
4955 if (contents != NULL)
50 ide_subprocess_launcher_push_args (launcher, IDE_STRV_INIT ("--stdin", "--stdin-filename"));
51 ide_subprocess_launcher_push_argv (launcher, g_file_peek_path (file));
56 ide_run_context_append_args (run_context, IDE_STRV_INIT ("--stdin", "--stdin-filename"));
57 ide_run_context_append_argv (run_context, g_file_peek_path (file));
58
59 return TRUE;
5260 }
5361
5462 static IdeDiagnosticSeverity
135143 }
136144 }
137145
138 G_DEFINE_FINAL_TYPE (GbpStylelintDiagnosticProvider, gbp_stylelint_diagnostic_provider, IDE_TYPE_DIAGNOSTIC_TOOL)
139
140146 static void
141147 gbp_stylelint_diagnostic_provider_class_init (GbpStylelintDiagnosticProviderClass *klass)
142148 {
143149 IdeDiagnosticToolClass *diagnostic_tool_class = IDE_DIAGNOSTIC_TOOL_CLASS (klass);
144150
145 diagnostic_tool_class->configure_launcher = gbp_stylelint_diagnostic_provider_configure_launcher;
151 diagnostic_tool_class->prepare_run_context = gbp_stylelint_diagnostic_provider_prepare_run_context;
146152 diagnostic_tool_class->populate_diagnostics = gbp_stylelint_diagnostic_provider_populate_diagnostics;
147153 }
148154