geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

tm_tag.h
Go to the documentation of this file.
1/*
2*
3* Copyright (c) 2001-2002, Biswapesh Chattopadhyay
4* Copyright 2005 The Geany contributors
5*
6* This source code is released for free distribution under the terms of the
7* GNU General Public License.
8*
9*/
10
11#ifndef TM_TAG_H
12#define TM_TAG_H
13
14/* @file
15 The TMTag structure and the associated functions are used to manipulate
16 tags and arrays of tags. Normally, you should not create tags individually
17 but through an external interface such as tm_source_file_parse(), which generates
18 an array of tags for the given source file. Once the tag list is generated,
19 you can do various operations such as:
20 -# Extract relevant tags using tm_tags_extract()
21 -# Sort an array of tags using tm_tags_sort()
22 -# Deduplicate an array of tags using tm_tags_dedup().
23
24 An important thing to remember here is that the tags operations such as extraction,
25 sorting and deduplication do not change the tag itself in any way, but rather,
26 manipulate pointers to the tags structure. The tags themselves are owned by the
27 TMSourceFile structure which created them during parsing. So, be careful, for example,
28 while deduping the tags array of a source file directly, since this might lead to
29 'dangling' tags whose pointers have been removed from the array. If you need to
30 deduplicate, create a copy of the tag pointer array using tm_tags_extract().
31*/
32
33#include "tm_source_file.h"
34#include "tm_parser.h"
35#include <glib-object.h>
36
37G_BEGIN_DECLS
38
39/** Use the TM_TAG() macro to cast a pointer to (TMTag *) */
40#define TM_TAG(tag) ((TMTag *) tag)
41
42/**
43 Tag Attributes. Note that some attributes are available to file
44 pseudotags only. Attributes are useful for specifying as arguments
45 to the builtin sort and dedup functions, and during printing or writing
46 to file, since these functions can operate on the given set of attributes
47 only. Tag attributes are bitmasks and can be 'OR'-ed bitwise to represent
48 any combination (line TMTagType).
49*/
50typedef enum
51{
52 tm_tag_attr_none_t = 0, /**< Undefined */
53 tm_tag_attr_name_t = 1, /**< Tag Name */
54 tm_tag_attr_type_t = 2, /**< Tag Type */
55 tm_tag_attr_file_t = 4, /**< File in which tag exists */
56 tm_tag_attr_line_t = 8, /**< Line number of tag */
57 tm_tag_attr_pos_t = 16, /**< Byte position of tag in the file (Obsolete) */
58 tm_tag_attr_scope_t = 32, /**< Scope of the tag */
59 tm_tag_attr_inheritance_t = 64, /**< Parent classes */
60 tm_tag_attr_arglist_t = 128, /**< Argument list */
61 tm_tag_attr_local_t = 256, /**< If it has local scope */
62 tm_tag_attr_time_t = 512, /**< Modification time (File tag only) */
63 tm_tag_attr_vartype_t = 1024, /**< Variable Type */
64 tm_tag_attr_access_t = 2048, /**< Access type (public/protected/private) */
65 tm_tag_attr_impl_t = 4096, /**< Implementation (e.g. virtual) */
66 tm_tag_attr_lang_t = 8192, /**< Language (File tag only) */
67 tm_tag_attr_inactive_t = 16384, /**< Inactive file (File tag only, obsolete) */
68 tm_tag_attr_pointer_t = 32768, /**< Pointer type */
69 tm_tag_attr_max_t = 65535 /**< Maximum value */
71
72/** Tag access type for C++/Java member functions and variables */
73#define TAG_ACCESS_PUBLIC 'p' /**< Public member */
74#define TAG_ACCESS_PROTECTED 'r' /**< Protected member */
75#define TAG_ACCESS_PRIVATE 'v' /**< Private member */
76#define TAG_ACCESS_FRIEND 'f' /**< Friend members/functions */
77#define TAG_ACCESS_DEFAULT 'd' /**< Default access (Java) */
78#define TAG_ACCESS_UNKNOWN 'x' /**< Unknown access type */
79
80/** Tag implementation type for functions */
81#define TAG_IMPL_VIRTUAL 'v' /**< Virtual implementation */
82#define TAG_IMPL_UNKNOWN 'x' /**< Unknown implementation */
83
84/**
85 * The TMTag structure represents a single tag in the tag manager.
86 **/
87typedef struct TMTag
88{
89 char *name; /**< Name of tag */
90 TMTagType type; /**< Tag Type */
91 gint refcount; /* the reference count of the tag */
92
93 /** These are tag attributes */
94 TMSourceFile *file; /**< File in which the tag occurs; NULL for global tags */
95 gulong line; /**< Line number of the tag */
96 gboolean local; /**< Is the tag of local scope */
98 char *arglist; /**< Argument list (functions/prototypes/macros) */
99 char *scope; /**< Scope of tag */
100 char *inheritance; /**< Parent classes */
101 char *var_type; /**< Variable type (maps to struct for typedefs) */
102 char access; /**< Access type (public/protected/private/etc.) */
103 char impl; /**< Implementation (e.g. virtual) */
104 TMParserType lang; /* Programming language of the file */
106
107/* The GType for a TMTag */
108#define TM_TYPE_TAG (tm_tag_get_type())
109
110GType tm_tag_get_type(void) G_GNUC_CONST;
111
112#ifdef GEANY_PRIVATE
113
114TMTag *tm_tag_new(void);
115
116void tm_tags_remove_file_tags(TMSourceFile *source_file, GPtrArray *tags_array);
117
118GPtrArray *tm_tags_merge(GPtrArray *big_array, GPtrArray *small_array,
119 TMTagAttrType *sort_attributes, gboolean unref_duplicates);
120
121void tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes,
122 gboolean dedup, gboolean unref_duplicates);
123
124GPtrArray *tm_tags_extract(GPtrArray *tags_array, guint tag_types);
125
126void tm_tags_prune(GPtrArray *tags_array);
127
128void tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean unref_duplicates);
129
130TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name,
131 gboolean partial, guint * tagCount);
132
133void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all);
134
135const TMTag *tm_get_current_tag(GPtrArray *file_tags, const gulong line, const TMTagType tag_types);
136
137void tm_tag_unref(TMTag *tag);
138
139TMTag *tm_tag_ref(TMTag *tag);
140
141gboolean tm_tags_equal(const TMTag *a, const TMTag *b);
142
143gboolean tm_tag_is_anon(const TMTag *tag);
144
145#ifdef TM_DEBUG /* various debugging functions */
146
147const char *tm_tag_type_name(const TMTag *tag);
148
149TMTagType tm_tag_name_type(const char* tag_name);
150
151void tm_tag_print(TMTag *tag, FILE *fp);
152
153void tm_tags_array_print(GPtrArray *tags, FILE *fp);
154
155gint tm_tag_scope_depth(const TMTag *t);
156
157#endif /* TM_DEBUG */
158
159#endif /* GEANY_PRIVATE */
160
161G_END_DECLS
162
163#endif /* TM_TAG_H */
const gchar * name
Definition: document.c:3219
vString * line
Definition: geany_cobol.c:133
The TMSourceFile structure represents the source file and its tags in the tag manager.
The TMTag structure represents a single tag in the tag manager.
Definition: tm_tag.h:88
char * scope
Scope of tag.
Definition: tm_tag.h:99
char * inheritance
Parent classes.
Definition: tm_tag.h:100
char * var_type
Variable type (maps to struct for typedefs)
Definition: tm_tag.h:101
char * arglist
Argument list (functions/prototypes/macros)
Definition: tm_tag.h:98
TMSourceFile * file
These are tag attributes.
Definition: tm_tag.h:94
TMTagType type
Tag Type.
Definition: tm_tag.h:90
gulong line
Line number of the tag.
Definition: tm_tag.h:95
char * name
Name of tag.
Definition: tm_tag.h:89
char access
Access type (public/protected/private/etc.)
Definition: tm_tag.h:102
gint refcount
Definition: tm_tag.h:91
TMParserType lang
Definition: tm_tag.h:104
guint pointerOrder
Definition: tm_tag.h:97
char impl
Implementation (e.g.
Definition: tm_tag.h:103
gboolean local
Is the tag of local scope.
Definition: tm_tag.h:96
TMTagType
Types of tags.
Definition: tm_parser.h:23
gint TMParserType
Definition: tm_parser.h:52
The TMSourceFile structure and associated functions are used to maintain tags for individual files.
const TMTag * tm_get_current_tag(GPtrArray *file_tags, const gulong line, const TMTagType tag_types)
Definition: tm_tag.c:646
GPtrArray * tm_tags_merge(GPtrArray *big_array, GPtrArray *small_array, TMTagAttrType *sort_attributes, gboolean unref_duplicates)
Definition: tm_tag.c:482
TMTag * tm_tag_new(void)
Definition: tm_tag.c:106
GPtrArray * tm_tags_extract(GPtrArray *tags_array, TMTagType tag_types)
Definition: tm_tag.c:505
void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all)
Definition: tm_tag.c:529
void tm_tags_remove_file_tags(TMSourceFile *source_file, GPtrArray *tags_array)
Definition: tm_tag.c:311
TMTag ** tm_tags_find(const GPtrArray *tags_array, const char *name, gboolean partial, guint *tagCount)
Definition: tm_tag.c:603
TMTag * tm_tag_ref(TMTag *tag)
Definition: tm_tag.c:152
gboolean tm_tag_is_anon(const TMTag *tag)
Definition: tm_tag.c:668
void tm_tag_unref(TMTag *tag)
Definition: tm_tag.c:136
gboolean tm_tags_equal(const TMTag *a, const TMTag *b)
Definition: tm_tag.c:221
void tm_tags_prune(GPtrArray *tags_array)
Definition: tm_tag.c:246
void tm_tags_sort(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean dedup, gboolean unref_duplicates)
Definition: tm_tag.c:297
void tm_tags_dedup(GPtrArray *tags_array, TMTagAttrType *sort_attributes, gboolean unref_duplicates)
Definition: tm_tag.c:267
struct TMTag TMTag
The TMTag structure represents a single tag in the tag manager.
GType tm_tag_get_type(void) G_GNUC_CONST
Gets the GType for a TMTag.
Definition: tm_tag.c:91
TMTagAttrType
Tag Attributes.
Definition: tm_tag.h:51
@ tm_tag_attr_none_t
Undefined.
Definition: tm_tag.h:52
@ tm_tag_attr_vartype_t
Variable Type.
Definition: tm_tag.h:63
@ tm_tag_attr_max_t
Maximum value.
Definition: tm_tag.h:69
@ tm_tag_attr_name_t
Tag Name.
Definition: tm_tag.h:53
@ tm_tag_attr_pointer_t
Pointer type.
Definition: tm_tag.h:68
@ tm_tag_attr_file_t
File in which tag exists.
Definition: tm_tag.h:55
@ tm_tag_attr_pos_t
Byte position of tag in the file (Obsolete)
Definition: tm_tag.h:57
@ tm_tag_attr_scope_t
Scope of the tag.
Definition: tm_tag.h:58
@ tm_tag_attr_lang_t
Language (File tag only)
Definition: tm_tag.h:66
@ tm_tag_attr_access_t
Access type (public/protected/private)
Definition: tm_tag.h:64
@ tm_tag_attr_inheritance_t
Parent classes.
Definition: tm_tag.h:59
@ tm_tag_attr_inactive_t
Inactive file (File tag only, obsolete)
Definition: tm_tag.h:67
@ tm_tag_attr_impl_t
Implementation (e.g.
Definition: tm_tag.h:65
@ tm_tag_attr_local_t
If it has local scope.
Definition: tm_tag.h:61
@ tm_tag_attr_arglist_t
Argument list.
Definition: tm_tag.h:60
@ tm_tag_attr_line_t
Line number of tag.
Definition: tm_tag.h:56
@ tm_tag_attr_time_t
Modification time (File tag only)
Definition: tm_tag.h:62
@ tm_tag_attr_type_t
Tag Type.
Definition: tm_tag.h:54