walker pakage
This commit is contained in:
@@ -2,6 +2,7 @@ package name
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// FullyQualified node
|
||||
@@ -23,7 +24,7 @@ func (n *FullyQualified) Attributes() map[string]interface{} {
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *FullyQualified) Walk(v node.Visitor) {
|
||||
func (n *FullyQualified) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package name
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// Name node
|
||||
@@ -23,7 +24,7 @@ func (n *Name) Attributes() map[string]interface{} {
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *Name) Walk(v node.Visitor) {
|
||||
func (n *Name) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package name
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
import "github.com/z7zmey/php-parser/walker"
|
||||
|
||||
// NamePart node
|
||||
type NamePart struct {
|
||||
@@ -25,7 +23,7 @@ func (n *NamePart) Attributes() map[string]interface{} {
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *NamePart) Walk(v node.Visitor) {
|
||||
func (n *NamePart) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
"github.com/z7zmey/php-parser/node/name"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
@@ -124,12 +125,12 @@ type visitorMock struct {
|
||||
visitedKeys []string
|
||||
}
|
||||
|
||||
func (v *visitorMock) EnterNode(n node.Node) bool { return v.visitChildren }
|
||||
func (v *visitorMock) GetChildrenVisitor(key string) node.Visitor {
|
||||
func (v *visitorMock) EnterNode(n walker.Walker) 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 node.Node) {}
|
||||
func (v *visitorMock) LeaveNode(n walker.Walker) {}
|
||||
|
||||
func TestNameVisitorDisableChildren(t *testing.T) {
|
||||
for _, tt := range nameNodesTests {
|
||||
|
||||
@@ -2,6 +2,7 @@ package name
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// Relative node
|
||||
@@ -23,7 +24,7 @@ func (n *Relative) Attributes() map[string]interface{} {
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *Relative) Walk(v node.Visitor) {
|
||||
func (n *Relative) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user