#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,11 +30,12 @@ func (n *Encapsed) Walk(v walker.Visitor) {
}
if n.Parts != nil {
vv := v.GetChildrenVisitor("Parts")
v.EnterChildList("Parts", n)
for _, nn := range n.Parts {
if nn != nil {
nn.Walk(vv)
nn.Walk(v)
}
}
v.LeaveChildList("Parts", n)
}
}

View File

@@ -34,11 +34,12 @@ func (n *Heredoc) Walk(v walker.Visitor) {
}
if n.Parts != nil {
vv := v.GetChildrenVisitor("Parts")
v.EnterChildList("Parts", n)
for _, nn := range n.Parts {
if nn != nil {
nn.Walk(vv)
nn.Walk(v)
}
}
v.LeaveChildList("Parts", n)
}
}

View File

@@ -58,11 +58,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 TestNameVisitorDisableChildren(t *testing.T) {
for _, tt := range nameNodesTests {