#25: save comments within node
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package name
|
||||
|
||||
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 (
|
||||
|
||||
// FullyQualified node
|
||||
type FullyQualified struct {
|
||||
Comments []*comment.Comment
|
||||
Position *position.Position
|
||||
Parts []node.Node
|
||||
}
|
||||
@@ -29,6 +31,17 @@ func (n *FullyQualified) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *FullyQualified) AddComments(cc []*comment.Comment, tn comment.TokenName) {
|
||||
for _, c := range cc {
|
||||
c.SetTokenName(tn)
|
||||
}
|
||||
n.Comments = append(n.Comments, cc...)
|
||||
}
|
||||
|
||||
func (n *FullyQualified) GetComments() []*comment.Comment {
|
||||
return n.Comments
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *FullyQualified) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package name
|
||||
|
||||
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 (
|
||||
|
||||
// Name node
|
||||
type Name struct {
|
||||
Comments []*comment.Comment
|
||||
Position *position.Position
|
||||
Parts []node.Node
|
||||
}
|
||||
@@ -29,6 +31,17 @@ func (n *Name) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Name) AddComments(cc []*comment.Comment, tn comment.TokenName) {
|
||||
for _, c := range cc {
|
||||
c.SetTokenName(tn)
|
||||
}
|
||||
n.Comments = append(n.Comments, cc...)
|
||||
}
|
||||
|
||||
func (n *Name) GetComments() []*comment.Comment {
|
||||
return n.Comments
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *Name) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package name
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/comment"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// NamePart node
|
||||
type NamePart struct {
|
||||
Comments []*comment.Comment
|
||||
Position *position.Position
|
||||
Value string
|
||||
}
|
||||
@@ -28,6 +30,17 @@ func (n *NamePart) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *NamePart) AddComments(cc []*comment.Comment, tn comment.TokenName) {
|
||||
for _, c := range cc {
|
||||
c.SetTokenName(tn)
|
||||
}
|
||||
n.Comments = append(n.Comments, cc...)
|
||||
}
|
||||
|
||||
func (n *NamePart) GetComments() []*comment.Comment {
|
||||
return n.Comments
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *NamePart) Attributes() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package name
|
||||
|
||||
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 (
|
||||
|
||||
// Relative node
|
||||
type Relative struct {
|
||||
Comments []*comment.Comment
|
||||
Position *position.Position
|
||||
Parts []node.Node
|
||||
}
|
||||
@@ -29,6 +31,17 @@ func (n *Relative) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Relative) AddComments(cc []*comment.Comment, tn comment.TokenName) {
|
||||
for _, c := range cc {
|
||||
c.SetTokenName(tn)
|
||||
}
|
||||
n.Comments = append(n.Comments, cc...)
|
||||
}
|
||||
|
||||
func (n *Relative) GetComments() []*comment.Comment {
|
||||
return n.Comments
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *Relative) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user