[gnome-builder] plugins/rust-analyzer: track refactoring changes in libide-foundry



commit 94921b7b490eb065bbb3d0a730bcfd9001aed9f6
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 11 23:17:06 2022 -0700

    plugins/rust-analyzer: track refactoring changes in libide-foundry

 .../rust-analyzer-completion-provider.c            |  37 +++-----
 .../rust-analyzer/rust-analyzer-pipeline-addin.c   |   5 +-
 src/plugins/rust-analyzer/rust-analyzer-plugin.c   |   4 +-
 .../rust-analyzer-preferences-addin.c              | 103 +++++++++++----------
 src/plugins/rust-analyzer/rust-analyzer-service.c  |  17 ++--
 src/plugins/rust-analyzer/rust-analyzer.plugin     |  10 +-
 6 files changed, 83 insertions(+), 93 deletions(-)
---
diff --git a/src/plugins/rust-analyzer/rust-analyzer-completion-provider.c 
b/src/plugins/rust-analyzer/rust-analyzer-completion-provider.c
index 88cbaa1ce..3c322689c 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-completion-provider.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-completion-provider.c
@@ -26,47 +26,32 @@ struct _RustAnalyzerCompletionProvider
   IdeLspCompletionProvider parent_instance;
 };
 
-static void provider_iface_init (IdeCompletionProviderInterface *iface);
-
-G_DEFINE_FINAL_TYPE_WITH_CODE (RustAnalyzerCompletionProvider,
-                         rust_analyzer_completion_provider,
-                         IDE_TYPE_LSP_COMPLETION_PROVIDER,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_COMPLETION_PROVIDER, provider_iface_init))
-
-static void
-rust_analyzer_completion_provider_class_init (RustAnalyzerCompletionProviderClass *klass)
-{
-}
+G_DEFINE_FINAL_TYPE (RustAnalyzerCompletionProvider, rust_analyzer_completion_provider, 
IDE_TYPE_LSP_COMPLETION_PROVIDER)
 
 static void
-rust_analyzer_completion_provider_init (RustAnalyzerCompletionProvider *self)
-{
-}
-
-static void
-rust_analyzer_completion_provider_load (IdeCompletionProvider *self,
-                                        IdeContext            *context)
+rust_analyzer_completion_provider_load (IdeLspCompletionProvider *provider)
 {
+  RustAnalyzerCompletionProvider *self = (RustAnalyzerCompletionProvider *)provider;
   RustAnalyzerService *service;
+  IdeContext *context;
 
   g_assert (RUST_IS_ANALYZER_COMPLETION_PROVIDER (self));
-  g_assert (IDE_IS_CONTEXT (context));
 
+  context = ide_object_get_context (IDE_OBJECT (self));
   service = rust_analyzer_service_from_context (context);
   g_object_bind_property (service, "client", self, "client", G_BINDING_SYNC_CREATE);
   rust_analyzer_service_ensure_started (service);
 }
 
-static gint
-rust_analyzer_completion_provider_get_priority (IdeCompletionProvider *provider,
-                                                IdeCompletionContext  *context)
+static void
+rust_analyzer_completion_provider_class_init (RustAnalyzerCompletionProviderClass *klass)
 {
-  return -1000;
+  IdeLspCompletionProviderClass *provider_class = IDE_LSP_COMPLETION_PROVIDER_CLASS (klass);
+
+  provider_class->load = rust_analyzer_completion_provider_load;
 }
 
 static void
-provider_iface_init (IdeCompletionProviderInterface *iface)
+rust_analyzer_completion_provider_init (RustAnalyzerCompletionProvider *self)
 {
-  iface->load = rust_analyzer_completion_provider_load;
-  iface->get_priority = rust_analyzer_completion_provider_get_priority;
 }
diff --git a/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c 
b/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c
index 099c5a46e..f7f18c390 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-pipeline-addin.c
@@ -98,10 +98,9 @@ find_cargo_toml_from_file (GFile *file)
 }
 
 static void
-rust_analyzer_pipeline_addin_discover_workdir_cb (GtkWidget *widget,
-                                                  gpointer   user_data)
+rust_analyzer_pipeline_addin_discover_workdir_cb (IdePage  *page,
+                                                  gpointer  user_data)
 {
-  IdePage *page = (IdePage *)widget;
   GFile **workdir = user_data;
   g_autoptr(GFile) file = NULL;
   g_autoptr(GFile) cargo_toml = NULL;
diff --git a/src/plugins/rust-analyzer/rust-analyzer-plugin.c 
b/src/plugins/rust-analyzer/rust-analyzer-plugin.c
index 61a5e35f0..c64bc15eb 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-plugin.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-plugin.c
@@ -47,7 +47,7 @@ _rust_analyzer_register_types (PeasObjectModule *module)
                                               IDE_TYPE_PIPELINE_ADDIN,
                                               RUST_TYPE_ANALYZER_PIPELINE_ADDIN);
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_COMPLETION_PROVIDER,
+                                              GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
                                               RUST_TYPE_ANALYZER_COMPLETION_PROVIDER);
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_SYMBOL_RESOLVER,
@@ -62,7 +62,7 @@ _rust_analyzer_register_types (PeasObjectModule *module)
                                               IDE_TYPE_HIGHLIGHTER,
                                               RUST_TYPE_ANALYZER_HIGHLIGHTER);
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_HOVER_PROVIDER,
+                                              GTK_SOURCE_TYPE_HOVER_PROVIDER,
                                               RUST_TYPE_ANALYZER_HOVER_PROVIDER);
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_RENAME_PROVIDER,
diff --git a/src/plugins/rust-analyzer/rust-analyzer-preferences-addin.c 
b/src/plugins/rust-analyzer/rust-analyzer-preferences-addin.c
index 93d50b42c..13cb83c91 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-preferences-addin.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-preferences-addin.c
@@ -18,76 +18,66 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include "rust-analyzer-preferences-addin.h"
+#define G_LOG_DOMAIN "rust-analyzer-preferences-addin"
+
+#include "config.h"
+
 #include <glib/gi18n.h>
 
+#include <libide-gui.h>
+
+#include "rust-analyzer-preferences-addin.h"
+
 struct _RustAnalyzerPreferencesAddin
 {
   IdeObject parent_instance;
-  guint check_id;
-  guint clippy_id;
 };
 
-static void preferences_addin_iface_init (IdePreferencesAddinInterface *iface);
-
-G_DEFINE_FINAL_TYPE_WITH_CODE (RustAnalyzerPreferencesAddin,
-                         rust_analyzer_preferences_addin,
-                         IDE_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN, preferences_addin_iface_init))
+static const IdePreferenceGroupEntry groups[] = {
+  { "insight", "rust-analyer", 2000, N_("Rust Analyzer") },
+};
 
-static void
-rust_analyzer_preferences_addin_class_init (RustAnalyzerPreferencesAddinClass *klass)
-{
-}
+static const IdePreferenceItemEntry items[] = {
+  { "insight", "rust-analyzer", "cargo-command-check", 0, ide_preferences_window_check,
+    N_("Cargo Check"),
+    N_("Run “cargo check” as the default cargo command"),
+    "org.gnome.builder.rust-analyzer", NULL, "cargo-command", "'check'" },
 
-static void
-rust_analyzer_preferences_addin_init (RustAnalyzerPreferencesAddin *self)
-{
-}
+  { "insight", "rust-analyzer", "cargo-command-clippy", 0, ide_preferences_window_check,
+    N_("Cargo Clippy"),
+    N_("Run “cargo clippy” as the default cargo command"),
+    "org.gnome.builder.rust-analyzer", NULL, "cargo-command", "'clippy'" },
+};
 
 static void
-rust_analyzer_preferences_addin_load (IdePreferencesAddin *addin,
-                                      DzlPreferences      *preferences)
+rust_analyzer_preferences_addin_load (IdePreferencesAddin  *addin,
+                                      IdePreferencesWindow *window,
+                                      IdeContext           *context)
 {
   RustAnalyzerPreferencesAddin *self = (RustAnalyzerPreferencesAddin *)addin;
 
+  IDE_ENTRY;
+
   g_return_if_fail (RUST_IS_ANALYZER_PREFERENCES_ADDIN (self));
-  g_return_if_fail (DZL_IS_PREFERENCES (preferences));
-
-  dzl_preferences_add_list_group (preferences, "code-insight", "rust-analyzer", _("Rust Analyzer: Cargo 
command for diagnostics"), GTK_SELECTION_NONE, 0);
-  self->check_id = dzl_preferences_add_radio (preferences,
-                                              "code-insight",
-                                              "rust-analyzer",
-                                              "org.gnome.builder.rust-analyzer",
-                                              "cargo-command",
-                                              NULL,
-                                              "\"check\"",
-                                              "Cargo check",
-                                              _("the default cargo command"),
-                                              NULL, 1);
-  self->clippy_id = dzl_preferences_add_radio (preferences,
-                                               "code-insight",
-                                               "rust-analyzer",
-                                               "org.gnome.builder.rust-analyzer",
-                                               "cargo-command",
-                                               NULL,
-                                               "\"clippy\"",
-                                               "Cargo clippy",
-                                               _("clippy adds additional lints to catch common mistakes but 
is in general slower"),
-                                               NULL, 2);
+  g_return_if_fail (IDE_IS_PREFERENCES_WINDOW (window));
+
+  ide_preferences_window_add_groups (window, groups, G_N_ELEMENTS (groups), NULL);
+  ide_preferences_window_add_items (window, items, G_N_ELEMENTS (items), window, NULL);
+
+  IDE_EXIT;
 }
 
 static void
-rust_analyzer_preferences_addin_unload (IdePreferencesAddin *addin,
-                                        DzlPreferences      *preferences)
+rust_analyzer_preferences_addin_unload (IdePreferencesAddin  *addin,
+                                        IdePreferencesWindow *window,
+                                        IdeContext           *context)
 {
-  RustAnalyzerPreferencesAddin *self = (RustAnalyzerPreferencesAddin *)addin;
+  IDE_ENTRY;
 
-  g_return_if_fail (RUST_IS_ANALYZER_PREFERENCES_ADDIN (self));
-  g_return_if_fail (DZL_IS_PREFERENCES (preferences));
+  g_return_if_fail (RUST_IS_ANALYZER_PREFERENCES_ADDIN (addin));
+  g_return_if_fail (IDE_IS_PREFERENCES_WINDOW (window));
 
-  dzl_preferences_remove_id (preferences, self->check_id);
-  dzl_preferences_remove_id (preferences, self->clippy_id);
+  IDE_EXIT;
 }
 
 static void
@@ -96,3 +86,18 @@ preferences_addin_iface_init (IdePreferencesAddinInterface *iface)
   iface->load = rust_analyzer_preferences_addin_load;
   iface->unload = rust_analyzer_preferences_addin_unload;
 }
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (RustAnalyzerPreferencesAddin,
+                               rust_analyzer_preferences_addin,
+                               IDE_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN, 
preferences_addin_iface_init))
+
+static void
+rust_analyzer_preferences_addin_class_init (RustAnalyzerPreferencesAddinClass *klass)
+{
+}
+
+static void
+rust_analyzer_preferences_addin_init (RustAnalyzerPreferencesAddin *self)
+{
+}
diff --git a/src/plugins/rust-analyzer/rust-analyzer-service.c 
b/src/plugins/rust-analyzer/rust-analyzer-service.c
index 261203c38..601fa93c8 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-service.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-service.c
@@ -23,7 +23,6 @@
 
 #include "config.h"
 
-#include <dazzle.h>
 #include <jsonrpc-glib.h>
 
 #include "rust-analyzer-pipeline-addin.h"
@@ -35,7 +34,7 @@ struct _RustAnalyzerService
   IdeWorkbench            *workbench;
   IdeLspClient            *client;
   IdeSubprocessSupervisor *supervisor;
-  DzlSignalGroup          *pipeline_signals;
+  IdeSignalGroup          *pipeline_signals;
   GSettings               *settings;
 };
 
@@ -82,13 +81,13 @@ rust_analyzer_service_pipeline_loaded_cb (RustAnalyzerService *self,
 static void
 rust_analyzer_service_bind_pipeline (RustAnalyzerService *self,
                                      IdePipeline         *pipeline,
-                                     DzlSignalGroup      *signal_group)
+                                     IdeSignalGroup      *signal_group)
 {
   IDE_ENTRY;
 
   g_assert (RUST_IS_ANALYZER_SERVICE (self));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (DZL_IS_SIGNAL_GROUP (signal_group));
+  g_assert (IDE_IS_SIGNAL_GROUP (signal_group));
 
   if (ide_pipeline_is_ready (pipeline))
     rust_analyzer_service_pipeline_loaded_cb (self, pipeline);
@@ -315,8 +314,8 @@ rust_analyzer_service_init (RustAnalyzerService *self)
                            self,
                            G_CONNECT_SWAPPED);
 
-  self->pipeline_signals = dzl_signal_group_new (IDE_TYPE_PIPELINE);
-  dzl_signal_group_connect_object (self->pipeline_signals,
+  self->pipeline_signals = ide_signal_group_new (IDE_TYPE_PIPELINE);
+  ide_signal_group_connect_object (self->pipeline_signals,
                                    "loaded",
                                    G_CALLBACK (rust_analyzer_service_pipeline_loaded_cb),
                                    self,
@@ -357,7 +356,7 @@ rust_analyzer_service_unload (IdeWorkbenchAddin *addin,
 
   self->workbench = NULL;
 
-  dzl_signal_group_set_target (self->pipeline_signals, NULL);
+  ide_signal_group_set_target (self->pipeline_signals, NULL);
 
   if (self->client != NULL)
     {
@@ -389,7 +388,7 @@ rust_analyzer_service_notify_pipeline_cb (RustAnalyzerService *self,
   g_assert (IDE_IS_BUILD_MANAGER (build_manager));
 
   pipeline = ide_build_manager_get_pipeline (build_manager);
-  dzl_signal_group_set_target (self->pipeline_signals, pipeline);
+  ide_signal_group_set_target (self->pipeline_signals, pipeline);
 
   IDE_EXIT;
 }
@@ -481,7 +480,7 @@ rust_analyzer_service_ensure_started (RustAnalyzerService *self)
   /* Try again (maybe new files opened) to see if we can get launcher
    * using a discovered Cargo.toml.
    */
-  if (!(pipeline = dzl_signal_group_get_target (self->pipeline_signals)) ||
+  if (!(pipeline = ide_signal_group_get_target (self->pipeline_signals)) ||
       !ide_pipeline_is_ready (pipeline))
     IDE_EXIT;
 
diff --git a/src/plugins/rust-analyzer/rust-analyzer.plugin b/src/plugins/rust-analyzer/rust-analyzer.plugin
index c554f8365..912e3943d 100644
--- a/src/plugins/rust-analyzer/rust-analyzer.plugin
+++ b/src/plugins/rust-analyzer/rust-analyzer.plugin
@@ -2,15 +2,17 @@
 Authors=Günther Wagner <info gunibert de>
 Builtin=true
 Copyright=Copyright © 2020 Günther Wagner
-Description=Provides auto-completion, diagnostics, and other IDE features
+Description=Provides integration with the rust-analzyer language server
 Module=rust-analyzer
 Embedded=_rust_analyzer_register_types
-Name=Rust Analyzer Language Server Integration
+Name=Rust Language Server
+X-Category=lsps
+X-Code-Action-Languages=rust
 X-Completion-Provider-Languages=rust
 X-Diagnostic-Provider-Languages=rust
-X-Symbol-Resolver-Languages=rust
 X-Formatter-Languages=rust
 X-Highlighter-Languages=rust
 X-Hover-Provider-Languages=rust
 X-Rename-Provider-Languages=rust
-X-Code-Action-Languages=rust
+X-Symbol-Resolver-Languages=rust
+X-Preferences-Kind=application;


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