update dumper.go comments
This commit is contained in:
parent
538cf34777
commit
1db53be4ae
@ -10,12 +10,15 @@ import (
|
|||||||
"github.com/z7zmey/php-parser/node"
|
"github.com/z7zmey/php-parser/node"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Dumper prints ast hierarchy to stdout
|
||||||
|
// Also prints comments and positions attached to nodes
|
||||||
type Dumper struct {
|
type Dumper struct {
|
||||||
Indent string
|
Indent string
|
||||||
Comments comment.Comments
|
Comments comment.Comments
|
||||||
Positions position.Positions
|
Positions position.Positions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnterNode is invoked at every node in heirerchy
|
||||||
func (d Dumper) EnterNode(n node.Node) bool {
|
func (d Dumper) EnterNode(n node.Node) bool {
|
||||||
|
|
||||||
fmt.Printf("%v%v", d.Indent, reflect.TypeOf(n))
|
fmt.Printf("%v%v", d.Indent, reflect.TypeOf(n))
|
||||||
@ -37,11 +40,13 @@ func (d Dumper) EnterNode(n node.Node) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetChildrenVisitor is invoked at every node parameter that contains children nodes
|
||||||
func (d Dumper) GetChildrenVisitor(key string) node.Visitor {
|
func (d Dumper) GetChildrenVisitor(key string) node.Visitor {
|
||||||
fmt.Printf("%v%q:\n", d.Indent+" ", key)
|
fmt.Printf("%v%q:\n", d.Indent+" ", key)
|
||||||
return Dumper{d.Indent + " ", d.Comments, d.Positions}
|
return Dumper{d.Indent + " ", d.Comments, d.Positions}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LeaveNode is invoked after node process
|
||||||
func (d Dumper) LeaveNode(n node.Node) {
|
func (d Dumper) LeaveNode(n node.Node) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user