Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / go / analysis / diagnostic.go
1 package analysis
2
3 import "go/token"
4
5 // A Diagnostic is a message associated with a source location or range.
6 //
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.
10 //
11 // If End is provided, the diagnostic is specified to apply to the range between
12 // Pos and End.
13 type Diagnostic struct {
14         Pos      token.Pos
15         End      token.Pos // optional
16         Category string    // optional
17         Message  string
18
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
25
26         // Experimental: This API is experimental and may change in the future.
27         Related []RelatedInformation // optional
28 }
29
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
33 // declaration.
34 type RelatedInformation struct {
35         Pos     token.Pos
36         End     token.Pos
37         Message string
38 }
39
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
42 // by the diagnostic.
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.
49         Message   string
50         TextEdits []TextEdit
51 }
52
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.
58         Pos     token.Pos
59         End     token.Pos
60         NewText []byte
61 }