jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • QDox
  • QDOX-79

Expose enums in model

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.7
  • Component/s: Java API
  • Labels:
    None

Description

Following on from QDOX-74, Java 5 enums should be accessible through the model.

Ponder - do we create a JavaEnum class, or maybe just add some methods to JavaClass?

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    EnumsModelTest.java
    12/Nov/08 10:07 AM
    7 kB
    Andrew Mickish
  2. File
    parser.y.diff
    12/Nov/08 10:18 AM
    1 kB
    Andrew Mickish

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Daniel Serodio added a comment - 08/Dec/05 7:14 AM

Any news on this? It's been almost a year since the bug was reported and no one touched it yet.

Show
Daniel Serodio added a comment - 08/Dec/05 7:14 AM Any news on this? It's been almost a year since the bug was reported and no one touched it yet.
Hide
Permalink
Ted Bergeron added a comment - 12/Jun/07 4:23 PM

It's been close to 2.5 years now. Is this a dead project?

Show
Ted Bergeron added a comment - 12/Jun/07 4:23 PM It's been close to 2.5 years now. Is this a dead project?
Hide
Permalink
Libor Tvrdík added a comment - 09/Oct/07 8:24 AM

I use 1.6.3 and 1.7-20070527.154641-2 version.

This is stack trace:

Exception in thread "main" com.thoughtworks.qdox.parser.ParseException: 
    syntax error @[35,20] in file:/...myclass.....java
	at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:716)
	at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:826)
	at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:697)
        ... my class
Show
Libor Tvrdík added a comment - 09/Oct/07 8:24 AM I use 1.6.3 and 1.7-20070527.154641-2 version. This is stack trace:
Exception in thread "main" com.thoughtworks.qdox.parser.ParseException: 
    syntax error @[35,20] in file:/...myclass.....java
	at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:716)
	at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:826)
	at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:697)
        ... my class
Hide
Permalink
Andrew Mickish added a comment - 19/Feb/08 8:59 AM

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.

Show
Andrew Mickish added a comment - 19/Feb/08 8:59 AM 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.
Hide
Permalink
Andrew Mickish added a comment - 19/Feb/08 9:00 AM

Expose enum members to the model as fields

Show
Andrew Mickish added a comment - 19/Feb/08 9:00 AM Expose enum members to the model as fields
Hide
Permalink
Paul Hammant added a comment - 19/Feb/08 10:04 AM

Andrew. Thanks for the patch.

If you can also supply a unit test that illustrates/proves the enum case, then we'll apply it

  • Paul
Show
Paul Hammant added a comment - 19/Feb/08 10:04 AM Andrew. Thanks for the patch. If you can also supply a unit test that illustrates/proves the enum case, then we'll apply it
  • Paul
Hide
Permalink
Andrew Mickish added a comment - 25/Feb/08 3:56 PM

EnumsModelTest.java is a sequel to EnumsTest.java, showing that parsed enums are accessed like fields in the QDox model.

Show
Andrew Mickish added a comment - 25/Feb/08 3:56 PM EnumsModelTest.java is a sequel to EnumsTest.java, showing that parsed enums are accessed like fields in the QDox model.
Hide
Permalink
Arnaud Vandyck added a comment - 12/Nov/08 4:01 AM

Hi,

Have those patches been applied? I'd like to use this feature in a project. Which release can I get to use this?

Many thanks for your cool project!

Show
Arnaud Vandyck added a comment - 12/Nov/08 4:01 AM Hi, Have those patches been applied? I'd like to use this feature in a project. Which release can I get to use this? Many thanks for your cool project!
Hide
Permalink
Paul Hammant added a comment - 12/Nov/08 8:21 AM

Unfortunately the tests fail for the patch and unit test above :

-------------------------------------------------------------------------------
Test set: com.thoughtworks.qdox.EnumsModelTest
-------------------------------------------------------------------------------
Tests run: 6, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec <<< FAILURE!
testAddEnumWithAnnotationToModel(com.thoughtworks.qdox.EnumsModelTest) Time elapsed: 0.008 sec <<< FAILURE!
junit.framework.AssertionFailedError: expected:<1> but was:<0>
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.failNotEquals(Assert.java:282)
at junit.framework.Assert.assertEquals(Assert.java:64)
at junit.framework.Assert.assertEquals(Assert.java:201)
at junit.framework.Assert.assertEquals(Assert.java:207)
at com.thoughtworks.qdox.EnumsModelTest.testAddEnumWithAnnotationToModel(EnumsModelTest.java:113)

testAddEnumWithFieldAndConstructorsToModel(com.thoughtworks.qdox.EnumsModelTest) Time elapsed: 0.002 sec <<< FAILURE!
junit.framework.AssertionFailedError: expected:<1> but was:<0>
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.failNotEquals(Assert.java:282)
at junit.framework.Assert.assertEquals(Assert.java:64)
at junit.framework.Assert.assertEquals(Assert.java:201)
at junit.framework.Assert.assertEquals(Assert.java:207)
at com.thoughtworks.qdox.EnumsModelTest.testAddEnumWithFieldAndConstructorsToModel(EnumsModelTest.java:162)

Show
Paul Hammant added a comment - 12/Nov/08 8:21 AM Unfortunately the tests fail for the patch and unit test above : ------------------------------------------------------------------------------- Test set: com.thoughtworks.qdox.EnumsModelTest ------------------------------------------------------------------------------- Tests run: 6, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec <<< FAILURE! testAddEnumWithAnnotationToModel(com.thoughtworks.qdox.EnumsModelTest) Time elapsed: 0.008 sec <<< FAILURE! junit.framework.AssertionFailedError: expected:<1> but was:<0> at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.failNotEquals(Assert.java:282) at junit.framework.Assert.assertEquals(Assert.java:64) at junit.framework.Assert.assertEquals(Assert.java:201) at junit.framework.Assert.assertEquals(Assert.java:207) at com.thoughtworks.qdox.EnumsModelTest.testAddEnumWithAnnotationToModel(EnumsModelTest.java:113) testAddEnumWithFieldAndConstructorsToModel(com.thoughtworks.qdox.EnumsModelTest) Time elapsed: 0.002 sec <<< FAILURE! junit.framework.AssertionFailedError: expected:<1> but was:<0> at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.failNotEquals(Assert.java:282) at junit.framework.Assert.assertEquals(Assert.java:64) at junit.framework.Assert.assertEquals(Assert.java:201) at junit.framework.Assert.assertEquals(Assert.java:207) at com.thoughtworks.qdox.EnumsModelTest.testAddEnumWithFieldAndConstructorsToModel(EnumsModelTest.java:162)
Hide
Permalink
Andrew Mickish added a comment - 12/Nov/08 10:07 AM

These tests verify that we can access enum fields in the model.
This is a sequel to EnumsTest.java.

Show
Andrew Mickish added a comment - 12/Nov/08 10:07 AM These tests verify that we can access enum fields in the model. This is a sequel to EnumsTest.java.
Hide
Permalink
Andrew Mickish added a comment - 12/Nov/08 10:11 AM

The first version of EnumsModelTest.java that I submitted was too ambitious. It illustrated continued failure to associate annotations with enums.

However, despite not being able to annotate enums, the rest of the test was successful.

I have resubmitted a new version of EnumsModelTest.java that tests all the same things, except for the annotation of enums. It passes all tests.

The parser.y.diff patch is unchanged.

Show
Andrew Mickish added a comment - 12/Nov/08 10:11 AM The first version of EnumsModelTest.java that I submitted was too ambitious. It illustrated continued failure to associate annotations with enums. However, despite not being able to annotate enums, the rest of the test was successful. I have resubmitted a new version of EnumsModelTest.java that tests all the same things, except for the annotation of enums. It passes all tests. The parser.y.diff patch is unchanged.
Hide
Permalink
Andrew Mickish added a comment - 12/Nov/08 10:18 AM

By request, I have re-created the patch from the same directory as the pom.xml.

Show
Andrew Mickish added a comment - 12/Nov/08 10:18 AM By request, I have re-created the patch from the same directory as the pom.xml.
Hide
Permalink
Mauro Talevi added a comment - 12/Nov/08 2:20 PM

Applied patch - which now passes all unit tests. Thanks!

Show
Mauro Talevi added a comment - 12/Nov/08 2:20 PM Applied patch - which now passes all unit tests. Thanks!
Hide
Permalink
Paul Hammant added a comment - 12/Nov/08 10:38 PM

yay!

Show
Paul Hammant added a comment - 12/Nov/08 10:38 PM yay!

People

  • Assignee:
    Unassigned
    Reporter:
    Joe Walnes
Vote (4)
Watch (5)

Dates

  • Created:
    03/Jan/05 1:54 PM
    Updated:
    12/Nov/08 10:38 PM
    Resolved:
    12/Nov/08 2:20 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.