[anjuta/sdb-queries] language-support-cpp-java: Port to new symbol query API



commit c9d6bae45c2fc1c65c6073bc91b220c7d12f48bc
Author: Naba Kumar <naba gnome org>
Date:   Sun Jun 13 01:59:35 2010 +0300

    language-support-cpp-java: Port to new symbol query API

 .../language-support-cpp-java/cpp-java-assist.c    |  350 +++++++++++---------
 .../cxxparser/engine-parser-priv.h                 |   12 +-
 .../cxxparser/engine-parser.cpp                    |  134 ++++----
 3 files changed, 265 insertions(+), 231 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index b0471a5..386f246 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -63,7 +63,6 @@ typedef struct
 
 struct _CppJavaAssistPriv {
 	AnjutaPreferences *preferences;
-	IAnjutaSymbolManager* isymbol_manager;
 	IAnjutaEditorAssist* iassist;
 	IAnjutaEditorTip* itip;
 
@@ -79,9 +78,9 @@ struct _CppJavaAssistPriv {
 	gint async_calltip_system;
 	gint async_calltip_project;
 
-	GCancellable* cancel_calltip_system;
-	GCancellable* cancel_calltip_file;
-	GCancellable* cancel_calltip_project;
+	IAnjutaSymbolQuery *calltip_query_file;
+	IAnjutaSymbolQuery *calltip_query_system;
+	IAnjutaSymbolQuery *calltip_query_project;
 
 	/* Autocompletion */
 	gboolean member_completion;
@@ -92,10 +91,13 @@ struct _CppJavaAssistPriv {
 	gint async_file_id;
 	gint async_system_id;
 	gint async_project_id;
-	
-	GCancellable* cancel_system;
-	GCancellable* cancel_file;
-	GCancellable* cancel_project;	
+
+	IAnjutaSymbolQuery *ac_query_file;
+	IAnjutaSymbolQuery *ac_query_system;
+	IAnjutaSymbolQuery *ac_query_project;
+
+	/* Member autocompletion */
+	IAnjutaSymbolQuery *query_members;
 };
 
 typedef struct
@@ -119,18 +121,18 @@ cpp_java_assist_proposal_new (IAnjutaSymbol* symbol)
 	IAnjutaSymbolType type = ianjuta_symbol_get_sym_type (symbol, NULL);
 	ProposalData* data = g_new0 (ProposalData, 1);
 
-	data->name = g_strdup (ianjuta_symbol_get_name (symbol, NULL));
+	data->name = g_strdup (ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL));
 	switch (type)
 	{
 		case IANJUTA_SYMBOL_TYPE_PROTOTYPE:
 		case IANJUTA_SYMBOL_TYPE_FUNCTION:
 		case IANJUTA_SYMBOL_TYPE_METHOD:
 		case IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG:
-			proposal->label = g_strdup_printf ("%s()", ianjuta_symbol_get_name (symbol, NULL));
+			proposal->label = g_strdup_printf ("%s()", data->name);
 			data->is_func = TRUE;
 			break;
 		default:
-			proposal->label = g_strdup (ianjuta_symbol_get_name (symbol, NULL));
+			proposal->label = g_strdup (data->name);
 			data->is_func = FALSE;
 	}
 	proposal->data = data;
@@ -173,8 +175,6 @@ 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
  *
@@ -182,7 +182,7 @@ anjuta_proposal_completion_func (gpointer data)
  * with cpp_java_assist_proposal_free()
  */
 static GList*
-cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols, gboolean local_only)
+cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols)
 {
 	GList* list = NULL;
 
@@ -191,11 +191,6 @@ cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols, gboole
 	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);
@@ -489,9 +484,12 @@ cpp_java_assist_create_completion_cache (CppJavaAssist* assist)
 static void
 cpp_java_assist_clear_completion_cache (CppJavaAssist* assist)
 {
-	g_cancellable_cancel (assist->priv->cancel_file);
-	g_cancellable_cancel (assist->priv->cancel_project);	
-	g_cancellable_cancel (assist->priv->cancel_system);
+	ianjuta_symbol_query_cancel (assist->priv->ac_query_file, NULL);
+	ianjuta_symbol_query_cancel (assist->priv->ac_query_project, NULL);
+	ianjuta_symbol_query_cancel (assist->priv->ac_query_system, NULL);
+	assist->priv->async_file_id = 0;
+	assist->priv->async_project_id = 0;
+	assist->priv->async_system_id = 0;
 	if (assist->priv->completion_cache)
 	{	
 		g_list_foreach (assist->priv->completion_cache->items, (GFunc) cpp_java_assist_proposal_free, NULL);
@@ -555,17 +553,13 @@ cpp_java_assist_create_member_completion_cache (CppJavaAssist* assist, IAnjutaIt
 		gint retval = FALSE;
 		/* Query symbol children */
 		IAnjutaIterable *children = 
-			ianjuta_symbol_manager_get_members (assist->priv->isymbol_manager,
+			ianjuta_symbol_query_search_members (assist->priv->query_members,
 			                                    IANJUTA_SYMBOL(symbol),
-			                                    IANJUTA_SYMBOL_FIELD_SIMPLE |
-			                                    IANJUTA_SYMBOL_FIELD_KIND |
-			                                    IANJUTA_SYMBOL_FIELD_ACCESS |
-			                                    IANJUTA_SYMBOL_FIELD_TYPE,
 			                                    NULL);
 		if (children)
 		{
 			GList* proposals = 
-				cpp_java_assist_create_completion_from_symbols (children, FALSE);
+				cpp_java_assist_create_completion_from_symbols (children);
 			cpp_java_assist_create_completion_cache (assist);
 			g_completion_add_items (assist->priv->completion_cache, proposals);
 
@@ -593,23 +587,17 @@ cpp_java_assist_create_member_completion_cache (CppJavaAssist* assist, IAnjutaIt
  * Called by the async search method when it found symbols
  */
 static void
-on_symbol_search_complete (gint search_id, IAnjutaIterable* symbols, CppJavaAssist* assist)
+on_symbol_search_complete (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols,
+						   CppJavaAssist* assist)
 {
 	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);
-	}
+	proposals = cpp_java_assist_create_completion_from_symbols (symbols);
 
-	if (search_id == assist->priv->async_file_id)
+	if (query == assist->priv->ac_query_file)
 		assist->priv->async_file_id = 0;
-	else if (search_id == assist->priv->async_project_id)
+	else if (query == assist->priv->ac_query_project)
 		assist->priv->async_project_id = 0;
-	else if (search_id == assist->priv->async_system_id)
+	else if (query == assist->priv->ac_query_system)
 		assist->priv->async_system_id = 0;
 	else
 		g_assert_not_reached ();
@@ -648,11 +636,6 @@ cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaItera
 	else
 	{
 		gchar *pattern = g_strconcat (pre_word, "%", NULL);
-		IAnjutaSymbolType match_types = IANJUTA_SYMBOL_TYPE_MAX;
-		IAnjutaSymbolField fields = IANJUTA_SYMBOL_FIELD_SIMPLE |
-			IANJUTA_SYMBOL_FIELD_TYPE |
-			IANJUTA_SYMBOL_FIELD_ACCESS |
-			IANJUTA_SYMBOL_FIELD_KIND;
 		
 		cpp_java_assist_create_completion_cache (assist);
 		cpp_java_assist_update_pre_word (assist, pre_word);
@@ -662,48 +645,17 @@ cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaItera
 			GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
 			if (file != NULL)
 			{
-				g_cancellable_reset (assist->priv->cancel_file);
-				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,
-					                                          NULL, 
-					                                          (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete,
-					                                          assist,
-					                                          NULL);
+				assist->priv->async_file_id = 1;
+				ianjuta_symbol_query_search_file (assist->priv->ac_query_file,
+												  pattern, file, NULL);
 				g_object_unref (file);
 			}
 		}
 		/* This will avoid duplicates of FUNCTION and PROTOTYPE */
-		match_types &= ~IANJUTA_SYMBOL_TYPE_FUNCTION;
-		g_cancellable_reset (assist->priv->cancel_project);
-		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,
-			                                             NULL, 
-			                                             (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete, 
-			                                             assist,
-			                                             NULL);
-		g_cancellable_reset (assist->priv->cancel_system);
-		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,
-			                                            NULL, 
-			                                            (IAnjutaSymbolManagerSearchCallback) on_symbol_search_complete, 
-			                                            assist,
-			                                            NULL);
+		assist->priv->async_project_id = 1;
+		ianjuta_symbol_query_search (assist->priv->ac_query_project, pattern, NULL);
+		assist->priv->async_system_id = 1;
+		ianjuta_symbol_query_search (assist->priv->ac_query_system, pattern, NULL);
 		g_free (pre_word);
 		g_free (pattern);
 
@@ -732,11 +684,11 @@ cpp_java_assist_create_calltips (IAnjutaIterable* iter, GList* merge)
 		do
 		{
 			IAnjutaSymbol* symbol = IANJUTA_SYMBOL(iter);
-			const gchar* name = ianjuta_symbol_get_name(symbol, NULL);
+			const gchar* name = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL);
 			if (name != NULL)
 			{
-				const gchar* args = ianjuta_symbol_get_args(symbol, NULL);
-				const gchar* rettype = ianjuta_symbol_get_returntype (symbol, NULL);
+				const gchar* args = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
+				const gchar* rettype = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_RETURNTYPE, NULL);
 				gchar* print_args;
 				gchar* separator;
 				gchar* white_name;
@@ -786,14 +738,15 @@ cpp_java_assist_create_calltips (IAnjutaIterable* iter, GList* merge)
  * Called by the async search method when it found calltips
  */
 static void
-on_calltip_search_complete (gint search_id, IAnjutaIterable* symbols, CppJavaAssist* assist)
+on_calltip_search_complete (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols,
+							CppJavaAssist* assist)
 {
 	assist->priv->tips = cpp_java_assist_create_calltips (symbols, assist->priv->tips);
-	if (search_id == assist->priv->async_calltip_file)
+	if (query == assist->priv->calltip_query_file)
 		assist->priv->async_calltip_file = 0;
-	else if (search_id == assist->priv->async_calltip_project)
+	else if (query == assist->priv->calltip_query_project)
 		assist->priv->async_calltip_project = 0;
-	else if (search_id == assist->priv->async_calltip_system)
+	else if (query == assist->priv->calltip_query_system)
 		assist->priv->async_calltip_system = 0;
 	else
 		g_assert_not_reached ();
@@ -823,17 +776,6 @@ static void
 cpp_java_assist_query_calltip (CppJavaAssist *assist, const gchar *call_context)
 {	
 	CppJavaAssistPriv* priv = assist->priv;
-	IAnjutaSymbolType types = 
-		IANJUTA_SYMBOL_TYPE_PROTOTYPE |
-		IANJUTA_SYMBOL_TYPE_FUNCTION |
-		IANJUTA_SYMBOL_TYPE_METHOD |
-		IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG;
-	IAnjutaSymbolField fields = 
-		IANJUTA_SYMBOL_FIELD_SIMPLE |
-		IANJUTA_SYMBOL_FIELD_TYPE |
-		IANJUTA_SYMBOL_FIELD_ACCESS |
-		IANJUTA_SYMBOL_FIELD_KIND;
-
 	
 	/* Search file */
 	if (IANJUTA_IS_FILE (assist->priv->itip))
@@ -842,52 +784,23 @@ cpp_java_assist_query_calltip (CppJavaAssist *assist, const gchar *call_context)
 
 		if (file != NULL)
 		{
-			g_cancellable_reset (assist->priv->cancel_calltip_file);
-			priv->async_calltip_file = 
-				ianjuta_symbol_manager_search_file_async (assist->priv->isymbol_manager,
-				                                          types,
-				                                          TRUE, 
-				                                          fields,
-				                                          call_context, file, -1, -1,
-				                                          assist->priv->cancel_calltip_file,
-				                                          NULL,
-				                                          (IAnjutaSymbolManagerSearchCallback) on_calltip_search_complete,
-				                                          assist,
+			priv->async_calltip_file = 1;
+			ianjuta_symbol_query_search_file (assist->priv->calltip_query_file,
+				                                          call_context, file,
 				                                          NULL);
 			g_object_unref (file);
 		}
 	}
 
-	types &= ~IANJUTA_SYMBOL_TYPE_FUNCTION;
 	/* Search Project */
-	g_cancellable_reset (assist->priv->cancel_calltip_file);
-	priv->async_calltip_project = 
-		ianjuta_symbol_manager_search_project_async (assist->priv->isymbol_manager,
-		                                             types,
-		                                             TRUE, 
-		                                             fields,
-		                                             call_context, 
-		                                             IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
-		                                             assist->priv->cancel_calltip_project,
-		                                             NULL,
-		                                             (IAnjutaSymbolManagerSearchCallback) on_calltip_search_complete,
-		                                             assist,
-		                                             NULL);
+	priv->async_calltip_project = 1;
+	ianjuta_symbol_query_search (assist->priv->calltip_query_project,
+		                                             call_context, NULL);
 	
 	/* Search system */
-	g_cancellable_reset (assist->priv->cancel_calltip_file);
-	assist->priv->async_calltip_system = 
-		ianjuta_symbol_manager_search_system_async (assist->priv->isymbol_manager,
-		                                            types,
-		                                            TRUE, 
-		                                            fields,
-		                                            call_context, 
-		                                            IANJUTA_SYMBOL_MANAGER_SEARCH_FS_PUBLIC, -1, -1,
-		                                            assist->priv->cancel_calltip_system,
-		                                            NULL,
-		                                            (IAnjutaSymbolManagerSearchCallback) on_calltip_search_complete,
-		                                            assist,
-		                                            NULL);
+	assist->priv->async_calltip_system = 1;
+	ianjuta_symbol_query_search (assist->priv->calltip_query_system,
+		                                            call_context, NULL);
 }
 
 /**
@@ -1041,9 +954,13 @@ cpp_java_assist_create_calltip_context (CppJavaAssist* assist,
 static void
 cpp_java_assist_clear_calltip_context (CppJavaAssist* assist)
 {
-	g_cancellable_cancel (assist->priv->cancel_calltip_file);
-	g_cancellable_cancel (assist->priv->cancel_calltip_project);
-	g_cancellable_cancel (assist->priv->cancel_calltip_system);
+	ianjuta_symbol_query_cancel (assist->priv->calltip_query_file, NULL);
+	ianjuta_symbol_query_cancel (assist->priv->calltip_query_project, NULL);
+	ianjuta_symbol_query_cancel (assist->priv->calltip_query_system, NULL);
+
+	assist->priv->async_calltip_file = 0;
+	assist->priv->async_calltip_project = 0;
+	assist->priv->async_calltip_system = 0;
 	
 	g_free (assist->priv->calltip_context);
 	assist->priv->calltip_context = NULL;
@@ -1370,12 +1287,6 @@ static void
 cpp_java_assist_init (CppJavaAssist *assist)
 {
 	assist->priv = g_new0 (CppJavaAssistPriv, 1);
-	assist->priv->cancel_calltip_file = g_cancellable_new();
-	assist->priv->cancel_calltip_project = g_cancellable_new();
-	assist->priv->cancel_calltip_system = g_cancellable_new();
-	assist->priv->cancel_file = g_cancellable_new();
-	assist->priv->cancel_project = g_cancellable_new();
-	assist->priv->cancel_system = g_cancellable_new();
 }
 
 static void
@@ -1385,12 +1296,6 @@ cpp_java_assist_finalize (GObject *object)
 	cpp_java_assist_uninstall (assist);
 	cpp_java_assist_clear_completion_cache (assist);
 	cpp_java_assist_clear_calltip_context (assist);
-	g_object_unref (assist->priv->cancel_calltip_file);
-	g_object_unref (assist->priv->cancel_calltip_project);
-	g_object_unref (assist->priv->cancel_calltip_system);
-	g_object_unref (assist->priv->cancel_file);
-	g_object_unref (assist->priv->cancel_project);
-	g_object_unref (assist->priv->cancel_system);		
 	g_free (assist->priv);
 	G_OBJECT_CLASS (cpp_java_assist_parent_class)->finalize (object);
 }
@@ -1409,15 +1314,148 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
 					 AnjutaPreferences *prefs)
 {
 	CppJavaAssist *assist;
-	
+	static IAnjutaSymbolField calltip_fields[] = {
+		IANJUTA_SYMBOL_FIELD_ID,
+		IANJUTA_SYMBOL_FIELD_NAME,
+		IANJUTA_SYMBOL_FIELD_RETURNTYPE,
+		IANJUTA_SYMBOL_FIELD_SIGNATURE
+	};
+	static IAnjutaSymbolField ac_fields[] = {
+		IANJUTA_SYMBOL_FIELD_ID,
+		IANJUTA_SYMBOL_FIELD_NAME,
+		IANJUTA_SYMBOL_FIELD_KIND,
+		IANJUTA_SYMBOL_FIELD_TYPE,
+		IANJUTA_SYMBOL_FIELD_ACCESS
+	};
+
 	if (!IANJUTA_IS_EDITOR_ASSIST (ieditor) && !IANJUTA_IS_EDITOR_TIP (ieditor))
 	{
 		/* No assistance is available with the current editor */
 		return NULL;
 	}
 	assist = g_object_new (TYPE_CPP_JAVA_ASSIST, NULL);
-	assist->priv->isymbol_manager = isymbol_manager;
 	assist->priv->preferences = prefs;
+
+	/* Create call tip queries */
+	/* Calltip in file */
+	assist->priv->calltip_query_file =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH_FILE,
+											 IANJUTA_SYMBOL_QUERY_DB_PROJECT,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->calltip_query_file,
+									 G_N_ELEMENTS (calltip_fields),
+									 calltip_fields, NULL);
+	ianjuta_symbol_query_set_filters (assist->priv->calltip_query_file,
+									  IANJUTA_SYMBOL_TYPE_PROTOTYPE |
+									  IANJUTA_SYMBOL_TYPE_FUNCTION |
+									  IANJUTA_SYMBOL_TYPE_METHOD |
+									  IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
+									  TRUE, NULL);
+	ianjuta_symbol_query_set_file_scope (assist->priv->calltip_query_file,
+										 IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE, NULL);
+	ianjuta_symbol_query_set_mode (assist->priv->calltip_query_file,
+								   IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
+	g_signal_connect (assist->priv->calltip_query_file, "async-result",
+					  G_CALLBACK (on_calltip_search_complete), assist);
+	/* Calltip in project */
+	assist->priv->calltip_query_project =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH,
+											 IANJUTA_SYMBOL_QUERY_DB_PROJECT,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->calltip_query_project,
+									 G_N_ELEMENTS (calltip_fields),
+									 calltip_fields, NULL);
+	ianjuta_symbol_query_set_filters (assist->priv->calltip_query_project,
+									  IANJUTA_SYMBOL_TYPE_PROTOTYPE |
+									  IANJUTA_SYMBOL_TYPE_METHOD |
+									  IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
+									  TRUE, NULL);
+	ianjuta_symbol_query_set_file_scope (assist->priv->calltip_query_project,
+										 IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+	ianjuta_symbol_query_set_mode (assist->priv->calltip_query_project,
+								   IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
+	g_signal_connect (assist->priv->calltip_query_project, "async-result",
+					  G_CALLBACK (on_calltip_search_complete), assist);
+	/* Calltip in system */
+	assist->priv->calltip_query_system =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH,
+											 IANJUTA_SYMBOL_QUERY_DB_SYSTEM,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->calltip_query_system,
+									 G_N_ELEMENTS (calltip_fields),
+									 calltip_fields, NULL);
+	ianjuta_symbol_query_set_filters (assist->priv->calltip_query_system,
+									  IANJUTA_SYMBOL_TYPE_PROTOTYPE |
+									  IANJUTA_SYMBOL_TYPE_METHOD |
+									  IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
+									  TRUE, NULL);
+	ianjuta_symbol_query_set_file_scope (assist->priv->calltip_query_system,
+										 IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+	ianjuta_symbol_query_set_mode (assist->priv->calltip_query_system,
+								   IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
+	g_signal_connect (assist->priv->calltip_query_system, "async-result",
+					  G_CALLBACK (on_calltip_search_complete), assist);
+	
+	/* Create autocomplete queries */
+	/* AC in file */
+	assist->priv->ac_query_file =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH_FILE,
+											 IANJUTA_SYMBOL_QUERY_DB_PROJECT,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->ac_query_file,
+									 G_N_ELEMENTS (ac_fields),
+									 ac_fields, NULL);
+	ianjuta_symbol_query_set_file_scope (assist->priv->ac_query_file,
+										 IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE, NULL);
+	ianjuta_symbol_query_set_mode (assist->priv->ac_query_file,
+								   IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
+	g_signal_connect (assist->priv->ac_query_file, "async-result",
+					  G_CALLBACK (on_symbol_search_complete), assist);
+	/* AC in project */
+	assist->priv->ac_query_project =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH,
+											 IANJUTA_SYMBOL_QUERY_DB_PROJECT,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->ac_query_project,
+									 G_N_ELEMENTS (ac_fields),
+									 ac_fields, NULL);
+	ianjuta_symbol_query_set_file_scope (assist->priv->ac_query_project,
+										 IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+	ianjuta_symbol_query_set_mode (assist->priv->ac_query_project,
+								   IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
+	g_signal_connect (assist->priv->ac_query_project, "async-result",
+					  G_CALLBACK (on_symbol_search_complete), assist);
+	/* AC in system */
+	assist->priv->ac_query_system =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH,
+											 IANJUTA_SYMBOL_QUERY_DB_SYSTEM,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->ac_query_system,
+									 G_N_ELEMENTS (ac_fields),
+									 ac_fields, NULL);
+	ianjuta_symbol_query_set_file_scope (assist->priv->ac_query_system,
+										 IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+	ianjuta_symbol_query_set_mode (assist->priv->ac_query_system,
+								   IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
+	g_signal_connect (assist->priv->ac_query_system, "async-result",
+					  G_CALLBACK (on_symbol_search_complete), assist);
+	
+	/* Members autocompletion */
+	assist->priv->query_members =
+		ianjuta_symbol_manager_create_query (isymbol_manager,
+											 IANJUTA_SYMBOL_QUERY_SEARCH_MEMBERS,
+											 IANJUTA_SYMBOL_QUERY_DB_PROJECT,
+											 NULL);
+	ianjuta_symbol_query_set_fields (assist->priv->query_members,
+									 G_N_ELEMENTS (ac_fields),
+									 ac_fields, NULL);
+	/* Install support */
 	cpp_java_assist_install (assist, ieditor);
 
 	engine_parser_init (isymbol_manager);	
diff --git a/plugins/language-support-cpp-java/cxxparser/engine-parser-priv.h b/plugins/language-support-cpp-java/cxxparser/engine-parser-priv.h
index 25337b8..e9c1adc 100644
--- a/plugins/language-support-cpp-java/cxxparser/engine-parser-priv.h
+++ b/plugins/language-support-cpp-java/cxxparser/engine-parser-priv.h
@@ -45,9 +45,6 @@ public:
 	/* setter for the IAnjutaSymbolManager. */
 	void setSymbolManager (IAnjutaSymbolManager *manager);
 
-	/* getter for the IAnjutaSymbolManager. */
-	IAnjutaSymbolManager * getSymbolManager ();
-
 	IAnjutaIterable * getCurrentScopeChainByFileLine (const char* full_file_path,
 	    											  unsigned long linenum);
 
@@ -64,7 +61,7 @@ public:
 
 	IAnjutaIterable * switchTypedefToStruct (IAnjutaIterable * test, 
 		IAnjutaSymbolField sym_info = 
-			(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE | IANJUTA_SYMBOL_FIELD_KIND));
+			(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_NAME | IANJUTA_SYMBOL_FIELD_KIND));
 
 	IAnjutaIterable * switchMemberToContainer (IAnjutaIterable * test);
 	
@@ -123,7 +120,12 @@ private:
 
 	CppTokenizer *_main_tokenizer;
 	CppTokenizer *_extra_tokenizer;
-	IAnjutaSymbolManager *_sym_man;
+	
+	IAnjutaSymbolQuery *query_scope;
+	IAnjutaSymbolQuery *query_search;
+	IAnjutaSymbolQuery *query_search_in_scope;
+	IAnjutaSymbolQuery *query_parent_scope;
+	IAnjutaSymbolQuery *query_scope_chain;
 };
 
 
diff --git a/plugins/language-support-cpp-java/cxxparser/engine-parser.cpp b/plugins/language-support-cpp-java/cxxparser/engine-parser.cpp
index 13e35e5..e350602 100644
--- a/plugins/language-support-cpp-java/cxxparser/engine-parser.cpp
+++ b/plugins/language-support-cpp-java/cxxparser/engine-parser.cpp
@@ -21,6 +21,7 @@
 #include <libanjuta/anjuta-debug.h>
 #include <string>
 #include <vector>
+#include <libanjuta/interfaces/ianjuta-symbol-query.h>
 #include <libanjuta/interfaces/ianjuta-symbol-manager.h>
 
 #include "engine-parser-priv.h"
@@ -51,7 +52,6 @@ EngineParser::EngineParser ()
 {	
 	_main_tokenizer = new CppTokenizer ();	
 	_extra_tokenizer = new CppTokenizer ();	
-	_sym_man = NULL;
 }
 
 EngineParser::~EngineParser ()
@@ -119,13 +119,40 @@ EngineParser::parseExpression(const string &in)
 void 
 EngineParser::setSymbolManager (IAnjutaSymbolManager *manager)
 {
-	_sym_man = manager;
-}
-
-IAnjutaSymbolManager * 
-EngineParser::getSymbolManager ()
-{
-	return _sym_man;
+	static IAnjutaSymbolField query_scope_chain_fields[] =
+	{
+		IANJUTA_SYMBOL_FIELD_ID, IANJUTA_SYMBOL_FIELD_NAME,
+		IANJUTA_SYMBOL_FIELD_KIND, IANJUTA_SYMBOL_FIELD_TYPE
+	};
+	static IAnjutaSymbolField query_search_fields[] =
+	{
+		IANJUTA_SYMBOL_FIELD_ID, IANJUTA_SYMBOL_FIELD_NAME,
+		IANJUTA_SYMBOL_FIELD_KIND
+	};
+	query_search = ianjuta_symbol_manager_create_query (manager,
+						IANJUTA_SYMBOL_QUERY_SEARCH,
+						IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
+	ianjuta_symbol_query_set_filters (query_search,
+		(IAnjutaSymbolType) (IANJUTA_SYMBOL_TYPE_SCOPE_CONTAINER |
+		 IANJUTA_SYMBOL_TYPE_TYPEDEF), TRUE, NULL);
+	ianjuta_symbol_query_set_fields (query_search,
+									 G_N_ELEMENTS (query_search_fields),
+									 query_search_fields, NULL);
+	query_scope = ianjuta_symbol_manager_create_query (manager,
+						IANJUTA_SYMBOL_QUERY_SEARCH_SCOPE,
+						IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
+	query_search_in_scope = ianjuta_symbol_manager_create_query (manager,
+						IANJUTA_SYMBOL_QUERY_SEARCH_IN_SCOPE,
+						IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
+	query_parent_scope = ianjuta_symbol_manager_create_query (manager,
+						IANJUTA_SYMBOL_QUERY_SEARCH_PARENT_SCOPE,
+						IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
+	query_scope_chain = ianjuta_symbol_manager_create_query (manager,
+						IANJUTA_SYMBOL_QUERY_SEARCH_SCOPE_CHAIN,
+						IANJUTA_SYMBOL_QUERY_DB_PROJECT, NULL);
+	ianjuta_symbol_query_set_fields (query_scope_chain,
+									 G_N_ELEMENTS (query_scope_chain_fields),
+									 query_scope_chain_fields, NULL);
 }
 
 void 
@@ -156,8 +183,7 @@ EngineParser::getCurrentScopeChainByFileLine (const char* full_file_path,
     										  unsigned long linenum)
 {	
 	IAnjutaIterable *iter = 		
-		ianjuta_symbol_manager_get_scope_chain (_sym_man, full_file_path, linenum, 
-		                                        IANJUTA_SYMBOL_FIELD_SIMPLE, NULL);
+		ianjuta_symbol_query_search_scope_chain (query_scope_chain, full_file_path, linenum, NULL);
 
 	DEBUG_PRINT ("Checking for completion scope..");
 	/* it's a global one if it's NULL or if it has just only one element */
@@ -177,7 +203,7 @@ EngineParser::getCurrentScopeChainByFileLine (const char* full_file_path,
 		{
 			IAnjutaSymbol *node = IANJUTA_SYMBOL (iter);
 			DEBUG_PRINT ("Got completion scope name: %s", 
-				ianjuta_symbol_get_name (node, NULL));
+				ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL));
 		} while (ianjuta_iterable_next (iter, NULL) == TRUE);
 	}
 	
@@ -245,10 +271,7 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
 		 */	
 		
 		IAnjutaIterable* scope_chain_iter = 
-			ianjuta_symbol_manager_get_scope_chain (_sym_man, full_file_path.c_str (), linenum, 
-			                                  IAnjutaSymbolField(IANJUTA_SYMBOL_FIELD_SIMPLE |
-			                                  IANJUTA_SYMBOL_FIELD_KIND |
-			                                  IANJUTA_SYMBOL_FIELD_TYPE), NULL);
+			ianjuta_symbol_query_search_scope_chain (query_scope_chain, full_file_path.c_str (), linenum, NULL);
 
 		/* will we find a good class scope? */
 		out_type_scope = result.m_scope.empty() ? "" : result.m_scope.c_str();
@@ -262,10 +285,10 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
 			do 
 			{
 				IAnjutaSymbol *node = IANJUTA_SYMBOL (scope_chain_iter);
-				DEBUG_PRINT ("sym_name = %s", ianjuta_symbol_get_name (node, NULL));
+				DEBUG_PRINT ("sym_name = %s", ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL));
 				if (ianjuta_symbol_get_sym_type (node, NULL) == IANJUTA_SYMBOL_TYPE_CLASS)
 				{
-					out_type_name = ianjuta_symbol_get_name (node, NULL);
+					out_type_name = ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL);
 					break;
 				}				
 			} while (ianjuta_iterable_next (scope_chain_iter, NULL) == TRUE);
@@ -321,8 +344,7 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
 		}
 
 		IAnjutaIterable* curr_scope_iter = 
-			ianjuta_symbol_manager_get_scope (_sym_man, full_file_path.c_str (), linenum, 
-			                                  IANJUTA_SYMBOL_FIELD_SIMPLE, NULL);
+			ianjuta_symbol_query_search_scope (query_scope, full_file_path.c_str (), linenum, NULL);
 
 		if (curr_scope_iter != NULL)
 		{
@@ -331,7 +353,7 @@ EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result,
 			/* try to get the signature from the symbol and test if the 
 			 * variable searched is found there.
 			 */
-			const gchar * signature = ianjuta_symbol_get_args (node, NULL);
+			const gchar * signature = ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
 			if (signature == NULL)
 			{
 				g_object_unref (curr_scope_iter);
@@ -376,16 +398,7 @@ EngineParser::getCurrentSearchableScope (string &type_name, string &type_scope)
 {
 	// FIXME: case of more results now it's hardcoded to 1
 	IAnjutaIterable *curr_searchable_scope =
-		ianjuta_symbol_manager_search_project (_sym_man, 
-		            (IAnjutaSymbolType) (IANJUTA_SYMBOL_TYPE_SCOPE_CONTAINER |
-		            IANJUTA_SYMBOL_TYPE_TYPEDEF),
-		            TRUE,
-		            (IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE | IANJUTA_SYMBOL_FIELD_KIND),
-		            type_name.c_str(),
-		            IANJUTA_SYMBOL_MANAGER_SEARCH_FS_IGNORE,
-		            -1,
-		            -1,
-		            NULL);
+		ianjuta_symbol_query_search (query_search, type_name.c_str(), NULL);
 	
 	if (curr_searchable_scope != NULL)
 	{
@@ -393,15 +406,15 @@ EngineParser::getCurrentSearchableScope (string &type_name, string &type_scope)
 
 		node = IANJUTA_SYMBOL (curr_searchable_scope);
 
-		const gchar *skind = ianjuta_symbol_get_extra_info_string (node,
+		const gchar *skind = ianjuta_symbol_get_string (node,
 		    					IANJUTA_SYMBOL_FIELD_KIND, NULL);
 		
 		DEBUG_PRINT ("Current Searchable Scope name \"%s\" kind \"%s\" and id %d",
-		             ianjuta_symbol_get_name (node, NULL), skind,
-		             ianjuta_symbol_get_id (node, NULL));
+		             ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL), skind,
+		             ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
 
 		/* is it a typedef? In that case find the parent struct */
-		if (g_strcmp0 (ianjuta_symbol_get_extra_info_string (node,
+		if (g_strcmp0 (ianjuta_symbol_get_string (node,
 		    IANJUTA_SYMBOL_FIELD_KIND, NULL), "typedef") == 0)
 		{
 			DEBUG_PRINT ("It's a TYPEDEF... trying to find the associated struct...!");
@@ -410,8 +423,8 @@ EngineParser::getCurrentSearchableScope (string &type_name, string &type_scope)
 			
 			node = IANJUTA_SYMBOL (curr_searchable_scope);
 			DEBUG_PRINT ("(NEW) Current Searchable Scope %s and id %d",
-						ianjuta_symbol_get_name (node, NULL), 
-						ianjuta_symbol_get_id (node, NULL));
+						ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_NAME, NULL), 
+						ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
 		}
 	}
 	else
@@ -436,8 +449,8 @@ EngineParser::switchTypedefToStruct (IAnjutaIterable * test,
 	IAnjutaSymbol *node = IANJUTA_SYMBOL (test);	
 	IAnjutaIterable *new_struct;
 
-	DEBUG_PRINT ("Switching TYPEDEF (%d) ==> to STRUCT", ianjuta_symbol_get_id (node, NULL));
-	new_struct = ianjuta_symbol_manager_get_parent_scope (_sym_man, node, NULL, sym_info, NULL);
+	DEBUG_PRINT ("Switching TYPEDEF (%d) ==> to STRUCT", ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
+	new_struct = ianjuta_symbol_query_search_parent_scope (query_parent_scope, node, NULL);
 	                                         
 	if (new_struct != NULL)
 	{
@@ -459,23 +472,14 @@ EngineParser::switchMemberToContainer (IAnjutaIterable * test)
 {
 	IAnjutaSymbol *node = IANJUTA_SYMBOL (test);	
 	IAnjutaIterable *new_container;
-	const gchar* sym_type_name = ianjuta_symbol_get_extra_info_string (node, 
+	const gchar* sym_type_name = ianjuta_symbol_get_string (node, 
 	                                   IANJUTA_SYMBOL_FIELD_TYPE_NAME, NULL);
 
 	DEBUG_PRINT ("Switching container with type_name %s", sym_type_name);
 
 	/* hopefully we'll find a new container for the type_name of test param */
-	new_container = ianjuta_symbol_manager_search_project (_sym_man, 
-	                IANJUTA_SYMBOL_TYPE_SCOPE_CONTAINER,
-		            TRUE,
-		            (IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE | IANJUTA_SYMBOL_FIELD_KIND |
-		                                 IANJUTA_SYMBOL_FIELD_TYPE_NAME),
-		            sym_type_name,
-		            IANJUTA_SYMBOL_MANAGER_SEARCH_FS_IGNORE,
-		            -1,
-		            -1,
-		            NULL);		
-	    
+	new_container = ianjuta_symbol_query_search (query_search,
+		            sym_type_name, NULL);
 	if (new_container != NULL)
 	{
 		g_object_unref (test);
@@ -584,24 +588,14 @@ EngineParser::processExpression(const string& stmt,
 
 		node = IANJUTA_SYMBOL (curr_searchable_scope);
 		
-		iter = ianjuta_symbol_manager_search_symbol_in_scope (_sym_man,
-		                result.m_name.c_str (),
-		                node,
-		                IANJUTA_SYMBOL_TYPE_UNDEF,
-		                TRUE,
-		                -1,
-		                -1,
-						(IAnjutaSymbolField)(IANJUTA_SYMBOL_FIELD_SIMPLE |
-		                                     IANJUTA_SYMBOL_FIELD_KIND |
-						                     IANJUTA_SYMBOL_FIELD_TYPE |
-						                     IANJUTA_SYMBOL_FIELD_TYPE_NAME),
-		                NULL);
-			
+		iter = ianjuta_symbol_query_search_in_scope (query_search_in_scope,
+		                result.m_name.c_str (), node, NULL);
+		
 		if (iter == NULL)
 		{
 			DEBUG_PRINT ("Warning, the result.m_name %s "
 				"does not belong to scope (id %d)", result.m_name.c_str (), 
-			             ianjuta_symbol_get_id (node, NULL));
+			             ianjuta_symbol_get_int (node, IANJUTA_SYMBOL_FIELD_ID, NULL));
 			
 			if (curr_searchable_scope != NULL)
 				g_object_unref (curr_searchable_scope );
@@ -614,7 +608,7 @@ EngineParser::processExpression(const string& stmt,
 			DEBUG_PRINT ("Good element %s", result.m_name.c_str ());
 			
 			node = IANJUTA_SYMBOL (iter);
-			sym_kind = (gchar*)ianjuta_symbol_get_extra_info_string (node, 
+			sym_kind = (gchar*)ianjuta_symbol_get_string (node, 
 		    										IANJUTA_SYMBOL_FIELD_KIND, NULL);
 			
 			DEBUG_PRINT (".. it has sym_kind \"%s\"", sym_kind);
@@ -626,18 +620,18 @@ EngineParser::processExpression(const string& stmt,
 			{
 				iter = switchMemberToContainer (iter);
 				node = IANJUTA_SYMBOL (iter);
-				sym_kind = (gchar*)ianjuta_symbol_get_extra_info_string (node, 
+				sym_kind = (gchar*)ianjuta_symbol_get_string (node, 
 		    										IANJUTA_SYMBOL_FIELD_KIND, NULL);				
 			}
 			
 			/* check for any typedef */
-			if (g_strcmp0 (ianjuta_symbol_get_extra_info_string (node, 
+			if (g_strcmp0 (ianjuta_symbol_get_string (node, 
 		    										IANJUTA_SYMBOL_FIELD_KIND, NULL),
 	    											"typedef") == 0)
 			{			
 				iter = switchTypedefToStruct (iter);
 				node = IANJUTA_SYMBOL (iter);
-				sym_kind = (gchar*)ianjuta_symbol_get_extra_info_string (node, 
+				sym_kind = (gchar*)ianjuta_symbol_get_string (node, 
 		    										IANJUTA_SYMBOL_FIELD_KIND, NULL);				
 			}
 			
@@ -648,10 +642,10 @@ EngineParser::processExpression(const string& stmt,
 			{
 
 				string func_ret_type_name = 
-					ianjuta_symbol_get_returntype (node, NULL);
+					ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_RETURNTYPE, NULL);
 
 				string func_signature = 
-					ianjuta_symbol_get_args (node, NULL);
+					ianjuta_symbol_get_string (node, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
 				
 				func_ret_type_name += " " + result.m_name + func_signature + "{}";
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]