[gnome-builder/wip/gtk4-port] plugins/jedi-language-server: port jedi plugin to C



commit 0d66befc3211859481fd92601bac6e2cc8f99c90
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 24 02:39:37 2022 -0700

    plugins/jedi-language-server: port jedi plugin to C
    
    Following the clangd and vala-language-server plugins with a port to C.

 .../gbp-jedi-code-action-provider.c                | 65 +++++++++++++++++
 .../gbp-jedi-code-action-provider.h                | 31 ++++++++
 .../gbp-jedi-completion-provider.c                 | 75 +++++++++++++++++++
 .../gbp-jedi-completion-provider.h                 | 31 ++++++++
 .../gbp-jedi-diagnostic-provider.c                 | 65 +++++++++++++++++
 .../gbp-jedi-diagnostic-provider.h                 | 31 ++++++++
 .../jedi-language-server/gbp-jedi-formatter.c      | 65 +++++++++++++++++
 .../jedi-language-server/gbp-jedi-formatter.h      | 31 ++++++++
 .../jedi-language-server/gbp-jedi-highlighter.c    | 65 +++++++++++++++++
 .../jedi-language-server/gbp-jedi-highlighter.h    | 31 ++++++++
 .../jedi-language-server/gbp-jedi-hover-provider.c | 66 +++++++++++++++++
 .../jedi-language-server/gbp-jedi-hover-provider.h | 31 ++++++++
 .../gbp-jedi-rename-provider.c                     | 65 +++++++++++++++++
 .../gbp-jedi-rename-provider.h                     | 31 ++++++++
 .../jedi-language-server/gbp-jedi-service.c        | 69 ++++++++++++++++++
 .../jedi-language-server/gbp-jedi-service.h        | 31 ++++++++
 .../gbp-jedi-symbol-resolver.c                     | 65 +++++++++++++++++
 .../gbp-jedi-symbol-resolver.h                     | 31 ++++++++
 .../jedi-language-server-plugin.c                  | 70 ++++++++++++++++++
 .../jedi-language-server.gresource.xml             |  6 ++
 .../jedi-language-server.plugin                    |  7 +-
 .../jedi_language_server_plugin.py                 | 83 ----------------------
 src/plugins/jedi-language-server/meson.build       | 27 ++++---
 23 files changed, 977 insertions(+), 95 deletions(-)
---
diff --git a/src/plugins/jedi-language-server/gbp-jedi-code-action-provider.c 
b/src/plugins/jedi-language-server/gbp-jedi-code-action-provider.c
new file mode 100644
index 000000000..35c477a6c
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-code-action-provider.c
@@ -0,0 +1,65 @@
+/* gbp-jedi-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-jedi-code-action-provider"
+
+#include "config.h"
+
+#include "gbp-jedi-code-action-provider.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediCodeActionProvider
+{
+  IdeLspCodeActionProvider parent_instance;
+};
+
+static void
+gbp_jedi_code_action_provider_load (IdeCodeActionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_CODE_ACTION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_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_jedi_code_action_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediCodeActionProvider, gbp_jedi_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_jedi_code_action_provider_class_init (GbpJediCodeActionProviderClass *klass)
+{
+}
+
+static void
+gbp_jedi_code_action_provider_init (GbpJediCodeActionProvider *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-code-action-provider.h 
b/src/plugins/jedi-language-server/gbp-jedi-code-action-provider.h
new file mode 100644
index 000000000..a48ea1d9e
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-code-action-provider.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-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_JEDI_CODE_ACTION_PROVIDER (gbp_jedi_code_action_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediCodeActionProvider, gbp_jedi_code_action_provider, GBP, 
JEDI_CODE_ACTION_PROVIDER, IdeLspCodeActionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-completion-provider.c 
b/src/plugins/jedi-language-server/gbp-jedi-completion-provider.c
new file mode 100644
index 000000000..98b258702
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-completion-provider.c
@@ -0,0 +1,75 @@
+/* gbp-jedi-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-jedi-completion-provider"
+
+#include "config.h"
+
+#include "gbp-jedi-completion-provider.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediCompletionProvider
+{
+  IdeLspCompletionProvider parent_instance;
+};
+
+static void
+gbp_jedi_completion_provider_load (IdeLspCompletionProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_COMPLETION_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static int
+gbp_jedi_completion_provider_get_priority (GtkSourceCompletionProvider *provider,
+                                           GtkSourceCompletionContext  *context)
+{
+  return -1000;
+}
+
+static void
+completion_provider_iface_init (GtkSourceCompletionProviderInterface *iface)
+{
+  iface->get_priority = gbp_jedi_completion_provider_get_priority;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediCompletionProvider, gbp_jedi_completion_provider, 
IDE_TYPE_LSP_COMPLETION_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER, 
completion_provider_iface_init))
+
+static void
+gbp_jedi_completion_provider_class_init (GbpJediCompletionProviderClass *klass)
+{
+  IdeLspCompletionProviderClass *lsp_completion_provider_class = IDE_LSP_COMPLETION_PROVIDER_CLASS (klass);
+
+  lsp_completion_provider_class->load = gbp_jedi_completion_provider_load;
+}
+
+static void
+gbp_jedi_completion_provider_init (GbpJediCompletionProvider *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-completion-provider.h 
b/src/plugins/jedi-language-server/gbp-jedi-completion-provider.h
new file mode 100644
index 000000000..f0d3722b7
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-completion-provider.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-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_JEDI_COMPLETION_PROVIDER (gbp_jedi_completion_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediCompletionProvider, gbp_jedi_completion_provider, GBP, 
JEDI_COMPLETION_PROVIDER, IdeLspCompletionProvider)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-diagnostic-provider.c 
b/src/plugins/jedi-language-server/gbp-jedi-diagnostic-provider.c
new file mode 100644
index 000000000..4a615a4da
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-diagnostic-provider.c
@@ -0,0 +1,65 @@
+/* gbp-jedi-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-jedi-diagnostic-provider"
+
+#include "config.h"
+
+#include "gbp-jedi-diagnostic-provider.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediDiagnosticProvider
+{
+  IdeLspDiagnosticProvider parent_instance;
+};
+
+static void
+gbp_jedi_diagnostic_provider_load (IdeDiagnosticProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_DIAGNOSTIC_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+diagnostic_provider_iface_init (IdeDiagnosticProviderInterface *iface)
+{
+  iface->load = gbp_jedi_diagnostic_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediDiagnosticProvider, gbp_jedi_diagnostic_provider, 
IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER, 
diagnostic_provider_iface_init))
+
+static void
+gbp_jedi_diagnostic_provider_class_init (GbpJediDiagnosticProviderClass *klass)
+{
+}
+
+static void
+gbp_jedi_diagnostic_provider_init (GbpJediDiagnosticProvider *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-diagnostic-provider.h 
b/src/plugins/jedi-language-server/gbp-jedi-diagnostic-provider.h
new file mode 100644
index 000000000..d176d81bc
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-diagnostic-provider.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-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_JEDI_DIAGNOSTIC_PROVIDER (gbp_jedi_diagnostic_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediDiagnosticProvider, gbp_jedi_diagnostic_provider, GBP, 
JEDI_DIAGNOSTIC_PROVIDER, IdeLspDiagnosticProvider)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-formatter.c 
b/src/plugins/jedi-language-server/gbp-jedi-formatter.c
new file mode 100644
index 000000000..3ddf9a3fe
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-formatter.c
@@ -0,0 +1,65 @@
+/* gbp-jedi-formatter.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-jedi-formatter"
+
+#include "config.h"
+
+#include "gbp-jedi-formatter.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediFormatter
+{
+  IdeLspFormatter parent_instance;
+};
+
+static void
+gbp_jedi_formatter_load (IdeFormatter *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_FORMATTER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+formatter_iface_init (IdeFormatterInterface *iface)
+{
+  iface->load = gbp_jedi_formatter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediFormatter, gbp_jedi_formatter, IDE_TYPE_LSP_FORMATTER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_FORMATTER, formatter_iface_init))
+
+static void
+gbp_jedi_formatter_class_init (GbpJediFormatterClass *klass)
+{
+}
+
+static void
+gbp_jedi_formatter_init (GbpJediFormatter *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-formatter.h 
b/src/plugins/jedi-language-server/gbp-jedi-formatter.h
new file mode 100644
index 000000000..864793b12
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-formatter.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-formatter.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_JEDI_FORMATTER (gbp_jedi_formatter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediFormatter, gbp_jedi_formatter, GBP, JEDI_FORMATTER, IdeLspFormatter)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-highlighter.c 
b/src/plugins/jedi-language-server/gbp-jedi-highlighter.c
new file mode 100644
index 000000000..aa577af5d
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-highlighter.c
@@ -0,0 +1,65 @@
+/* gbp-jedi-highlighter.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-jedi-highlighter"
+
+#include "config.h"
+
+#include "gbp-jedi-highlighter.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediHighlighter
+{
+  IdeLspHighlighter parent_instance;
+};
+
+static void
+gbp_jedi_highlighter_load (IdeHighlighter *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_HIGHLIGHTER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+highlighter_iface_init (IdeHighlighterInterface *iface)
+{
+  iface->load = gbp_jedi_highlighter_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediHighlighter, gbp_jedi_highlighter, IDE_TYPE_LSP_HIGHLIGHTER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_HIGHLIGHTER, highlighter_iface_init))
+
+static void
+gbp_jedi_highlighter_class_init (GbpJediHighlighterClass *klass)
+{
+}
+
+static void
+gbp_jedi_highlighter_init (GbpJediHighlighter *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-highlighter.h 
b/src/plugins/jedi-language-server/gbp-jedi-highlighter.h
new file mode 100644
index 000000000..4a4ffc6d4
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-highlighter.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-highlighter.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_JEDI_HIGHLIGHTER (gbp_jedi_highlighter_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediHighlighter, gbp_jedi_highlighter, GBP, JEDI_HIGHLIGHTER, IdeLspHighlighter)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-hover-provider.c 
b/src/plugins/jedi-language-server/gbp-jedi-hover-provider.c
new file mode 100644
index 000000000..5f62280fe
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-hover-provider.c
@@ -0,0 +1,66 @@
+/* gbp-jedi-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-jedi-hover-provider"
+
+#include "config.h"
+
+#include "gbp-jedi-hover-provider.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediHoverProvider
+{
+  IdeLspHoverProvider parent_instance;
+};
+
+static void
+gbp_jedi_hover_provider_prepare (IdeLspHoverProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_HOVER_PROVIDER (provider));
+
+  g_object_set (provider,
+                "category", "Python",
+                "priority", 200,
+                NULL);
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+G_DEFINE_FINAL_TYPE (GbpJediHoverProvider, gbp_jedi_hover_provider, IDE_TYPE_LSP_HOVER_PROVIDER)
+
+static void
+gbp_jedi_hover_provider_class_init (GbpJediHoverProviderClass *klass)
+{
+  IdeLspHoverProviderClass *lsp_hover_provider_class = IDE_LSP_HOVER_PROVIDER_CLASS (klass);
+
+  lsp_hover_provider_class->prepare = gbp_jedi_hover_provider_prepare;
+}
+
+static void
+gbp_jedi_hover_provider_init (GbpJediHoverProvider *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-hover-provider.h 
b/src/plugins/jedi-language-server/gbp-jedi-hover-provider.h
new file mode 100644
index 000000000..d4b9f5452
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-hover-provider.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-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_JEDI_HOVER_PROVIDER (gbp_jedi_hover_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediHoverProvider, gbp_jedi_hover_provider, GBP, JEDI_HOVER_PROVIDER, 
IdeLspHoverProvider)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-rename-provider.c 
b/src/plugins/jedi-language-server/gbp-jedi-rename-provider.c
new file mode 100644
index 000000000..b7f4092c1
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-rename-provider.c
@@ -0,0 +1,65 @@
+/* gbp-jedi-rename-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-jedi-rename-provider"
+
+#include "config.h"
+
+#include "gbp-jedi-rename-provider.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediRenameProvider
+{
+  IdeLspRenameProvider parent_instance;
+};
+
+static void
+gbp_jedi_rename_provider_load (IdeRenameProvider *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_RENAME_PROVIDER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+rename_provider_iface_init (IdeRenameProviderInterface *iface)
+{
+  iface->load = gbp_jedi_rename_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediRenameProvider, gbp_jedi_rename_provider, IDE_TYPE_LSP_RENAME_PROVIDER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_RENAME_PROVIDER, rename_provider_iface_init))
+
+static void
+gbp_jedi_rename_provider_class_init (GbpJediRenameProviderClass *klass)
+{
+}
+
+static void
+gbp_jedi_rename_provider_init (GbpJediRenameProvider *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-rename-provider.h 
b/src/plugins/jedi-language-server/gbp-jedi-rename-provider.h
new file mode 100644
index 000000000..b3fd3a2c2
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-rename-provider.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-rename-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_JEDI_RENAME_PROVIDER (gbp_jedi_rename_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediRenameProvider, gbp_jedi_rename_provider, GBP, JEDI_RENAME_PROVIDER, 
IdeLspRenameProvider)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-service.c 
b/src/plugins/jedi-language-server/gbp-jedi-service.c
new file mode 100644
index 000000000..9feae8fe0
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-service.c
@@ -0,0 +1,69 @@
+/* gbp-jedi-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-jedi-service"
+
+#include "config.h"
+
+#include <jsonrpc-glib.h>
+
+#include "gbp-jedi-service.h"
+
+struct _GbpJediService
+{
+  IdeLspService parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpJediService, gbp_jedi_service, IDE_TYPE_LSP_SERVICE)
+
+static void
+gbp_jedi_service_configure_client (IdeLspService *service,
+                                   IdeLspClient  *client)
+{
+  g_autoptr(GVariant) params = NULL;
+
+  g_assert (GBP_IS_JEDI_SERVICE (service));
+  g_assert (IDE_IS_LSP_CLIENT (client));
+
+  ide_lsp_client_add_language (client, "python");
+  ide_lsp_client_add_language (client, "python3");
+
+  params = JSONRPC_MESSAGE_NEW (
+    "autoImportModules", "[",
+      JSONRPC_MESSAGE_PUT_STRING ("gi"),
+    "]"
+  );
+
+  ide_lsp_client_set_initialization_options (client, params);
+}
+
+static void
+gbp_jedi_service_class_init (GbpJediServiceClass *klass)
+{
+  IdeLspServiceClass *lsp_service_class = IDE_LSP_SERVICE_CLASS (klass);
+
+  lsp_service_class->configure_client = gbp_jedi_service_configure_client;
+}
+
+static void
+gbp_jedi_service_init (GbpJediService *self)
+{
+  ide_lsp_service_set_program (IDE_LSP_SERVICE (self), "jedi-language-server");
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-service.h 
b/src/plugins/jedi-language-server/gbp-jedi-service.h
new file mode 100644
index 000000000..360c67c2c
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-service.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-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_JEDI_SERVICE (gbp_jedi_service_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediService, gbp_jedi_service, GBP, JEDI_SERVICE, IdeLspService)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/gbp-jedi-symbol-resolver.c 
b/src/plugins/jedi-language-server/gbp-jedi-symbol-resolver.c
new file mode 100644
index 000000000..8a34bb799
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-symbol-resolver.c
@@ -0,0 +1,65 @@
+/* gbp-jedi-symbol-resolver.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-jedi-symbol-resolver"
+
+#include "config.h"
+
+#include "gbp-jedi-symbol-resolver.h"
+#include "gbp-jedi-service.h"
+
+struct _GbpJediSymbolResolver
+{
+  IdeLspSymbolResolver parent_instance;
+};
+
+static void
+gbp_jedi_symbol_provider_load (IdeSymbolResolver *provider)
+{
+  g_autoptr(IdeLspServiceClass) klass = NULL;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_JEDI_SYMBOL_RESOLVER (provider));
+
+  klass = g_type_class_ref (GBP_TYPE_JEDI_SERVICE);
+  ide_lsp_service_class_bind_client (klass, IDE_OBJECT (provider));
+
+  IDE_EXIT;
+}
+
+static void
+symbol_provider_iface_init (IdeSymbolResolverInterface *iface)
+{
+  iface->load = gbp_jedi_symbol_provider_load;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpJediSymbolResolver, gbp_jedi_symbol_provider, IDE_TYPE_LSP_SYMBOL_RESOLVER,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_SYMBOL_RESOLVER, symbol_provider_iface_init))
+
+static void
+gbp_jedi_symbol_provider_class_init (GbpJediSymbolResolverClass *klass)
+{
+}
+
+static void
+gbp_jedi_symbol_provider_init (GbpJediSymbolResolver *self)
+{
+}
diff --git a/src/plugins/jedi-language-server/gbp-jedi-symbol-resolver.h 
b/src/plugins/jedi-language-server/gbp-jedi-symbol-resolver.h
new file mode 100644
index 000000000..32f975f72
--- /dev/null
+++ b/src/plugins/jedi-language-server/gbp-jedi-symbol-resolver.h
@@ -0,0 +1,31 @@
+/* gbp-jedi-symbol-resolver.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_JEDI_SYMBOL_RESOLVER (gbp_jedi_symbol_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpJediSymbolResolver, gbp_jedi_symbol_provider, GBP, JEDI_SYMBOL_RESOLVER, 
IdeLspSymbolResolver)
+
+G_END_DECLS
diff --git a/src/plugins/jedi-language-server/jedi-language-server-plugin.c 
b/src/plugins/jedi-language-server/jedi-language-server-plugin.c
new file mode 100644
index 000000000..e47862c28
--- /dev/null
+++ b/src/plugins/jedi-language-server/jedi-language-server-plugin.c
@@ -0,0 +1,70 @@
+/* jedi-language-server-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 "jedi-language-server-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-lsp.h>
+
+#include "gbp-jedi-service.h"
+#include "gbp-jedi-completion-provider.h"
+#include "gbp-jedi-diagnostic-provider.h"
+#include "gbp-jedi-symbol-resolver.h"
+#include "gbp-jedi-highlighter.h"
+#include "gbp-jedi-formatter.h"
+#include "gbp-jedi-rename-provider.h"
+#include "gbp-jedi-hover-provider.h"
+#include "gbp-jedi-code-action-provider.h"
+
+_IDE_EXTERN void
+_gbp_jedi_register_types (PeasObjectModule *module)
+{
+  ide_g_file_add_ignored_pattern (".cache");
+
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_DIAGNOSTIC_PROVIDER,
+                                              GBP_TYPE_JEDI_DIAGNOSTIC_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+                                              GBP_TYPE_JEDI_COMPLETION_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_SYMBOL_RESOLVER,
+                                              GBP_TYPE_JEDI_SYMBOL_RESOLVER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_HIGHLIGHTER,
+                                              GBP_TYPE_JEDI_HIGHLIGHTER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_FORMATTER,
+                                              GBP_TYPE_JEDI_FORMATTER);
+  peas_object_module_register_extension_type (module,
+                                              GTK_SOURCE_TYPE_HOVER_PROVIDER,
+                                              GBP_TYPE_JEDI_HOVER_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_RENAME_PROVIDER,
+                                              GBP_TYPE_JEDI_RENAME_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_CODE_ACTION_PROVIDER,
+                                              GBP_TYPE_JEDI_CODE_ACTION_PROVIDER);
+}
diff --git a/src/plugins/jedi-language-server/jedi-language-server.gresource.xml 
b/src/plugins/jedi-language-server/jedi-language-server.gresource.xml
new file mode 100644
index 000000000..7245d7665
--- /dev/null
+++ b/src/plugins/jedi-language-server/jedi-language-server.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/plugins/jedi-language-server">
+    <file>jedi-language-server.plugin</file>
+  </gresource>
+</gresources>
diff --git a/src/plugins/jedi-language-server/jedi-language-server.plugin 
b/src/plugins/jedi-language-server/jedi-language-server.plugin
index bce4d2045..9149baf6b 100644
--- a/src/plugins/jedi-language-server/jedi-language-server.plugin
+++ b/src/plugins/jedi-language-server/jedi-language-server.plugin
@@ -1,11 +1,10 @@
 [Plugin]
 Builtin=true
-Copyright=Copyright © 2021 Günther Wagner
+Copyright=Copyright © 2021 Günther Wagner, Copyright © 2022 Christian Hergert
 Description=Provides LSP integration for Python
-Loader=python3
-Module=jedi_language_server_plugin
+Embedded=_gbp_jedi_register_types
+Module=jedi-language-server
 Name=Jedi Python Language Server
-X-Builder-ABI=@PACKAGE_ABI@
 X-Category=lsps
 X-Completion-Provider-Languages=python,python3
 X-Symbol-Resolver-Languages=python,python3
diff --git a/src/plugins/jedi-language-server/meson.build b/src/plugins/jedi-language-server/meson.build
index fe273a8dc..4eae5dbc5 100644
--- a/src/plugins/jedi-language-server/meson.build
+++ b/src/plugins/jedi-language-server/meson.build
@@ -1,13 +1,24 @@
 if get_option('plugin_jedi_language_server')
 
-install_data('jedi_language_server_plugin.py', install_dir: plugindir)
-
-configure_file(
-          input: 'jedi-language-server.plugin',
-         output: 'jedi-language-server.plugin',
-  configuration: config_h,
-        install: true,
-    install_dir: plugindir,
+plugins_sources += files([
+  'jedi-language-server-plugin.c',
+  'gbp-jedi-code-action-provider.c',
+  'gbp-jedi-completion-provider.c',
+  'gbp-jedi-diagnostic-provider.c',
+  'gbp-jedi-formatter.c',
+  'gbp-jedi-highlighter.c',
+  'gbp-jedi-hover-provider.c',
+  'gbp-jedi-rename-provider.c',
+  'gbp-jedi-symbol-resolver.c',
+  'gbp-jedi-service.c',
+])
+
+plugin_jedi_resources = gnome.compile_resources(
+  'jedi-language-server-resources',
+  'jedi-language-server.gresource.xml',
+  c_name: 'gbp_jedi',
 )
 
+plugins_sources += plugin_jedi_resources
+
 endif


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