[gnome-builder/wip/chergert/completion] completion: track activation of completion in context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/completion] completion: track activation of completion in context
- Date: Fri, 8 Jun 2018 09:19:01 +0000 (UTC)
commit 4f66c8072b266d23ec34071d1d4d3da0698dc9cd
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 8 02:06:50 2018 -0700
completion: track activation of completion in context
This will allow providers to ignore some work for cases that
would be really expensive to process.
src/libide/completion/ide-completion-context.c | 33 ++++++++++++---
src/libide/completion/ide-completion-context.h | 51 +++++++++++++----------
src/libide/completion/ide-completion-display.c | 4 +-
src/libide/completion/ide-completion-display.h | 2 +-
src/libide/completion/ide-completion-private.h | 1 +
src/libide/completion/ide-completion-provider.c | 4 +-
src/libide/completion/ide-completion-types.h | 9 +++-
src/libide/completion/ide-completion.c | 1 +
src/libide/completion/ide-completion.h | 7 ----
src/libide/completion/meson.build | 5 +++
src/libide/ide-enums.c.in | 1 +
src/libide/sourceview/ide-source-search-context.c | 2 +-
12 files changed, 76 insertions(+), 44 deletions(-)
---
diff --git a/src/libide/completion/ide-completion-context.c b/src/libide/completion/ide-completion-context.c
index dab4bc4bc..4a7219d9b 100644
--- a/src/libide/completion/ide-completion-context.c
+++ b/src/libide/completion/ide-completion-context.c
@@ -41,6 +41,8 @@ struct _IdeCompletionContext
GtkTextMark *begin_mark;
GtkTextMark *end_mark;
+ IdeCompletionActivation activation;
+
guint busy : 1;
guint has_populated : 1;
guint empty : 1;
@@ -503,6 +505,7 @@ ide_completion_context_notify_complete_cb (IdeCompletionContext *self,
/**
* _ide_completion_context_complete_async:
* @self: a #IdeCompletionContext
+ * @activation: how we are being activated
* @iter: a #GtkTextIter
* @cancellable: (nullable): a #GCancellable or %NULL
* @callback: (nullable): a callback or %NULL
@@ -514,12 +517,13 @@ ide_completion_context_notify_complete_cb (IdeCompletionContext *self,
* Since: 3.30
*/
void
-_ide_completion_context_complete_async (IdeCompletionContext *self,
- const GtkTextIter *begin,
- const GtkTextIter *end,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+_ide_completion_context_complete_async (IdeCompletionContext *self,
+ IdeCompletionActivation activation,
+ const GtkTextIter *begin,
+ const GtkTextIter *end,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
g_autoptr(IdeTask) task = NULL;
CompleteTaskData *task_data;
@@ -534,6 +538,7 @@ _ide_completion_context_complete_async (IdeCompletionContext *self,
g_return_if_fail (end != NULL);
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+ self->activation = activation;
self->has_populated = TRUE;
self->busy = TRUE;
@@ -1061,3 +1066,19 @@ ide_completion_context_is_language (IdeCompletionContext *self,
return g_strcmp0 (language, ide_completion_context_get_language (self)) == 0;
}
+
+/**
+ * ide_completion_context_get_activation:
+ * @self: a #IdeCompletionContext
+ *
+ * Gets the mode for which the context was activated.
+ *
+ * Since: 3.30
+ */
+IdeCompletionActivation
+ide_completion_context_get_activation (IdeCompletionContext *self)
+{
+ g_return_val_if_fail (IDE_IS_COMPLETION_CONTEXT (self), 0);
+
+ return self->activation;
+}
diff --git a/src/libide/completion/ide-completion-context.h b/src/libide/completion/ide-completion-context.h
index 1c8432292..29f250cdc 100644
--- a/src/libide/completion/ide-completion-context.h
+++ b/src/libide/completion/ide-completion-context.h
@@ -18,9 +18,12 @@
#pragma once
-#include "ide-completion-types.h"
+#include <gtk/gtk.h>
+
#include "ide-version-macros.h"
+#include "completion/ide-completion-types.h"
+
G_BEGIN_DECLS
#define IDE_TYPE_COMPLETION_CONTEXT (ide_completion_context_get_type())
@@ -29,39 +32,41 @@ IDE_AVAILABLE_IN_3_30
G_DECLARE_FINAL_TYPE (IdeCompletionContext, ide_completion_context, IDE, COMPLETION_CONTEXT, GObject)
IDE_AVAILABLE_IN_3_30
-const gchar *ide_completion_context_get_language (IdeCompletionContext *self);
+IdeCompletionActivation ide_completion_context_get_activation (IdeCompletionContext *self);
+IDE_AVAILABLE_IN_3_30
+const gchar *ide_completion_context_get_language (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-gboolean ide_completion_context_is_language (IdeCompletionContext *self,
- const gchar *language);
+gboolean ide_completion_context_is_language (IdeCompletionContext *self,
+ const gchar
*language);
IDE_AVAILABLE_IN_3_30
-GtkTextBuffer *ide_completion_context_get_buffer (IdeCompletionContext *self);
+GtkTextBuffer *ide_completion_context_get_buffer (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-GtkTextView *ide_completion_context_get_view (IdeCompletionContext *self);
+GtkTextView *ide_completion_context_get_view (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-gboolean ide_completion_context_get_busy (IdeCompletionContext *self);
+gboolean ide_completion_context_get_busy (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-gboolean ide_completion_context_is_empty (IdeCompletionContext *self);
+gboolean ide_completion_context_is_empty (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-void ide_completion_context_set_proposals_for_provider (IdeCompletionContext *self,
- IdeCompletionProvider *provider,
- GListModel *results);
+void ide_completion_context_set_proposals_for_provider (IdeCompletionContext *self,
+ IdeCompletionProvider *provider,
+ GListModel *results);
IDE_AVAILABLE_IN_3_30
-IdeCompletion *ide_completion_context_get_completion (IdeCompletionContext *self);
+IdeCompletion *ide_completion_context_get_completion (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-gboolean ide_completion_context_get_bounds (IdeCompletionContext *self,
- GtkTextIter *begin,
- GtkTextIter *end);
+gboolean ide_completion_context_get_bounds (IdeCompletionContext *self,
+ GtkTextIter *begin,
+ GtkTextIter *end);
IDE_AVAILABLE_IN_3_30
-gboolean ide_completion_context_get_start_iter (IdeCompletionContext *self,
- GtkTextIter *iter);
+gboolean ide_completion_context_get_start_iter (IdeCompletionContext *self,
+ GtkTextIter *iter);
IDE_AVAILABLE_IN_3_30
-gchar *ide_completion_context_get_word (IdeCompletionContext *self);
+gchar *ide_completion_context_get_word (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-gchar *ide_completion_context_get_line_text (IdeCompletionContext *self);
+gchar *ide_completion_context_get_line_text (IdeCompletionContext *self);
IDE_AVAILABLE_IN_3_30
-gboolean ide_completion_context_get_item_full (IdeCompletionContext *self,
- guint position,
- IdeCompletionProvider **provider,
- IdeCompletionProposal **proposal);
+gboolean ide_completion_context_get_item_full (IdeCompletionContext *self,
+ guint position,
+ IdeCompletionProvider **provider,
+ IdeCompletionProposal
**proposal);
G_END_DECLS
diff --git a/src/libide/completion/ide-completion-display.c b/src/libide/completion/ide-completion-display.c
index 938629826..f615231f8 100644
--- a/src/libide/completion/ide-completion-display.c
+++ b/src/libide/completion/ide-completion-display.c
@@ -16,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define G_LOG_DOMAIN "ide-completion-display"
-
#include "config.h"
+#define G_LOG_DOMAIN "ide-completion-display"
+
#include "completion/ide-completion-context.h"
#include "completion/ide-completion-display.h"
#include "sourceview/ide-source-view.h"
diff --git a/src/libide/completion/ide-completion-display.h b/src/libide/completion/ide-completion-display.h
index be99f4e59..f1d13be6d 100644
--- a/src/libide/completion/ide-completion-display.h
+++ b/src/libide/completion/ide-completion-display.h
@@ -18,7 +18,7 @@
#pragma once
-#include <gtk/gtk.h>
+#include <gtksourceview/gtksource.h>
#include "ide-version-macros.h"
diff --git a/src/libide/completion/ide-completion-private.h b/src/libide/completion/ide-completion-private.h
index 5e5a38e7d..e9de88f7f 100644
--- a/src/libide/completion/ide-completion-private.h
+++ b/src/libide/completion/ide-completion-private.h
@@ -55,6 +55,7 @@ gboolean _ide_completion_context_can_refilter (IdeCompletio
const GtkTextIter *end);
void _ide_completion_context_refilter (IdeCompletionContext *self);
void _ide_completion_context_complete_async (IdeCompletionContext *self,
+ IdeCompletionActivation activation,
const GtkTextIter *begin,
const GtkTextIter *end,
GCancellable *cancellable,
diff --git a/src/libide/completion/ide-completion-provider.c b/src/libide/completion/ide-completion-provider.c
index c426efc0f..cd202af0f 100644
--- a/src/libide/completion/ide-completion-provider.c
+++ b/src/libide/completion/ide-completion-provider.c
@@ -16,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define G_LOG_DOMAIN "ide-completion-provider"
-
#include "config.h"
+#define G_LOG_DOMAIN "ide-completion-provider"
+
#include "ide-completion-context.h"
#include "ide-completion-proposal.h"
#include "ide-completion-provider.h"
diff --git a/src/libide/completion/ide-completion-types.h b/src/libide/completion/ide-completion-types.h
index 46df79312..a86c42cfe 100644
--- a/src/libide/completion/ide-completion-types.h
+++ b/src/libide/completion/ide-completion-types.h
@@ -18,8 +18,6 @@
#pragma once
-#include <gtksourceview/gtksource.h>
-
G_BEGIN_DECLS
typedef struct _IdeCompletion IdeCompletion;
@@ -33,6 +31,13 @@ typedef struct _IdeCompletionProvider IdeCompletionProvider;
typedef struct _IdeCompletionView IdeCompletionView;
typedef struct _IdeCompletionWindow IdeCompletionWindow;
+typedef enum
+{
+ IDE_COMPLETION_INTERACTIVE,
+ IDE_COMPLETION_USER_REQUESTED,
+ IDE_COMPLETION_TRIGGERED,
+} IdeCompletionActivation;
+
typedef enum
{
IDE_COMPLETION_COLUMN_ICON,
diff --git a/src/libide/completion/ide-completion.c b/src/libide/completion/ide-completion.c
index 2943a16e9..76d92c425 100644
--- a/src/libide/completion/ide-completion.c
+++ b/src/libide/completion/ide-completion.c
@@ -331,6 +331,7 @@ ide_completion_start (IdeCompletion *self,
self->needs_refilter = FALSE;
_ide_completion_context_complete_async (context,
+ activation,
&begin,
&end,
self->cancellable,
diff --git a/src/libide/completion/ide-completion.h b/src/libide/completion/ide-completion.h
index 707e77bfe..bd6978eba 100644
--- a/src/libide/completion/ide-completion.h
+++ b/src/libide/completion/ide-completion.h
@@ -29,13 +29,6 @@ G_BEGIN_DECLS
#define IDE_TYPE_COMPLETION (ide_completion_get_type())
-typedef enum
-{
- IDE_COMPLETION_INTERACTIVE,
- IDE_COMPLETION_USER_REQUESTED,
- IDE_COMPLETION_TRIGGERED,
-} IdeCompletionActivation;
-
IDE_AVAILABLE_IN_3_30
G_DECLARE_FINAL_TYPE (IdeCompletion, ide_completion, IDE, COMPLETION, GObject)
diff --git a/src/libide/completion/meson.build b/src/libide/completion/meson.build
index 713c45e39..918c83076 100644
--- a/src/libide/completion/meson.build
+++ b/src/libide/completion/meson.build
@@ -25,6 +25,10 @@ completion_sources = [
'ide-completion-window.c',
]
+completion_enums = [
+ 'ide-completion-types.h',
+]
+
completion_private_sources = [
'ide-completion-private.h',
# 'ide-completion-words.c',
@@ -41,5 +45,6 @@ completion_private_sources = [
libide_public_headers += files(completion_headers)
libide_public_sources += files(completion_sources)
libide_private_sources += files(completion_private_sources)
+libide_enum_headers += files(completion_enums)
install_headers(completion_headers, subdir: join_paths(libide_header_subdir, 'completion'))
diff --git a/src/libide/ide-enums.c.in b/src/libide/ide-enums.c.in
index 556c12180..c03c5c2be 100644
--- a/src/libide/ide-enums.c.in
+++ b/src/libide/ide-enums.c.in
@@ -7,6 +7,7 @@
#include "buffers/ide-buffer.h"
#include "buildsystem/ide-build-log.h"
#include "buildsystem/ide-build-pipeline.h"
+#include "completion/ide-completion-types.h"
#include "config/ide-configuration.h"
#include "devices/ide-device.h"
#include "devices/ide-device-info.h"
diff --git a/src/libide/sourceview/ide-source-search-context.c
b/src/libide/sourceview/ide-source-search-context.c
index f4e5ef5b6..49e14eaff 100644
--- a/src/libide/sourceview/ide-source-search-context.c
+++ b/src/libide/sourceview/ide-source-search-context.c
@@ -104,7 +104,7 @@ ide_source_search_context_backward_async (GtkSourceSearchContext *search,
/**
* ide_source_search_context_backward_finish2:
- * @self: a #GtkSourceSearchContext
+ * @search: a #GtkSourceSearchContext
* @result: a #GAsyncResult
* @match_begin: (out): a #GtkTextIter
* @match_end: (out): a #GtkTextIter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]