walker
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package name
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
@@ -23,13 +20,15 @@ func NewName(parts []node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n NameNode) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v", indent, n.name)
|
||||
func (n NameNode) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
if n.parts != nil {
|
||||
fmt.Fprintf(out, "\n%vparts:", indent+" ")
|
||||
vv := v.Children("parts")
|
||||
for _, nn := range n.parts {
|
||||
nn.Print(out, indent+" ")
|
||||
nn.Walk(vv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package name
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n NamePart) Name() string {
|
||||
func (n NamePart) Name() string {
|
||||
return "NamePart"
|
||||
}
|
||||
|
||||
@@ -24,6 +21,10 @@ func NewNamePart(token token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n NamePart) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
|
||||
func (n NamePart) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user