group_use node
This commit is contained in:
59
node/stmt/group_use.go
Normal file
59
node/stmt/group_use.go
Normal file
@@ -0,0 +1,59 @@
|
||||
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+" ")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user