property_fetch static_property_fetch nodes
This commit is contained in:
36
node/expr/property_fetch.go
Normal file
36
node/expr/property_fetch.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type PropertyFetch struct {
|
||||
node.SimpleNode
|
||||
variable node.Node
|
||||
name node.Node
|
||||
}
|
||||
|
||||
func NewPropertyFetch(variable node.Node, name node.Node) node.Node {
|
||||
return PropertyFetch{
|
||||
node.SimpleNode{Name: "PropertyFetch", Attributes: make(map[string]string)},
|
||||
variable,
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
func (n PropertyFetch) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||
|
||||
if n.variable != nil {
|
||||
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
|
||||
n.variable.Print(out, indent+" ")
|
||||
}
|
||||
|
||||
if n.name != nil {
|
||||
fmt.Fprintf(out, "\n%vname:", indent+" ")
|
||||
n.name.Print(out, indent+" ")
|
||||
}
|
||||
}
|
||||
36
node/expr/static_property_fetch.go
Normal file
36
node/expr/static_property_fetch.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type StaticPropertyFetch struct {
|
||||
node.SimpleNode
|
||||
class node.Node
|
||||
name node.Node
|
||||
}
|
||||
|
||||
func NewStaticPropertyFetch(class node.Node, name node.Node) node.Node {
|
||||
return StaticPropertyFetch{
|
||||
node.SimpleNode{Name: "StaticPropertyFetch", Attributes: make(map[string]string)},
|
||||
class,
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
func (n StaticPropertyFetch) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||
|
||||
if n.class != nil {
|
||||
fmt.Fprintf(out, "\n%vclass:", indent+" ")
|
||||
n.class.Print(out, indent+" ")
|
||||
}
|
||||
|
||||
if n.name != nil {
|
||||
fmt.Fprintf(out, "\n%vname:", indent+" ")
|
||||
n.name.Print(out, indent+" ")
|
||||
}
|
||||
}
|
||||
25
node/identifier.go
Normal file
25
node/identifier.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Identifier struct {
|
||||
SimpleNode
|
||||
name token.Token
|
||||
}
|
||||
|
||||
func NewIdentifier(name token.Token) Node {
|
||||
return Identifier{
|
||||
SimpleNode{Name: "Identifier", Attributes: make(map[string]string)},
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Identifier) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||
fmt.Fprintf(out, "\n%vname: %q", indent+" ", n.name.Value)
|
||||
}
|
||||
Reference in New Issue
Block a user