#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,12 +1,14 @@
package scalar
import (
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// Dnumber node
type Dnumber struct {
Comments []*comment.Comment
Position *position.Position
Value string
}
@@ -28,6 +30,17 @@ func (n *Dnumber) GetPosition() *position.Position {
return n.Position
}
func (n *Dnumber) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Dnumber) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Dnumber) Attributes() map[string]interface{} {
return map[string]interface{}{

View File

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

View File

@@ -1,12 +1,14 @@
package scalar
import (
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// EncapsedStringPart node
type EncapsedStringPart struct {
Comments []*comment.Comment
Position *position.Position
Value string
}
@@ -28,6 +30,17 @@ func (n *EncapsedStringPart) GetPosition() *position.Position {
return n.Position
}
func (n *EncapsedStringPart) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *EncapsedStringPart) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *EncapsedStringPart) Attributes() map[string]interface{} {
return map[string]interface{}{

View File

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

View File

@@ -1,12 +1,14 @@
package scalar
import (
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// Lnumber node
type Lnumber struct {
Comments []*comment.Comment
Position *position.Position
Value string
}
@@ -28,6 +30,17 @@ func (n *Lnumber) GetPosition() *position.Position {
return n.Position
}
func (n *Lnumber) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *Lnumber) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *Lnumber) Attributes() map[string]interface{} {
return map[string]interface{}{

View File

@@ -1,12 +1,14 @@
package scalar
import (
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// MagicConstant node
type MagicConstant struct {
Comments []*comment.Comment
Position *position.Position
Value string
}
@@ -28,6 +30,17 @@ func (n *MagicConstant) GetPosition() *position.Position {
return n.Position
}
func (n *MagicConstant) AddComments(cc []*comment.Comment, tn comment.TokenName) {
for _, c := range cc {
c.SetTokenName(tn)
}
n.Comments = append(n.Comments, cc...)
}
func (n *MagicConstant) GetComments() []*comment.Comment {
return n.Comments
}
// Attributes returns node attributes as map
func (n *MagicConstant) Attributes() map[string]interface{} {
return map[string]interface{}{

View File

@@ -1,12 +1,14 @@
package scalar
import (
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// String node
type String struct {
Comments []*comment.Comment
Position *position.Position
Value string
}
@@ -28,6 +30,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 map[string]interface{}{