[anjuta] symbol-db: Fixed bgo #614906 - New: Local view shows namespaces far too often
- From: Naba Kumar <naba src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] symbol-db: Fixed bgo #614906 - New: Local view shows namespaces far too often
- Date: Tue, 6 Apr 2010 19:13:30 +0000 (UTC)
commit 7029b2fe705667203ec454c18430aacc6b53774a
Author: Naba Kumar <naba gnome org>
Date: Tue Apr 6 22:11:32 2010 +0300
symbol-db: Fixed bgo #614906 - New: Local view shows namespaces far too often
Shows only file symbols for expanded nodes in local view.
plugins/symbol-db/symbol-db-engine-queries.c | 54 ++++++++++++++++++++++--
plugins/symbol-db/symbol-db-engine-queries.h | 1 +
plugins/symbol-db/symbol-db-iface.c | 1 +
plugins/symbol-db/symbol-db-model-file.c | 56 ++++++++++++++++++--------
plugins/symbol-db/symbol-db-model-project.c | 4 +-
5 files changed, 92 insertions(+), 24 deletions(-)
---
diff --git a/plugins/symbol-db/symbol-db-engine-queries.c b/plugins/symbol-db/symbol-db-engine-queries.c
index 62b13a8..dd5c078 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.c
+++ b/plugins/symbol-db/symbol-db-engine-queries.c
@@ -1078,10 +1078,12 @@ symbol_db_engine_get_scope_members_by_symbol_id_filtered (SymbolDBEngine *dbe,
#define DYN_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_EXTRA_PAR_LIMIT 1
#define DYN_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_EXTRA_PAR_OFFSET 2
+#define DYN_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_EXTRA_PAR_FILE_PATH 4
SymbolDBEngineIterator *
symbol_db_engine_get_scope_members_by_symbol_id (SymbolDBEngine *dbe,
- gint scope_parent_symbol_id,
+ gint scope_parent_symbol_id,
+ gchar *scope_file_path,
gint results_limit,
gint results_offset,
SymExtraInfo sym_info)
@@ -1099,11 +1101,15 @@ select b.* from symbol a, symbol b where a.symbol_id = 348 and
gboolean limit_free = FALSE;
gchar *offset = "";
gboolean offset_free = FALSE;
+ gchar *file_path = "";
+ gboolean file_path_free = FALSE;
+ gchar *relative_path;
gint other_parameters;
const DynChildQueryNode *dyn_node = NULL;
GdaHolder *param;
GValue *ret_value;
gboolean ret_bool;
+ GError *error = NULL;
g_return_val_if_fail (dbe != NULL, NULL);
priv = dbe->priv;
@@ -1132,6 +1138,13 @@ select b.* from symbol a, symbol b where a.symbol_id = 348 and
other_parameters |= DYN_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_EXTRA_PAR_OFFSET;
}
+ if (scope_file_path)
+ {
+ file_path = g_strdup_printf (" AND file.file_path = ## /* name:'filepath' type:gchararray */");
+ file_path_free = TRUE;
+ other_parameters |= DYN_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_EXTRA_PAR_FILE_PATH;
+ }
+
if ((dyn_node = sdb_engine_get_dyn_query_node_by_id (dbe,
DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID, sym_info,
other_parameters)) == NULL)
@@ -1159,9 +1172,10 @@ select b.* from symbol a, symbol b where a.symbol_id = 348 and
"symbol.returntype AS returntype "
"%s FROM symbol a, symbol symbol "
"%s WHERE a.symbol_id = ## /* name:'scopeparentsymid' type:gint */ "
- "AND symbol.scope_id = a.scope_definition_id "
- "AND symbol.scope_id > 0 order by name %s %s", info_data->str, join_data->str,
- limit, offset);
+ "AND symbol.scope_id = a.scope_definition_id %s "
+ "AND symbol.scope_id > 0 order by name %s %s",
+ info_data->str, join_data->str,
+ file_path, limit, offset);
dyn_node = sdb_engine_insert_dyn_query_node_by_id (dbe,
DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID,
@@ -1179,6 +1193,9 @@ select b.* from symbol a, symbol b where a.symbol_id = 348 and
if (offset_free)
g_free (offset);
+ if (file_path_free)
+ g_free (file_path);
+
if (dyn_node == NULL)
{
SDB_UNLOCK(priv);
@@ -1216,15 +1233,42 @@ select b.* from symbol a, symbol b where a.symbol_id = 348 and
MP_SET_HOLDER_BATCH_INT(priv, param, scope_parent_symbol_id, ret_bool, ret_value);
+ if (other_parameters & DYN_GET_SCOPE_MEMBERS_BY_SYMBOL_ID_EXTRA_PAR_FILE_PATH)
+ {
+ if ((param = gda_set_get_holder ((GdaSet*)dyn_node->plist, "filepath")) == NULL)
+ {
+ SDB_UNLOCK(priv);
+ return NULL;
+ }
+
+ relative_path = symbol_db_util_get_file_db_path (dbe, scope_file_path);
+ if (relative_path == NULL)
+ {
+ SDB_UNLOCK(priv);
+ return NULL;
+ }
+
+ MP_SET_HOLDER_BATCH_STR(priv, param, relative_path, ret_bool, ret_value);
+ }
+
/*DEBUG_PRINT ("symbol_db_engine_get_scope_members_by_symbol_id (): %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);
+ (GdaSet*)dyn_node->plist,
+ &error);
+ if (error)
+ {
+ g_warning ("SQL error: %s: %s", dyn_node->query_str, error->message);
+ g_error_free (error);
+ }
+
MP_RESET_PLIST(dyn_node->plist);
+ g_free (relative_path);
+
/*gda_data_model_dump (data, stdout);*/
if (!GDA_IS_DATA_MODEL (data) ||
gda_data_model_get_n_rows (GDA_DATA_MODEL (data)) <= 0)
diff --git a/plugins/symbol-db/symbol-db-engine-queries.h b/plugins/symbol-db/symbol-db-engine-queries.h
index bbaaf01..3957bab 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.h
+++ b/plugins/symbol-db/symbol-db-engine-queries.h
@@ -281,6 +281,7 @@ symbol_db_engine_get_scope_members_by_path (SymbolDBEngine *dbe,
SymbolDBEngineIterator *
symbol_db_engine_get_scope_members_by_symbol_id (SymbolDBEngine *dbe,
gint scope_parent_symbol_id,
+ gchar *scope_file_path,
gint results_limit,
gint results_offset,
SymExtraInfo sym_info);
diff --git a/plugins/symbol-db/symbol-db-iface.c b/plugins/symbol-db/symbol-db-iface.c
index 92c30af..b57a155 100644
--- a/plugins/symbol-db/symbol-db-iface.c
+++ b/plugins/symbol-db/symbol-db-iface.c
@@ -98,6 +98,7 @@ isymbol_manager_get_members (IAnjutaSymbolManager *sm,
iterator = symbol_db_engine_get_scope_members_by_symbol_id (dbe,
sym_id,
+ NULL,
-1,
-1,
info_fields);
diff --git a/plugins/symbol-db/symbol-db-model-file.c b/plugins/symbol-db/symbol-db-model-file.c
index 67d3442..88a05c0 100644
--- a/plugins/symbol-db/symbol-db-model-file.c
+++ b/plugins/symbol-db/symbol-db-model-file.c
@@ -42,6 +42,7 @@ sdb_model_file_get_n_children (SymbolDBModel *model, gint tree_level,
SymbolDBEngine *dbe;
SymbolDBModelFilePriv *priv;
SymbolDBEngineIterator *iter = NULL;
+ gint symbol_id;
g_return_val_if_fail (SYMBOL_DB_IS_MODEL_FILE (model), 0);
priv = SYMBOL_DB_MODEL_FILE (model)->priv;
@@ -59,18 +60,27 @@ sdb_model_file_get_n_children (SymbolDBModel *model, gint tree_level,
{
iter = symbol_db_engine_get_file_symbols
(dbe, priv->file_path, -1, -1, SYMINFO_SIMPLE);
- if (iter)
- {
- n_children = symbol_db_engine_iterator_get_n_items (iter);
- g_object_unref (iter);
- return n_children;
- }
}
- return 0;
+ break;
+ case 1:
+ if (priv->file_path)
+ {
+ symbol_id = g_value_get_int (&column_values[0]); /* fixme: */
+ iter = symbol_db_engine_get_scope_members_by_symbol_id
+ (dbe, symbol_id, priv->file_path, -1, -1, SYMINFO_SIMPLE | SYMINFO_FILE_PATH);
+ }
+ break;
default:
return SYMBOL_DB_MODEL_CLASS (sdb_model_file_parent_class)->
get_n_children (model, tree_level, column_values);
}
+ if (iter)
+ {
+ n_children = symbol_db_engine_iterator_get_n_items (iter);
+ g_object_unref (iter);
+ return n_children;
+ }
+ return 0;
}
static GdaDataModel*
@@ -81,6 +91,7 @@ sdb_model_file_get_children (SymbolDBModel *model, gint tree_level,
SymbolDBEngine *dbe;
SymbolDBModelFilePriv *priv;
SymbolDBEngineIterator *iter = NULL;
+ gint symbol_id;
g_return_val_if_fail (SYMBOL_DB_IS_MODEL_FILE (model), 0);
priv = SYMBOL_DB_MODEL_FILE (model)->priv;
@@ -100,21 +111,32 @@ sdb_model_file_get_children (SymbolDBModel *model, gint tree_level,
(dbe, priv->file_path, limit, offset,
SYMINFO_SIMPLE | SYMINFO_ACCESS | SYMINFO_TYPE |
SYMINFO_KIND | SYMINFO_FILE_PATH);
- if (iter)
- {
- GdaDataModel *data_model;
- data_model =
- GDA_DATA_MODEL (symbol_db_engine_iterator_get_datamodel (iter));
- g_object_ref (data_model);
- g_object_unref (iter);
- return data_model;
- }
}
- return NULL;
+ break;
+ case 1:
+ if (priv->file_path)
+ {
+ symbol_id = g_value_get_int (&column_values[0]); /* fixme: */
+ iter = symbol_db_engine_get_scope_members_by_symbol_id
+ (dbe, symbol_id, priv->file_path, limit, offset, SYMINFO_SIMPLE |
+ SYMINFO_KIND | SYMINFO_ACCESS | SYMINFO_TYPE |
+ SYMINFO_FILE_PATH);
+ }
+ break;
default:
return SYMBOL_DB_MODEL_CLASS (sdb_model_file_parent_class)->
get_children (model, tree_level, column_values, offset, limit);
}
+ if (iter)
+ {
+ GdaDataModel *data_model;
+ data_model =
+ GDA_DATA_MODEL (symbol_db_engine_iterator_get_datamodel (iter));
+ g_object_ref (data_model);
+ g_object_unref (iter);
+ return data_model;
+ }
+ return NULL;
}
static void
diff --git a/plugins/symbol-db/symbol-db-model-project.c b/plugins/symbol-db/symbol-db-model-project.c
index ebc209e..a7645f7 100644
--- a/plugins/symbol-db/symbol-db-model-project.c
+++ b/plugins/symbol-db/symbol-db-model-project.c
@@ -76,7 +76,7 @@ sdb_model_project_get_n_children (SymbolDBModel *model, gint tree_level,
case 1:
symbol_id = g_value_get_int (&column_values[DATA_COL_SYMBOL_ID]);
iter = symbol_db_engine_get_scope_members_by_symbol_id
- (priv->dbe, symbol_id, -1, -1, SYMINFO_SIMPLE);
+ (priv->dbe, symbol_id, NULL, -1, -1, SYMINFO_SIMPLE);
break;
default:
return 0; /* FIXME */
@@ -117,7 +117,7 @@ sdb_model_project_get_children (SymbolDBModel *model, gint tree_level,
case 1:
symbol_id = g_value_get_int (&column_values[DATA_COL_SYMBOL_ID]);
iter = symbol_db_engine_get_scope_members_by_symbol_id
- (priv->dbe, symbol_id, limit, offset, SYMINFO_SIMPLE |
+ (priv->dbe, symbol_id, NULL, limit, offset, SYMINFO_SIMPLE |
SYMINFO_KIND | SYMINFO_ACCESS | SYMINFO_TYPE |
SYMINFO_FILE_PATH);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]