- Revision
- 698
- Author
- rfscholte
- Date
- 2010-01-09 13:54:57 -0600 (Sat, 09 Jan 2010)
Log Message
Fix for QDOX-191: operator in constructor of a new Object
Modified Paths
Diff
Modified: trunk/qdox/src/grammar/lexer.flex (697 => 698)
--- trunk/qdox/src/grammar/lexer.flex 2010-01-08 17:20:21 UTC (rev 697) +++ trunk/qdox/src/grammar/lexer.flex 2010-01-09 19:54:57 UTC (rev 698) @@ -15,6 +15,7 @@ %{ private int classDepth = 0; + private int parenDepth = 0; private int nestingDepth = 0; private int annotationDepth = 0; private int assignmentDepth = 0; @@ -63,6 +64,15 @@ yybegin(stateStack[--stateDepth]); } + private int peekState(int relative) { + if(relative > stateDepth) { + return -1; + } + else { + return stateStack[stateDepth - relative]; + } + } + public String getCodeBody(){ String s = codeBody.toString(); codeBody = new StringBuffer(8192); @@ -227,9 +237,10 @@ return Parser.PARENOPEN; } else { - if(isConstructor) { + parenDepth = classDepth; pushState(PARENBLOCK); + return Parser.PARENBLOCK; } else { return Parser.PARENOPEN; @@ -351,12 +362,15 @@ } <PARENBLOCK> { - "(" { nestingDepth++; } - ")" { + "(" { + nestingDepth++; + if (appendingToCodeBody) { codeBody.append("("); } + } + ")" { nestingDepth--; - if (nestingDepth == classDepth) { + if (appendingToCodeBody) { codeBody.append(")"); } + if (nestingDepth == parenDepth) { popState(); - return Parser.PARENBLOCK; } } } @@ -396,7 +410,11 @@ } } - "(" { codeBody.append('('); nestingDepth++; } + "(" { + codeBody.append('('); + parenDepth = nestingDepth++; + pushState(PARENBLOCK); + } ")" { codeBody.append(')'); nestingDepth--;
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/JavaDocBuilderTest.java (697 => 698)
--- trunk/qdox/src/test/com/thoughtworks/qdox/JavaDocBuilderTest.java 2010-01-08 17:20:21 UTC (rev 697) +++ trunk/qdox/src/test/com/thoughtworks/qdox/JavaDocBuilderTest.java 2010-01-09 19:54:57 UTC (rev 698) @@ -1197,6 +1197,16 @@ JavaSource src = "" StringReader(source)); assertEquals( "comment 2", src.getClasses()[0].getFieldByName( "JDK1_2" ).getComment() ); } + + //for QDOX-191 + public void testLeftShift() { + JavaDocBuilder builder = new JavaDocBuilder(); + String source = + "private static class Flags {\n" + + " static final Flags LEFT_JUSTIFY = new Flags(1 << 0);\n" + + "}\n"; + builder.addSource(new StringReader(source)); + } public void _testSharedPackageJavaClasses() { String source1 = "@javax.xml.bind.annotation.XmlSchema(namespace = \"http://docs.oasis-open.org/wsn/br-2\")\n" +
To unsubscribe from this list please visit: