Debian Codegraph @

v2/sarif/node.go

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