[gnome-builder] langserv: use decode helpers for kind property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] langserv: use decode helpers for kind property
- Date: Tue, 4 Apr 2017 21:57:18 +0000 (UTC)
commit 40387c2d2aa81c4e592c096748fe4983d53309c5
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 4 14:56:15 2017 -0700
langserv: use decode helpers for kind property
libide/langserv/ide-langserv-completion-provider.c | 11 +++++++++
libide/langserv/ide-langserv-symbol-node.c | 24 +------------------
2 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/libide/langserv/ide-langserv-completion-provider.c
b/libide/langserv/ide-langserv-completion-provider.c
index 45c2f6b..00a0c94 100644
--- a/libide/langserv/ide-langserv-completion-provider.c
+++ b/libide/langserv/ide-langserv-completion-provider.c
@@ -24,6 +24,8 @@
#include "buffers/ide-buffer.h"
#include "langserv/ide-langserv-completion-provider.h"
+#include "langserv/ide-langserv-util.h"
+#include "symbols/ide-symbol.h"
typedef struct
{
@@ -260,7 +262,9 @@ ide_langserv_completion_provider_complete_cb (GObject *object,
g_autofree gchar *full_label = NULL;
const gchar *label;
const gchar *detail;
+ const gchar *icon_name = NULL;
gboolean success;
+ gint64 kind = 0;
success = JSONRPC_MESSAGE_PARSE (node,
"label", JSONRPC_MESSAGE_GET_STRING (&label),
@@ -273,6 +277,12 @@ ide_langserv_completion_provider_complete_cb (GObject *object,
continue;
}
+ /* Optional kind field */
+ JSONRPC_MESSAGE_PARSE (node, "kind", JSONRPC_MESSAGE_GET_INT64 (&kind));
+ kind = ide_langserv_decode_completion_kind (kind);
+ if (kind != IDE_SYMBOL_NONE)
+ icon_name = ide_symbol_kind_get_icon_name (kind);
+
if (label != NULL && detail != NULL)
full_label = g_strdup_printf ("%s : %s", label, detail);
else
@@ -280,6 +290,7 @@ ide_langserv_completion_provider_complete_cb (GObject *object,
//item = gtk_source_completion_item_new (full_label, label, NULL, NULL);
item = g_object_new (GTK_SOURCE_TYPE_COMPLETION_ITEM,
+ "icon-name", icon_name,
"label", full_label,
"text", label,
NULL);
diff --git a/libide/langserv/ide-langserv-symbol-node.c b/libide/langserv/ide-langserv-symbol-node.c
index a906c53..2e7a9ec 100644
--- a/libide/langserv/ide-langserv-symbol-node.c
+++ b/libide/langserv/ide-langserv-symbol-node.c
@@ -24,6 +24,7 @@
#include "files/ide-file.h"
#include "langserv/ide-langserv-symbol-node.h"
#include "langserv/ide-langserv-symbol-node-private.h"
+#include "langserv/ide-langserv-util.h"
typedef struct
{
@@ -144,28 +145,7 @@ ide_langserv_symbol_node_new (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
- switch (kind)
- {
- case 1: kind = IDE_SYMBOL_FILE; break;
- case 2: kind = IDE_SYMBOL_MODULE; break;
- case 3: kind = IDE_SYMBOL_NAMESPACE; break;
- case 4: kind = IDE_SYMBOL_PACKAGE; break;
- case 5: kind = IDE_SYMBOL_CLASS; break;
- case 6: kind = IDE_SYMBOL_METHOD; break;
- case 7: kind = IDE_SYMBOL_PROPERTY; break;
- case 8: kind = IDE_SYMBOL_FIELD; break;
- case 9: kind = IDE_SYMBOL_CONSTRUCTOR; break;
- case 10: kind = IDE_SYMBOL_ENUM; break;
- case 11: kind = IDE_SYMBOL_INTERFACE; break;
- case 12: kind = IDE_SYMBOL_FUNCTION; break;
- case 13: kind = IDE_SYMBOL_VARIABLE; break;
- case 14: kind = IDE_SYMBOL_CONSTANT; break;
- case 15: kind = IDE_SYMBOL_STRING; break;
- case 16: kind = IDE_SYMBOL_NUMBER; break;
- case 17: kind = IDE_SYMBOL_BOOLEAN; break;
- case 18: kind = IDE_SYMBOL_ARRAY; break;
- default: kind = IDE_SYMBOL_NONE; break;
- }
+ kind = ide_langserv_decode_symbol_kind (kind);
self = g_object_new (IDE_TYPE_LANGSERV_SYMBOL_NODE,
"flags", 0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]