#31 dump to native golang struct

This commit is contained in:
z7zmey
2018-06-18 23:29:52 +03:00
parent 063726aac4
commit dd572a8fed
173 changed files with 1279 additions and 735 deletions

View File

@@ -30,8 +30,9 @@ func (n *Array) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -30,8 +30,9 @@ func (n *Bool) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -30,8 +30,9 @@ func (n *Double) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -30,8 +30,9 @@ func (n *Int) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -30,8 +30,9 @@ func (n *Object) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -30,8 +30,9 @@ func (n *String) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -30,8 +30,9 @@ func (n *Unset) Walk(v walker.Visitor) {
}
if n.Expr != nil {
vv := v.GetChildrenVisitor("Expr")
n.Expr.Walk(vv)
v.EnterChildNode("Expr", n)
n.Expr.Walk(v)
v.LeaveChildNode("Expr", n)
}
v.LeaveNode(n)

View File

@@ -19,49 +19,49 @@ var nodesToTest = []struct {
}{
{
&cast.Array{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
},
{
&cast.Bool{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
},
{
&cast.Double{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
},
{
&cast.Int{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
},
{
&cast.Object{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
},
{
&cast.String{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
},
{
&cast.Unset{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
@@ -74,11 +74,15 @@ type visitorMock struct {
}
func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren }
func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor {
func (v *visitorMock) LeaveNode(n walker.Walkable) {}
func (v *visitorMock) EnterChildNode(key string, w walker.Walkable) {
v.visitedKeys = append(v.visitedKeys, key)
return &visitorMock{v.visitChildren, nil}
}
func (v *visitorMock) LeaveNode(n walker.Walkable) {}
func (v *visitorMock) LeaveChildNode(key string, w walker.Walkable) {}
func (v *visitorMock) EnterChildList(key string, w walker.Walkable) {
v.visitedKeys = append(v.visitedKeys, key)
}
func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
func TestVisitorDisableChildren(t *testing.T) {
for _, tt := range nodesToTest {