Commit f2a57a4b authored by Massimo Cora's avatar Massimo Cora

Splitted interfaces for searching symbols. Now you can search in system,

	* libanjuta/interfaces/libanjuta.idl:
	* plugins/symbol-db/plugin.c (do_import_system_sources),
	(on_project_root_added), (isymbol_manager_search),
	(isymbol_manager_get_members), (isymbol_manager_search_system),
	(isymbol_manager_search_project), (isymbol_manager_search_file),
	(isymbol_manager_iface_init):
	* plugins/symbol-db/symbol-db-engine-core.c (sdb_engine_init),
	(symbol_db_engine_file_exists),
	(symbol_db_engine_add_new_workspace),
	(symbol_db_engine_project_exists),
	(symbol_db_engine_add_new_project), (sdb_engine_add_new_db_file),
	(symbol_db_engine_update_project_symbols),
	(symbol_db_engine_remove_file), (on_scan_update_buffer_end),
	(symbol_db_engine_update_buffer_symbols):
	* plugins/symbol-db/symbol-db-engine-priv.h:
	* plugins/symbol-db/symbol-db-engine-queries.c
	(symbol_db_engine_get_current_scope),
	(symbol_db_engine_get_file_symbols),
	(symbol_db_engine_find_symbol_by_name_pattern_on_file):
	* plugins/symbol-db/symbol-db-engine-queries.h:
	* plugins/symbol-db/symbol-db-engine-utils.c
	(symbol_db_util_get_full_local_path),
	(symbol_db_util_get_file_db_path),
	(symbol_db_util_get_files_with_zero_symbols),
	(symbol_db_util_is_pattern_exact_match),
	(symbol_db_util_fill_type_array),
	(symbol_db_util_get_sym_type_conversion_hash):
	* plugins/symbol-db/symbol-db-engine-utils.h:
	* plugins/symbol-db/symbol-db-view-locals.c
	(symbol_db_view_locals_update_list):
	* plugins/symbol-db/symbol-db-view-search.c
	(sdb_view_search_model_filter):
	Splitted interfaces for searching symbols. Now you can search in system,
	project or file.
	#566987 – display tooltip with prototype when calling function in project
	Fixed some lock () issues.

svn path=/trunk/; revision=4693
parent 95f5842c
2009-02-03 Massimo Cora' <mcora@svn.gnome.org>
* libanjuta/interfaces/libanjuta.idl:
* plugins/symbol-db/plugin.c (do_import_system_sources),
(on_project_root_added), (isymbol_manager_search),
(isymbol_manager_get_members), (isymbol_manager_search_system),
(isymbol_manager_search_project), (isymbol_manager_search_file),
(isymbol_manager_iface_init):
* plugins/symbol-db/symbol-db-engine-core.c (sdb_engine_init),
(symbol_db_engine_file_exists),
(symbol_db_engine_add_new_workspace),
(symbol_db_engine_project_exists),
(symbol_db_engine_add_new_project), (sdb_engine_add_new_db_file),
(symbol_db_engine_update_project_symbols),
(symbol_db_engine_remove_file), (on_scan_update_buffer_end),
(symbol_db_engine_update_buffer_symbols):
* plugins/symbol-db/symbol-db-engine-priv.h:
* plugins/symbol-db/symbol-db-engine-queries.c
(symbol_db_engine_get_current_scope),
(symbol_db_engine_get_file_symbols),
(symbol_db_engine_find_symbol_by_name_pattern_on_file):
* plugins/symbol-db/symbol-db-engine-queries.h:
* plugins/symbol-db/symbol-db-engine-utils.c
(symbol_db_util_get_full_local_path),
(symbol_db_util_get_file_db_path),
(symbol_db_util_get_files_with_zero_symbols),
(symbol_db_util_is_pattern_exact_match),
(symbol_db_util_fill_type_array),
(symbol_db_util_get_sym_type_conversion_hash):
* plugins/symbol-db/symbol-db-engine-utils.h:
* plugins/symbol-db/symbol-db-view-locals.c
(symbol_db_view_locals_update_list):
* plugins/symbol-db/symbol-db-view-search.c
(sdb_view_search_model_filter):
Splitted interfaces for searching symbols. Now you can search in system,
project or file.
#566987 – display tooltip with prototype when calling function in project
Fixed some lock () issues.
=== 2.25.901 ===
2009-02-03 Johannes Schmid <jhs@gnome.org>
......@@ -497,7 +497,7 @@ interface IAnjutaIterable
* @obj: Self
* @err: Error propagation and reporting
*
* Clones the iterable. The returned iterable object must be unrefed
* Clones the iterable. The returned iterable object must be unreffed
* when done.
*
* Returns: A new instance of this iterable pointing at the same location.
......@@ -5030,20 +5030,84 @@ interface IAnjutaSymbolManager
* @global_symbols_search: if TRUE it will search only for public/extern functions.
* If FALSE it will search also for static/private functions.
* @global_tags_search: If TRUE it'll search only for system tags, using pkg-config to retrieve installed packages
* infos. If FALSE only current project's symbols will be searched.
* info. If FALSE only current project's symbols will be searched.
* @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.
* @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.
* @err: Error propagation and reporting.
* @deprecated This function is deprecated and should not be used in new code.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
IAnjutaIterable* search (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);
/**
* ianjuta_symbol_manager_search_system:
* @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.
* @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 global (system) packages.
* User must have installed the -dev packages of, for istance, gtk+, glib, etc.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
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:
* @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.
* @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 current opened project.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
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:
* @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.
* @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.
*
* 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_get_members:
* @obj: Self
......@@ -5051,7 +5115,7 @@ interface IAnjutaSymbolManager
* @global_search: fixme
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
......@@ -5065,7 +5129,7 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
*
* Returns: if the passed symbol is a class then this function tries to catch its parents.
*
......@@ -5080,7 +5144,7 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* It gets the scope specified by the line of the file.
*
* Returns: The returned iterator should contain just one element if the query is successful,
......@@ -5097,12 +5161,12 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* Find the parent scope given a symbol
*
* Returns: The returned #IAnjutaIterable object should contain just one element if the
* query is successful, no element or NULL is returned if function went wrong.
* The returned #IAnjutaIterable object must be unrefed after use.
* The returned #IAnjutaIterable object must be unreffed after use.
*/
IAnjutaIterable* get_parent_scope (const IAnjutaSymbol *symbol, const gchar *filename, IAnjutaSymbolField info_fields);
......@@ -5113,7 +5177,7 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* While at first sight this function may seem as useless, in a deeper inspection
* you can see that you can achieve speed improvements for example avoiding
* to pass many info_fields requests to a search query, which itself could require
......@@ -5122,7 +5186,7 @@ interface IAnjutaSymbolManager
*
* Returns: The returned #IAnjutaIterable object should contain just one element if the
* query is successful, no element or NULL is returned if function went wrong.
* The returned #IAnjutaIterable object must be unrefed after use.
* The returned #IAnjutaIterable object must be unreffed after use.
*
*/
IAnjutaIterable* get_symbol_more_info (const IAnjutaSymbol *symbol, IAnjutaSymbolField info_fields);
......@@ -5134,13 +5198,13 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @return NULL on error.
*
* Database query. The returned #IAnjutaIterable object must be unrefed after use.
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* A symbol is identified by an unique id. If you have its id you can also
* have its object IAnjutaSymbol.
*
* Returns: The returned #IAnjutaIterable object should contain just one element if the
* query is successful, no element or NULL is returned if function went wrong.
* The returned #IAnjutaIterable object must be unrefed after use.
* The returned #IAnjutaIterable object must be unreffed after use.
*/
IAnjutaSymbol* get_symbol_by_id (gint symbol_id, IAnjutaSymbolField info_fields);
}
......
......@@ -1502,7 +1502,7 @@ do_import_system_sources (SymbolDBPlugin *sdb_plugin)
/* the resume thing */
GPtrArray *sys_src_array = NULL;
sys_src_array =
symbol_db_engine_get_files_with_zero_symbols (sdb_plugin->sdbe_globals);
symbol_db_util_get_files_with_zero_symbols (sdb_plugin->sdbe_globals);
if (sys_src_array != NULL && sys_src_array->len > 0)
{
......@@ -1874,7 +1874,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
sources_array =
symbol_db_engine_get_files_with_zero_symbols (sdb_plugin->sdbe_project);
symbol_db_util_get_files_with_zero_symbols (sdb_plugin->sdbe_project);
if (sources_array != NULL && sources_array->len > 0)
{
......@@ -2577,7 +2577,7 @@ isymbol_manager_search (IAnjutaSymbolManager *sm,
}
else
{
filter_array = symbol_db_engine_fill_type_array (match_types);
filter_array = symbol_db_util_fill_type_array (match_types);
/*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/
}
......@@ -2629,7 +2629,6 @@ isymbol_manager_get_members (IAnjutaSymbolManager *sm,
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);
......@@ -2770,6 +2769,134 @@ isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm,
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;
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,
TRUE,
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;
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,
FALSE,
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;
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)
{
......@@ -2780,6 +2907,9 @@ isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface)
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;
}
......
......@@ -2362,6 +2362,10 @@ sdb_engine_init (SymbolDBEngine * object)
DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILTERED,
TRUE);
DYN_QUERY_POPULATE_INIT_NODE(sdbe->priv->dyn_query_list,
DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE,
TRUE);
DYN_QUERY_POPULATE_INIT_NODE(sdbe->priv->dyn_query_list,
DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID,
TRUE);
......@@ -2874,7 +2878,7 @@ symbol_db_engine_file_exists (SymbolDBEngine * dbe, const gchar * abs_file_path)
SDB_LOCK(priv);
relative = symbol_db_engine_get_file_db_path (dbe, abs_file_path);
relative = symbol_db_util_get_file_db_path (dbe, abs_file_path);
if (relative == NULL)
{
SDB_UNLOCK(priv);
......@@ -2970,6 +2974,7 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
return TRUE;
}
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean
symbol_db_engine_add_new_workspace (SymbolDBEngine * dbe,
const gchar * workspace_name)
......@@ -2992,10 +2997,13 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
g_return_val_if_fail (priv->db_connection != NULL, FALSE);
SDB_LOCK(priv);
if ((stmt =
sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_WORKSPACE_NEW)) == NULL)
{
g_warning ("query is null");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3004,6 +3012,7 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
if ((param = gda_set_get_holder ((GdaSet*)plist, "wsname")) == NULL)
{
g_warning ("param is NULL from pquery!\n");
SDB_UNLOCK(priv);
return FALSE;
}
MP_SET_HOLDER_BATCH_STR(priv, param, workspace_name, ret_bool, ret_value);
......@@ -3013,12 +3022,15 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
(GdaStatement*)stmt,
(GdaSet*)plist, NULL, NULL) == -1)
{
SDB_UNLOCK(priv);
return FALSE;
}
SDB_UNLOCK(priv);
return TRUE;
}
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean
symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
const gchar * project_name)
......@@ -3029,6 +3041,8 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
priv = dbe->priv;
SDB_LOCK(priv);
g_return_val_if_fail (priv->db_connection != NULL, FALSE);
MP_LEND_OBJ_STR(priv,value);
g_value_set_static_string (value, project_name);
......@@ -3039,13 +3053,16 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
"prjname",
value)) <= 0)
{
SDB_UNLOCK(priv);
return FALSE;
}
SDB_UNLOCK(priv);
/* we found it */
return TRUE;
}
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean
symbol_db_engine_add_new_project (SymbolDBEngine * dbe, const gchar * workspace,
const gchar * project)
......@@ -3070,6 +3087,8 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
g_return_val_if_fail (dbe != NULL, FALSE);
priv = dbe->priv;
SDB_LOCK(priv);
if (workspace == NULL)
{
GValue *value;
......@@ -3084,12 +3103,18 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
"wsname",
value)) <= 0)
{
/* symbol_db_engine_add_new_workspace 'll lock so unlock here before */
SDB_UNLOCK(priv);
if (symbol_db_engine_add_new_workspace (dbe, workspace_name) == FALSE)
{
DEBUG_PRINT ("%s", "Project cannot be added because a default workspace "
"cannot be created");
return FALSE;
}
/* relock */
SDB_LOCK(priv);
}
}
else
......@@ -3107,6 +3132,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
value)) <= 0)
{
DEBUG_PRINT ("No workspace id");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3115,6 +3141,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_PROJECT_NEW)) == NULL)
{
g_warning ("query is null");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3124,6 +3151,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
if ((param = gda_set_get_holder ((GdaSet*)plist, "prjname")) == NULL)
{
g_warning ("param prjname is NULL from pquery!");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3132,6 +3160,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
if ((param = gda_set_get_holder ((GdaSet*)plist, "wsid")) == NULL)
{
g_warning ("param prjname is NULL from pquery!");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3142,12 +3171,15 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
(GdaStatement*)stmt,
(GdaSet*)plist, NULL, NULL) == -1)
{
SDB_UNLOCK(priv);
return FALSE;
}
SDB_UNLOCK(priv);
return TRUE;
}
/* ### Thread note: this function inherits the mutex lock ### */
static gint
sdb_engine_add_new_language (SymbolDBEngine * dbe, const gchar *language)
{
......@@ -3217,7 +3249,10 @@ CREATE TABLE language (language_id integer PRIMARY KEY AUTOINCREMENT,
return table_id;
}
/* Add a file to project.
/**
* ~~~ Thread note: this function locks the mutex ~~~
*
* Add a file to project.
* This function requires an opened db, i.e. calling before
* symbol_db_engine_open_db ()
* filepath: referes to a full file path.
......@@ -3253,6 +3288,8 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
if (strstr (local_filepath, priv->project_directory) == NULL)
return FALSE;
SDB_LOCK(priv);
MP_LEND_OBJ_STR(priv, value);
g_value_set_static_string (value, project_name);
......@@ -3263,6 +3300,7 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
value)) < 0)
{
g_warning ("no project with that name exists");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3271,10 +3309,11 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
* e.g.: we have a file on disk: "/tmp/foo/src/file.c" and a db_directory located on
* "/tmp/foo/". The entry on db will be "src/file.c"
*/
gchar *relative_path = symbol_db_engine_get_file_db_path (dbe, local_filepath);
gchar *relative_path = symbol_db_util_get_file_db_path (dbe, local_filepath);
if (relative_path == NULL)
{
DEBUG_PRINT ("%s", "relative_path == NULL");
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3301,6 +3340,7 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
{
g_warning ("query is null");
g_free (relative_path);
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3311,6 +3351,7 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
{
g_warning ("param langname is NULL from pquery!");
g_free (relative_path);
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3321,6 +3362,7 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
{
g_warning ("param prjid is NULL from pquery!");
g_free (relative_path);
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3331,6 +3373,7 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
{
g_warning ("param langid is NULL from pquery!");
g_free (relative_path);
SDB_UNLOCK(priv);
return FALSE;
}
......@@ -3343,12 +3386,14 @@ CREATE TABLE file (file_id integer PRIMARY KEY AUTOINCREMENT,
NULL) == -1)
{
g_free (relative_path);
SDB_UNLOCK(priv);
return FALSE;
}
}
g_free (relative_path);
SDB_UNLOCK(priv);
return TRUE;
}
......@@ -5317,136 +5362,6 @@ on_scan_update_files_symbols_end (SymbolDBEngine * dbe,
g_free (update_data);
}
const GHashTable*
symbol_db_engine_get_sym_type_conversion_hash (SymbolDBEngine *dbe)
{
SymbolDBEnginePriv *priv;
g_return_val_if_fail (dbe != NULL, NULL);
priv = dbe->priv;
return priv->sym_type_conversion_hash;
}
GPtrArray *
symbol_db_engine_fill_type_array (IAnjutaSymbolType match_types)
{
GPtrArray *filter_array;
filter_array = g_ptr_array_new ();
if (match_types & IANJUTA_SYMBOL_TYPE_CLASS)
{
g_ptr_array_add (filter_array, g_strdup ("class"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_ENUM)
{
g_ptr_array_add (filter_array, g_strdup ("enum"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_ENUMERATOR)
{
g_ptr_array_add (filter_array, g_strdup ("enumerator"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_FIELD)
{
g_ptr_array_add (filter_array, g_strdup ("field"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_FUNCTION)
{
g_ptr_array_add (filter_array, g_strdup ("function"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_INTERFACE)
{
g_ptr_array_add (filter_array, g_strdup ("interface"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_MEMBER)
{
g_ptr_array_add (filter_array, g_strdup ("member"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_METHOD)
{
g_ptr_array_add (filter_array, g_strdup ("method"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_NAMESPACE)
{
g_ptr_array_add (filter_array, g_strdup ("namespace"));
}
if (match_types & IANJUTA_SYMBOL_TYPE_PACKAGE)