Skip to content

Commit 8fc1f80

Browse files
committed
add end position for JSON analysis output
1 parent 6f4e2a8 commit 8fc1f80

File tree

1 file changed

+4
-4
lines changed
  • go/analysis/internal/analysisflags

1 file changed

+4
-4
lines changed

go/analysis/internal/analysisflags/flags.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -363,22 +363,20 @@ type JSONSuggestedFix struct {
363363
}
364364

365365
// A JSONDiagnostic describes the JSON schema of an analysis.Diagnostic.
366-
//
367-
// TODO(matloob): include End position if present.
368366
type JSONDiagnostic struct {
369367
Category string `json:"category,omitempty"`
370368
Posn string `json:"posn"` // e.g. "file.go:line:column"
369+
EndPosn string `json:"end_posn,omitempty"`
371370
Message string `json:"message"`
372371
SuggestedFixes []JSONSuggestedFix `json:"suggested_fixes,omitempty"`
373372
Related []JSONRelatedInformation `json:"related,omitempty"`
374373
}
375374

376375
// A JSONRelated describes a secondary position and message related to
377376
// a primary diagnostic.
378-
//
379-
// TODO(adonovan): include End position if present.
380377
type JSONRelatedInformation struct {
381378
Posn string `json:"posn"` // e.g. "file.go:line:column"
379+
EndPosn string `json:"end_posn,omitempty"`
382380
Message string `json:"message"`
383381
}
384382

@@ -414,12 +412,14 @@ func (tree JSONTree) Add(fset *token.FileSet, id, name string, diags []analysis.
414412
for _, r := range f.Related {
415413
related = append(related, JSONRelatedInformation{
416414
Posn: fset.Position(r.Pos).String(),
415+
EndPosn: fset.Position(r.End).String(),
417416
Message: r.Message,
418417
})
419418
}
420419
jdiag := JSONDiagnostic{
421420
Category: f.Category,
422421
Posn: fset.Position(f.Pos).String(),
422+
EndPosn: fset.Position(f.End).String(),
423423
Message: f.Message,
424424
SuggestedFixes: fixes,
425425
Related: related,

0 commit comments

Comments
 (0)