2017-12-09 11:41:08 +00:00
|
|
|
package stmt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
"github.com/z7zmey/php-parser/token"
|
|
|
|
)
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
func(n Use) Name() string {
|
|
|
|
return "Use"
|
|
|
|
}
|
|
|
|
|
2017-12-09 11:41:08 +00:00
|
|
|
type Use struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
2017-12-09 11:41:08 +00:00
|
|
|
useType node.Node
|
2017-12-27 17:55:58 +00:00
|
|
|
use node.Node
|
2017-12-09 11:41:08 +00:00
|
|
|
alias token.TokenInterface
|
|
|
|
}
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
func NewUse(useType node.Node, use node.Node, alias token.TokenInterface) node.Node {
|
2017-12-09 11:41:08 +00:00
|
|
|
return Use{
|
2017-12-27 17:55:58 +00:00
|
|
|
"Use",
|
2017-12-09 11:41:08 +00:00
|
|
|
useType,
|
2017-12-27 17:55:58 +00:00
|
|
|
use,
|
2017-12-09 11:41:08 +00:00
|
|
|
alias,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Use) SetType(useType node.Node) node.Node {
|
|
|
|
n.useType = useType
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Use) Print(out io.Writer, indent string) {
|
2017-12-27 17:55:58 +00:00
|
|
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
|
2017-12-09 11:41:08 +00:00
|
|
|
|
|
|
|
if n.useType != nil {
|
2017-12-09 11:50:01 +00:00
|
|
|
fmt.Fprintf(out, "\n%vtype:", indent+" ")
|
2017-12-09 11:41:08 +00:00
|
|
|
n.useType.Print(out, indent+" ")
|
|
|
|
}
|
|
|
|
|
2017-12-27 17:55:58 +00:00
|
|
|
if n.use != nil {
|
|
|
|
fmt.Fprintf(out, "\n%vuse:", indent+" ")
|
|
|
|
n.use.Print(out, indent+" ")
|
2017-12-09 11:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if n.alias != nil {
|
|
|
|
fmt.Fprintf(out, "\n%valias: %q", indent+" ", n.alias.GetValue())
|
|
|
|
}
|
|
|
|
}
|