| 1 | package sarif |
| 2 | |
| 3 | // Region ... |
| 4 | type Region struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10541123 |
| 5 | PropertyBag |
| 6 | StartLine *int `json:"startLine,omitempty"` |
| 7 | StartColumn *int `json:"startColumn,omitempty"` |
| 8 | EndLine *int `json:"endLine,omitempty"` |
| 9 | EndColumn *int `json:"endColumn,omitempty"` |
| 10 | CharOffset *int `json:"charOffset,omitempty"` |
| 11 | CharLength *int `json:"charLength,omitempty"` |
| 12 | ByteOffset *int `json:"byteOffset,omitempty"` |
| 13 | ByteLength *int `json:"byteLength,omitempty"` |
| 14 | Snippet *ArtifactContent `json:"snippet,omitempty"` |
| 15 | Message *Message `json:"message,omitempty"` |
| 16 | SourceLanguage *string `json:"sourceLanguage,omitempty"` |
| 17 | } |
| 18 | |
| 19 | // NewRegion ... |
| 20 | func NewRegion() *Region { |
| 21 | return &Region{} |
| 22 | } |
| 23 | |
| 24 | // NewSimpleRegion ... |
| 25 | func NewSimpleRegion(startLine, endLine int) *Region { |
| 26 | return NewRegion(). |
| 27 | WithStartLine(startLine). |
| 28 | WithEndLine(endLine) |
| 29 | } |
| 30 | |
| 31 | // WithStartLine ... |
| 32 | func (r *Region) WithStartLine(startLine int) *Region { |
| 33 | r.StartLine = &startLine |
| 34 | return r |
| 35 | } |
| 36 | |
| 37 | // WithStartColumn ... |
| 38 | func (r *Region) WithStartColumn(startColumn int) *Region { |
| 39 | r.StartColumn = &startColumn |
| 40 | return r |
| 41 | } |
| 42 | |
| 43 | // WithEndLine ... |
| 44 | func (r *Region) WithEndLine(endLine int) *Region { |
| 45 | r.EndLine = &endLine |
| 46 | return r |
| 47 | } |
| 48 | |
| 49 | // WithEndColumn ... |
| 50 | func (r *Region) WithEndColumn(endColumn int) *Region { |
| 51 | r.EndColumn = &endColumn |
| 52 | return r |
| 53 | } |
| 54 | |
| 55 | // WithCharOffset ... |
| 56 | func (r *Region) WithCharOffset(charOffset int) *Region { |
| 57 | r.CharOffset = &charOffset |
| 58 | return r |
| 59 | } |
| 60 | |
| 61 | // WithCharLength ... |
| 62 | func (r *Region) WithCharLength(charLength int) *Region { |
| 63 | r.CharLength = &charLength |
| 64 | return r |
| 65 | } |
| 66 | |
| 67 | // WithByteOffset ... |
| 68 | func (r *Region) WithByteOffset(byteOffset int) *Region { |
| 69 | r.ByteOffset = &byteOffset |
| 70 | return r |
| 71 | } |
| 72 | |
| 73 | // WithByteLength ... |
| 74 | func (r *Region) WithByteLength(byteLength int) *Region { |
| 75 | r.ByteLength = &byteLength |
| 76 | return r |
| 77 | } |
| 78 | |
| 79 | // WithSnippet ... |
| 80 | func (r *Region) WithSnippet(snippet *ArtifactContent) *Region { |
| 81 | r.Snippet = snippet |
| 82 | return r |
| 83 | } |
| 84 | |
| 85 | // WithMessage ... |
| 86 | func (r *Region) WithMessage(message *Message) *Region { |
| 87 | r.Message = message |
| 88 | return r |
| 89 | } |
| 90 | |
| 91 | // WithSourceLanguage ... |
| 92 | func (r *Region) WithSourceLanguage(sourceLanguage string) *Region { |
| 93 | |
| 94 | return r |
| 95 | } |