[gnome-builder] libide/lsp: remove configure_launcher use from plugins



commit 9ab71ad5eedaf0b58e26ade2b81b67d3b66ac9e8
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 6 17:14:05 2022 -0700

    libide/lsp: remove configure_launcher use from plugins
    
    We want to use prepare_run_context instead so we can alter things before
    the launcher is created (and possibly args joined into sh -c '' usage).

 .../bash-language-server/gbp-bash-service.c        | 12 +++---
 src/plugins/blueprint/gbp-blueprint-service.c      | 12 +++---
 src/plugins/gopls/gbp-gopls-service.c              | 44 ++++------------------
 .../intelephense/gbp-intelephense-service.c        | 13 +++----
 src/plugins/lua-language-server/gbp-lua-service.c  | 10 ++---
 .../rust-analyzer/gbp-rust-analyzer-service.c      | 15 --------
 src/plugins/ts-language-server/gbp-tslsp-service.c | 12 +++---
 7 files changed, 36 insertions(+), 82 deletions(-)
---
diff --git a/src/plugins/bash-language-server/gbp-bash-service.c 
b/src/plugins/bash-language-server/gbp-bash-service.c
index 04ed0803c..0ea0fdd26 100644
--- a/src/plugins/bash-language-server/gbp-bash-service.c
+++ b/src/plugins/bash-language-server/gbp-bash-service.c
@@ -48,17 +48,17 @@ gbp_bash_service_configure_client (IdeLspService *service,
 }
 
 static void
-gbp_bash_service_configure_launcher (IdeLspService         *service,
-                                     IdePipeline           *pipeline,
-                                     IdeSubprocessLauncher *launcher)
+gbp_bash_service_prepare_run_context (IdeLspService *service,
+                                      IdePipeline   *pipeline,
+                                      IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
   g_assert (GBP_IS_BASH_SERVICE (service));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
 
-  ide_subprocess_launcher_push_argv (launcher, "start");
+  ide_run_context_append_argv (run_context, "start");
 
   IDE_EXIT;
 }
@@ -69,7 +69,7 @@ gbp_bash_service_class_init (GbpBashServiceClass *klass)
   IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
 
   lsp_service_class->configure_client = gbp_bash_service_configure_client;
-  lsp_service_class->configure_launcher = gbp_bash_service_configure_launcher;
+  lsp_service_class->prepare_run_context = gbp_bash_service_prepare_run_context;
 }
 
 static void
diff --git a/src/plugins/blueprint/gbp-blueprint-service.c b/src/plugins/blueprint/gbp-blueprint-service.c
index 92339470e..5cfa38ba2 100644
--- a/src/plugins/blueprint/gbp-blueprint-service.c
+++ b/src/plugins/blueprint/gbp-blueprint-service.c
@@ -48,17 +48,17 @@ gbp_blueprint_service_configure_client (IdeLspService *service,
 }
 
 static void
-gbp_blueprint_service_configure_launcher (IdeLspService         *service,
-                                          IdePipeline           *pipeline,
-                                          IdeSubprocessLauncher *launcher)
+gbp_blueprint_service_prepare_run_context (IdeLspService *service,
+                                           IdePipeline   *pipeline,
+                                           IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
   g_assert (GBP_IS_BLUEPRINT_SERVICE (service));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
 
-  ide_subprocess_launcher_push_argv (launcher, "lsp");
+  ide_run_context_append_argv (run_context, "lsp");
 
   IDE_EXIT;
 }
@@ -69,7 +69,7 @@ gbp_blueprint_service_class_init (GbpBlueprintServiceClass *klass)
   IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
 
   lsp_service_class->configure_client = gbp_blueprint_service_configure_client;
-  lsp_service_class->configure_launcher = gbp_blueprint_service_configure_launcher;
+  lsp_service_class->prepare_run_context = gbp_blueprint_service_prepare_run_context;
 }
 
 static void
diff --git a/src/plugins/gopls/gbp-gopls-service.c b/src/plugins/gopls/gbp-gopls-service.c
index e5c2f276a..4b17193bd 100644
--- a/src/plugins/gopls/gbp-gopls-service.c
+++ b/src/plugins/gopls/gbp-gopls-service.c
@@ -51,47 +51,17 @@ gbp_gopls_service_configure_client (IdeLspService *service,
 }
 
 static void
-gbp_gopls_service_configure_launcher (IdeLspService         *service,
-                                      IdePipeline           *pipeline,
-                                      IdeSubprocessLauncher *launcher)
+gbp_gopls_service_prepare_run_context (IdeLspService *service,
+                                       IdePipeline   *pipeline,
+                                       IdeRunContext *run_context)
 {
-  const char *user_shell;
-
   IDE_ENTRY;
 
   g_assert (GBP_IS_GOPLS_SERVICE (service));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
-
-  /* First add our necessary "serve" argument */
-  ide_subprocess_launcher_push_argv (launcher, "serve");
-
-  /* Bash will load the host $PATH and $GOPATH (and optionally $GOROOT)
-   * for us.  This does mean there will be a possible .bashrc vs
-   * .bash_profile discrepancy. Possibly there is a better native way to
-   * make sure that builder running in flatpak can run processes in the
-   * host context with the host's $PATH.
-   */
-
-  /* Now we need to convert the arguments into something we can pass to
-   * $SHELL --login -c if the shell supports that.
-   */
-  if ((user_shell = ide_get_user_shell ()) &&
-      ide_shell_supports_dash_c (user_shell) &&
-      ide_shell_supports_dash_login (user_shell))
-    {
-      const char * const *argv = ide_subprocess_launcher_get_argv (launcher);
-      g_autoptr(GPtrArray) ar = g_ptr_array_new_with_free_func (g_free);
-      g_autofree char *quoted = NULL;
-
-      for (guint i = 0; argv[i]; i++)
-        g_ptr_array_add (ar, g_shell_quote (argv[i]));
-      g_ptr_array_add (ar, NULL);
-
-      quoted = g_strjoinv (" ", (char **)(gpointer)ar->pdata);
-      ide_subprocess_launcher_set_argv (launcher,
-                                        IDE_STRV_INIT (user_shell, "-l", "-c", quoted));
-    }
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
+
+  ide_run_context_append_argv (run_context, "serve");
 
   IDE_EXIT;
 }
@@ -102,7 +72,7 @@ gbp_gopls_service_class_init (GbpGoplsServiceClass *klass)
   IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
 
   lsp_service_class->configure_client = gbp_gopls_service_configure_client;
-  lsp_service_class->configure_launcher = gbp_gopls_service_configure_launcher;
+  lsp_service_class->prepare_run_context = gbp_gopls_service_prepare_run_context;
 }
 
 static void
diff --git a/src/plugins/intelephense/gbp-intelephense-service.c 
b/src/plugins/intelephense/gbp-intelephense-service.c
index 1ff9f262d..6b3bf3be6 100644
--- a/src/plugins/intelephense/gbp-intelephense-service.c
+++ b/src/plugins/intelephense/gbp-intelephense-service.c
@@ -140,18 +140,17 @@ gbp_intelephense_service_configure_client (IdeLspService *service,
 }
 
 static void
-gbp_intelephense_service_configure_launcher (IdeLspService         *service,
-                                             IdePipeline           *pipeline,
-                                             IdeSubprocessLauncher *launcher)
+gbp_intelephense_service_prepare_run_context (IdeLspService *service,
+                                              IdePipeline   *pipeline,
+                                              IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
   g_assert (IDE_IS_LSP_SERVICE (service));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
 
-  ide_subprocess_launcher_push_argv (launcher, "--stdio");
-  ide_subprocess_launcher_append_path (launcher, "/app/bin");
+  ide_run_context_append_argv (run_context, "--stdio");
 
   IDE_EXIT;
 }
@@ -175,7 +174,7 @@ gbp_intelephense_service_class_init (GbpIntelephenseServiceClass *klass)
   object_class->dispose = gbp_intelephense_service_dispose;
 
   lsp_service_class->configure_client = gbp_intelephense_service_configure_client;
-  lsp_service_class->configure_launcher = gbp_intelephense_service_configure_launcher;
+  lsp_service_class->prepare_run_context = gbp_intelephense_service_prepare_run_context;
 }
 
 static void
diff --git a/src/plugins/lua-language-server/gbp-lua-service.c 
b/src/plugins/lua-language-server/gbp-lua-service.c
index cc919ea9d..e8486f925 100644
--- a/src/plugins/lua-language-server/gbp-lua-service.c
+++ b/src/plugins/lua-language-server/gbp-lua-service.c
@@ -48,15 +48,15 @@ gbp_lua_service_configure_client (IdeLspService *service,
 }
 
 static void
-gbp_lua_service_configure_launcher (IdeLspService         *service,
-                                    IdePipeline           *pipeline,
-                                    IdeSubprocessLauncher *launcher)
+gbp_lua_service_prepare_run_context (IdeLspService *service,
+                                     IdePipeline   *pipeline,
+                                     IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
   g_assert (GBP_IS_LUA_SERVICE (service));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
 
   /* Options:
    *
@@ -79,7 +79,7 @@ gbp_lua_service_class_init (GbpLuaServiceClass *klass)
   IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
 
   lsp_service_class->configure_client = gbp_lua_service_configure_client;
-  lsp_service_class->configure_launcher = gbp_lua_service_configure_launcher;
+  lsp_service_class->prepare_run_context = gbp_lua_service_prepare_run_context;
 }
 
 static void
diff --git a/src/plugins/rust-analyzer/gbp-rust-analyzer-service.c 
b/src/plugins/rust-analyzer/gbp-rust-analyzer-service.c
index 3b60aed1d..08af4b950 100644
--- a/src/plugins/rust-analyzer/gbp-rust-analyzer-service.c
+++ b/src/plugins/rust-analyzer/gbp-rust-analyzer-service.c
@@ -173,20 +173,6 @@ gbp_rust_analyzer_service_configure_client (IdeLspService *service,
   IDE_EXIT;
 }
 
-static void
-gbp_rust_analyzer_service_configure_launcher (IdeLspService         *service,
-                                              IdePipeline           *pipeline,
-                                              IdeSubprocessLauncher *launcher)
-{
-  IDE_ENTRY;
-
-  g_assert (GBP_IS_RUST_ANALYZER_SERVICE (service));
-  g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
-
-  IDE_EXIT;
-}
-
 static void
 gbp_rust_analyzer_service_dispose (GObject *object)
 {
@@ -207,7 +193,6 @@ gbp_rust_analyzer_service_class_init (GbpRustAnalyzerServiceClass *klass)
   object_class->dispose = gbp_rust_analyzer_service_dispose;
 
   lsp_service_class->configure_client = gbp_rust_analyzer_service_configure_client;
-  lsp_service_class->configure_launcher = gbp_rust_analyzer_service_configure_launcher;
 }
 
 static void
diff --git a/src/plugins/ts-language-server/gbp-tslsp-service.c 
b/src/plugins/ts-language-server/gbp-tslsp-service.c
index cba1f9b78..e056f265e 100644
--- a/src/plugins/ts-language-server/gbp-tslsp-service.c
+++ b/src/plugins/ts-language-server/gbp-tslsp-service.c
@@ -51,17 +51,17 @@ gbp_tslsp_service_configure_client (IdeLspService *service,
 }
 
 static void
-gbp_tslsp_service_configure_launcher (IdeLspService         *service,
-                                      IdePipeline           *pipeline,
-                                      IdeSubprocessLauncher *launcher)
+gbp_tslsp_service_prepare_run_context (IdeLspService *service,
+                                       IdePipeline   *pipeline,
+                                       IdeRunContext *run_context)
 {
   IDE_ENTRY;
 
   g_assert (GBP_IS_TSLSP_SERVICE (service));
   g_assert (IDE_IS_PIPELINE (pipeline));
-  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+  g_assert (IDE_IS_RUN_CONTEXT (run_context));
 
-  ide_subprocess_launcher_push_argv (launcher, "--stdio");
+  ide_run_context_append_argv (run_context, "--stdio");
 
   IDE_EXIT;
 }
@@ -72,7 +72,7 @@ gbp_tslsp_service_class_init (GbpTslspServiceClass *klass)
   IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
 
   lsp_service_class->configure_client = gbp_tslsp_service_configure_client;
-  lsp_service_class->configure_launcher= gbp_tslsp_service_configure_launcher;
+  lsp_service_class->prepare_run_context = gbp_tslsp_service_prepare_run_context;
 }
 
 static void


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