Remove TmWorkObject and all the OO related stuff
In addition, rename all functions, parameters, comments etc. mentioning work_object and remove unnecessary parameters of various functions. Delete dead code paths. Also move common functions like tm_get_real_path() from tm_work_object to tm_source_file.
This commit is contained in:
parent
94a7762f91
commit
26587454b0
@ -778,8 +778,6 @@ INPUT = @top_srcdir@/src/ \
|
|||||||
@top_srcdir@/plugins/geanyfunctions.h \
|
@top_srcdir@/plugins/geanyfunctions.h \
|
||||||
@top_srcdir@/tagmanager/src/tm_source_file.c \
|
@top_srcdir@/tagmanager/src/tm_source_file.c \
|
||||||
@top_srcdir@/tagmanager/src/tm_source_file.h \
|
@top_srcdir@/tagmanager/src/tm_source_file.h \
|
||||||
@top_srcdir@/tagmanager/src/tm_work_object.c \
|
|
||||||
@top_srcdir@/tagmanager/src/tm_work_object.h \
|
|
||||||
@top_srcdir@/tagmanager/src/tm_workspace.c \
|
@top_srcdir@/tagmanager/src/tm_workspace.c \
|
||||||
@top_srcdir@/tagmanager/src/tm_workspace.h
|
@top_srcdir@/tagmanager/src/tm_workspace.h
|
||||||
|
|
||||||
|
@ -98,7 +98,6 @@ doxygen_sources = \
|
|||||||
$(top_srcdir)/plugins/geanyplugin.h \
|
$(top_srcdir)/plugins/geanyplugin.h \
|
||||||
$(top_srcdir)/plugins/geanyfunctions.h \
|
$(top_srcdir)/plugins/geanyfunctions.h \
|
||||||
$(top_srcdir)/tagmanager/src/tm_source_file.[ch] \
|
$(top_srcdir)/tagmanager/src/tm_source_file.[ch] \
|
||||||
$(top_srcdir)/tagmanager/src/tm_work_object.[ch] \
|
|
||||||
$(top_srcdir)/tagmanager/src/tm_workspace.[ch]
|
$(top_srcdir)/tagmanager/src/tm_workspace.[ch]
|
||||||
|
|
||||||
Doxyfile.stamp: Doxyfile $(doxygen_sources)
|
Doxyfile.stamp: Doxyfile $(doxygen_sources)
|
||||||
|
@ -346,14 +346,14 @@
|
|||||||
geany_functions->p_tm->tm_get_real_path
|
geany_functions->p_tm->tm_get_real_path
|
||||||
#define tm_source_file_new \
|
#define tm_source_file_new \
|
||||||
geany_functions->p_tm->tm_source_file_new
|
geany_functions->p_tm->tm_source_file_new
|
||||||
#define tm_workspace_add_object \
|
#define tm_workspace_add_source_file \
|
||||||
geany_functions->p_tm->tm_workspace_add_object
|
geany_functions->p_tm->tm_workspace_add_source_file
|
||||||
#define tm_source_file_update \
|
#define tm_source_file_update \
|
||||||
geany_functions->p_tm->tm_source_file_update
|
geany_functions->p_tm->tm_source_file_update
|
||||||
#define tm_work_object_free \
|
#define tm_source_file_free \
|
||||||
geany_functions->p_tm->tm_work_object_free
|
geany_functions->p_tm->tm_source_file_free
|
||||||
#define tm_workspace_remove_object \
|
#define tm_workspace_remove_source_file \
|
||||||
geany_functions->p_tm->tm_workspace_remove_object
|
geany_functions->p_tm->tm_workspace_remove_source_file
|
||||||
#define search_show_find_in_files_dialog \
|
#define search_show_find_in_files_dialog \
|
||||||
geany_functions->p_search->search_show_find_in_files_dialog
|
geany_functions->p_search->search_show_find_in_files_dialog
|
||||||
#define highlighting_get_style \
|
#define highlighting_get_style \
|
||||||
|
@ -502,7 +502,7 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
|
|||||||
document_rename_file(doc, utf8_filename);
|
document_rename_file(doc, utf8_filename);
|
||||||
}
|
}
|
||||||
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
|
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
|
||||||
tm_workspace_remove_object(doc->tm_file, TRUE, TRUE);
|
tm_workspace_remove_source_file(doc->tm_file, TRUE, TRUE);
|
||||||
doc->tm_file = NULL;
|
doc->tm_file = NULL;
|
||||||
}
|
}
|
||||||
success = document_save_file_as(doc, utf8_filename);
|
success = document_save_file_as(doc, utf8_filename);
|
||||||
|
@ -140,7 +140,7 @@ static GtkWidget* document_show_message(GeanyDocument *doc, GtkMessageType msgty
|
|||||||
* string returned by @c tm_get_real_path().
|
* string returned by @c tm_get_real_path().
|
||||||
*
|
*
|
||||||
* @return The matching document, or @c NULL.
|
* @return The matching document, or @c NULL.
|
||||||
* @note This is only really useful when passing a @c TMWorkObject::file_name.
|
* @note This is only really useful when passing a @c TMSourceFile::file_name.
|
||||||
* @see GeanyDocument::real_path.
|
* @see GeanyDocument::real_path.
|
||||||
* @see document_find_by_filename().
|
* @see document_find_by_filename().
|
||||||
*
|
*
|
||||||
@ -714,7 +714,7 @@ static gboolean remove_page(guint page_num)
|
|||||||
g_free(doc->priv->saved_encoding.encoding);
|
g_free(doc->priv->saved_encoding.encoding);
|
||||||
g_free(doc->file_name);
|
g_free(doc->file_name);
|
||||||
g_free(doc->real_path);
|
g_free(doc->real_path);
|
||||||
tm_workspace_remove_object(doc->tm_file, TRUE, !main_status.quitting);
|
tm_workspace_remove_source_file(doc->tm_file, TRUE, !main_status.quitting);
|
||||||
|
|
||||||
if (doc->priv->tag_tree)
|
if (doc->priv->tag_tree)
|
||||||
gtk_widget_destroy(doc->priv->tag_tree);
|
gtk_widget_destroy(doc->priv->tag_tree);
|
||||||
@ -2486,14 +2486,14 @@ void document_update_tags(GeanyDocument *doc)
|
|||||||
doc->tm_file = tm_source_file_new(locale_filename, FALSE, name);
|
doc->tm_file = tm_source_file_new(locale_filename, FALSE, name);
|
||||||
g_free(locale_filename);
|
g_free(locale_filename);
|
||||||
|
|
||||||
if (doc->tm_file && !tm_workspace_add_object(doc->tm_file))
|
if (doc->tm_file && !tm_workspace_add_source_file(doc->tm_file))
|
||||||
{
|
{
|
||||||
tm_work_object_free(doc->tm_file);
|
tm_source_file_free(doc->tm_file);
|
||||||
doc->tm_file = NULL;
|
doc->tm_file = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* early out if there's no work object and we couldn't create one */
|
/* early out if there's no tm source file and we couldn't create one */
|
||||||
if (doc->tm_file == NULL)
|
if (doc->tm_file == NULL)
|
||||||
{
|
{
|
||||||
/* We must call sidebar_update_tag_list() before returning,
|
/* We must call sidebar_update_tag_list() before returning,
|
||||||
@ -2555,12 +2555,12 @@ void document_highlight_tags(GeanyDocument *doc)
|
|||||||
default:
|
default:
|
||||||
return; /* early out if type keywords are not supported */
|
return; /* early out if type keywords are not supported */
|
||||||
}
|
}
|
||||||
if (!app->tm_workspace->work_object.tags_array)
|
if (!app->tm_workspace->tags_array)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* get any type keywords and tell scintilla about them
|
/* get any type keywords and tell scintilla about them
|
||||||
* this will cause the type keywords to be colourized in scintilla */
|
* this will cause the type keywords to be colourized in scintilla */
|
||||||
keywords_str = symbols_find_tags_as_string(app->tm_workspace->work_object.tags_array,
|
keywords_str = symbols_find_tags_as_string(app->tm_workspace->tags_array,
|
||||||
TM_GLOBAL_TYPE_MASK, doc->file_type->lang);
|
TM_GLOBAL_TYPE_MASK, doc->file_type->lang);
|
||||||
if (keywords_str)
|
if (keywords_str)
|
||||||
{
|
{
|
||||||
@ -2617,7 +2617,7 @@ static void document_load_config(GeanyDocument *doc, GeanyFiletype *type,
|
|||||||
/* delete tm file object to force creation of a new one */
|
/* delete tm file object to force creation of a new one */
|
||||||
if (doc->tm_file != NULL)
|
if (doc->tm_file != NULL)
|
||||||
{
|
{
|
||||||
tm_workspace_remove_object(doc->tm_file, TRUE, TRUE);
|
tm_workspace_remove_source_file(doc->tm_file, TRUE, TRUE);
|
||||||
doc->tm_file = NULL;
|
doc->tm_file = NULL;
|
||||||
}
|
}
|
||||||
/* load tags files before highlighting (some lexers highlight global typenames) */
|
/* load tags files before highlighting (some lexers highlight global typenames) */
|
||||||
|
@ -93,8 +93,8 @@ typedef struct GeanyDocument
|
|||||||
/** The filetype for this document, it's only a reference to one of the elements of the global
|
/** The filetype for this document, it's only a reference to one of the elements of the global
|
||||||
* filetypes array. */
|
* filetypes array. */
|
||||||
GeanyFiletype *file_type;
|
GeanyFiletype *file_type;
|
||||||
/** TMWorkObject object for this document, or @c NULL. */
|
/** TMSourceFile object for this document, or @c NULL. */
|
||||||
TMWorkObject *tm_file;
|
TMSourceFile *tm_file;
|
||||||
/** Whether this document is read-only. */
|
/** Whether this document is read-only. */
|
||||||
gboolean readonly;
|
gboolean readonly;
|
||||||
/** Whether this document has been changed since it was last saved. */
|
/** Whether this document has been changed since it was last saved. */
|
||||||
|
@ -735,7 +735,7 @@ static void autocomplete_scope(GeanyEditor *editor)
|
|||||||
name = tag->atts.entry.var_type;
|
name = tag->atts.entry.var_type;
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
TMWorkObject *obj = editor->document->tm_file;
|
TMSourceFile *obj = editor->document->tm_file;
|
||||||
|
|
||||||
tags = tm_workspace_find_scope_members(obj ? obj->tags_array : NULL,
|
tags = tm_workspace_find_scope_members(obj ? obj->tags_array : NULL,
|
||||||
name, TRUE, FALSE);
|
name, TRUE, FALSE);
|
||||||
|
@ -1289,7 +1289,7 @@ static void do_main_quit(void)
|
|||||||
filetypes_free_types();
|
filetypes_free_types();
|
||||||
log_finalize();
|
log_finalize();
|
||||||
|
|
||||||
tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));
|
tm_workspace_free();
|
||||||
g_free(app->configdir);
|
g_free(app->configdir);
|
||||||
g_free(app->datadir);
|
g_free(app->datadir);
|
||||||
g_free(app->docdir);
|
g_free(app->docdir);
|
||||||
|
@ -599,12 +599,11 @@ SearchFuncs;
|
|||||||
typedef struct TagManagerFuncs
|
typedef struct TagManagerFuncs
|
||||||
{
|
{
|
||||||
gchar* (*tm_get_real_path) (const gchar *file_name);
|
gchar* (*tm_get_real_path) (const gchar *file_name);
|
||||||
TMWorkObject* (*tm_source_file_new) (const char *file_name, gboolean update, const char *name);
|
TMSourceFile* (*tm_source_file_new) (const char *file_name, gboolean update, const char *name);
|
||||||
gboolean (*tm_workspace_add_object) (TMWorkObject *work_object);
|
gboolean (*tm_workspace_add_source_file) (TMSourceFile *source_file);
|
||||||
gboolean (*tm_source_file_update) (TMWorkObject *source_file, gboolean force,
|
void (*tm_source_file_update) (TMSourceFile *source_file, gboolean update_workspace);
|
||||||
gboolean recurse, gboolean update_parent);
|
void (*tm_source_file_free) (TMSourceFile *source_file);
|
||||||
void (*tm_work_object_free) (gpointer work_object);
|
gboolean (*tm_workspace_remove_source_file) (TMSourceFile *source_file, gboolean do_free, gboolean update);
|
||||||
gboolean (*tm_workspace_remove_object) (TMWorkObject *w, gboolean do_free, gboolean update);
|
|
||||||
}
|
}
|
||||||
TagManagerFuncs;
|
TagManagerFuncs;
|
||||||
|
|
||||||
|
@ -290,10 +290,10 @@ static KeybindingFuncs keybindings_funcs = {
|
|||||||
static TagManagerFuncs tagmanager_funcs = {
|
static TagManagerFuncs tagmanager_funcs = {
|
||||||
&tm_get_real_path,
|
&tm_get_real_path,
|
||||||
&tm_source_file_new,
|
&tm_source_file_new,
|
||||||
&tm_workspace_add_object,
|
&tm_workspace_add_source_file,
|
||||||
&tm_source_file_update,
|
&tm_source_file_update,
|
||||||
&tm_work_object_free,
|
&tm_source_file_free,
|
||||||
&tm_workspace_remove_object
|
&tm_workspace_remove_source_file
|
||||||
};
|
};
|
||||||
|
|
||||||
static SearchFuncs search_funcs = {
|
static SearchFuncs search_funcs = {
|
||||||
|
@ -333,17 +333,17 @@ GString *symbols_get_macro_list(gint lang)
|
|||||||
gint tag_lang;
|
gint tag_lang;
|
||||||
TMTag *tag;
|
TMTag *tag;
|
||||||
|
|
||||||
if (app->tm_workspace->work_objects == NULL)
|
if (app->tm_workspace->source_files == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ftags = g_ptr_array_sized_new(50);
|
ftags = g_ptr_array_sized_new(50);
|
||||||
words = g_string_sized_new(200);
|
words = g_string_sized_new(200);
|
||||||
|
|
||||||
for (j = 0; j < app->tm_workspace->work_objects->len; j++)
|
for (j = 0; j < app->tm_workspace->source_files->len; j++)
|
||||||
{
|
{
|
||||||
GPtrArray *tags;
|
GPtrArray *tags;
|
||||||
|
|
||||||
tags = tm_tags_extract(TM_WORK_OBJECT(app->tm_workspace->work_objects->pdata[j])->tags_array,
|
tags = tm_tags_extract(TM_SOURCE_FILE(app->tm_workspace->source_files->pdata[j])->tags_array,
|
||||||
tm_tag_enum_t | tm_tag_variable_t | tm_tag_macro_t | tm_tag_macro_with_arg_t);
|
tm_tag_enum_t | tm_tag_variable_t | tm_tag_macro_t | tm_tag_macro_with_arg_t);
|
||||||
if (NULL != tags)
|
if (NULL != tags)
|
||||||
{
|
{
|
||||||
@ -395,24 +395,21 @@ symbols_find_tm_tag(const GPtrArray *tags, const gchar *tag_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TMTag *find_work_object_tag(const TMWorkObject *workobj,
|
static TMTag *find_source_file_tag(GPtrArray *tags_array,
|
||||||
const gchar *tag_name, guint type)
|
const gchar *tag_name, guint type)
|
||||||
{
|
{
|
||||||
GPtrArray *tags;
|
GPtrArray *tags;
|
||||||
TMTag *tmtag;
|
TMTag *tmtag;
|
||||||
|
|
||||||
if (G_LIKELY(workobj != NULL))
|
tags = tm_tags_extract(tags_array, type);
|
||||||
|
if (tags != NULL)
|
||||||
{
|
{
|
||||||
tags = tm_tags_extract(workobj->tags_array, type);
|
tmtag = symbols_find_tm_tag(tags, tag_name);
|
||||||
if (tags != NULL)
|
|
||||||
{
|
|
||||||
tmtag = symbols_find_tm_tag(tags, tag_name);
|
|
||||||
|
|
||||||
g_ptr_array_free(tags, TRUE);
|
g_ptr_array_free(tags, TRUE);
|
||||||
|
|
||||||
if (tmtag != NULL)
|
if (tmtag != NULL)
|
||||||
return tmtag;
|
return tmtag;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL; /* not found */
|
return NULL; /* not found */
|
||||||
}
|
}
|
||||||
@ -421,19 +418,19 @@ static TMTag *find_work_object_tag(const TMWorkObject *workobj,
|
|||||||
static TMTag *find_workspace_tag(const gchar *tag_name, guint type)
|
static TMTag *find_workspace_tag(const gchar *tag_name, guint type)
|
||||||
{
|
{
|
||||||
guint j;
|
guint j;
|
||||||
const GPtrArray *work_objects = NULL;
|
const GPtrArray *source_files = NULL;
|
||||||
|
|
||||||
if (app->tm_workspace != NULL)
|
if (app->tm_workspace != NULL)
|
||||||
work_objects = app->tm_workspace->work_objects;
|
source_files = app->tm_workspace->source_files;
|
||||||
|
|
||||||
if (work_objects != NULL)
|
if (source_files != NULL)
|
||||||
{
|
{
|
||||||
for (j = 0; j < work_objects->len; j++)
|
for (j = 0; j < source_files->len; j++)
|
||||||
{
|
{
|
||||||
TMWorkObject *workobj = TM_WORK_OBJECT(work_objects->pdata[j]);
|
TMSourceFile *srcfile = source_files->pdata[j];
|
||||||
TMTag *tmtag;
|
TMTag *tmtag;
|
||||||
|
|
||||||
tmtag = find_work_object_tag(workobj, tag_name, type);
|
tmtag = find_source_file_tag(srcfile->tags_array, tag_name, type);
|
||||||
if (tmtag != NULL)
|
if (tmtag != NULL)
|
||||||
return tmtag;
|
return tmtag;
|
||||||
}
|
}
|
||||||
@ -1941,7 +1938,7 @@ static gboolean goto_tag(const gchar *name, gboolean definition)
|
|||||||
|
|
||||||
/* first look in the current document */
|
/* first look in the current document */
|
||||||
if (old_doc != NULL && old_doc->tm_file)
|
if (old_doc != NULL && old_doc->tm_file)
|
||||||
tmtag = find_work_object_tag(old_doc->tm_file, name, type);
|
tmtag = find_source_file_tag(old_doc->tm_file->tags_array, name, type);
|
||||||
|
|
||||||
/* if not found, look in the workspace */
|
/* if not found, look in the workspace */
|
||||||
if (tmtag == NULL)
|
if (tmtag == NULL)
|
||||||
@ -1950,7 +1947,7 @@ static gboolean goto_tag(const gchar *name, gboolean definition)
|
|||||||
if (tmtag != NULL)
|
if (tmtag != NULL)
|
||||||
{
|
{
|
||||||
GeanyDocument *new_doc = document_find_by_real_path(
|
GeanyDocument *new_doc = document_find_by_real_path(
|
||||||
tmtag->atts.entry.file->work_object.file_name);
|
tmtag->atts.entry.file->file_name);
|
||||||
|
|
||||||
if (new_doc)
|
if (new_doc)
|
||||||
{
|
{
|
||||||
@ -1965,7 +1962,7 @@ static gboolean goto_tag(const gchar *name, gboolean definition)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* not found in opened document, should open */
|
/* not found in opened document, should open */
|
||||||
new_doc = document_open_file(tmtag->atts.entry.file->work_object.file_name, FALSE, NULL, NULL);
|
new_doc = document_open_file(tmtag->atts.entry.file->file_name, FALSE, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navqueue_goto_line(old_doc, new_doc, tmtag->atts.entry.line))
|
if (navqueue_goto_line(old_doc, new_doc, tmtag->atts.entry.line))
|
||||||
|
@ -17,7 +17,6 @@ tagmanager_include_HEADERS = \
|
|||||||
tm_source_file.h \
|
tm_source_file.h \
|
||||||
tm_tag.h \
|
tm_tag.h \
|
||||||
tm_tagmanager.h \
|
tm_tagmanager.h \
|
||||||
tm_work_object.h \
|
|
||||||
tm_workspace.h
|
tm_workspace.h
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +29,5 @@ libtagmanager_a_SOURCES =\
|
|||||||
tm_source_file.c \
|
tm_source_file.c \
|
||||||
tm_tag.h \
|
tm_tag.h \
|
||||||
tm_tag.c \
|
tm_tag.c \
|
||||||
tm_work_object.c \
|
|
||||||
tm_work_object.h \
|
|
||||||
tm_workspace.h \
|
tm_workspace.h \
|
||||||
tm_workspace.c
|
tm_workspace.c
|
||||||
|
@ -44,7 +44,7 @@ all: $(COMPLIB)
|
|||||||
clean:
|
clean:
|
||||||
-$(RM) deps.mak *.o $(COMPLIB)
|
-$(RM) deps.mak *.o $(COMPLIB)
|
||||||
|
|
||||||
$(COMPLIB): tm_workspace.o tm_work_object.o tm_source_file.o tm_tag.o \
|
$(COMPLIB): tm_workspace.o tm_source_file.o tm_tag.o \
|
||||||
tm_file_entry.o
|
tm_file_entry.o
|
||||||
$(AR) rc $@ $^
|
$(AR) rc $@ $^
|
||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
@ -24,9 +24,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "tm_work_object.h"
|
|
||||||
#include "tm_file_entry.h"
|
#include "tm_file_entry.h"
|
||||||
|
#include "tm_source_file.h"
|
||||||
|
|
||||||
#define FILE_NEW(T) ((T) = g_slice_new0(TMFileEntry))
|
#define FILE_NEW(T) ((T) = g_slice_new0(TMFileEntry))
|
||||||
#define FILE_FREE(T) g_slice_free(TMFileEntry, (T))
|
#define FILE_FREE(T) g_slice_free(TMFileEntry, (T))
|
||||||
|
@ -18,35 +18,114 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
# define VC_EXTRALEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h> /* for GetFullPathName */
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "entry.h"
|
#include "entry.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
#include "read.h"
|
#include "read.h"
|
||||||
#define LIBCTAGS_DEFINED
|
#define LIBCTAGS_DEFINED
|
||||||
#include "tm_work_object.h"
|
#include "tm_workspace.h"
|
||||||
|
|
||||||
#include "tm_source_file.h"
|
#include "tm_source_file.h"
|
||||||
#include "tm_tag.h"
|
#include "tm_tag.h"
|
||||||
|
|
||||||
|
|
||||||
guint source_file_class_id = 0;
|
|
||||||
static TMSourceFile *current_source_file = NULL;
|
static TMSourceFile *current_source_file = NULL;
|
||||||
|
|
||||||
|
static int get_path_max(const char *path)
|
||||||
|
{
|
||||||
|
#ifdef PATH_MAX
|
||||||
|
return PATH_MAX;
|
||||||
|
#else
|
||||||
|
int path_max = pathconf(path, _PC_PATH_MAX);
|
||||||
|
if (path_max <= 0)
|
||||||
|
path_max = 4096;
|
||||||
|
return path_max;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
/* realpath implementation for Windows found at http://bugzilla.gnome.org/show_bug.cgi?id=342926
|
||||||
|
* this one is better than e.g. liberty's lrealpath because this one uses Win32 API and works
|
||||||
|
* with special chars within the filename */
|
||||||
|
static char *realpath (const char *pathname, char *resolved_path)
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if (resolved_path != NULL)
|
||||||
|
{
|
||||||
|
int path_max = get_path_max(pathname);
|
||||||
|
size = GetFullPathNameA (pathname, path_max, resolved_path, NULL);
|
||||||
|
if (size > path_max)
|
||||||
|
return NULL;
|
||||||
|
else
|
||||||
|
return resolved_path;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size = GetFullPathNameA (pathname, 0, NULL, NULL);
|
||||||
|
resolved_path = g_new0 (char, size);
|
||||||
|
GetFullPathNameA (pathname, size, resolved_path, NULL);
|
||||||
|
return resolved_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gchar *tm_get_real_path(const gchar *file_name)
|
||||||
|
{
|
||||||
|
if (file_name)
|
||||||
|
{
|
||||||
|
gsize len = get_path_max(file_name) + 1;
|
||||||
|
gchar *path = g_malloc0(len);
|
||||||
|
|
||||||
|
if (realpath(file_name, path))
|
||||||
|
return path;
|
||||||
|
else
|
||||||
|
g_free(path);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
|
gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
|
||||||
, gboolean update, const char* name)
|
, gboolean update, const char* name)
|
||||||
{
|
{
|
||||||
if (0 == source_file_class_id)
|
struct stat s;
|
||||||
source_file_class_id = tm_work_object_register(tm_source_file_free
|
int status;
|
||||||
, tm_source_file_update, NULL);
|
|
||||||
|
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Source File init: %s", file_name);
|
g_message("Source File init: %s", file_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (FALSE == tm_work_object_init(&(source_file->work_object),
|
if (file_name != NULL)
|
||||||
source_file_class_id, file_name, FALSE))
|
{
|
||||||
return FALSE;
|
status = g_stat(file_name, &s);
|
||||||
|
if (0 != status)
|
||||||
|
{
|
||||||
|
/* g_warning("Unable to stat %s", file_name);*/
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!S_ISREG(s.st_mode))
|
||||||
|
{
|
||||||
|
g_warning("%s: Not a regular file", file_name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
source_file->file_name = tm_get_real_path(file_name);
|
||||||
|
source_file->short_name = strrchr(source_file->file_name, '/');
|
||||||
|
if (source_file->short_name)
|
||||||
|
++ source_file->short_name;
|
||||||
|
else
|
||||||
|
source_file->short_name = source_file->file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
source_file->tags_array = NULL;
|
||||||
|
|
||||||
source_file->inactive = FALSE;
|
source_file->inactive = FALSE;
|
||||||
if (NULL == LanguageTable)
|
if (NULL == LanguageTable)
|
||||||
@ -65,11 +144,11 @@ gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
|
|||||||
source_file->lang = getNamedLanguage(name);
|
source_file->lang = getNamedLanguage(name);
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
tm_source_file_update(TM_WORK_OBJECT(source_file), TRUE, FALSE, FALSE);
|
tm_source_file_update(source_file, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TMWorkObject *tm_source_file_new(const char *file_name, gboolean update, const char *name)
|
TMSourceFile *tm_source_file_new(const char *file_name, gboolean update, const char *name)
|
||||||
{
|
{
|
||||||
TMSourceFile *source_file = g_new(TMSourceFile, 1);
|
TMSourceFile *source_file = g_new(TMSourceFile, 1);
|
||||||
if (TRUE != tm_source_file_init(source_file, file_name, update, name))
|
if (TRUE != tm_source_file_init(source_file, file_name, update, name))
|
||||||
@ -77,24 +156,24 @@ TMWorkObject *tm_source_file_new(const char *file_name, gboolean update, const c
|
|||||||
g_free(source_file);
|
g_free(source_file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (TMWorkObject *) source_file;
|
return source_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tm_source_file_destroy(TMSourceFile *source_file)
|
void tm_source_file_destroy(TMSourceFile *source_file)
|
||||||
{
|
{
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Destroying source file: %s", source_file->work_object.file_name);
|
g_message("Destroying source file: %s", source_file->file_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NULL != TM_WORK_OBJECT(source_file)->tags_array)
|
g_free(source_file->file_name);
|
||||||
|
if (NULL != source_file->tags_array)
|
||||||
{
|
{
|
||||||
tm_tags_array_free(TM_WORK_OBJECT(source_file)->tags_array, TRUE);
|
tm_tags_array_free(source_file->tags_array, TRUE);
|
||||||
TM_WORK_OBJECT(source_file)->tags_array = NULL;
|
source_file->tags_array = NULL;
|
||||||
}
|
}
|
||||||
tm_work_object_destroy(&(source_file->work_object));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tm_source_file_free(gpointer source_file)
|
void tm_source_file_free(TMSourceFile *source_file)
|
||||||
{
|
{
|
||||||
if (NULL != source_file)
|
if (NULL != source_file)
|
||||||
{
|
{
|
||||||
@ -109,13 +188,13 @@ gboolean tm_source_file_parse(TMSourceFile *source_file)
|
|||||||
gboolean status = TRUE;
|
gboolean status = TRUE;
|
||||||
int passCount = 0;
|
int passCount = 0;
|
||||||
|
|
||||||
if ((NULL == source_file) || (NULL == source_file->work_object.file_name))
|
if ((NULL == source_file) || (NULL == source_file->file_name))
|
||||||
{
|
{
|
||||||
g_warning("Attempt to parse NULL file");
|
g_warning("Attempt to parse NULL file");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_name = source_file->work_object.file_name;
|
file_name = source_file->file_name;
|
||||||
if (NULL == LanguageTable)
|
if (NULL == LanguageTable)
|
||||||
{
|
{
|
||||||
initializeParsing();
|
initializeParsing();
|
||||||
@ -135,8 +214,8 @@ gboolean tm_source_file_parse(TMSourceFile *source_file)
|
|||||||
|
|
||||||
while ((TRUE == status) && (passCount < 3))
|
while ((TRUE == status) && (passCount < 3))
|
||||||
{
|
{
|
||||||
if (source_file->work_object.tags_array)
|
if (source_file->tags_array)
|
||||||
tm_tags_array_free(source_file->work_object.tags_array, FALSE);
|
tm_tags_array_free(source_file->tags_array, FALSE);
|
||||||
if (fileOpen (file_name, source_file->lang))
|
if (fileOpen (file_name, source_file->lang))
|
||||||
{
|
{
|
||||||
if (LanguageTable [source_file->lang]->parser != NULL)
|
if (LanguageTable [source_file->lang]->parser != NULL)
|
||||||
@ -164,7 +243,7 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf
|
|||||||
const char *file_name;
|
const char *file_name;
|
||||||
gboolean status = TRUE;
|
gboolean status = TRUE;
|
||||||
|
|
||||||
if ((NULL == source_file) || (NULL == source_file->work_object.file_name))
|
if ((NULL == source_file) || (NULL == source_file->file_name))
|
||||||
{
|
{
|
||||||
g_warning("Attempt to parse NULL file");
|
g_warning("Attempt to parse NULL file");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -175,7 +254,7 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf
|
|||||||
g_warning("Attempt to parse a NULL text buffer");
|
g_warning("Attempt to parse a NULL text buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
file_name = source_file->work_object.file_name;
|
file_name = source_file->file_name;
|
||||||
if (NULL == LanguageTable)
|
if (NULL == LanguageTable)
|
||||||
{
|
{
|
||||||
initializeParsing();
|
initializeParsing();
|
||||||
@ -205,8 +284,8 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf
|
|||||||
int passCount = 0;
|
int passCount = 0;
|
||||||
while ((TRUE == status) && (passCount < 3))
|
while ((TRUE == status) && (passCount < 3))
|
||||||
{
|
{
|
||||||
if (source_file->work_object.tags_array)
|
if (source_file->tags_array)
|
||||||
tm_tags_array_free(source_file->work_object.tags_array, FALSE);
|
tm_tags_array_free(source_file->tags_array, FALSE);
|
||||||
if (bufferOpen (text_buf, buf_size, file_name, source_file->lang))
|
if (bufferOpen (text_buf, buf_size, file_name, source_file->lang))
|
||||||
{
|
{
|
||||||
if (LanguageTable [source_file->lang]->parser != NULL)
|
if (LanguageTable [source_file->lang]->parser != NULL)
|
||||||
@ -239,12 +318,12 @@ void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist)
|
|||||||
if (NULL == arglist ||
|
if (NULL == arglist ||
|
||||||
NULL == tag_name ||
|
NULL == tag_name ||
|
||||||
NULL == current_source_file ||
|
NULL == current_source_file ||
|
||||||
NULL == current_source_file->work_object.tags_array)
|
NULL == current_source_file->tags_array)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = tm_tags_find(current_source_file->work_object.tags_array, tag_name, FALSE, FALSE,
|
tags = tm_tags_find(current_source_file->tags_array, tag_name, FALSE, FALSE,
|
||||||
&count);
|
&count);
|
||||||
if (tags != NULL && count == 1)
|
if (tags != NULL && count == 1)
|
||||||
{
|
{
|
||||||
@ -258,71 +337,70 @@ int tm_source_file_tags(const tagEntryInfo *tag)
|
|||||||
{
|
{
|
||||||
if (NULL == current_source_file)
|
if (NULL == current_source_file)
|
||||||
return 0;
|
return 0;
|
||||||
if (NULL == current_source_file->work_object.tags_array)
|
if (NULL == current_source_file->tags_array)
|
||||||
current_source_file->work_object.tags_array = g_ptr_array_new();
|
current_source_file->tags_array = g_ptr_array_new();
|
||||||
g_ptr_array_add(current_source_file->work_object.tags_array,
|
g_ptr_array_add(current_source_file->tags_array,
|
||||||
tm_tag_new(current_source_file, tag));
|
tm_tag_new(current_source_file, tag));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean tm_source_file_update(TMWorkObject *source_file, gboolean force
|
void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace)
|
||||||
, gboolean UNUSED recurse, gboolean update_parent)
|
|
||||||
{
|
{
|
||||||
if (force)
|
#ifdef TM_DEBUG
|
||||||
{
|
g_message("Source file updating based on source file %s", source_file->file_name);
|
||||||
tm_source_file_parse(TM_SOURCE_FILE(source_file));
|
|
||||||
tm_tags_sort(source_file->tags_array, NULL, FALSE);
|
|
||||||
/* source_file->analyze_time = tm_get_file_timestamp(source_file->file_name); */
|
|
||||||
if ((source_file->parent) && update_parent)
|
|
||||||
{
|
|
||||||
tm_work_object_update(source_file->parent, TRUE, FALSE, TRUE);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#ifdef TM_DEBUG
|
|
||||||
g_message ("no parsing of %s has been done", source_file->file_name);
|
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
|
||||||
|
tm_source_file_parse(source_file);
|
||||||
|
tm_tags_sort(source_file->tags_array, NULL, FALSE);
|
||||||
|
if (update_workspace)
|
||||||
|
{
|
||||||
|
#ifdef TM_DEBUG
|
||||||
|
g_message("Updating workspace from source file");
|
||||||
|
#endif
|
||||||
|
tm_workspace_update();
|
||||||
}
|
}
|
||||||
|
#ifdef TM_DEBUG
|
||||||
|
else
|
||||||
|
g_message("Skipping workspace update because update_workspace is %s"
|
||||||
|
, update_workspace?"TRUE":"FALSE");
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean tm_source_file_buffer_update(TMWorkObject *source_file, guchar* text_buf,
|
void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
|
||||||
gint buf_size, gboolean update_parent)
|
gint buf_size, gboolean update_workspace)
|
||||||
{
|
{
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Buffer updating based on source file %s", source_file->file_name);
|
g_message("Buffer updating based on source file %s", source_file->file_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tm_source_file_buffer_parse (TM_SOURCE_FILE(source_file), text_buf, buf_size);
|
tm_source_file_buffer_parse (source_file, text_buf, buf_size);
|
||||||
tm_tags_sort(source_file->tags_array, NULL, FALSE);
|
tm_tags_sort(source_file->tags_array, NULL, FALSE);
|
||||||
/* source_file->analyze_time = time(NULL); */
|
if (update_workspace)
|
||||||
if ((source_file->parent) && update_parent)
|
|
||||||
{
|
{
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Updating parent from buffer..");
|
g_message("Updating workspace from buffer..");
|
||||||
#endif
|
#endif
|
||||||
tm_work_object_update(source_file->parent, TRUE, FALSE, TRUE);
|
tm_workspace_update();
|
||||||
}
|
}
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
else
|
else
|
||||||
g_message("Skipping parent update because parent is %s and update_parent is %s"
|
g_message("Skipping workspace update because update_workspace is %s"
|
||||||
, source_file->parent?"NOT NULL":"NULL", update_parent?"TRUE":"FALSE");
|
, update_workspace?"TRUE":"FALSE");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean tm_source_file_write(TMWorkObject *source_file, FILE *fp, guint attrs)
|
gboolean tm_source_file_write(TMSourceFile *source_file, FILE *fp, guint attrs)
|
||||||
{
|
{
|
||||||
TMTag *tag;
|
TMTag *tag;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (NULL != source_file)
|
if (NULL != source_file)
|
||||||
{
|
{
|
||||||
if (NULL != (tag = tm_tag_new(TM_SOURCE_FILE(source_file), NULL)))
|
if (NULL != (tag = tm_tag_new(source_file, NULL)))
|
||||||
{
|
{
|
||||||
tm_tag_write(tag, fp, tm_tag_attr_max_t);
|
tm_tag_write(tag, fp, tm_tag_attr_max_t);
|
||||||
tm_tag_unref(tag);
|
tm_tag_unref(tag);
|
||||||
@ -367,4 +445,3 @@ gint tm_source_file_get_named_lang(const gchar *name)
|
|||||||
}
|
}
|
||||||
return getNamedLanguage(name);
|
return getNamedLanguage(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
#ifndef TM_SOURCE_FILE_H
|
#ifndef TM_SOURCE_FILE_H
|
||||||
#define TM_SOURCE_FILE_H
|
#define TM_SOURCE_FILE_H
|
||||||
|
|
||||||
#include "tm_work_object.h"
|
#include <stdio.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#ifndef LIBCTAGS_DEFINED
|
#ifndef LIBCTAGS_DEFINED
|
||||||
typedef int langType;
|
typedef int langType;
|
||||||
@ -27,21 +27,22 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Casts a pointer to a pointer to a TMSourceFile structure */
|
/* Casts a pointer to a pointer to a TMSourceFile structure */
|
||||||
#define TM_SOURCE_FILE(work_object) ((TMSourceFile *) work_object)
|
#define TM_SOURCE_FILE(source_file) ((TMSourceFile *) source_file)
|
||||||
|
|
||||||
|
/* Evaluates to X is X is defined, else evaluates to Y */
|
||||||
|
#define FALLBACK(X,Y) (X)?(X):(Y)
|
||||||
|
|
||||||
/* Checks whether the object is a TMSourceFile */
|
|
||||||
#define IS_TM_SOURCE_FILE(source_file) (((TMWorkObject *) (source_file))->type \
|
|
||||||
== source_file_class_id)
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
The TMSourceFile structure is derived from TMWorkObject and contains all it's
|
The TMSourceFile structure represents the source file and its tags in the tag manager.
|
||||||
attributes, plus an integer representing the language of the file.
|
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
TMWorkObject work_object; /*!< The base work object */
|
|
||||||
langType lang; /*!< Programming language used */
|
langType lang; /*!< Programming language used */
|
||||||
gboolean inactive; /*!< Whether this file should be scanned for tags */
|
gboolean inactive; /*!< Whether this file should be scanned for tags */
|
||||||
|
char *file_name; /*!< Full file name (inc. path) */
|
||||||
|
char *short_name; /*!< Just the name of the file (without the path) */
|
||||||
|
GPtrArray *tags_array; /*!< Tags obtained by parsing the object */
|
||||||
} TMSourceFile;
|
} TMSourceFile;
|
||||||
|
|
||||||
/*! Initializes a TMSourceFile structure and returns a pointer to it.
|
/*! Initializes a TMSourceFile structure and returns a pointer to it.
|
||||||
@ -50,24 +51,29 @@ typedef struct
|
|||||||
* \param name Name of the used programming language, NULL for autodetection.
|
* \param name Name of the used programming language, NULL for autodetection.
|
||||||
* \return The created TMSourceFile object.
|
* \return The created TMSourceFile object.
|
||||||
* */
|
* */
|
||||||
TMWorkObject *tm_source_file_new(const char *file_name, gboolean update, const char *name);
|
TMSourceFile *tm_source_file_new(const char *file_name, gboolean update, const char *name);
|
||||||
|
|
||||||
/*! Updates the source file by reparsing if the modification time is greater
|
/*! Updates the source file by reparsing. The tags array and
|
||||||
than the timestamp in the structure, or if force is TRUE. The tags array and
|
|
||||||
the tags themselves are destroyed and re-created, hence any other tag arrays
|
the tags themselves are destroyed and re-created, hence any other tag arrays
|
||||||
pointing to these tags should be rebuilt as well. All sorting information is
|
pointing to these tags should be rebuilt as well. All sorting information is
|
||||||
also lost. The language parameter is automatically set the first time the file
|
also lost. The language parameter is automatically set the first time the file
|
||||||
is parsed.
|
is parsed.
|
||||||
\param source_file The source file to update.
|
\param source_file The source file to update.
|
||||||
\param force Ignored. The source file is always updated.
|
\param update_workspace If set to TRUE, sends an update signal to the workspace if required. You should
|
||||||
\param recurse This parameter is ignored for source files and is only there for consistency.
|
|
||||||
\param update_parent If set to TRUE, sends an update signal to parent if required. You should
|
|
||||||
always set this to TRUE if you are calling this function directly.
|
always set this to TRUE if you are calling this function directly.
|
||||||
\return TRUE if the file was parsed, FALSE otherwise.
|
|
||||||
\sa tm_work_object_update(), tm_workspace_update()
|
|
||||||
*/
|
*/
|
||||||
gboolean tm_source_file_update(TMWorkObject *source_file, gboolean force
|
void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace);
|
||||||
, gboolean recurse, gboolean update_parent);
|
|
||||||
|
/*! Frees a TMSourceFile structure, including all contents */
|
||||||
|
void tm_source_file_free(TMSourceFile *source_file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Given a file name, returns a newly allocated string containing the realpath()
|
||||||
|
of the file.
|
||||||
|
\param file_name The original file_name
|
||||||
|
\return A newly allocated string containing the real path to the file. NULL if none is available.
|
||||||
|
*/
|
||||||
|
gchar *tm_get_real_path(const gchar *file_name);
|
||||||
|
|
||||||
|
|
||||||
#ifdef GEANY_PRIVATE
|
#ifdef GEANY_PRIVATE
|
||||||
@ -82,9 +88,6 @@ gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name,
|
|||||||
*/
|
*/
|
||||||
void tm_source_file_destroy(TMSourceFile *source_file);
|
void tm_source_file_destroy(TMSourceFile *source_file);
|
||||||
|
|
||||||
/* Frees a TMSourceFile structure, including all contents */
|
|
||||||
void tm_source_file_free(gpointer source_file);
|
|
||||||
|
|
||||||
/* Updates the source file by reparsing the text-buffer passed as parameter.
|
/* Updates the source file by reparsing the text-buffer passed as parameter.
|
||||||
Ctags will use a parsing based on buffer instead of on files.
|
Ctags will use a parsing based on buffer instead of on files.
|
||||||
You should call this function when you don't want a previous saving of the file
|
You should call this function when you don't want a previous saving of the file
|
||||||
@ -97,13 +100,12 @@ void tm_source_file_free(gpointer source_file);
|
|||||||
\param text_buf A text buffer. The user should take care of allocate and free it after
|
\param text_buf A text buffer. The user should take care of allocate and free it after
|
||||||
the use here.
|
the use here.
|
||||||
\param buf_size The size of text_buf.
|
\param buf_size The size of text_buf.
|
||||||
\param update_parent If set to TRUE, sends an update signal to parent if required. You should
|
\param update_workspace If set to TRUE, sends an update signal to the workspace if required. You should
|
||||||
always set this to TRUE if you are calling this function directly.
|
always set this to TRUE if you are calling this function directly.
|
||||||
\return TRUE if the file was parsed, FALSE otherwise.
|
\return TRUE if the file was parsed, FALSE otherwise.
|
||||||
\sa tm_work_object_update(), tm_workspace_update()
|
|
||||||
*/
|
*/
|
||||||
gboolean tm_source_file_buffer_update(TMWorkObject *source_file, guchar* text_buf,
|
void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
|
||||||
gint buf_size, gboolean update_parent);
|
gint buf_size, gboolean update_workspace);
|
||||||
|
|
||||||
/* Parses the source file and regenarates the tags.
|
/* Parses the source file and regenarates the tags.
|
||||||
\param source_file The source file to parse
|
\param source_file The source file to parse
|
||||||
@ -137,13 +139,8 @@ int tm_source_file_tags(const tagEntryInfo *tag);
|
|||||||
\param attrs The attributes to write.
|
\param attrs The attributes to write.
|
||||||
\return TRUE on success, FALSE on failure.
|
\return TRUE on success, FALSE on failure.
|
||||||
*/
|
*/
|
||||||
gboolean tm_source_file_write(TMWorkObject *source_file, FILE *fp, guint attrs);
|
gboolean tm_source_file_write(TMSourceFile *source_file, FILE *fp, guint attrs);
|
||||||
|
|
||||||
/* Contains the id obtained by registering the TMSourceFile class as a child of
|
|
||||||
TMWorkObject.
|
|
||||||
\sa tm_work_object_register()
|
|
||||||
*/
|
|
||||||
extern guint source_file_class_id;
|
|
||||||
|
|
||||||
/* Gets the name associated with the language index.
|
/* Gets the name associated with the language index.
|
||||||
\param lang The language index.
|
\param lang The language index.
|
||||||
|
@ -218,9 +218,8 @@ gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_ent
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tag->name = g_strdup(file->work_object.file_name);
|
tag->name = g_strdup(file->file_name);
|
||||||
tag->type = tm_tag_file_t;
|
tag->type = tm_tag_file_t;
|
||||||
/* tag->atts.file.timestamp = file->work_object.analyze_time; */
|
|
||||||
tag->atts.file.lang = file->lang;
|
tag->atts.file.lang = file->lang;
|
||||||
tag->atts.file.inactive = FALSE;
|
tag->atts.file.inactive = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1053,7 +1052,7 @@ void tm_tag_print(TMTag *tag, FILE *fp)
|
|||||||
if (tag->atts.entry.inheritance)
|
if (tag->atts.entry.inheritance)
|
||||||
fprintf(fp, " : from %s", tag->atts.entry.inheritance);
|
fprintf(fp, " : from %s", tag->atts.entry.inheritance);
|
||||||
if ((tag->atts.entry.file) && (tag->atts.entry.line > 0))
|
if ((tag->atts.entry.file) && (tag->atts.entry.line > 0))
|
||||||
fprintf(fp, "[%s:%ld]", tag->atts.entry.file->work_object.file_name
|
fprintf(fp, "[%s:%ld]", tag->atts.entry.file->file_name
|
||||||
, tag->atts.entry.line);
|
, tag->atts.entry.line);
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "tm_tag.h"
|
#include "tm_tag.h"
|
||||||
#include "tm_workspace.h"
|
#include "tm_workspace.h"
|
||||||
#include "tm_work_object.h"
|
|
||||||
#include "tm_source_file.h"
|
#include "tm_source_file.h"
|
||||||
#ifdef GEANY_PRIVATE
|
#ifdef GEANY_PRIVATE
|
||||||
#include "tm_file_entry.h"
|
#include "tm_file_entry.h"
|
||||||
|
@ -1,298 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 2001-2002, Biswapesh Chattopadhyay
|
|
||||||
*
|
|
||||||
* This source code is released for free distribution under the terms of the
|
|
||||||
* GNU General Public License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file tm_work_object.h
|
|
||||||
* A TMWorkObject structure is the base class for TMSourceFile.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "general.h" /* must always come first */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <glib/gstdio.h>
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
# define VC_EXTRALEAN
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# include <windows.h> /* for GetFullPathName */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "tm_tag.h"
|
|
||||||
#include "tm_work_object.h"
|
|
||||||
|
|
||||||
static GPtrArray *s_work_object_subclasses = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
static int get_path_max(const char *path)
|
|
||||||
{
|
|
||||||
#ifdef PATH_MAX
|
|
||||||
return PATH_MAX;
|
|
||||||
#else
|
|
||||||
int path_max = pathconf(path, _PC_PATH_MAX);
|
|
||||||
if (path_max <= 0)
|
|
||||||
path_max = 4096;
|
|
||||||
return path_max;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
/* realpath implementation for Windows found at http://bugzilla.gnome.org/show_bug.cgi?id=342926
|
|
||||||
* this one is better than e.g. liberty's lrealpath because this one uses Win32 API and works
|
|
||||||
* with special chars within the filename */
|
|
||||||
static char *realpath (const char *pathname, char *resolved_path)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
|
|
||||||
if (resolved_path != NULL)
|
|
||||||
{
|
|
||||||
int path_max = get_path_max(pathname);
|
|
||||||
size = GetFullPathNameA (pathname, path_max, resolved_path, NULL);
|
|
||||||
if (size > path_max)
|
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
return resolved_path;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size = GetFullPathNameA (pathname, 0, NULL, NULL);
|
|
||||||
resolved_path = g_new0 (char, size);
|
|
||||||
GetFullPathNameA (pathname, size, resolved_path, NULL);
|
|
||||||
return resolved_path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gchar *tm_get_real_path(const gchar *file_name)
|
|
||||||
{
|
|
||||||
if (file_name)
|
|
||||||
{
|
|
||||||
gsize len = get_path_max(file_name) + 1;
|
|
||||||
gchar *path = g_malloc0(len);
|
|
||||||
|
|
||||||
if (realpath(file_name, path))
|
|
||||||
return path;
|
|
||||||
else
|
|
||||||
g_free(path);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
guint tm_work_object_register(GFreeFunc free_func, TMUpdateFunc update_func, TMFindFunc find_func)
|
|
||||||
{
|
|
||||||
TMWorkObjectClass *object_class;
|
|
||||||
if (NULL == s_work_object_subclasses)
|
|
||||||
{
|
|
||||||
s_work_object_subclasses = g_ptr_array_new();
|
|
||||||
object_class = g_new(TMWorkObjectClass, 1);
|
|
||||||
object_class->free_func = tm_work_object_free;
|
|
||||||
object_class->update_func = NULL;
|
|
||||||
object_class->find_func = NULL;
|
|
||||||
g_ptr_array_add(s_work_object_subclasses, object_class);
|
|
||||||
}
|
|
||||||
object_class = g_new(TMWorkObjectClass, 1);
|
|
||||||
object_class->free_func = free_func;
|
|
||||||
object_class->update_func = update_func;
|
|
||||||
object_class->find_func = find_func;
|
|
||||||
g_ptr_array_add(s_work_object_subclasses, object_class);
|
|
||||||
return (s_work_object_subclasses->len - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean tm_work_object_init(TMWorkObject *work_object, guint type, const char *file_name
|
|
||||||
, gboolean create)
|
|
||||||
{
|
|
||||||
struct stat s;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
if (file_name != NULL)
|
|
||||||
{
|
|
||||||
if (0 != (status = g_stat(file_name, &s)))
|
|
||||||
{
|
|
||||||
if (create)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
if (NULL == (f = g_fopen(file_name, "a+")))
|
|
||||||
{
|
|
||||||
g_warning("Unable to create file %s", file_name);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
status = g_stat(file_name, &s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (0 != status)
|
|
||||||
{
|
|
||||||
/* g_warning("Unable to stat %s", file_name);*/
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (!S_ISREG(s.st_mode))
|
|
||||||
{
|
|
||||||
g_warning("%s: Not a regular file", file_name);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
work_object->file_name = tm_get_real_path(file_name);
|
|
||||||
work_object->short_name = strrchr(work_object->file_name, '/');
|
|
||||||
if (work_object->short_name)
|
|
||||||
++ work_object->short_name;
|
|
||||||
else
|
|
||||||
work_object->short_name = work_object->file_name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
work_object->file_name = NULL;
|
|
||||||
work_object->short_name = NULL;
|
|
||||||
}
|
|
||||||
work_object->type = type;
|
|
||||||
work_object->parent = NULL;
|
|
||||||
work_object->analyze_time = 0;
|
|
||||||
work_object->tags_array = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
time_t tm_get_file_timestamp(const char *file_name)
|
|
||||||
{
|
|
||||||
struct stat s;
|
|
||||||
|
|
||||||
g_return_val_if_fail(file_name, 0);
|
|
||||||
|
|
||||||
if (0 != g_stat(file_name, &s))
|
|
||||||
{
|
|
||||||
return (time_t) 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return s.st_mtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean tm_work_object_is_changed(TMWorkObject *work_object)
|
|
||||||
{
|
|
||||||
return (gboolean) (work_object->analyze_time < tm_get_file_timestamp(work_object->file_name));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
TMWorkObject *tm_work_object_new(guint type, const char *file_name, gboolean create)
|
|
||||||
{
|
|
||||||
TMWorkObject *work_object = g_new(TMWorkObject, 1);
|
|
||||||
if (!tm_work_object_init(work_object, type, file_name, create))
|
|
||||||
{
|
|
||||||
g_free(work_object);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return work_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tm_work_object_destroy(TMWorkObject *work_object)
|
|
||||||
{
|
|
||||||
if (work_object)
|
|
||||||
{
|
|
||||||
g_free(work_object->file_name);
|
|
||||||
if (work_object->tags_array)
|
|
||||||
g_ptr_array_free(work_object->tags_array, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tm_work_object_free(gpointer work_object)
|
|
||||||
{
|
|
||||||
if (NULL != work_object)
|
|
||||||
{
|
|
||||||
TMWorkObject *w = (TMWorkObject *) work_object;
|
|
||||||
if ((w->type > 0) && (w->type < s_work_object_subclasses->len) &&
|
|
||||||
(s_work_object_subclasses->pdata[w->type] != NULL))
|
|
||||||
{
|
|
||||||
GFreeFunc free_func =
|
|
||||||
((TMWorkObjectClass *)s_work_object_subclasses->pdata[w->type])->free_func;
|
|
||||||
if (NULL != free_func)
|
|
||||||
free_func(work_object);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tm_work_object_destroy(w);
|
|
||||||
g_free(work_object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tm_work_object_write_tags(TMWorkObject *work_object, FILE *file, guint attrs)
|
|
||||||
{
|
|
||||||
if (NULL != work_object->tags_array)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
for (i=0; i < work_object->tags_array->len; ++i)
|
|
||||||
tm_tag_write((TMTag *) g_ptr_array_index(work_object->tags_array, i)
|
|
||||||
, file, (TMTagAttrType) attrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean tm_work_object_update(TMWorkObject *work_object, gboolean force
|
|
||||||
, gboolean recurse, gboolean update_parent)
|
|
||||||
{
|
|
||||||
if ((NULL != work_object) && (work_object->type > 0) &&
|
|
||||||
(work_object->type < s_work_object_subclasses->len) &&
|
|
||||||
(s_work_object_subclasses->pdata[work_object->type] != NULL))
|
|
||||||
{
|
|
||||||
TMUpdateFunc update_func =
|
|
||||||
((TMWorkObjectClass *)s_work_object_subclasses->pdata[work_object->type])->update_func;
|
|
||||||
if (NULL != update_func)
|
|
||||||
return update_func(work_object, force, recurse, update_parent);
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
TMWorkObject *tm_work_object_find(TMWorkObject *work_object, const char *file_name
|
|
||||||
, gboolean name_only)
|
|
||||||
{
|
|
||||||
if ((NULL != work_object) && (work_object->type > 0) &&
|
|
||||||
(work_object->type < s_work_object_subclasses->len) &&
|
|
||||||
(s_work_object_subclasses->pdata[work_object->type] != NULL))
|
|
||||||
{
|
|
||||||
TMFindFunc find_func =
|
|
||||||
((TMWorkObjectClass *)s_work_object_subclasses->pdata[work_object->type])->find_func;
|
|
||||||
if (NULL == find_func)
|
|
||||||
{
|
|
||||||
if (name_only)
|
|
||||||
{
|
|
||||||
const char *short_name = strrchr(file_name, '/');
|
|
||||||
if (short_name)
|
|
||||||
++ short_name;
|
|
||||||
else
|
|
||||||
short_name = file_name;
|
|
||||||
if (0 == strcmp(work_object->short_name, short_name))
|
|
||||||
return work_object;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *path = tm_get_real_path(file_name);
|
|
||||||
int cmp = strcmp(work_object->file_name, file_name);
|
|
||||||
g_free(path);
|
|
||||||
if (0 == cmp)
|
|
||||||
return work_object;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return find_func(work_object, file_name, name_only);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tm_work_object_dump(const TMWorkObject *w)
|
|
||||||
{
|
|
||||||
if (w)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s", w->file_name);
|
|
||||||
if (w->parent)
|
|
||||||
fprintf(stderr, " <- %s\n", w->parent->file_name);
|
|
||||||
else
|
|
||||||
fprintf(stderr, " <- NULL\n");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 2001-2002, Biswapesh Chattopadhyay
|
|
||||||
*
|
|
||||||
* This source code is released for free distribution under the terms of the
|
|
||||||
* GNU General Public License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TM_WORK_OBJECT_H
|
|
||||||
#define TM_WORK_OBJECT_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Macro to cast a pointer to (TMWorkObject *) */
|
|
||||||
#define TM_WORK_OBJECT(work_object) ((TMWorkObject *) work_object)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
A TMWorkObject structure is the base class for TMSourceFile.
|
|
||||||
This struct contains data common to all work objects, namely, a file name,
|
|
||||||
time when the file was analyzed (for caching) and an array of tags which
|
|
||||||
should be populated when the object is analyzed.
|
|
||||||
*/
|
|
||||||
typedef struct TMWorkObject
|
|
||||||
{
|
|
||||||
guint type; /*!< The type of object. Can be a source file or a project */
|
|
||||||
char *file_name; /*!< Full file name (inc. path) of the work object */
|
|
||||||
char *short_name; /*!< Just the name of the file (without the path) */
|
|
||||||
struct TMWorkObject *parent;
|
|
||||||
time_t analyze_time; /*!< UNUSED Time when the object was last analyzed */
|
|
||||||
GPtrArray *tags_array; /*!< Tags obtained by parsing the object */
|
|
||||||
} TMWorkObject;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Given a file name, returns a newly allocated string containing the realpath()
|
|
||||||
of the file.
|
|
||||||
\param file_name The original file_name
|
|
||||||
\return A newly allocated string containing the real path to the file. NULL if none is available.
|
|
||||||
*/
|
|
||||||
gchar *tm_get_real_path(const gchar *file_name);
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Deallocates a work object and it's component structures. The user can call this
|
|
||||||
function directly since it will automatically call the correct deallocator function
|
|
||||||
of the derived class if required.
|
|
||||||
\param work_object Pointer to a work object or an object derived from it.
|
|
||||||
*/
|
|
||||||
void tm_work_object_free(gpointer work_object);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GEANY_PRIVATE
|
|
||||||
|
|
||||||
/* Evaluates to X is X is defined, else evaluates to Y */
|
|
||||||
#define FALLBACK(X,Y) (X)?(X):(Y)
|
|
||||||
|
|
||||||
#define TM_OBJECT_TYPE(work_object) ((TMWorkObject *) work_object)->type /*< Type of the work object */
|
|
||||||
#define TM_OBJECT_FILE(work_object) ((TMWorkObject *) work_object)->file_name /*< File name of the work object */
|
|
||||||
#define TM_OBJECT_TAGS(work_object) ((TMWorkObject *) work_object)->tags_array /*< Tag array of the work object */
|
|
||||||
|
|
||||||
/* Prototype of the update function required to be written by all classes
|
|
||||||
derived from TMWorkObject. The function should take a pointer to the
|
|
||||||
object and a flag indicating whether the cache should be ignored, and
|
|
||||||
update the object's tag array accordingly.
|
|
||||||
\sa tm_work_object_update(), tm_workspace_update(),
|
|
||||||
tm_source_file_update().
|
|
||||||
*/
|
|
||||||
typedef gboolean (*TMUpdateFunc) (TMWorkObject *work_object, gboolean force
|
|
||||||
, gboolean recurse, gboolean update_parent);
|
|
||||||
|
|
||||||
/* Prototype of the find function required to be written by all classed
|
|
||||||
derived from TMWorkObject. The function should take a pointer to the work
|
|
||||||
object and a file name and return a pointer to the work object corresponding
|
|
||||||
to the file name if the file is part of the object, and NULL otherwise.
|
|
||||||
\sa tm_work_object_find()
|
|
||||||
*/
|
|
||||||
typedef TMWorkObject *(*TMFindFunc) (TMWorkObject *work_object, const char *file_name
|
|
||||||
, gboolean name_only);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Contains pointers to functions necessary to handle virtual function calls
|
|
||||||
correctly. To create a new object derived from TMWorkObject, you
|
|
||||||
need to write the three functions specified as the members of this class and
|
|
||||||
register your class before first use using tm_work_object_register()
|
|
||||||
*/
|
|
||||||
typedef struct _TMWorkObjectClass
|
|
||||||
{
|
|
||||||
GFreeFunc free_func; /* Function to free the derived object */
|
|
||||||
TMUpdateFunc update_func; /* Function to update the derived object */
|
|
||||||
TMFindFunc find_func; /* Function to locate contained work objects */
|
|
||||||
} TMWorkObjectClass;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Initializes the work object structure. This function should be called by the
|
|
||||||
initialization routine of the derived classes to ensure that the base members
|
|
||||||
are initialized properly. The library user should not have to call this under
|
|
||||||
any circumstance.
|
|
||||||
\param work_object The work object to be initialized.
|
|
||||||
\param type The type of the work object obtained by registering the derived class.
|
|
||||||
\param file_name The name of the file corresponding to the work object.
|
|
||||||
\param create Whether to create the file if it doesn't exist.
|
|
||||||
\return TRUE on success, FALSE on failure.
|
|
||||||
\sa tm_work_object_register()
|
|
||||||
*/
|
|
||||||
gboolean tm_work_object_init(TMWorkObject *work_object, guint type, const char *file_name
|
|
||||||
, gboolean create);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Initializes a new TMWorkObject structure and returns a pointer to it. You shouldn't
|
|
||||||
have to call this function.
|
|
||||||
\return NULL on failure
|
|
||||||
\sa tm_source_file_new()
|
|
||||||
*/
|
|
||||||
TMWorkObject *tm_work_object_new(guint type, const char *file_name, gboolean create);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Utility function - Given a file name, returns the timestamp of modification.
|
|
||||||
\param file_name Full path to the file.
|
|
||||||
\return Timestamp of the file's modification time. 0 on failure.
|
|
||||||
*/
|
|
||||||
time_t tm_get_file_timestamp(const char *file_name);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Destroys a work object's data without freeing the structure itself. It should
|
|
||||||
be called by the deallocator function of classes derived from TMWorkObject. The
|
|
||||||
user shouldn't have to call this function.
|
|
||||||
*/
|
|
||||||
void tm_work_object_destroy(TMWorkObject *work_object);
|
|
||||||
|
|
||||||
/*
|
|
||||||
This function should be called exactly once by all classes derived from TMWorkObject,
|
|
||||||
since it supplies a unique ID on each call and stores the functions to call for
|
|
||||||
updation and deallocation of objects of the type allocated. The user should not
|
|
||||||
have to use this function unless he/she wants to create a new class derived from
|
|
||||||
TMWorkObject.
|
|
||||||
\param free_func The function to call to free the derived object.
|
|
||||||
\param update_func The function to call to update the derived object.
|
|
||||||
\return A unique ID for the derived class.
|
|
||||||
\sa TMSourceFile
|
|
||||||
*/
|
|
||||||
guint tm_work_object_register(GFreeFunc free_func, TMUpdateFunc update_func, TMFindFunc find_func);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Writes the tags for the work object to the file specified.
|
|
||||||
\param work_object The work object whose tags need to be written.
|
|
||||||
\param file The file to which the tags are to be written.
|
|
||||||
\param attrs The attributes to write (Can be a bitmask).
|
|
||||||
*/
|
|
||||||
void tm_work_object_write_tags(TMWorkObject *work_object, FILE *file, guint attrs);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Updates the tags array if necessary. Automatically calls the update function
|
|
||||||
of the type to which the object belongs.
|
|
||||||
\param work_object Pointer to a work object or an object derived from it.
|
|
||||||
\param force Whether the cache is to be ignored.
|
|
||||||
\param recurse Whether to recurse into child work objects (for workspace).
|
|
||||||
\param update_parent If set to TRUE, calls the update function of the parent if required.
|
|
||||||
If you are calling this function, you should set this to TRUE.
|
|
||||||
\return TRUE on success, FALSE on failure.
|
|
||||||
\sa tm_source_file_update()
|
|
||||||
*/
|
|
||||||
gboolean tm_work_object_update(TMWorkObject *work_object, gboolean force
|
|
||||||
, gboolean recurse, gboolean update_parent);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Finds the work object corresponding to the file name passed and returns a pointer
|
|
||||||
to it. If not found, returns NULL. This is a virtual function which automatically
|
|
||||||
calls the registered find function of teh derived object.
|
|
||||||
\sa TMFindFunc
|
|
||||||
*/
|
|
||||||
TMWorkObject *tm_work_object_find(TMWorkObject *work_object, const char *file_name
|
|
||||||
, gboolean name_only);
|
|
||||||
|
|
||||||
/* Dumps the contents of a work object - useful for debugging */
|
|
||||||
void tm_work_object_dump(const TMWorkObject *w);
|
|
||||||
|
|
||||||
#endif /* GEANY_PRIVATE */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* TM_WORK_OBJECT_H */
|
|
@ -13,10 +13,9 @@
|
|||||||
wide tag information.
|
wide tag information.
|
||||||
|
|
||||||
The workspace is intended to contain a list of global tags
|
The workspace is intended to contain a list of global tags
|
||||||
and a set of work objects (individual files). You need not use the
|
and a set of individual source files. You need not use the
|
||||||
workspace, though, to use tag manager, unless you need things like global tags
|
workspace, though, to use tag manager, unless you need things like global tags
|
||||||
and a place to store all current open files. TMWorkspace
|
and a place to store all current open files.
|
||||||
is derived from TMWorkObject.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
@ -33,50 +32,36 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "tm_tag.h"
|
|
||||||
#include "tm_workspace.h"
|
#include "tm_workspace.h"
|
||||||
|
|
||||||
|
|
||||||
static TMWorkspace *theWorkspace = NULL;
|
static TMWorkspace *theWorkspace = NULL;
|
||||||
guint workspace_class_id = 0;
|
|
||||||
|
|
||||||
static gboolean tm_create_workspace(void)
|
static gboolean tm_create_workspace(void)
|
||||||
{
|
{
|
||||||
workspace_class_id = tm_work_object_register(tm_workspace_free, tm_workspace_update
|
|
||||||
, tm_workspace_find_object);
|
|
||||||
theWorkspace = g_new(TMWorkspace, 1);
|
theWorkspace = g_new(TMWorkspace, 1);
|
||||||
if (FALSE == tm_work_object_init(TM_WORK_OBJECT(theWorkspace),
|
theWorkspace->tags_array = NULL;
|
||||||
workspace_class_id, NULL, TRUE))
|
|
||||||
{
|
|
||||||
g_free(theWorkspace);
|
|
||||||
theWorkspace = NULL;
|
|
||||||
g_warning("Failed to initialize workspace");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
theWorkspace->global_tags = NULL;
|
theWorkspace->global_tags = NULL;
|
||||||
theWorkspace->work_objects = NULL;
|
theWorkspace->source_files = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tm_workspace_free(gpointer workspace)
|
void tm_workspace_free(void)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (workspace != theWorkspace)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Workspace destroyed");
|
g_message("Workspace destroyed");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (theWorkspace)
|
if (theWorkspace)
|
||||||
{
|
{
|
||||||
if (theWorkspace->work_objects)
|
if (theWorkspace->source_files)
|
||||||
{
|
{
|
||||||
for (i=0; i < theWorkspace->work_objects->len; ++i)
|
for (i=0; i < theWorkspace->source_files->len; ++i)
|
||||||
tm_work_object_free(theWorkspace->work_objects->pdata[i]);
|
tm_source_file_free(theWorkspace->source_files->pdata[i]);
|
||||||
g_ptr_array_free(theWorkspace->work_objects, TRUE);
|
g_ptr_array_free(theWorkspace->source_files, TRUE);
|
||||||
}
|
}
|
||||||
if (theWorkspace->global_tags)
|
if (theWorkspace->global_tags)
|
||||||
{
|
{
|
||||||
@ -84,7 +69,8 @@ void tm_workspace_free(gpointer workspace)
|
|||||||
tm_tag_unref(theWorkspace->global_tags->pdata[i]);
|
tm_tag_unref(theWorkspace->global_tags->pdata[i]);
|
||||||
g_ptr_array_free(theWorkspace->global_tags, TRUE);
|
g_ptr_array_free(theWorkspace->global_tags, TRUE);
|
||||||
}
|
}
|
||||||
tm_work_object_destroy(TM_WORK_OBJECT(theWorkspace));
|
if (NULL != theWorkspace->tags_array)
|
||||||
|
g_ptr_array_free(theWorkspace->tags_array, TRUE);
|
||||||
g_free(theWorkspace);
|
g_free(theWorkspace);
|
||||||
theWorkspace = NULL;
|
theWorkspace = NULL;
|
||||||
}
|
}
|
||||||
@ -97,35 +83,34 @@ const TMWorkspace *tm_get_workspace(void)
|
|||||||
return theWorkspace;
|
return theWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean tm_workspace_add_object(TMWorkObject *work_object)
|
gboolean tm_workspace_add_source_file(TMSourceFile *source_file)
|
||||||
{
|
{
|
||||||
/* theWorkspace should already have been created otherwise something went wrong */
|
/* theWorkspace should already have been created otherwise something went wrong */
|
||||||
if (NULL == theWorkspace)
|
if (NULL == theWorkspace)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (NULL == theWorkspace->work_objects)
|
if (NULL == theWorkspace->source_files)
|
||||||
theWorkspace->work_objects = g_ptr_array_new();
|
theWorkspace->source_files = g_ptr_array_new();
|
||||||
g_ptr_array_add(theWorkspace->work_objects, work_object);
|
g_ptr_array_add(theWorkspace->source_files, source_file);
|
||||||
work_object->parent = TM_WORK_OBJECT(theWorkspace);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean tm_workspace_remove_object(TMWorkObject *w, gboolean do_free, gboolean update)
|
gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
if ((NULL == theWorkspace) || (NULL == theWorkspace->work_objects)
|
if ((NULL == theWorkspace) || (NULL == theWorkspace->source_files)
|
||||||
|| (NULL == w))
|
|| (NULL == source_file))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
||||||
for (i=0; i < theWorkspace->work_objects->len; ++i)
|
for (i=0; i < theWorkspace->source_files->len; ++i)
|
||||||
{
|
{
|
||||||
if (theWorkspace->work_objects->pdata[i] == w)
|
if (theWorkspace->source_files->pdata[i] == source_file)
|
||||||
{
|
{
|
||||||
if (do_free)
|
if (do_free)
|
||||||
tm_work_object_free(w);
|
tm_source_file_free(source_file);
|
||||||
g_ptr_array_remove_index_fast(theWorkspace->work_objects, i);
|
g_ptr_array_remove_index_fast(theWorkspace->source_files, i);
|
||||||
if (update)
|
if (update)
|
||||||
tm_workspace_update(TM_WORK_OBJECT(theWorkspace), TRUE, FALSE, FALSE);
|
tm_workspace_update();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +276,7 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
|
|||||||
char *command;
|
char *command;
|
||||||
guint i;
|
guint i;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
TMWorkObject *source_file;
|
TMSourceFile *source_file;
|
||||||
GPtrArray *tags_array;
|
GPtrArray *tags_array;
|
||||||
GHashTable *includes_files_hash;
|
GHashTable *includes_files_hash;
|
||||||
GList *includes_files = NULL;
|
GList *includes_files = NULL;
|
||||||
@ -462,30 +447,10 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TMWorkObject *tm_workspace_find_object(TMWorkObject *work_object, const char *file_name
|
|
||||||
, gboolean name_only)
|
|
||||||
{
|
|
||||||
TMWorkObject *w = NULL;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (work_object != TM_WORK_OBJECT(theWorkspace))
|
|
||||||
return NULL;
|
|
||||||
if ((NULL == theWorkspace) || (NULL == theWorkspace->work_objects)
|
|
||||||
|| (0 == theWorkspace->work_objects->len))
|
|
||||||
return NULL;
|
|
||||||
for (i = 0; i < theWorkspace->work_objects->len; ++i)
|
|
||||||
{
|
|
||||||
if (NULL != (w = tm_work_object_find(TM_WORK_OBJECT(theWorkspace->work_objects->pdata[i])
|
|
||||||
, file_name, name_only)))
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tm_workspace_recreate_tags_array(void)
|
void tm_workspace_recreate_tags_array(void)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
TMWorkObject *w;
|
TMSourceFile *w;
|
||||||
TMTagAttrType sort_attrs[] = { tm_tag_attr_name_t, tm_tag_attr_file_t
|
TMTagAttrType sort_attrs[] = { tm_tag_attr_name_t, tm_tag_attr_file_t
|
||||||
, tm_tag_attr_scope_t, tm_tag_attr_type_t, tm_tag_attr_arglist_t, 0};
|
, tm_tag_attr_scope_t, tm_tag_attr_type_t, tm_tag_attr_arglist_t, 0};
|
||||||
|
|
||||||
@ -493,19 +458,19 @@ void tm_workspace_recreate_tags_array(void)
|
|||||||
g_message("Recreating workspace tags array");
|
g_message("Recreating workspace tags array");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((NULL == theWorkspace) || (NULL == theWorkspace->work_objects))
|
if ((NULL == theWorkspace) || (NULL == theWorkspace->source_files))
|
||||||
return;
|
return;
|
||||||
if (NULL != theWorkspace->work_object.tags_array)
|
if (NULL != theWorkspace->tags_array)
|
||||||
g_ptr_array_set_size(theWorkspace->work_object.tags_array, 0);
|
g_ptr_array_set_size(theWorkspace->tags_array, 0);
|
||||||
else
|
else
|
||||||
theWorkspace->work_object.tags_array = g_ptr_array_new();
|
theWorkspace->tags_array = g_ptr_array_new();
|
||||||
|
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Total %d objects", theWorkspace->work_objects->len);
|
g_message("Total %d objects", theWorkspace->source_files->len);
|
||||||
#endif
|
#endif
|
||||||
for (i=0; i < theWorkspace->work_objects->len; ++i)
|
for (i=0; i < theWorkspace->source_files->len; ++i)
|
||||||
{
|
{
|
||||||
w = TM_WORK_OBJECT(theWorkspace->work_objects->pdata[i]);
|
w = theWorkspace->source_files->pdata[i];
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Adding tags of %s", w->file_name);
|
g_message("Adding tags of %s", w->file_name);
|
||||||
#endif
|
#endif
|
||||||
@ -513,44 +478,26 @@ void tm_workspace_recreate_tags_array(void)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < w->tags_array->len; ++j)
|
for (j = 0; j < w->tags_array->len; ++j)
|
||||||
{
|
{
|
||||||
g_ptr_array_add(theWorkspace->work_object.tags_array,
|
g_ptr_array_add(theWorkspace->tags_array,
|
||||||
w->tags_array->pdata[j]);
|
w->tags_array->pdata[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Total: %d tags", theWorkspace->work_object.tags_array->len);
|
g_message("Total: %d tags", theWorkspace->tags_array->len);
|
||||||
#endif
|
#endif
|
||||||
tm_tags_sort(theWorkspace->work_object.tags_array, sort_attrs, TRUE);
|
tm_tags_sort(theWorkspace->tags_array, sort_attrs, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean tm_workspace_update(TMWorkObject *workspace, gboolean force
|
void tm_workspace_update(void)
|
||||||
, gboolean recurse, gboolean UNUSED update_parent)
|
|
||||||
{
|
{
|
||||||
guint i;
|
|
||||||
gboolean update_tags = force;
|
|
||||||
|
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Updating workspace");
|
g_message("Updating workspace");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (workspace != TM_WORK_OBJECT(theWorkspace))
|
|
||||||
return FALSE;
|
|
||||||
if (NULL == theWorkspace)
|
if (NULL == theWorkspace)
|
||||||
return TRUE;
|
return;
|
||||||
if ((recurse) && (theWorkspace->work_objects))
|
tm_workspace_recreate_tags_array();
|
||||||
{
|
|
||||||
for (i=0; i < theWorkspace->work_objects->len; ++i)
|
|
||||||
{
|
|
||||||
if (TRUE == tm_work_object_update(TM_WORK_OBJECT(
|
|
||||||
theWorkspace->work_objects->pdata[i]), FALSE, TRUE, FALSE))
|
|
||||||
update_tags = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (update_tags)
|
|
||||||
tm_workspace_recreate_tags_array();
|
|
||||||
/* workspace->analyze_time = time(NULL); */
|
|
||||||
return update_tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tm_workspace_dump(void)
|
void tm_workspace_dump(void)
|
||||||
@ -560,13 +507,13 @@ void tm_workspace_dump(void)
|
|||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
g_message("Dumping TagManager workspace tree..");
|
g_message("Dumping TagManager workspace tree..");
|
||||||
#endif
|
#endif
|
||||||
tm_work_object_dump(TM_WORK_OBJECT(theWorkspace));
|
if (theWorkspace->source_files)
|
||||||
if (theWorkspace->work_objects)
|
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
for (i=0; i < theWorkspace->work_objects->len; ++i)
|
for (i=0; i < theWorkspace->source_files->len; ++i)
|
||||||
{
|
{
|
||||||
tm_work_object_dump(TM_WORK_OBJECT(theWorkspace->work_objects->pdata[i]));
|
TMSourceFile *source_file = theWorkspace->source_files->pdata[i];
|
||||||
|
fprintf(stderr, "%s", source_file->file_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,7 +537,7 @@ const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *at
|
|||||||
else
|
else
|
||||||
tags = g_ptr_array_new();
|
tags = g_ptr_array_new();
|
||||||
|
|
||||||
matches[0] = tm_tags_find(theWorkspace->work_object.tags_array, name, partial, TRUE,
|
matches[0] = tm_tags_find(theWorkspace->tags_array, name, partial, TRUE,
|
||||||
&tagCount[0]);
|
&tagCount[0]);
|
||||||
matches[1] = tm_tags_find(theWorkspace->global_tags, name, partial, TRUE, &tagCount[1]);
|
matches[1] = tm_tags_find(theWorkspace->global_tags, name, partial, TRUE, &tagCount[1]);
|
||||||
|
|
||||||
@ -724,7 +671,7 @@ tm_workspace_find_scoped (const char *name, const char *scope, gint type,
|
|||||||
else
|
else
|
||||||
tags = g_ptr_array_new ();
|
tags = g_ptr_array_new ();
|
||||||
|
|
||||||
fill_find_tags_array (tags, theWorkspace->work_object.tags_array,
|
fill_find_tags_array (tags, theWorkspace->tags_array,
|
||||||
name, scope, type, partial, lang, FALSE);
|
name, scope, type, partial, lang, FALSE);
|
||||||
if (global_search)
|
if (global_search)
|
||||||
{
|
{
|
||||||
@ -783,7 +730,7 @@ find_scope_members_tags (const GPtrArray * all, GPtrArray * tags,
|
|||||||
tag = TM_TAG (all->pdata[i]);
|
tag = TM_TAG (all->pdata[i]);
|
||||||
if (no_definitions && filename && tag->atts.entry.file &&
|
if (no_definitions && filename && tag->atts.entry.file &&
|
||||||
0 != strcmp (filename,
|
0 != strcmp (filename,
|
||||||
tag->atts.entry.file->work_object.short_name))
|
tag->atts.entry.file->short_name))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -903,7 +850,7 @@ find_namespace_members_tags (const GPtrArray * all, GPtrArray * tags,
|
|||||||
tag = TM_TAG (all->pdata[i]);
|
tag = TM_TAG (all->pdata[i]);
|
||||||
if (filename && tag->atts.entry.file &&
|
if (filename && tag->atts.entry.file &&
|
||||||
0 != strcmp (filename,
|
0 != strcmp (filename,
|
||||||
tag->atts.entry.file->work_object.short_name))
|
tag->atts.entry.file->short_name))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -996,7 +943,7 @@ tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *na
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
filename = (tag->atts.entry.file ?
|
filename = (tag->atts.entry.file ?
|
||||||
tag->atts.entry.file->work_object.short_name : NULL);
|
tag->atts.entry.file->short_name : NULL);
|
||||||
if (tag->atts.entry.scope && tag->atts.entry.scope[0] != '\0')
|
if (tag->atts.entry.scope && tag->atts.entry.scope[0] != '\0')
|
||||||
{
|
{
|
||||||
del = 1;
|
del = 1;
|
||||||
@ -1026,14 +973,14 @@ tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *na
|
|||||||
|
|
||||||
if (tag && tag->atts.entry.file)
|
if (tag && tag->atts.entry.file)
|
||||||
{
|
{
|
||||||
local = tm_tags_extract (tag->atts.entry.file->work_object.tags_array,
|
local = tm_tags_extract (tag->atts.entry.file->tags_array,
|
||||||
(tm_tag_function_t |
|
(tm_tag_function_t |
|
||||||
tm_tag_field_t | tm_tag_enumerator_t |
|
tm_tag_field_t | tm_tag_enumerator_t |
|
||||||
tm_tag_namespace_t | tm_tag_class_t ));
|
tm_tag_namespace_t | tm_tag_class_t ));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
local = tm_tags_extract (theWorkspace->work_object.tags_array,
|
local = tm_tags_extract (theWorkspace->tags_array,
|
||||||
(tm_tag_function_t | tm_tag_prototype_t |
|
(tm_tag_function_t | tm_tag_prototype_t |
|
||||||
tm_tag_member_t |
|
tm_tag_member_t |
|
||||||
tm_tag_field_t | tm_tag_enumerator_t |
|
tm_tag_field_t | tm_tag_enumerator_t |
|
||||||
@ -1150,7 +1097,7 @@ tm_workspace_find_scope_members (const GPtrArray * file_tags, const char *name,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
filename = (tag->atts.entry.file ?
|
filename = (tag->atts.entry.file ?
|
||||||
tag->atts.entry.file->work_object.short_name : NULL);
|
tag->atts.entry.file->short_name : NULL);
|
||||||
if (tag->atts.entry.scope && tag->atts.entry.scope[0] != '\0')
|
if (tag->atts.entry.scope && tag->atts.entry.scope[0] != '\0')
|
||||||
{
|
{
|
||||||
del = 1;
|
del = 1;
|
||||||
@ -1180,14 +1127,14 @@ tm_workspace_find_scope_members (const GPtrArray * file_tags, const char *name,
|
|||||||
|
|
||||||
if (no_definitions && tag && tag->atts.entry.file)
|
if (no_definitions && tag && tag->atts.entry.file)
|
||||||
{
|
{
|
||||||
local = tm_tags_extract (tag->atts.entry.file->work_object.tags_array,
|
local = tm_tags_extract (tag->atts.entry.file->tags_array,
|
||||||
(tm_tag_function_t | tm_tag_prototype_t |
|
(tm_tag_function_t | tm_tag_prototype_t |
|
||||||
tm_tag_member_t | tm_tag_field_t |
|
tm_tag_member_t | tm_tag_field_t |
|
||||||
tm_tag_method_t | tm_tag_enumerator_t));
|
tm_tag_method_t | tm_tag_enumerator_t));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
local = tm_tags_extract (theWorkspace->work_object.tags_array,
|
local = tm_tags_extract (theWorkspace->tags_array,
|
||||||
(tm_tag_function_t | tm_tag_prototype_t |
|
(tm_tag_function_t | tm_tag_prototype_t |
|
||||||
tm_tag_member_t | tm_tag_field_t |
|
tm_tag_member_t | tm_tag_field_t |
|
||||||
tm_tag_method_t | tm_tag_enumerator_t));
|
tm_tag_method_t | tm_tag_enumerator_t));
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "tm_work_object.h"
|
#include "tm_tag.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -21,54 +21,44 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*! The Tag Manager Workspace. This is a singleton work object containing a list
|
/*! The Tag Manager Workspace. This is a singleton object containing a list
|
||||||
of work objects - individual source files. There is also a global tag list
|
of individual source files. There is also a global tag list
|
||||||
which can be loaded or created. This contains global tags gleaned from
|
which can be loaded or created. This contains global tags gleaned from
|
||||||
/usr/include, etc. and should be used for autocompletion, calltips, etc.
|
/usr/include, etc. and should be used for autocompletion, calltips, etc.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
TMWorkObject work_object; /*!< The parent work object */
|
|
||||||
GPtrArray *global_tags; /*!< Global tags loaded at startup */
|
GPtrArray *global_tags; /*!< Global tags loaded at startup */
|
||||||
GPtrArray *work_objects; /*!< An array of TMWorkObject pointers */
|
GPtrArray *source_files; /*!< An array of TMSourceFile pointers */
|
||||||
|
GPtrArray *tags_array; /*!< Sorted tags from all source files
|
||||||
|
(just pointers to source file tags, the tag objects are owned by the source files) */
|
||||||
} TMWorkspace;
|
} TMWorkspace;
|
||||||
|
|
||||||
/*! Adds a work object (source file) to the workspace.
|
/*! Adds a source file to the workspace.
|
||||||
\param work_object The work object to add to the workspace.
|
\param source_file The source file to add to the workspace.
|
||||||
\return TRUE on success, FALSE on failure (e.g. object already exixts).
|
\return TRUE on success, FALSE on failure (e.g. object already exixts).
|
||||||
*/
|
*/
|
||||||
gboolean tm_workspace_add_object(TMWorkObject *work_object);
|
gboolean tm_workspace_add_source_file(TMSourceFile *source_file);
|
||||||
|
|
||||||
/*! Removes a member object from the workspace if it exists.
|
/*! Removes a member object from the workspace if it exists.
|
||||||
\param work_object Pointer to the work object to be removed.
|
\param source_file Pointer to the source file to be removed.
|
||||||
\param do_free Whether the work object is to be freed as well.
|
\param do_free Whether the source file is to be freed as well.
|
||||||
\param update Whether to update workspace objects.
|
\param update Whether to update workspace objects.
|
||||||
\return TRUE on success, FALSE on failure (e.g. the work object does not exist).
|
\return TRUE on success, FALSE on failure (e.g. the source file does not exist).
|
||||||
*/
|
*/
|
||||||
gboolean tm_workspace_remove_object(TMWorkObject *work_object, gboolean do_free, gboolean update);
|
gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update);
|
||||||
|
|
||||||
|
|
||||||
#ifdef GEANY_PRIVATE
|
#ifdef GEANY_PRIVATE
|
||||||
|
|
||||||
/* Since TMWorkspace is a singleton, you should not create multiple
|
/* Since TMWorkspace is a singleton, you should not create multiple
|
||||||
workspaces, but get a pointer to the workspace whenever required. The first
|
workspaces, but get a pointer to the workspace whenever required. The first
|
||||||
time a pointer is requested, or a work object is added to the workspace,
|
time a pointer is requested, or a source file is added to the workspace,
|
||||||
a workspace is created. Subsequent calls to the function will return the
|
a workspace is created. Subsequent calls to the function will return the
|
||||||
created workspace.
|
created workspace.
|
||||||
*/
|
*/
|
||||||
const TMWorkspace *tm_get_workspace(void);
|
const TMWorkspace *tm_get_workspace(void);
|
||||||
|
|
||||||
/* Given a file name, returns a pointer to the object if the object's file
|
|
||||||
name is same as the passed file name, otherwise retruns NULL. This is an
|
|
||||||
overloaded version of tm_work_object_find().
|
|
||||||
\param work_object Pointer to the workspace.
|
|
||||||
\param file_name The name of the file to search.
|
|
||||||
\param name_only If you want to match just the name and not the full path.
|
|
||||||
\return Pointer to the work object matching the file name (NULL if not found).
|
|
||||||
\sa tm_work_object_find().
|
|
||||||
*/
|
|
||||||
TMWorkObject *tm_workspace_find_object(TMWorkObject *work_object, const char *file_name
|
|
||||||
,gboolean name_only);
|
|
||||||
|
|
||||||
/* Loads the global tag list from the specified file. The global tag list should
|
/* Loads the global tag list from the specified file. The global tag list should
|
||||||
have been first created using tm_workspace_create_global_tags().
|
have been first created using tm_workspace_create_global_tags().
|
||||||
@ -94,22 +84,15 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
|
|||||||
int includes_count, const char *tags_file, int lang);
|
int includes_count, const char *tags_file, int lang);
|
||||||
|
|
||||||
/* Recreates the tag array of the workspace by collecting the tags of
|
/* Recreates the tag array of the workspace by collecting the tags of
|
||||||
all member work objects. You shouldn't have to call this directly since
|
all member source files. You shouldn't have to call this directly since
|
||||||
this is called automatically by tm_workspace_update().
|
this is called automatically by tm_workspace_update().
|
||||||
*/
|
*/
|
||||||
void tm_workspace_recreate_tags_array(void);
|
void tm_workspace_recreate_tags_array(void);
|
||||||
|
|
||||||
/* Calls tm_work_object_update() for all workspace member work objects.
|
/* Calls tm_source_file_update() for all workspace member source files.
|
||||||
Use if you want to globally refresh the workspace.
|
Use if you want to globally refresh the workspace.
|
||||||
\param workspace Pointer to the workspace.
|
|
||||||
\param force Whether the cache should be ignored.
|
|
||||||
\param recurse If set to TRUE, updates all children before updating the tag image.
|
|
||||||
\param update_parent This parameter is ignored for the workspace since it is at the
|
|
||||||
top of the work object hierarchy.
|
|
||||||
\sa tm_work_object_update(), tm_source_file_update()
|
|
||||||
*/
|
*/
|
||||||
gboolean tm_workspace_update(TMWorkObject *workspace, gboolean force
|
void tm_workspace_update(void);
|
||||||
, gboolean recurse, gboolean update_parent);
|
|
||||||
|
|
||||||
/* Dumps the workspace tree - useful for debugging */
|
/* Dumps the workspace tree - useful for debugging */
|
||||||
void tm_workspace_dump(void);
|
void tm_workspace_dump(void);
|
||||||
@ -171,16 +154,11 @@ const TMTag *tm_get_current_function(GPtrArray *file_tags, const gulong line);
|
|||||||
\return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
|
\return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
|
||||||
const GPtrArray *tm_workspace_get_parents(const gchar *name);
|
const GPtrArray *tm_workspace_get_parents(const gchar *name);
|
||||||
|
|
||||||
/* Frees the workspace structure and all child work objects. Use only when
|
/* Frees the workspace structure and all child source files. Use only when
|
||||||
exiting from the main program.
|
exiting from the main program.
|
||||||
*/
|
*/
|
||||||
void tm_workspace_free(gpointer workspace);
|
void tm_workspace_free(void);
|
||||||
|
|
||||||
/* Contains the id obtained by registering the TMWorkspace class as a child of
|
|
||||||
TMWorkObject.
|
|
||||||
\sa tm_work_object_register()
|
|
||||||
*/
|
|
||||||
extern guint workspace_class_id;
|
|
||||||
|
|
||||||
#endif /* GEANY_PRIVATE */
|
#endif /* GEANY_PRIVATE */
|
||||||
|
|
||||||
|
3
wscript
3
wscript
@ -121,7 +121,6 @@ tagmanager_sources = set([
|
|||||||
'tagmanager/src/tm_file_entry.c',
|
'tagmanager/src/tm_file_entry.c',
|
||||||
'tagmanager/src/tm_source_file.c',
|
'tagmanager/src/tm_source_file.c',
|
||||||
'tagmanager/src/tm_tag.c',
|
'tagmanager/src/tm_tag.c',
|
||||||
'tagmanager/src/tm_work_object.c',
|
|
||||||
'tagmanager/src/tm_workspace.c'])
|
'tagmanager/src/tm_workspace.c'])
|
||||||
|
|
||||||
scintilla_sources = set(['scintilla/gtk/scintilla-marshal.c'])
|
scintilla_sources = set(['scintilla/gtk/scintilla-marshal.c'])
|
||||||
@ -553,7 +552,7 @@ def build(bld):
|
|||||||
bld.install_files('${PREFIX}/include/geany/tagmanager', '''
|
bld.install_files('${PREFIX}/include/geany/tagmanager', '''
|
||||||
tagmanager/src/tm_source_file.h
|
tagmanager/src/tm_source_file.h
|
||||||
tagmanager/src/tm_tag.h
|
tagmanager/src/tm_tag.h
|
||||||
tagmanager/src/tm_tagmanager.h tagmanager/src/tm_work_object.h
|
tagmanager/src/tm_tagmanager.h
|
||||||
tagmanager/src/tm_workspace.h ''')
|
tagmanager/src/tm_workspace.h ''')
|
||||||
# Docs
|
# Docs
|
||||||
base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
|
base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user