From e3ed427fac8fbd4faa4565e4dfc1abb0b18d60b9 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Tue, 20 Feb 2018 19:52:07 +0200 Subject: [PATCH] rename Walker to Walkable interface --- node/expr/assign/t_visitor_test.go | 4 ++-- node/expr/binary/t_visitor_test.go | 4 ++-- node/expr/cast/t_visitor_test.go | 4 ++-- node/expr/t_visitor_test.go | 4 ++-- node/name/t_visitor_test.go | 4 ++-- node/node.go | 2 +- node/scalar/t_visitor_test.go | 4 ++-- node/stmt/t_visitor_test.go | 4 ++-- node/t_visitor_test.go | 4 ++-- visitor/dumper.go | 6 +++--- walker/walker.go | 8 ++++---- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/node/expr/assign/t_visitor_test.go b/node/expr/assign/t_visitor_test.go index daa9f26..deb8d7a 100644 --- a/node/expr/assign/t_visitor_test.go +++ b/node/expr/assign/t_visitor_test.go @@ -137,12 +137,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { diff --git a/node/expr/binary/t_visitor_test.go b/node/expr/binary/t_visitor_test.go index f4c1a67..72749c7 100644 --- a/node/expr/binary/t_visitor_test.go +++ b/node/expr/binary/t_visitor_test.go @@ -240,12 +240,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { diff --git a/node/expr/cast/t_visitor_test.go b/node/expr/cast/t_visitor_test.go index c4f5e94..198f36b 100644 --- a/node/expr/cast/t_visitor_test.go +++ b/node/expr/cast/t_visitor_test.go @@ -73,12 +73,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { diff --git a/node/expr/t_visitor_test.go b/node/expr/t_visitor_test.go index e4449f2..9c39154 100644 --- a/node/expr/t_visitor_test.go +++ b/node/expr/t_visitor_test.go @@ -360,12 +360,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { diff --git a/node/name/t_visitor_test.go b/node/name/t_visitor_test.go index 8a4fd1e..38a7a64 100644 --- a/node/name/t_visitor_test.go +++ b/node/name/t_visitor_test.go @@ -43,12 +43,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestNameVisitorDisableChildren(t *testing.T) { for _, tt := range nameNodesTests { diff --git a/node/node.go b/node/node.go index 10c5ec9..f37732a 100644 --- a/node/node.go +++ b/node/node.go @@ -4,6 +4,6 @@ import "github.com/z7zmey/php-parser/walker" // Node interface type Node interface { - walker.Walker + walker.Walkable Attributes() map[string]interface{} // Attributes returns node attributes as map } diff --git a/node/scalar/t_visitor_test.go b/node/scalar/t_visitor_test.go index 6a9d75a..db9a465 100644 --- a/node/scalar/t_visitor_test.go +++ b/node/scalar/t_visitor_test.go @@ -52,12 +52,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestNameVisitorDisableChildren(t *testing.T) { for _, tt := range nameNodesTests { diff --git a/node/stmt/t_visitor_test.go b/node/stmt/t_visitor_test.go index d4ffa07..85b185a 100644 --- a/node/stmt/t_visitor_test.go +++ b/node/stmt/t_visitor_test.go @@ -486,12 +486,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { diff --git a/node/t_visitor_test.go b/node/t_visitor_test.go index a8c3ac4..1fc3545 100644 --- a/node/t_visitor_test.go +++ b/node/t_visitor_test.go @@ -51,12 +51,12 @@ type visitorMock struct { visitedKeys []string } -func (v *visitorMock) EnterNode(n walker.Walker) bool { return v.visitChildren } +func (v *visitorMock) EnterNode(n walker.Walkable) bool { return v.visitChildren } func (v *visitorMock) GetChildrenVisitor(key string) walker.Visitor { v.visitedKeys = append(v.visitedKeys, key) return &visitorMock{v.visitChildren, nil} } -func (v *visitorMock) LeaveNode(n walker.Walker) {} +func (v *visitorMock) LeaveNode(n walker.Walkable) {} func TestNameVisitorDisableChildren(t *testing.T) { for _, tt := range nodesToTest { diff --git a/visitor/dumper.go b/visitor/dumper.go index 8e3995c..6a0c593 100644 --- a/visitor/dumper.go +++ b/visitor/dumper.go @@ -11,7 +11,7 @@ import ( "github.com/z7zmey/php-parser/walker" ) -func isWalkerImplementsNodeInterface(w walker.Walker) bool { +func isWalkerImplementsNodeInterface(w walker.Walkable) bool { switch w.(type) { case node.Node: return true @@ -29,7 +29,7 @@ type Dumper struct { } // EnterNode is invoked at every node in heirerchy -func (d Dumper) EnterNode(w walker.Walker) bool { +func (d Dumper) EnterNode(w walker.Walkable) bool { if !isWalkerImplementsNodeInterface(w) { return false } @@ -62,6 +62,6 @@ func (d Dumper) GetChildrenVisitor(key string) walker.Visitor { } // LeaveNode is invoked after node process -func (d Dumper) LeaveNode(n walker.Walker) { +func (d Dumper) LeaveNode(n walker.Walkable) { // do nothing } diff --git a/walker/walker.go b/walker/walker.go index 034a6cd..9cd41a7 100644 --- a/walker/walker.go +++ b/walker/walker.go @@ -1,13 +1,13 @@ package walker -// Walker interface -type Walker interface { +// Walkable interface +type Walkable interface { Walk(v Visitor) } // Visitor interface type Visitor interface { - EnterNode(w Walker) bool // EnterNode invoked for each node encountered by Walk. + EnterNode(w Walkable) bool // EnterNode invoked for each node encountered by Walk. GetChildrenVisitor(Key string) Visitor // GetChildrenVisitor returns visitor for children nodes - LeaveNode(w Walker) // LeaveNode invoked after process node + LeaveNode(w Walkable) // LeaveNode invoked after process node }