| 1 |
package sarif |
| 2 |
|
| 3 |
// Stack ... |
| 4 |
type Stack struct { |
| 5 |
Frames []*StackFrame `json:"frames"` |
| 6 |
Message *Message `json:"message,omitempty"` |
| 7 |
PropertyBag |
| 8 |
} |
| 9 |
|
| 10 |
// NewStack creates a new Stack and returns a pointer to it |
| 11 |
func NewStack() *Stack { |
| 12 |
return &Stack{} |
| 13 |
} |
| 14 |
|
| 15 |
// WithFrames sets the Frames |
| 16 |
func (stack *Stack) WithFrames(frames []*StackFrame) *Stack { |
| 17 |
stack.Frames = frames |
| 18 |
return stack |
| 19 |
} |
| 20 |
|
| 21 |
// AddFrame ... |
| 22 |
func (stack *Stack) AddFrame(frame *StackFrame) { |
| 23 |
stack.Frames = append(stack.Frames, frame) |
| 24 |
} |
| 25 |
|
| 26 |
// WithMessage sets the Message |
| 27 |
func (stack *Stack) WithMessage(message *Message) *Stack { |
| 28 |
stack.Message = message |
| 29 |
return stack |
| 30 |
} |
| 31 |
|
| 32 |
// WithTextMessage sets the Message text |
| 33 |
func (stack *Stack) WithTextMessage(text string) *Stack { |
| 34 |
if stack.Message == nil { |
| 35 |
stack.Message = &Message{} |
| 36 |
} |
| 37 |
stack.Message.Text = &text |
| 38 |
return stack |
| 39 |
} |
| 40 |
|
| 41 |
// WithMessageMarkdown sets the Message markdown |
| 42 |
func (stack *Stack) WithMessageMarkdown(markdown string) *Stack { |
| 43 |
if stack.Message == nil { |
| 44 |
stack.Message = &Message{} |
| 45 |
} |
| 46 |
stack.Message.Markdown = &markdown |
| 47 |
return stack |
| 48 |
} |