1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // A Diagnostic is a message associated with a source location or range.
11 // An Analyzer may return a variety of diagnostics; the optional Category,
12 // which should be a constant, may be used to classify them.
13 // It is primarily intended to make it easy to look up documentation.
15 // If End is provided, the diagnostic is specified to apply to the range between
17 type Diagnostic struct {
19 End token.Pos // optional
20 Category string // optional
23 // SuggestedFixes contains suggested fixes for a diagnostic which can be used to perform
24 // edits to a file that address the diagnostic.
25 // TODO(matloob): Should multiple SuggestedFixes be allowed for a diagnostic?
26 // Diagnostics should not contain SuggestedFixes that overlap.
27 // Experimental: This API is experimental and may change in the future.
28 SuggestedFixes []SuggestedFix // optional
30 // Experimental: This API is experimental and may change in the future.
31 Related []RelatedInformation // optional
34 // RelatedInformation contains information related to a diagnostic.
35 // For example, a diagnostic that flags duplicated declarations of a
36 // variable may include one RelatedInformation per existing
38 type RelatedInformation struct {
44 // A SuggestedFix is a code change associated with a Diagnostic that a user can choose
45 // to apply to their code. Usually the SuggestedFix is meant to fix the issue flagged
47 // TextEdits for a SuggestedFix should not overlap. TextEdits for a SuggestedFix
48 // should not contain edits for other packages.
49 // Experimental: This API is experimental and may change in the future.
50 type SuggestedFix struct {
51 // A description for this suggested fix to be shown to a user deciding
52 // whether to accept it.
57 // A TextEdit represents the replacement of the code between Pos and End with the new text.
58 // Each TextEdit should apply to a single file. End should not be earlier in the file than Pos.
59 // Experimental: This API is experimental and may change in the future.
60 type TextEdit struct {
61 // For a pure insertion, End can either be set to Pos or token.NoPos.