Skip to content

Commit

Permalink
Add support for MetaValue in root node
Browse files Browse the repository at this point in the history
  • Loading branch information
teo authored and xlab committed Nov 12, 2018
1 parent d6fb674 commit a009c39
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion treeprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Tree interface {
Bytes() []byte

SetValue(value Value)
SetMetaValue(meta MetaValue)
}

type node struct {
Expand Down Expand Up @@ -127,7 +128,11 @@ func (n *node) Bytes() []byte {
level := 0
var levelsEnded []int
if n.Root == nil {
buf.WriteString(fmt.Sprintf("%v",n.Value))
if n.Meta != nil {
buf.WriteString(fmt.Sprintf("[%v] %v", n.Meta, n.Value))
} else {
buf.WriteString(fmt.Sprintf("%v",n.Value))
}
buf.WriteByte('\n')
} else {
edge := EdgeTypeMid
Expand All @@ -151,6 +156,10 @@ func (n *node) SetValue(value Value){
n.Value = value
}

func (n *node) SetMetaValue(meta MetaValue){
n.Meta = meta
}

func printNodes(wr io.Writer,
level int, levelsEnded []int, nodes []*node) {

Expand Down

0 comments on commit a009c39

Please sign in to comment.