@@ -76,36 +76,36 @@ func (p Problem) MarshalYAML() (interface{}, error) {
7676
7777// Marshal defines how to represent a serialized Problem.
7878func (p Problem ) marshal () interface {} {
79- var fl fileLocation
79+ var fl FileLocation
8080 if p .Location != nil {
8181 // If Location is set, use it.
82- fl = fileLocationFromPBLocation (p .Location , p .Descriptor )
82+ fl = FileLocationFromPBLocation (p .Location , p .Descriptor )
8383 } else if p .Descriptor != nil {
8484 // Otherwise, use the descriptor's location.
8585 // This is the protobuf-go idiomatic way to get the source location.
8686 // Note: ParentFile() called on a FileDescriptor returns itself.
8787 loc := p .Descriptor .ParentFile ().SourceLocations ().ByDescriptor (p .Descriptor )
88- fl = fileLocation {
88+ fl = FileLocation {
8989 Path : p .Descriptor .ParentFile ().Path (),
90- Start : position {
90+ Start : Position {
9191 Line : loc .StartLine + 1 ,
9292 Column : loc .StartColumn + 1 ,
9393 },
94- End : position {
94+ End : Position {
9595 Line : loc .EndLine + 1 ,
9696 Column : loc .EndColumn ,
9797 },
9898 }
9999 } else {
100100 // Default location if no descriptor.
101- fl = fileLocationFromPBLocation (nil , nil )
101+ fl = FileLocationFromPBLocation (nil , nil )
102102 }
103103
104104 // Return a marshal-able structure.
105105 return struct {
106106 Message string `json:"message" yaml:"message"`
107107 Suggestion string `json:"suggestion,omitempty" yaml:"suggestion,omitempty"`
108- Location fileLocation `json:"location" yaml:"location"`
108+ Location FileLocation `json:"location" yaml:"location"`
109109 RuleID RuleName `json:"rule_id" yaml:"rule_id"`
110110 RuleDocURI string `json:"rule_doc_uri" yaml:"rule_doc_uri"`
111111 Category string `json:"category,omitempty" yaml:"category,omitempty"`
@@ -124,35 +124,35 @@ func (p Problem) GetRuleURI() string {
124124 return getRuleURL (string (p .RuleID ), ruleURLMappings )
125125}
126126
127- // position describes a one-based position in a source code file.
127+ // Position describes a one-based Position in a source code file.
128128// They are one-indexed, as a human counts lines or columns.
129- type position struct {
129+ type Position struct {
130130 Line int `json:"line_number" yaml:"line_number"`
131131 Column int `json:"column_number" yaml:"column_number"`
132132}
133133
134- // fileLocation describes a location in a source code file.
134+ // FileLocation describes a location in a source code file.
135135//
136136// Note: Positions are one-indexed, as a human counts lines or columns
137137// in a file.
138- type fileLocation struct {
139- Start position `json:"start_position" yaml:"start_position"`
140- End position `json:"end_position" yaml:"end_position"`
138+ type FileLocation struct {
139+ Start Position `json:"start_position" yaml:"start_position"`
140+ End Position `json:"end_position" yaml:"end_position"`
141141 Path string `json:"path" yaml:"path"`
142142}
143143
144- // fileLocationFromPBLocation returns a new fileLocation object based on a
144+ // FileLocationFromPBLocation returns a new fileLocation object based on a
145145// protocol buffer SourceCodeInfo_Location
146- func fileLocationFromPBLocation (l * dpb.SourceCodeInfo_Location , d protoreflect.Descriptor ) fileLocation {
146+ func FileLocationFromPBLocation (l * dpb.SourceCodeInfo_Location , d protoreflect.Descriptor ) FileLocation {
147147 // Spans are guaranteed by protobuf to have either three or four ints.
148148 span := []int32 {0 , 0 , 1 }
149149 if l != nil {
150150 span = l .Span
151151 }
152152
153- var fl fileLocation
153+ var fl FileLocation
154154 if d != nil {
155- fl = fileLocation {Path : d .ParentFile ().Path ()}
155+ fl = FileLocation {Path : d .ParentFile ().Path ()}
156156 }
157157
158158 // If `span` has four ints; they correspond to
@@ -161,11 +161,11 @@ func fileLocationFromPBLocation(l *dpb.SourceCodeInfo_Location, d protoreflect.D
161161 // We add one because spans are zero-indexed, but not to the end column
162162 // because we want the ending position to be inclusive and not exclusive.
163163 if len (span ) == 4 {
164- fl .Start = position {
164+ fl .Start = Position {
165165 Line : int (span [0 ]) + 1 ,
166166 Column : int (span [1 ]) + 1 ,
167167 }
168- fl .End = position {
168+ fl .End = Position {
169169 Line : int (span [2 ]) + 1 ,
170170 Column : int (span [3 ]),
171171 }
@@ -177,11 +177,11 @@ func fileLocationFromPBLocation(l *dpb.SourceCodeInfo_Location, d protoreflect.D
177177 //
178178 // We add one because spans are zero-indexed, but not to the end column
179179 // because we want the ending position to be inclusive and not exclusive.
180- fl .Start = position {
180+ fl .Start = Position {
181181 Line : int (span [0 ]) + 1 ,
182182 Column : int (span [1 ]) + 1 ,
183183 }
184- fl .End = position {
184+ fl .End = Position {
185185 Line : int (span [0 ]) + 1 ,
186186 Column : int (span [2 ]),
187187 }
0 commit comments