Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 15 Jul 2013 15:42:00 UTC Commit: b016e132fd3578c71f3362399b91562e2f6623c8 https://github.com/geany/geany/commit/b016e132fd3578c71f3362399b91562e2f6623...
Log Message: ----------- Java: Report enums and fix parsing them
Modified Paths: -------------- src/symbols.c tagmanager/ctags/c.c tests/ctags/enum.java.tags tests/ctags/java_enum.java tests/ctags/java_enum.java.tags
Modified: src/symbols.c 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -905,6 +905,7 @@ static void add_top_level_items(GeanyDocument *doc) &(tv_iters.tag_class), _("Classes"), "classviewer-class", &(tv_iters.tag_function), _("Methods"), "classviewer-method", &(tv_iters.tag_member), _("Members"), "classviewer-member", + &(tv_iters.tag_type), _("Enums"), "classviewer-struct", &(tv_iters.tag_other), _("Other"), "classviewer-other", NULL); break;
Modified: tagmanager/ctags/c.c 29 files changed, 21 insertions(+), 8 deletions(-) =================================================================== @@ -204,6 +204,7 @@ boolean haveQualifyingName; /* do we have a name we are considering? */ boolean gotParenName; /* was a name inside parentheses parsed yet? */ boolean gotArgs; /* was a list of parameters parsed yet? */ + unsigned int nSemicolons; /* how many semicolons did we see in that statement */ impType implementation; /* abstract or concrete implementation? */ unsigned int tokenIndex; /* currently active token */ tokenInfo* token [((int) NumTokens)]; @@ -327,7 +328,7 @@ { JK_UNDEFINED = -1, JK_CLASS, JK_FIELD, JK_INTERFACE, JK_METHOD, - JK_PACKAGE + JK_PACKAGE, JK_ENUMERATOR, JK_ENUMERATION } javaKind;
static kindOption JavaKinds [] = { @@ -336,6 +337,8 @@ { TRUE, 'i', "interface", "interfaces"}, { TRUE, 'm', "method", "methods"}, { TRUE, 'p', "package", "packages"}, + { TRUE, 'e', "enumerator", "enumerators (values inside an enumeration)"}, + { TRUE, 'g', "enum", "enumeration names"}, };
typedef enum @@ -940,6 +943,7 @@ static void reinitStatement (statementInfo *const st, const boolean partial) st->implementation = IMP_DEFAULT; st->gotArgs = FALSE; st->gotName = FALSE; + st->nSemicolons = 0; st->haveQualifyingName = FALSE; st->argEndPosition = 0;
@@ -1089,11 +1093,13 @@ static javaKind javaTagKind (const tagType type) javaKind result = JK_UNDEFINED; switch (type) { - case TAG_CLASS: result = JK_CLASS; break; - case TAG_FIELD: result = JK_FIELD; break; - case TAG_INTERFACE: result = JK_INTERFACE; break; - case TAG_METHOD: result = JK_METHOD; break; - case TAG_PACKAGE: result = JK_PACKAGE; break; + case TAG_CLASS: result = JK_CLASS; break; + case TAG_FIELD: result = JK_FIELD; break; + case TAG_INTERFACE: result = JK_INTERFACE; break; + case TAG_METHOD: result = JK_METHOD; break; + case TAG_PACKAGE: result = JK_PACKAGE; break; + case TAG_ENUM: result = JK_ENUMERATION; break; + case TAG_ENUMERATOR: result = JK_ENUMERATOR; break;
default: Assert ("Bad Java tag type" == NULL); break; } @@ -2786,6 +2792,9 @@ static void nextToken (statementInfo *const st) } } while (isType (token, TOKEN_NONE));
+ if (isType (token, TOKEN_SEMICOLON) && st->parent) + st->parent->nSemicolons ++; + /* We want to know about non-keyword variable types */ if (TOKEN_NONE == st->firstToken->type) { @@ -2913,7 +2922,9 @@ static void tagCheck (statementInfo *const st) { case TOKEN_NAME: { - if (insideEnumBody (st)) + if (insideEnumBody (st) && + /* Java enumerations can contain members after a semicolon */ + (! isLanguage(Lang_java) || st->parent->nSemicolons < 1)) qualifyEnumeratorTag (st, token); break; } @@ -3022,7 +3033,9 @@ static void tagCheck (statementInfo *const st) case TOKEN_SEMICOLON: case TOKEN_COMMA: { - if (insideEnumBody (st)) + if (insideEnumBody (st) && + /* Java enumerations can contain members after a semicolon */ + (! isLanguage (Lang_java) || st->parent->nSemicolons < 2)) ; else if (isType (prev, TOKEN_NAME)) {
Modified: tests/ctags/enum.java.tags 10 files changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -1,3 +1,13 @@ # format=tagmanager +A�4�e�0 +B�4�e�0 +C�4�e�0 +D�4�e�0 +E�4�e�0 +F�4�e�0 +e�2�0 getShape�128�()�e�0�public final Shape getString�128�()�e�0�public String +shape�8�e�0�Shape +string�8�e�0�String +twoKeywordsInARow�8�e�0�boolean
Modified: tests/ctags/java_enum.java 5 files changed, 5 insertions(+), 0 deletions(-) =================================================================== @@ -12,4 +12,9 @@ void m() { } } + public enum FancyEnum2 { + X, Y; + void m2() { + } + } }
Modified: tests/ctags/java_enum.java.tags 11 files changed, 11 insertions(+), 0 deletions(-) =================================================================== @@ -1,4 +1,15 @@ # format=tagmanager +A�4�C.FancyEnum�0 +B�4�C.FancyEnum�0 C�1�0 +FIRST_VALUE�4�C.TrivialEnum�0 +FancyEnum�2�C�0 FancyEnum�128�(int i)�C.FancyEnum�0 +FancyEnum2�2�C�0 +SECOND_VALUE�4�C.TrivialEnum�0 +TrivialEnum�2�C�0 +X�4�C.FancyEnum2�0 +Y�4�C.FancyEnum2�0 +i�8�C.FancyEnum�0�int m�128�()�C.FancyEnum�0�void +m2�128�()�C.FancyEnum2�0�void
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).