#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 cast
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 (
// Array node
type Array struct {
Comments []*comment.Comment
Position *position.Position
Expr node.Node
}
@@ -29,6 +31,17 @@ func (n *Array) GetPosition() *position.Position {
return n.Position
}
func (n *Array) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Array) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Array) Attributes() map[string]interface{} {
return nil

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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