[ 
https://issues.apache.org/jira/browse/VELOCITY-832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claude Brisson resolved VELOCITY-832.
-------------------------------------
       Resolution: Done
         Assignee: Claude Brisson
    Fix Version/s: 2.x

Node dump nicified:

{code}
ASTprocess [id=0, info=0, invalid=false, tokens=[#if], [(], [$goo], [)], 
[#set(], [$ak], [=], ['ti...]
 |_ASTIfStatement [id=23, info=0, invalid=false, tokens=[#if], [(], [$goo], 
[)], [#set(], [$ak], [=], ['ti...]
    |_ASTExpression [id=27, info=0, invalid=false, tokens=[$goo]]
    |  |_ASTReference [id=19, info=0, invalid=false, tokens=[$goo]]
    |_ASTBlock [id=13, info=0, invalid=false, tokens=[#set(], [$ak], [=], 
['bar'], [)], [hehe]]
    |  |_ASTSetDirective [id=26, info=0, invalid=false, tokens=[#set(], [$ak], 
[=], ['bar'], [)]]
    |  |  |_ASTReference [id=19, info=0, invalid=false, tokens=[$ak]]
    |  |  |_ASTExpression [id=27, info=0, invalid=false, tokens=['bar']]
    |  |     |_ASTStringLiteral [id=8, info=0, invalid=false, tokens=['bar']]
    |  |_ASTText [id=22, info=0, invalid=false, tokens=[hehe]]
    |_ASTElseStatement [id=24, info=0, invalid=false, tokens=[#{else}], [#if], 
[(], ['foo'], [==], ['bar'], [...]
       |_ASTBlock [id=13, info=0, invalid=false, tokens=[#if], [(], ['foo'], 
[==], ['bar'], [)], [okok],...]
          |_ASTIfStatement [id=23, info=0, invalid=false, tokens=[#if], [(], 
['foo'], [==], ['bar'], [)], [okok],...]
             |_ASTExpression [id=27, info=0, invalid=false, tokens=['foo'], 
[==], ['bar']]
             |  |_ASTEQNode [id=31, info=0, invalid=false, tokens=['bar']]
             |     |_ASTStringLiteral [id=8, info=0, invalid=false, 
tokens=['foo']]
             |     |_ASTStringLiteral [id=8, info=0, invalid=false, 
tokens=['bar']]
             |_ASTBlock [id=13, info=0, invalid=false, tokens=[okok]]
             |  |_ASTText [id=22, info=0, invalid=false, tokens=[okok]]
             |_ASTElseStatement [id=24, info=0, invalid=false, tokens=[#else], 
[$a], [.], [b], [.], [c], [(], ['schmoo'], ...]
                |_ASTBlock [id=13, info=0, invalid=false, tokens=[$a], [.], 
[b], [.], [c], [(], ['schmoo'], [)]]
                   |_ASTReference [id=19, info=0, invalid=false, tokens=[$a], 
[.], [b], [.], [c], [(], ['schmoo'], [)]]
                      |_ASTIdentifier [id=9, info=0, invalid=false, tokens=[b]]
                      |_ASTMethod [id=17, info=0, invalid=false, tokens=[c], 
[(], ['schmoo'], [)]]
                         |_ASTIdentifier [id=9, info=0, invalid=false, 
tokens=[c]]
                         |_ASTExpression [id=27, info=0, invalid=false, 
tokens=['schmoo']]
                            |_ASTStringLiteral [id=8, info=0, invalid=false, 
tokens=['schmoo']]

{code}

>  node dump info easy to read
> ----------------------------
>
>                 Key: VELOCITY-832
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-832
>             Project: Velocity
>          Issue Type: Wish
>          Components: Engine
>    Affects Versions: 1.7
>            Reporter: madding.lip
>            Assignee: Claude Brisson
>            Priority: Trivial
>              Labels: velocity
>             Fix For: 2.x
>
>   Original Estimate: 1m
>  Remaining Estimate: 1m
>
> when I use velocity to find the ast info, I find it difficulty to read the 
> output info。
> e.g.
> vm:
> #if(true)#end
> node dump print:
> SimpleNode [id=0, info=0, invalid=false, children=[SimpleNode [id=23, info=0, 
> invalid=false, children=[SimpleNode [id=27, info=0, invalid=false, 
> children=[SimpleNode [id=20, info=0, invalid=false, children=null, 
> tokens=[true]]], tokens=[true]], SimpleNode [id=13, info=0, invalid=false, 
> children=null, tokens=[#end
> ], [
> ]]], tokens=[#if], [(], [true], [)], [#end
> ]]], tokens=[#if], [(], [true], [)], [#end
> ], [
> ]] -> #if
>   SimpleNode [id=23, info=0, invalid=false, children=[SimpleNode [id=27, 
> info=0, invalid=false, children=[SimpleNode [id=20, info=0, invalid=false, 
> children=null, tokens=[true]]], tokens=[true]], SimpleNode [id=13, info=0, 
> invalid=false, children=null, tokens=[#end
> ], [
> ]]], tokens=[#if], [(], [true], [)], [#end
> ]] -> #if
>     SimpleNode [id=27, info=0, invalid=false, children=[SimpleNode [id=20, 
> info=0, invalid=false, children=null, tokens=[true]]], tokens=[true]] -> true
>       SimpleNode [id=20, info=0, invalid=false, children=null, tokens=[true]] 
> -> true
>     SimpleNode [id=13, info=0, invalid=false, children=null, tokens=[#end
> ], [
> ]] -> #end
> every node is simpleNode, I can find more clear node info.
> after analyze code,wo can change as following:
> SimpleNode (435 line):
> change :
>     return "SimpleNode [id=" + id + ", info=" + info + ", invalid="
> to:
>     return getClass().getSimpleName() + " [id=" + id + ", info=" + info + ", 
> invalid="
> final node dump:
> ASTprocess [id=0, info=0, invalid=false, children=[ASTIfStatement [id=23, 
> info=0, invalid=false, children=[ASTExpression [id=27, info=0, invalid=false, 
> children=[ASTTrue [id=20, info=0, invalid=false, children=null, 
> tokens=[true]]], tokens=[true]], ASTBlock [id=13, info=0, invalid=false, 
> children=null, tokens=[#end
> ], [
> ]]], tokens=[#if], [(], [true], [)], [#end
> ]]], tokens=[#if], [(], [true], [)], [#end
> ], [
> ]] -> #if
>   ASTIfStatement [id=23, info=0, invalid=false, children=[ASTExpression 
> [id=27, info=0, invalid=false, children=[ASTTrue [id=20, info=0, 
> invalid=false, children=null, tokens=[true]]], tokens=[true]], ASTBlock 
> [id=13, info=0, invalid=false, children=null, tokens=[#end
> ], [
> ]]], tokens=[#if], [(], [true], [)], [#end
> ]] -> #if
>     ASTExpression [id=27, info=0, invalid=false, children=[ASTTrue [id=20, 
> info=0, invalid=false, children=null, tokens=[true]]], tokens=[true]] -> true
>       ASTTrue [id=20, info=0, invalid=false, children=null, tokens=[true]] -> 
> true
>     ASTBlock [id=13, info=0, invalid=false, children=null, tokens=[#end
> ], [
> ]] -> #end



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to