Commit c3e2e238 authored by Massimo Cora's avatar Massimo Cora

Implemented async interface to search database. Needs test.

	* libanjuta/interfaces/libanjuta.idl:
	* plugins/symbol-db/Makefile.am:
	* plugins/symbol-db/plugin.c (on_prefs_buffer_update_toggled):
	* plugins/symbol-db/symbol-db-engine-core.c
	(sdb_engine_get_statement_by_query_id):
	* plugins/symbol-db/symbol-db-iface.c (isymbol_manager_search),
	(isymbol_manager_get_members), (isymbol_manager_get_class_parents),
	(isymbol_manager_get_scope), (isymbol_manager_get_parent_scope),
	(isymbol_manager_get_symbol_more_info),
	(isymbol_manager_get_symbol_by_id), (do_search_prj_glb),
	(isymbol_manager_search_system), (get_unique_async_command_id),
	(on_sdb_search_command_data_arrived), (do_search_prj_glb_async),
	(isymbol_manager_search_system_async),
	(isymbol_manager_search_project),
	(isymbol_manager_search_project_async),
	(isymbol_manager_search_file), (isymbol_manager_search_file_async),
	(isymbol_manager_iface_init):
	* plugins/symbol-db/symbol-db-iface.h:
	* plugins/symbol-db/symbol-db-search-command.c
	(sdb_search_command_init), (sdb_search_command_finalize),
	(do_search_file), (do_search_prj_glb), (sdb_search_command_run),
	(sdb_search_command_class_init), (symbol_db_search_command_new),
	(symbol_db_search_command_set_file),
	(symbol_db_search_command_set_session_packages),
	(symbol_db_search_command_get_iterator_result):
	* plugins/symbol-db/symbol-db-search-command.h:
	* plugins/symbol-db/symbol-db-system.c (on_pkg_config_exit):
	Implemented async interface to search database. Needs test.

svn path=/trunk/; revision=4940
parent b4e5ceda
2009-04-13 Massimo Cora' <mcora@svn.gnome.org>
* libanjuta/interfaces/libanjuta.idl:
* plugins/symbol-db/Makefile.am:
* plugins/symbol-db/plugin.c (on_prefs_buffer_update_toggled):
* plugins/symbol-db/symbol-db-engine-core.c
(sdb_engine_get_statement_by_query_id):
* plugins/symbol-db/symbol-db-iface.c (isymbol_manager_search),
(isymbol_manager_get_members), (isymbol_manager_get_class_parents),
(isymbol_manager_get_scope), (isymbol_manager_get_parent_scope),
(isymbol_manager_get_symbol_more_info),
(isymbol_manager_get_symbol_by_id), (do_search_prj_glb),
(isymbol_manager_search_system), (get_unique_async_command_id),
(on_sdb_search_command_data_arrived), (do_search_prj_glb_async),
(isymbol_manager_search_system_async),
(isymbol_manager_search_project),
(isymbol_manager_search_project_async),
(isymbol_manager_search_file), (isymbol_manager_search_file_async),
(isymbol_manager_iface_init):
* plugins/symbol-db/symbol-db-iface.h:
* plugins/symbol-db/symbol-db-search-command.c
(sdb_search_command_init), (sdb_search_command_finalize),
(do_search_file), (do_search_prj_glb), (sdb_search_command_run),
(sdb_search_command_class_init), (symbol_db_search_command_new),
(symbol_db_search_command_set_file),
(symbol_db_search_command_set_session_packages),
(symbol_db_search_command_get_iterator_result):
* plugins/symbol-db/symbol-db-search-command.h:
* plugins/symbol-db/symbol-db-system.c (on_pkg_config_exit):
Implemented async interface to search database. Needs test.
2009-04-11 James Liggett <jrliggett@cox.net>
* libanjuta/anjuta-glade.xml:
......@@ -5048,6 +5048,7 @@ interface IAnjutaSymbol
*/
interface IAnjutaSymbolManager
{
#include <libanjuta/anjuta-async-notify.h>
#include "ianjuta-iterable.h"
#include "ianjuta-symbol.h"
......@@ -5098,7 +5099,33 @@ interface IAnjutaSymbolManager
*
*/
IAnjutaIterable* search_system (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset);
/**
* ianjuta_symbol_manager_search_project_async:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
* FALSE to exclude. For example use may want all symbols but classes.
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @cancel: An optional #GCancellable object to cancel the operation, or NULL.
* @notify: #AnjutaAsyncNotify object for finish notification and error reporting.
* @callback: #SearchCallback callback to call when query result data from database is available
* @callback_user_data: User data passed to callback
* @err: Error propagation and reporting.
*
* Async database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched in the global packages (system) context.
*
* Returns: guint handle to identify the query result. It would infact be possible to have
* more async queries at the same time. This is for identify them. Returns 0 on error.
*
*/
guint search_system_async (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset, GCancellable* cancel, AnjutaAsyncNotify *notify, SearchCallback callback, gpointer callback_user_data);
/**
* ianjuta_symbol_manager_search_project:
* @obj: Self
......@@ -5119,9 +5146,35 @@ interface IAnjutaSymbolManager
*
*/
IAnjutaIterable* search_project (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset);
/**
* ianjuta_symbol_manager_search_project_async:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
* FALSE to exclude. For example use may want all symbols but classes.
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @cancel: An optional #GCancellable object to cancel the operation, or NULL.
* @notify: #AnjutaAsyncNotify object for finish notification and error reporting.
* @callback: #SearchCallback callback to call when query result data from database is available
* @callback_user_data: User data passed to callback
* @err: Error propagation and reporting.
*
* Async database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched only in the opened project's context.
*
* Returns: guint handle to identify the query result. It would infact be possible to have
* more async queries at the same time. This is for identify them. Returns 0 on error.
*
*/
guint search_project_async (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset, GCancellable* cancel, AnjutaAsyncNotify *notify, SearchCallback callback, gpointer callback_user_data);
/**
* ianjuta_symbol_manager_search_project:
* ianjuta_symbol_manager_search_file:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
......@@ -5135,13 +5188,51 @@ interface IAnjutaSymbolManager
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched in the specified file.
* The search is case sensitive. Symbols are searched only in the specified file.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
IAnjutaIterable* search_file (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, const GFile *file, gint results_limit, gint results_offset);
/**
* ianjuta_symbol_manager_search_file_async:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
* FALSE to exclude. For example use may want all symbols but classes.
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
* @file GFile of the file, belonging to the project, which you want to scan symbols for.
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @cancel: An optional #GCancellable object to cancel the operation, or NULL.
* @notify: #AnjutaAsyncNotify object for finish notification and error reporting.
* @callback: #SearchCallback callback to call when query result data from database is available
* @callback_user_data: User data passed to callback
* @err: Error propagation and reporting.
*
* Async database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched only in the specified file.
*
* Returns: guint handle to identify the query result. It would infact be possible to have
* more async queries at the same time. This is for identify them. Returns 0 on error.
*
*/
guint search_file_async (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, const GFile *file, gint results_limit, gint results_offset, GCancellable* cancel, AnjutaAsyncNotify *notify, SearchCallback callback, gpointer callback_user_data);
/**
* IAnjutaSymbolManagerSearchCallback:
* @search_id: id that identifies uniquely the async query.
* @result: #IAnjutaIterable iterator object that contains the database query result.
* @user_data: User data
*
* Callback called for an async query to the database.
*/
typedef void (*SearchCallback) (guint search_id, IAnjutaIterable* result, gpointer user_data);
/**
* ianjuta_symbol_manager_get_members:
* @obj: Self
......
......@@ -64,7 +64,9 @@ libanjuta_symbol_db_la_SOURCES = plugin.c plugin.h \
symbol-db-engine-queries.h symbol-db-engine-utils.c \
symbol-db-engine-utils.h symbol-db-engine-priv.h \
symbol-db-engine-core.c symbol-db-engine-core.h \
symbol-db-engine.h
symbol-db-engine.h symbol-db-iface.c \
symbol-db-iface.h symbol-db-search-command.h \
symbol-db-search-command.c
libanjuta_symbol_db_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
......
......@@ -45,6 +45,7 @@
#include "symbol-db-view-search.h"
#include "symbol-db-engine.h"
#include "symbol-db-prefs.h"
#include "symbol-db-iface.h"
#define ICON_FILE "anjuta-symbol-db-plugin-48.png"
#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-symbol-db-plugin.ui"
......@@ -325,9 +326,11 @@ static GtkActionEntry actions[] =
};
static GtkActionEntry actions_search[] = {
{ "ActionEditSearchFindSymbol", GTK_STOCK_FIND, N_("_Find Symbol..."),
{
"ActionEditSearchFindSymbol", GTK_STOCK_FIND, N_("_Find Symbol..."),
"<control>l", N_("Find Symbol"),
G_CALLBACK (on_find_symbol)}
G_CALLBACK (on_find_symbol)
}
};
static void
......@@ -2546,377 +2549,6 @@ symbol_db_class_init (GObjectClass *klass)
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static IAnjutaIterable*
isymbol_manager_search (IAnjutaSymbolManager *sm,
IAnjutaSymbolType match_types,
gboolean include_types,
IAnjutaSymbolField info_fields,
const gchar *match_name,
gboolean partial_name_match,
gboolean global_symbols_search,
gboolean global_tags_search,
gint results_limit,
gint results_offset,
GError **err)
{
SymbolDBEngineIterator *iterator = NULL;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe_project;
SymbolDBEngine *dbe_globals;
GPtrArray *filter_array;
gchar *pattern;
gboolean exact_match = !partial_name_match;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe_project = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
dbe_globals = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
/*DEBUG_PRINT ("%s", "filter_array is NULL");*/
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
/*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/
}
if (exact_match == FALSE)
pattern = g_strdup_printf ("%s%%", match_name == NULL ? "" : match_name);
else
{
if (match_name == NULL)
pattern = NULL;
else
pattern = g_strdup_printf ("%s", match_name);
}
/* should we lookup for project of system tags? */
iterator =
symbol_db_engine_find_symbol_by_name_pattern_filtered (
global_tags_search == FALSE ? dbe_project : dbe_globals,
pattern,
exact_match,
filter_array,
include_types,
global_symbols_search,
global_tags_search == FALSE ? NULL : sdb_plugin->session_packages,
results_limit,
results_offset,
info_fields);
g_free (pattern);
if (filter_array)
{
g_ptr_array_foreach (filter_array, (GFunc)g_free, NULL);
g_ptr_array_free (filter_array, TRUE);
}
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_get_members (IAnjutaSymbolManager *sm,
const IAnjutaSymbol *symbol,
IAnjutaSymbolField info_fields,
gboolean global_search,
GError **err)
{
SymbolDBEngineIteratorNode *node;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
gint sym_id;
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
iterator = symbol_db_engine_get_scope_members_by_symbol_id (dbe,
sym_id,
-1,
-1,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_get_class_parents (IAnjutaSymbolManager *sm,
const IAnjutaSymbol *symbol,
IAnjutaSymbolField info_fields,
GError **err)
{
SymbolDBEngineIteratorNode *node;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
gint sym_id;
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
iterator = symbol_db_engine_get_class_parents_by_symbol_id (dbe,
sym_id,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_get_scope (IAnjutaSymbolManager *sm,
const gchar* filename,
gulong line,
IAnjutaSymbolField info_fields,
GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
iterator = symbol_db_engine_get_current_scope (dbe, filename, line, info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_get_parent_scope (IAnjutaSymbolManager *sm,
const IAnjutaSymbol *symbol,
const gchar *filename,
IAnjutaSymbolField info_fields,
GError **err)
{
SymbolDBEngineIteratorNode *node;
gint child_node_id, parent_node_id;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
child_node_id = symbol_db_engine_iterator_node_get_symbol_id (node);
if (child_node_id <= 0)
return NULL;
parent_node_id = symbol_db_engine_get_parent_scope_id_by_symbol_id (dbe,
child_node_id,
filename);
iterator = symbol_db_engine_get_symbol_info_by_id (dbe, parent_node_id,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_get_symbol_more_info (IAnjutaSymbolManager *sm,
const IAnjutaSymbol *symbol,
IAnjutaSymbolField info_fields,
GError **err)
{
SymbolDBEngineIteratorNode *node;
gint node_id;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
node_id = symbol_db_engine_iterator_node_get_symbol_id (node);
if (node_id <= 0)
return NULL;
iterator = symbol_db_engine_get_symbol_info_by_id (dbe, node_id, info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaSymbol*
isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm,
gint symbol_id,
IAnjutaSymbolField info_fields,
GError **err)
{
SymbolDBEngineIteratorNode *node;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
g_return_val_if_fail (symbol_id > 0, NULL);
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
iterator = symbol_db_engine_get_symbol_info_by_id (dbe, symbol_id,
info_fields);
if (iterator == NULL)
return NULL;
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iterator);
return IANJUTA_SYMBOL (node);
}
static IAnjutaIterable*
isymbol_manager_search_system (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types,
gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern,
gint results_limit, gint results_offset, GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
gboolean exact_match;
GPtrArray *filter_array;
g_return_val_if_fail (pattern != NULL, NULL);
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
exact_match = symbol_db_util_is_pattern_exact_match (pattern);
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
}
iterator =
symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
pattern,
exact_match,
filter_array,
include_types,
1,
sdb_plugin->session_packages,
results_limit,
results_offset,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_search_project (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types,
gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern,
gint results_limit, gint results_offset, GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
gboolean exact_match;
GPtrArray *filter_array;
g_return_val_if_fail (pattern != NULL, NULL);
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
exact_match = symbol_db_util_is_pattern_exact_match (pattern);
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
}
iterator =
symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
pattern,
exact_match,
filter_array,
include_types,
1,
NULL,
results_limit,
results_offset,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_search_file (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types,
gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern,
const GFile *file, gint results_limit, gint results_offset, GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
GPtrArray *filter_array;
gchar *abs_file_path;
g_return_val_if_fail (pattern != NULL, NULL);
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
abs_file_path = g_file_get_path ((GFile *)file);
if (abs_file_path == NULL)
{
g_warning ("isymbol_manager_search_file (): GFile has no absolute path");
return NULL;
}
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
}
iterator =
symbol_db_engine_find_symbol_by_name_pattern_on_file (dbe,
pattern,
abs_file_path,
filter_array,
include_types,
results_limit,
results_offset,
info_fields);
g_free (abs_file_path);
return IANJUTA_ITERABLE (iterator);
}
static void
isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface)
{
iface->search = isymbol_manager_search;
iface->get_members = isymbol_manager_get_members;
iface->get_class_parents = isymbol_manager_get_class_parents;
iface->get_scope = isymbol_manager_get_scope;
iface->get_parent_scope = isymbol_manager_get_parent_scope;
iface->get_symbol_more_info = isymbol_manager_get_symbol_more_info;
iface->get_symbol_by_id = isymbol_manager_get_symbol_by_id;
iface->search_system = isymbol_manager_search_system;
iface->search_project = isymbol_manager_search_project;
iface->search_file = isymbol_manager_search_file;
}
static void
......@@ -2982,8 +2614,7 @@ on_prefs_buffer_update_toggled (SymbolDBPrefs *sdbp, guint value,
on_editor_buffer_symbols_update_timeout,
sdb_plugin);
}
}
}
static void
......
......@@ -421,7 +421,6 @@ sdb_engine_get_statement_by_query_id (SymbolDBEngine * dbe, static_query_type qu
if (node->stmt == NULL)
{
/*DEBUG_PRINT ("generating new statement.. %d", query_id);*/
/* create a new GdaStatement */
node->stmt =
gda_sql_parser_parse_string (priv->sql_parser, node->query_str, NULL,
......
/*
* anjuta
* Copyright (C) Massimo Cora' 2007-2009 <maxcvs@email.it>
*
* anjuta is free software.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
#include "symbol-db-engine.h"
#include "symbol-db-search-command.h"
#include "symbol-db-iface.h"
#include "plugin.h"
#include <libanjuta/anjuta-debug.h>
static guint async_command_id = 1;
IAnjutaIterable*
isymbol_manager_search (IAnjutaSymbolManager *sm,
IAnjutaSymbolType match_types,
gboolean include_types,
IAnjutaSymbolField info_fields,
const gchar *match_name,
gboolean partial_name_match,
gboolean global_symbols_search,
gboolean global_tags_search,
gint results_limit,
gint results_offset,
GError **err)
{
SymbolDBEngineIterator *iterator = NULL;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe_project;
SymbolDBEngine *dbe_globals;
GPtrArray *filter_array;
gchar *pattern;
gboolean exact_match = !partial_name_match;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe_project = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
dbe_globals = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
/*DEBUG_PRINT ("%s", "filter_array is NULL");*/
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
/*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/
}
if (exact_match == FALSE)
pattern = g_strdup_printf ("%s%%", match_name == NULL ? "" : match_name);
else
{
if (match_name == NULL)
pattern = NULL;
else
pattern = g_strdup_printf ("%s", match_name);
}
/* should we lookup for project of system tags? */
iterator =
symbol_db_engine_find_symbol_by_name_pattern_filtered (
global_tags_search == FALSE ? dbe_project : dbe_globals,
pattern,
exact_match,
filter_array,
include_types,
global_symbols_search,
global_tags_search == FALSE ? NULL : sdb_plugin->session_packages,
results_limit,
results_offset,
info_fields);
g_free (pattern);
if (filter_array)
{
g_ptr_array_foreach (filter_array, (GFunc)g_free, NULL);
g_ptr_array_free (filter_array, TRUE);
}
return IANJUTA_ITERABLE (iterator);
}
IAnjutaIterable*
isymbol_manager_get_members (IAnjutaSymbolManager *sm,
const IAnjutaSymbol *symbol,
IAnjutaSymbolField info_fields,
gboolean global_search,
GError **err)
{
SymbolDBEngineIteratorNode *node;
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
gint sym_id;
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
iterator = symbol_db_engine_get_scope_members_by_symbol_id (dbe,
sym_id,
-1,