#51 saving optional tokes and tokens that have different representation as meta
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Array node
|
||||
type Array struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Array) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Array) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Array) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Array) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Bool node
|
||||
type Bool struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Bool) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Bool) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Bool) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Bool) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Double node
|
||||
type Double struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Double) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Double) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Double) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Double) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Int node
|
||||
type Int struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Int) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Int) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Int) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Int) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Object node
|
||||
type Object struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Object) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Object) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Object) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Object) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// String node
|
||||
type String struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *String) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *String) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *String) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *String) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Unset node
|
||||
type Unset struct {
|
||||
Meta []meta.Meta
|
||||
Meta meta.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@@ -31,12 +31,8 @@ func (n *Unset) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Unset) AddMeta(m []meta.Meta) {
|
||||
n.Meta = append(n.Meta, m...)
|
||||
}
|
||||
|
||||
func (n *Unset) GetMeta() []meta.Meta {
|
||||
return n.Meta
|
||||
func (n *Unset) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
||||
@@ -21,12 +21,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