[gnome-builder] lsp: add override for style-scheme kind
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] lsp: add override for style-scheme kind
- Date: Thu, 5 Dec 2019 05:26:27 +0000 (UTC)
commit 7b32fadfc3ddb9d49e503361143a1dcd2e53f2de
Author: Christian Hergert <chergert redhat com>
Date: Wed Dec 4 21:23:37 2019 -0800
lsp: add override for style-scheme kind
This allows a plugin to specify what IdeSymbolKind should map
to. I'll note that we could drastically shrink the memory
overhead here by reversing the style type, but I'll leave that
to a future commit.
Related #1084
src/libide/lsp/ide-lsp-highlighter.c | 27 ++++++++++++++++++++++++++-
src/libide/lsp/ide-lsp-highlighter.h | 4 ++++
2 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/lsp/ide-lsp-highlighter.c b/src/libide/lsp/ide-lsp-highlighter.c
index 29188e93a..282210296 100644
--- a/src/libide/lsp/ide-lsp-highlighter.c
+++ b/src/libide/lsp/ide-lsp-highlighter.c
@@ -27,6 +27,7 @@
#include <jsonrpc-glib.h>
#include "ide-lsp-highlighter.h"
+#include "ide-lsp-util.h"
#define DELAY_TIMEOUT_MSEC 333
@@ -45,6 +46,8 @@ typedef struct
IdeHighlightIndex *index;
DzlSignalGroup *buffer_signals;
+ const gchar *style_map[IDE_SYMBOL_KIND_LAST];
+
guint queued_update;
guint active : 1;
@@ -128,8 +131,9 @@ ide_lsp_highlighter_document_symbol_cb (GObject *object,
while (g_variant_iter_loop (&iter, "v", &member))
{
const gchar *name = NULL;
- const gchar *tag;
+ const gchar *tag = NULL;
gboolean success;
+ IdeSymbolKind symkind;
gint64 kind = 0;
success = JSONRPC_MESSAGE_PARSE (member,
@@ -143,6 +147,14 @@ ide_lsp_highlighter_document_symbol_cb (GObject *object,
continue;
}
+ symkind = ide_lsp_decode_symbol_kind (kind);
+
+ if ((tag = priv->style_map[symkind]))
+ {
+ ide_highlight_index_insert (index, name, (gpointer)tag);
+ continue;
+ }
+
switch (kind)
{
case 6: /* METHOD */
@@ -516,3 +528,16 @@ highlighter_iface_init (IdeHighlighterInterface *iface)
iface->update = ide_lsp_highlighter_update;
iface->set_engine = ide_lsp_highlighter_set_engine;
}
+
+void
+ide_lsp_highlighter_set_kind_style (IdeLspHighlighter *self,
+ IdeSymbolKind kind,
+ const gchar *style)
+{
+ IdeLspHighlighterPrivate *priv = ide_lsp_highlighter_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_LSP_HIGHLIGHTER (self));
+ g_return_if_fail (kind < IDE_SYMBOL_KIND_LAST);
+
+ priv->style_map[kind] = g_intern_string (style);
+}
diff --git a/src/libide/lsp/ide-lsp-highlighter.h b/src/libide/lsp/ide-lsp-highlighter.h
index bb240e9f0..6a798c7b4 100644
--- a/src/libide/lsp/ide-lsp-highlighter.h
+++ b/src/libide/lsp/ide-lsp-highlighter.h
@@ -48,5 +48,9 @@ IdeLspClient *ide_lsp_highlighter_get_client (IdeLspHighlighter *self);
IDE_AVAILABLE_IN_3_32
void ide_lsp_highlighter_set_client (IdeLspHighlighter *self,
IdeLspClient *client);
+IDE_AVAILABLE_IN_3_36
+void ide_lsp_highlighter_set_kind_style (IdeLspHighlighter *self,
+ IdeSymbolKind kind,
+ const gchar *style);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]