[geany/geany] 1b32ac: Add full xtag implementation and use it to check XTAG_QUALIFIED_TAGS
Jiří Techet
git-noreply at xxxxx
Sat Sep 10 07:26:13 UTC 2016
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Mon, 01 Aug 2016 16:58:27 UTC
Commit: 1b32ac5481d826a4fbc729ef06a4b664e5448d21
https://github.com/geany/geany/commit/1b32ac5481d826a4fbc729ef06a4b664e5448d21
Log Message:
-----------
Add full xtag implementation and use it to check XTAG_QUALIFIED_TAGS
Modified Paths:
--------------
ctags/Makefile.am
ctags/main/options.c
ctags/main/options.h
ctags/main/routines.h
ctags/main/xtag.c
ctags/main/xtag.h
ctags/parsers/c.c
ctags/parsers/go.c
ctags/parsers/perl.c
Modified: ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -87,4 +87,5 @@ libctags_la_SOURCES = \
main/vstring.c \
main/vstring.h \
main/xtag.h \
+ main/xtag.c \
$(parsers)
Modified: ctags/main/options.c
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -57,7 +57,6 @@
optionValues Option = {
{
FALSE, /* --extra=f */
- FALSE, /* --extra=q */
TRUE, /* --file-scope */
},
{
@@ -102,6 +101,8 @@ optionValues Option = {
FALSE, /* --totals */
FALSE, /* --line-directives */
FALSE, /* --nest */
+ .machinable = FALSE,
+ .withListHeader = TRUE,
};
Modified: ctags/main/options.h
12 lines changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -1,14 +1,13 @@
/*
-*
-* Copyright (c) 1998-2001, Darren Hiebert
+* Copyright (c) 1998-2003, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
-* GNU General Public License.
+* GNU General Public License version 2 or (at your option) any later version.
*
* Defines external interface to option processing.
*/
-#ifndef _OPTIONS_H
-#define _OPTIONS_H
+#ifndef CTAGS_MAIN_OPTIONS_H
+#define CTAGS_MAIN_OPTIONS_H
#if defined(OPTION_WRITE) || defined(VAXC)
# define CONST_OPTION
@@ -38,7 +37,6 @@
typedef struct sOptionValues {
struct sInclude {
boolean fileNames; /* include tags for source file names */
- boolean qualifiedTags; /* include tags for qualified class members */
boolean fileScope; /* include tags of file scope only */
} include;
struct sExtFields { /* extension field content control */
@@ -83,6 +81,8 @@ typedef struct sOptionValues {
boolean printTotals; /* --totals print cumulative statistics */
boolean lineDirectives; /* --linedirectives process #line directives */
boolean nestFunction; /* --nest Nest inside function blocks for tags */
+ boolean machinable; /* --machinable */
+ boolean withListHeader; /* --with-list-header */
} optionValues;
/*
Modified: ctags/main/routines.h
3 lines changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,9 @@
*/
#define ARRAY_SIZE(X) (sizeof (X) / sizeof (X[0]))
+#define STRINGIFY(X) STRINGIFY_(X)
+#define STRINGIFY_(X) #X
+
#endif /* CTAGS_MAIN_ROUTINES_H */
/* vi:set tabstop=4 shiftwidth=4: */
Modified: ctags/main/xtag.c
155 lines changed, 155 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,155 @@
+/*
+ *
+ * Copyright (c) 2015, Red Hat, Inc.
+ * Copyright (c) 2015, Masatake YAMATO
+ *
+ * Author: Masatake YAMATO <yamato at redhat.com>
+ *
+ * This source code is released for free distribution under the terms of the
+ * GNU General Public License version 2 or (at your option) any later version.
+ *
+ */
+
+#include "general.h" /* must always come first */
+#include "debug.h"
+#include "main.h"
+#include "options.h"
+#include "routines.h"
+#include "xtag.h"
+
+#include <string.h>
+
+
+static boolean isPseudoTagsEnabled (xtagDesc *pdesc UNUSED)
+{
+ return ! isDestinationStdout ();
+}
+
+static xtagDesc xtagDescs [] = {
+ { TRUE, 'F', "fileScope",
+ "Include tags of file scope" },
+ { FALSE, 'f', "inputFile",
+ "Include an entry for the base file name of every input file"},
+ { FALSE, 'p', "pseudo",
+ "Include pseudo tags",
+ isPseudoTagsEnabled},
+ { FALSE, 'q', "qualified",
+ "Include an extra class-qualified tag entry for each tag"},
+ { FALSE, 'r', "reference",
+ "Include reference tags"},
+ { FALSE, 's', "subparser",
+ "Include tags generated by sub parsers"},
+};
+
+extern xtagDesc* getXtagDesc (xtagType type)
+{
+ Assert ((0 <= type) && (type < XTAG_COUNT));
+ return xtagDescs + type;
+}
+
+typedef boolean (* xtagPredicate) (xtagDesc *pdesc, const void *user_data);
+static xtagType getXtagTypeGeneric (xtagPredicate predicate, const void *user_data)
+{
+ int i;
+
+ for (i = 0; i < XTAG_COUNT; i++)
+ {
+ if (predicate (xtagDescs + i, user_data))
+ return i;
+ }
+ return XTAG_UNKNOWN;
+}
+
+static boolean xtagEqualByLetter (xtagDesc *pdesc, const void *user_data)
+{
+ return (pdesc->letter == *((char *)user_data))? TRUE: FALSE;
+}
+
+extern xtagType getXtagTypeForLetter (char letter)
+{
+ return getXtagTypeGeneric (xtagEqualByLetter, &letter);
+}
+
+static boolean xtagEqualByName (xtagDesc *pdesc, const void *user_data)
+{
+ return (strcmp (pdesc->name, user_data) == 0)? TRUE: FALSE;
+}
+
+extern xtagType getXtagTypeForName (const char *name)
+{
+ return getXtagTypeGeneric (xtagEqualByName, name);
+}
+
+
+#define PR_XTAG_WIDTH_LETTER 7
+#define PR_XTAG_WIDTH_NAME 22
+#define PR_XTAG_WIDTH_ENABLED 7
+#define PR_XTAG_WIDTH_DESC 30
+
+#define PR_XTAG_STR(X) PR_XTAG_WIDTH_##X
+#define PR_XTAG_FMT(X,T) "%-" STRINGIFY(PR_XTAG_STR(X)) STRINGIFY(T)
+#define MAKE_XTAG_FMT(LETTER_SPEC) \
+ PR_XTAG_FMT (LETTER,LETTER_SPEC) \
+ " " \
+ PR_XTAG_FMT (NAME,s) \
+ " " \
+ PR_XTAG_FMT (ENABLED,s) \
+ " " \
+ PR_XTAG_FMT (DESC,s) \
+ "\n"
+
+static void printXtag (xtagType i)
+{
+ printf((Option.machinable? "%c\t%s\t%s\t%s\n": MAKE_XTAG_FMT(c)),
+ xtagDescs[i].letter,
+ xtagDescs[i].name,
+ getXtagDesc (i)->enabled? "TRUE": "FALSE",
+ xtagDescs[i].description? xtagDescs[i].description: "NONE");
+}
+
+extern void printXtags (void)
+{
+ unsigned int i;
+
+ if (Option.withListHeader)
+ printf ((Option.machinable? "%s\t%s\t%s\t%s\n": MAKE_XTAG_FMT(s)),
+ "#LETTER", "NAME", "ENABLED", "DESCRIPTION");
+
+ for (i = 0; i < XTAG_COUNT; i++)
+ printXtag (i);
+}
+
+extern boolean isXtagEnabled (xtagType type)
+{
+ xtagDesc* desc = getXtagDesc (type);
+
+ Assert (desc);
+
+ if (desc->isEnabled)
+ return desc->isEnabled (desc);
+ else
+ return desc->enabled;
+}
+
+extern boolean enableXtag (xtagType type, boolean state)
+{
+ boolean old;
+ xtagDesc* desc = getXtagDesc (type);
+
+ Assert (desc);
+
+ old = isXtagEnabled (type);
+ desc->enabled = state;
+ desc->isEnabled = NULL;;
+
+ return old;
+}
+
+const char* getXtagName (xtagType type)
+{
+ xtagDesc* desc = getXtagDesc (type);
+ if (desc)
+ return desc->name;
+ else
+ return NULL;
+}
Modified: ctags/main/xtag.h
55 lines changed, 55 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright (c) 2015, Red Hat, Inc.
+ * Copyright (c) 2015, Masatake YAMATO
+ *
+ * Author: Masatake YAMATO <yamato at redhat.com>
+ *
+ * This source code is released for free distribution under the terms of the
+ * GNU General Public License version 2 or (at your option) any later version.
+ *
+ */
+#ifndef CTAGS_MAIN_XTAG_H
+#define CTAGS_MAIN_XTAG_H
+
+#include "general.h"
+
+typedef enum eXtagType { /* extra tag content control */
+ XTAG_UNKNOWN = -1,
+
+ XTAG_FILE_SCOPE,
+ XTAG_FILE_NAMES,
+ XTAG_PSEUDO_TAGS,
+ XTAG_QUALIFIED_TAGS,
+ XTAG_REFERENCE_TAGS,
+ XTAG_TAGS_GENERATED_BY_SUB_PARSERS,
+
+ XTAG_COUNT
+} xtagType;
+
+typedef struct sXtagDesc {
+ boolean enabled;
+ unsigned char letter;
+ const char* name; /* used in extra: field */
+ const char* description; /* displayed in --list-extra output */
+
+ /* If the value for "enabled" is given dynamically,
+ use this field.
+
+ "enabled" field of Pseudo extra tag depends on where
+ the output stream is connected to. If it is connected
+ to standared output, the tag is disabled by default.
+ If it is connected to a regular file, the tag is enabled
+ by default. */
+ boolean (* isEnabled) (struct sXtagDesc *desc);
+} xtagDesc;
+
+extern xtagDesc* getXtagDesc (xtagType type);
+extern xtagType getXtagTypeForLetter (char letter);
+extern xtagType getXtagTypeForName (const char *name);
+extern boolean isXtagEnabled (xtagType type);
+extern boolean enableXtag (xtagType type, boolean state);
+const char* getXtagName (xtagType type);
+extern void printXtags (void);
+
+#endif /* CTAGS_MAIN_FIELD_H */
Modified: ctags/parsers/c.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1398,7 +1398,7 @@ static void findScopeHierarchy (vString *const string,
static void makeExtraTagEntry (const tagType type, tagEntryInfo *const e,
vString *const scope)
{
- if (Option.include.qualifiedTags &&
+ if (isXtagEnabled(XTAG_QUALIFIED_TAGS) &&
scope != NULL && vStringLength (scope) > 0)
{
vString *const scopedName = vStringNew ();
Modified: ctags/parsers/go.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -542,7 +542,7 @@ static void makeTag (tokenInfo *const token, const goKind kind,
}
makeTagEntry (&e);
- if (scope && Option.include.qualifiedTags)
+ if (scope && isXtagEnabled(XTAG_QUALIFIED_TAGS))
{
vString *qualifiedName = vStringNew ();
vStringCopy (qualifiedName, scope);
@@ -560,7 +560,7 @@ static void parsePackage (tokenInfo *const token)
if (isType (token, TOKEN_IDENTIFIER))
{
makeTag (token, GOTAG_PACKAGE, NULL, GOTAG_UNDEFINED, NULL, NULL);
- if (!scope && Option.include.qualifiedTags)
+ if (!scope && isXtagEnabled(XTAG_QUALIFIED_TAGS))
{
scope = vStringNew ();
vStringCopy (scope, token->string);
Modified: ctags/parsers/perl.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -332,7 +332,7 @@ static void findPerlTags (void)
makeTagEntry(&e);
- if (Option.include.qualifiedTags && qualified &&
+ if (isXtagEnabled(XTAG_QUALIFIED_TAGS) && qualified &&
package != NULL && vStringLength (package) > 0)
{
vString *const qualifiedName = vStringNew ();
@@ -345,7 +345,7 @@ static void findPerlTags (void)
} else if (vStringLength (name) > 0)
{
makeSimpleTag (name, PerlKinds, kind);
- if (Option.include.qualifiedTags && qualified &&
+ if (isXtagEnabled(XTAG_QUALIFIED_TAGS) && qualified &&
K_PACKAGE != kind &&
package != NULL && vStringLength (package) > 0)
{
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list