Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.5.2
Description
Consider the following example:
package groovy import groovy.inspect.swingui.AstNodeToScriptVisitor import org.codehaus.groovy.ast.expr.EmptyExpression import org.codehaus.groovy.ast.tools.GeneralUtils class SandBox { static void main(String[] args) { new SandBox().someMethod() } void someMethod() { StringWriter stringWriter = new StringWriter() GeneralUtils.declS(GeneralUtils.varX("someVariableName"), new EmptyExpression()).visit(new AstNodeToScriptVisitor(stringWriter)) System.out.println("Output: "+stringWriter.getBuffer().toString().replace("\$", "")) } }
Actual result:
Output: java.lang.Object someVariableName =
Expected result:
Output: java.lang.Object someVariableName
When DeclarationExpression (or possibly other BinaryExpression) is initialized with EmptyExpression as "right" expression, AstNodeToScriptVisitor should not output the token ("=" in this example), as there is no corresponding expression printed after the token.