#25: save comments within node

This commit is contained in:
z7zmey
2018-06-25 15:38:31 +03:00
parent 1ebb0c6fad
commit 3cd45ecac5
183 changed files with 16743 additions and 14671 deletions

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Assign node
type Assign struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Assign) GetPosition() *position.Position {
return n.Position
}
func (n *Assign) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Assign) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Assign) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Reference node
type Reference struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Reference) GetPosition() *position.Position {
return n.Position
}
func (n *Reference) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Reference) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Reference) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// BitwiseAnd node
type BitwiseAnd struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseAnd) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *BitwiseAnd) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *BitwiseAnd) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// BitwiseOr node
type BitwiseOr struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *BitwiseOr) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseOr) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *BitwiseOr) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *BitwiseOr) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// BitwiseXor node
type BitwiseXor struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *BitwiseXor) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseXor) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *BitwiseXor) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *BitwiseXor) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Concat node
type Concat struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Concat) GetPosition() *position.Position {
return n.Position
}
func (n *Concat) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Concat) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Concat) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Div node
type Div struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Div) GetPosition() *position.Position {
return n.Position
}
func (n *Div) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Div) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Div) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Minus node
type Minus struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Minus) GetPosition() *position.Position {
return n.Position
}
func (n *Minus) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Minus) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Minus) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Mod node
type Mod struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Mod) GetPosition() *position.Position {
return n.Position
}
func (n *Mod) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Mod) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Mod) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Mul node
type Mul struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Mul) GetPosition() *position.Position {
return n.Position
}
func (n *Mul) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Mul) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Mul) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Plus node
type Plus struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Plus) GetPosition() *position.Position {
return n.Position
}
func (n *Plus) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Plus) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Plus) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// Pow node
type Pow struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *Pow) GetPosition() *position.Position {
return n.Position
}
func (n *Pow) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Pow) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Pow) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// ShiftLeft node
type ShiftLeft struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *ShiftLeft) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftLeft) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *ShiftLeft) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *ShiftLeft) Attributes() map[string]interface{} {
return nil

View File

@@ -1,6 +1,7 @@
package assign
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"
@@ -8,6 +9,7 @@ import (
// ShiftRight node
type ShiftRight struct {
Comments []*comment.Comment
Position *position.Position
Variable node.Node
Expression node.Node
@@ -31,6 +33,17 @@ func (n *ShiftRight) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftRight) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *ShiftRight) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *ShiftRight) Attributes() map[string]interface{} {
return nil