[gnome-builder] clang: use private api so we can be more efficient
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] clang: use private api so we can be more efficient
- Date: Sat, 21 Apr 2018 06:33:49 +0000 (UTC)
commit f99104dced5d2302f2bb0eface433dbd0c781c6d
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 20 23:34:15 2018 -0700
clang: use private api so we can be more efficient
src/plugins/clang/gnome-builder-clang.c | 4 ++--
src/plugins/clang/ide-clang.c | 31 ++++++++++++++++++++++++++++---
src/plugins/clang/test-daemon.c | 2 +-
3 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/clang/gnome-builder-clang.c b/src/plugins/clang/gnome-builder-clang.c
index ad8b489b7..9a2037d99 100644
--- a/src/plugins/clang/gnome-builder-clang.c
+++ b/src/plugins/clang/gnome-builder-clang.c
@@ -362,7 +362,7 @@ handle_complete (JsonrpcServer *server,
g_assert (JSONRPC_IS_SERVER (server));
g_assert (JSONRPC_IS_CLIENT (client));
- g_assert (g_str_equal (method, "textDocument/completion"));
+ g_assert (g_str_equal (method, "clang/complete"));
g_assert (id != NULL);
g_assert (IDE_IS_CLANG (clang));
@@ -508,7 +508,7 @@ main (gint argc,
g_object_ref (clang),
g_object_unref);
jsonrpc_server_add_handler (server,
- "textDocument/completion",
+ "clang/complete",
(JsonrpcServerHandler)handle_complete,
g_object_ref (clang),
g_object_unref);
diff --git a/src/plugins/clang/ide-clang.c b/src/plugins/clang/ide-clang.c
index 587bb5af4..cf7dc6712 100644
--- a/src/plugins/clang/ide-clang.c
+++ b/src/plugins/clang/ide-clang.c
@@ -910,14 +910,35 @@ static void
ide_clang_build_completion (GVariantBuilder *builder,
CXCompletionResult *result)
{
- guint kind;
+ GVariantBuilder chunks_builder;
+ guint n_chunks;
g_assert (builder != NULL);
g_assert (result != NULL);
- kind = translate_completion_kind (result->CursorKind);
+ g_variant_builder_add_parsed (builder, "{%s,<%i>}", "kind",
+ translate_completion_kind (result->CursorKind));
- g_variant_builder_add_parsed (builder, "{%s,<%i>}", "kind", kind);
+ if (clang_getCompletionAvailability (result->CompletionString))
+ g_variant_builder_add_parsed (builder, "{%s,<%i>}", "availability",
+ clang_getCompletionAvailability (result->CompletionString));
+
+ n_chunks = clang_getNumCompletionChunks (result->CompletionString);
+
+ g_variant_builder_init (&chunks_builder, G_VARIANT_TYPE ("aa{sv}"));
+
+ for (guint i = 0; i < n_chunks; i++)
+ {
+ g_auto(CXString) str = clang_getCompletionChunkText (result->CompletionString, i);
+ guint kind = clang_getCompletionChunkKind (result->CompletionString, i);
+
+ g_variant_builder_open (&chunks_builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add_parsed (&chunks_builder, "{%s,<%s>}", "text", clang_getCString (str));
+ g_variant_builder_add_parsed (&chunks_builder, "{%s,<%i>}", "kind", kind);
+ g_variant_builder_close (&chunks_builder);
+ }
+
+ g_variant_builder_add (builder, "{sv}", "chunks", g_variant_builder_end (&chunks_builder));
}
static void
@@ -981,6 +1002,10 @@ ide_clang_complete_worker (IdeTask *task,
return;
}
+#if 0
+ clang_sortCodeCompletionResults (results->Results, results->NumResults);
+#endif
+
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
for (guint i = 0; i < results->NumResults; i++)
diff --git a/src/plugins/clang/test-daemon.c b/src/plugins/clang/test-daemon.c
index f911fcf46..7206f7d85 100644
--- a/src/plugins/clang/test-daemon.c
+++ b/src/plugins/clang/test-daemon.c
@@ -155,7 +155,7 @@ test_complete (JsonrpcClient *client,
);
jsonrpc_client_call_async (client,
- "textDocument/completion",
+ "clang/complete",
params,
NULL,
test_complete_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]