@@ -16,7 +16,12 @@ import (
16
16
// For clarity, the type of such a field is declared as a DocumentURI.
17
17
// Over the wire, it will still be transferred as a string, but this guarantees
18
18
// that the contents of that string can be parsed as a valid URI.
19
- type DocumentURI string
19
+ type DocumentURI = uri.URI
20
+
21
+ // URI a tagging interface for normal non document URIs.
22
+ //
23
+ // @since 3.16.0.
24
+ type URI = uri.URI
20
25
21
26
// EOL denotes represents the character offset.
22
27
var EOL = []string {"\n " , "\r \n " , "\r " }
@@ -26,14 +31,14 @@ var EOL = []string{"\n", "\r\n", "\r"}
26
31
// A position is between two characters like an "insert" cursor in a editor.
27
32
type Position struct {
28
33
// Line position in a document (zero-based).
29
- Line float64 `json:"line"`
34
+ Line uint32 `json:"line"`
30
35
31
36
// Character offset on a line in a document (zero-based). Assuming that the line is
32
37
// represented as a string, the `character` value represents the gap between the
33
38
// `character` and `character + 1`.
34
39
// If the character value is greater than the line length it defaults back to the
35
40
// line length.
36
- Character float64 `json:"character"`
41
+ Character uint32 `json:"character"`
37
42
}
38
43
39
44
// Range represents a text document expressed as (zero-based) start and end positions.
@@ -50,8 +55,8 @@ type Range struct {
50
55
51
56
// Location represents a location inside a resource, such as a line inside a text file.
52
57
type Location struct {
53
- URI uri. URI `json:"uri"`
54
- Range Range `json:"range"`
58
+ URI DocumentURI `json:"uri"`
59
+ Range Range `json:"range"`
55
60
}
56
61
57
62
// LocationLink represents a link between a source and a target location.
@@ -62,7 +67,7 @@ type LocationLink struct {
62
67
OriginSelectionRange * Range `json:"originSelectionRange,omitempty"`
63
68
64
69
// TargetURI is the target resource identifier of this link.
65
- TargetURI uri. URI `json:"targetUri"`
70
+ TargetURI DocumentURI `json:"targetUri"`
66
71
67
72
// TargetRange is the full target range of this link. If the target for example is a symbol then target range is the
68
73
// range enclosing this symbol not including leading/trailing whitespace but everything else
@@ -74,6 +79,14 @@ type LocationLink struct {
74
79
TargetSelectionRange Range `json:"targetSelectionRange"`
75
80
}
76
81
82
+ // CodeDescription is the structure to capture a description for an error code.
83
+ //
84
+ // @since 3.16.0.
85
+ type CodeDescription struct {
86
+ // Href an URI to open with more information about the diagnostic error.
87
+ Href URI `json:"href"`
88
+ }
89
+
77
90
// Diagnostic represents a diagnostic, such as a compiler error or warning.
78
91
//
79
92
// Diagnostic objects are only valid in the scope of a resource.
@@ -86,7 +99,12 @@ type Diagnostic struct {
86
99
Severity DiagnosticSeverity `json:"severity,omitempty"`
87
100
88
101
// Code is the diagnostic's code, which might appear in the user interface.
89
- Code interface {} `json:"code,omitempty"`
102
+ Code interface {} `json:"code,omitempty"` // int32 | string;
103
+
104
+ // CodeDescription an optional property to describe the error code.
105
+ //
106
+ // @since 3.16.0.
107
+ CodeDescription * CodeDescription `json:"codeDescription,omitempty"`
90
108
91
109
// Source a human-readable string describing the source of this
92
110
// diagnostic, e.g. 'typescript' or 'super lint'.
@@ -103,35 +121,42 @@ type Diagnostic struct {
103
121
// RelatedInformation an array of related diagnostic information, e.g. when symbol-names within
104
122
// a scope collide all definitions can be marked via this property.
105
123
RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
124
+
125
+ // Data is a data entry field that is preserved between a
126
+ // "textDocument/publishDiagnostics" notification and
127
+ // "textDocument/codeAction" request.
128
+ //
129
+ // @since 3.16.0.
130
+ Data interface {} `json:"data,omitempty"`
106
131
}
107
132
108
133
// DiagnosticSeverity indicates the severity of a Diagnostic message.
109
134
type DiagnosticSeverity float64
110
135
111
136
const (
112
- // SeverityError reports an error.
113
- SeverityError DiagnosticSeverity = 1
137
+ // DiagnosticSeverityError reports an error.
138
+ DiagnosticSeverityError DiagnosticSeverity = 1
114
139
115
- // SeverityWarning reports a warning.
116
- SeverityWarning DiagnosticSeverity = 2
140
+ // DiagnosticSeverityWarning reports a warning.
141
+ DiagnosticSeverityWarning DiagnosticSeverity = 2
117
142
118
- // SeverityInformation reports an information.
119
- SeverityInformation DiagnosticSeverity = 3
143
+ // DiagnosticSeverityInformation reports an information.
144
+ DiagnosticSeverityInformation DiagnosticSeverity = 3
120
145
121
- // SeverityHint reports a hint.
122
- SeverityHint DiagnosticSeverity = 4
146
+ // DiagnosticSeverityHint reports a hint.
147
+ DiagnosticSeverityHint DiagnosticSeverity = 4
123
148
)
124
149
125
150
// String implements fmt.Stringer.
126
151
func (d DiagnosticSeverity ) String () string {
127
152
switch d {
128
- case SeverityError :
153
+ case DiagnosticSeverityError :
129
154
return "Error"
130
- case SeverityWarning :
155
+ case DiagnosticSeverityWarning :
131
156
return "Warning"
132
- case SeverityInformation :
157
+ case DiagnosticSeverityInformation :
133
158
return "Information"
134
- case SeverityHint :
159
+ case DiagnosticSeverityHint :
135
160
return "Hint"
136
161
default :
137
162
return strconv .FormatFloat (float64 (d ), 'f' , - 10 , 64 )
@@ -145,24 +170,24 @@ type DiagnosticTag float64
145
170
146
171
// list of DiagnosticTag.
147
172
const (
148
- // DiagnosticUnnecessary unused or unnecessary code.
173
+ // DiagnosticTagUnnecessary unused or unnecessary code.
149
174
//
150
175
// Clients are allowed to render diagnostics with this tag faded out instead of having
151
176
// an error squiggle.
152
- DiagnosticUnnecessary DiagnosticTag = 1
177
+ DiagnosticTagUnnecessary DiagnosticTag = 1
153
178
154
- // DiagnosticDeprecated deprecated or obsolete code.
179
+ // DiagnosticTagDeprecated deprecated or obsolete code.
155
180
//
156
181
// Clients are allowed to rendered diagnostics with this tag strike through.
157
- DiagnosticDeprecated DiagnosticTag = 2
182
+ DiagnosticTagDeprecated DiagnosticTag = 2
158
183
)
159
184
160
185
// String implements fmt.Stringer.
161
186
func (d DiagnosticTag ) String () string {
162
187
switch d {
163
- case DiagnosticUnnecessary :
188
+ case DiagnosticTagUnnecessary :
164
189
return "Unnecessary"
165
- case DiagnosticDeprecated :
190
+ case DiagnosticTagDeprecated :
166
191
return "Deprecated"
167
192
default :
168
193
return strconv .FormatFloat (float64 (d ), 'f' , - 10 , 64 )
@@ -197,6 +222,39 @@ type Command struct {
197
222
Arguments []interface {} `json:"arguments,omitempty"`
198
223
}
199
224
225
+ // ChangeAnnotation is the additional information that describes document changes.
226
+ //
227
+ // @since 3.16.0.
228
+ type ChangeAnnotation struct {
229
+ // Label a human-readable string describing the actual change. The string
230
+ // is rendered prominent in the user interface.
231
+ Label string `json:"label"`
232
+
233
+ // NeedsConfirmation is a flag which indicates that user confirmation is needed
234
+ // before applying the change.
235
+ NeedsConfirmation bool `json:"needsConfirmation,omitempty"`
236
+
237
+ // Description is a human-readable string which is rendered less prominent in
238
+ // the user interface.
239
+ Description string `json:"description,omitempty"`
240
+ }
241
+
242
+ // ChangeAnnotationIdentifier an identifier referring to a change annotation managed by a workspace
243
+ // edit.
244
+ //
245
+ // @since 3.16.0.
246
+ type ChangeAnnotationIdentifier string
247
+
248
+ // AnnotatedTextEdit is a special text edit with an additional change annotation.
249
+ //
250
+ // @since 3.16.0.
251
+ type AnnotatedTextEdit struct {
252
+ TextEdit
253
+
254
+ // AnnotationID is the actual annotation identifier.
255
+ AnnotationID ChangeAnnotationIdentifier `json:"annotationId"`
256
+ }
257
+
200
258
// TextEdit is a textual edit applicable to a text document.
201
259
type TextEdit struct {
202
260
// Range is the range of the text document to be manipulated.
@@ -218,7 +276,10 @@ type TextDocumentEdit struct {
218
276
TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`
219
277
220
278
// Edits is the edits to be applied.
221
- Edits []TextEdit `json:"edits"`
279
+ //
280
+ // @since 3.16.0 - support for AnnotatedTextEdit.
281
+ // This is guarded by the client capability "workspace.workspaceEdit.changeAnnotationSupport".
282
+ Edits []TextEdit `json:"edits"` // []TextEdit | []AnnotatedTextEdit
222
283
}
223
284
224
285
// ResourceOperationKind is the file event type.
@@ -250,10 +311,15 @@ type CreateFile struct {
250
311
Kind ResourceOperationKind `json:"kind"` // should be `create`
251
312
252
313
// URI is the resource to create.
253
- URI uri. URI `json:"uri"`
314
+ URI DocumentURI `json:"uri"`
254
315
255
316
// Options additional options.
256
317
Options * CreateFileOptions `json:"options,omitempty"`
318
+
319
+ // AnnotationID an optional annotation identifier describing the operation.
320
+ //
321
+ // @since 3.16.0.
322
+ AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"`
257
323
}
258
324
259
325
// RenameFileOptions represents a rename file options.
@@ -271,13 +337,18 @@ type RenameFile struct {
271
337
Kind ResourceOperationKind `json:"kind"` // should be `rename`
272
338
273
339
// OldURI is the old (existing) location.
274
- OldURI uri. URI `json:"oldUri"`
340
+ OldURI DocumentURI `json:"oldUri"`
275
341
276
342
// NewURI is the new location.
277
- NewURI uri. URI `json:"newUri"`
343
+ NewURI DocumentURI `json:"newUri"`
278
344
279
345
// Options rename options.
280
346
Options * RenameFileOptions `json:"options,omitempty"`
347
+
348
+ // AnnotationID an optional annotation identifier describing the operation.
349
+ //
350
+ // @since 3.16.0.
351
+ AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"`
281
352
}
282
353
283
354
// DeleteFileOptions represents a delete file options.
@@ -295,10 +366,15 @@ type DeleteFile struct {
295
366
Kind ResourceOperationKind `json:"kind"` // should be `delete`
296
367
297
368
// URI is the file to delete.
298
- URI uri. URI `json:"uri"`
369
+ URI DocumentURI `json:"uri"`
299
370
300
371
// Options delete options.
301
372
Options * DeleteFileOptions `json:"options,omitempty"`
373
+
374
+ // AnnotationID an optional annotation identifier describing the operation.
375
+ //
376
+ // @since 3.16.0.
377
+ AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"`
302
378
}
303
379
304
380
// WorkspaceEdit represent a changes to many resources managed in the workspace.
@@ -307,7 +383,7 @@ type DeleteFile struct {
307
383
// If the client can handle versioned document edits and if documentChanges are present, the latter are preferred over changes.
308
384
type WorkspaceEdit struct {
309
385
// Changes holds changes to existing resources.
310
- Changes map [uri. URI ][]TextEdit `json:"changes,omitempty"`
386
+ Changes map [DocumentURI ][]TextEdit `json:"changes,omitempty"`
311
387
312
388
// DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
313
389
// are either an array of `TextDocumentEdit`s to express changes to n different text documents
@@ -320,25 +396,35 @@ type WorkspaceEdit struct {
320
396
// If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
321
397
// only plain `TextEdit`s using the `changes` property are supported.
322
398
DocumentChanges []TextDocumentEdit `json:"documentChanges,omitempty"`
399
+
400
+ // ChangeAnnotations is a map of change annotations that can be referenced in
401
+ // "AnnotatedTextEdit"s or create, rename and delete file / folder
402
+ // operations.
403
+ //
404
+ // Whether clients honor this property depends on the client capability
405
+ // "workspace.changeAnnotationSupport".
406
+ //
407
+ // @since 3.16.0.
408
+ ChangeAnnotations map [ChangeAnnotationIdentifier ]ChangeAnnotation `json:"changeAnnotations,omitempty"`
323
409
}
324
410
325
411
// TextDocumentIdentifier indicates the using a URI. On the protocol level, URIs are passed as strings.
326
412
type TextDocumentIdentifier struct {
327
413
// URI is the text document's URI.
328
- URI uri. URI `json:"uri"`
414
+ URI DocumentURI `json:"uri"`
329
415
}
330
416
331
417
// TextDocumentItem represent an item to transfer a text document from the client to the server.
332
418
type TextDocumentItem struct {
333
419
// URI is the text document's URI.
334
- URI uri. URI `json:"uri"`
420
+ URI DocumentURI `json:"uri"`
335
421
336
422
// LanguageID is the text document's language identifier.
337
423
LanguageID LanguageIdentifier `json:"languageId"`
338
424
339
425
// Version is the version number of this document (it will increase after each
340
426
// change, including undo/redo).
341
- Version float64 `json:"version"`
427
+ Version int32 `json:"version"`
342
428
343
429
// Text is the content of the opened text document.
344
430
Text string `json:"text"`
@@ -584,11 +670,11 @@ var languageIdentifierMap = map[string]LanguageIdentifier{
584
670
// ToLanguageIdentifier converts ft to LanguageIdentifier.
585
671
func ToLanguageIdentifier (ft string ) LanguageIdentifier {
586
672
langID , ok := languageIdentifierMap [ft ]
587
- if ! ok {
588
- return LanguageIdentifier ( ft )
673
+ if ok {
674
+ return langID
589
675
}
590
676
591
- return langID
677
+ return LanguageIdentifier ( ft )
592
678
}
593
679
594
680
// VersionedTextDocumentIdentifier represents an identifier to denote a specific version of a text document.
@@ -597,14 +683,29 @@ type VersionedTextDocumentIdentifier struct {
597
683
598
684
// Version is the version number of this document.
599
685
//
600
- // If a versioned text document identifier is sent from the server to the client and the file is not open in the editor
601
- // (the server has not received an open notification before) the server can send
602
- // `null` to indicate that the version is known and the content on disk is the
603
- // truth (as speced with document content ownership).
604
- //
605
686
// The version number of a document will increase after each change, including
606
687
// undo/redo. The number doesn't need to be consecutive.
607
- Version * uint64 `json:"version"`
688
+ Version int32 `json:"version"`
689
+ }
690
+
691
+ // OptionalVersionedTextDocumentIdentifier represents an identifier which optionally denotes a specific version of a text document.
692
+ //
693
+ // This information usually flows from the server to the client.
694
+ //
695
+ // @since 3.16.0.
696
+ type OptionalVersionedTextDocumentIdentifier struct {
697
+ TextDocumentIdentifier
698
+
699
+ // Version is the version number of this document. If an optional versioned text document
700
+ // identifier is sent from the server to the client and the file is not
701
+ // open in the editor (the server has not received an open notification
702
+ // before) the server can send `null` to indicate that the version is
703
+ // known and the content on disk is the master (as specified with document
704
+ // content ownership).
705
+ //
706
+ // The version number of a document will increase after each change,
707
+ // including undo/redo. The number doesn't need to be consecutive.
708
+ Version * int32 `json:"version"` // int32 | null
608
709
}
609
710
610
711
// TextDocumentPositionParams is a parameter literal used in requests to pass a text document and a position inside that document.
0 commit comments