-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
node.go
52 lines (45 loc) · 1.08 KB
/
node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package sarif
// Node ...
type Node struct {
Children []*Node `json:"children,omitempty"`
ID string `json:"id"`
Label *Message `json:"label,omitempty"`
Location *Location `json:"location,omitempty"`
PropertyBag
}
// NewNode creates a new Node and returns a pointer to it
func NewNode(id string) *Node {
return &Node{
ID: id,
}
}
// WithChildren sets the Children
func (node *Node) WithChildren(children []*Node) *Node {
node.Children = children
return node
}
// AddChild ...
func (node *Node) AddChild(child *Node) {
node.Children = append(node.Children, child)
}
// WithLabel sets the Label
func (node *Node) WithLabel(message *Message) *Node {
node.Label = message
return node
}
// WithLabelText sets the LabelText
func (node *Node) WithLabelText(text string) *Node {
if node.Label == nil {
node.Label = &Message{}
}
node.Label.Text = &text
return node
}
// WithLabelMarkdown sets the LabelMarkdown
func (node *Node) WithLabelMarkdown(markdown string) *Node {
if node.Label == nil {
node.Label = &Message{}
}
node.Label.Markdown = &markdown
return node
}