[gnome-builder] rust-analyzer: notify the user



commit 5422b8119f4db58a494cb859c16c5bcca2ac650c
Author: Günther Wagner <info gunibert de>
Date:   Fri Jul 23 21:24:28 2021 +0200

    rust-analyzer: notify the user
    
    Notify the user about a missing rust-analyzer executable.

 src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c 
b/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c
index 063f7db2c..1f3634fc9 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <libide-gui.h>
+#include <libide-core.h>
 
 #include "rust-analyzer-pipeline-addin.h"
 
@@ -283,14 +284,22 @@ rust_analyzer_pipeline_addin_prepare (IdePipelineAddin *addin,
                                       IdePipeline      *pipeline)
 {
   RustAnalyzerPipelineAddin *self = (RustAnalyzerPipelineAddin *)addin;
+  IdeContext *context = NULL;
+  IdeBuildSystem *buildsystem = NULL;
   g_autoptr(GFile) cargo_home = NULL;
   g_autoptr(GFile) file = NULL;
+  g_autoptr(IdeNotification) notif = NULL;
 
   IDE_ENTRY;
 
   g_assert (RUST_IS_ANALYZER_PIPELINE_ADDIN (self));
   g_assert (IDE_IS_PIPELINE (pipeline));
 
+  context = ide_object_get_context (IDE_OBJECT (pipeline));
+  buildsystem = ide_build_system_from_context (context);
+  if (!ide_str_equal (ide_build_system_get_id (buildsystem), "cargo"))
+      IDE_EXIT;
+
   self->pipeline = pipeline;
 
   if (ide_pipeline_contains_program_in_path (pipeline, "rust-analyzer", NULL))
@@ -308,6 +317,13 @@ rust_analyzer_pipeline_addin_prepare (IdePipelineAddin *addin,
       IDE_EXIT;
     }
 
+  notif = ide_notification_new ();
+  ide_notification_set_id (notif, "org.gnome.builder.rust-analyzer");
+  ide_notification_set_title (notif, "Could not find rust-analyzer.");
+  ide_notification_set_body (notif, "Install rust-analyzer in your PATH or use the flatpak extension");
+  ide_notification_set_urgent (notif, TRUE);
+  ide_notification_attach (notif, IDE_OBJECT (pipeline));
+
   set_path (self, NULL, NULL);
 
   IDE_EXIT;


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