[anjuta/symbol-db-model] language-support-cpp-java: Avoid duplication of local symbols in project search
- From: Naba Kumar <naba src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/symbol-db-model] language-support-cpp-java: Avoid duplication of local symbols in project search
- Date: Thu, 18 Mar 2010 20:45:25 +0000 (UTC)
commit d6d7aae5f43c4bcd16184e073aecc6b79f79fade
Author: Johannes Schmid <jhs gnome org>
Date: Mon Mar 15 21:04:15 2010 +0100
language-support-cpp-java: Avoid duplication of local symbols in project search
.../language-support-cpp-java/cpp-java-assist.c | 93 ++++++++++++--------
.../language-support-cpp-java/cpp-java-assist.h | 2 -
2 files changed, 58 insertions(+), 37 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index 8873e07..4b5c190 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -93,6 +93,10 @@ struct _CppJavaAssistPriv {
gboolean async_system;
gboolean async_project;
+ gint async_file_id;
+ gint async_system_id;
+ gint async_project_id;
+
GCancellable* cancel_system;
GCancellable* cancel_file;
GCancellable* cancel_project;
@@ -173,6 +177,8 @@ anjuta_proposal_completion_func (gpointer data)
/**
* cpp_java_assist_create_completion_from_symbols:
* @symbols: Symbol iteration
+ * @local_only: Only include symbols with local file scope, useful for
+ * concatination of file and project/global search to avoid duplicates
*
* Create a list of IAnjutaEditorAssistProposals from a list of symbols
*
@@ -180,12 +186,17 @@ anjuta_proposal_completion_func (gpointer data)
* with cpp_java_assist_proposal_free()
*/
static GList*
-cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols)
+cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols, gboolean local_only)
{
GList* list = NULL;
do
{
IAnjutaSymbol* symbol = IANJUTA_SYMBOL (symbols);
+ if (local_only)
+ {
+ if (!ianjuta_symbol_is_local (symbol, NULL))
+ continue;
+ }
IAnjutaEditorAssistProposal* proposal = cpp_java_assist_proposal_new (symbol);
list = g_list_append (list, proposal);
@@ -549,7 +560,7 @@ cpp_java_assist_create_member_completion_cache (CppJavaAssist* assist, IAnjutaIt
if (children)
{
GList* proposals =
- cpp_java_assist_create_completion_from_symbols (children);
+ cpp_java_assist_create_completion_from_symbols (children, FALSE);
cpp_java_assist_create_completion_cache (assist);
g_completion_add_items (assist->priv->completion_cache, proposals);
@@ -579,7 +590,16 @@ cpp_java_assist_create_member_completion_cache (CppJavaAssist* assist, IAnjutaIt
static void
on_symbol_search_complete (gint search_id, IAnjutaIterable* symbols, CppJavaAssist* assist)
{
- GList* proposals = cpp_java_assist_create_completion_from_symbols (symbols);
+ GList* proposals;
+ if (search_id == assist->priv->async_file_id)
+ {
+ proposals = cpp_java_assist_create_completion_from_symbols (symbols, TRUE);
+ }
+ else
+ {
+ proposals = cpp_java_assist_create_completion_from_symbols (symbols, FALSE);
+ }
+
g_completion_add_items (assist->priv->completion_cache, proposals);
gboolean running = assist->priv->async_system || assist->priv->async_file ||
assist->priv->async_project;
@@ -671,16 +691,17 @@ cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaItera
g_signal_connect (notify, "finished", G_CALLBACK(notify_file_finished), assist);
assist->priv->async_file = TRUE;
g_cancellable_reset (assist->priv->cancel_file);
- ianjuta_symbol_manager_search_file_async (assist->priv->isymbol_manager,
- match_types,
- TRUE,
- fields,
- pattern, file, -1, -1,
- assist->priv->cancel_file,
- notify,
- (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
- assist,
- NULL);
+ assist->priv->async_file_id =
+ ianjuta_symbol_manager_search_file_async (assist->priv->isymbol_manager,
+ match_types,
+ TRUE,
+ fields,
+ pattern, file, -1, -1,
+ assist->priv->cancel_file,
+ notify,
+ (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
+ assist,
+ NULL);
g_object_unref (file);
}
}
@@ -690,33 +711,35 @@ cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaItera
g_signal_connect (notify, "finished", G_CALLBACK(notify_project_finished), assist);
assist->priv->async_project = TRUE;
g_cancellable_reset (assist->priv->cancel_project);
- ianjuta_symbol_manager_search_project_async (assist->priv->isymbol_manager,
- match_types,
- TRUE,
- fields,
- pattern,
- IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
- assist->priv->cancel_project,
- notify,
- (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
- assist,
- NULL);
-
+ assist->priv->async_project_id =
+ ianjuta_symbol_manager_search_project_async (assist->priv->isymbol_manager,
+ match_types,
+ TRUE,
+ fields,
+ pattern,
+ IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
+ assist->priv->cancel_project,
+ notify,
+ (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
+ assist,
+ NULL);
+
notify = anjuta_async_notify_new();
g_signal_connect (notify, "finished", G_CALLBACK(notify_system_finished), assist);
assist->priv->async_system = TRUE;
g_cancellable_reset (assist->priv->cancel_system);
- ianjuta_symbol_manager_search_system_async (assist->priv->isymbol_manager,
- match_types,
- TRUE,
- fields,
- pattern, IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
- assist->priv->cancel_system,
- notify,
- (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
- assist,
- NULL);
+ assist->priv->async_system_id =
+ ianjuta_symbol_manager_search_system_async (assist->priv->isymbol_manager,
+ match_types,
+ TRUE,
+ fields,
+ pattern, IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
+ assist->priv->cancel_system,
+ notify,
+ (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
+ assist,
+ NULL);
g_free (pre_word);
g_free (pattern);
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.h b/plugins/language-support-cpp-java/cpp-java-assist.h
index 18f1dce..33cc92d 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.h
+++ b/plugins/language-support-cpp-java/cpp-java-assist.h
@@ -65,8 +65,6 @@ GType cpp_java_assist_get_type (void) G_GNUC_CONST;
CppJavaAssist *cpp_java_assist_new (IAnjutaEditor *editor,
IAnjutaSymbolManager *isymbol_manager,
AnjutaPreferences *preferences);
-void cpp_java_assist_check (CppJavaAssist *assist, gboolean autocomplete,
- gboolean calltips, gboolean backspace);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]