Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 18 Oct 2014 19:40:10 UTC
Commit: 4903d79dcc7ed1e8e0d54f85f00d07dbb62e33dc
https://github.com/geany/geany/commit/4903d79dcc7ed1e8e0d54f85f00d07dbb62e3…
Log Message:
-----------
TM: use the same format of docstrings as in the rest of Geany
Modified Paths:
--------------
tagmanager/src/tm_source_file.h
tagmanager/src/tm_tag.h
tagmanager/src/tm_tagmanager.h
tagmanager/src/tm_workspace.c
tagmanager/src/tm_workspace.h
Modified: tagmanager/src/tm_source_file.h
78 lines changed, 39 insertions(+), 39 deletions(-)
===================================================================
@@ -33,44 +33,44 @@ extern "C"
#define FALLBACK(X,Y) (X)?(X):(Y)
-/*!
+/**
The TMSourceFile structure represents the source file and its tags in the tag manager.
*/
typedef struct
{
- langType lang; /*!< Programming language used */
- 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 */
+ langType lang; /**< Programming language used */
+ 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;
-/*! Initializes a TMSourceFile structure and returns a pointer to it.
- * \param file_name The file name.
- * \param update Update the tag array of the file.
- * \param name Name of the used programming language, NULL for autodetection.
- * \return The created TMSourceFile object.
+/** Initializes a TMSourceFile structure and returns a pointer to it.
+ * @param file_name The file name.
+ * @param update Update the tag array of the file.
+ * @param name Name of the used programming language, NULL for autodetection.
+ * @return The created TMSourceFile object.
* */
TMSourceFile *tm_source_file_new(const char *file_name, gboolean update, const char *name);
-/*! Updates the source file by reparsing. The tags array and
+/** Updates the source file by reparsing. The tags array and
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
also lost. The language parameter is automatically set the first time the file
is parsed.
- \param source_file The source file to update.
- \param update_workspace If set to TRUE, sends an update signal to the workspace if required. You should
+ @param source_file The source file to update.
+ @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.
*/
void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace);
-/*! Frees a TMSourceFile structure, including all contents */
+/** 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.
+ @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);
@@ -95,30 +95,30 @@ void tm_source_file_destroy(TMSourceFile *source_file);
other tag arrays 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 is parsed.
- \param source_file The source file to update with a buffer.
- \param text_buf A text buffer. The user should take care of allocate and free it after
+ @param source_file The source file to update with a buffer.
+ @param text_buf A text buffer. The user should take care of allocate and free it after
the use here.
- \param buf_size The size of text_buf.
- \param update_workspace If set to TRUE, sends an update signal to the workspace if required. You should
+ @param buf_size The size of text_buf.
+ @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.
- \return TRUE if the file was parsed, FALSE otherwise.
+ @return TRUE if the file was parsed, FALSE otherwise.
*/
void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
gint buf_size, gboolean update_workspace);
/* Parses the source file and regenarates the tags.
- \param source_file The source file to parse
- \return TRUE on success, FALSE on failure
- \sa tm_source_file_update()
+ @param source_file The source file to parse
+ @return TRUE on success, FALSE on failure
+ @see tm_source_file_update()
*/
gboolean tm_source_file_parse(TMSourceFile *source_file);
/* Parses the text-buffer and regenarates the tags.
- \param source_file The source file to parse
- \param text_buf The text buffer to parse
- \param buf_size The size of text_buf.
- \return TRUE on success, FALSE on failure
- \sa tm_source_file_update()
+ @param source_file The source file to parse
+ @param text_buf The text buffer to parse
+ @param buf_size The size of text_buf.
+ @return TRUE on success, FALSE on failure
+ @see tm_source_file_update()
*/
gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf, gint buf_size);
@@ -126,30 +126,30 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf
This function is registered into the ctags parser when a file is parsed for
the first time. The function is then called by the ctags parser each time
it finds a new tag. You should not have to use this function.
- \sa tm_source_file_parse()
+ @see tm_source_file_parse()
*/
int tm_source_file_tags(const tagEntryInfo *tag);
/*
Writes all tags of a source file (including the file tag itself) to the passed
file pointer.
- \param source_file The source file to write.
- \param fp The file pointer to write to.
- \param attrs The attributes to write.
- \return TRUE on success, FALSE on failure.
+ @param source_file The source file to write.
+ @param fp The file pointer to write to.
+ @param attrs The attributes to write.
+ @return TRUE on success, FALSE on failure.
*/
gboolean tm_source_file_write(TMSourceFile *source_file, FILE *fp, guint attrs);
/* Gets the name associated with the language index.
- \param lang The language index.
- \return The language name, or NULL.
+ @param lang The language index.
+ @return The language name, or NULL.
*/
const gchar *tm_source_file_get_lang_name(gint lang);
/* Gets the language index for \a name.
- \param name The language name.
- \return The language index, or -2.
+ @param name The language name.
+ @return The language index, or -2.
*/
gint tm_source_file_get_named_lang(const gchar *name);
Modified: tagmanager/src/tm_tag.h
248 lines changed, 124 insertions(+), 124 deletions(-)
===================================================================
@@ -10,7 +10,7 @@
#ifndef TM_TAG_H
#define TM_TAG_H
-/* \file
+/* @file
The TMTag structure and the associated functions are used to manipulate
tags and arrays of tags. Normally, you should not create tags individually
but through an external interface such as tm_source_file_parse(), which generates
@@ -37,41 +37,41 @@ extern "C"
{
#endif
-/*! Use the TM_TAG() macro to cast a pointer to (TMTag *) */
+/** Use the TM_TAG() macro to cast a pointer to (TMTag *) */
#define TM_TAG(tag) ((TMTag *) tag)
-/*!
+/**
Types of tags. It is a bitmask so that multiple tag types can
be used simultaneously by 'OR'-ing them bitwise.
e.g. tm_tag_class_t | tm_tag_struct_t
*/
typedef enum
{
- tm_tag_undef_t = 0, /*!< Unknown type */
- tm_tag_class_t = 1, /*!< Class declaration */
- tm_tag_enum_t = 2, /*!< Enum declaration */
- tm_tag_enumerator_t = 4, /*!< Enumerator value */
- tm_tag_field_t = 8, /*!< Field (Java only) */
- tm_tag_function_t = 16, /*!< Function definition */
- tm_tag_interface_t = 32, /*!< Interface (Java only) */
- tm_tag_member_t = 64, /*!< Member variable of class/struct */
- tm_tag_method_t = 128, /*!< Class method (Java only) */
- tm_tag_namespace_t = 256, /*!< Namespace declaration */
- tm_tag_package_t = 512, /*!< Package (Java only) */
- tm_tag_prototype_t = 1024, /*!< Function prototype */
- tm_tag_struct_t = 2048, /*!< Struct declaration */
- tm_tag_typedef_t = 4096, /*!< Typedef */
- tm_tag_union_t = 8192, /*!< Union */
- tm_tag_variable_t = 16384, /*!< Variable */
- tm_tag_externvar_t = 32768, /*!< Extern or forward declaration */
- tm_tag_macro_t = 65536, /*!< Macro (without arguments) */
- tm_tag_macro_with_arg_t = 131072, /*!< Parameterized macro */
- tm_tag_file_t = 262144, /*!< File (Pseudo tag) */
- tm_tag_other_t = 524288, /*!< Other (non C/C++/Java tag) */
- tm_tag_max_t = 1048575 /*!< Maximum value of TMTagType */
+ tm_tag_undef_t = 0, /**< Unknown type */
+ tm_tag_class_t = 1, /**< Class declaration */
+ tm_tag_enum_t = 2, /**< Enum declaration */
+ tm_tag_enumerator_t = 4, /**< Enumerator value */
+ tm_tag_field_t = 8, /**< Field (Java only) */
+ tm_tag_function_t = 16, /**< Function definition */
+ tm_tag_interface_t = 32, /**< Interface (Java only) */
+ tm_tag_member_t = 64, /**< Member variable of class/struct */
+ tm_tag_method_t = 128, /**< Class method (Java only) */
+ tm_tag_namespace_t = 256, /**< Namespace declaration */
+ tm_tag_package_t = 512, /**< Package (Java only) */
+ tm_tag_prototype_t = 1024, /**< Function prototype */
+ tm_tag_struct_t = 2048, /**< Struct declaration */
+ tm_tag_typedef_t = 4096, /**< Typedef */
+ tm_tag_union_t = 8192, /**< Union */
+ tm_tag_variable_t = 16384, /**< Variable */
+ tm_tag_externvar_t = 32768, /**< Extern or forward declaration */
+ tm_tag_macro_t = 65536, /**< Macro (without arguments) */
+ tm_tag_macro_with_arg_t = 131072, /**< Parameterized macro */
+ tm_tag_file_t = 262144, /**< File (Pseudo tag) */
+ tm_tag_other_t = 524288, /**< Other (non C/C++/Java tag) */
+ tm_tag_max_t = 1048575 /**< Maximum value of TMTagType */
} TMTagType;
-/*!
+/**
Tag Attributes. Note that some attributes are available to file
pseudotags only. Attributes are useful for specifying as arguments
to the builtin sort and dedup functions, and during printing or writing
@@ -81,39 +81,39 @@ typedef enum
*/
typedef enum
{
- tm_tag_attr_none_t = 0, /*!< Undefined */
- tm_tag_attr_name_t = 1, /*!< Tag Name */
- tm_tag_attr_type_t = 2, /*!< Tag Type */
- tm_tag_attr_file_t = 4, /*!< File in which tag exists */
- tm_tag_attr_line_t = 8, /*!< Line number of tag */
- tm_tag_attr_pos_t = 16, /*!< Byte position of tag in the file (Obsolete) */
- tm_tag_attr_scope_t = 32, /*!< Scope of the tag */
- tm_tag_attr_inheritance_t = 64, /*!< Parent classes */
- tm_tag_attr_arglist_t = 128, /*!< Argument list */
- tm_tag_attr_local_t = 256, /*!< If it has local scope */
- tm_tag_attr_time_t = 512, /*!< Modification time (File tag only) */
- tm_tag_attr_vartype_t = 1024, /*!< Variable Type */
- tm_tag_attr_access_t = 2048, /*!< Access type (public/protected/private) */
- tm_tag_attr_impl_t = 4096, /*!< Implementation (e.g. virtual) */
- tm_tag_attr_lang_t = 8192, /*!< Language (File tag only) */
- tm_tag_attr_inactive_t = 16384, /*!< Inactive file (File tag only, obsolete) */
- tm_tag_attr_pointer_t = 32768, /*!< Pointer type */
- tm_tag_attr_max_t = 65535 /*!< Maximum value */
+ tm_tag_attr_none_t = 0, /**< Undefined */
+ tm_tag_attr_name_t = 1, /**< Tag Name */
+ tm_tag_attr_type_t = 2, /**< Tag Type */
+ tm_tag_attr_file_t = 4, /**< File in which tag exists */
+ tm_tag_attr_line_t = 8, /**< Line number of tag */
+ tm_tag_attr_pos_t = 16, /**< Byte position of tag in the file (Obsolete) */
+ tm_tag_attr_scope_t = 32, /**< Scope of the tag */
+ tm_tag_attr_inheritance_t = 64, /**< Parent classes */
+ tm_tag_attr_arglist_t = 128, /**< Argument list */
+ tm_tag_attr_local_t = 256, /**< If it has local scope */
+ tm_tag_attr_time_t = 512, /**< Modification time (File tag only) */
+ tm_tag_attr_vartype_t = 1024, /**< Variable Type */
+ tm_tag_attr_access_t = 2048, /**< Access type (public/protected/private) */
+ tm_tag_attr_impl_t = 4096, /**< Implementation (e.g. virtual) */
+ tm_tag_attr_lang_t = 8192, /**< Language (File tag only) */
+ tm_tag_attr_inactive_t = 16384, /**< Inactive file (File tag only, obsolete) */
+ tm_tag_attr_pointer_t = 32768, /**< Pointer type */
+ tm_tag_attr_max_t = 65535 /**< Maximum value */
} TMTagAttrType;
-/*! Tag access type for C++/Java member functions and variables */
-#define TAG_ACCESS_PUBLIC 'p' /*!< Public member */
-#define TAG_ACCESS_PROTECTED 'r' /*!< Protected member */
-#define TAG_ACCESS_PRIVATE 'v' /*!< Private member */
-#define TAG_ACCESS_FRIEND 'f' /*!< Friend members/functions */
-#define TAG_ACCESS_DEFAULT 'd' /*!< Default access (Java) */
-#define TAG_ACCESS_UNKNOWN 'x' /*!< Unknown access type */
+/** Tag access type for C++/Java member functions and variables */
+#define TAG_ACCESS_PUBLIC 'p' /**< Public member */
+#define TAG_ACCESS_PROTECTED 'r' /**< Protected member */
+#define TAG_ACCESS_PRIVATE 'v' /**< Private member */
+#define TAG_ACCESS_FRIEND 'f' /**< Friend members/functions */
+#define TAG_ACCESS_DEFAULT 'd' /**< Default access (Java) */
+#define TAG_ACCESS_UNKNOWN 'x' /**< Unknown access type */
-/*! Tag implementation type for functions */
-#define TAG_IMPL_VIRTUAL 'v' /*!< Virtual implementation */
-#define TAG_IMPL_UNKNOWN 'x' /*!< Unknown implementation */
+/** Tag implementation type for functions */
+#define TAG_IMPL_VIRTUAL 'v' /**< Virtual implementation */
+#define TAG_IMPL_UNKNOWN 'x' /**< Unknown implementation */
-/*!
+/**
This structure holds all information about a tag, including the file
pseudo tag. It should always be created indirectly with one of the tag
creation functions such as tm_source_file_parse() or tm_tag_new_from_file().
@@ -122,32 +122,32 @@ typedef enum
*/
typedef struct _TMTag
{
- char *name; /*!< Name of tag */
- TMTagType type; /*!< Tag Type */
+ char *name; /**< Name of tag */
+ TMTagType type; /**< Tag Type */
union
{
- /*! These are *real* tag attributes */
+ /** These are *real* tag attributes */
struct
{
- TMSourceFile *file; /*!< File in which the tag occurs */
- gulong line; /*!< Line number of the tag */
- gboolean local; /*!< Is the tag of local scope */
+ TMSourceFile *file; /**< File in which the tag occurs */
+ gulong line; /**< Line number of the tag */
+ gboolean local; /**< Is the tag of local scope */
guint pointerOrder;
- char *arglist; /*!< Argument list (functions/prototypes/macros) */
- char *scope; /*!< Scope of tag */
- char *inheritance; /*!< Parent classes */
- char *var_type; /*!< Variable type (maps to struct for typedefs) */
- char access; /*!< Access type (public/protected/private/etc.) */
- char impl; /*!< Implementation (e.g. virtual) */
+ char *arglist; /**< Argument list (functions/prototypes/macros) */
+ char *scope; /**< Scope of tag */
+ char *inheritance; /**< Parent classes */
+ char *var_type; /**< Variable type (maps to struct for typedefs) */
+ char access; /**< Access type (public/protected/private/etc.) */
+ char impl; /**< Implementation (e.g. virtual) */
} entry;
- /*! These are pseudo tag attributes representing a file */
+ /** These are pseudo tag attributes representing a file */
struct
{
- time_t timestamp; /*!< Time of parsing of the file */
- langType lang; /*!< Programming language of the file */
+ time_t timestamp; /**< Time of parsing of the file */
+ langType lang; /**< Programming language of the file */
} file;
} atts;
- gint refcount; /*!< the reference count of the tag */
+ gint refcount; /**< the reference count of the tag */
} TMTag;
@@ -179,20 +179,20 @@ GType tm_tag_get_type(void) G_GNUC_CONST;
used by the ctags parsers. Note that the TMTag structure must be malloc()ed
before calling this function. This function is called by tm_tag_new() - you
should not need to call this directly.
- \param tag The TMTag structure to initialize
- \param file Pointer to a TMSourceFile struct (it is assigned to the file member)
- \param tag_entry Tag information gathered by the ctags parser
- \return TRUE on success, FALSE on failure
+ @param tag The TMTag structure to initialize
+ @param file Pointer to a TMSourceFile struct (it is assigned to the file member)
+ @param tag_entry Tag information gathered by the ctags parser
+ @return TRUE on success, FALSE on failure
*/
gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_entry);
/*
Initializes an already malloc()ed TMTag structure by reading a tag entry
line from a file. The structure should be allocated beforehand.
- \param tag The TMTag structure to populate
- \param file The TMSourceFile struct (assigned to the file member)
- \param fp FILE pointer from where the tag line is read
- \return TRUE on success, FALSE on FAILURE
+ @param tag The TMTag structure to populate
+ @param file The TMSourceFile struct (assigned to the file member)
+ @param fp FILE pointer from where the tag line is read
+ @return TRUE on success, FALSE on FAILURE
*/
gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp);
@@ -210,24 +210,24 @@ gboolean tm_tag_init_from_file_ctags(TMTag *tag, TMSourceFile *file, FILE *fp);
/*
Creates a new tag structure from a tagEntryInfo pointer and a TMSOurceFile pointer
and returns a pointer to it.
- \param file - Pointer to the TMSourceFile structure containing the tag
- \param tag_entry Contains tag information generated by ctags
- \return the new TMTag structure. This should be free()-ed using tm_tag_free()
+ @param file - Pointer to the TMSourceFile structure containing the tag
+ @param tag_entry Contains tag information generated by ctags
+ @return the new TMTag structure. This should be free()-ed using tm_tag_free()
*/
TMTag *tm_tag_new(TMSourceFile *file, const tagEntryInfo *tag_entry);
/*
Same as tm_tag_new() except that the tag attributes are read from file.
- \param mode langType to use for the tag.
+ @param mode langType to use for the tag.
*/
TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileFormat format);
/*
Writes tag information to the given FILE *.
- \param tag The tag information to write.
- \param file FILE pointer to which the tag information is written.
- \param attrs Attributes to be written (bitmask).
- \return TRUE on success, FALSE on failure.
+ @param tag The tag information to write.
+ @param file FILE pointer to which the tag information is written.
+ @param attrs Attributes to be written (bitmask).
+ @return TRUE on success, FALSE on failure.
*/
gboolean tm_tag_write(TMTag *tag, FILE *file, guint attrs);
@@ -248,10 +248,10 @@ GPtrArray *tm_tags_merge_big_small(GPtrArray *big_array, GPtrArray *small_array,
/*
Sort an array of tags on the specified attribuites using the inbuilt comparison
function.
- \param tags_array The array of tags to be sorted
- \param sort_attributes Attributes to be sorted on (int array terminated by 0)
- \param dedup Whether to deduplicate the sorted array
- \return TRUE on success, FALSE on failure
+ @param tags_array The array of tags to be sorted
+ @param sort_attributes Attributes to be sorted on (int array terminated by 0)
+ @param dedup Whether to deduplicate the sorted array
+ @return TRUE on success, FALSE on failure
*/
gboolean tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean dedup);
@@ -259,13 +259,13 @@ gboolean tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gbo
This function should be used whenever more involved sorting is required. For this,
you need to write a function as per the prototype of TMTagCompareFunc() and pass
the function as a parameter to this function.
- \param tags_array Array of tags to be sorted
- \param compare_func A function which takes two pointers to (TMTag *)s and returns
+ @param tags_array Array of tags to be sorted
+ @param compare_func A function which takes two pointers to (TMTag *)s and returns
0, 1 or -1 depending on whether the first value is equal to, greater than or less that
the second
- \param dedup Whether to deduplicate the sorted array. Note that the same comparison
+ @param dedup Whether to deduplicate the sorted array. Note that the same comparison
function will be used
- \return TRUE on success, FALSE on failure
+ @return TRUE on success, FALSE on failure
*/
gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_func, gboolean dedup);
@@ -274,39 +274,39 @@ gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_fun
The returned value is a GPtrArray which should be free-d with a call to
g_ptr_array_free(array, TRUE). However, do not free the tags themselves since they
are not duplicated.
- \param tags_array The original array of tags
- \param tag_types - The tag types to extract. Can be a bitmask. For example, passing
+ @param tags_array The original array of tags
+ @param tag_types - The tag types to extract. Can be a bitmask. For example, passing
(tm_tag_typedef_t | tm_tag_struct_t) will extract all typedefs and structures from
the original array.
- \return an array of tags (NULL on failure)
+ @return an array of tags (NULL on failure)
*/
GPtrArray *tm_tags_extract(GPtrArray *tags_array, guint tag_types);
/*
Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() and
tm_tags_custom_dedup() since these functions substitute duplicate entries with NULL
- \param tags_array Array of tags to dedup
- \return TRUE on success, FALSE on failure
+ @param tags_array Array of tags to dedup
+ @return TRUE on success, FALSE on failure
*/
gboolean tm_tags_prune(GPtrArray *tags_array);
/*
Deduplicates an array on tags using the inbuilt comparison function based on
the attributes specified. Called by tm_tags_sort() when dedup is TRUE.
- \param tags_array Array of tags to dedup.
- \param sort_attributes Attributes the array is sorted on. They will be deduped
+ @param tags_array Array of tags to dedup.
+ @param sort_attributes Attributes the array is sorted on. They will be deduped
on the same criteria.
- \return TRUE on success, FALSE on failure
+ @return TRUE on success, FALSE on failure
*/
gboolean tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes);
/*
This is a more powerful form of tm_tags_dedup() since it can accomodate user
defined comparison functions. Called by tm_tags_custom_sort() is dedup is TRUE.
- \param tags_array Array of tags to dedup.
- \compare_function Comparison function
- \return TRUE on success, FALSE on FAILURE
- \sa TMTagCompareFunc
+ @param tags_array Array of tags to dedup.
+ @param compare_func Comparison function
+ @return TRUE on success, FALSE on FAILURE
+ @see TMTagCompareFunc
*/
gboolean tm_tags_custom_dedup(GPtrArray *tags_array, TMTagCompareFunc compare_func);
@@ -314,34 +314,34 @@ gboolean tm_tags_custom_dedup(GPtrArray *tags_array, TMTagCompareFunc compare_fu
Returns a pointer to the position of the first matching tag in a (sorted) tags array.
The passed array of tags should be already sorted by name for optimal performance. If
\c tags_array_sorted is set to FALSE, it may be unsorted but the lookup will be slower.
- \param tags_array Tag array (may be sorted on name)
- \param name Name of the tag to locate.
- \param partial If TRUE, matches the first part of the name instead of doing exact match.
- \param tags_array_sorted If TRUE, the passed \c tags_array is sorted by name so it can be
+ @param tags_array Tag array (may be sorted on name)
+ @param name Name of the tag to locate.
+ @param partial If TRUE, matches the first part of the name instead of doing exact match.
+ @param tags_array_sorted If TRUE, the passed \c tags_array is sorted by name so it can be
searched with binary search. Otherwise it is searched linear which is obviously slower.
- \param tagCount Return location of the matched tags.
+ @param tagCount Return location of the matched tags.
*/
TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
gboolean partial, gboolean tags_array_sorted, int * tagCount);
/*
Completely frees an array of tags.
- \param tags_array Array of tags to be freed.
- \param free_array Whether the GptrArray is to be freed as well.
+ @param tags_array Array of tags to be freed.
+ @param free_array Whether the GptrArray is to be freed as well.
*/
void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all);
#if 0
/*
Destroys a TMTag structure, i.e. frees all elements except the tag itself.
- \param tag The TMTag structure to destroy
- \sa tm_tag_free()
+ @param tag The TMTag structure to destroy
+ @see tm_tag_free()
*/
void tm_tag_destroy(TMTag *tag);
/*
Destroys all data in the tag and frees the tag structure as well.
- \param tag Pointer to a TMTag structure
+ @param tag Pointer to a TMTag structure
*/
void tm_tag_free(gpointer tag);
#endif
@@ -349,33 +349,33 @@ void tm_tag_free(gpointer tag);
/*
Drops a reference from a TMTag. If the reference count reaches 0, this function
destroys all data in the tag and frees the tag structure as well.
- \param tag Pointer to a TMTag structure
+ @param tag Pointer to a TMTag structure
*/
void tm_tag_unref(TMTag *tag);
/*
Adds a reference to a TMTag.
- \param tag Pointer to a TMTag structure
- \return the passed-in TMTag
+ @param tag Pointer to a TMTag structure
+ @return the passed-in TMTag
*/
TMTag *tm_tag_ref(TMTag *tag);
/*
Returns the type of tag as a string
- \param tag The tag whose type is required
+ @param tag The tag whose type is required
*/
const char *tm_tag_type_name(const TMTag *tag);
/*
Returns the TMTagType given the name of the type. Reverse of tm_tag_type_name.
- \param tag_name Name of the tag type
+ @param tag_name Name of the tag type
*/
TMTagType tm_tag_name_type(const char* tag_name);
/*
Prints information about a tag to the given file pointer.
- \param tag The tag whose info is required.
- \fp The file pointer of teh file to print the info to.
+ @param tag The tag whose info is required.
+ @param fp The file pointer of teh file to print the info to.
*/
void tm_tag_print(TMTag *tag, FILE *fp);
Modified: tagmanager/src/tm_tagmanager.h
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -17,20 +17,20 @@
#include "tm_parser.h"
#endif /* GEANY_PRIVATE */
-/*! \mainpage Introduction
- \section Introduction
+/** @mainpage Introduction
+ @section Introduction
TagManager is a library and a set of utility programs which can be integrated into
Integrated Development Environments to provide features such as code completion,
calltips, etc. Tag Manager is based on <a href="http://ctags.sourceforge.net">
Exuberent Ctags</a> with some added features.
- \section Licence
+ @section Licence
TagManager is <a href="http://www.gnu.org/philosophy/free-sw.html">free software</a>,
licenced under the <a href="http://www.gnu.org/licenses/gpl.html">GPL</a>. You can only
use it with free software (GPL compatible) projects. This is chiefly because it uses
code from ctags which is under GPL.
*/
-/*! \file
+/** @file
Include this file in all programs using the tag manager library. Including this
automatically includes all the necessary files, namely, tm_tag.h, tm_source_file.h
and tm_workspace.h
Modified: tagmanager/src/tm_workspace.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -7,7 +7,7 @@
*
*/
-/*!
+/**
* @file tm_workspace.h
The TMWorkspace structure is meant to be used as a singleton to store application
wide tag information.
Modified: tagmanager/src/tm_workspace.h
92 lines changed, 46 insertions(+), 46 deletions(-)
===================================================================
@@ -21,34 +21,34 @@ extern "C"
#endif
-/*! The Tag Manager Workspace. This is a singleton object containing a list
+/** The Tag Manager Workspace. This is a singleton object containing a list
of individual source files. There is also a global tag list
which can be loaded or created. This contains global tags gleaned from
/usr/include, etc. and should be used for autocompletion, calltips, etc.
*/
typedef struct
{
- GPtrArray *global_tags; /*!< Global tags loaded at startup */
- GPtrArray *source_files; /*!< An array of TMSourceFile pointers */
- GPtrArray *tags_array; /*!< Sorted tags from all source files
+ GPtrArray *global_tags; /**< Global tags loaded at startup */
+ 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;
-/*! Adds a source file 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).
+/** Adds a source file 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).
*/
gboolean tm_workspace_add_source_file(TMSourceFile *source_file);
-/*! Removes a member object from the workspace if it exists.
- \param source_file Pointer to the source file to be removed.
- \param do_free Whether the source file is to be freed as well.
- \param update Whether to update workspace objects.
- \return TRUE on success, FALSE on failure (e.g. the source file does not exist).
+/** Removes a member object from the workspace if it exists.
+ @param source_file Pointer to the source file to be removed.
+ @param do_free Whether the source file is to be freed as well.
+ @param update Whether to update workspace objects.
+ @return TRUE on success, FALSE on failure (e.g. the source file does not exist).
*/
gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update);
-/*! Calls tm_source_file_update() for all workspace member source files and creates
+/** Calls tm_source_file_update() for all workspace member source files and creates
workspace tag array. Use if you want to globally refresh the workspace.
*/
void tm_workspace_update(void);
@@ -67,9 +67,9 @@ const TMWorkspace *tm_get_workspace(void);
/* Loads the global tag list from the specified file. The global tag list should
have been first created using tm_workspace_create_global_tags().
- \param tags_file The file containing global tags.
- \return TRUE on success, FALSE on failure.
- \sa tm_workspace_create_global_tags()
+ @param tags_file The file containing global tags.
+ @return TRUE on success, FALSE on failure.
+ @see tm_workspace_create_global_tags()
*/
gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode);
/*gboolean tm_workspace_load_global_tags(const char *tags_file);*/
@@ -77,13 +77,13 @@ gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode);
/* Creates a list of global tags. Ideally, this should be created once during
installations so that all users can use the same file. Thsi is because a full
scale global tag list can occupy several megabytes of disk space.
- \param pre_process The pre-processing command. This is executed via system(),
+ @param pre_process The pre-processing command. This is executed via system(),
so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
- \param includes Include files to process. Wildcards such as '/usr/include/a*.h'
+ @param includes Include files to process. Wildcards such as '/usr/include/a*.h'
are allowed.
- \param tags_file The file where the tags will be stored.
- \param lang The language to use for the tags file.
- \return TRUE on success, FALSE on failure.
+ @param tags_file The file where the tags will be stored.
+ @param lang The language to use for the tags file.
+ @return TRUE on success, FALSE on failure.
*/
gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
int includes_count, const char *tags_file, int lang);
@@ -98,35 +98,35 @@ void tm_workspace_recreate_tags_array(void);
void tm_workspace_dump(void);
/* Returns all matching tags found in the workspace.
- \param name The name of the tag to find.
- \param type The tag types to return (TMTagType). Can be a bitmask.
- \param attrs The attributes to sort and dedup on (0 terminated integer array).
- \param partial Whether partial match is allowed.
- \param lang Specifies the language(see the table in parsers.h) of the tags to be found,
+ @param name The name of the tag to find.
+ @param type The tag types to return (TMTagType). Can be a bitmask.
+ @param attrs The attributes to sort and dedup on (0 terminated integer array).
+ @param partial Whether partial match is allowed.
+ @param lang Specifies the language(see the table in parsers.h) of the tags to be found,
-1 for all
- \return Array of matching tags. Do not free() it since it is a static member.
+ @return Array of matching tags. Do not free() it since it is a static member.
*/
const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *attrs
, gboolean partial, langType lang);
/* Returns all matching tags found in the workspace.
- \param name The name of the tag to find.
- \param scope The scope name of the tag to find, or NULL.
- \param type The tag types to return (TMTagType). Can be a bitmask.
- \param attrs The attributes to sort and dedup on (0 terminated integer array).
- \param partial Whether partial match is allowed.
- \param lang Specifies the language(see the table in parsers.h) of the tags to be found,
+ @param name The name of the tag to find.
+ @param scope The scope name of the tag to find, or NULL.
+ @param type The tag types to return (TMTagType). Can be a bitmask.
+ @param attrs The attributes to sort and dedup on (0 terminated integer array).
+ @param partial Whether partial match is allowed.
+ @param lang Specifies the language(see the table in parsers.h) of the tags to be found,
-1 for all
- \return Array of matching tags. Do not free() it since it is a static member.
+ @return Array of matching tags. Do not free() it since it is a static member.
*/
const GPtrArray *
tm_workspace_find_scoped (const char *name, const char *scope, gint type,
TMTagAttrType *attrs, gboolean partial, langType lang, gboolean global_search);
/* Returns all matching members tags found in given struct/union/class name.
- \param name Name of the struct/union/class.
- \param file_tags A GPtrArray of edited file TMTag pointers (for search speedup, can be NULL).
- \return A GPtrArray of TMTag pointers to struct/union/class members */
+ @param name Name of the struct/union/class.
+ @param file_tags A GPtrArray of edited file TMTag pointers (for search speedup, can be NULL).
+ @return A GPtrArray of TMTag pointers to struct/union/class members */
const GPtrArray *tm_workspace_find_scope_members(const GPtrArray *file_tags,
const char *scope_name,
gboolean find_global,
@@ -137,21 +137,21 @@ tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *na
gboolean search_global);
/* Returns TMTag which "own" given line
- \param line Current line in edited file.
- \param file_tags A GPtrArray of edited file TMTag pointers.
- \param tag_types the tag types to include in the match
- \return TMTag pointers to owner tag. */
+ @param line Current line in edited file.
+ @param file_tags A GPtrArray of edited file TMTag pointers.
+ @param tag_types the tag types to include in the match
+ @return TMTag pointers to owner tag. */
const TMTag *tm_get_current_tag(GPtrArray *file_tags, const gulong line, const guint tag_types);
/* Returns TMTag to function or method which "own" given line
- \param line Current line in edited file.
- \param file_tags A GPtrArray of edited file TMTag pointers.
- \return TMTag pointers to owner function. */
+ @param line Current line in edited file.
+ @param file_tags A GPtrArray of edited file TMTag pointers.
+ @return TMTag pointers to owner function. */
const TMTag *tm_get_current_function(GPtrArray *file_tags, const gulong line);
/* Returns a list of parent classes for the given class name
- \param name Name of the class
- \return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
+ @param name Name of the class
+ @return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
const GPtrArray *tm_workspace_get_parents(const gchar *name);
/* Frees the workspace structure and all child source files. Use only when
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 18 Oct 2014 19:40:10 UTC
Commit: 0470f45e0cac539efed63e3f01d519ac01623f74
https://github.com/geany/geany/commit/0470f45e0cac539efed63e3f01d519ac01623…
Log Message:
-----------
TM: move function descriptions from headers to sources
To make it consistent with the rest of Geany.
Modified Paths:
--------------
tagmanager/src/tm_source_file.c
tagmanager/src/tm_source_file.h
tagmanager/src/tm_tag.c
tagmanager/src/tm_tag.h
tagmanager/src/tm_workspace.c
tagmanager/src/tm_workspace.h
Modified: tagmanager/src/tm_source_file.c
78 lines changed, 78 insertions(+), 0 deletions(-)
===================================================================
@@ -79,6 +79,12 @@ static char *realpath (const char *pathname, char *resolved_path)
}
#endif
+/**
+ 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)
{
if (file_name)
@@ -94,6 +100,7 @@ gchar *tm_get_real_path(const gchar *file_name)
return NULL;
}
+/* Initializes a TMSourceFile structure from a file name. */
gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
, gboolean update, const char* name)
{
@@ -147,6 +154,12 @@ gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
return TRUE;
}
+/** Initializes a TMSourceFile structure and returns a pointer to it.
+ * @param file_name The file name.
+ * @param update Update the tag array of the file.
+ * @param name Name of the used programming language, NULL for autodetection.
+ * @return The created TMSourceFile object.
+ * */
TMSourceFile *tm_source_file_new(const char *file_name, gboolean update, const char *name)
{
TMSourceFile *source_file = g_new(TMSourceFile, 1);
@@ -158,6 +171,10 @@ TMSourceFile *tm_source_file_new(const char *file_name, gboolean update, const c
return source_file;
}
+/* Destroys the contents of the source file. Note that the tags are owned by the
+ source file and are also destroyed when the source file is destroyed. If pointers
+ to these tags are used elsewhere, then those tag arrays should be rebuilt.
+*/
void tm_source_file_destroy(TMSourceFile *source_file)
{
#ifdef TM_DEBUG
@@ -172,6 +189,7 @@ void tm_source_file_destroy(TMSourceFile *source_file)
}
}
+/** Frees a TMSourceFile structure, including all contents */
void tm_source_file_free(TMSourceFile *source_file)
{
if (NULL != source_file)
@@ -181,6 +199,11 @@ void tm_source_file_free(TMSourceFile *source_file)
}
}
+/* Parses the source file and regenarates the tags.
+ @param source_file The source file to parse
+ @return TRUE on success, FALSE on failure
+ @see tm_source_file_update()
+*/
gboolean tm_source_file_parse(TMSourceFile *source_file)
{
const char *file_name;
@@ -237,6 +260,13 @@ gboolean tm_source_file_parse(TMSourceFile *source_file)
return status;
}
+/* Parses the text-buffer and regenarates the tags.
+ @param source_file The source file to parse
+ @param text_buf The text buffer to parse
+ @param buf_size The size of text_buf.
+ @return TRUE on success, FALSE on failure
+ @see tm_source_file_update()
+*/
gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf, gint buf_size)
{
const char *file_name;
@@ -309,6 +339,7 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf
return status;
}
+/* Set the argument list of tag identified by its name */
void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist)
{
int count;
@@ -332,6 +363,12 @@ void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist)
}
}
+/*
+ This function is registered into the ctags parser when a file is parsed for
+ the first time. The function is then called by the ctags parser each time
+ it finds a new tag. You should not have to use this function.
+ @see tm_source_file_parse()
+*/
int tm_source_file_tags(const tagEntryInfo *tag)
{
if (NULL == current_source_file)
@@ -343,6 +380,15 @@ int tm_source_file_tags(const tagEntryInfo *tag)
return TRUE;
}
+/** Updates the source file by reparsing. The tags array and
+ 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
+ also lost. The language parameter is automatically set the first time the file
+ is parsed.
+ @param source_file The source file to update.
+ @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.
+*/
void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace)
{
#ifdef TM_DEBUG
@@ -373,6 +419,22 @@ void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace)
}
+/* Updates the source file by reparsing the text-buffer passed as parameter.
+ 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're editing. It's useful for a "real-time" updating of the tags.
+ The tags array and 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 also lost. The language parameter is automatically set the first
+ time the file is parsed.
+ @param source_file The source file to update with a buffer.
+ @param text_buf A text buffer. The user should take care of allocate and free it after
+ the use here.
+ @param buf_size The size of text_buf.
+ @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.
+ @return TRUE if the file was parsed, FALSE otherwise.
+*/
void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
gint buf_size, gboolean update_workspace)
{
@@ -404,6 +466,14 @@ void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
}
+/*
+ Writes all tags of a source file (including the file tag itself) to the passed
+ file pointer.
+ @param source_file The source file to write.
+ @param fp The file pointer to write to.
+ @param attrs The attributes to write.
+ @return TRUE on success, FALSE on failure.
+*/
gboolean tm_source_file_write(TMSourceFile *source_file, FILE *fp, guint attrs)
{
TMTag *tag;
@@ -429,6 +499,10 @@ gboolean tm_source_file_write(TMSourceFile *source_file, FILE *fp, guint attrs)
return TRUE;
}
+/* Gets the name associated with the language index.
+ @param lang The language index.
+ @return The language name, or NULL.
+*/
const gchar *tm_source_file_get_lang_name(gint lang)
{
if (NULL == LanguageTable)
@@ -443,6 +517,10 @@ const gchar *tm_source_file_get_lang_name(gint lang)
return getLanguageName(lang);
}
+/* Gets the language index for \a name.
+ @param name The language name.
+ @return The language index, or -2.
+*/
gint tm_source_file_get_named_lang(const gchar *name)
{
if (NULL == LanguageTable)
Modified: tagmanager/src/tm_source_file.h
79 lines changed, 0 insertions(+), 79 deletions(-)
===================================================================
@@ -44,116 +44,37 @@ typedef struct
GPtrArray *tags_array; /**< Tags obtained by parsing the object */
} TMSourceFile;
-/** Initializes a TMSourceFile structure and returns a pointer to it.
- * @param file_name The file name.
- * @param update Update the tag array of the file.
- * @param name Name of the used programming language, NULL for autodetection.
- * @return The created TMSourceFile object.
- * */
TMSourceFile *tm_source_file_new(const char *file_name, gboolean update, const char *name);
-/** Updates the source file by reparsing. The tags array and
- 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
- also lost. The language parameter is automatically set the first time the file
- is parsed.
- @param source_file The source file to update.
- @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.
-*/
void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace);
-/** 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
-/* Initializes a TMSourceFile structure from a file name. */
gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name,
gboolean update, const char *name);
-/* Destroys the contents of the source file. Note that the tags are owned by the
- source file and are also destroyed when the source file is destroyed. If pointers
- to these tags are used elsewhere, then those tag arrays should be rebuilt.
-*/
void tm_source_file_destroy(TMSourceFile *source_file);
-/* Updates the source file by reparsing the text-buffer passed as parameter.
- 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're editing. It's useful for a "real-time" updating of the tags.
- The tags array and 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 also lost. The language parameter is automatically set the first
- time the file is parsed.
- @param source_file The source file to update with a buffer.
- @param text_buf A text buffer. The user should take care of allocate and free it after
- the use here.
- @param buf_size The size of text_buf.
- @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.
- @return TRUE if the file was parsed, FALSE otherwise.
-*/
void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
gint buf_size, gboolean update_workspace);
-/* Parses the source file and regenarates the tags.
- @param source_file The source file to parse
- @return TRUE on success, FALSE on failure
- @see tm_source_file_update()
-*/
gboolean tm_source_file_parse(TMSourceFile *source_file);
-/* Parses the text-buffer and regenarates the tags.
- @param source_file The source file to parse
- @param text_buf The text buffer to parse
- @param buf_size The size of text_buf.
- @return TRUE on success, FALSE on failure
- @see tm_source_file_update()
-*/
gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf, gint buf_size);
-/*
- This function is registered into the ctags parser when a file is parsed for
- the first time. The function is then called by the ctags parser each time
- it finds a new tag. You should not have to use this function.
- @see tm_source_file_parse()
-*/
int tm_source_file_tags(const tagEntryInfo *tag);
-/*
- Writes all tags of a source file (including the file tag itself) to the passed
- file pointer.
- @param source_file The source file to write.
- @param fp The file pointer to write to.
- @param attrs The attributes to write.
- @return TRUE on success, FALSE on failure.
-*/
gboolean tm_source_file_write(TMSourceFile *source_file, FILE *fp, guint attrs);
-
-/* Gets the name associated with the language index.
- @param lang The language index.
- @return The language name, or NULL.
-*/
const gchar *tm_source_file_get_lang_name(gint lang);
-/* Gets the language index for \a name.
- @param name The language name.
- @return The language index, or -2.
-*/
gint tm_source_file_get_named_lang(const gchar *name);
-/* Set the argument list of tag identified by its name */
void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist);
#endif /* GEANY_PRIVATE */
Modified: tagmanager/src/tm_tag.c
154 lines changed, 153 insertions(+), 1 deletions(-)
===================================================================
@@ -144,6 +144,7 @@ static int s_tag_types[] = {
tm_tag_other_t
};
+/* Gets the GType for a TMTag */
GType tm_tag_get_type(void)
{
static GType gtype = 0;
@@ -208,6 +209,16 @@ static char get_tag_access(const char *access)
return TAG_ACCESS_UNKNOWN;
}
+/*
+ Initializes a TMTag structure with information from a tagEntryInfo struct
+ used by the ctags parsers. Note that the TMTag structure must be malloc()ed
+ before calling this function. This function is called by tm_tag_new() - you
+ should not need to call this directly.
+ @param tag The TMTag structure to initialize
+ @param file Pointer to a TMSourceFile struct (it is assigned to the file member)
+ @param tag_entry Tag information gathered by the ctags parser
+ @return TRUE on success, FALSE on failure
+*/
gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_entry)
{
tag->refcount = 1;
@@ -256,6 +267,13 @@ gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_ent
}
}
+/*
+ Creates a new tag structure from a tagEntryInfo pointer and a TMSOurceFile pointer
+ and returns a pointer to it.
+ @param file - Pointer to the TMSourceFile structure containing the tag
+ @param tag_entry Contains tag information generated by ctags
+ @return the new TMTag structure. This should be free()-ed using tm_tag_free()
+*/
TMTag *tm_tag_new(TMSourceFile *file, const tagEntryInfo *tag_entry)
{
TMTag *tag;
@@ -269,6 +287,14 @@ TMTag *tm_tag_new(TMSourceFile *file, const tagEntryInfo *tag_entry)
return tag;
}
+/*
+ Initializes an already malloc()ed TMTag structure by reading a tag entry
+ line from a file. The structure should be allocated beforehand.
+ @param tag The TMTag structure to populate
+ @param file The TMSourceFile struct (assigned to the file member)
+ @param fp FILE pointer from where the tag line is read
+ @return TRUE on success, FALSE on FAILURE
+*/
gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp)
{
guchar buf[BUFSIZ];
@@ -409,7 +435,10 @@ gboolean tm_tag_init_from_file_alt(TMTag *tag, TMSourceFile *file, FILE *fp)
return TRUE;
}
-/* Reads ctags format (http://ctags.sourceforge.net/FORMAT) */
+/*
+ Same as tm_tag_init_from_file(), but parsing CTags tag file format
+ (http://ctags.sourceforge.net/FORMAT)
+*/
gboolean tm_tag_init_from_file_ctags(TMTag *tag, TMSourceFile *file, FILE *fp)
{
gchar buf[BUFSIZ];
@@ -551,6 +580,10 @@ gboolean tm_tag_init_from_file_ctags(TMTag *tag, TMSourceFile *file, FILE *fp)
return TRUE;
}
+/*
+ Same as tm_tag_new() except that the tag attributes are read from file.
+ @param mode langType to use for the tag.
+*/
TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileFormat format)
{
TMTag *tag;
@@ -580,6 +613,13 @@ TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileForma
return tag;
}
+/*
+ Writes tag information to the given FILE *.
+ @param tag The tag information to write.
+ @param file FILE pointer to which the tag information is written.
+ @param attrs Attributes to be written (bitmask).
+ @return TRUE on success, FALSE on failure.
+*/
gboolean tm_tag_write(TMTag *tag, FILE *fp, guint attrs)
{
fprintf(fp, "%s", tag->name);
@@ -619,6 +659,11 @@ gboolean tm_tag_write(TMTag *tag, FILE *fp, guint attrs)
return FALSE;
}
+/*
+ Destroys a TMTag structure, i.e. frees all elements except the tag itself.
+ @param tag The TMTag structure to destroy
+ @see tm_tag_free()
+*/
static void tm_tag_destroy(TMTag *tag)
{
g_free(tag->name);
@@ -632,12 +677,21 @@ static void tm_tag_destroy(TMTag *tag)
}
#if 0
+/*
+ Destroys all data in the tag and frees the tag structure as well.
+ @param tag Pointer to a TMTag structure
+*/
void tm_tag_free(gpointer tag)
{
tm_tag_unref(tag);
}
#endif
+/*
+ Drops a reference from a TMTag. If the reference count reaches 0, this function
+ destroys all data in the tag and frees the tag structure as well.
+ @param tag Pointer to a TMTag structure
+*/
void tm_tag_unref(TMTag *tag)
{
/* be NULL-proof because tm_tag_free() was NULL-proof and we indent to be a
@@ -649,12 +703,22 @@ void tm_tag_unref(TMTag *tag)
}
}
+/*
+ Adds a reference to a TMTag.
+ @param tag Pointer to a TMTag structure
+ @return the passed-in TMTag
+*/
TMTag *tm_tag_ref(TMTag *tag)
{
g_atomic_int_inc(&tag->refcount);
return tag;
}
+/*
+ Inbuilt tag comparison function. Do not call directly since it needs some
+ static variables to be set. Always use tm_tags_sort() and tm_tags_dedup()
+ instead.
+*/
int tm_tag_compare(const void *ptr1, const void *ptr2)
{
unsigned int *sort_attr;
@@ -720,6 +784,12 @@ int tm_tag_compare(const void *ptr1, const void *ptr2)
return returnval;
}
+/*
+ Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() and
+ tm_tags_custom_dedup() since these functions substitute duplicate entries with NULL
+ @param tags_array Array of tags to dedup
+ @return TRUE on success, FALSE on failure
+*/
gboolean tm_tags_prune(GPtrArray *tags_array)
{
guint i, count;
@@ -732,6 +802,14 @@ gboolean tm_tags_prune(GPtrArray *tags_array)
return TRUE;
}
+/*
+ Deduplicates an array on tags using the inbuilt comparison function based on
+ the attributes specified. Called by tm_tags_sort() when dedup is TRUE.
+ @param tags_array Array of tags to dedup.
+ @param sort_attributes Attributes the array is sorted on. They will be deduped
+ on the same criteria.
+ @return TRUE on success, FALSE on failure
+*/
gboolean tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes)
{
guint i;
@@ -751,6 +829,14 @@ gboolean tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes)
return TRUE;
}
+/*
+ This is a more powerful form of tm_tags_dedup() since it can accomodate user
+ defined comparison functions. Called by tm_tags_custom_sort() is dedup is TRUE.
+ @param tags_array Array of tags to dedup.
+ @param compare_func Comparison function
+ @return TRUE on success, FALSE on FAILURE
+ @see TMTagCompareFunc
+*/
gboolean tm_tags_custom_dedup(GPtrArray *tags_array, TMTagCompareFunc compare_func)
{
guint i;
@@ -812,6 +898,14 @@ gboolean tm_tags_merge(GPtrArray *tags_array, gsize orig_len,
return TRUE;
}
+/*
+ Sort an array of tags on the specified attribuites using the inbuilt comparison
+ function.
+ @param tags_array The array of tags to be sorted
+ @param sort_attributes Attributes to be sorted on (int array terminated by 0)
+ @param dedup Whether to deduplicate the sorted array
+ @return TRUE on success, FALSE on failure
+*/
gboolean tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean dedup)
{
if ((!tags_array) || (!tags_array->len))
@@ -938,6 +1032,18 @@ GPtrArray *tm_tags_merge_big_small(GPtrArray *big_array, GPtrArray *small_array,
return res_array;
}
+/*
+ This function should be used whenever more involved sorting is required. For this,
+ you need to write a function as per the prototype of TMTagCompareFunc() and pass
+ the function as a parameter to this function.
+ @param tags_array Array of tags to be sorted
+ @param compare_func A function which takes two pointers to (TMTag *)s and returns
+ 0, 1 or -1 depending on whether the first value is equal to, greater than or less that
+ the second
+ @param dedup Whether to deduplicate the sorted array. Note that the same comparison
+ function will be used
+ @return TRUE on success, FALSE on failure
+*/
gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_func, gboolean dedup)
{
if ((!tags_array) || (!tags_array->len))
@@ -948,6 +1054,17 @@ gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_fun
return TRUE;
}
+/*
+ This function will extract the tags of the specified types from an array of tags.
+ The returned value is a GPtrArray which should be free-d with a call to
+ g_ptr_array_free(array, TRUE). However, do not free the tags themselves since they
+ are not duplicated.
+ @param tags_array The original array of tags
+ @param tag_types - The tag types to extract. Can be a bitmask. For example, passing
+ (tm_tag_typedef_t | tm_tag_struct_t) will extract all typedefs and structures from
+ the original array.
+ @return an array of tags (NULL on failure)
+*/
GPtrArray *tm_tags_extract(GPtrArray *tags_array, guint tag_types)
{
GPtrArray *new_tags;
@@ -966,6 +1083,11 @@ GPtrArray *tm_tags_extract(GPtrArray *tags_array, guint tag_types)
return new_tags;
}
+/*
+ Completely frees an array of tags.
+ @param tags_array Array of tags to be freed.
+ @param free_array Whether the GptrArray is to be freed as well.
+*/
void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all)
{
if (tags_array)
@@ -1003,6 +1125,17 @@ static TMTag **tags_search(const GPtrArray *tags_array, TMTag *tag, gboolean par
return NULL;
}
+/*
+ Returns a pointer to the position of the first matching tag in a (sorted) tags array.
+ The passed array of tags should be already sorted by name for optimal performance. If
+ \c tags_array_sorted is set to FALSE, it may be unsorted but the lookup will be slower.
+ @param tags_array Tag array (may be sorted on name)
+ @param name Name of the tag to locate.
+ @param partial If TRUE, matches the first part of the name instead of doing exact match.
+ @param tags_array_sorted If TRUE, the passed \c tags_array is sorted by name so it can be
+ searched with binary search. Otherwise it is searched linear which is obviously slower.
+ @param tagCount Return location of the matched tags.
+*/
TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
gboolean partial, gboolean tags_array_sorted, int * tagCount)
{
@@ -1049,6 +1182,10 @@ TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
return (TMTag **) result;
}
+/*
+ Returns the type of tag as a string
+ @param tag The tag whose type is required
+*/
const char *tm_tag_type_name(const TMTag *tag)
{
g_return_val_if_fail(tag, NULL);
@@ -1078,6 +1215,10 @@ const char *tm_tag_type_name(const TMTag *tag)
return NULL;
}
+/*
+ Returns the TMTagType given the name of the type. Reverse of tm_tag_type_name.
+ @param tag_name Name of the tag type
+*/
TMTagType tm_tag_name_type(const char* tag_name)
{
g_return_val_if_fail(tag_name, tm_tag_undef_t);
@@ -1126,6 +1267,11 @@ static const char *tm_tag_access_name(TMTag *tag)
return NULL;
}
+/*
+ Prints information about a tag to the given file pointer.
+ @param tag The tag whose info is required.
+ @param fp The file pointer of teh file to print the info to.
+*/
void tm_tag_print(TMTag *tag, FILE *fp)
{
const char *laccess, *impl, *type;
@@ -1160,6 +1306,9 @@ void tm_tag_print(TMTag *tag, FILE *fp)
fprintf(fp, "\n");
}
+/*
+ Prints info about all tags in the array to the given file pointer.
+*/
void tm_tags_array_print(GPtrArray *tags, FILE *fp)
{
guint i;
@@ -1173,6 +1322,9 @@ void tm_tags_array_print(GPtrArray *tags, FILE *fp)
}
}
+/*
+ Returns the depth of tag scope (useful for finding tag hierarchy
+*/
gint tm_tag_scope_depth(const TMTag *t)
{
gint depth;
Modified: tagmanager/src/tm_tag.h
156 lines changed, 0 insertions(+), 156 deletions(-)
===================================================================
@@ -171,71 +171,22 @@ typedef int (*TMTagCompareFunc) (const void *ptr1, const void *ptr2);
/* The GType for a TMTag */
#define TM_TYPE_TAG (tm_tag_get_type())
-/* Gets the GType for a TMTag */
GType tm_tag_get_type(void) G_GNUC_CONST;
-/*
- Initializes a TMTag structure with information from a tagEntryInfo struct
- used by the ctags parsers. Note that the TMTag structure must be malloc()ed
- before calling this function. This function is called by tm_tag_new() - you
- should not need to call this directly.
- @param tag The TMTag structure to initialize
- @param file Pointer to a TMSourceFile struct (it is assigned to the file member)
- @param tag_entry Tag information gathered by the ctags parser
- @return TRUE on success, FALSE on failure
-*/
gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_entry);
-/*
- Initializes an already malloc()ed TMTag structure by reading a tag entry
- line from a file. The structure should be allocated beforehand.
- @param tag The TMTag structure to populate
- @param file The TMSourceFile struct (assigned to the file member)
- @param fp FILE pointer from where the tag line is read
- @return TRUE on success, FALSE on FAILURE
-*/
gboolean tm_tag_init_from_file(TMTag *tag, TMSourceFile *file, FILE *fp);
-/*
- Same as tm_tag_init_from_file(), but using an alternative parser for PHP and
- LaTeX global tags files.
-*/
gboolean tm_tag_init_from_file_alt(TMTag *tag, TMSourceFile *file, FILE *fp);
-/*
- Same as tm_tag_init_from_file(), but parsing CTags tag file format
-*/
gboolean tm_tag_init_from_file_ctags(TMTag *tag, TMSourceFile *file, FILE *fp);
-/*
- Creates a new tag structure from a tagEntryInfo pointer and a TMSOurceFile pointer
- and returns a pointer to it.
- @param file - Pointer to the TMSourceFile structure containing the tag
- @param tag_entry Contains tag information generated by ctags
- @return the new TMTag structure. This should be free()-ed using tm_tag_free()
-*/
TMTag *tm_tag_new(TMSourceFile *file, const tagEntryInfo *tag_entry);
-/*
- Same as tm_tag_new() except that the tag attributes are read from file.
- @param mode langType to use for the tag.
-*/
TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileFormat format);
-/*
- Writes tag information to the given FILE *.
- @param tag The tag information to write.
- @param file FILE pointer to which the tag information is written.
- @param attrs Attributes to be written (bitmask).
- @return TRUE on success, FALSE on failure.
-*/
gboolean tm_tag_write(TMTag *tag, FILE *file, guint attrs);
-/*
- Inbuilt tag comparison function. Do not call directly since it needs some
- static variables to be set. Always use tm_tags_sort() and tm_tags_dedup()
- instead.
-*/
int tm_tag_compare(const void *ptr1, const void *ptr2);
gboolean tm_tags_merge(GPtrArray *tags_array, gsize orig_len,
@@ -245,148 +196,41 @@ GPtrArray *tm_tags_remove_file_tags(TMSourceFile *source_file, GPtrArray *tags_a
GPtrArray *tm_tags_merge_big_small(GPtrArray *big_array, GPtrArray *small_array, TMTagAttrType *sort_attributes);
-/*
- Sort an array of tags on the specified attribuites using the inbuilt comparison
- function.
- @param tags_array The array of tags to be sorted
- @param sort_attributes Attributes to be sorted on (int array terminated by 0)
- @param dedup Whether to deduplicate the sorted array
- @return TRUE on success, FALSE on failure
-*/
gboolean tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean dedup);
-/*
- This function should be used whenever more involved sorting is required. For this,
- you need to write a function as per the prototype of TMTagCompareFunc() and pass
- the function as a parameter to this function.
- @param tags_array Array of tags to be sorted
- @param compare_func A function which takes two pointers to (TMTag *)s and returns
- 0, 1 or -1 depending on whether the first value is equal to, greater than or less that
- the second
- @param dedup Whether to deduplicate the sorted array. Note that the same comparison
- function will be used
- @return TRUE on success, FALSE on failure
-*/
gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_func, gboolean dedup);
-/*
- This function will extract the tags of the specified types from an array of tags.
- The returned value is a GPtrArray which should be free-d with a call to
- g_ptr_array_free(array, TRUE). However, do not free the tags themselves since they
- are not duplicated.
- @param tags_array The original array of tags
- @param tag_types - The tag types to extract. Can be a bitmask. For example, passing
- (tm_tag_typedef_t | tm_tag_struct_t) will extract all typedefs and structures from
- the original array.
- @return an array of tags (NULL on failure)
-*/
GPtrArray *tm_tags_extract(GPtrArray *tags_array, guint tag_types);
-/*
- Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() and
- tm_tags_custom_dedup() since these functions substitute duplicate entries with NULL
- @param tags_array Array of tags to dedup
- @return TRUE on success, FALSE on failure
-*/
gboolean tm_tags_prune(GPtrArray *tags_array);
-/*
- Deduplicates an array on tags using the inbuilt comparison function based on
- the attributes specified. Called by tm_tags_sort() when dedup is TRUE.
- @param tags_array Array of tags to dedup.
- @param sort_attributes Attributes the array is sorted on. They will be deduped
- on the same criteria.
- @return TRUE on success, FALSE on failure
-*/
gboolean tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes);
-/*
- This is a more powerful form of tm_tags_dedup() since it can accomodate user
- defined comparison functions. Called by tm_tags_custom_sort() is dedup is TRUE.
- @param tags_array Array of tags to dedup.
- @param compare_func Comparison function
- @return TRUE on success, FALSE on FAILURE
- @see TMTagCompareFunc
-*/
gboolean tm_tags_custom_dedup(GPtrArray *tags_array, TMTagCompareFunc compare_func);
-/*
- Returns a pointer to the position of the first matching tag in a (sorted) tags array.
- The passed array of tags should be already sorted by name for optimal performance. If
- \c tags_array_sorted is set to FALSE, it may be unsorted but the lookup will be slower.
- @param tags_array Tag array (may be sorted on name)
- @param name Name of the tag to locate.
- @param partial If TRUE, matches the first part of the name instead of doing exact match.
- @param tags_array_sorted If TRUE, the passed \c tags_array is sorted by name so it can be
- searched with binary search. Otherwise it is searched linear which is obviously slower.
- @param tagCount Return location of the matched tags.
-*/
TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
gboolean partial, gboolean tags_array_sorted, int * tagCount);
-/*
- Completely frees an array of tags.
- @param tags_array Array of tags to be freed.
- @param free_array Whether the GptrArray is to be freed as well.
-*/
void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all);
#if 0
-/*
- Destroys a TMTag structure, i.e. frees all elements except the tag itself.
- @param tag The TMTag structure to destroy
- @see tm_tag_free()
-*/
void tm_tag_destroy(TMTag *tag);
-/*
- Destroys all data in the tag and frees the tag structure as well.
- @param tag Pointer to a TMTag structure
-*/
void tm_tag_free(gpointer tag);
#endif
-/*
- Drops a reference from a TMTag. If the reference count reaches 0, this function
- destroys all data in the tag and frees the tag structure as well.
- @param tag Pointer to a TMTag structure
-*/
void tm_tag_unref(TMTag *tag);
-/*
- Adds a reference to a TMTag.
- @param tag Pointer to a TMTag structure
- @return the passed-in TMTag
-*/
TMTag *tm_tag_ref(TMTag *tag);
-/*
- Returns the type of tag as a string
- @param tag The tag whose type is required
-*/
const char *tm_tag_type_name(const TMTag *tag);
-/*
- Returns the TMTagType given the name of the type. Reverse of tm_tag_type_name.
- @param tag_name Name of the tag type
-*/
TMTagType tm_tag_name_type(const char* tag_name);
-/*
- Prints information about a tag to the given file pointer.
- @param tag The tag whose info is required.
- @param fp The file pointer of teh file to print the info to.
-*/
void tm_tag_print(TMTag *tag, FILE *fp);
-/*
- Prints info about all tags in the array to the given file pointer.
-*/
void tm_tags_array_print(GPtrArray *tags, FILE *fp);
-/*
- Returns the depth of tag scope (useful for finding tag hierarchy
-*/
gint tm_tag_scope_depth(const TMTag *t);
#endif /* GEANY_PRIVATE */
Modified: tagmanager/src/tm_workspace.c
80 lines changed, 79 insertions(+), 1 deletions(-)
===================================================================
@@ -47,6 +47,9 @@ static gboolean tm_create_workspace(void)
return TRUE;
}
+/* Frees the workspace structure and all child source files. Use only when
+ exiting from the main program.
+*/
void tm_workspace_free(void)
{
guint i;
@@ -76,6 +79,12 @@ void tm_workspace_free(void)
}
}
+/* Since TMWorkspace is a singleton, you should not create multiple
+ workspaces, but get a pointer to the workspace whenever required. The first
+ 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
+ created workspace.
+*/
const TMWorkspace *tm_get_workspace(void)
{
if (NULL == theWorkspace)
@@ -83,6 +92,10 @@ const TMWorkspace *tm_get_workspace(void)
return theWorkspace;
}
+/** Adds a source file 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).
+*/
gboolean tm_workspace_add_source_file(TMSourceFile *source_file)
{
/* theWorkspace should already have been created otherwise something went wrong */
@@ -94,6 +107,12 @@ gboolean tm_workspace_add_source_file(TMSourceFile *source_file)
return TRUE;
}
+/** Removes a member object from the workspace if it exists.
+ @param source_file Pointer to the source file to be removed.
+ @param do_free Whether the source file is to be freed as well.
+ @param update Whether to update workspace objects.
+ @return TRUE on success, FALSE on failure (e.g. the source file does not exist).
+*/
gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update)
{
guint i;
@@ -124,6 +143,12 @@ static TMTagAttrType global_tags_sort_attrs[] =
tm_tag_attr_type_t, tm_tag_attr_arglist_t, 0
};
+/* Loads the global tag list from the specified file. The global tag list should
+ have been first created using tm_workspace_create_global_tags().
+ @param tags_file The file containing global tags.
+ @return TRUE on success, FALSE on failure.
+ @see tm_workspace_create_global_tags()
+*/
gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode)
{
gsize orig_len;
@@ -265,6 +290,17 @@ static gchar *create_temp_file(const gchar *tpl)
return name;
}
+/* Creates a list of global tags. Ideally, this should be created once during
+ installations so that all users can use the same file. Thsi is because a full
+ scale global tag list can occupy several megabytes of disk space.
+ @param pre_process The pre-processing command. This is executed via system(),
+ so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
+ @param includes Include files to process. Wildcards such as '/usr/include/a*.h'
+ are allowed.
+ @param tags_file The file where the tags will be stored.
+ @param lang The language to use for the tags file.
+ @return TRUE on success, FALSE on failure.
+*/
gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
int includes_count, const char *tags_file, int lang)
{
@@ -447,6 +483,10 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
return TRUE;
}
+/* Recreates the tag array of the workspace by collecting the tags of
+ all member source files. You shouldn't have to call this directly since
+ this is called automatically by tm_workspace_update().
+*/
void tm_workspace_recreate_tags_array(void)
{
guint i, j;
@@ -513,6 +553,9 @@ void tm_workspace_merge_file_tags(TMSourceFile *source_file)
}
}
+/** Calls tm_source_file_update() for all workspace member source files and creates
+ workspace tag array. Use if you want to globally refresh the workspace.
+*/
void tm_workspace_update(void)
{
#ifdef TM_DEBUG
@@ -524,6 +567,7 @@ void tm_workspace_update(void)
tm_workspace_recreate_tags_array();
}
+/* Dumps the workspace tree - useful for debugging */
void tm_workspace_dump(void)
{
if (theWorkspace)
@@ -543,6 +587,15 @@ void tm_workspace_dump(void)
}
}
+/* Returns all matching tags found in the workspace.
+ @param name The name of the tag to find.
+ @param type The tag types to return (TMTagType). Can be a bitmask.
+ @param attrs The attributes to sort and dedup on (0 terminated integer array).
+ @param partial Whether partial match is allowed.
+ @param lang Specifies the language(see the table in parsers.h) of the tags to be found,
+ -1 for all
+ @return Array of matching tags. Do not free() it since it is a static member.
+*/
const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *attrs
, gboolean partial, langType lang)
{
@@ -680,7 +733,16 @@ fill_find_tags_array (GPtrArray *dst, const GPtrArray *src,
}
-/* adapted from tm_workspace_find, Anjuta 2.02 */
+/* Returns all matching tags found in the workspace. Adapted from tm_workspace_find, Anjuta 2.02
+ @param name The name of the tag to find.
+ @param scope The scope name of the tag to find, or NULL.
+ @param type The tag types to return (TMTagType). Can be a bitmask.
+ @param attrs The attributes to sort and dedup on (0 terminated integer array).
+ @param partial Whether partial match is allowed.
+ @param lang Specifies the language(see the table in parsers.h) of the tags to be found,
+ -1 for all
+ @return Array of matching tags. Do not free() it since it is a static member.
+*/
const GPtrArray *
tm_workspace_find_scoped (const char *name, const char *scope, gint type,
TMTagAttrType *attrs, gboolean partial, langType lang, gboolean global_search)
@@ -709,6 +771,11 @@ tm_workspace_find_scoped (const char *name, const char *scope, gint type,
}
+/* Returns TMTag which "own" given line
+ @param line Current line in edited file.
+ @param file_tags A GPtrArray of edited file TMTag pointers.
+ @param tag_types the tag types to include in the match
+ @return TMTag pointers to owner tag. */
const TMTag *
tm_get_current_tag (GPtrArray * file_tags, const gulong line, const guint tag_types)
{
@@ -733,6 +800,10 @@ tm_get_current_tag (GPtrArray * file_tags, const gulong line, const guint tag_ty
}
+/* Returns TMTag to function or method which "own" given line
+ @param line Current line in edited file.
+ @param file_tags A GPtrArray of edited file TMTag pointers.
+ @return TMTag pointers to owner function. */
const TMTag *
tm_get_current_function (GPtrArray * file_tags, const gulong line)
{
@@ -1059,6 +1130,10 @@ tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *na
}
#endif
+/* Returns all matching members tags found in given struct/union/class name.
+ @param name Name of the struct/union/class.
+ @param file_tags A GPtrArray of edited file TMTag pointers (for search speedup, can be NULL).
+ @return A GPtrArray of TMTag pointers to struct/union/class members */
const GPtrArray *
tm_workspace_find_scope_members (const GPtrArray * file_tags, const char *name,
gboolean search_global, gboolean no_definitions)
@@ -1195,6 +1270,9 @@ tm_workspace_find_scope_members (const GPtrArray * file_tags, const char *name,
return tags;
}
+/* Returns a list of parent classes for the given class name
+ @param name Name of the class
+ @return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
const GPtrArray *tm_workspace_get_parents(const gchar *name)
{
static TMTagAttrType type[] = { tm_tag_attr_name_t, tm_tag_attr_none_t };
Modified: tagmanager/src/tm_workspace.h
83 lines changed, 1 insertions(+), 82 deletions(-)
===================================================================
@@ -34,99 +34,33 @@ typedef struct
(just pointers to source file tags, the tag objects are owned by the source files) */
} TMWorkspace;
-/** Adds a source file 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).
-*/
gboolean tm_workspace_add_source_file(TMSourceFile *source_file);
-/** Removes a member object from the workspace if it exists.
- @param source_file Pointer to the source file to be removed.
- @param do_free Whether the source file is to be freed as well.
- @param update Whether to update workspace objects.
- @return TRUE on success, FALSE on failure (e.g. the source file does not exist).
-*/
gboolean tm_workspace_remove_source_file(TMSourceFile *source_file, gboolean do_free, gboolean update);
-/** Calls tm_source_file_update() for all workspace member source files and creates
- workspace tag array. Use if you want to globally refresh the workspace.
-*/
void tm_workspace_update(void);
#ifdef GEANY_PRIVATE
-/* Since TMWorkspace is a singleton, you should not create multiple
- workspaces, but get a pointer to the workspace whenever required. The first
- 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
- created workspace.
-*/
const TMWorkspace *tm_get_workspace(void);
-
-/* Loads the global tag list from the specified file. The global tag list should
- have been first created using tm_workspace_create_global_tags().
- @param tags_file The file containing global tags.
- @return TRUE on success, FALSE on failure.
- @see tm_workspace_create_global_tags()
-*/
gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode);
-/*gboolean tm_workspace_load_global_tags(const char *tags_file);*/
-
-/* Creates a list of global tags. Ideally, this should be created once during
- installations so that all users can use the same file. Thsi is because a full
- scale global tag list can occupy several megabytes of disk space.
- @param pre_process The pre-processing command. This is executed via system(),
- so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
- @param includes Include files to process. Wildcards such as '/usr/include/a*.h'
- are allowed.
- @param tags_file The file where the tags will be stored.
- @param lang The language to use for the tags file.
- @return TRUE on success, FALSE on failure.
-*/
+
gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
int includes_count, const char *tags_file, int lang);
-/* Recreates the tag array of the workspace by collecting the tags of
- all member source files. You shouldn't have to call this directly since
- this is called automatically by tm_workspace_update().
-*/
void tm_workspace_recreate_tags_array(void);
-/* Dumps the workspace tree - useful for debugging */
void tm_workspace_dump(void);
-/* Returns all matching tags found in the workspace.
- @param name The name of the tag to find.
- @param type The tag types to return (TMTagType). Can be a bitmask.
- @param attrs The attributes to sort and dedup on (0 terminated integer array).
- @param partial Whether partial match is allowed.
- @param lang Specifies the language(see the table in parsers.h) of the tags to be found,
- -1 for all
- @return Array of matching tags. Do not free() it since it is a static member.
-*/
const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *attrs
, gboolean partial, langType lang);
-/* Returns all matching tags found in the workspace.
- @param name The name of the tag to find.
- @param scope The scope name of the tag to find, or NULL.
- @param type The tag types to return (TMTagType). Can be a bitmask.
- @param attrs The attributes to sort and dedup on (0 terminated integer array).
- @param partial Whether partial match is allowed.
- @param lang Specifies the language(see the table in parsers.h) of the tags to be found,
- -1 for all
- @return Array of matching tags. Do not free() it since it is a static member.
-*/
const GPtrArray *
tm_workspace_find_scoped (const char *name, const char *scope, gint type,
TMTagAttrType *attrs, gboolean partial, langType lang, gboolean global_search);
-/* Returns all matching members tags found in given struct/union/class name.
- @param name Name of the struct/union/class.
- @param file_tags A GPtrArray of edited file TMTag pointers (for search speedup, can be NULL).
- @return A GPtrArray of TMTag pointers to struct/union/class members */
const GPtrArray *tm_workspace_find_scope_members(const GPtrArray *file_tags,
const char *scope_name,
gboolean find_global,
@@ -136,27 +70,12 @@ const GPtrArray *
tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *name,
gboolean search_global);
-/* Returns TMTag which "own" given line
- @param line Current line in edited file.
- @param file_tags A GPtrArray of edited file TMTag pointers.
- @param tag_types the tag types to include in the match
- @return TMTag pointers to owner tag. */
const TMTag *tm_get_current_tag(GPtrArray *file_tags, const gulong line, const guint tag_types);
-/* Returns TMTag to function or method which "own" given line
- @param line Current line in edited file.
- @param file_tags A GPtrArray of edited file TMTag pointers.
- @return TMTag pointers to owner function. */
const TMTag *tm_get_current_function(GPtrArray *file_tags, const gulong line);
-/* Returns a list of parent classes for the given class name
- @param name Name of the class
- @return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
const GPtrArray *tm_workspace_get_parents(const gchar *name);
-/* Frees the workspace structure and all child source files. Use only when
- exiting from the main program.
-*/
void tm_workspace_free(void);
void tm_workspace_merge_file_tags(TMSourceFile *source_file);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 18 Oct 2014 19:40:10 UTC
Commit: 034ef6d79de3bf61907894674cc8efadfadd5bde
https://github.com/geany/geany/commit/034ef6d79de3bf61907894674cc8efadfadd5…
Log Message:
-----------
Remove the unused (and misleading) tm_tag_free()
It just calls unref() which might not actually free the tag if the refnum
is more than 1.
Modified Paths:
--------------
tagmanager/src/tm_tag.c
tagmanager/src/tm_tag.h
Modified: tagmanager/src/tm_tag.c
10 lines changed, 0 insertions(+), 10 deletions(-)
===================================================================
@@ -676,16 +676,6 @@ static void tm_tag_destroy(TMTag *tag)
}
}
-#if 0
-/*
- Destroys all data in the tag and frees the tag structure as well.
- @param tag Pointer to a TMTag structure
-*/
-void tm_tag_free(gpointer tag)
-{
- tm_tag_unref(tag);
-}
-#endif
/*
Drops a reference from a TMTag. If the reference count reaches 0, this function
Modified: tagmanager/src/tm_tag.h
6 lines changed, 0 insertions(+), 6 deletions(-)
===================================================================
@@ -198,12 +198,6 @@ TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all);
-#if 0
-void tm_tag_destroy(TMTag *tag);
-
-void tm_tag_free(gpointer tag);
-#endif
-
void tm_tag_unref(TMTag *tag);
TMTag *tm_tag_ref(TMTag *tag);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 18 Oct 2014 19:40:10 UTC
Commit: 2c09333b6a3deb4f38a0b70888122829cc6e3818
https://github.com/geany/geany/commit/2c09333b6a3deb4f38a0b70888122829cc6e3…
Log Message:
-----------
Remove unused tm_tags_custom_sort() and tm_tags_custom_dedup() and friends
Modified Paths:
--------------
tagmanager/src/tm_tag.c
tagmanager/src/tm_tag.h
Modified: tagmanager/src/tm_tag.c
49 lines changed, 2 insertions(+), 47 deletions(-)
===================================================================
@@ -785,8 +785,8 @@ int tm_tag_compare(const void *ptr1, const void *ptr2)
}
/*
- Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() and
- tm_tags_custom_dedup() since these functions substitute duplicate entries with NULL
+ Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() since
+ this function substitutes duplicate entries with NULL
@param tags_array Array of tags to dedup
@return TRUE on success, FALSE on failure
*/
@@ -830,29 +830,6 @@ gboolean tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes)
}
/*
- This is a more powerful form of tm_tags_dedup() since it can accomodate user
- defined comparison functions. Called by tm_tags_custom_sort() is dedup is TRUE.
- @param tags_array Array of tags to dedup.
- @param compare_func Comparison function
- @return TRUE on success, FALSE on FAILURE
- @see TMTagCompareFunc
-*/
-gboolean tm_tags_custom_dedup(GPtrArray *tags_array, TMTagCompareFunc compare_func)
-{
- guint i;
-
- if ((!tags_array) || (!tags_array->len))
- return TRUE;
- for (i = 1; i < tags_array->len; ++i)
- {
- if (0 == compare_func(&(tags_array->pdata[i - 1]), &(tags_array->pdata[i])))
- tags_array->pdata[i-1] = NULL;
- }
- tm_tags_prune(tags_array);
- return TRUE;
-}
-
-/*
Sort an array of tags on the specified attribuites using the inbuilt comparison
function.
@param tags_array The array of tags to be sorted
@@ -999,28 +976,6 @@ GPtrArray *tm_tags_merge(GPtrArray *big_array, GPtrArray *small_array, TMTagAttr
}
/*
- This function should be used whenever more involved sorting is required. For this,
- you need to write a function as per the prototype of TMTagCompareFunc() and pass
- the function as a parameter to this function.
- @param tags_array Array of tags to be sorted
- @param compare_func A function which takes two pointers to (TMTag *)s and returns
- 0, 1 or -1 depending on whether the first value is equal to, greater than or less that
- the second
- @param dedup Whether to deduplicate the sorted array. Note that the same comparison
- function will be used
- @return TRUE on success, FALSE on failure
-*/
-gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_func, gboolean dedup)
-{
- if ((!tags_array) || (!tags_array->len))
- return TRUE;
- qsort(tags_array->pdata, tags_array->len, sizeof(gpointer), compare_func);
- if (dedup)
- tm_tags_custom_dedup(tags_array, compare_func);
- return TRUE;
-}
-
-/*
This function will extract the tags of the specified types from an array of tags.
The returned value is a GPtrArray which should be free-d with a call to
g_ptr_array_free(array, TRUE). However, do not free the tags themselves since they
Modified: tagmanager/src/tm_tag.h
18 lines changed, 3 insertions(+), 15 deletions(-)
===================================================================
@@ -17,8 +17,8 @@
an array of tags for the given source file. Once the tag list is generated,
you can do various operations such as:
-# Extract relevant tags using tm_tags_extract()
- -# Sort an array of tags using tm_tags_sort() or tm_tags_custom_sort()
- -# Deduplicate an array of tags using tm_tags_dedup() or tm_tags_dedup_custom().
+ -# Sort an array of tags using tm_tags_sort()
+ -# Deduplicate an array of tags using tm_tags_dedup().
An important thing to remember here is that the tags operations such as extraction,
sorting and deduplication do not change the tag itself in any way, but rather,
@@ -118,7 +118,7 @@ typedef enum
pseudo tag. It should always be created indirectly with one of the tag
creation functions such as tm_source_file_parse() or tm_tag_new_from_file().
Once created, they can be sorted, deduped, etc. using functions such as
- tm_tags_custom_sort(), tm_tags_sort(), tm_tags_dedup() and tm_tags_custom_dedup()
+ tm_tags_sort() or tm_tags_dedup()
*/
typedef struct _TMTag
{
@@ -159,14 +159,6 @@ typedef enum {
TM_FILE_FORMAT_CTAGS
} TMFileFormat;
-/*
- Prototype for user-defined tag comparison function. This is the type
- of argument that needs to be passed to tm_tags_sort_custom() and
- tm_tags_dedup_custom(). The function should take two void pointers,
- cast them to (TMTag **) and return 0, 1 or -1 depending on whether the
- first tag is equal to, greater than or less than the second tag.
-*/
-typedef int (*TMTagCompareFunc) (const void *ptr1, const void *ptr2);
/* The GType for a TMTag */
#define TM_TYPE_TAG (tm_tag_get_type())
@@ -195,16 +187,12 @@ GPtrArray *tm_tags_merge(GPtrArray *big_array, GPtrArray *small_array, TMTagAttr
gboolean tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean dedup);
-gboolean tm_tags_custom_sort(GPtrArray *tags_array, TMTagCompareFunc compare_func, gboolean dedup);
-
GPtrArray *tm_tags_extract(GPtrArray *tags_array, guint tag_types);
gboolean tm_tags_prune(GPtrArray *tags_array);
gboolean tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes);
-gboolean tm_tags_custom_dedup(GPtrArray *tags_array, TMTagCompareFunc compare_func);
-
TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
gboolean partial, gboolean tags_array_sorted, int * tagCount);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 18 Oct 2014 19:40:10 UTC
Commit: 26587454b043971d3f1557a5bace257a51125eba
https://github.com/geany/geany/commit/26587454b043971d3f1557a5bace257a51125…
Log Message:
-----------
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.
Modified Paths:
--------------
doc/Doxyfile.in
doc/Makefile.am
plugins/geanyfunctions.h
src/dialogs.c
src/document.c
src/document.h
src/editor.c
src/main.c
src/plugindata.h
src/plugins.c
src/symbols.c
tagmanager/src/Makefile.am
tagmanager/src/makefile.win32
tagmanager/src/tm_file_entry.c
tagmanager/src/tm_source_file.c
tagmanager/src/tm_source_file.h
tagmanager/src/tm_tag.c
tagmanager/src/tm_tagmanager.h
tagmanager/src/tm_work_object.c
tagmanager/src/tm_work_object.h
tagmanager/src/tm_workspace.c
tagmanager/src/tm_workspace.h
wscript
Modified: doc/Doxyfile.in
2 lines changed, 0 insertions(+), 2 deletions(-)
===================================================================
@@ -778,8 +778,6 @@ INPUT = @top_srcdir@/src/ \
@top_srcdir@/plugins/geanyfunctions.h \
@top_srcdir@/tagmanager/src/tm_source_file.c \
@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.h
Modified: doc/Makefile.am
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -98,7 +98,6 @@ doxygen_sources = \
$(top_srcdir)/plugins/geanyplugin.h \
$(top_srcdir)/plugins/geanyfunctions.h \
$(top_srcdir)/tagmanager/src/tm_source_file.[ch] \
- $(top_srcdir)/tagmanager/src/tm_work_object.[ch] \
$(top_srcdir)/tagmanager/src/tm_workspace.[ch]
Doxyfile.stamp: Doxyfile $(doxygen_sources)
Modified: plugins/geanyfunctions.h
12 lines changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -346,14 +346,14 @@
geany_functions->p_tm->tm_get_real_path
#define tm_source_file_new \
geany_functions->p_tm->tm_source_file_new
-#define tm_workspace_add_object \
- geany_functions->p_tm->tm_workspace_add_object
+#define tm_workspace_add_source_file \
+ geany_functions->p_tm->tm_workspace_add_source_file
#define tm_source_file_update \
geany_functions->p_tm->tm_source_file_update
-#define tm_work_object_free \
- geany_functions->p_tm->tm_work_object_free
-#define tm_workspace_remove_object \
- geany_functions->p_tm->tm_workspace_remove_object
+#define tm_source_file_free \
+ geany_functions->p_tm->tm_source_file_free
+#define tm_workspace_remove_source_file \
+ geany_functions->p_tm->tm_workspace_remove_source_file
#define search_show_find_in_files_dialog \
geany_functions->p_search->search_show_find_in_files_dialog
#define highlighting_get_style \
Modified: src/dialogs.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -502,7 +502,7 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
document_rename_file(doc, utf8_filename);
}
/* 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;
}
success = document_save_file_as(doc, utf8_filename);
Modified: src/document.c
16 lines changed, 8 insertions(+), 8 deletions(-)
===================================================================
@@ -140,7 +140,7 @@ static GtkWidget* document_show_message(GeanyDocument *doc, GtkMessageType msgty
* string returned by @c tm_get_real_path().
*
* @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 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->file_name);
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)
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);
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;
}
}
- /* 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)
{
/* We must call sidebar_update_tag_list() before returning,
@@ -2555,12 +2555,12 @@ void document_highlight_tags(GeanyDocument *doc)
default:
return; /* early out if type keywords are not supported */
}
- if (!app->tm_workspace->work_object.tags_array)
+ if (!app->tm_workspace->tags_array)
return;
/* get any type keywords and tell scintilla about them
* 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);
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 */
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;
}
/* load tags files before highlighting (some lexers highlight global typenames) */
Modified: src/document.h
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -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
* filetypes array. */
GeanyFiletype *file_type;
- /** TMWorkObject object for this document, or @c NULL. */
- TMWorkObject *tm_file;
+ /** TMSourceFile object for this document, or @c NULL. */
+ TMSourceFile *tm_file;
/** Whether this document is read-only. */
gboolean readonly;
/** Whether this document has been changed since it was last saved. */
Modified: src/editor.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -735,7 +735,7 @@ static void autocomplete_scope(GeanyEditor *editor)
name = tag->atts.entry.var_type;
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,
name, TRUE, FALSE);
Modified: src/main.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1289,7 +1289,7 @@ static void do_main_quit(void)
filetypes_free_types();
log_finalize();
- tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));
+ tm_workspace_free();
g_free(app->configdir);
g_free(app->datadir);
g_free(app->docdir);
Modified: src/plugindata.h
11 lines changed, 5 insertions(+), 6 deletions(-)
===================================================================
@@ -599,12 +599,11 @@ SearchFuncs;
typedef struct TagManagerFuncs
{
gchar* (*tm_get_real_path) (const gchar *file_name);
- TMWorkObject* (*tm_source_file_new) (const char *file_name, gboolean update, const char *name);
- gboolean (*tm_workspace_add_object) (TMWorkObject *work_object);
- gboolean (*tm_source_file_update) (TMWorkObject *source_file, gboolean force,
- gboolean recurse, gboolean update_parent);
- void (*tm_work_object_free) (gpointer work_object);
- gboolean (*tm_workspace_remove_object) (TMWorkObject *w, gboolean do_free, gboolean update);
+ TMSourceFile* (*tm_source_file_new) (const char *file_name, gboolean update, const char *name);
+ gboolean (*tm_workspace_add_source_file) (TMSourceFile *source_file);
+ void (*tm_source_file_update) (TMSourceFile *source_file, gboolean update_workspace);
+ void (*tm_source_file_free) (TMSourceFile *source_file);
+ gboolean (*tm_workspace_remove_source_file) (TMSourceFile *source_file, gboolean do_free, gboolean update);
}
TagManagerFuncs;
Modified: src/plugins.c
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -290,10 +290,10 @@ static KeybindingFuncs keybindings_funcs = {
static TagManagerFuncs tagmanager_funcs = {
&tm_get_real_path,
&tm_source_file_new,
- &tm_workspace_add_object,
+ &tm_workspace_add_source_file,
&tm_source_file_update,
- &tm_work_object_free,
- &tm_workspace_remove_object
+ &tm_source_file_free,
+ &tm_workspace_remove_source_file
};
static SearchFuncs search_funcs = {
Modified: src/symbols.c
41 lines changed, 19 insertions(+), 22 deletions(-)
===================================================================
@@ -333,17 +333,17 @@ GString *symbols_get_macro_list(gint lang)
gint tag_lang;
TMTag *tag;
- if (app->tm_workspace->work_objects == NULL)
+ if (app->tm_workspace->source_files == NULL)
return NULL;
ftags = g_ptr_array_sized_new(50);
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;
- 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);
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)
{
GPtrArray *tags;
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);
- if (tags != NULL)
- {
- tmtag = symbols_find_tm_tag(tags, tag_name);
+ tmtag = symbols_find_tm_tag(tags, tag_name);
- g_ptr_array_free(tags, TRUE);
+ g_ptr_array_free(tags, TRUE);
- if (tmtag != NULL)
- return tmtag;
- }
+ if (tmtag != NULL)
+ return tmtag;
}
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)
{
guint j;
- const GPtrArray *work_objects = NULL;
+ const GPtrArray *source_files = 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 = find_work_object_tag(workobj, tag_name, type);
+ tmtag = find_source_file_tag(srcfile->tags_array, tag_name, type);
if (tmtag != NULL)
return tmtag;
}
@@ -1941,7 +1938,7 @@ static gboolean goto_tag(const gchar *name, gboolean definition)
/* first look in the current document */
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 (tmtag == NULL)
@@ -1950,7 +1947,7 @@ static gboolean goto_tag(const gchar *name, gboolean definition)
if (tmtag != NULL)
{
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)
{
@@ -1965,7 +1962,7 @@ static gboolean goto_tag(const gchar *name, gboolean definition)
else
{
/* 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))
Modified: tagmanager/src/Makefile.am
3 lines changed, 0 insertions(+), 3 deletions(-)
===================================================================
@@ -17,7 +17,6 @@ tagmanager_include_HEADERS = \
tm_source_file.h \
tm_tag.h \
tm_tagmanager.h \
- tm_work_object.h \
tm_workspace.h
@@ -30,7 +29,5 @@ libtagmanager_a_SOURCES =\
tm_source_file.c \
tm_tag.h \
tm_tag.c \
- tm_work_object.c \
- tm_work_object.h \
tm_workspace.h \
tm_workspace.c
Modified: tagmanager/src/makefile.win32
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -44,7 +44,7 @@ all: $(COMPLIB)
clean:
-$(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
$(AR) rc $@ $^
$(RANLIB) $@
Modified: tagmanager/src/tm_file_entry.c
3 lines changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -24,9 +24,8 @@
#endif
#include <glib/gstdio.h>
-#include "tm_work_object.h"
#include "tm_file_entry.h"
-
+#include "tm_source_file.h"
#define FILE_NEW(T) ((T) = g_slice_new0(TMFileEntry))
#define FILE_FREE(T) g_slice_free(TMFileEntry, (T))
Modified: tagmanager/src/tm_source_file.c
195 lines changed, 136 insertions(+), 59 deletions(-)
===================================================================
@@ -18,35 +18,114 @@
#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 "general.h"
#include "entry.h"
#include "parse.h"
#include "read.h"
#define LIBCTAGS_DEFINED
-#include "tm_work_object.h"
+#include "tm_workspace.h"
#include "tm_source_file.h"
#include "tm_tag.h"
-guint source_file_class_id = 0;
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 update, const char* name)
{
- if (0 == source_file_class_id)
- source_file_class_id = tm_work_object_register(tm_source_file_free
- , tm_source_file_update, NULL);
+ struct stat s;
+ int status;
#ifdef TM_DEBUG
g_message("Source File init: %s", file_name);
#endif
- if (FALSE == tm_work_object_init(&(source_file->work_object),
- source_file_class_id, file_name, FALSE))
- return FALSE;
+ if (file_name != NULL)
+ {
+ 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;
if (NULL == LanguageTable)
@@ -65,11 +144,11 @@ gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
source_file->lang = getNamedLanguage(name);
if (update)
- tm_source_file_update(TM_WORK_OBJECT(source_file), TRUE, FALSE, FALSE);
+ tm_source_file_update(source_file, FALSE);
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);
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);
return NULL;
}
- return (TMWorkObject *) source_file;
+ return source_file;
}
void tm_source_file_destroy(TMSourceFile *source_file)
{
#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
- 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_WORK_OBJECT(source_file)->tags_array = NULL;
+ tm_tags_array_free(source_file->tags_array, TRUE);
+ 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)
{
@@ -109,13 +188,13 @@ gboolean tm_source_file_parse(TMSourceFile *source_file)
gboolean status = TRUE;
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");
return FALSE;
}
- file_name = source_file->work_object.file_name;
+ file_name = source_file->file_name;
if (NULL == LanguageTable)
{
initializeParsing();
@@ -135,8 +214,8 @@ gboolean tm_source_file_parse(TMSourceFile *source_file)
while ((TRUE == status) && (passCount < 3))
{
- if (source_file->work_object.tags_array)
- tm_tags_array_free(source_file->work_object.tags_array, FALSE);
+ if (source_file->tags_array)
+ tm_tags_array_free(source_file->tags_array, FALSE);
if (fileOpen (file_name, source_file->lang))
{
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;
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");
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");
}
- file_name = source_file->work_object.file_name;
+ file_name = source_file->file_name;
if (NULL == LanguageTable)
{
initializeParsing();
@@ -205,8 +284,8 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf
int passCount = 0;
while ((TRUE == status) && (passCount < 3))
{
- if (source_file->work_object.tags_array)
- tm_tags_array_free(source_file->work_object.tags_array, FALSE);
+ if (source_file->tags_array)
+ tm_tags_array_free(source_file->tags_array, FALSE);
if (bufferOpen (text_buf, buf_size, file_name, source_file->lang))
{
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 ||
NULL == tag_name ||
NULL == current_source_file ||
- NULL == current_source_file->work_object.tags_array)
+ NULL == current_source_file->tags_array)
{
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);
if (tags != NULL && count == 1)
{
@@ -258,71 +337,70 @@ int tm_source_file_tags(const tagEntryInfo *tag)
{
if (NULL == current_source_file)
return 0;
- if (NULL == current_source_file->work_object.tags_array)
- current_source_file->work_object.tags_array = g_ptr_array_new();
- g_ptr_array_add(current_source_file->work_object.tags_array,
+ if (NULL == current_source_file->tags_array)
+ current_source_file->tags_array = g_ptr_array_new();
+ g_ptr_array_add(current_source_file->tags_array,
tm_tag_new(current_source_file, tag));
return TRUE;
}
-gboolean tm_source_file_update(TMWorkObject *source_file, gboolean force
- , gboolean UNUSED recurse, gboolean update_parent)
+void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace)
{
- if (force)
+#ifdef TM_DEBUG
+ g_message("Source file updating based on source file %s", source_file->file_name);
+#endif
+
+ tm_source_file_parse(source_file);
+ tm_tags_sort(source_file->tags_array, NULL, FALSE);
+ if (update_workspace)
{
- 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);
+#ifdef TM_DEBUG
+ g_message("Updating workspace from source file");
#endif
- return FALSE;
+ 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,
- gint buf_size, gboolean update_parent)
+void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
+ gint buf_size, gboolean update_workspace)
{
#ifdef TM_DEBUG
g_message("Buffer updating based on source file %s", source_file->file_name);
#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);
- /* source_file->analyze_time = time(NULL); */
- if ((source_file->parent) && update_parent)
+ if (update_workspace)
{
#ifdef TM_DEBUG
- g_message("Updating parent from buffer..");
+ g_message("Updating workspace from buffer..");
#endif
- tm_work_object_update(source_file->parent, TRUE, FALSE, TRUE);
+ tm_workspace_update();
}
#ifdef TM_DEBUG
else
- g_message("Skipping parent update because parent is %s and update_parent is %s"
- , source_file->parent?"NOT NULL":"NULL", update_parent?"TRUE":"FALSE");
+ g_message("Skipping workspace update because update_workspace is %s"
+ , update_workspace?"TRUE":"FALSE");
#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;
guint i;
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_unref(tag);
@@ -367,4 +445,3 @@ gint tm_source_file_get_named_lang(const gchar *name)
}
return getNamedLanguage(name);
}
-
Modified: tagmanager/src/tm_source_file.h
61 lines changed, 29 insertions(+), 32 deletions(-)
===================================================================
@@ -10,8 +10,8 @@
#ifndef TM_SOURCE_FILE_H
#define TM_SOURCE_FILE_H
-#include "tm_work_object.h"
-
+#include <stdio.h>
+#include <glib.h>
#ifndef LIBCTAGS_DEFINED
typedef int langType;
@@ -27,21 +27,22 @@ extern "C"
#endif
/* 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
- attributes, plus an integer representing the language of the file.
+ The TMSourceFile structure represents the source file and its tags in the tag manager.
*/
typedef struct
{
- TMWorkObject work_object; /*!< The base work object */
langType lang; /*!< Programming language used */
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;
/*! 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.
* \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
- than the timestamp in the structure, or if force is TRUE. The tags array and
+/*! Updates the source file by reparsing. The tags array and
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
also lost. The language parameter is automatically set the first time the file
is parsed.
\param source_file The source file to update.
- \param force Ignored. The source file is always updated.
- \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
+ \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.
- \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
- , gboolean recurse, gboolean update_parent);
+void tm_source_file_update(TMSourceFile *source_file, gboolean update_workspace);
+
+/*! 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
@@ -82,9 +88,6 @@ gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name,
*/
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.
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
@@ -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
the use here.
\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.
\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,
- gint buf_size, gboolean update_parent);
+void tm_source_file_buffer_update(TMSourceFile *source_file, guchar* text_buf,
+ gint buf_size, gboolean update_workspace);
/* Parses the source file and regenarates the tags.
\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.
\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.
\param lang The language index.
Modified: tagmanager/src/tm_tag.c
5 lines changed, 2 insertions(+), 3 deletions(-)
===================================================================
@@ -218,9 +218,8 @@ gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_ent
return FALSE;
else
{
- tag->name = g_strdup(file->work_object.file_name);
+ tag->name = g_strdup(file->file_name);
tag->type = tm_tag_file_t;
- /* tag->atts.file.timestamp = file->work_object.analyze_time; */
tag->atts.file.lang = file->lang;
tag->atts.file.inactive = FALSE;
return TRUE;
@@ -1053,7 +1052,7 @@ void tm_tag_print(TMTag *tag, FILE *fp)
if (tag->atts.entry.inheritance)
fprintf(fp, " : from %s", tag->atts.entry.inheritance);
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);
fprintf(fp, "\n");
}
Modified: tagmanager/src/tm_tagmanager.h
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -12,7 +12,6 @@
#include "tm_tag.h"
#include "tm_workspace.h"
-#include "tm_work_object.h"
#include "tm_source_file.h"
#ifdef GEANY_PRIVATE
#include "tm_file_entry.h"
Modified: tagmanager/src/tm_work_object.c
298 lines changed, 0 insertions(+), 298 deletions(-)
===================================================================
@@ -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");
- }
-}
Modified: tagmanager/src/tm_work_object.h
191 lines changed, 0 insertions(+), 191 deletions(-)
===================================================================
@@ -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 */
Modified: tagmanager/src/tm_workspace.c
157 lines changed, 52 insertions(+), 105 deletions(-)
===================================================================
@@ -13,10 +13,9 @@
wide tag information.
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
- and a place to store all current open files. TMWorkspace
- is derived from TMWorkObject.
+ and a place to store all current open files.
*/
#include "general.h"
@@ -33,50 +32,36 @@
#endif
#include <glib/gstdio.h>
-#include "tm_tag.h"
#include "tm_workspace.h"
static TMWorkspace *theWorkspace = NULL;
-guint workspace_class_id = 0;
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);
- if (FALSE == tm_work_object_init(TM_WORK_OBJECT(theWorkspace),
- workspace_class_id, NULL, TRUE))
- {
- g_free(theWorkspace);
- theWorkspace = NULL;
- g_warning("Failed to initialize workspace");
- return FALSE;
- }
+ theWorkspace->tags_array = NULL;
theWorkspace->global_tags = NULL;
- theWorkspace->work_objects = NULL;
+ theWorkspace->source_files = NULL;
return TRUE;
}
-void tm_workspace_free(gpointer workspace)
+void tm_workspace_free(void)
{
guint i;
- if (workspace != theWorkspace)
- return;
-
#ifdef TM_DEBUG
g_message("Workspace destroyed");
#endif
if (theWorkspace)
{
- if (theWorkspace->work_objects)
+ if (theWorkspace->source_files)
{
- for (i=0; i < theWorkspace->work_objects->len; ++i)
- tm_work_object_free(theWorkspace->work_objects->pdata[i]);
- g_ptr_array_free(theWorkspace->work_objects, TRUE);
+ for (i=0; i < theWorkspace->source_files->len; ++i)
+ tm_source_file_free(theWorkspace->source_files->pdata[i]);
+ g_ptr_array_free(theWorkspace->source_files, TRUE);
}
if (theWorkspace->global_tags)
{
@@ -84,7 +69,8 @@ void tm_workspace_free(gpointer workspace)
tm_tag_unref(theWorkspace->global_tags->pdata[i]);
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);
theWorkspace = NULL;
}
@@ -97,35 +83,34 @@ const TMWorkspace *tm_get_workspace(void)
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 */
if (NULL == theWorkspace)
return FALSE;
- if (NULL == theWorkspace->work_objects)
- theWorkspace->work_objects = g_ptr_array_new();
- g_ptr_array_add(theWorkspace->work_objects, work_object);
- work_object->parent = TM_WORK_OBJECT(theWorkspace);
+ if (NULL == theWorkspace->source_files)
+ theWorkspace->source_files = g_ptr_array_new();
+ g_ptr_array_add(theWorkspace->source_files, source_file);
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;
- if ((NULL == theWorkspace) || (NULL == theWorkspace->work_objects)
- || (NULL == w))
+ if ((NULL == theWorkspace) || (NULL == theWorkspace->source_files)
+ || (NULL == source_file))
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)
- tm_work_object_free(w);
- g_ptr_array_remove_index_fast(theWorkspace->work_objects, i);
+ tm_source_file_free(source_file);
+ g_ptr_array_remove_index_fast(theWorkspace->source_files, i);
if (update)
- tm_workspace_update(TM_WORK_OBJECT(theWorkspace), TRUE, FALSE, FALSE);
+ tm_workspace_update();
return TRUE;
}
}
@@ -291,7 +276,7 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
char *command;
guint i;
FILE *fp;
- TMWorkObject *source_file;
+ TMSourceFile *source_file;
GPtrArray *tags_array;
GHashTable *includes_files_hash;
GList *includes_files = NULL;
@@ -462,30 +447,10 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
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)
{
guint i, j;
- TMWorkObject *w;
+ TMSourceFile *w;
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};
@@ -493,19 +458,19 @@ void tm_workspace_recreate_tags_array(void)
g_message("Recreating workspace tags array");
#endif
- if ((NULL == theWorkspace) || (NULL == theWorkspace->work_objects))
+ if ((NULL == theWorkspace) || (NULL == theWorkspace->source_files))
return;
- if (NULL != theWorkspace->work_object.tags_array)
- g_ptr_array_set_size(theWorkspace->work_object.tags_array, 0);
+ if (NULL != theWorkspace->tags_array)
+ g_ptr_array_set_size(theWorkspace->tags_array, 0);
else
- theWorkspace->work_object.tags_array = g_ptr_array_new();
+ theWorkspace->tags_array = g_ptr_array_new();
#ifdef TM_DEBUG
- g_message("Total %d objects", theWorkspace->work_objects->len);
+ g_message("Total %d objects", theWorkspace->source_files->len);
#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
g_message("Adding tags of %s", w->file_name);
#endif
@@ -513,44 +478,26 @@ void tm_workspace_recreate_tags_array(void)
{
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]);
}
}
}
#ifdef TM_DEBUG
- g_message("Total: %d tags", theWorkspace->work_object.tags_array->len);
+ g_message("Total: %d tags", theWorkspace->tags_array->len);
#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
- , gboolean recurse, gboolean UNUSED update_parent)
+void tm_workspace_update(void)
{
- guint i;
- gboolean update_tags = force;
-
#ifdef TM_DEBUG
g_message("Updating workspace");
#endif
- if (workspace != TM_WORK_OBJECT(theWorkspace))
- return FALSE;
if (NULL == theWorkspace)
- return TRUE;
- if ((recurse) && (theWorkspace->work_objects))
- {
- 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;
+ return;
+ tm_workspace_recreate_tags_array();
}
void tm_workspace_dump(void)
@@ -560,13 +507,13 @@ void tm_workspace_dump(void)
#ifdef TM_DEBUG
g_message("Dumping TagManager workspace tree..");
#endif
- tm_work_object_dump(TM_WORK_OBJECT(theWorkspace));
- if (theWorkspace->work_objects)
+ if (theWorkspace->source_files)
{
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
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]);
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
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);
if (global_search)
{
@@ -783,7 +730,7 @@ find_scope_members_tags (const GPtrArray * all, GPtrArray * tags,
tag = TM_TAG (all->pdata[i]);
if (no_definitions && filename && tag->atts.entry.file &&
0 != strcmp (filename,
- tag->atts.entry.file->work_object.short_name))
+ tag->atts.entry.file->short_name))
{
continue;
}
@@ -903,7 +850,7 @@ find_namespace_members_tags (const GPtrArray * all, GPtrArray * tags,
tag = TM_TAG (all->pdata[i]);
if (filename && tag->atts.entry.file &&
0 != strcmp (filename,
- tag->atts.entry.file->work_object.short_name))
+ tag->atts.entry.file->short_name))
{
continue;
}
@@ -996,7 +943,7 @@ tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *na
continue;
}
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')
{
del = 1;
@@ -1026,14 +973,14 @@ tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *na
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_field_t | tm_tag_enumerator_t |
tm_tag_namespace_t | tm_tag_class_t ));
}
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_member_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;
}
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')
{
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)
{
- 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_member_t | tm_tag_field_t |
tm_tag_method_t | tm_tag_enumerator_t));
}
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_member_t | tm_tag_field_t |
tm_tag_method_t | tm_tag_enumerator_t));
Modified: tagmanager/src/tm_workspace.h
60 lines changed, 19 insertions(+), 41 deletions(-)
===================================================================
@@ -13,7 +13,7 @@
#include <glib.h>
-#include "tm_work_object.h"
+#include "tm_tag.h"
#ifdef __cplusplus
extern "C"
@@ -21,54 +21,44 @@ extern "C"
#endif
-/*! The Tag Manager Workspace. This is a singleton work object containing a list
- of work objects - individual source files. There is also a global tag list
+/*! The Tag Manager Workspace. This is a singleton object containing a list
+ of individual source files. There is also a global tag list
which can be loaded or created. This contains global tags gleaned from
/usr/include, etc. and should be used for autocompletion, calltips, etc.
*/
typedef struct
{
- TMWorkObject work_object; /*!< The parent work object */
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;
-/*! Adds a work object (source file) to the workspace.
- \param work_object The work object to add to the workspace.
+/*! Adds a source file 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).
*/
-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.
- \param work_object Pointer to the work object to be removed.
- \param do_free Whether the work object is to be freed as well.
+ \param source_file Pointer to the source file to be removed.
+ \param do_free Whether the source file is to be freed as well.
\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
/* Since TMWorkspace is a singleton, you should not create multiple
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
created workspace.
*/
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
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);
/* 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().
*/
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.
- \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
- , gboolean recurse, gboolean update_parent);
+void tm_workspace_update(void);
/* Dumps the workspace tree - useful for debugging */
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) */
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.
*/
-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 */
Modified: wscript
3 lines changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -121,7 +121,6 @@ tagmanager_sources = set([
'tagmanager/src/tm_file_entry.c',
'tagmanager/src/tm_source_file.c',
'tagmanager/src/tm_tag.c',
- 'tagmanager/src/tm_work_object.c',
'tagmanager/src/tm_workspace.c'])
scintilla_sources = set(['scintilla/gtk/scintilla-marshal.c'])
@@ -553,7 +552,7 @@ def build(bld):
bld.install_files('${PREFIX}/include/geany/tagmanager', '''
tagmanager/src/tm_source_file.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 ''')
# Docs
base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).