anjuta r4693 - in trunk: . libanjuta/interfaces plugins/symbol-db
- From: mcora svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4693 - in trunk: . libanjuta/interfaces plugins/symbol-db
- Date: Tue, 3 Feb 2009 17:58:59 +0000 (UTC)
Author: mcora
Date: Tue Feb 3 17:58:59 2009
New Revision: 4693
URL: http://svn.gnome.org/viewvc/anjuta?rev=4693&view=rev
Log:
* 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.
Modified:
trunk/ChangeLog
trunk/libanjuta/interfaces/libanjuta.idl
trunk/plugins/symbol-db/plugin.c
trunk/plugins/symbol-db/symbol-db-engine-core.c
trunk/plugins/symbol-db/symbol-db-engine-priv.h
trunk/plugins/symbol-db/symbol-db-engine-queries.c
trunk/plugins/symbol-db/symbol-db-engine-queries.h
trunk/plugins/symbol-db/symbol-db-engine-utils.c
trunk/plugins/symbol-db/symbol-db-engine-utils.h
trunk/plugins/symbol-db/symbol-db-view-locals.c
trunk/plugins/symbol-db/symbol-db-view-search.c
Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl (original)
+++ trunk/libanjuta/interfaces/libanjuta.idl Tue Feb 3 17:58:59 2009
@@ -497,7 +497,7 @@
* @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,14 +5030,13 @@
* @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.
- *
- * Database query. The returned #IAnjutaIterable object must be unrefed after use.
+ * @deprecated This function is deprecated and should not be used in new code.
+ *
+ * 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.
*
@@ -5045,13 +5044,78 @@
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
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
*
* 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 @@
* @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);
}
Modified: trunk/plugins/symbol-db/plugin.c
==============================================================================
--- trunk/plugins/symbol-db/plugin.c (original)
+++ trunk/plugins/symbol-db/plugin.c Tue Feb 3 17:58:59 2009
@@ -1502,7 +1502,7 @@
/* 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 @@
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 @@
}
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);*/
}
@@ -2628,8 +2628,7 @@
SymbolDBEngineIterator *iterator;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
- dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
-
+ 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);
@@ -2767,7 +2766,135 @@
return NULL;
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iterator);
- return IANJUTA_SYMBOL (node);
+ 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
@@ -2780,6 +2907,9 @@
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;
}
Modified: trunk/plugins/symbol-db/symbol-db-engine-core.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-core.c (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-core.c Tue Feb 3 17:58:59 2009
@@ -2363,6 +2363,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
(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 @@
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 @@
"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 @@
g_return_val_if_fail (dbe != NULL, FALSE);
priv = dbe->priv;
+ SDB_LOCK(priv);
+
if (workspace == NULL)
{
GValue *value;
@@ -3084,12 +3103,18 @@
"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");
+ "cannot be created");
return FALSE;
}
+ /* relock */
+ SDB_LOCK(priv);
}
}
else
@@ -3107,6 +3132,7 @@
value)) <= 0)
{
DEBUG_PRINT ("No workspace id");
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -3115,6 +3141,7 @@
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 @@
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 @@
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 @@
(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 @@
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 @@
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 @@
value)) < 0)
{
g_warning ("no project with that name exists");
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -3271,10 +3309,11 @@
* 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 @@
{
g_warning ("query is null");
g_free (relative_path);
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -3311,6 +3351,7 @@
{
g_warning ("param langname is NULL from pquery!");
g_free (relative_path);
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -3321,6 +3362,7 @@
{
g_warning ("param prjid is NULL from pquery!");
g_free (relative_path);
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -3331,6 +3373,7 @@
{
g_warning ("param langid is NULL from pquery!");
g_free (relative_path);
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -3343,12 +3386,14 @@
NULL) == -1)
{
g_free (relative_path);
+ SDB_UNLOCK(priv);
return FALSE;
}
}
g_free (relative_path);
+ SDB_UNLOCK(priv);
return TRUE;
}
@@ -5317,136 +5362,6 @@
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)
- {
- g_ptr_array_add (filter_array, g_strdup ("package"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_PROTOTYPE)
- {
- g_ptr_array_add (filter_array, g_strdup ("prototype"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_STRUCT)
- {
- g_ptr_array_add (filter_array, g_strdup ("struct"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_TYPEDEF)
- {
- g_ptr_array_add (filter_array, g_strdup ("typedef"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_STRUCT)
- {
- g_ptr_array_add (filter_array, g_strdup ("struct"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_UNION)
- {
- g_ptr_array_add (filter_array, g_strdup ("union"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_VARIABLE)
- {
- g_ptr_array_add (filter_array, g_strdup ("variable"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_EXTERNVAR)
- {
- g_ptr_array_add (filter_array, g_strdup ("externvar"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_MACRO)
- {
- g_ptr_array_add (filter_array, g_strdup ("macro"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG)
- {
- g_ptr_array_add (filter_array, g_strdup ("macro_with_arg"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_FILE)
- {
- g_ptr_array_add (filter_array, g_strdup ("file"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_VARIABLE)
- {
- g_ptr_array_add (filter_array, g_strdup ("variable"));
- }
-
- if (match_types & IANJUTA_SYMBOL_TYPE_OTHER)
- {
- g_ptr_array_add (filter_array, g_strdup ("other"));
- }
-
- return filter_array;
-}
-
gint
symbol_db_engine_update_files_symbols (SymbolDBEngine * dbe, const gchar * project,
GPtrArray * files_path,
@@ -5564,7 +5479,6 @@
value)) <= 0)
{
SDB_UNLOCK(priv);
-
return FALSE;
}
@@ -5574,7 +5488,6 @@
{
g_warning ("query is null");
SDB_UNLOCK(priv);
-
return FALSE;
}
@@ -5585,8 +5498,7 @@
if ((param = gda_set_get_holder ((GdaSet*)plist, "prjid")) == NULL)
{
g_warning ("param prjid is NULL from pquery!");
- SDB_UNLOCK(priv);
-
+ SDB_UNLOCK(priv);
return FALSE;
}
@@ -5779,7 +5691,7 @@
return FALSE;
}
- gchar * file_on_db = symbol_db_engine_get_file_db_path (dbe, abs_file);
+ gchar * file_on_db = symbol_db_util_get_file_db_path (dbe, abs_file);
MP_SET_HOLDER_BATCH_STR(priv, param, file_on_db, ret_bool, ret_value);
/* Triggers will take care of updating/deleting connected symbols
@@ -5831,7 +5743,7 @@
for (i = 0; i < files_to_scan->len; i++)
{
gchar *node = (gchar *) g_ptr_array_index (files_to_scan, i);
- gchar *relative_path = symbol_db_engine_get_file_db_path (dbe, node);
+ gchar *relative_path = symbol_db_util_get_file_db_path (dbe, node);
if (relative_path != NULL)
{
/* will be emitted removed signals */
@@ -5905,7 +5817,7 @@
continue;
}
- relative_path = symbol_db_engine_get_file_db_path (dbe, curr_abs_file);
+ relative_path = symbol_db_util_get_file_db_path (dbe, curr_abs_file);
if (relative_path == NULL)
{
g_warning ("symbol_db_engine_update_buffer_symbols (): "
Modified: trunk/plugins/symbol-db/symbol-db-engine-priv.h
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-priv.h (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-priv.h Tue Feb 3 17:58:59 2009
@@ -47,8 +47,8 @@
#define THREADS_MAX_CONCURRENT 2
#define TRIGGER_SIGNALS_DELAY 100
-#define MEMORY_POOL_STRING_SIZE 100
-#define MEMORY_POOL_INT_SIZE 100
+#define MEMORY_POOL_STRING_SIZE 200
+#define MEMORY_POOL_INT_SIZE 200
#define USE_ASYNC_QUEUE
@@ -183,6 +183,7 @@
DYN_PREP_QUERY_GET_SYMBOL_INFO_BY_ID,
DYN_PREP_QUERY_FIND_SYMBOL_NAME_BY_PATTERN,
DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILTERED,
+ DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE,
DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID,
DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_FILTERED,
DYN_PREP_QUERY_GET_FILES_FOR_PROJECT,
Modified: trunk/plugins/symbol-db/symbol-db-engine-queries.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-queries.c (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-queries.c Tue Feb 3 17:58:59 2009
@@ -1351,7 +1351,7 @@
g_return_val_if_fail (dbe != NULL, NULL);
priv = dbe->priv;
- db_relative_file = symbol_db_engine_get_file_db_path (dbe, full_local_file_path);
+ db_relative_file = symbol_db_util_get_file_db_path (dbe, full_local_file_path);
if (db_relative_file == NULL)
return NULL;
@@ -1528,7 +1528,7 @@
return NULL;
}
- gchar *relative_path = symbol_db_engine_get_file_db_path (dbe, file_path);
+ gchar *relative_path = symbol_db_util_get_file_db_path (dbe, file_path);
if (relative_path == NULL)
{
SDB_UNLOCK(priv);
@@ -2016,6 +2016,293 @@
return res;
}
+#define DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_INCLUDE_KINDS_YES 0x010000
+#define DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_INCLUDE_KINDS_NO 0x020000
+#define DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_LIMIT 0x040000
+#define DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_OFFSET 0x080000
+#define DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_EXACT_MATCH_YES 0x100000
+#define DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_EXACT_MATCH_NO 0x200000
+
+SymbolDBEngineIterator *
+symbol_db_engine_find_symbol_by_name_pattern_on_file (SymbolDBEngine *dbe,
+ const gchar *pattern,
+ const gchar *full_local_file_path,
+ const GPtrArray *filter_kinds,
+ gboolean include_kinds,
+ gint results_limit,
+ gint results_offset,
+ SymExtraInfo sym_info)
+{
+ SymbolDBEnginePriv *priv;
+ GdaDataModel *data;
+ GString *info_data;
+ GString *join_data;
+ GString *filter_str;
+ gchar *query_str;
+ const gchar *match_str;
+ GdaHolder *param;
+ const DynChildQueryNode *dyn_node;
+ gint other_parameters;
+ gchar *limit = "";
+ gboolean limit_free = FALSE;
+ gchar *offset = "";
+ gboolean offset_free = FALSE;
+ GValue *ret_value;
+ gboolean ret_bool;
+ gchar *db_rel_path;
+
+ g_return_val_if_fail (dbe != NULL, NULL);
+ priv = dbe->priv;
+
+ SDB_LOCK(priv);
+
+ /* remove kind and path. They're already provided */
+ sym_info = sym_info & ~SYMINFO_KIND;
+ sym_info = sym_info & ~SYMINFO_FILE_PATH;
+
+ /* initialize dynamic stuff */
+ other_parameters = 0;
+ dyn_node = NULL;
+
+
+ /* check for match */
+ if (g_strrstr (pattern, "%") == NULL)
+ {
+ other_parameters |=
+ DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_EXACT_MATCH_YES;
+ match_str = " = ## /* name:'pattern' type:gchararray */";
+ }
+ else
+ {
+ other_parameters |=
+ DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_EXACT_MATCH_NO;
+ match_str = " LIKE ## /* name:'pattern' type:gchararray */";
+ }
+
+ if (results_limit > 0)
+ {
+ other_parameters |= DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_LIMIT;
+ limit_free = TRUE;
+ limit = g_strdup_printf ("LIMIT ## /* name:'limit' type:gint */");
+ }
+
+ if (results_offset > 0)
+ {
+ other_parameters |= DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_OFFSET;
+ offset_free = TRUE;
+ offset = g_strdup_printf ("OFFSET ## /* name:'offset' type:gint */");
+ }
+
+ if (filter_kinds == NULL || filter_kinds->len > 255 || filter_kinds->len <= 0)
+ {
+ if ((dyn_node = sdb_engine_get_dyn_query_node_by_id (dbe,
+ DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE, sym_info,
+ other_parameters)) == NULL)
+ {
+ /* info_data contains the stuff after SELECT and befor FROM */
+ info_data = g_string_new ("");
+
+ /* join_data contains the optionals joins to do to retrieve new data on other
+ * tables.
+ */
+ join_data = g_string_new ("");
+
+ /* fill info_data and join data with optional sql */
+ sdb_engine_prepare_symbol_info_sql (dbe, info_data, join_data, sym_info);
+
+ query_str = g_strdup_printf ("SELECT symbol.symbol_id AS symbol_id, "
+ "symbol.name AS name, symbol.file_position AS file_position, "
+ "symbol.is_file_scope AS is_file_scope, symbol.signature AS signature, "
+ "sym_kind.kind_name AS kind_name "
+ "%s FROM symbol %s JOIN sym_kind ON symbol.kind_id = sym_kind.sym_kind_id "
+ "WHERE symbol.name %s AND symbol.file_defined_id IN "
+ "(SELECT file_id FROM file WHERE file_path = ## /* name:'fpath' type:gchararray */) %s %s",
+ info_data->str, join_data->str, match_str, limit, offset);
+
+ dyn_node = sdb_engine_insert_dyn_query_node_by_id (dbe,
+ DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE,
+ sym_info, other_parameters,
+ query_str);
+
+ g_free (query_str);
+ g_string_free (info_data, TRUE);
+ g_string_free (join_data, TRUE);
+ }
+ }
+ else
+ {
+ if (include_kinds == TRUE)
+ {
+ other_parameters |=
+ DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_INCLUDE_KINDS_YES;
+ }
+ else
+ {
+ other_parameters |=
+ DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_INCLUDE_KINDS_NO;
+ }
+
+ /* set the number of parameters in the less important byte */
+ other_parameters |= filter_kinds->len;
+
+ if ((dyn_node = sdb_engine_get_dyn_query_node_by_id (dbe,
+ DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE, sym_info,
+ other_parameters)) == NULL)
+ {
+ gint i;
+
+ /* info_data contains the stuff after SELECT and before FROM */
+ info_data = g_string_new ("");
+
+ /* join_data contains the optionals joins to do to retrieve new
+ * data on other tables.
+ */
+ join_data = g_string_new ("");
+
+ /* fill info_data and join data with optional sql */
+ sdb_engine_prepare_symbol_info_sql (dbe, info_data, join_data, sym_info);
+ /* prepare the dynamic filter string before the final query */
+ filter_str = g_string_new ("");
+
+ if (include_kinds == TRUE)
+ {
+ filter_str = g_string_append (filter_str ,
+ "AND sym_kind.kind_name IN (## /* name:'filter0' type:gchararray */");
+ for (i = 1; i < filter_kinds->len; i++)
+ {
+ g_string_append_printf (filter_str ,
+ ",## /* name:'filter%d' type:gchararray */", i);
+ }
+ filter_str = g_string_append (filter_str , ")");
+ }
+ else
+ {
+ filter_str = g_string_append (filter_str ,
+ "AND sym_kind.kind_name NOT IN (## /* name:'filter0' type:gchararray */");
+ for (i = 1; i < filter_kinds->len; i++)
+ {
+ g_string_append_printf (filter_str ,
+ ",## /* name:'filter%d' type:gchararray */", i);
+ }
+ filter_str = g_string_append (filter_str , ")");
+ }
+
+ query_str = g_strdup_printf ("SELECT symbol.symbol_id AS symbol_id, symbol.name AS name, "
+ "symbol.file_position AS file_position, "
+ "symbol.is_file_scope AS is_file_scope, symbol.signature AS signature, "
+ "sym_kind.kind_name AS kind_name "
+ "%s FROM symbol %s JOIN sym_kind ON symbol.kind_id = sym_kind.sym_kind_id "
+ "WHERE symbol.name %s AND symbol.file_defined_id IN "
+ "(SELECT file_id FROM file WHERE file_path = ## /* name:'fpath' type:gchararray */) "
+ "%s GROUP BY symbol.name %s %s",
+ info_data->str, join_data->str, match_str,
+ filter_str->str, limit, offset);
+
+ dyn_node = sdb_engine_insert_dyn_query_node_by_id (dbe,
+ DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE,
+ sym_info, other_parameters,
+ query_str);
+ g_free (query_str);
+ g_string_free (info_data, TRUE);
+ g_string_free (join_data, TRUE);
+ g_string_free (filter_str, TRUE);
+ }
+ }
+
+ if (limit_free)
+ g_free (limit);
+
+ if (offset_free)
+ g_free (offset);
+
+ if (dyn_node == NULL)
+ {
+ SDB_UNLOCK(priv);
+ return NULL;
+ }
+
+ if (other_parameters & DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_LIMIT)
+ {
+ if ((param = gda_set_get_holder ((GdaSet*)dyn_node->plist, "limit")) == NULL)
+ {
+ SDB_UNLOCK(priv);
+ return NULL;
+ }
+
+ MP_SET_HOLDER_BATCH_INT(priv, param, results_limit, ret_bool, ret_value);
+ }
+
+ if (other_parameters & DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_OFFSET)
+ {
+ if ((param = gda_set_get_holder ((GdaSet*)dyn_node->plist, "offset")) == NULL)
+ {
+ SDB_UNLOCK(priv);
+ return NULL;
+ }
+
+ MP_SET_HOLDER_BATCH_INT(priv, param, results_offset, ret_bool, ret_value);
+ }
+
+ /* fill parameters for filter kinds */
+ if (other_parameters & DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_INCLUDE_KINDS_YES ||
+ other_parameters & DYN_FIND_SYMBOL_BY_NAME_PATTERN_FILE_EXTRA_PAR_INCLUDE_KINDS_NO)
+ {
+ gint i;
+ for (i = 0; i < filter_kinds->len; i++)
+ {
+ gchar *curr_str = g_strdup_printf ("filter%d", i);
+ param = gda_set_get_holder ((GdaSet*)dyn_node->plist, curr_str);
+ MP_SET_HOLDER_BATCH_STR(priv, param, g_ptr_array_index (filter_kinds, i), ret_bool, ret_value);
+ g_free (curr_str);
+ }
+ }
+
+ if ((param = gda_set_get_holder ((GdaSet*)dyn_node->plist, "pattern")) == NULL)
+ {
+ SDB_UNLOCK(priv);
+ return NULL;
+ }
+
+ MP_SET_HOLDER_BATCH_STR(priv, param, pattern, ret_bool, ret_value);
+
+ /* get the db-relative file path */
+ db_rel_path = symbol_db_util_get_file_db_path (dbe, full_local_file_path);
+ if ((param = gda_set_get_holder ((GdaSet*)dyn_node->plist, "fpath")) == NULL)
+ {
+ SDB_UNLOCK(priv);
+ g_free (db_rel_path);
+ return NULL;
+ }
+
+ MP_SET_HOLDER_BATCH_STR(priv, param, db_rel_path, ret_bool, ret_value);
+
+ /*DEBUG_PRINT ("query: %s", dyn_node->query_str);*/
+
+ /* execute the query with parametes just set */
+ data = gda_connection_statement_execute_select (priv->db_connection,
+ (GdaStatement*)dyn_node->stmt,
+ (GdaSet*)dyn_node->plist, NULL);
+
+ if (!GDA_IS_DATA_MODEL (data) ||
+ gda_data_model_get_n_rows (GDA_DATA_MODEL (data)) <= 0)
+ {
+ if (data != NULL)
+ g_object_unref (data);
+
+ SDB_UNLOCK(priv);
+ g_free (db_rel_path);
+ return NULL;
+ }
+
+ SDB_UNLOCK(priv);
+
+ g_free (db_rel_path);
+ return (SymbolDBEngineIterator *)symbol_db_engine_iterator_new (data,
+ priv->sym_type_conversion_hash,
+ priv->project_directory);
+}
+
+
/**
* @param pattern Pattern you want to search for. If NULL it will use '%' and LIKE for query.
* Please provide a pattern with '%' if you also specify a exact_match = FALSE
Modified: trunk/plugins/symbol-db/symbol-db-engine-queries.h
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-queries.h (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-queries.h Tue Feb 3 17:58:59 2009
@@ -76,6 +76,16 @@
SymExtraInfo sym_info);
+SymbolDBEngineIterator *
+symbol_db_engine_find_symbol_by_name_pattern_on_file (SymbolDBEngine *dbe,
+ const gchar *pattern,
+ const gchar *full_local_file_path,
+ const GPtrArray *filter_kinds,
+ gboolean include_kinds,
+ gint results_limit,
+ gint results_offset,
+ SymExtraInfo sym_info);
+
/**
* Return an iterator to the data retrieved from database.
* The iterator, if not null, will contain a list of parent classes for the
Modified: trunk/plugins/symbol-db/symbol-db-engine-utils.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-utils.c (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-utils.c Tue Feb 3 17:58:59 2009
@@ -65,7 +65,7 @@
}
gchar*
-symbol_db_engine_get_full_local_path (SymbolDBEngine *dbe, const gchar* file)
+symbol_db_util_get_full_local_path (SymbolDBEngine *dbe, const gchar* file)
{
SymbolDBEnginePriv *priv;
gchar *full_path;
@@ -78,7 +78,7 @@
}
gchar*
-symbol_db_engine_get_file_db_path (SymbolDBEngine *dbe, const gchar* full_local_file_path)
+symbol_db_util_get_file_db_path (SymbolDBEngine *dbe, const gchar* full_local_file_path)
{
SymbolDBEnginePriv *priv;
gchar *relative_path;
@@ -103,7 +103,7 @@
}
GPtrArray *
-symbol_db_engine_get_files_with_zero_symbols (SymbolDBEngine *dbe)
+symbol_db_util_get_files_with_zero_symbols (SymbolDBEngine *dbe)
{
/*select * from file where file_id not in (select file_defined_id from symbol);*/
SymbolDBEnginePriv *priv;
@@ -161,7 +161,7 @@
/* build abs path. */
file_name = g_value_get_string (value);
- file_abs_path = symbol_db_engine_get_full_local_path (dbe, file_name);
+ file_abs_path = symbol_db_util_get_full_local_path (dbe, file_name);
g_ptr_array_add (files_to_scan, file_abs_path);
}
@@ -239,10 +239,6 @@
CREATE_SYM_ICON ("globalglobal", "element-event-16.png");
}
-/**
- * @return The pixbufs. It will initialize pixbufs first if they weren't before
- * @param node_access can be NULL.
- */
const GdkPixbuf*
symbol_db_util_get_pixbuf (const gchar *node_type, const gchar *node_access)
{
@@ -283,3 +279,170 @@
return pix;
}
+
+gboolean
+symbol_db_util_is_pattern_exact_match (const gchar *pattern)
+{
+ gint i;
+ g_return_val_if_fail (pattern != NULL, FALSE);
+ gint str_len = strlen (pattern);
+ gboolean found_sequence = FALSE;
+ gint count = 0;
+
+ for (i = 0; i < str_len; i++)
+ {
+ gchar c = pattern[i];
+ gint j = i;
+
+ while (c == '%')
+ {
+ found_sequence = TRUE;
+ count++;
+ /* grab the next one */
+ if (j + 1 < str_len)
+ {
+ c = pattern[j+1];
+ j++;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (found_sequence)
+ break;
+ }
+
+ return (count % 2 == 1) ? FALSE : TRUE;
+}
+
+GPtrArray *
+symbol_db_util_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)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("package"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_PROTOTYPE)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("prototype"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_STRUCT)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("struct"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_TYPEDEF)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("typedef"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_STRUCT)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("struct"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_UNION)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("union"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_VARIABLE)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("variable"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_EXTERNVAR)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("externvar"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_MACRO)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("macro"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("macro_with_arg"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_FILE)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("file"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_VARIABLE)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("variable"));
+ }
+
+ if (match_types & IANJUTA_SYMBOL_TYPE_OTHER)
+ {
+ g_ptr_array_add (filter_array, g_strdup ("other"));
+ }
+
+ return filter_array;
+}
+
+const GHashTable*
+symbol_db_util_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;
+}
Modified: trunk/plugins/symbol-db/symbol-db-engine-utils.h
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-utils.h (original)
+++ trunk/plugins/symbol-db/symbol-db-engine-utils.h Tue Feb 3 17:58:59 2009
@@ -45,33 +45,33 @@
symbol_db_glist_compare_func (gconstpointer a, gconstpointer b);
/**
- * Return full_local_path given a relative-to-db file path.
+ * @return full_local_path given a relative-to-db file path.
* User must care to free the returned string.
* @param db_file Relative path inside project.
*/
gchar*
-symbol_db_engine_get_full_local_path (SymbolDBEngine *dbe, const gchar* db_file);
+symbol_db_util_get_full_local_path (SymbolDBEngine *dbe, const gchar* db_file);
/**
- * Return a db-relativ file path. Es. given the full_local_file_path
+ * @return a db-relativ file path. Es. given the full_local_file_path
* /home/user/foo_project/src/foo.c returned file should be /src/foo.c.
* Return NULL on error.
*/
gchar*
-symbol_db_engine_get_file_db_path (SymbolDBEngine *dbe, const gchar* full_local_file_path);
+symbol_db_util_get_file_db_path (SymbolDBEngine *dbe, const gchar* full_local_file_path);
/**
* Hash table that converts from a char like 'class' 'struct' etc to an
* IANJUTA_SYMBOL_TYPE
*/
const GHashTable*
-symbol_db_engine_get_sym_type_conversion_hash (SymbolDBEngine *dbe);
+symbol_db_util_get_sym_type_conversion_hash (SymbolDBEngine *dbe);
/**
- * Return a GPtrArray that must be freed from caller.
+ * @return a GPtrArray that must be freed from caller.
*/
GPtrArray *
-symbol_db_engine_fill_type_array (IAnjutaSymbolType match_types);
+symbol_db_util_fill_type_array (IAnjutaSymbolType match_types);
/**
* Try to get all the files with zero symbols: these should be the ones
@@ -80,12 +80,22 @@
* @return NULL if no files are found.
*/
GPtrArray *
-symbol_db_engine_get_files_with_zero_symbols (SymbolDBEngine *dbe);
+symbol_db_util_get_files_with_zero_symbols (SymbolDBEngine *dbe);
-/* return the pixbufs. It will initialize pixbufs first if they weren't before
- * node_access: can be NULL.
+/**
+ * @return The pixbufs. It will initialize pixbufs first if they weren't before
+ * @param node_access can be NULL.
*/
const GdkPixbuf*
symbol_db_util_get_pixbuf (const gchar *node_type, const gchar *node_access);
+/**
+ * @param pattern The pattern you want to test to check if it's an exact pattern
+ * or not. An exact pattern can be "foo_function", while a LIKE pattern can be
+ * "foo_func%". You can escape the '%' by prefixing it with another '%', e.g.
+ * "strange_search_%%_yeah"
+ */
+gboolean
+symbol_db_util_is_pattern_exact_match (const gchar *pattern);
+
#endif
Modified: trunk/plugins/symbol-db/symbol-db-view-locals.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-view-locals.c (original)
+++ trunk/plugins/symbol-db/symbol-db-view-locals.c Tue Feb 3 17:58:59 2009
@@ -1371,7 +1371,7 @@
priv->current_local_file_path = NULL;
priv->current_db_file =
- symbol_db_engine_get_file_db_path (dbe, filepath);
+ symbol_db_util_get_file_db_path (dbe, filepath);
if (priv->current_db_file == NULL)
{
DEBUG_PRINT ("Warning: priv->current_db_file is NULL");
Modified: trunk/plugins/symbol-db/symbol-db-view-search.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-view-search.c (original)
+++ trunk/plugins/symbol-db/symbol-db-view-search.c Tue Feb 3 17:58:59 2009
@@ -142,7 +142,7 @@
gint pos;
/* and now get the relative one */
- db_file_path = symbol_db_engine_get_file_db_path (priv->sdbe,
+ db_file_path = symbol_db_util_get_file_db_path (priv->sdbe,
file_path);
pos = symbol_db_engine_iterator_node_get_symbol_file_pos (iter_node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]