-
Notifications
You must be signed in to change notification settings - Fork 328
/
protocol.ts
874 lines (756 loc) · 22.6 KB
/
protocol.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import { RequestType, NotificationType, ResponseError } from 'vscode-jsonrpc';
import {
TextDocument, TextDocumentChangeEvent, TextDocumentContentChangeEvent,
Range, Position, Location, Diagnostic, DiagnosticSeverity, Command,
TextEdit, WorkspaceEdit, WorkspaceChange, TextEditChange,
TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem,
CompletionItemKind, CompletionItem, CompletionList,
Hover, MarkedString,
SignatureHelp, SignatureInformation, ParameterInformation,
Definition, ReferenceContext,
DocumentHighlight, DocumentHighlightKind,
SymbolInformation, SymbolKind,
CodeLens, CodeActionContext,
FormattingOptions,
} from 'vscode-languageserver-types';
/**
* A parameter literal used in requests to pass a text document and a position inside that
* document.
*/
export interface TextDocumentPositionParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The position inside the text document.
*/
position: Position;
}
//---- Initialize Method ----
/**
* Defines the capabilities provided by the client.
*/
export interface ClientCapabilities {
}
/**
* Defines how the host (editor) should sync
* document changes to the language server.
*/
export enum TextDocumentSyncKind {
/**
* Documents should not be synced at all.
*/
None = 0,
/**
* Documents are synced by always sending the full content
* of the document.
*/
Full = 1,
/**
* Documents are synced by sending the full content on open.
* After that only incremental updates to the document are
* send.
*/
Incremental = 2
}
/**
* Completion options.
*/
export interface CompletionOptions {
/**
* The server provides support to resolve additional
* information for a completion item.
*/
resolveProvider?: boolean;
/**
* The characters that trigger completion automatically.
*/
triggerCharacters?: string[];
}
/**
* Signature help options.
*/
export interface SignatureHelpOptions {
/**
* The characters that trigger signature help
* automatically.
*/
triggerCharacters?: string[];
}
/**
* Code Lens options.
*/
export interface CodeLensOptions {
/**
* Code lens has a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Format document on type options
*/
export interface DocumentOnTypeFormattingOptions {
/**
* A character on which formatting should be triggered, like `}`.
*/
firstTriggerCharacter: string;
/**
* More trigger characters.
*/
moreTriggerCharacter?: string[]
}
/**
* Defines the capabilities provided by a language
* server.
*/
export interface ServerCapabilities {
/**
* Defines how text documents are synced.
*/
textDocumentSync?: number;
/**
* The server provides hover support.
*/
hoverProvider?: boolean;
/**
* The server provides completion support.
*/
completionProvider?: CompletionOptions;
/**
* The server provides signature help support.
*/
signatureHelpProvider?: SignatureHelpOptions;
/**
* The server provides goto definition support.
*/
definitionProvider?: boolean;
/**
* The server provides find references support.
*/
referencesProvider?: boolean;
/**
* The server provides document highlight support.
*/
documentHighlightProvider?: boolean;
/**
* The server provides document symbol support.
*/
documentSymbolProvider?: boolean;
/**
* The server provides workspace symbol support.
*/
workspaceSymbolProvider?: boolean;
/**
* The server provides code actions.
*/
codeActionProvider?: boolean;
/**
* The server provides code lens.
*/
codeLensProvider?: CodeLensOptions;
/**
* The server provides document formatting.
*/
documentFormattingProvider?: boolean;
/**
* The server provides document range formatting.
*/
documentRangeFormattingProvider?: boolean;
/**
* The server provides document formatting on typing.
*/
documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
/**
* The server provides rename support.
*/
renameProvider?: boolean
}
/**
* The initialize method is sent from the client to the server.
* It is send once as the first method after starting up the
* worker. The requests parameter is of type [InitializeParams](#InitializeParams)
* the response if of type [InitializeResult](#InitializeResult) of a Thenable that
* resolves to such.
*/
export namespace InitializeRequest {
export const type: RequestType<InitializeParams, InitializeResult, InitializeError> = { get method() { return 'initialize'; } };
}
/**
* The initialize parameters
*/
export interface InitializeParams {
/**
* The process Id of the parent process that started
* the server.
*/
processId: number;
/**
* The rootPath of the workspace. Is null
* if no folder is open.
*/
rootPath: string;
/**
* The capabilities provided by the client (editor)
*/
capabilities: ClientCapabilities;
/**
* User provided initialization options.
*/
initializationOptions: any;
}
/**
* The result returned from an initilize request.
*/
export interface InitializeResult {
/**
* The capabilities the language server provides.
*/
capabilities: ServerCapabilities;
}
/**
* The error returned if the initilize request fails.
*/
export interface InitializeError {
/**
* Indicates whether the client should retry to send the
* initilize request after showing the message provided
* in the {@link ResponseError}
*/
retry: boolean;
}
//---- Shutdown Method ----
/**
* A shutdown request is sent from the client to the server.
* It is send once when the client descides to shutdown the
* server. The only notification that is sent after a shudown request
* is the exit event.
*/
export namespace ShutdownRequest {
export const type: RequestType<void, void, void> = { get method() { return 'shutdown'; } };
}
//---- Exit Notification ----
/**
* The exit event is sent from the client to the server to
* ask the server to exit its process.
*/
export namespace ExitNotification {
export const type: NotificationType<void> = { get method() { return 'exit'; } };
}
//---- Configuration notification ----
/**
* The configuration change notification is sent from the client to the server
* when the client's configuration has changed. The notification contains
* the changed configuration as defined by the language client.
*/
export namespace DidChangeConfigurationNotification {
export const type: NotificationType<DidChangeConfigurationParams> = { get method() { return 'workspace/didChangeConfiguration'; } };
}
/**
* The parameters of a change configuration notification.
*/
export interface DidChangeConfigurationParams {
/**
* The actual changed settings
*/
settings: any;
}
//---- Message show and log notifications ----
/**
* The message type
*/
export enum MessageType {
/**
* An error message.
*/
Error = 1,
/**
* A warning message.
*/
Warning = 2,
/**
* An information message.
*/
Info = 3,
/**
* A log message.
*/
Log = 4
}
/**
* The parameters of a notification message.
*/
export interface ShowMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
/**
* The show message notification is sent from a server to a client to ask
* the client to display a particular message in the user interface.
*/
export namespace ShowMessageNotification {
export const type: NotificationType<ShowMessageParams> = { get method() { return 'window/showMessage'; } };
}
export interface MessageActionItem {
/**
* A short title like 'Retry', 'Open Log' etc.
*/
title: string;
}
export interface ShowMessageRequestParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
/**
* The message action items to present.
*/
actions?: MessageActionItem[];
}
/**
* The show message request is send from the server to the clinet to show a message
* and a set of options actions to the user.
*/
export namespace ShowMessageRequest {
export const type: RequestType<ShowMessageRequestParams, MessageActionItem, void> = { get method() { return 'window/showMessageRequest'; } };
}
/**
* The log message notification is send from the server to the client to ask
* the client to log a particular message.
*/
export namespace LogMessageNotification {
export let type: NotificationType<LogMessageParams> = { get method() { return 'window/logMessage'; } };
}
/**
* The log message parameters.
*/
export interface LogMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
//---- Telemetry notification
/**
* The telemetry event notification is send from the server to the client to ask
* the client to log telemetry data.
*/
export namespace TelemetryEventNotification {
export let type: NotificationType<any> = { get method() { return 'telemetry/event'; } };
}
//---- Text document notifications ----
/**
* The parameters send in a open text document notification
*/
export interface DidOpenTextDocumentParams {
/**
* The document that was opened.
*/
textDocument: TextDocumentItem;
}
/**
* The document open notification is sent from the client to the server to signal
* newly opened text documents. The document's truth is now managed by the client
* and the server must not try to read the document's truth using the document's
* uri.
*/
export namespace DidOpenTextDocumentNotification {
export const type: NotificationType<DidOpenTextDocumentParams> = { get method() { return 'textDocument/didOpen'; } };
}
/**
* An event describing a change to a text document. If range and rangeLength are omitted
* the new text is considered to be the full content of the document.
*/
export interface TextDocumentContentChangeEvent {
/**
* The range of the document that changed.
*/
range?: Range;
/**
* The length of the range that got replaced.
*/
rangeLength?: number;
/**
* The new text of the document.
*/
text: string;
}
/**
* The change text document notification's parameters.
*/
export interface DidChangeTextDocumentParams {
/**
* The document that did change. The version number points
* to the version after all provided content changes have
* been applied.
*/
textDocument: VersionedTextDocumentIdentifier;
/**
* The actual content changes.
*/
contentChanges: TextDocumentContentChangeEvent[];
}
/**
* The document change notification is sent from the client to the server to signal
* changes to a text document.
*/
export namespace DidChangeTextDocumentNotification {
export const type: NotificationType<DidChangeTextDocumentParams> = { get method() { return 'textDocument/didChange'; } };
}
/**
* The parameters send in a close text document notification
*/
export interface DidCloseTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The document close notification is sent from the client to the server when
* the document got closed in the client. The document's truth now exists
* where the document's uri points to (e.g. if the document's uri is a file uri
* the truth now exists on disk).
*/
export namespace DidCloseTextDocumentNotification {
export const type: NotificationType<DidCloseTextDocumentParams> = { get method() { return 'textDocument/didClose'; } };
}
/**
* The parameters send in a save text document notification
*/
export interface DidSaveTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The document save notification is sent from the client to the server when
* the document got saved in the client.
*/
export namespace DidSaveTextDocumentNotification {
export const type: NotificationType<DidSaveTextDocumentParams> = { get method() { return 'textDocument/didSave'; } };
}
//---- File eventing ----
/**
* The watched files notification is sent from the client to the server when
* the client detects changes to file watched by the lanaguage client.
*/
export namespace DidChangeWatchedFilesNotification {
export const type: NotificationType<DidChangeWatchedFilesParams> = { get method() { return 'workspace/didChangeWatchedFiles'; } };
}
/**
* The watched files change notification's parameters.
*/
export interface DidChangeWatchedFilesParams {
/**
* The actual file events.
*/
changes: FileEvent[];
}
/**
* The file event type
*/
export enum FileChangeType {
/**
* The file got created.
*/
Created = 1,
/**
* The file got changed.
*/
Changed = 2,
/**
* The file got deleted.
*/
Deleted = 3
}
/**
* An event describing a file change.
*/
export interface FileEvent {
/**
* The file's uri.
*/
uri: string;
/**
* The change type.
*/
type: number;
}
//---- Diagnostic notification ----
/**
* Diagnostics notification are sent from the server to the client to signal
* results of validation runs.
*/
export namespace PublishDiagnosticsNotification {
export const type: NotificationType<PublishDiagnosticsParams> = { get method() { return 'textDocument/publishDiagnostics'; } };
}
/**
* The publish diagnostic notification's parameters.
*/
export interface PublishDiagnosticsParams {
/**
* The URI for which diagnostic information is reported.
*/
uri: string;
/**
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
}
//---- Completion Support --------------------------
/**
* Request to request completion at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
* is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
* or a Thenable that resolves to such.
*/
export namespace CompletionRequest {
export const type: RequestType<TextDocumentPositionParams, CompletionItem[] | CompletionList, void> = { get method() { return 'textDocument/completion'; } };
}
/**
* Request to resolve additional information for a given completion item.The request's
* parameter is of type [CompletionItem](#CompletionItem) the response
* is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
*/
export namespace CompletionResolveRequest {
export const type: RequestType<CompletionItem, CompletionItem, void> = { get method() { return 'completionItem/resolve'; } };
}
//---- Hover Support -------------------------------
export type MarkedString = string | { language: string; value: string };
/**
* Request to request hover information at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
* type [Hover](#Hover) or a Thenable that resolves to such.
*/
export namespace HoverRequest {
export const type: RequestType<TextDocumentPositionParams, Hover, void> = { get method() { return 'textDocument/hover'; } };
}
//---- SignatureHelp ----------------------------------
export namespace SignatureHelpRequest {
export const type: RequestType<TextDocumentPositionParams, SignatureHelp, void> = { get method() { return 'textDocument/signatureHelp'; } };
}
//---- Goto Definition -------------------------------------
/**
* A request to resolve the defintion location of a symbol at a given text
* document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the response is of type [Definition](#Definition) or a
* Thenable that resolves to such.
*/
export namespace DefinitionRequest {
export const type: RequestType<TextDocumentPositionParams, Definition, void> = { get method() { return 'textDocument/definition'; } };
}
//---- Reference Provider ----------------------------------
/**
* Parameters for a [ReferencesRequest](#ReferencesRequest).
*/
export interface ReferenceParams extends TextDocumentPositionParams {
context: ReferenceContext
}
/**
* A request to resolve project-wide references for the symbol denoted
* by the given text document position. The request's parameter is of
* type [ReferenceParams](#ReferenceParams) the response is of type
* [Location[]](#Location) or a Thenable that resolves to such.
*/
export namespace ReferencesRequest {
export const type: RequestType<ReferenceParams, Location[], void> = { get method() { return 'textDocument/references'; } };
}
//---- Document Highlight ----------------------------------
/**
* Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
* text document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the request reponse is of type [DocumentHighlight[]]
* (#DocumentHighlight) or a Thenable that resolves to such.
*/
export namespace DocumentHighlightRequest {
export const type: RequestType<TextDocumentPositionParams, DocumentHighlight[], void> = { get method() { return 'textDocument/documentHighlight'; } };
}
//---- Document Symbol Provider ---------------------------
/**
* Parameters for a [DocumentSymbolRequest](#DocumentSymbolRequest).
*/
export interface DocumentSymbolParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to list all symbols found in a given text document. The request's
* parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
* response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
* that resolves to such.
*/
export namespace DocumentSymbolRequest {
export const type: RequestType<DocumentSymbolParams, SymbolInformation[], void> = { get method() { return 'textDocument/documentSymbol'; } };
}
//---- Workspace Symbol Provider ---------------------------
/**
* The parameters of a [WorkspaceSymbolRequest](#WorkspaceSymbolRequest).
*/
export interface WorkspaceSymbolParams {
/**
* A non-empty query string
*/
query: string;
}
/**
* A request to list project-wide symbols matching the query string given
* by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
* of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
* resolves to such.
*/
export namespace WorkspaceSymbolRequest {
export const type: RequestType<WorkspaceSymbolParams, SymbolInformation[], void> = { get method() { return 'workspace/symbol'; } };
}
//---- Code Action Provider ----------------------------------
/**
* Params for the CodeActionRequest
*/
export interface CodeActionParams {
/**
* The document in which the command was invoked.
*/
textDocument: TextDocumentIdentifier;
/**
* The range for which the command was invoked.
*/
range: Range;
/**
* Context carrying additional information.
*/
context: CodeActionContext;
}
/**
* A request to provide commands for the given text document and range.
*/
export namespace CodeActionRequest {
export const type: RequestType<CodeActionParams, Command[], void> = { get method() { return 'textDocument/codeAction'; } };
}
//---- Code Lens Provider -------------------------------------------
/**
* Params for the Code Lens request.
*/
export interface CodeLensParams {
/**
* The document to request code lens for.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to provide code lens for the given text document.
*/
export namespace CodeLensRequest {
export const type: RequestType<CodeLensParams, CodeLens[], void> = { get method() { return 'textDocument/codeLens'; } };
}
/**
* A request to resolve a command for a given code lens.
*/
export namespace CodeLensResolveRequest {
export const type: RequestType<CodeLens, CodeLens, void> = { get method() { return 'codeLens/resolve'; } };
}
//---- Formatting ----------------------------------------------
export interface DocumentFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The format options
*/
options: FormattingOptions;
}
/**
* A request to to format a whole document.
*/
export namespace DocumentFormattingRequest {
export const type: RequestType<DocumentFormattingParams, TextEdit[], void> = { get method() { return 'textDocument/formatting'; } };
}
export interface DocumentRangeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The range to format
*/
range: Range;
/**
* The format options
*/
options: FormattingOptions;
}
/**
* A request to to format a range in a document.
*/
export namespace DocumentRangeFormattingRequest {
export const type: RequestType<DocumentRangeFormattingParams, TextEdit[], void> = { get method() { return 'textDocument/rangeFormatting'; } };
}
export interface DocumentOnTypeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was send.
*/
position: Position;
/**
* The character that has been typed.
*/
ch: string;
/**
* The format options.
*/
options: FormattingOptions;
}
/**
* A request to format a document on type.
*/
export namespace DocumentOnTypeFormattingRequest {
export const type: RequestType<DocumentOnTypeFormattingParams, TextEdit[], void> = { get method() { return 'textDocument/onTypeFormatting'; } };
}
//---- Rename ----------------------------------------------
export interface RenameParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was send.
*/
position: Position;
/**
* The new name of the symbol. If the given name is not valid the
* request must return a [ResponseError](#ResponseError) with an
* appropriate message set.
*/
newName: string;
}
/**
* A request to rename a symbol.
*/
export namespace RenameRequest {
export const type: RequestType<RenameParams, WorkspaceEdit, void> = { get method() { return 'textDocument/rename'; } };
}