Description
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