plugins/stylelint: port to run contexts
Christian Hergert
1 year, 7 months ago
32 | 32 | IdeDiagnosticTool parent_instance; |
33 | 33 | }; |
34 | 34 | |
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) | |
41 | 44 | { |
42 | 45 | GbpStylelintDiagnosticProvider *self = (GbpStylelintDiagnosticProvider *)tool; |
43 | 46 | |
44 | 47 | 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)); | |
46 | 49 | g_assert (G_IS_FILE (file)); |
47 | 50 | |
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")); | |
49 | 55 | 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; | |
52 | 60 | } |
53 | 61 | |
54 | 62 | static IdeDiagnosticSeverity |
135 | 143 | } |
136 | 144 | } |
137 | 145 | |
138 | G_DEFINE_FINAL_TYPE (GbpStylelintDiagnosticProvider, gbp_stylelint_diagnostic_provider, IDE_TYPE_DIAGNOSTIC_TOOL) | |
139 | ||
140 | 146 | static void |
141 | 147 | gbp_stylelint_diagnostic_provider_class_init (GbpStylelintDiagnosticProviderClass *klass) |
142 | 148 | { |
143 | 149 | IdeDiagnosticToolClass *diagnostic_tool_class = IDE_DIAGNOSTIC_TOOL_CLASS (klass); |
144 | 150 | |
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; | |
146 | 152 | diagnostic_tool_class->populate_diagnostics = gbp_stylelint_diagnostic_provider_populate_diagnostics; |
147 | 153 | } |
148 | 154 |