create token name constants in comment package
This commit is contained in:
@@ -3,6 +3,7 @@ package parser
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/comment"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/scanner"
|
||||
)
|
||||
|
||||
// Comments a collection of comment groups assigned to nodes
|
||||
@@ -12,3 +13,18 @@ type Comments map[node.Node][]*comment.Comment
|
||||
func (c Comments) AddComments(node node.Node, comments []*comment.Comment) {
|
||||
c[node] = append(c[node], comments...)
|
||||
}
|
||||
|
||||
func (c Comments) AddFromToken(node node.Node, token *scanner.Token, tokenName comment.TokenName) {
|
||||
comments := token.Comments()
|
||||
|
||||
for _, cmt := range comments {
|
||||
cmt.SetTokenName(tokenName)
|
||||
}
|
||||
|
||||
c.AddComments(node, comments)
|
||||
}
|
||||
|
||||
func (c Comments) AddFromChildNode(n node.Node, ch node.Node) {
|
||||
c.AddComments(n, c[ch])
|
||||
delete(c, ch)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user