- Revision
- 598
- Author
- rfscholte
- Date
- 2009-05-13 16:29:20 -0500 (Wed, 13 May 2009)
Log Message
fix for QDOX/162: support annotations for enum constructors
Modified Paths
- trunk/qdox/src/grammar/lexer.flex
- trunk/qdox/src/test/com/thoughtworks/qdox/AnnotationsTest.java
- trunk/qdox/src/test/com/thoughtworks/qdox/parser/LexerTest.java
Diff
Modified: trunk/qdox/src/grammar/lexer.flex (597 => 598)
--- trunk/qdox/src/grammar/lexer.flex 2009-05-12 02:23:00 UTC (rev 597) +++ trunk/qdox/src/grammar/lexer.flex 2009-05-13 21:29:20 UTC (rev 598) @@ -219,11 +219,20 @@ ";" { isConstructor = false; return Parser.SEMI; } "(" { nestingDepth++; - if(isConstructor) { - pushState(PARENBLOCK); + if(parenMode >= 0) { + annotationDepth = nestingDepth; + pushState(parenMode); + parenMode = -1; + return Parser.PARENOPEN; } else { - return Parser.PARENOPEN; + + if(isConstructor) { + pushState(PARENBLOCK); + } + else { + return Parser.PARENOPEN; + } } } }
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/AnnotationsTest.java (597 => 598)
--- trunk/qdox/src/test/com/thoughtworks/qdox/AnnotationsTest.java 2009-05-12 02:23:00 UTC (rev 597) +++ trunk/qdox/src/test/com/thoughtworks/qdox/AnnotationsTest.java 2009-05-13 21:29:20 UTC (rev 598) @@ -216,4 +216,16 @@ builder.addSource(new StringReader(source)); assertEquals("java.lang.Override", builder.getClasses()[0].getMethods()[0].getAnnotations()[0].getType().getValue()); } + + public void testEnumsWithAnnotations() throws Exception { + String source="class Foo {\n" + + " public enum BasicType {\n" + + " @XmlEnumValue(\"text\")\n" + + " TEXT(\"text\"),\n" + + "" + + " @XmlEnumValue(\"value\")\n" + + " VALUE(\"value\") }\n" + + "}"; + builder.addSource(new StringReader(source)); + } }
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/parser/LexerTest.java (597 => 598)
--- trunk/qdox/src/test/com/thoughtworks/qdox/parser/LexerTest.java 2009-05-12 02:23:00 UTC (rev 597) +++ trunk/qdox/src/test/com/thoughtworks/qdox/parser/LexerTest.java 2009-05-13 21:29:20 UTC (rev 598) @@ -716,4 +716,28 @@ assertLex(Parser.STRING_LITERAL, lexer); assertLex(Parser.PARENCLOSE, lexer); } + + public void testEnumWithAnnotations() throws Exception { + String in = "class Foo {\n" + + "public enum BasicType {\n" + + "@XmlEnumValue(\"text\")\n" + + "VALUE(\"value\"); }\n" + + "}"; + Lexer lexer = new JFlexLexer(new StringReader(in)); + assertLex(Parser.CLASS, lexer); + assertLex(Parser.IDENTIFIER, lexer); + assertLex(Parser.BRACEOPEN, lexer); + assertLex(Parser.PUBLIC, lexer); + assertLex(Parser.ENUM, lexer); + assertLex(Parser.IDENTIFIER, lexer); + assertLex(Parser.BRACEOPEN, lexer); + assertLex(Parser.AT, lexer); + assertLex(Parser.IDENTIFIER, lexer); + assertLex(Parser.PARENOPEN, lexer); + assertLex(Parser.STRING_LITERAL, lexer); + assertLex(Parser.PARENCLOSE, lexer); + assertLex(Parser.IDENTIFIER, lexer); + assertLex(Parser.PARENBLOCK, lexer); + assertLex(Parser.SEMI, lexer); + } }
To unsubscribe from this list please visit:
