| 1 |
package sarif |
| 2 |
|
| 3 |
// Region ... |
| 4 |
type Region struct { |
| 5 |
StartLine *int `json:"startLine,omitempty"` |
| 6 |
StartColumn *int `json:"startColumn,omitempty"` |
| 7 |
EndLine *int `json:"endLine,omitempty"` |
| 8 |
EndColumn *int `json:"endColumn,omitempty"` |
| 9 |
CharOffset *int `json:"charOffset,omitempty"` |
| 10 |
CharLength *int `json:"charLength,omitempty"` |
| 11 |
ByteOffset *int `json:"byteOffset,omitempty"` |
| 12 |
ByteLength *int `json:"byteLength,omitempty"` |
| 13 |
Snippet *ArtifactContent `json:"snippet,omitempty"` |
| 14 |
Message *Message `json:"message,omitempty"` |
| 15 |
SourceLanguage *string `json:"sourceLanguage,omitempty"` |
| 16 |
PropertyBag |
| 17 |
} |
| 18 |
|
| 19 |
// NewRegion creates a new Region and returns a pointer to it |
| 20 |
func NewRegion() *Region { |
| 21 |
return &Region{} |
| 22 |
} |
| 23 |
|
| 24 |
// NewSimpleRegion creates a new SimpleRegion and returns a pointer to it |
| 25 |
func NewSimpleRegion(startLine, endLine int) *Region { |
| 26 |
return NewRegion(). |
| 27 |
WithStartLine(startLine). |
| 28 |
WithEndLine(endLine) |
| 29 |
} |
| 30 |
|
| 31 |
// WithStartLine sets the StartLine |
| 32 |
func (region *Region) WithStartLine(startLine int) *Region { |
| 33 |
region.StartLine = &startLine |
| 34 |
return region |
| 35 |
} |
| 36 |
|
| 37 |
// WithStartColumn sets the StartColumn |
| 38 |
func (region *Region) WithStartColumn(startColumn int) *Region { |
| 39 |
region.StartColumn = &startColumn |
| 40 |
return region |
| 41 |
} |
| 42 |
|
| 43 |
// WithEndLine sets the EndLine |
| 44 |
func (region *Region) WithEndLine(endLine int) *Region { |
| 45 |
region.EndLine = &endLine |
| 46 |
return region |
| 47 |
} |
| 48 |
|
| 49 |
// WithEndColumn sets the EndColumn |
| 50 |
func (region *Region) WithEndColumn(endColumn int) *Region { |
| 51 |
region.EndColumn = &endColumn |
| 52 |
return region |
| 53 |
} |
| 54 |
|
| 55 |
// WithCharOffset sets the CharOffset |
| 56 |
func (region *Region) WithCharOffset(charOffset int) *Region { |
| 57 |
region.CharOffset = &charOffset |
| 58 |
return region |
| 59 |
} |
| 60 |
|
| 61 |
// WithCharLength sets the CharLength |
| 62 |
func (region *Region) WithCharLength(charLength int) *Region { |
| 63 |
region.CharLength = &charLength |
| 64 |
return region |
| 65 |
} |
| 66 |
|
| 67 |
// WithByteOffset sets the ByteOffset |
| 68 |
func (region *Region) WithByteOffset(byteOffset int) *Region { |
| 69 |
region.ByteOffset = &byteOffset |
| 70 |
return region |
| 71 |
} |
| 72 |
|
| 73 |
// WithByteLength sets the ByteLength |
| 74 |
func (region *Region) WithByteLength(byteLength int) *Region { |
| 75 |
region.ByteLength = &byteLength |
| 76 |
return region |
| 77 |
} |
| 78 |
|
| 79 |
// WithSnippet sets the Snippet |
| 80 |
func (region *Region) WithSnippet(snippet *ArtifactContent) *Region { |
| 81 |
region.Snippet = snippet |
| 82 |
return region |
| 83 |
} |
| 84 |
|
| 85 |
// WithMessage sets the Message |
| 86 |
func (region *Region) WithMessage(message *Message) *Region { |
| 87 |
region.Message = message |
| 88 |
return region |
| 89 |
} |
| 90 |
|
| 91 |
// WithTextMessage sets the Message text |
| 92 |
func (region *Region) WithTextMessage(text string) *Region { |
| 93 |
if region.Message == nil { |
| 94 |
region.Message = &Message{} |
| 95 |
} |
| 96 |
region.Message.Text = &text |
| 97 |
return region |
| 98 |
} |
| 99 |
|
| 100 |
// WithMessageMarkdown sets the Message markdown |
| 101 |
func (region *Region) WithMessageMarkdown(markdown string) *Region { |
| 102 |
if region.Message == nil { |
| 103 |
region.Message = &Message{} |
| 104 |
} |
| 105 |
region.Message.Markdown = &markdown |
| 106 |
return region |
| 107 |
} |
| 108 |
|
| 109 |
// WithSourceLanguage sets the SourceLanguage |
| 110 |
func (region *Region) WithSourceLanguage(sourceLanguage string) *Region { |
| 111 |
|
| 112 |
return region |
| 113 |
} |