move Positions and Comments into parser package
This commit is contained in:
@@ -6,29 +6,9 @@ import (
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
|
||||
"github.com/z7zmey/php-parser/comment"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
func TestComments(t *testing.T) {
|
||||
n := node.NewIdentifier("test")
|
||||
|
||||
commentGroup := []*comment.Comment{
|
||||
comment.NewComment("/** hello world */", nil),
|
||||
comment.NewComment("// hello world", nil),
|
||||
}
|
||||
|
||||
comments := comment.Comments{}
|
||||
comments.AddComments(n, commentGroup)
|
||||
|
||||
if comments[n][0].String() != "/** hello world */" {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
if comments[n][1].String() != "// hello world" {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommentPos(t *testing.T) {
|
||||
func TestCommentGetPosition(t *testing.T) {
|
||||
expected := position.NewPosition(0, 0, 0, 0)
|
||||
|
||||
comment := comment.NewComment("/** hello world */", expected)
|
||||
@@ -39,3 +19,15 @@ func TestCommentPos(t *testing.T) {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommentPrint(t *testing.T) {
|
||||
expected := "/** hello world */"
|
||||
|
||||
comment := comment.NewComment(expected, nil)
|
||||
|
||||
actual := comment.String()
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package comment
|
||||
|
||||
import "github.com/z7zmey/php-parser/node"
|
||||
|
||||
// Comments a collection of comment groups assigned to nodes
|
||||
type Comments map[node.Node][]*Comment
|
||||
|
||||
// AddComments add comment group to the collection
|
||||
func (c Comments) AddComments(node node.Node, comments []*Comment) {
|
||||
c[node] = append(c[node], comments...)
|
||||
}
|
||||
Reference in New Issue
Block a user