|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +package protocol |
| 4 | + |
| 5 | +import "github.com/caixw/apidoc/v7/core" |
| 6 | + |
| 7 | +// PublishDiagnosticsParams textDocument/publishDiagnostics 事件发送的参数 |
| 8 | +type PublishDiagnosticsParams struct { |
| 9 | + // The URI for which diagnostic information is reported. |
| 10 | + URI core.URI `json:"uri"` |
| 11 | + |
| 12 | + // Optional the version number of the document the diagnostics are published for. |
| 13 | + // |
| 14 | + // @since 3.15.0 |
| 15 | + Version int `json:"version,omitempty"` |
| 16 | + |
| 17 | + // An array of diagnostic information items. |
| 18 | + Diagnostics []Diagnostic `json:"diagnostics"` |
| 19 | +} |
| 20 | + |
| 21 | +// Diagnostic represents a diagnostic,such as a compiler error or warning. |
| 22 | +// Diagnostic objects are only valid in the scope of a resource. |
| 23 | +// |
| 24 | +// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#diagnostic |
| 25 | +type Diagnostic struct { |
| 26 | + // The range at which the message applies. |
| 27 | + Range core.Range `json:"range"` |
| 28 | + |
| 29 | + // The diagnostic's severity. Can be omitted. If omitted it is up to the |
| 30 | + // client to interpret diagnostics as error, warning, info or hint. |
| 31 | + Severity DiagnosticSeverity `json:"severity,omitempty"` |
| 32 | + |
| 33 | + // The diagnostic's code, which might appear in the user interface. |
| 34 | + Code string `json:"code,omitempty"` |
| 35 | + |
| 36 | + // A human-readable string describing the source of this |
| 37 | + // diagnostic, e.g. 'typescript' or 'super lint'. |
| 38 | + Source string `json:"source,omitempty"` |
| 39 | + |
| 40 | + // The diagnostic's message. |
| 41 | + Message string `json:"message"` |
| 42 | + |
| 43 | + // Additional metadata about the diagnostic. |
| 44 | + // |
| 45 | + // @since 3.15.0 |
| 46 | + Tags []DiagnosticTag `json:"tags,omitempty"` |
| 47 | + |
| 48 | + // An array of related diagnostic information, e.g. when symbol-names within |
| 49 | + // a scope collide all definitions can be marked via this property. |
| 50 | + RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"` |
| 51 | +} |
| 52 | + |
| 53 | +type DiagnosticSeverity int |
| 54 | + |
| 55 | +// DiagnosticSeverity 可用的常量 |
| 56 | +const ( |
| 57 | + DiagnosticSeverityError DiagnosticSeverity = iota + 1 // Reports an error |
| 58 | + DiagnosticSeverityWarning // Reports a warning |
| 59 | + DiagnosticSeverityInformation // Reports an information |
| 60 | + DiagnosticSeverityHint // Reports a hint |
| 61 | +) |
| 62 | + |
| 63 | +// DiagnosticTag the diagnostic tags. |
| 64 | +// |
| 65 | +// @since 3.15.0 |
| 66 | +type DiagnosticTag int |
| 67 | + |
| 68 | +// DiagnosticTag 可用的常量列表 |
| 69 | +const ( |
| 70 | + // DiagnosticTagUnnecessary unused or unnecessary code. |
| 71 | + // |
| 72 | + // Clients are allowed to render diagnostics with this tag faded out instead of having |
| 73 | + // an error squiggle. |
| 74 | + DiagnosticTagUnnecessary DiagnosticTag = 1 |
| 75 | + |
| 76 | + // DiagnosticTagDeprecated deprecated or obsolete code. |
| 77 | + // |
| 78 | + // Clients are allowed to rendered diagnostics with this tag strike through. |
| 79 | + DiagnosticTagDeprecated DiagnosticTag = 2 |
| 80 | +) |
| 81 | + |
| 82 | +// DiagnosticRelatedInformation represents a related message and source code location for a diagnostic |
| 83 | +// |
| 84 | +// This should be used to point to code locations that cause or are related to a diagnostics, |
| 85 | +// e.g when duplicating a symbol in a scope. |
| 86 | +type DiagnosticRelatedInformation struct { |
| 87 | + // The location of this related diagnostic information. |
| 88 | + Location core.Location `json:"location"` |
| 89 | + |
| 90 | + // The message of this related diagnostic information. |
| 91 | + Message string `json:"message"` |
| 92 | +} |
0 commit comments