5 // A Diagnostic is a message associated with a source location or range.
7 // An Analyzer may return a variety of diagnostics; the optional Category,
8 // which should be a constant, may be used to classify them.
9 // It is primarily intended to make it easy to look up documentation.
11 // If End is provided, the diagnostic is specified to apply to the range between
13 type Diagnostic struct {
15 End token.Pos // optional
16 Category string // optional
19 // SuggestedFixes contains suggested fixes for a diagnostic which can be used to perform
20 // edits to a file that address the diagnostic.
21 // TODO(matloob): Should multiple SuggestedFixes be allowed for a diagnostic?
22 // Diagnostics should not contain SuggestedFixes that overlap.
23 // Experimental: This API is experimental and may change in the future.
24 SuggestedFixes []SuggestedFix // optional
26 // Experimental: This API is experimental and may change in the future.
27 Related []RelatedInformation // optional
30 // RelatedInformation contains information related to a diagnostic.
31 // For example, a diagnostic that flags duplicated declarations of a
32 // variable may include one RelatedInformation per existing
34 type RelatedInformation struct {
40 // A SuggestedFix is a code change associated with a Diagnostic that a user can choose
41 // to apply to their code. Usually the SuggestedFix is meant to fix the issue flagged
43 // TextEdits for a SuggestedFix should not overlap. TextEdits for a SuggestedFix
44 // should not contain edits for other packages.
45 // Experimental: This API is experimental and may change in the future.
46 type SuggestedFix struct {
47 // A description for this suggested fix to be shown to a user deciding
48 // whether to accept it.
53 // A TextEdit represents the replacement of the code between Pos and End with the new text.
54 // Each TextEdit should apply to a single file. End should not be earlier in the file than Pos.
55 // Experimental: This API is experimental and may change in the future.
56 type TextEdit struct {
57 // For a pure insertion, End can either be set to Pos or token.NoPos.