Anton Pryamostanov created GROOVY-8835:
------------------------------------------
Summary: AstNodeToScriptVisitor - no token needed for
EmptyStatement initialization
Key: GROOVY-8835
URL: https://issues.apache.org/jira/browse/GROOVY-8835
Project: Groovy
Issue Type: Bug
Components: Groovy Console, Swing
Affects Versions: 2.5.2
Reporter: Anton Pryamostanov
Consider the following example:
{code:java}
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("\$", ""))
}
}
{code}
Actual result:
{code}
Output: java.lang.Object someVariableName =
{code}
Expected result:
{code}
Output: java.lang.Object someVariableName
{code}
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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)