[
https://issues.apache.org/jira/browse/GROOVY-8835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Anton Pryamostanov updated GROOVY-8835:
---------------------------------------
Comment: was deleted
(was: Many thanks [~paulk], I retested the above example on snapshots (3.0.0
and 2.5.3), it works ok now.
Closing this issue.)
> 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
> Assignee: Paul King
> Priority: Minor
> Labels: inspect
> Fix For: 3.0.0-alpha-4, 2.5.3
>
>
> 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)