[gnome-builder] codespell: find codespell binary when loading provider
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] codespell: find codespell binary when loading provider
- Date: Sat, 1 Jan 2022 19:09:40 +0000 (UTC)
commit 5f12e8f0b33864c7396ccf102651a1d9aa567b76
Author: Christian Hergert <chergert redhat com>
Date: Sat Jan 1 10:53:27 2022 -0800
codespell: find codespell binary when loading provider
We don't need to keep running this. If someone actually installs codespell
while a document is open, then can just reopen the document to get the
plugin to recover.
.../codespell/ide-codespell-diagnostic-provider.c | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
---
diff --git a/src/plugins/codespell/ide-codespell-diagnostic-provider.c
b/src/plugins/codespell/ide-codespell-diagnostic-provider.c
index 94ff5abe3..c35afc81a 100644
--- a/src/plugins/codespell/ide-codespell-diagnostic-provider.c
+++ b/src/plugins/codespell/ide-codespell-diagnostic-provider.c
@@ -23,6 +23,7 @@
struct _IdeCodespellDiagnosticProvider
{
IdeObject parent_instance;
+ char *codespell_path;
};
static void diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface);
@@ -152,6 +153,15 @@ ide_codespell_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provide
ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
+ if (self->codespell_path == NULL)
+ {
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Not supported");
+ return;
+ }
+
launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDIN_PIPE |
G_SUBPROCESS_FLAGS_STDOUT_PIPE |
G_SUBPROCESS_FLAGS_STDERR_SILENCE);
@@ -186,9 +196,31 @@ ide_codespell_diagnostic_provider_diagnose_finish (IdeDiagnosticProvider *provi
return ide_task_propagate_pointer (IDE_TASK (result), error);
}
+static void
+ide_codespell_diagnostic_provider_load (IdeDiagnosticProvider *provider)
+{
+ IdeCodespellDiagnosticProvider *self = (IdeCodespellDiagnosticProvider *)provider;
+
+ g_assert (IDE_IS_CODESPELL_DIAGNOSTIC_PROVIDER (self));
+
+ self->codespell_path = g_find_program_in_path ("codespell");
+}
+
+static void
+ide_codespell_diagnostic_provider_unload (IdeDiagnosticProvider *provider)
+{
+ IdeCodespellDiagnosticProvider *self = (IdeCodespellDiagnosticProvider *)provider;
+
+ g_assert (IDE_IS_CODESPELL_DIAGNOSTIC_PROVIDER (self));
+
+ g_clear_pointer (&self->codespell_path, g_free);
+}
+
static void
diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
{
iface->diagnose_async = ide_codespell_diagnostic_provider_diagnose_async;
iface->diagnose_finish = ide_codespell_diagnostic_provider_diagnose_finish;
+ iface->load = ide_codespell_diagnostic_provider_load;
+ iface->unload = ide_codespell_diagnostic_provider_unload;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]