[gnome-builder] libide: add match helper to check item against string
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add match helper to check item against string
- Date: Tue, 24 Mar 2015 00:20:56 +0000 (UTC)
commit 5c18ab58c6d03f5e0d20db01efbe614c7d69750d
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 15 16:27:25 2015 -0700
libide: add match helper to check item against string
libide/clang/ide-clang-completion-item.c | 49 ++++++++++++++++++++++++++++++
libide/clang/ide-clang-completion-item.h | 2 +
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/libide/clang/ide-clang-completion-item.c b/libide/clang/ide-clang-completion-item.c
index d8b2356..694632c 100644
--- a/libide/clang/ide-clang-completion-item.c
+++ b/libide/clang/ide-clang-completion-item.c
@@ -178,3 +178,52 @@ ide_clang_completion_item_sort (gconstpointer a,
return (gint)aprio - (gint)bprio;
}
+
+gboolean
+ide_clang_completion_item_matches (IdeClangCompletionItem *self,
+ const gchar *text)
+{
+ CXCompletionResult *result = get_completion_result ((GtkSourceCompletionProposal *)self);
+ enum CXAvailabilityKind availability;
+ unsigned chunks;
+ unsigned i;
+
+ g_return_val_if_fail (IDE_IS_CLANG_COMPLETION_ITEM (self), text);
+
+ availability = clang_getCompletionAvailability (result->CompletionString);
+
+ switch (availability)
+ {
+ case CXAvailability_NotAvailable:
+ case CXAvailability_NotAccessible:
+ return FALSE;
+
+ default:
+ break;
+ }
+
+ chunks = clang_getNumCompletionChunks (result->CompletionString);
+
+ for (i = 0; i < chunks; i++)
+ {
+ enum CXCompletionChunkKind kind;
+
+ kind = clang_getCompletionChunkKind (result->CompletionString, i);
+
+ if (kind == CXCompletionChunk_TypedText)
+ {
+ CXString cxstr;
+
+ cxstr = clang_getCompletionChunkText(result->CompletionString, i);
+ if (g_str_has_prefix (clang_getCString (cxstr), text))
+ {
+ clang_disposeString (cxstr);
+ return TRUE;
+ }
+
+ clang_disposeString (cxstr);
+ }
+ }
+
+ return FALSE;
+}
diff --git a/libide/clang/ide-clang-completion-item.h b/libide/clang/ide-clang-completion-item.h
index c70cab6..60d458d 100644
--- a/libide/clang/ide-clang-completion-item.h
+++ b/libide/clang/ide-clang-completion-item.h
@@ -35,6 +35,8 @@ typedef struct _IdeClangCompletionItem IdeClangCompletionItem;
typedef struct _IdeClangCompletionItemClass IdeClangCompletionItemClass;
GType ide_clang_completion_item_get_type (void);
+gboolean ide_clang_completion_item_matches (IdeClangCompletionItem *self,
+ const gchar *text);
gint ide_clang_completion_item_sort (gconstpointer a,
gconstpointer b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]