package stmt import ( "github.com/z7zmey/php-parser/comment" "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/position" "github.com/z7zmey/php-parser/walker" ) // TraitUsePrecedence node type TraitUsePrecedence struct { Comments []*comment.Comment Position *position.Position Ref node.Node Insteadof []node.Node } // NewTraitUsePrecedence node constructor func NewTraitUsePrecedence(Ref node.Node, Insteadof []node.Node) *TraitUsePrecedence { return &TraitUsePrecedence{ Ref: Ref, Insteadof: Insteadof, } } // SetPosition sets node position func (n *TraitUsePrecedence) SetPosition(p *position.Position) { n.Position = p } // GetPosition returns node positions func (n *TraitUsePrecedence) GetPosition() *position.Position { return n.Position } func (n *TraitUsePrecedence) AddComments(cc []*comment.Comment, tn comment.TokenName) { for _, c := range cc { c.SetTokenName(tn) } n.Comments = append(n.Comments, cc...) } func (n *TraitUsePrecedence) GetComments() []*comment.Comment { return n.Comments } // Attributes returns node attributes as map func (n *TraitUsePrecedence) Attributes() map[string]interface{} { return nil } // Walk traverses nodes // Walk is invoked recursively until v.EnterNode returns true func (n *TraitUsePrecedence) Walk(v walker.Visitor) { if v.EnterNode(n) == false { return } if n.Ref != nil { v.EnterChildNode("Ref", n) n.Ref.Walk(v) v.LeaveChildNode("Ref", n) } if n.Insteadof != nil { v.EnterChildList("Insteadof", n) for _, nn := range n.Insteadof { if nn != nil { nn.Walk(v) } } v.LeaveChildList("Insteadof", n) } v.LeaveNode(n) }