1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Massimo Cora' 2007 <maxcvs@email.it>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #ifndef _SYMBOL_DB_ENGINE_H_
26 #define _SYMBOL_DB_ENGINE_H_
28 #include <glib-object.h>
31 #include "symbol-db-engine-iterator.h"
35 #define SYMBOL_TYPE_DB_ENGINE (symbol_db_engine_get_type ())
36 #define SYMBOL_DB_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYMBOL_TYPE_DB_ENGINE, SymbolDBEngine))
37 #define SYMBOL_DB_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYMBOL_TYPE_DB_ENGINE, SymbolDBEngineClass))
38 #define SYMBOL_IS_DB_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYMBOL_TYPE_DB_ENGINE))
39 #define SYMBOL_IS_DB_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYMBOL_TYPE_DB_ENGINE))
40 #define SYMBOL_DB_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYMBOL_TYPE_DB_ENGINE, SymbolDBEngineClass))
42 typedef struct _SymbolDBEngineClass SymbolDBEngineClass
;
43 typedef struct _SymbolDBEngine SymbolDBEngine
;
44 typedef struct _SymbolDBEnginePriv SymbolDBEnginePriv
;
46 struct _SymbolDBEngineClass
48 GObjectClass parent_class
;
52 void (* symbol_inserted
) (gint symbol_id
);
53 void (* symbol_updated
) (gint symbol_id
);
54 void (* symbol_removed
) (gint symbol_id
);
57 struct _SymbolDBEngine
59 GObject parent_instance
;
60 SymbolDBEnginePriv
*priv
;
66 SYMINFO_FILE_PATH
= 1,
67 SYMINFO_IMPLEMENTATION
= 2,
71 SYMINFO_TYPE_NAME
= 32,
72 SYMINFO_LANGUAGE
= 64,
73 SYMINFO_FILE_IGNORE
= 128,
74 SYMINFO_FILE_INCLUDE
= 256,
75 SYMINFO_PROJECT_NAME
= 512,
76 SYMINFO_WORKSPACE_NAME
= 1024
80 GType
symbol_db_engine_get_type (void) G_GNUC_CONST
;
83 SymbolDBEngine
* symbol_db_engine_new (void);
87 * Be sure to check lock status with this function before calling
88 * something else below. If you call a scanning function while
89 * dbe is locked there can be some weird behaviours.
92 symbol_db_engine_is_locked (SymbolDBEngine
*dbe
);
95 * Open or create a new database.
96 * Be sure to give a base_prj_path with the ending '/' for directory.
97 * E.g: a project on '/tmp/foo/' dir.
100 symbol_db_engine_open_db (SymbolDBEngine
*dbe
, gchar
* base_prj_path
);
103 * Check if the database already exists into the prj_directory
106 symbol_db_engine_db_exists (SymbolDBEngine
* dbe
, gchar
* prj_directory
);
109 /** Add a new workspace to database. */
111 symbol_db_engine_add_new_workspace (SymbolDBEngine
*dbe
, gchar
* workspace
);
114 /** Add a new project to workspace.*/
116 symbol_db_engine_add_new_project (SymbolDBEngine
*dbe
, gchar
* workspace
,
120 * Return the name of the opened project.
121 * NULL on error. Returned string must be freed by caller.
124 symbol_db_engine_get_opened_project_name (SymbolDBEngine
* dbe
);
127 /** Open a project. Return false if project isn't created/opened.
128 * This function *must* be called before any other operation on db.
129 * Another option would be create a fresh new project: that way will also open it.
132 symbol_db_engine_open_project (SymbolDBEngine
*dbe
, /*gchar* workspace, */
133 const gchar
* project_name
);
136 /** Disconnect db, gda client and db_connection and close the project */
138 symbol_db_engine_close_project (SymbolDBEngine
*dbe
, gchar
* project_name
);
142 * Add a group of files of a single language to a project. It will perform also
143 * a symbols scannig/populating of db if scan_symbols is TRUE.
144 * This function requires an opened db, i.e. calling before
145 * symbol_db_engine_open_db ().
146 * @note if some file fails to enter the db the function will return without
147 * processing the remaining files.
148 * @param files_path requires full path to files on disk. Ctags itself requires that.
149 * it must be something like /path/to/my/foo/file.xyz
152 symbol_db_engine_add_new_files (SymbolDBEngine
*dbe
, gchar
* project
,
153 const GPtrArray
*files_path
,
154 gchar
*language
, gboolean scan_symbols
);
157 * Update symbols of the whole project. It scans all file symbols etc.
158 * If force is true then update forcely all the files.
161 symbol_db_engine_update_project_symbols (SymbolDBEngine
*dbe
, gchar
*project
/*,
165 /** Remove a file, together with its symbols, from a project. */
167 symbol_db_engine_remove_file (SymbolDBEngine
*dbe
, const gchar
* project
,
171 * Update symbols of saved files.
172 * WARNING: files_path and it's contents will be freed on callback.
175 symbol_db_engine_update_files_symbols (SymbolDBEngine
*dbe
, gchar
*project
,
176 GPtrArray
*files_path
,
177 gboolean update_prj_analize_time
);
180 * Update symbols of a file by a memory-buffer to perform a real-time updating
185 symbol_db_engine_update_buffer_symbols (SymbolDBEngine
* dbe
, gchar
* project
,
186 GPtrArray
* real_files_list
,
187 const GPtrArray
* text_buffers
,
188 const GPtrArray
* buffer_sizes
);
191 symbol_db_engine_get_full_local_path (SymbolDBEngine
*dbe
, const gchar
* file
);
194 * Will test the opened project within the dbe plugin and the passed one.
197 symbol_db_engine_is_project_opened (SymbolDBEngine
*dbe
, const gchar
* project_name
);
200 * Return an iterator to the data retrieved from database.
201 * It will be possible to get the scope specified by the line of the file.
203 SymbolDBEngineIterator
*
204 symbol_db_engine_get_current_scope (SymbolDBEngine
*dbe
,
205 const gchar
* filename
, gulong line
);
208 * Return an iterator to the data retrieved from database.
209 * The iterator, if not null, will contain a list of parent classes for the
212 SymbolDBEngineIterator
*
213 symbol_db_engine_get_class_parents (SymbolDBEngine
*dbe
, gchar
*klass_name
,
214 const GPtrArray
*scope_path
);
218 * scope_path cannot be NULL.
219 * scope_path will be something like "scope1_kind", "scope1_name", "scope2_kind",
220 * "scope2_name", NULL
222 SymbolDBEngineIterator
*
223 symbol_db_engine_get_scope_members (SymbolDBEngine
*dbe
,
224 const GPtrArray
* scope_path
,
228 * kind can be NULL. In that case we'll return all the kinds of symbols found
229 * at root level [global level].
231 SymbolDBEngineIterator
*
232 symbol_db_engine_get_global_members (SymbolDBEngine
*dbe
,
233 const gchar
*kind
, gint sym_info
);
235 SymbolDBEngineIterator
*
236 symbol_db_engine_get_file_symbols (SymbolDBEngine
*dbe
,
237 const gchar
*file_path
, gint sym_info
);
239 SymbolDBEngineIterator
*
240 symbol_db_engine_get_symbol_info_by_id (SymbolDBEngine
*dbe
,
241 gint sym_id
, gint sym_info
);
244 * Use this function to find symbols names by patterns like '%foo_func%'
245 * that will return a family of my_foo_func_1, your_foo_func_2 etc
247 SymbolDBEngineIterator
*
248 symbol_db_engine_find_symbol_by_name_pattern (SymbolDBEngine
*dbe
,
249 const gchar
*name
, gint sym_info
);
252 * Sometimes it's useful going to query just with ids [and so integers] to have
253 * a little speed improvement.
255 SymbolDBEngineIterator
*
256 symbol_db_engine_get_scope_members_by_symbol_id (SymbolDBEngine
*dbe
,
257 gint scope_parent_symbol_id
, gint sym_info
);
260 /* No iterator for now. We need the quickest query possible. */
262 symbol_db_engine_get_parent_scope_id_by_symbol_id (SymbolDBEngine
*dbe
,
263 gint scoped_symbol_id
);
267 #endif /* _SYMBOL_DB_ENGINE_H_ */