[geany/geany] ef4c72: Fortran: generate fake tags for anonymous structures, interfaces and enums
Colomban Wendling
git-noreply at xxxxx
Sun Feb 23 19:02:55 UTC 2014
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sun, 23 Feb 2014 19:02:55 UTC
Commit: ef4c72501e0f8532e31a9fac91a3a29c3e078ce4
https://github.com/geany/geany/commit/ef4c72501e0f8532e31a9fac91a3a29c3e078ce4
Log Message:
-----------
Fortran: generate fake tags for anonymous structures, interfaces and enums
This allows both to show those anonymous elements, as well as giving a
parent to their children, fixing display in the symbols tree.
Modified Paths:
--------------
src/symbols.c
tagmanager/ctags/fortran.c
tests/ctags/enum.f90.tags
tests/ctags/enumerators.f90.tags
tests/ctags/numlib.f90.tags
tests/ctags/recursive.f95.tags
tests/ctags/structure.f.tags
Modified: src/symbols.c
1 files changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -979,6 +979,7 @@ static void add_top_level_items(GeanyDocument *doc)
&(tv_iters.tag_class), _("Types"), "classviewer-class",
&(tv_iters.tag_member), _("Components"), "classviewer-member",
&(tv_iters.tag_macro), _("Blocks"), "classviewer-member",
+ &(tv_iters.tag_type), _("Enums"), "classviewer-struct",
&(tv_iters.tag_other), _("Other"), "classviewer-other",
NULL);
break;
Modified: tagmanager/ctags/fortran.c
38 files changed, 22 insertions(+), 16 deletions(-)
===================================================================
@@ -208,6 +208,7 @@
static boolean FreeSourceForm = FALSE;
static boolean ParsingString;
static tokenInfo *Parent = NULL;
+static unsigned int contextual_fake_count = 0;
/* indexed by tagType */
static kindOption FortranKinds [] = {
@@ -378,8 +379,7 @@ static const tokenInfo* ancestorScope (void)
{
tokenInfo *const token = Ancestors.list + i - 1;
if (token->type == TOKEN_IDENTIFIER &&
- token->tag != TAG_UNDEFINED && token->tag != TAG_INTERFACE &&
- token->tag != TAG_ENUM)
+ token->tag != TAG_UNDEFINED)
result = token;
}
return result;
@@ -456,6 +456,16 @@ static tokenInfo *newTokenFrom (tokenInfo *const token)
return result;
}
+static tokenInfo *newAnonTokenFrom (tokenInfo *const token, const char *type)
+{
+ char buffer[64];
+ tokenInfo *result = newTokenFrom (token);
+ sprintf (buffer, "%s#%u", type, contextual_fake_count++);
+ vStringClear (result->string);
+ vStringCatS (result->string, buffer);
+ return result;
+}
+
static void deleteToken (tokenInfo *const token)
{
if (token != NULL)
@@ -1593,7 +1603,7 @@ static void parseUnionStmt (tokenInfo *const token)
*/
static void parseStructureStmt (tokenInfo *const token)
{
- tokenInfo *name;
+ tokenInfo *name = NULL;
Assert (isKeyword (token, KEYWORD_structure));
readToken (token);
if (isType (token, TOKEN_OPERATOR) &&
@@ -1601,17 +1611,16 @@ static void parseStructureStmt (tokenInfo *const token)
{ /* read structure name */
readToken (token);
if (isType (token, TOKEN_IDENTIFIER))
- makeFortranTag (token, TAG_DERIVED_TYPE);
- name = newTokenFrom (token);
+ name = newTokenFrom (token);
skipPast (token, TOKEN_OPERATOR);
}
- else
+ if (name == NULL)
{ /* fake out anonymous structure */
- name = newToken ();
+ name = newAnonTokenFrom (token, "Structure");
name->type = TOKEN_IDENTIFIER;
name->tag = TAG_DERIVED_TYPE;
- vStringCopyS (name->string, "anonymous");
}
+ makeFortranTag (name, TAG_DERIVED_TYPE);
while (isType (token, TOKEN_IDENTIFIER))
{ /* read field names */
makeFortranTag (token, TAG_COMPONENT);
@@ -1770,7 +1779,6 @@ static void parseInterfaceBlock (tokenInfo *const token)
readToken (token);
if (isType (token, TOKEN_IDENTIFIER))
{
- makeFortranTag (token, TAG_INTERFACE);
name = newTokenFrom (token);
}
else if (isKeyword (token, KEYWORD_assignment) ||
@@ -1780,17 +1788,15 @@ static void parseInterfaceBlock (tokenInfo *const token)
if (isType (token, TOKEN_PAREN_OPEN))
readToken (token);
if (isType (token, TOKEN_OPERATOR))
- {
- makeFortranTag (token, TAG_INTERFACE);
name = newTokenFrom (token);
- }
}
if (name == NULL)
{
- name = newToken ();
+ name = newAnonTokenFrom (token, "Interface");
name->type = TOKEN_IDENTIFIER;
name->tag = TAG_INTERFACE;
}
+ makeFortranTag (name, TAG_INTERFACE);
ancestorPush (name);
while (! isKeyword (token, KEYWORD_end))
{
@@ -1842,12 +1848,11 @@ static void parseEnumBlock (tokenInfo *const token)
name = newTokenFrom (token);
if (name == NULL)
{
- name = newToken ();
+ name = newAnonTokenFrom (token, "Enum");
name->type = TOKEN_IDENTIFIER;
name->tag = TAG_ENUM;
}
- else
- makeFortranTag (name, TAG_ENUM);
+ makeFortranTag (name, TAG_ENUM);
skipToNextStatement (token);
ancestorPush (name);
while (! isKeyword (token, KEYWORD_end))
@@ -2282,6 +2287,7 @@ static boolean findFortranTags (const unsigned int passCount)
Parent = newToken ();
token = newToken ();
FreeSourceForm = (boolean) (passCount > 1);
+ contextual_fake_count = 0;
Column = 0;
exception = (exception_t) setjmp (Exception);
if (exception == ExceptionEOF)
Modified: tests/ctags/enum.f90.tags
70 files changed, 36 insertions(+), 34 deletions(-)
===================================================================
@@ -1,6 +1,8 @@
# format=tagmanager
ConstantsÌ256Ö0
E_eÌ16384ÎConstantsÖ0
+Enum#0Ì2ÎConstantsÖ0
+Enum#1Ì2ÎConstantsÖ0
Named1Ì2ÎConstantsÖ0
Named2Ì2ÎConstantsÖ0
Named3Ì2ÎConstantsÖ0
@@ -8,39 +10,39 @@ Named4
Named5Ì2ÎConstantsÖ0
Named6Ì2ÎConstantsÖ0
Named7Ì2ÎConstantsÖ0
-aÌ4ÎConstantsÖ0
-bÌ4ÎConstantsÖ0
-blackÌ4ÎConstantsÖ0
-blueÌ4ÎConstantsÖ0
-bronzeÌ4ÎConstantsÖ0
-cÌ4ÎConstantsÖ0
-goldÌ4ÎConstantsÖ0
+aÌ4ÎEnum#1Ö0
+bÌ4ÎEnum#1Ö0
+blackÌ4ÎEnum#0Ö0
+blueÌ4ÎEnum#0Ö0
+bronzeÌ4ÎEnum#0Ö0
+cÌ4ÎEnum#1Ö0
+goldÌ4ÎEnum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ö0
+z5Ì4ÎNamed5Ö0
+z6Ì4ÎNamed6Ö0
+z7Ì4ÎNamed7Ö0
Modified: tests/ctags/enumerators.f90.tags
31 files changed, 17 insertions(+), 14 deletions(-)
===================================================================
@@ -3,24 +3,27 @@ Aster_colon
Aster_kindÌ2ÎEnumsÖ0
BodyPartÌ2ÎEnumsÖ0
ColonsÌ2ÎEnumsÖ0
+Enum#0Ì2ÎEnumsÖ0
+Enum#1Ì2ÎEnumsÖ0
EnumsÌ256Ö0
FuncÌ16ÎEnumsÖ0
Name_colonÌ2ÎEnumsÖ0
Paren_colonÌ2ÎEnumsÖ0
Paren_kindÌ2ÎEnumsÖ0
-armÌ4ÎEnumsÖ0
-bÌ4ÎEnumsÖ0
-blueÌ4ÎEnumsÖ0
-bronzeÌ4ÎEnumsÖ0
-cÌ4ÎEnumsÖ0
-dÌ4ÎEnumsÖ0
-eÌ4ÎEnumsÖ0
-goldÌ4ÎEnumsÖ0
-legÌ4ÎEnumsÖ0
-no_c_bindingÌ4ÎEnumsÖ0
+armÌ4ÎBodyPartÖ0
+bÌ4ÎParen_kindÖ0
+blueÌ4ÎEnum#0Ö0
+bronzeÌ4ÎEnum#0Ö0
+cÌ4ÎAster_kindÖ0
+dÌ4ÎName_colonÖ0
+dÌ4ÎParen_colonÖ0
+eÌ4ÎAster_colonÖ0
+goldÌ4ÎEnum#0Ö0
+legÌ4ÎBodyPartÖ0
+no_c_bindingÌ4ÎEnum#1Ö0
othervarÌ16384ÎEnumsÖ0
-purpleÌ4ÎEnumsÖ0
-rÌ4ÎEnumsÖ0
-redÌ4ÎEnumsÖ0
-silverÌ4ÎEnumsÖ0
+purpleÌ4ÎEnum#0Ö0
+rÌ4ÎColonsÖ0
+redÌ4ÎEnum#0Ö0
+silverÌ4ÎEnum#0Ö0
somevarÌ16384ÎEnumsÖ0
Modified: tests/ctags/numlib.f90.tags
1 files changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -1,2 +1,3 @@
# format=tagmanager
+Interface#0Ì32Înumerical_librariesÖ0
numerical_librariesÌ256Ö0
Modified: tests/ctags/recursive.f95.tags
2 files changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -1,4 +1,6 @@
# format=tagmanager
+Interface#0Ì32ÎapproxÖ0
+Interface#1Ì32Îapprox2Ö0
approxÌ256Ö0
approx2Ì256Ö0
partsÌ16384ÎapproxÖ0
Modified: tests/ctags/structure.f.tags
3 files changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -1,5 +1,6 @@
# format=tagmanager
-aÌ64ÎanonymousÖ0
+Structure#0Ì1ÎnestedÖ0
+aÌ64ÎStructure#0Ö0
cloudsÌ64ÎweatherÖ0
dayÌ64ÎweatherÖ0
initialized_structureÌ2048Ö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