- Revision
- 1094
- Author
- rfscholte
- Date
- 2011-02-27 16:35:45 -0600 (Sun, 27 Feb 2011)
Log Message
Let Parser call begin/endConstructor
Modified Paths
- trunk/qdox/src/grammar/parser.y
- trunk/qdox/src/java/com/thoughtworks/qdox/builder/ModelBuilder.java
- trunk/qdox/src/test/com/thoughtworks/qdox/parser/MockBuilder.java
- trunk/qdox/src/test/com/thoughtworks/qdox/parser/ParserTest.java
Diff
Modified: trunk/qdox/src/grammar/parser.y (1093 => 1094)
--- trunk/qdox/src/grammar/parser.y 2011-02-27 20:43:35 UTC (rev 1093) +++ trunk/qdox/src/grammar/parser.y 2011-02-27 22:35:45 UTC (rev 1094) @@ -583,24 +583,24 @@ constructor: modifiers IDENTIFIER { - builder.beginMethod(); + builder.beginConstructor(); mth.lineNumber = lexer.getLine(); mth.modifiers.addAll(modifiers); modifiers.clear(); mth.constructor = true; mth.name = $2; } methoddef opt_exceptions memberend { mth.body = $6; - builder.endMethod(mth); + builder.endConstructor(mth); mth = new MethodDef(); } | modifiers typeparams IDENTIFIER { - builder.beginMethod(); + builder.beginConstructor(); mth.lineNumber = lexer.getLine(); mth.typeParams = typeParams; mth.modifiers.addAll(modifiers); modifiers.clear(); mth.constructor = true; mth.name = $3; } methoddef opt_exceptions memberend { mth.body = $7; - builder.endMethod(mth); + builder.endConstructor(mth); mth = new MethodDef(); };
Modified: trunk/qdox/src/java/com/thoughtworks/qdox/builder/ModelBuilder.java (1093 => 1094)
--- trunk/qdox/src/java/com/thoughtworks/qdox/builder/ModelBuilder.java 2011-02-27 20:43:35 UTC (rev 1093) +++ trunk/qdox/src/java/com/thoughtworks/qdox/builder/ModelBuilder.java 2011-02-27 22:35:45 UTC (rev 1094) @@ -211,22 +211,32 @@ public void beginConstructor() { - currentConstructor = new DefaultJavaConstructor(); - currentConstructor.setParentClass( classStack.getFirst() ); - classStack.getFirst().addConstructor( currentConstructor ); - - currentConstructor.setModelWriterFactory( modelWriterFactory ); - - addJavaDoc( currentConstructor ); - setAnnotations( currentConstructor ); +// currentConstructor = new DefaultJavaConstructor(); + currentMethod = new DefaultJavaMethod(); + currentMethod.setConstructor( true ); + +// currentConstructor.setParentClass( classStack.getFirst() ); + currentMethod.setParentClass( classStack.getFirst() ); +// classStack.getFirst().addConstructor( currentConstructor ); + classStack.getFirst().addMethod( currentMethod ); +// +// currentConstructor.setModelWriterFactory( modelWriterFactory ); + currentMethod.setModelWriterFactory( modelWriterFactory ); +// +// addJavaDoc( currentConstructor ); + addJavaDoc( currentMethod ); +// setAnnotations( currentConstructor ); + setAnnotations( currentMethod ); } public void endConstructor( MethodDef def ) { - currentConstructor.setLineNumber(def.lineNumber); +// currentConstructor.setLineNumber(def.lineNumber); + currentMethod.setLineNumber( def.lineNumber ); // basic details - currentConstructor.setName(def.name); +// currentConstructor.setName(def.name); + currentMethod.setName( def.name ); // typeParameters if (def.typeParams != null) { @@ -234,7 +244,8 @@ for(TypeVariableDef typeVariableDef : def.typeParams) { typeParams.add(createTypeVariable(typeVariableDef)); } - currentConstructor.setTypeParameters(typeParams); +// currentConstructor.setTypeParameters(typeParams); + currentMethod.setTypeParameters( typeParams ); } // exceptions @@ -243,15 +254,16 @@ for (TypeDef type : def.exceptions) { exceptions.add(createType(type, 0)); } - currentConstructor.setExceptions(exceptions); +// currentConstructor.setExceptions(exceptions); + currentMethod.setExceptions( exceptions ); } // modifiers - { - currentConstructor.setModifiers(new LinkedList<String>( def.modifiers )); - } +// currentConstructor.setModifiers(new LinkedList<String>( def.modifiers )); + currentMethod.setModifiers(new LinkedList<String>(def.modifiers) ); - currentConstructor.setSourceCode(def.body); +// currentConstructor.setSourceCode(def.body); + currentMethod.setSourceCode( def.body ); } public void addMethod(MethodDef def) {
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/parser/MockBuilder.java (1093 => 1094)
--- trunk/qdox/src/test/com/thoughtworks/qdox/parser/MockBuilder.java 2011-02-27 20:43:35 UTC (rev 1093) +++ trunk/qdox/src/test/com/thoughtworks/qdox/parser/MockBuilder.java 2011-02-27 22:35:45 UTC (rev 1094) @@ -126,7 +126,11 @@ public void addExpectedAddMethodValues(MethodDef arg0) { myEndMethodParameter0Values.addExpected(arg0); } - + + public void addExpectedAddConstructorValues(MethodDef arg0) { + myEndConstructorParameter0Values.addExpected(arg0); + } + public void endConstructor( MethodDef def ) { myEndConstructorCalls.inc();
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/parser/ParserTest.java (1093 => 1094)
--- trunk/qdox/src/test/com/thoughtworks/qdox/parser/ParserTest.java 2011-02-27 20:43:35 UTC (rev 1093) +++ trunk/qdox/src/test/com/thoughtworks/qdox/parser/ParserTest.java 2011-02-27 22:35:45 UTC (rev 1094) @@ -1560,7 +1560,7 @@ MethodDef mth = new MethodDef(); mth.name = "MyClass"; mth.constructor = true; - builder.addExpectedAddMethodValues(mth); + builder.addExpectedAddConstructorValues(mth); // execute Parser parser = new Parser(lexer, builder); @@ -1597,7 +1597,7 @@ p1.name = "count"; p1.type = new TypeDef("int"); - builder.addExpectedAddMethodValues(mth); + builder.addExpectedAddConstructorValues(mth); builder.addExpectedAddParameterValues( p1 ); // execute @@ -1645,7 +1645,7 @@ p2.name = "thingy"; p2.type = new TypeDef("java.lang.String"); - builder.addExpectedAddMethodValues(mth); + builder.addExpectedAddConstructorValues(mth); builder.addExpectedAddParameterValues( p1 ); builder.addExpectedAddParameterValues( p2 ); @@ -1680,7 +1680,7 @@ mth.constructor = true; mth.exceptions.add(new TypeDef("SomeException")); - builder.addExpectedAddMethodValues(mth); + builder.addExpectedAddConstructorValues(mth); // execute Parser parser = new Parser(lexer, builder); @@ -1720,7 +1720,7 @@ mth.exceptions.add(new TypeDef("SomeException")); mth.exceptions.add(new TypeDef("java.io.IOException")); - builder.addExpectedAddMethodValues(mth); + builder.addExpectedAddConstructorValues(mth); // execute Parser parser = new Parser(lexer, builder);
To unsubscribe from this list please visit:
