node attributes

This commit is contained in:
vadim
2017-12-29 17:20:24 +02:00
parent 722fa00fa3
commit 70a4ef18ab
159 changed files with 2214 additions and 1682 deletions

View File

@@ -20,3 +20,7 @@ func NewFullyQualified(parts []node.Node) node.Node {
func (n FullyQualified) Name() string {
return "FullyQualified"
}
func (n FullyQualified) Attributes() map[string]interface{} {
return nil
}

View File

@@ -4,10 +4,6 @@ import (
"github.com/z7zmey/php-parser/node"
)
func (n NameNode) Name() string {
return "Name"
}
type NameNode struct {
name string
parts []node.Node
@@ -20,6 +16,14 @@ func NewName(parts []node.Node) node.Node {
}
}
func (n NameNode) Name() string {
return "Name"
}
func (n NameNode) Attributes() map[string]interface{} {
return nil
}
func (n NameNode) Walk(v node.Visitor) {
if v.EnterNode(n) == false {
return
@@ -31,4 +35,6 @@ func (n NameNode) Walk(v node.Visitor) {
nn.Walk(vv)
}
}
v.LeaveNode(n)
}

View File

@@ -2,23 +2,28 @@ package name
import (
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type NamePart struct {
name string
attributes map[string]interface{}
}
func NewNamePart(value string) node.Node {
return NamePart{
"NamePart",
map[string]interface{}{
"value": value,
},
}
}
func (n NamePart) Name() string {
return "NamePart"
}
type NamePart struct {
name string
token token.Token
}
func NewNamePart(token token.Token) node.Node {
return NamePart{
"NamePart",
token,
}
func (n NamePart) Attributes() map[string]interface{} {
return n.attributes
}
func (n NamePart) Walk(v node.Visitor) {
@@ -26,5 +31,5 @@ func (n NamePart) Walk(v node.Visitor) {
return
}
v.Scalar("token", n.token.Value)
v.LeaveNode(n)
}

View File

@@ -20,3 +20,7 @@ func NewRelative(parts []node.Node) node.Node {
func (n Relative) Name() string {
return "Relative"
}
func (n Relative) Attributes() map[string]interface{} {
return nil
}