@jupyterlab/lsp 4.0.0-alpha.19 → 4.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tokens.ts ADDED
@@ -0,0 +1,872 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { IDocumentWidget } from '@jupyterlab/docregistry';
5
+ import { ServerConnection } from '@jupyterlab/services';
6
+ import { Token } from '@lumino/coreutils';
7
+ import { IDisposable, IObservableDisposable } from '@lumino/disposable';
8
+ import { ISignal, Signal } from '@lumino/signaling';
9
+
10
+ import { WidgetLSPAdapter } from './adapters/adapter';
11
+ import { IForeignCodeExtractor } from './extractors/types';
12
+ import {
13
+ AnyCompletion,
14
+ AnyLocation,
15
+ ClientCapabilities,
16
+ LanguageIdentifier
17
+ } from './lsp';
18
+ import { LanguageServer1 as LSPLanguageServerSettings } from './plugin';
19
+ import * as SCHEMA from './schema';
20
+ import { VirtualDocument } from './virtual/document';
21
+ import {
22
+ IDocumentInfo,
23
+ ILspConnection,
24
+ ILspOptions
25
+ } from './ws-connection/types';
26
+
27
+ import type * as rpc from 'vscode-jsonrpc';
28
+ import type * as lsp from 'vscode-languageserver-protocol';
29
+ import { CodeEditor } from '@jupyterlab/codeeditor';
30
+ export { IDocumentInfo };
31
+
32
+ /**
33
+ * Example server keys==ids that are expected. The list is not exhaustive.
34
+ * Custom server keys are allowed. Constraining the values helps avoid errors,
35
+ * but at runtime any value is allowed.
36
+ */
37
+ export type TLanguageServerId =
38
+ | 'pylsp'
39
+ | 'bash-language-server'
40
+ | 'dockerfile-language-server-nodejs'
41
+ | 'javascript-typescript-langserver'
42
+ | 'unified-language-server'
43
+ | 'vscode-css-languageserver-bin'
44
+ | 'vscode-html-languageserver-bin'
45
+ | 'vscode-json-languageserver-bin'
46
+ | 'yaml-language-server'
47
+ | 'r-languageserver';
48
+
49
+ /**
50
+ * Type alias for the server ids.
51
+ */
52
+ export type TServerKeys = TLanguageServerId;
53
+
54
+ /**
55
+ * Type of language server configuration, it is a map between server
56
+ * id and its setting.
57
+ */
58
+ export type TLanguageServerConfigurations = Partial<
59
+ Record<TServerKeys, LSPLanguageServerSettings>
60
+ >;
61
+
62
+ /**
63
+ * Type of language server session, it is a map between server
64
+ * id and the associated session.
65
+ */
66
+ export type TSessionMap = Map<TServerKeys, SCHEMA.LanguageServerSession>;
67
+
68
+ /**
69
+ * Type of language server specs, it is a map between server
70
+ * id and the associated specs.
71
+ */
72
+ export type TSpecsMap = Map<TServerKeys, SCHEMA.LanguageServerSpec>;
73
+
74
+ /**
75
+ * Type alias for language server id, it helps to clarify other types.
76
+ */
77
+ export type TLanguageId = string;
78
+
79
+ export interface ILanguageServerManager extends IDisposable {
80
+ /**
81
+ * @alpha
82
+ *
83
+ * Signal emitted when the language server sessions are changed.
84
+ */
85
+ sessionsChanged: ISignal<ILanguageServerManager, void>;
86
+
87
+ /**
88
+ * @alpha
89
+ *
90
+ * The current session information of running language servers.
91
+ */
92
+ readonly sessions: TSessionMap;
93
+
94
+ /**
95
+ * @alpha
96
+ *
97
+ * A promise that is fulfilled when the connection manager is ready.
98
+ */
99
+ readonly ready: Promise<void>;
100
+
101
+ /**
102
+ * @alpha
103
+ *
104
+ * Current endpoint to get the status of running language servers
105
+ */
106
+ readonly statusUrl: string;
107
+
108
+ /**
109
+ * @alpha
110
+ *
111
+ * Status code of the `fetchSession` request.
112
+ */
113
+ readonly statusCode: number;
114
+
115
+ /**
116
+ * @alpha
117
+ *
118
+ * Check if the manager is enabled or disabled
119
+ */
120
+ readonly isEnabled: boolean;
121
+
122
+ /**
123
+ * @alpha
124
+ *
125
+ * Enable the language server services
126
+ */
127
+ enable(): void;
128
+
129
+ /**
130
+ * @alpha
131
+ *
132
+ * Disable the language server services
133
+ */
134
+ disable(): void;
135
+
136
+ /**
137
+ * @alpha
138
+ *
139
+ * An ordered list of matching >running< sessions, with servers of higher rank higher in the list
140
+ */
141
+ getMatchingServers(
142
+ options: ILanguageServerManager.IGetServerIdOptions
143
+ ): TLanguageServerId[];
144
+
145
+ /**
146
+ * @alpha
147
+ *
148
+ * A list of all known matching specs (whether detected or not).
149
+ */
150
+ getMatchingSpecs(
151
+ options: ILanguageServerManager.IGetServerIdOptions
152
+ ): TSpecsMap;
153
+
154
+ /**
155
+ * @alpha
156
+ *
157
+ * Set the configuration for language servers
158
+ */
159
+ setConfiguration(configuration: TLanguageServerConfigurations): void;
160
+
161
+ /**
162
+ * @alpha
163
+ *
164
+ * Send a request to language server handler to get the session information.
165
+ */
166
+ fetchSessions(): Promise<void>;
167
+ }
168
+
169
+ /**
170
+ * Virtual document namespace
171
+ */
172
+ export namespace Document {
173
+ /**
174
+ * Code block description.
175
+ */
176
+ export interface ICodeBlockOptions {
177
+ /**
178
+ * CodeEditor accessor
179
+ */
180
+ ceEditor: IEditor;
181
+
182
+ /**
183
+ * Type of the cell holding this block
184
+ */
185
+ type: string;
186
+
187
+ /**
188
+ * Editor text
189
+ *
190
+ * #### Notes
191
+ * This must always be available and should come from the document model directly.
192
+ */
193
+ value: string;
194
+ }
195
+
196
+ /**
197
+ * Code editor accessor.
198
+ */
199
+ export interface IEditor {
200
+ /**
201
+ * CodeEditor getter.
202
+ *
203
+ * It will return `null` if the editor is not yet instantiated;
204
+ * e.g. to support windowed notebook.
205
+ */
206
+ getEditor(): CodeEditor.IEditor | null;
207
+
208
+ /**
209
+ * Promise getter that resolved when the editor is instantiated.
210
+ */
211
+ ready(): Promise<CodeEditor.IEditor>;
212
+
213
+ /**
214
+ * Reveal the code editor in viewport.
215
+ *
216
+ * ### Notes
217
+ * The promise will resolve when the editor is instantiated and in
218
+ * the viewport.
219
+ */
220
+ reveal(): Promise<CodeEditor.IEditor>;
221
+ }
222
+
223
+ /**
224
+ * Foreign context within code block.
225
+ */
226
+ export interface IForeignContext {
227
+ /**
228
+ * The virtual document
229
+ */
230
+ foreignDocument: VirtualDocument;
231
+
232
+ /**
233
+ * The document holding the virtual document.
234
+ */
235
+ parentHost: VirtualDocument;
236
+ }
237
+
238
+ /**
239
+ * Virtual document block.
240
+ */
241
+ export interface IVirtualDocumentBlock {
242
+ /**
243
+ * Line corresponding to the block in the entire foreign document
244
+ */
245
+ virtualLine: number;
246
+
247
+ /**
248
+ * The virtual document holding this virtual line.
249
+ */
250
+ virtualDocument: VirtualDocument;
251
+
252
+ /**
253
+ * The CM editor associated with this virtual line.
254
+ */
255
+ editor: IEditor;
256
+ }
257
+ }
258
+
259
+ export namespace ILanguageServerManager {
260
+ /**
261
+ * LSP endpoint prefix.
262
+ */
263
+ export const URL_NS = 'lsp';
264
+
265
+ export interface IOptions {
266
+ /**
267
+ * The Jupyter server settings objec
268
+ */
269
+ settings?: ServerConnection.ISettings;
270
+
271
+ /**
272
+ * Base URL of current JupyterLab server.
273
+ */
274
+ baseUrl?: string;
275
+
276
+ /**
277
+ * Number of connection retries to fetch the sessions.
278
+ * Default 2.
279
+ */
280
+ retries?: number;
281
+
282
+ /**
283
+ * The interval for retries, default 10 seconds.
284
+ */
285
+ retriesInterval?: number;
286
+ }
287
+ /**
288
+ * The argument for getting server session or specs.
289
+ */
290
+ export interface IGetServerIdOptions {
291
+ /**
292
+ * Language server id
293
+ */
294
+ language?: TLanguageId;
295
+
296
+ /**
297
+ * Server specs mime type.
298
+ */
299
+ mimeType?: string;
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Option to create the websocket connection to the LSP proxy server
305
+ * on the backend.
306
+ */
307
+ export interface ISocketConnectionOptions {
308
+ /**
309
+ * The virtual document trying to connect to the LSP server.
310
+ */
311
+ virtualDocument: VirtualDocument;
312
+
313
+ /**
314
+ * The language identifier, corresponding to the API endpoint on the
315
+ * LSP proxy server.
316
+ */
317
+ language: string;
318
+
319
+ /**
320
+ * LSP capabilities describing currently supported features
321
+ */
322
+ capabilities: ClientCapabilities;
323
+
324
+ /**
325
+ * Is the file format is supported by LSP?
326
+ */
327
+ hasLspSupportedFile: boolean;
328
+ }
329
+
330
+ /**
331
+ * @alpha
332
+ *
333
+ * Interface describing the LSP connection state
334
+ */
335
+ export interface IDocumentConnectionData {
336
+ /**
337
+ * The virtual document connected to the language server
338
+ */
339
+ virtualDocument: VirtualDocument;
340
+ /**
341
+ * The connection between the virtual document and the language server.
342
+ */
343
+ connection: ILSPConnection;
344
+ }
345
+
346
+ /**
347
+ * @alpha
348
+ *
349
+ * The LSP connection state manager
350
+ */
351
+ export interface ILSPDocumentConnectionManager {
352
+ /**
353
+ * The mapping of document uri to the connection to language server.
354
+ */
355
+ connections: Map<VirtualDocument.uri, ILSPConnection>;
356
+
357
+ /**
358
+ * The mapping of document uri to the virtual document.
359
+ */
360
+ documents: Map<VirtualDocument.uri, VirtualDocument>;
361
+
362
+ /**
363
+ * The mapping of document uri to the widget adapter.
364
+ */
365
+ adapters: Map<string, WidgetLSPAdapter<IDocumentWidget>>;
366
+
367
+ /**
368
+ * Signal emitted when a connection is connected.
369
+ */
370
+ connected: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
371
+
372
+ /**
373
+ * Signal emitted when a connection is disconnected.
374
+ */
375
+ disconnected: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
376
+
377
+ /**
378
+ * Signal emitted when the language server is initialized.
379
+ */
380
+ initialized: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
381
+
382
+ /**
383
+ * Signal emitted when a virtual document is closed.
384
+ */
385
+ closed: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
386
+
387
+ /**
388
+ * Signal emitted when the content of a virtual document is changed.
389
+ */
390
+ documentsChanged: ISignal<
391
+ ILSPDocumentConnectionManager,
392
+ Map<VirtualDocument.uri, VirtualDocument>
393
+ >;
394
+
395
+ /**
396
+ * The language server manager instance.
397
+ */
398
+ languageServerManager: ILanguageServerManager;
399
+
400
+ /**
401
+ * A promise that is fulfilled when the connection manager is ready.
402
+ */
403
+ readonly ready: Promise<void>;
404
+
405
+ /**
406
+ * Handles the settings that do not require an existing connection
407
+ * with a language server (or can influence to which server the
408
+ * connection will be created, e.g. `rank`).
409
+ *
410
+ * This function should be called **before** initialization of servers.
411
+ */
412
+ updateConfiguration(allServerSettings: TLanguageServerConfigurations): void;
413
+
414
+ /**
415
+ * Handles the settings that the language servers accept using
416
+ * `onDidChangeConfiguration` messages, which should be passed under
417
+ * the "serverSettings" keyword in the setting registry.
418
+ * Other configuration options are handled by `updateConfiguration` instead.
419
+ *
420
+ * This function should be called **after** initialization of servers.
421
+ */
422
+ updateServerConfigurations(
423
+ allServerSettings: TLanguageServerConfigurations
424
+ ): void;
425
+
426
+ /**
427
+ * Retry to connect to the server each `reconnectDelay` seconds
428
+ * and for `retrialsLeft` times.
429
+ */
430
+ retryToConnect(
431
+ options: ISocketConnectionOptions,
432
+ reconnectDelay: number,
433
+ retrialsLeft: number
434
+ ): Promise<void>;
435
+
436
+ /**
437
+ * Create a new connection to the language server
438
+ * @return A promise of the LSP connection
439
+ */
440
+ connect(
441
+ options: ISocketConnectionOptions,
442
+ firstTimeoutSeconds?: number,
443
+ secondTimeoutMinute?: number
444
+ ): Promise<ILSPConnection | undefined>;
445
+
446
+ /**
447
+ * Disconnect the connection to the language server of the requested
448
+ * language.
449
+ */
450
+ disconnect(languageId: TLanguageServerId): void;
451
+
452
+ /**
453
+ * Disconnect the signals of requested virtual document uri.
454
+ */
455
+ unregisterDocument(uri: string): void;
456
+
457
+ /**
458
+ * Register a widget adapter.
459
+ *
460
+ * @param path - path to current document widget of input adapter
461
+ * @param adapter - the adapter need to be registered
462
+ */
463
+ registerAdapter(
464
+ path: string,
465
+ adapter: WidgetLSPAdapter<IDocumentWidget>
466
+ ): void;
467
+ }
468
+
469
+ /**
470
+ * @alpha
471
+ *
472
+ * Interface describing the client feature
473
+ */
474
+ export interface IFeature {
475
+ /**
476
+ * The feature identifier. It must be the same as the feature plugin id.
477
+ */
478
+ id: string;
479
+
480
+ /**
481
+ * LSP capabilities implemented by the feature.
482
+ */
483
+ capabilities?: ClientCapabilities;
484
+ }
485
+
486
+ /**
487
+ * @alpha
488
+ *
489
+ * The LSP feature manager
490
+ */
491
+ export interface ILSPFeatureManager {
492
+ /**
493
+ * A read-only registry of all registered features.
494
+ */
495
+ readonly features: IFeature[];
496
+
497
+ /**
498
+ * Register the new feature (frontend capability)
499
+ * for one or more code editor implementations.
500
+ */
501
+ register(feature: IFeature): void;
502
+
503
+ /**
504
+ * Signal emitted when a feature is registered
505
+ */
506
+ featuresRegistered: ISignal<ILSPFeatureManager, IFeature>;
507
+
508
+ /**
509
+ * Get capabilities of all registered features
510
+ */
511
+ clientCapabilities(): ClientCapabilities;
512
+ }
513
+
514
+ /**
515
+ * @alpha
516
+ *
517
+ * Manages code transclusion plugins.
518
+ */
519
+ export interface ILSPCodeExtractorsManager {
520
+ /**
521
+ * Get the foreign code extractors.
522
+ */
523
+ getExtractors(
524
+ cellType: string,
525
+ hostLanguage: string | null
526
+ ): IForeignCodeExtractor[];
527
+
528
+ /**
529
+ * Register the extraction rules to be applied in documents with language `host_language`.
530
+ */
531
+ register(
532
+ extractor: IForeignCodeExtractor,
533
+ hostLanguage: LanguageIdentifier | null
534
+ ): void;
535
+ }
536
+
537
+ /**
538
+ * @alpha
539
+ *
540
+ * The virtual documents and language server connections manager
541
+ * Require this token in your extension to access the associated virtual
542
+ * document and LS connection of opened documents.
543
+ *
544
+ */
545
+ export const ILSPDocumentConnectionManager =
546
+ new Token<ILSPDocumentConnectionManager>(
547
+ '@jupyterlab/lsp:ILSPDocumentConnectionManager'
548
+ );
549
+
550
+ /**
551
+ * @alpha
552
+ *
553
+ * The language server feature manager. Require this token in your extension
554
+ * to register the client capabilities implemented by your extension.
555
+ *
556
+ */
557
+ export const ILSPFeatureManager = new Token<ILSPFeatureManager>(
558
+ '@jupyterlab/lsp:ILSPFeatureManager'
559
+ );
560
+
561
+ /**
562
+ * @alpha
563
+ *
564
+ * The code extractor manager. Require this token in your extension to
565
+ * register new code extractors. Code extractor allows creating multiple
566
+ * virtual documents from an opened document.
567
+ *
568
+ */
569
+ export const ILSPCodeExtractorsManager = new Token<ILSPCodeExtractorsManager>(
570
+ '@jupyterlab/lsp:ILSPCodeExtractorsManager'
571
+ );
572
+
573
+ /**
574
+ * Argument for creating a connection to the LSP proxy server.
575
+ */
576
+ export interface ILSPOptions extends ILspOptions {
577
+ /**
578
+ * Client capabilities implemented by the client.
579
+ */
580
+ capabilities: ClientCapabilities;
581
+
582
+ /**
583
+ * Language server id.
584
+ */
585
+ serverIdentifier?: string;
586
+ }
587
+
588
+ /**
589
+ * Method strings are reproduced here because a non-typing import of
590
+ * `vscode-languageserver-protocol` is ridiculously expensive.
591
+ */
592
+ export namespace Method {
593
+ /** Server notifications */
594
+ export enum ServerNotification {
595
+ PUBLISH_DIAGNOSTICS = 'textDocument/publishDiagnostics',
596
+ SHOW_MESSAGE = 'window/showMessage',
597
+ LOG_TRACE = '$/logTrace',
598
+ LOG_MESSAGE = 'window/logMessage'
599
+ }
600
+
601
+ /** Client notifications */
602
+ export enum ClientNotification {
603
+ DID_CHANGE = 'textDocument/didChange',
604
+ DID_CHANGE_CONFIGURATION = 'workspace/didChangeConfiguration',
605
+ DID_OPEN = 'textDocument/didOpen',
606
+ DID_SAVE = 'textDocument/didSave',
607
+ INITIALIZED = 'initialized',
608
+ SET_TRACE = '$/setTrace'
609
+ }
610
+
611
+ /** Server requests */
612
+ export enum ServerRequest {
613
+ REGISTER_CAPABILITY = 'client/registerCapability',
614
+ SHOW_MESSAGE_REQUEST = 'window/showMessageRequest',
615
+ UNREGISTER_CAPABILITY = 'client/unregisterCapability',
616
+ WORKSPACE_CONFIGURATION = 'workspace/configuration'
617
+ }
618
+
619
+ /** Client requests */
620
+ export enum ClientRequest {
621
+ COMPLETION = 'textDocument/completion',
622
+ COMPLETION_ITEM_RESOLVE = 'completionItem/resolve',
623
+ DEFINITION = 'textDocument/definition',
624
+ DOCUMENT_HIGHLIGHT = 'textDocument/documentHighlight',
625
+ DOCUMENT_SYMBOL = 'textDocument/documentSymbol',
626
+ HOVER = 'textDocument/hover',
627
+ IMPLEMENTATION = 'textDocument/implementation',
628
+ INITIALIZE = 'initialize',
629
+ REFERENCES = 'textDocument/references',
630
+ RENAME = 'textDocument/rename',
631
+ SIGNATURE_HELP = 'textDocument/signatureHelp',
632
+ TYPE_DEFINITION = 'textDocument/typeDefinition'
633
+ }
634
+ }
635
+
636
+ /**
637
+ * Interface describing the notifications that come from the server.
638
+ */
639
+ export interface IServerNotifyParams {
640
+ [Method.ServerNotification.LOG_MESSAGE]: lsp.LogMessageParams;
641
+ [Method.ServerNotification.LOG_TRACE]: rpc.LogTraceParams;
642
+ [Method.ServerNotification.PUBLISH_DIAGNOSTICS]: lsp.PublishDiagnosticsParams;
643
+ [Method.ServerNotification.SHOW_MESSAGE]: lsp.ShowMessageParams;
644
+ }
645
+
646
+ /**
647
+ * Interface describing the notifications that come from the client.
648
+ */
649
+ export interface IClientNotifyParams {
650
+ [Method.ClientNotification
651
+ .DID_CHANGE_CONFIGURATION]: lsp.DidChangeConfigurationParams;
652
+ [Method.ClientNotification.DID_CHANGE]: lsp.DidChangeTextDocumentParams;
653
+ [Method.ClientNotification.DID_OPEN]: lsp.DidOpenTextDocumentParams;
654
+ [Method.ClientNotification.DID_SAVE]: lsp.DidSaveTextDocumentParams;
655
+ [Method.ClientNotification.INITIALIZED]: lsp.InitializedParams;
656
+ [Method.ClientNotification.SET_TRACE]: rpc.SetTraceParams;
657
+ }
658
+
659
+ /**
660
+ * Interface describing the requests sent to the server.
661
+ */
662
+ export interface IServerRequestParams {
663
+ [Method.ServerRequest.REGISTER_CAPABILITY]: lsp.RegistrationParams;
664
+ [Method.ServerRequest.SHOW_MESSAGE_REQUEST]: lsp.ShowMessageRequestParams;
665
+ [Method.ServerRequest.UNREGISTER_CAPABILITY]: lsp.UnregistrationParams;
666
+ [Method.ServerRequest.WORKSPACE_CONFIGURATION]: lsp.ConfigurationParams;
667
+ }
668
+
669
+ /**
670
+ * Interface describing the responses received from the server.
671
+ */
672
+ export interface IServerResult {
673
+ [Method.ServerRequest.REGISTER_CAPABILITY]: void;
674
+ [Method.ServerRequest.SHOW_MESSAGE_REQUEST]: lsp.MessageActionItem | null;
675
+ [Method.ServerRequest.UNREGISTER_CAPABILITY]: void;
676
+ [Method.ServerRequest.WORKSPACE_CONFIGURATION]: any[];
677
+ }
678
+
679
+ /**
680
+ * Interface describing the request sent to the client.
681
+ */
682
+ export interface IClientRequestParams {
683
+ [Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
684
+ [Method.ClientRequest.COMPLETION]: lsp.CompletionParams;
685
+ [Method.ClientRequest.DEFINITION]: lsp.TextDocumentPositionParams;
686
+ [Method.ClientRequest.DOCUMENT_HIGHLIGHT]: lsp.TextDocumentPositionParams;
687
+ [Method.ClientRequest.DOCUMENT_SYMBOL]: lsp.DocumentSymbolParams;
688
+ [Method.ClientRequest.HOVER]: lsp.TextDocumentPositionParams;
689
+ [Method.ClientRequest.IMPLEMENTATION]: lsp.TextDocumentPositionParams;
690
+ [Method.ClientRequest.INITIALIZE]: lsp.InitializeParams;
691
+ [Method.ClientRequest.REFERENCES]: lsp.ReferenceParams;
692
+ [Method.ClientRequest.RENAME]: lsp.RenameParams;
693
+ [Method.ClientRequest.SIGNATURE_HELP]: lsp.TextDocumentPositionParams;
694
+ [Method.ClientRequest.TYPE_DEFINITION]: lsp.TextDocumentPositionParams;
695
+ }
696
+
697
+ /**
698
+ * Interface describing the responses received from the client.
699
+ */
700
+ export interface IClientResult {
701
+ [Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
702
+ [Method.ClientRequest.COMPLETION]: AnyCompletion;
703
+ [Method.ClientRequest.DEFINITION]: AnyLocation;
704
+ [Method.ClientRequest.DOCUMENT_HIGHLIGHT]: lsp.DocumentHighlight[];
705
+ [Method.ClientRequest.DOCUMENT_SYMBOL]: lsp.DocumentSymbol[];
706
+ [Method.ClientRequest.HOVER]: lsp.Hover | null;
707
+ [Method.ClientRequest.IMPLEMENTATION]: AnyLocation;
708
+ [Method.ClientRequest.INITIALIZE]: lsp.InitializeResult;
709
+ [Method.ClientRequest.REFERENCES]: lsp.Location[] | null;
710
+ [Method.ClientRequest.RENAME]: lsp.WorkspaceEdit;
711
+ [Method.ClientRequest.SIGNATURE_HELP]: lsp.SignatureHelp;
712
+ [Method.ClientRequest.TYPE_DEFINITION]: AnyLocation;
713
+ }
714
+
715
+ /**
716
+ * Type of server notification handlers, it is a map between the server
717
+ * notification name and the associated `ISignal`.
718
+ */
719
+ export type ServerNotifications<
720
+ T extends keyof IServerNotifyParams = keyof IServerNotifyParams
721
+ > = {
722
+ readonly [key in T]: ISignal<ILSPConnection, IServerNotifyParams[key]>;
723
+ };
724
+
725
+ /**
726
+ * Type of client notification handlers, it is a map between the client
727
+ * notification name and the associated signal.
728
+ */
729
+ export type ClientNotifications<
730
+ T extends keyof IClientNotifyParams = keyof IClientNotifyParams
731
+ > = {
732
+ readonly [key in T]: Signal<ILSPConnection, IClientNotifyParams[key]>;
733
+ };
734
+
735
+ /**
736
+ * Interface describing the client request handler.
737
+ */
738
+ export interface IClientRequestHandler<
739
+ T extends keyof IClientRequestParams = keyof IClientRequestParams
740
+ > {
741
+ request(params: IClientRequestParams[T]): Promise<IClientResult[T]>;
742
+ }
743
+
744
+ /**
745
+ * Interface describing the server request handler.
746
+ */
747
+ export interface IServerRequestHandler<
748
+ T extends keyof IServerRequestParams = keyof IServerRequestParams
749
+ > {
750
+ setHandler(
751
+ handler: (
752
+ params: IServerRequestParams[T],
753
+ connection?: ILSPConnection
754
+ ) => Promise<IServerResult[T]>
755
+ ): void;
756
+ clearHandler(): void;
757
+ }
758
+
759
+ /**
760
+ * Type of client request handlers, it is a map between the client
761
+ * request name and the associated handler.
762
+ */
763
+ export type ClientRequests<
764
+ T extends keyof IClientRequestParams = keyof IClientRequestParams
765
+ > = {
766
+ readonly // has async request(params) returning a promise with result.
767
+ [key in T]: IClientRequestHandler<key>;
768
+ };
769
+
770
+ /**
771
+ * Type of server request handlers, it is a map between the server
772
+ * request name and the associated handler.
773
+ */
774
+ export type ServerRequests<
775
+ T extends keyof IServerRequestParams = keyof IServerRequestParams
776
+ > = {
777
+ readonly // has async request(params) returning a promise with result.
778
+ [key in T]: IServerRequestHandler<key>;
779
+ };
780
+
781
+ /**
782
+ * @alpha
783
+ *
784
+ * Interface describing he connection to the language server.
785
+ */
786
+ export interface ILSPConnection extends ILspConnection, IObservableDisposable {
787
+ /**
788
+ * @alpha
789
+ *
790
+ * Identifier of the language server
791
+ */
792
+ serverIdentifier?: string;
793
+
794
+ /**
795
+ * @alpha
796
+ *
797
+ * Language of the language server
798
+ */
799
+ serverLanguage?: string;
800
+
801
+ /**
802
+ * @alpha
803
+ *
804
+ * Should log all communication?
805
+ */
806
+ logAllCommunication: boolean;
807
+
808
+ /**
809
+ * @alpha
810
+ *
811
+ * Notifications that come from the client.
812
+ */
813
+ clientNotifications: ClientNotifications;
814
+
815
+ /**
816
+ * @alpha
817
+ *
818
+ * Notifications that come from the server.
819
+ */
820
+ serverNotifications: ServerNotifications;
821
+
822
+ /**
823
+ * @alpha
824
+ *
825
+ * Requests that come from the client.
826
+ */
827
+ clientRequests: ClientRequests;
828
+
829
+ /**
830
+ * @alpha
831
+ *
832
+ * Responses that come from the server.
833
+ */
834
+ serverRequests: ServerRequests;
835
+
836
+ /**
837
+ * @alpha
838
+ *
839
+ * Signal emitted when the connection is closed.
840
+ */
841
+ closeSignal: ISignal<ILSPConnection, boolean>;
842
+
843
+ /**
844
+ * @alpha
845
+ *
846
+ * Signal emitted when the connection receives an error
847
+ * message..
848
+ */
849
+ errorSignal: ISignal<ILSPConnection, any>;
850
+
851
+ /**
852
+ * @alpha
853
+ *
854
+ * Signal emitted when the connection is initialized.
855
+ */
856
+ serverInitialized: ISignal<ILSPConnection, lsp.ServerCapabilities<any>>;
857
+
858
+ /**
859
+ * @alpha
860
+ *
861
+ * Send the open request to the backend when the server is
862
+ * ready.
863
+ */
864
+ sendOpenWhenReady(documentInfo: IDocumentInfo): void;
865
+
866
+ /**
867
+ * @alpha
868
+ *
869
+ * Send all changes to the server.
870
+ */
871
+ sendFullTextChange(text: string, documentInfo: IDocumentInfo): void;
872
+ }