php-parser/node/expr/method_call.go

50 lines
903 B
Go
Raw Normal View History

2017-12-18 16:39:04 +00:00
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
2017-12-27 17:55:58 +00:00
func (n MethodCall) Name() string {
return "MethodCall"
}
2017-12-18 16:39:04 +00:00
type MethodCall struct {
2017-12-27 17:55:58 +00:00
name string
2017-12-18 16:39:04 +00:00
variable node.Node
2017-12-27 17:55:58 +00:00
method node.Node
2017-12-18 16:39:04 +00:00
arguments []node.Node
}
2017-12-27 17:55:58 +00:00
func NewMethodCall(variable node.Node, method node.Node, arguments []node.Node) node.Node {
2017-12-18 16:39:04 +00:00
return MethodCall{
2017-12-27 17:55:58 +00:00
"MethodCall",
2017-12-18 16:39:04 +00:00
variable,
2017-12-27 17:55:58 +00:00
method,
2017-12-18 16:39:04 +00:00
arguments,
}
}
func (n MethodCall) 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-18 16:39:04 +00:00
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
}
2017-12-27 17:55:58 +00:00
if n.method != nil {
fmt.Fprintf(out, "\n%vmethod:", indent+" ")
n.method.Print(out, indent+" ")
2017-12-18 16:39:04 +00:00
}
if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ")
for _, nn := range n.arguments {
nn.Print(out, indent+" ")
}
}
}