|
| 1 | +// @flow |
| 2 | +declare module 'vscode-languageserver' { |
| 3 | + declare export opaque type ODiagnosticTag; |
| 4 | + declare export opaque type ODiagnosticSeverity; |
| 5 | + |
| 6 | + /** |
| 7 | + * The diagnostic tags. |
| 8 | + * |
| 9 | + * @since 3.15.0 |
| 10 | + */ |
| 11 | + declare export var DiagnosticTag: {| |
| 12 | + /** |
| 13 | + * Unused or unnecessary code. |
| 14 | + * |
| 15 | + * Clients are allowed to render diagnostics with this tag faded out instead of having |
| 16 | + * an error squiggle. |
| 17 | + */ |
| 18 | + Unnecessary: ODiagnosticTag, |
| 19 | + /** |
| 20 | + * Deprecated or obsolete code. |
| 21 | + * |
| 22 | + * Clients are allowed to rendered diagnostics with this tag strike through. |
| 23 | + */ |
| 24 | + Deprecated: ODiagnosticTag, |
| 25 | + |}; |
| 26 | + |
| 27 | + /** |
| 28 | + * The diagnostic's severity. |
| 29 | + */ |
| 30 | + declare export var DiagnosticSeverity: {| |
| 31 | + /** |
| 32 | + * Reports an error. |
| 33 | + */ |
| 34 | + Error: ODiagnosticSeverity, |
| 35 | + /** |
| 36 | + * Reports a warning. |
| 37 | + */ |
| 38 | + Warning: ODiagnosticSeverity, |
| 39 | + /** |
| 40 | + * Reports an information. |
| 41 | + */ |
| 42 | + Information: ODiagnosticSeverity, |
| 43 | + /** |
| 44 | + * Reports a hint. |
| 45 | + */ |
| 46 | + Hint: ODiagnosticSeverity, |
| 47 | + |}; |
| 48 | + |
| 49 | + declare export type DocumentUri = string; |
| 50 | + |
| 51 | + /** |
| 52 | + * A literal to identify a text document in the client. |
| 53 | + */ |
| 54 | + declare export type TextDocumentIdentifier = {| |
| 55 | + uri: DocumentUri, |
| 56 | + |}; |
| 57 | + |
| 58 | + /** |
| 59 | + * Position in a text document expressed as zero-based line and character |
| 60 | + * offset. Prior to 3.17 the offsets were always based on a UTF-16 string |
| 61 | + * representation. So a string of the form `a𐐀b` the character offset of the |
| 62 | + * character `a` is 0, the character offset of `𐐀` is 1 and the character |
| 63 | + * offset of b is 3 since `𐐀` is represented using two code units in UTF-16. |
| 64 | + * Since 3.17 clients and servers can agree on a different string encoding |
| 65 | + * representation (e.g. UTF-8). The client announces it's supported encoding |
| 66 | + * via the client capability [`general.positionEncodings`](#clientCapabilities). |
| 67 | + * The value is an array of position encodings the client supports, with |
| 68 | + * decreasing preference (e.g. the encoding at index `0` is the most preferred |
| 69 | + * one). To stay backwards compatible the only mandatory encoding is UTF-16 |
| 70 | + * represented via the string `utf-16`. The server can pick one of the |
| 71 | + * encodings offered by the client and signals that encoding back to the |
| 72 | + * client via the initialize result's property |
| 73 | + * [`capabilities.positionEncoding`](#serverCapabilities). If the string value |
| 74 | + * `utf-16` is missing from the client's capability `general.positionEncodings` |
| 75 | + * servers can safely assume that the client supports UTF-16. If the server |
| 76 | + * omits the position encoding in its initialize result the encoding defaults |
| 77 | + * to the string value `utf-16`. Implementation considerations: since the |
| 78 | + * conversion from one encoding into another requires the content of the |
| 79 | + * file / line the conversion is best done where the file is read which is |
| 80 | + * usually on the server side. |
| 81 | + * |
| 82 | + * Positions are line end character agnostic. So you can not specify a position |
| 83 | + * that denotes `\r|\n` or `\n|` where `|` represents the character offset. |
| 84 | + * |
| 85 | + * @since 3.17.0 - support for negotiated position encoding. |
| 86 | + */ |
| 87 | + declare export type Position = {|line: number, character: number|}; |
| 88 | + |
| 89 | + /** |
| 90 | + * A range in a text document expressed as (zero-based) start and end positions. |
| 91 | + * |
| 92 | + * If you want to specify a range that contains a line including the line ending |
| 93 | + * character(s) then use an end position denoting the start of the next line. |
| 94 | + * For example: |
| 95 | + * ```ts |
| 96 | + * { |
| 97 | + * start: { line: 5, character: 23 } |
| 98 | + * end : { line 6, character : 0 } |
| 99 | + * } |
| 100 | + * ``` |
| 101 | + */ |
| 102 | + declare export type Range = {|start: Position, end: Position|}; |
| 103 | + |
| 104 | + /** |
| 105 | + * Structure to capture a description for an error code. |
| 106 | + * |
| 107 | + * @since 3.16.0 |
| 108 | + */ |
| 109 | + declare export type CodeDescription = {|href: string|}; |
| 110 | + |
| 111 | + /** |
| 112 | + * Represents a location inside a resource, such as a line |
| 113 | + * inside a text file. |
| 114 | + */ |
| 115 | + declare export type Location = {|uri: string, range: Range|}; |
| 116 | + |
| 117 | + /** |
| 118 | + * The DiagnosticRelatedInformation namespace provides helper functions to work with |
| 119 | + * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals. |
| 120 | + */ |
| 121 | + declare export type DiagnosticRelatedInformation = {| |
| 122 | + location: Location, |
| 123 | + message: string, |
| 124 | + |}; |
| 125 | + |
| 126 | + /** |
| 127 | + * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects |
| 128 | + * are only valid in the scope of a resource. |
| 129 | + */ |
| 130 | + declare export type Diagnostic = {| |
| 131 | + range: Range, |
| 132 | + severity?: ODiagnosticSeverity, |
| 133 | + code?: number | string, |
| 134 | + codeDescription?: CodeDescription, |
| 135 | + source?: string, |
| 136 | + message: string, |
| 137 | + tags?: ODiagnosticTag[], |
| 138 | + relatedInformation?: DiagnosticRelatedInformation[], |
| 139 | + data?: mixed, |
| 140 | + |}; |
| 141 | + |
| 142 | + /** |
| 143 | + * A parameter literal used in requests to pass a text document and a position inside that |
| 144 | + * document. |
| 145 | + */ |
| 146 | + declare export type TextDocumentPositionParams = { |
| 147 | + textDocument: TextDocumentIdentifier, |
| 148 | + position: Position, |
| 149 | + ... |
| 150 | + }; |
| 151 | + |
| 152 | + /** |
| 153 | + * Represents the connection of two locations. Provides additional metadata over normal [locations](#Location), |
| 154 | + * including an origin range. |
| 155 | + */ |
| 156 | + declare export type LocationLink = {| |
| 157 | + /** |
| 158 | + * Span of the origin of this link. |
| 159 | + * |
| 160 | + * Used as the underlined span for mouse interaction. Defaults to the word range at |
| 161 | + * the definition position. |
| 162 | + */ |
| 163 | + originSelectionRange?: Range, |
| 164 | + /** |
| 165 | + * The target resource identifier of this link. |
| 166 | + */ |
| 167 | + targetUri: DocumentUri, |
| 168 | + /** |
| 169 | + * The full target range of this link. If the target for example is a symbol then target range is the |
| 170 | + * range enclosing this symbol not including leading/trailing whitespace but everything else |
| 171 | + * like comments. This information is typically used to highlight the range in the editor. |
| 172 | + */ |
| 173 | + targetRange: Range, |
| 174 | + /** |
| 175 | + * The range that should be selected and revealed when this link is being followed, e.g the name of a function. |
| 176 | + * Must be contained by the `targetRange`. See also `DocumentSymbol#range` |
| 177 | + */ |
| 178 | + targetSelectionRange: Range, |
| 179 | + |}; |
| 180 | + |
| 181 | + /** |
| 182 | + * Information about where a symbol is defined. |
| 183 | + * |
| 184 | + * Provides additional metadata over normal [location](#Location) definitions, including the range of |
| 185 | + * the defining symbol |
| 186 | + */ |
| 187 | + declare export type DefinitionLink = LocationLink; |
| 188 | +} |
0 commit comments