[gnome-builder/wip/gtk4-port] plugins/blueprint: port plugin to C



commit 5218ad84056d7ca63e11e22109193424eae7334f
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 24 14:51:42 2022 -0700

    plugins/blueprint: port plugin to C
    
    Ongoing work for #1670

 src/plugins/blueprint/blueprint-plugin.c           | 52 ++++++++++++++
 src/plugins/blueprint/blueprint.gresource.xml      |  9 +++
 src/plugins/blueprint/blueprint.plugin             |  5 +-
 src/plugins/blueprint/blueprint_plugin.py          | 38 -----------
 .../blueprint/gbp-blueprint-code-action-provider.c | 65 ++++++++++++++++++
 .../blueprint/gbp-blueprint-code-action-provider.h | 31 +++++++++
 .../blueprint/gbp-blueprint-completion-provider.c  | 75 ++++++++++++++++++++
 .../blueprint/gbp-blueprint-completion-provider.h  | 31 +++++++++
 .../blueprint/gbp-blueprint-diagnostic-provider.c  | 65 ++++++++++++++++++
 .../blueprint/gbp-blueprint-diagnostic-provider.h  | 31 +++++++++
 .../blueprint/gbp-blueprint-hover-provider.c       | 66 ++++++++++++++++++
 .../blueprint/gbp-blueprint-hover-provider.h       | 31 +++++++++
 src/plugins/blueprint/gbp-blueprint-service.c      | 79 ++++++++++++++++++++++
 src/plugins/blueprint/gbp-blueprint-service.h      | 31 +++++++++
 src/plugins/blueprint/meson.build                  | 22 +++---
 15 files changed, 581 insertions(+), 50 deletions(-)
---
diff --git a/src/plugins/blueprint/blueprint-plugin.c b/src/plugins/blueprint/blueprint-plugin.c
new file mode 100644
index 000000000..5a9b8c5cd
--- /dev/null
+++ b/src/plugins/blueprint/blueprint-plugin.c
@@ -0,0 +1,52 @@
+/* blueprint-plugin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "blueprint-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-lsp.h>
+
+#include "gbp-blueprint-service.h"
+#include "gbp-blueprint-completion-provider.h"
+#include "gbp-blueprint-diagnostic-provider.h"
+#include "gbp-blueprint-hover-provider.h"
+#include "gbp-blueprint-code-action-provider.h"
+
+_IDE_EXTERN void
+_gbp_blueprint_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_DIAGNOSTIC_PROVIDER,
+                                              GBP_TYPE_BLUEPRINT_DIAGNOSTIC_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+                                              GBP_TYPE_BLUEPRINT_COMPLETION_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_HOVER_PROVIDER,
+                                              GBP_TYPE_BLUEPRINT_HOVER_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_CODE_ACTION_PROVIDER,
+                                              GBP_TYPE_BLUEPRINT_CODE_ACTION_PROVIDER);
+}
diff --git a/src/plugins/blueprint/blueprint.gresource.xml b/src/plugins/blueprint/blueprint.gresource.xml
new file mode 100644
index 000000000..d78f4b8cf
--- /dev/null
+++ b/src/plugins/blueprint/blueprint.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/blueprint">
+    <file>blueprint.plugin</file>
+  </gresource>
+  <gresource prefix="/org/gnome/builder/gtksourceview/language-specs">
+    <file>blueprint.lang</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/blueprint/blueprint.plugin b/src/plugins/blueprint/blueprint.plugin
index 705994973..95d2b0b75 100644
--- a/src/plugins/blueprint/blueprint.plugin
+++ b/src/plugins/blueprint/blueprint.plugin
@@ -1,10 +1,9 @@
 [Plugin]
 Builtin=true
 Description=Provides integration with the blueprint language server
-Loader=python3
-Module=blueprint_plugin
+Embedded=_gbp_blueprint_register_types
+Module=blueprint
 Name=Blueprint Language Server
-X-Builder-ABI=@PACKAGE_ABI@
 X-Category=lsps
 X-Code-Action-Languages=blueprint
 X-Completion-Provider-Languages=blueprint
diff --git a/src/plugins/blueprint/gbp-blueprint-code-action-provider.c 
b/src/plugins/blueprint/gbp-blueprint-code-action-provider.c
new file mode 100644
index 000000000..07256a051
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-code-action-provider.c
@@ -0,0 +1,65 @@
+/* gbp-blueprint-code-action-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-blueprint-code-action-provider"
+
+#include "config.h"
+
+#include "gbp-blueprint-code-action-provider.h"
+#include "gbp-blueprint-service.h"
+
+struct _GbpBlueprintCodeActionProvider
+{
+  IdeLspCodeActionProvider parent_instance;
+};
+
+static void
+gbp_blueprint_code_action_provider_load (IdeCodeActionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BLUEPRINT_CODE_ACTION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BLUEPRINT_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+code_action_provider_iface_init (IdeCodeActionProviderInterface *iface)
+{
+  iface->load = gbp_blueprint_code_action_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBlueprintCodeActionProvider, gbp_blueprint_code_action_provider, 
IDE_TYPE_LSP_CODE_ACTION_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_CODE_ACTION_PROVIDER, 
code_action_provider_iface_init))
+
+static void
+gbp_blueprint_code_action_provider_class_init (GbpBlueprintCodeActionProviderClass *klass)
+{
+}
+
+static void
+gbp_blueprint_code_action_provider_init (GbpBlueprintCodeActionProvider *self)
+{
+}
diff --git a/src/plugins/blueprint/gbp-blueprint-code-action-provider.h 
b/src/plugins/blueprint/gbp-blueprint-code-action-provider.h
new file mode 100644
index 000000000..90fb76924
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-code-action-provider.h
@@ -0,0 +1,31 @@
+/* gbp-blueprint-code-action-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_BLUEPRINT_CODE_ACTION_PROVIDER (gbp_blueprint_code_action_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBlueprintCodeActionProvider, gbp_blueprint_code_action_provider, GBP, 
BLUEPRINT_CODE_ACTION_PROVIDER, IdeLspCodeActionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/blueprint/gbp-blueprint-completion-provider.c 
b/src/plugins/blueprint/gbp-blueprint-completion-provider.c
new file mode 100644
index 000000000..bf9809b42
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-completion-provider.c
@@ -0,0 +1,75 @@
+/* gbp-blueprint-completion-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-blueprint-completion-provider"
+
+#include "config.h"
+
+#include "gbp-blueprint-completion-provider.h"
+#include "gbp-blueprint-service.h"
+
+struct _GbpBlueprintCompletionProvider
+{
+  IdeLspCompletionProvider parent_instance;
+};
+
+static void
+gbp_blueprint_completion_provider_load (IdeLspCompletionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BLUEPRINT_COMPLETION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BLUEPRINT_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static int
+gbp_blueprint_completion_provider_get_priority (GtkSourceCompletionProvider *provider,
+                                           GtkSourceCompletionContext  *context)
+{
+  return -1000;
+}
+
+static void
+completion_provider_iface_init (GtkSourceCompletionProviderInterface *iface)
+{
+  iface->get_priority = gbp_blueprint_completion_provider_get_priority;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBlueprintCompletionProvider, gbp_blueprint_completion_provider, 
IDE_TYPE_LSP_COMPLETION_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER, 
completion_provider_iface_init))
+
+static void
+gbp_blueprint_completion_provider_class_init (GbpBlueprintCompletionProviderClass *klass)
+{
+  IdeLspCompletionProviderClass *lsp_completion_provider_class = IDE_LSP_COMPLETION_PROVIDER_CLASS (klass);
+
+  lsp_completion_provider_class->load = gbp_blueprint_completion_provider_load;
+}
+
+static void
+gbp_blueprint_completion_provider_init (GbpBlueprintCompletionProvider *self)
+{
+}
diff --git a/src/plugins/blueprint/gbp-blueprint-completion-provider.h 
b/src/plugins/blueprint/gbp-blueprint-completion-provider.h
new file mode 100644
index 000000000..b26cf4ca2
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-completion-provider.h
@@ -0,0 +1,31 @@
+/* gbp-blueprint-completion-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_BLUEPRINT_COMPLETION_PROVIDER (gbp_blueprint_completion_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBlueprintCompletionProvider, gbp_blueprint_completion_provider, GBP, 
BLUEPRINT_COMPLETION_PROVIDER, IdeLspCompletionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/blueprint/gbp-blueprint-diagnostic-provider.c 
b/src/plugins/blueprint/gbp-blueprint-diagnostic-provider.c
new file mode 100644
index 000000000..e9324978e
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-diagnostic-provider.c
@@ -0,0 +1,65 @@
+/* gbp-blueprint-diagnostic-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-blueprint-diagnostic-provider"
+
+#include "config.h"
+
+#include "gbp-blueprint-diagnostic-provider.h"
+#include "gbp-blueprint-service.h"
+
+struct _GbpBlueprintDiagnosticProvider
+{
+  IdeLspDiagnosticProvider parent_instance;
+};
+
+static void
+gbp_blueprint_diagnostic_provider_load (IdeDiagnosticProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BLUEPRINT_DIAGNOSTIC_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_BLUEPRINT_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
+{
+  iface->load = gbp_blueprint_diagnostic_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpBlueprintDiagnosticProvider, gbp_blueprint_diagnostic_provider, 
IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER, 
diagnostic_provider_iface_init))
+
+static void
+gbp_blueprint_diagnostic_provider_class_init (GbpBlueprintDiagnosticProviderClass *klass)
+{
+}
+
+static void
+gbp_blueprint_diagnostic_provider_init (GbpBlueprintDiagnosticProvider *self)
+{
+}
diff --git a/src/plugins/blueprint/gbp-blueprint-diagnostic-provider.h 
b/src/plugins/blueprint/gbp-blueprint-diagnostic-provider.h
new file mode 100644
index 000000000..e70dce7ac
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-diagnostic-provider.h
@@ -0,0 +1,31 @@
+/* gbp-blueprint-diagnostic-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_BLUEPRINT_DIAGNOSTIC_PROVIDER (gbp_blueprint_diagnostic_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBlueprintDiagnosticProvider, gbp_blueprint_diagnostic_provider, GBP, 
BLUEPRINT_DIAGNOSTIC_PROVIDER, IdeLspDiagnosticProvider)
+
+G_END_DECLS
diff --git a/src/plugins/blueprint/gbp-blueprint-hover-provider.c 
b/src/plugins/blueprint/gbp-blueprint-hover-provider.c
new file mode 100644
index 000000000..fa89c7eea
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-hover-provider.c
@@ -0,0 +1,66 @@
+/* gbp-blueprint-hover-provider.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-blueprint-hover-provider"
+
+#include "config.h"
+
+#include "gbp-blueprint-hover-provider.h"
+#include "gbp-blueprint-service.h"
+
+struct _GbpBlueprintHoverProvider
+{
+  IdeLspHoverProvider parent_instance;
+};
+
+static void
+gbp_blueprint_hover_provider_prepare (IdeLspHoverProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BLUEPRINT_HOVER_PROVIDER (provider));
+
+  g_object_set (provider,
+                "category", "Blueprint",
+                "priority", 100,
+                NULL);
+
+  klass = g_type_class_ref (GBP_TYPE_BLUEPRINT_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+G_DEFINE_FINAL_TYPE (GbpBlueprintHoverProvider, gbp_blueprint_hover_provider, IDE_TYPE_LSP_HOVER_PROVIDER)
+
+static void
+gbp_blueprint_hover_provider_class_init (GbpBlueprintHoverProviderClass *klass)
+{
+  IdeLspHoverProviderClass *lsp_hover_provider_class = IDE_LSP_HOVER_PROVIDER_CLASS (klass);
+
+  lsp_hover_provider_class->prepare = gbp_blueprint_hover_provider_prepare;
+}
+
+static void
+gbp_blueprint_hover_provider_init (GbpBlueprintHoverProvider *self)
+{
+}
diff --git a/src/plugins/blueprint/gbp-blueprint-hover-provider.h 
b/src/plugins/blueprint/gbp-blueprint-hover-provider.h
new file mode 100644
index 000000000..55a84f9a9
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-hover-provider.h
@@ -0,0 +1,31 @@
+/* gbp-blueprint-hover-provider.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_BLUEPRINT_HOVER_PROVIDER (gbp_blueprint_hover_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBlueprintHoverProvider, gbp_blueprint_hover_provider, GBP, 
BLUEPRINT_HOVER_PROVIDER, IdeLspHoverProvider)
+
+G_END_DECLS
diff --git a/src/plugins/blueprint/gbp-blueprint-service.c b/src/plugins/blueprint/gbp-blueprint-service.c
new file mode 100644
index 000000000..92339470e
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-service.c
@@ -0,0 +1,79 @@
+/* gbp-blueprint-service.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-blueprint-service"
+
+#include "config.h"
+
+#include <jsonrpc-glib.h>
+
+#include "gbp-blueprint-service.h"
+
+struct _GbpBlueprintService
+{
+  IdeLspService parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpBlueprintService, gbp_blueprint_service, IDE_TYPE_LSP_SERVICE)
+
+static void
+gbp_blueprint_service_configure_client (IdeLspService *service,
+                                        IdeLspClient  *client)
+{
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BLUEPRINT_SERVICE (service));
+  g_assert (IDE_IS_LSP_CLIENT (client));
+
+  ide_lsp_client_add_language (client, "blueprint");
+
+  IDE_EXIT;
+}
+
+static void
+gbp_blueprint_service_configure_launcher (IdeLspService         *service,
+                                          IdePipeline           *pipeline,
+                                          IdeSubprocessLauncher *launcher)
+{
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BLUEPRINT_SERVICE (service));
+  g_assert (IDE_IS_PIPELINE (pipeline));
+  g_assert (IDE_IS_SUBPROCESS_LAUNCHER (launcher));
+
+  ide_subprocess_launcher_push_argv (launcher, "lsp");
+
+  IDE_EXIT;
+}
+
+static void
+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;
+}
+
+static void
+gbp_blueprint_service_init (GbpBlueprintService *self)
+{
+  ide_lsp_service_set_program (IDE_LSP_SERVICE (self), "blueprint-compiler");
+}
diff --git a/src/plugins/blueprint/gbp-blueprint-service.h b/src/plugins/blueprint/gbp-blueprint-service.h
new file mode 100644
index 000000000..3117bcba7
--- /dev/null
+++ b/src/plugins/blueprint/gbp-blueprint-service.h
@@ -0,0 +1,31 @@
+/* gbp-blueprint-service.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-lsp.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_BLUEPRINT_SERVICE (gbp_blueprint_service_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpBlueprintService, gbp_blueprint_service, GBP, BLUEPRINT_SERVICE, IdeLspService)
+
+G_END_DECLS
diff --git a/src/plugins/blueprint/meson.build b/src/plugins/blueprint/meson.build
index 930e1017f..5581e4f70 100644
--- a/src/plugins/blueprint/meson.build
+++ b/src/plugins/blueprint/meson.build
@@ -1,16 +1,20 @@
 if get_option('plugin_blueprint')
 
-install_data('blueprint_plugin.py', install_dir: plugindir)
+plugins_sources += files([
+  'blueprint-plugin.c',
+  'gbp-blueprint-code-action-provider.c',
+  'gbp-blueprint-completion-provider.c',
+  'gbp-blueprint-diagnostic-provider.c',
+  'gbp-blueprint-hover-provider.c',
+  'gbp-blueprint-service.c',
+])
 
-configure_file(
-          input: 'blueprint.plugin',
-         output: 'blueprint.plugin',
-  configuration: config_h,
-        install: true,
-    install_dir: plugindir,
+plugin_blueprint_resources = gnome.compile_resources(
+  'blueprint-resources',
+  'blueprint.gresource.xml',
+  c_name: 'gbp_blueprint',
 )
 
-install_data('blueprint.lang',
-  install_dir: join_paths(get_option('datadir'), 'gtksourceview-4' / 'language-specs'))
+plugins_sources += plugin_blueprint_resources
 
 endif


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