handle comments

This commit is contained in:
vadim
2018-01-05 17:03:59 +02:00
parent cd34d41218
commit 21c0c7c86e
167 changed files with 3547 additions and 1567 deletions

View File

@@ -1,9 +1,15 @@
package token
import (
"github.com/z7zmey/php-parser/comment"
)
type TokenInterface interface {
GetValue() string
GetStartLine() int
GetEndLine() int
Comments() []comment.Comment
SetComments(comments []comment.Comment) Token
}
type Token struct {
@@ -12,10 +18,11 @@ type Token struct {
EndLine int
StartPos int
EndPos int
comments []comment.Comment
}
func NewToken(value []byte, startLine int, endLine int, startPos int, endPos int) Token {
return Token{string(value), startLine, endLine, startPos, endPos}
return Token{string(value), startLine, endLine, startPos, endPos, nil}
}
func (t Token) String() string {
@@ -31,3 +38,12 @@ func (t Token) GetStartLine() int {
func (t Token) GetEndLine() int {
return t.EndLine
}
func (t Token) Comments() []comment.Comment {
return t.comments
}
func (t Token) SetComments(comments []comment.Comment) Token {
t.comments = comments
return t
}