[anjuta] symbol-db: added api symbol_db_engine_get_scope_chain_by_file_line ().
- From: Massimo Cora' <mcora src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] symbol-db: added api symbol_db_engine_get_scope_chain_by_file_line ().
- Date: Sat, 25 Jul 2009 17:11:21 +0000 (UTC)
commit 40a3d27e63868d5f1b929d4c0b11ee8dab594bd4
Author: Massimo Corà <mcora src gnome org>
Date: Sat Jul 25 19:06:11 2009 +0200
symbol-db: added api symbol_db_engine_get_scope_chain_by_file_line ().
Preparing for pushing cxxparser test branch.
plugins/symbol-db/symbol-db-engine-queries.c | 47 +++++++++++++++++++++++--
plugins/symbol-db/symbol-db-engine-queries.h | 21 ++++++++++-
2 files changed, 62 insertions(+), 6 deletions(-)
---
diff --git a/plugins/symbol-db/symbol-db-engine-queries.c b/plugins/symbol-db/symbol-db-engine-queries.c
index bca3e9d..e848697 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.c
+++ b/plugins/symbol-db/symbol-db-engine-queries.c
@@ -1363,8 +1363,8 @@ symbol_db_engine_get_current_scope (SymbolDBEngine *dbe, const gchar* full_local
if (db_relative_file == NULL)
return NULL;
- DEBUG_PRINT ("db_relative_file %s", db_relative_file);
- DEBUG_PRINT ("full_local_file_path %s", full_local_file_path);
+ /*DEBUG_PRINT ("db_relative_file %s", db_relative_file);*/
+ /*DEBUG_PRINT ("full_local_file_path %s", full_local_file_path);*/
SDB_LOCK(priv);
@@ -2070,6 +2070,7 @@ symbol_db_engine_get_scope_chain (SymbolDBEngine *dbe,
tmp_res_data = sdb_engine_get_symbol_info_by_id_1 (dbe, scoped_symbol_id, sym_info);
gda_data_model_concat_append_model (GDA_DATA_MODEL_CONCAT (final_data),
tmp_res_data);
+ g_object_unref (tmp_res_data);
/* no need to get a lock */
/* first item is considered separately */
@@ -2078,7 +2079,9 @@ symbol_db_engine_get_scope_chain (SymbolDBEngine *dbe,
if (parent_sym_id <= 0)
{
- return NULL;
+ return (SymbolDBEngineIterator *)symbol_db_engine_iterator_new (final_data,
+ priv->sym_type_conversion_hash,
+ priv->project_directory);
}
tmp_res_data = sdb_engine_get_symbol_info_by_id_1 (dbe, parent_sym_id, sym_info);
@@ -2087,7 +2090,9 @@ symbol_db_engine_get_scope_chain (SymbolDBEngine *dbe,
if (!GDA_IS_DATA_MODEL (tmp_res_data) ||
gda_data_model_get_n_rows (GDA_DATA_MODEL (tmp_res_data)) <= 0 )
{
- return NULL;
+ return (SymbolDBEngineIterator *)symbol_db_engine_iterator_new (final_data,
+ priv->sym_type_conversion_hash,
+ priv->project_directory);
}
gda_data_model_concat_append_model (GDA_DATA_MODEL_CONCAT (final_data),
@@ -2126,6 +2131,40 @@ symbol_db_engine_get_scope_chain (SymbolDBEngine *dbe,
priv->project_directory);
}
+SymbolDBEngineIterator *
+symbol_db_engine_get_scope_chain_by_file_line (SymbolDBEngine *dbe,
+ const gchar* full_local_file_path,
+ gulong line,
+ SymExtraInfo sym_info)
+{
+ SymbolDBEngineIterator *iter, *res_iter;
+ SymbolDBEngineIteratorNode *node;
+ gchar *db_file;
+ gint symbol_id;
+
+ g_return_val_if_fail (dbe != NULL, NULL);
+ g_return_val_if_fail (full_local_file_path != NULL, NULL);
+
+ /* passing SYMINFO_SIMPLE is ok because we don't need extra info at this step */
+ iter = symbol_db_engine_get_current_scope (dbe,
+ full_local_file_path, line, SYMINFO_SIMPLE);
+
+ if (iter == NULL)
+ {
+ return NULL;
+ }
+
+ node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iter);
+ symbol_id = symbol_db_engine_iterator_node_get_symbol_id (node);
+ db_file = symbol_db_util_get_file_db_path (dbe, full_local_file_path);
+
+ res_iter = symbol_db_engine_get_scope_chain (dbe, symbol_id, db_file, sym_info);
+
+ g_free (db_file);
+ return res_iter;
+}
+
+
#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
diff --git a/plugins/symbol-db/symbol-db-engine-queries.h b/plugins/symbol-db/symbol-db-engine-queries.h
index b5e0c0b..93cfa99 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.h
+++ b/plugins/symbol-db/symbol-db-engine-queries.h
@@ -110,7 +110,8 @@ symbol_db_engine_get_class_parents_by_symbol_id (SymbolDBEngine *dbe,
*/
SymbolDBEngineIterator *
symbol_db_engine_get_current_scope (SymbolDBEngine *dbe,
- const gchar* full_local_file_path, gulong line,
+ const gchar* full_local_file_path,
+ gulong line,
SymExtraInfo sym_info);
@@ -169,6 +170,8 @@ symbol_db_engine_get_parent_scope_id_by_symbol_id (SymbolDBEngine *dbe,
* }
*
* the returned iterator'll contain symbols in this order: foo_func, FooKlass, FooBase.
+ *
+ * @return NULL on error or if scope isn't found.
*/
SymbolDBEngineIterator *
symbol_db_engine_get_scope_chain (SymbolDBEngine *dbe,
@@ -176,6 +179,20 @@ symbol_db_engine_get_scope_chain (SymbolDBEngine *dbe,
const gchar* db_file,
SymExtraInfo sym_info);
+/**
+ * Walk the path up to the root scope given a full_local_file_path and a line number.
+ * The returned iterator will be populated with SymbolDBEngineIteratorNode(s)
+ * so that it could be easily browsed by a client app.
+ *
+ * @return NULL on error or if scope isn't found.
+ */
+SymbolDBEngineIterator *
+symbol_db_engine_get_scope_chain_by_file_line (SymbolDBEngine *dbe,
+ const gchar* full_local_file_path,
+ gulong line,
+ SymExtraInfo sym_info);
+
+
/**
* scope_path cannot be NULL.
* scope_path will be something like "scope1_kind", "scope1_name", "scope2_kind",
@@ -201,7 +218,7 @@ symbol_db_engine_get_scope_members_by_symbol_id (SymbolDBEngine *dbe,
/**
* A filtered version of the symbol_db_engine_get_scope_members_by_symbol_id ().
- * You can specify which kind of symbols to retrieve, and if include them or exclude.
+ * You can specify which kind of symbols to retrieve, and if to include them or exclude.
* Kinds are 'namespace', 'class' etc.
* @param filter_kinds cannot be NULL.
* @param results_limit Limit results to an upper bound. -1 If you don't want to use this par.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]