Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MetaValue in root node #8

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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