[gnome-builder/wip/gtk4-port: 326/343] libide/lsp: start using GtkSourceSnippet




commit f985477c9a40c1e1698a228742988a8a4c1e5560
Author: Christian Hergert <chergert redhat com>
Date:   Sun Apr 3 10:44:59 2022 -0700

    libide/lsp: start using GtkSourceSnippet

 src/libide/lsp/ide-lsp-completion-item.c | 40 +++++++++++---------------------
 src/libide/lsp/ide-lsp-completion-item.h | 19 +++++++--------
 2 files changed, 22 insertions(+), 37 deletions(-)
---
diff --git a/src/libide/lsp/ide-lsp-completion-item.c b/src/libide/lsp/ide-lsp-completion-item.c
index f51741d8d..70b7021dc 100644
--- a/src/libide/lsp/ide-lsp-completion-item.c
+++ b/src/libide/lsp/ide-lsp-completion-item.c
@@ -22,7 +22,8 @@
 
 #include "config.h"
 
-#include <libide-sourceview.h>
+#include <gtksourceview/gtksource.h>
+
 #include <jsonrpc-glib.h>
 
 #include "ide-lsp-completion-item.h"
@@ -38,7 +39,7 @@ struct _IdeLspCompletionItem
 };
 
 G_DEFINE_FINAL_TYPE_WITH_CODE (IdeLspCompletionItem, ide_lsp_completion_item, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_COMPLETION_PROPOSAL, NULL))
+                               G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROPOSAL, NULL))
 
 static void
 ide_lsp_completion_item_finalize (GObject *object)
@@ -87,15 +88,6 @@ ide_lsp_completion_item_new (GVariant *variant)
   return self;
 }
 
-gchar *
-ide_lsp_completion_item_get_markup (IdeLspCompletionItem *self,
-                                    const gchar          *typed_text)
-{
-  g_return_val_if_fail (IDE_IS_LSP_COMPLETION_ITEM (self), NULL);
-
-  return ide_completion_fuzzy_highlight (self->label, typed_text);
-}
-
 const gchar *
 ide_lsp_completion_item_get_return_type (IdeLspCompletionItem *self)
 {
@@ -129,15 +121,13 @@ ide_lsp_completion_item_get_detail (IdeLspCompletionItem *self)
  * Creates a new snippet for the completion item to be inserted into
  * the document.
  *
- * Returns: (transfer full): an #IdeSnippet
- *
- * Since: 3.30
+ * Returns: (transfer full): an #GtkSourceSnippet
  */
-IdeSnippet *
+GtkSourceSnippet *
 ide_lsp_completion_item_get_snippet (IdeLspCompletionItem *self)
 {
-  g_autoptr(IdeSnippet) snippet = NULL;
-  g_autoptr(IdeSnippetChunk) plainchunk = NULL;
+  g_autoptr(GtkSourceSnippet) snippet = NULL;
+  g_autoptr(GtkSourceSnippetChunk) plainchunk = NULL;
   const gchar *snippet_text = NULL;
   const gchar *snippet_new_text = NULL;
   const gchar *text;
@@ -156,7 +146,7 @@ ide_lsp_completion_item_get_snippet (IdeLspCompletionItem *self)
         {
           g_autoptr(GError) error = NULL;
 
-          if ((snippet = ide_snippet_parser_parse_one (snippet_new_text, -1, &error)))
+          if ((snippet = gtk_source_snippet_new_parsed (snippet_new_text, &error)))
             return g_steal_pointer (&snippet);
 
           g_warning ("Failed to parse snippet: %s: %s",
@@ -166,7 +156,7 @@ ide_lsp_completion_item_get_snippet (IdeLspCompletionItem *self)
         {
           g_autoptr(GError) error = NULL;
 
-          if ((snippet = ide_snippet_parser_parse_one (snippet_text, -1, &error)))
+          if ((snippet = gtk_source_snippet_new_parsed (snippet_text, &error)))
             return g_steal_pointer (&snippet);
 
           g_warning ("Failed to parse snippet: %s: %s",
@@ -174,11 +164,11 @@ ide_lsp_completion_item_get_snippet (IdeLspCompletionItem *self)
         }
     }
 
-  snippet = ide_snippet_new (NULL, NULL);
-  plainchunk = ide_snippet_chunk_new ();
-  ide_snippet_chunk_set_text (plainchunk, text);
-  ide_snippet_chunk_set_text_set (plainchunk, TRUE);
-  ide_snippet_add_chunk (snippet, plainchunk);
+  snippet = gtk_source_snippet_new (NULL, NULL);
+  plainchunk = gtk_source_snippet_chunk_new ();
+  gtk_source_snippet_chunk_set_text (plainchunk, text);
+  gtk_source_snippet_chunk_set_text_set (plainchunk, TRUE);
+  gtk_source_snippet_add_chunk (snippet, plainchunk);
 
   return g_steal_pointer (&snippet);
 }
@@ -192,8 +182,6 @@ ide_lsp_completion_item_get_snippet (IdeLspCompletionItem *self)
  * Obtain an array of all additional text edits to be applied to the project.
  *
  * Returns: (transfer full) (element-type IdeTextEdit) (nullable): a #GPtrArray of #IdeTextEdit
- *
- * Since: 41.0
  */
 GPtrArray *
 ide_lsp_completion_item_get_additional_text_edits (IdeLspCompletionItem *self,
diff --git a/src/libide/lsp/ide-lsp-completion-item.h b/src/libide/lsp/ide-lsp-completion-item.h
index bb325a053..7dd6ff812 100644
--- a/src/libide/lsp/ide-lsp-completion-item.h
+++ b/src/libide/lsp/ide-lsp-completion-item.h
@@ -30,24 +30,21 @@ G_BEGIN_DECLS
 
 #define IDE_TYPE_LSP_COMPLETION_ITEM (ide_lsp_completion_item_get_type())
 
-IDE_AVAILABLE_IN_3_32
+IDE_AVAILABLE_IN_ALL
 G_DECLARE_FINAL_TYPE (IdeLspCompletionItem, ide_lsp_completion_item, IDE, LSP_COMPLETION_ITEM, GObject)
 
-IDE_AVAILABLE_IN_3_32
+IDE_AVAILABLE_IN_ALL
 IdeLspCompletionItem *ide_lsp_completion_item_new                       (GVariant             *variant);
-IDE_AVAILABLE_IN_3_32
+IDE_AVAILABLE_IN_ALL
 const gchar          *ide_lsp_completion_item_get_icon_name             (IdeLspCompletionItem *self);
-IDE_AVAILABLE_IN_3_32
+IDE_AVAILABLE_IN_ALL
 const gchar          *ide_lsp_completion_item_get_return_type           (IdeLspCompletionItem *self);
-IDE_AVAILABLE_IN_3_32
+IDE_AVAILABLE_IN_ALL
 const gchar          *ide_lsp_completion_item_get_detail                (IdeLspCompletionItem *self);
-IDE_AVAILABLE_IN_3_32
-gchar                *ide_lsp_completion_item_get_markup                (IdeLspCompletionItem *self,
-                                                                         const gchar          *typed_text);
-IDE_AVAILABLE_IN_3_32
-IdeSnippet           *ide_lsp_completion_item_get_snippet               (IdeLspCompletionItem *self);
+IDE_AVAILABLE_IN_ALL
+GtkSourceSnippet     *ide_lsp_completion_item_get_snippet               (IdeLspCompletionItem *self);
 
-IDE_AVAILABLE_IN_41
+IDE_AVAILABLE_IN_ALL
 GPtrArray            *ide_lsp_completion_item_get_additional_text_edits (IdeLspCompletionItem *self,
                                                                          GFile                *file);
 


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