php-parser/node/stmt/group_use.go

60 lines
1.2 KiB
Go
Raw Normal View History

2017-12-07 20:36:53 +00:00
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type GroupUse struct {
node.SimpleNode
token token.TokenInterface
useType node.Node
prefix node.Node
useList []node.Node
}
//TODO: stmts myst be []node.Node
func NewGroupUse(token token.TokenInterface, useType node.Node, prefix node.Node, useList []node.Node) node.Node {
return GroupUse{
node.SimpleNode{Name: "GroupUse", Attributes: make(map[string]string)},
token,
useType,
prefix,
useList,
}
}
func (n GroupUse) SetToken(token token.TokenInterface) node.Node {
n.token = token
return n
}
func (n GroupUse) SetUseType(useType node.Node) node.Node {
n.useType = useType
return n
}
func (n GroupUse) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.GetStartLine(), n.token.GetEndLine(), n.token.GetValue())
if n.useType != nil {
fmt.Fprintf(out, "\n%vuse type:", indent+" ")
n.useType.Print(out, indent+" ")
}
if n.prefix != nil {
fmt.Fprintf(out, "\n%vprefix:", indent+" ")
n.prefix.Print(out, indent+" ")
}
if n.useList != nil {
fmt.Fprintf(out, "\n%vuse list:", indent+" ")
for _, nn := range n.useList {
nn.Print(out, indent+" ")
}
}
}