#51 saving optional tokes and tokens that have different representation as meta
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// FullyQualified node
|
||||
type FullyQualified struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Parts []node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *FullyQualified) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *FullyQualified) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *FullyQualified) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *FullyQualified) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Name node
|
||||
type Name struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Parts []node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Name) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Name) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Name) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Name) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// NamePart node
|
||||
type NamePart struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Value string
|
||||
}
|
||||
@@ -30,12 +30,8 @@ func (n *NamePart) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *NamePart) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *NamePart) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *NamePart) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Relative node
|
||||
type Relative struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Parts []node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Relative) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Relative) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Relative) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Relative) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -18,12 +18,20 @@ var nodes = []node.Node{
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
expected := []meta.Meta{
|
||||
meta.NewComment("//comment\n", nil),
|
||||
meta.NewWhiteSpace(" ", nil),
|
||||
expected := &meta.Collection{
|
||||
&meta.Data{
|
||||
Value: "//comment\n",
|
||||
Type: meta.CommentType,
|
||||
Position: nil,
|
||||
},
|
||||
&meta.Data{
|
||||
Value: " ",
|
||||
Type: meta.WhiteSpaceType,
|
||||
Position: nil,
|
||||
},
|
||||
}
|
||||
for _, n := range nodes {
|
||||
n.AddMeta(expected)
|
||||
n.GetMeta().Push(*expected...)
|
||||
actual := n.GetMeta()
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user