Since this issue has not been fully addressed, I modified my personal build of QDox to get enums working for my own needs.
The problem is that while QDox 1.7 successfully parses enums, the parser doesn't add them to the model. From a top-level application's perspective, QDox appears to ignore the enums.
My fix was to modify QDox's parser.y grammar to add each enum's member as a field. Consequently, my top-level application is able to iterate over the members of an enum like fields in a class.
// ----- ENUM
enum: enum_definition BRACEOPEN enum_body BRACECLOSE
{
builder.endClass();
fieldType = null;
modifiers.clear();
}
;
enum_definition: modifiers ENUM IDENTIFIER opt_implements
{
cls.lineNumber = line;
cls.modifiers.addAll(modifiers);
cls.name = $3;
cls.type = ClassDef.ENUM;
builder.beginClass(cls);
cls = new ClassDef();
fieldType = new TypeDef($3, 0);
}
;
enum_body: enum_values | enum_values SEMI members;
enum_values: | enum_value | enum_value COMMA enum_values;
enum_value:
javadoc enum_constructor |
opt_annotations enum_constructor;
enum_constructor:
IDENTIFIER
{ makeField(new TypeDef($1, 0), ""); } |
IDENTIFIER CODEBLOCK { makeField(new TypeDef($1, 0), ""); }
|
IDENTIFIER PARENBLOCK
{ makeField(new TypeDef($1, 0), ""); } |
IDENTIFIER PARENBLOCK CODEBLOCK { makeField(new TypeDef($1, 0), ""); }
;
I have attached a patch file.
Any news on this? It's been almost a year since the bug was reported and no one touched it yet.