@jupyterlab/lsp 4.0.0-alpha.11 → 4.0.0-alpha.12
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/lib/adapters/adapter.d.ts +184 -54
- package/lib/adapters/adapter.js +177 -132
- package/lib/adapters/adapter.js.map +1 -1
- package/lib/adapters/statusmessage.d.ts +47 -0
- package/lib/adapters/statusmessage.js +74 -0
- package/lib/adapters/statusmessage.js.map +1 -0
- package/lib/connection.d.ts +113 -26
- package/lib/connection.js +166 -105
- package/lib/connection.js.map +1 -1
- package/lib/connection_manager.d.ts +143 -18
- package/lib/connection_manager.js +163 -49
- package/lib/connection_manager.js.map +1 -1
- package/lib/extractors/index.d.ts +3 -0
- package/lib/extractors/index.js +6 -0
- package/lib/extractors/index.js.map +1 -0
- package/lib/extractors/manager.d.ts +21 -4
- package/lib/extractors/manager.js +22 -5
- package/lib/extractors/manager.js.map +1 -1
- package/lib/extractors/text_extractor.d.ts +34 -7
- package/lib/extractors/text_extractor.js +11 -0
- package/lib/extractors/text_extractor.js.map +1 -1
- package/lib/extractors/types.d.ts +8 -6
- package/lib/extractors/types.js +2 -0
- package/lib/extractors/types.js.map +1 -1
- package/lib/feature.d.ts +18 -3
- package/lib/feature.js +20 -3
- package/lib/feature.js.map +1 -1
- package/lib/index.d.ts +6 -9
- package/lib/index.js +8 -13
- package/lib/index.js.map +1 -1
- package/lib/lsp.d.ts +10 -4
- package/lib/lsp.js +2 -0
- package/lib/lsp.js.map +1 -1
- package/lib/manager.d.ts +103 -16
- package/lib/manager.js +118 -31
- package/lib/manager.js.map +1 -1
- package/lib/plugin.d.ts +18 -13
- package/lib/plugin.js +2 -1
- package/lib/plugin.js.map +1 -1
- package/lib/positioning.d.ts +43 -6
- package/lib/positioning.js +28 -2
- package/lib/positioning.js.map +1 -1
- package/lib/schema.js +2 -1
- package/lib/schema.js.map +1 -1
- package/lib/tokens.d.ts +275 -45
- package/lib/tokens.js +28 -0
- package/lib/tokens.js.map +1 -1
- package/lib/utils.d.ts +15 -1
- package/lib/utils.js +18 -2
- package/lib/utils.js.map +1 -1
- package/lib/virtual/document.d.ts +374 -78
- package/lib/virtual/document.js +375 -148
- package/lib/virtual/document.js.map +1 -1
- package/lib/ws-connection/server-capability-registration.d.ts +18 -0
- package/lib/ws-connection/server-capability-registration.js +46 -0
- package/lib/ws-connection/server-capability-registration.js.map +1 -0
- package/lib/ws-connection/types.d.ts +75 -0
- package/lib/ws-connection/types.js +7 -0
- package/lib/ws-connection/types.js.map +1 -0
- package/lib/ws-connection/ws-connection.d.ts +82 -0
- package/lib/ws-connection/ws-connection.js +201 -0
- package/lib/ws-connection/ws-connection.js.map +1 -0
- package/package.json +15 -16
- package/style/index.css +0 -2
- package/style/index.js +0 -2
package/lib/tokens.d.ts
CHANGED
|
@@ -1,65 +1,116 @@
|
|
|
1
1
|
import { IDocumentWidget } from '@jupyterlab/docregistry';
|
|
2
|
-
import { CellType } from '@jupyterlab/nbformat';
|
|
3
2
|
import { ServerConnection } from '@jupyterlab/services';
|
|
4
3
|
import { Token } from '@lumino/coreutils';
|
|
4
|
+
import { IDisposable } from '@lumino/disposable';
|
|
5
5
|
import { ISignal, Signal } from '@lumino/signaling';
|
|
6
|
-
import {
|
|
7
|
-
import { WidgetAdapter } from './adapters/adapter';
|
|
6
|
+
import { WidgetLSPAdapter } from './adapters/adapter';
|
|
8
7
|
import { IForeignCodeExtractor } from './extractors/types';
|
|
9
|
-
import { ClientCapabilities, LanguageIdentifier } from './lsp';
|
|
10
|
-
import {
|
|
8
|
+
import { AnyCompletion, AnyLocation, ClientCapabilities, LanguageIdentifier } from './lsp';
|
|
9
|
+
import { LanguageServer1 as LSPLanguageServerSettings } from './plugin';
|
|
11
10
|
import * as SCHEMA from './schema';
|
|
12
11
|
import { VirtualDocument } from './virtual/document';
|
|
12
|
+
import { IDocumentInfo, ILspConnection, ILspOptions } from './ws-connection/types';
|
|
13
13
|
import type * as rpc from 'vscode-jsonrpc';
|
|
14
14
|
import type * as lsp from 'vscode-languageserver-protocol';
|
|
15
|
+
export { IDocumentInfo };
|
|
16
|
+
/**
|
|
17
|
+
* Example server keys==ids that are expected. The list is not exhaustive.
|
|
18
|
+
* Custom server keys are allowed. Constraining the values helps avoid errors,
|
|
19
|
+
* but at runtime any value is allowed.
|
|
20
|
+
*/
|
|
15
21
|
export declare type TLanguageServerId = 'pylsp' | 'bash-language-server' | 'dockerfile-language-server-nodejs' | 'javascript-typescript-langserver' | 'unified-language-server' | 'vscode-css-languageserver-bin' | 'vscode-html-languageserver-bin' | 'vscode-json-languageserver-bin' | 'yaml-language-server' | 'r-languageserver';
|
|
22
|
+
/**
|
|
23
|
+
* Type alias for the server ids.
|
|
24
|
+
*/
|
|
16
25
|
export declare type TServerKeys = TLanguageServerId;
|
|
26
|
+
/**
|
|
27
|
+
* Type of language server configuration, it is a map between server
|
|
28
|
+
* id and its setting.
|
|
29
|
+
*/
|
|
17
30
|
export declare type TLanguageServerConfigurations = Partial<Record<TServerKeys, LSPLanguageServerSettings>>;
|
|
31
|
+
/**
|
|
32
|
+
* Type of language server session, it is a map between server
|
|
33
|
+
* id and the associated session.
|
|
34
|
+
*/
|
|
18
35
|
export declare type TSessionMap = Map<TServerKeys, SCHEMA.LanguageServerSession>;
|
|
36
|
+
/**
|
|
37
|
+
* Type of language server specs, it is a map between server
|
|
38
|
+
* id and the associated specs.
|
|
39
|
+
*/
|
|
19
40
|
export declare type TSpecsMap = Map<TServerKeys, SCHEMA.LanguageServerSpec>;
|
|
41
|
+
/**
|
|
42
|
+
* Type alias for language server id, it helps to clarify other types.
|
|
43
|
+
*/
|
|
20
44
|
export declare type TLanguageId = string;
|
|
21
|
-
export interface ILanguageServerManager {
|
|
45
|
+
export interface ILanguageServerManager extends IDisposable {
|
|
22
46
|
/**
|
|
23
|
-
*
|
|
47
|
+
* @alpha
|
|
24
48
|
*
|
|
49
|
+
* Signal emitted when the language server sessions are changed.
|
|
25
50
|
*/
|
|
26
51
|
sessionsChanged: ISignal<ILanguageServerManager, void>;
|
|
27
52
|
/**
|
|
53
|
+
* @alpha
|
|
54
|
+
*
|
|
28
55
|
* The current session information of running language servers.
|
|
29
56
|
*/
|
|
30
|
-
sessions: TSessionMap;
|
|
57
|
+
readonly sessions: TSessionMap;
|
|
31
58
|
/**
|
|
32
|
-
*
|
|
59
|
+
* @alpha
|
|
60
|
+
*
|
|
61
|
+
* A promise that is fulfilled when the connection manager is ready.
|
|
33
62
|
*/
|
|
34
|
-
|
|
63
|
+
readonly ready: Promise<void>;
|
|
35
64
|
/**
|
|
36
|
-
*
|
|
65
|
+
* @alpha
|
|
66
|
+
*
|
|
67
|
+
* Current endpoint to get the status of running language servers
|
|
37
68
|
*/
|
|
38
|
-
|
|
69
|
+
readonly statusUrl: string;
|
|
39
70
|
/**
|
|
40
|
-
*
|
|
71
|
+
* @alpha
|
|
41
72
|
*
|
|
73
|
+
* Status code of the `fetchSession` request.
|
|
42
74
|
*/
|
|
43
|
-
|
|
75
|
+
readonly statusCode: number;
|
|
44
76
|
/**
|
|
45
|
-
*
|
|
77
|
+
* @alpha
|
|
46
78
|
*
|
|
79
|
+
* An ordered list of matching >running< sessions, with servers of higher rank higher in the list
|
|
47
80
|
*/
|
|
48
|
-
|
|
81
|
+
getMatchingServers(options: ILanguageServerManager.IGetServerIdOptions): TLanguageServerId[];
|
|
49
82
|
/**
|
|
50
|
-
*
|
|
83
|
+
* @alpha
|
|
84
|
+
*
|
|
85
|
+
* A list of all known matching specs (whether detected or not).
|
|
51
86
|
*/
|
|
52
|
-
|
|
87
|
+
getMatchingSpecs(options: ILanguageServerManager.IGetServerIdOptions): TSpecsMap;
|
|
53
88
|
/**
|
|
89
|
+
* @alpha
|
|
54
90
|
*
|
|
55
|
-
*
|
|
91
|
+
* Set the configuration for language servers
|
|
92
|
+
*/
|
|
93
|
+
setConfiguration(configuration: TLanguageServerConfigurations): void;
|
|
94
|
+
/**
|
|
95
|
+
* @alpha
|
|
96
|
+
*
|
|
97
|
+
* Send a request to language server handler to get the session information.
|
|
56
98
|
*/
|
|
57
|
-
|
|
99
|
+
fetchSessions(): Promise<void>;
|
|
58
100
|
}
|
|
59
101
|
export declare namespace ILanguageServerManager {
|
|
102
|
+
/**
|
|
103
|
+
* LSP endpoint prefix.
|
|
104
|
+
*/
|
|
60
105
|
const URL_NS = "lsp";
|
|
61
106
|
interface IOptions {
|
|
107
|
+
/**
|
|
108
|
+
* The Jupyter server settings objec
|
|
109
|
+
*/
|
|
62
110
|
settings?: ServerConnection.ISettings;
|
|
111
|
+
/**
|
|
112
|
+
* Base URL of current JupyterLab server.
|
|
113
|
+
*/
|
|
63
114
|
baseUrl?: string;
|
|
64
115
|
/**
|
|
65
116
|
* Number of connection retries to fetch the sessions.
|
|
@@ -71,42 +122,63 @@ export declare namespace ILanguageServerManager {
|
|
|
71
122
|
*/
|
|
72
123
|
retriesInterval?: number;
|
|
73
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* The argument for getting server session or specs.
|
|
127
|
+
*/
|
|
74
128
|
interface IGetServerIdOptions {
|
|
129
|
+
/**
|
|
130
|
+
* Language server id
|
|
131
|
+
*/
|
|
75
132
|
language?: TLanguageId;
|
|
133
|
+
/**
|
|
134
|
+
* Server specs mime type.
|
|
135
|
+
*/
|
|
76
136
|
mimeType?: string;
|
|
77
137
|
}
|
|
78
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Option to create the websocket connection to the LSP proxy server
|
|
141
|
+
* on the backend.
|
|
142
|
+
*/
|
|
79
143
|
export interface ISocketConnectionOptions {
|
|
144
|
+
/**
|
|
145
|
+
* The virtual document trying to connect to the LSP server.
|
|
146
|
+
*/
|
|
80
147
|
virtualDocument: VirtualDocument;
|
|
81
148
|
/**
|
|
82
|
-
* The language identifier, corresponding to the API endpoint on the
|
|
149
|
+
* The language identifier, corresponding to the API endpoint on the
|
|
150
|
+
* LSP proxy server.
|
|
83
151
|
*/
|
|
84
152
|
language: string;
|
|
85
153
|
/**
|
|
86
154
|
* LSP capabilities describing currently supported features
|
|
87
155
|
*/
|
|
88
156
|
capabilities: ClientCapabilities;
|
|
89
|
-
hasLspSupportedFile: boolean;
|
|
90
|
-
}
|
|
91
|
-
export interface IDocumentRegistationOptions {
|
|
92
|
-
/**
|
|
93
|
-
* The language identifier, corresponding to the API endpoint on the LSP proxy server.
|
|
94
|
-
*/
|
|
95
|
-
language: string;
|
|
96
157
|
/**
|
|
97
|
-
*
|
|
158
|
+
* Is the file format is supported by LSP?
|
|
98
159
|
*/
|
|
99
|
-
document: string;
|
|
100
|
-
/**
|
|
101
|
-
* LSP capabilities describing currently supported features
|
|
102
|
-
*/
|
|
103
|
-
capabilities: ClientCapabilities;
|
|
104
160
|
hasLspSupportedFile: boolean;
|
|
105
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* @alpha
|
|
164
|
+
*
|
|
165
|
+
* Interface describing the LSP connection state
|
|
166
|
+
*/
|
|
106
167
|
export interface IDocumentConnectionData {
|
|
168
|
+
/**
|
|
169
|
+
* The virtual document connected to the language server
|
|
170
|
+
*/
|
|
107
171
|
virtualDocument: VirtualDocument;
|
|
172
|
+
/**
|
|
173
|
+
* The connection between the virtual document and the language server.
|
|
174
|
+
*/
|
|
108
175
|
connection: ILSPConnection;
|
|
109
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* @alpha
|
|
179
|
+
*
|
|
180
|
+
* The LSP connection state manager
|
|
181
|
+
*/
|
|
110
182
|
export interface ILSPDocumentConnectionManager {
|
|
111
183
|
/**
|
|
112
184
|
* The mapping of document uri to the connection to language server.
|
|
@@ -119,7 +191,7 @@ export interface ILSPDocumentConnectionManager {
|
|
|
119
191
|
/**
|
|
120
192
|
* The mapping of document uri to the widget adapter.
|
|
121
193
|
*/
|
|
122
|
-
adapters: Map<string,
|
|
194
|
+
adapters: Map<string, WidgetLSPAdapter<IDocumentWidget>>;
|
|
123
195
|
/**
|
|
124
196
|
* Signal emitted when a connection is connected.
|
|
125
197
|
*/
|
|
@@ -144,10 +216,14 @@ export interface ILSPDocumentConnectionManager {
|
|
|
144
216
|
* The language server manager instance.
|
|
145
217
|
*/
|
|
146
218
|
languageServerManager: ILanguageServerManager;
|
|
219
|
+
/**
|
|
220
|
+
* A promise that is fulfilled when the connection manager is ready.
|
|
221
|
+
*/
|
|
222
|
+
readonly ready: Promise<void>;
|
|
147
223
|
/**
|
|
148
224
|
* Handles the settings that do not require an existing connection
|
|
149
225
|
* with a language server (or can influence to which server the
|
|
150
|
-
* connection will be created, e.g. `
|
|
226
|
+
* connection will be created, e.g. `rank`).
|
|
151
227
|
*
|
|
152
228
|
* This function should be called **before** initialization of servers.
|
|
153
229
|
*/
|
|
@@ -164,7 +240,6 @@ export interface ILSPDocumentConnectionManager {
|
|
|
164
240
|
/**
|
|
165
241
|
* Retry to connect to the server each `reconnectDelay` seconds
|
|
166
242
|
* and for `retrialsLeft` times.
|
|
167
|
-
*
|
|
168
243
|
*/
|
|
169
244
|
retryToConnect(options: ISocketConnectionOptions, reconnectDelay: number, retrialsLeft: number): Promise<void>;
|
|
170
245
|
/**
|
|
@@ -175,12 +250,10 @@ export interface ILSPDocumentConnectionManager {
|
|
|
175
250
|
/**
|
|
176
251
|
* Disconnect the connection to the language server of the requested
|
|
177
252
|
* language.
|
|
178
|
-
*
|
|
179
253
|
*/
|
|
180
254
|
disconnect(languageId: TLanguageServerId): void;
|
|
181
255
|
/**
|
|
182
256
|
* Disconnect the signals of requested virtual document.
|
|
183
|
-
*
|
|
184
257
|
*/
|
|
185
258
|
unregisterDocument(virtualDocument: VirtualDocument): void;
|
|
186
259
|
/**
|
|
@@ -189,8 +262,13 @@ export interface ILSPDocumentConnectionManager {
|
|
|
189
262
|
* @param path - path to current document widget of input adapter
|
|
190
263
|
* @param adapter - the adapter need to be registered
|
|
191
264
|
*/
|
|
192
|
-
registerAdapter(path: string, adapter:
|
|
265
|
+
registerAdapter(path: string, adapter: WidgetLSPAdapter<IDocumentWidget>): void;
|
|
193
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* @alpha
|
|
269
|
+
*
|
|
270
|
+
* Interface describing the client feature
|
|
271
|
+
*/
|
|
194
272
|
export interface IFeature {
|
|
195
273
|
/**
|
|
196
274
|
* The feature identifier. It must be the same as the feature plugin id.
|
|
@@ -201,6 +279,11 @@ export interface IFeature {
|
|
|
201
279
|
*/
|
|
202
280
|
capabilities?: ClientCapabilities;
|
|
203
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* @alpha
|
|
284
|
+
*
|
|
285
|
+
* The LSP feature manager
|
|
286
|
+
*/
|
|
204
287
|
export interface ILSPFeatureManager {
|
|
205
288
|
/**
|
|
206
289
|
* A read-only registry of all registered features.
|
|
@@ -211,27 +294,67 @@ export interface ILSPFeatureManager {
|
|
|
211
294
|
* for one or more code editor implementations.
|
|
212
295
|
*/
|
|
213
296
|
register(feature: IFeature): void;
|
|
297
|
+
/**
|
|
298
|
+
* Signal emitted when a feature is registered
|
|
299
|
+
*/
|
|
214
300
|
featuresRegistered: ISignal<ILSPFeatureManager, IFeature>;
|
|
301
|
+
/**
|
|
302
|
+
* Get capabilities of all registered features
|
|
303
|
+
*/
|
|
215
304
|
clientCapabilities(): ClientCapabilities;
|
|
216
305
|
}
|
|
217
306
|
/**
|
|
307
|
+
* @alpha
|
|
308
|
+
*
|
|
218
309
|
* Manages code transclusion plugins.
|
|
219
310
|
*/
|
|
220
311
|
export interface ILSPCodeExtractorsManager {
|
|
221
312
|
/**
|
|
222
313
|
* Get the foreign code extractors.
|
|
223
314
|
*/
|
|
224
|
-
getExtractors(cellType:
|
|
315
|
+
getExtractors(cellType: string, hostLanguage: string | null): IForeignCodeExtractor[];
|
|
225
316
|
/**
|
|
226
317
|
* Register the extraction rules to be applied in documents with language `host_language`.
|
|
227
318
|
*/
|
|
228
319
|
register(extractor: IForeignCodeExtractor, hostLanguage: LanguageIdentifier | null): void;
|
|
229
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* @alpha
|
|
323
|
+
*
|
|
324
|
+
* The virtual documents and language server connections manager
|
|
325
|
+
* Require this token in your extension to access the associated virtual
|
|
326
|
+
* document and LS connection of opened documents.
|
|
327
|
+
*
|
|
328
|
+
*/
|
|
230
329
|
export declare const ILSPDocumentConnectionManager: Token<ILSPDocumentConnectionManager>;
|
|
330
|
+
/**
|
|
331
|
+
* @alpha
|
|
332
|
+
*
|
|
333
|
+
* The language server feature manager. Require this token in your extension
|
|
334
|
+
* to register the client capabilities implemented by your extension.
|
|
335
|
+
*
|
|
336
|
+
*/
|
|
231
337
|
export declare const ILSPFeatureManager: Token<ILSPFeatureManager>;
|
|
338
|
+
/**
|
|
339
|
+
* @alpha
|
|
340
|
+
*
|
|
341
|
+
* The code extractor manager. Require this token in your extension to
|
|
342
|
+
* register new code extractors. Code extractor allows creating multiple
|
|
343
|
+
* virtual documents from an opened document.
|
|
344
|
+
*
|
|
345
|
+
*/
|
|
232
346
|
export declare const ILSPCodeExtractorsManager: Token<ILSPCodeExtractorsManager>;
|
|
347
|
+
/**
|
|
348
|
+
* Argument for creating a connection to the LSP proxy server.
|
|
349
|
+
*/
|
|
233
350
|
export interface ILSPOptions extends ILspOptions {
|
|
351
|
+
/**
|
|
352
|
+
* Client capabilities implemented by the client.
|
|
353
|
+
*/
|
|
234
354
|
capabilities: ClientCapabilities;
|
|
355
|
+
/**
|
|
356
|
+
* Language server id.
|
|
357
|
+
*/
|
|
235
358
|
serverIdentifier?: string;
|
|
236
359
|
}
|
|
237
360
|
/**
|
|
@@ -278,12 +401,18 @@ export declare namespace Method {
|
|
|
278
401
|
TYPE_DEFINITION = "textDocument/typeDefinition"
|
|
279
402
|
}
|
|
280
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Interface describing the notifications that come from the server.
|
|
406
|
+
*/
|
|
281
407
|
export interface IServerNotifyParams {
|
|
282
408
|
[Method.ServerNotification.LOG_MESSAGE]: lsp.LogMessageParams;
|
|
283
409
|
[Method.ServerNotification.LOG_TRACE]: rpc.LogTraceParams;
|
|
284
410
|
[Method.ServerNotification.PUBLISH_DIAGNOSTICS]: lsp.PublishDiagnosticsParams;
|
|
285
411
|
[Method.ServerNotification.SHOW_MESSAGE]: lsp.ShowMessageParams;
|
|
286
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Interface describing the notifications that come from the client.
|
|
415
|
+
*/
|
|
287
416
|
export interface IClientNotifyParams {
|
|
288
417
|
[Method.ClientNotification
|
|
289
418
|
.DID_CHANGE_CONFIGURATION]: lsp.DidChangeConfigurationParams;
|
|
@@ -293,18 +422,27 @@ export interface IClientNotifyParams {
|
|
|
293
422
|
[Method.ClientNotification.INITIALIZED]: lsp.InitializedParams;
|
|
294
423
|
[Method.ClientNotification.SET_TRACE]: rpc.SetTraceParams;
|
|
295
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* Interface describing the requests sent to the server.
|
|
427
|
+
*/
|
|
296
428
|
export interface IServerRequestParams {
|
|
297
429
|
[Method.ServerRequest.REGISTER_CAPABILITY]: lsp.RegistrationParams;
|
|
298
430
|
[Method.ServerRequest.SHOW_MESSAGE_REQUEST]: lsp.ShowMessageRequestParams;
|
|
299
431
|
[Method.ServerRequest.UNREGISTER_CAPABILITY]: lsp.UnregistrationParams;
|
|
300
432
|
[Method.ServerRequest.WORKSPACE_CONFIGURATION]: lsp.ConfigurationParams;
|
|
301
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Interface describing the responses received from the server.
|
|
436
|
+
*/
|
|
302
437
|
export interface IServerResult {
|
|
303
438
|
[Method.ServerRequest.REGISTER_CAPABILITY]: void;
|
|
304
439
|
[Method.ServerRequest.SHOW_MESSAGE_REQUEST]: lsp.MessageActionItem | null;
|
|
305
440
|
[Method.ServerRequest.UNREGISTER_CAPABILITY]: void;
|
|
306
441
|
[Method.ServerRequest.WORKSPACE_CONFIGURATION]: any[];
|
|
307
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Interface describing the request sent to the client.
|
|
445
|
+
*/
|
|
308
446
|
export interface IClientRequestParams {
|
|
309
447
|
[Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
|
|
310
448
|
[Method.ClientRequest.COMPLETION]: lsp.CompletionParams;
|
|
@@ -319,6 +457,9 @@ export interface IClientRequestParams {
|
|
|
319
457
|
[Method.ClientRequest.SIGNATURE_HELP]: lsp.TextDocumentPositionParams;
|
|
320
458
|
[Method.ClientRequest.TYPE_DEFINITION]: lsp.TextDocumentPositionParams;
|
|
321
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Interface describing the responses received from the client.
|
|
462
|
+
*/
|
|
322
463
|
export interface IClientResult {
|
|
323
464
|
[Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
|
|
324
465
|
[Method.ClientRequest.COMPLETION]: AnyCompletion;
|
|
@@ -333,36 +474,125 @@ export interface IClientResult {
|
|
|
333
474
|
[Method.ClientRequest.SIGNATURE_HELP]: lsp.SignatureHelp;
|
|
334
475
|
[Method.ClientRequest.TYPE_DEFINITION]: AnyLocation;
|
|
335
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Type of server notification handlers, it is a map between the server
|
|
479
|
+
* notification name and the associated `ISignal`.
|
|
480
|
+
*/
|
|
336
481
|
export declare type ServerNotifications<T extends keyof IServerNotifyParams = keyof IServerNotifyParams> = {
|
|
337
482
|
readonly [key in T]: ISignal<ILSPConnection, IServerNotifyParams[key]>;
|
|
338
483
|
};
|
|
484
|
+
/**
|
|
485
|
+
* Type of client notification handlers, it is a map between the client
|
|
486
|
+
* notification name and the associated signal.
|
|
487
|
+
*/
|
|
339
488
|
export declare type ClientNotifications<T extends keyof IClientNotifyParams = keyof IClientNotifyParams> = {
|
|
340
489
|
readonly [key in T]: Signal<ILSPConnection, IClientNotifyParams[key]>;
|
|
341
490
|
};
|
|
491
|
+
/**
|
|
492
|
+
* Interface describing the client request handler.
|
|
493
|
+
*/
|
|
342
494
|
export interface IClientRequestHandler<T extends keyof IClientRequestParams = keyof IClientRequestParams> {
|
|
343
495
|
request(params: IClientRequestParams[T]): Promise<IClientResult[T]>;
|
|
344
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Interface describing the server request handler.
|
|
499
|
+
*/
|
|
345
500
|
export interface IServerRequestHandler<T extends keyof IServerRequestParams = keyof IServerRequestParams> {
|
|
346
501
|
setHandler(handler: (params: IServerRequestParams[T], connection?: ILSPConnection) => Promise<IServerResult[T]>): void;
|
|
347
502
|
clearHandler(): void;
|
|
348
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Type of client request handlers, it is a map between the client
|
|
506
|
+
* request name and the associated handler.
|
|
507
|
+
*/
|
|
349
508
|
export declare type ClientRequests<T extends keyof IClientRequestParams = keyof IClientRequestParams> = {
|
|
350
509
|
readonly [key in T]: IClientRequestHandler<key>;
|
|
351
510
|
};
|
|
511
|
+
/**
|
|
512
|
+
* Type of server request handlers, it is a map between the server
|
|
513
|
+
* request name and the associated handler.
|
|
514
|
+
*/
|
|
352
515
|
export declare type ServerRequests<T extends keyof IServerRequestParams = keyof IServerRequestParams> = {
|
|
353
516
|
readonly [key in T]: IServerRequestHandler<key>;
|
|
354
517
|
};
|
|
355
|
-
|
|
518
|
+
/**
|
|
519
|
+
* @alpha
|
|
520
|
+
*
|
|
521
|
+
* Interface describing he connection to the language server.
|
|
522
|
+
*/
|
|
523
|
+
export interface ILSPConnection extends ILspConnection, IDisposable {
|
|
524
|
+
/**
|
|
525
|
+
* @alpha
|
|
526
|
+
*
|
|
527
|
+
* Identifier of the language server
|
|
528
|
+
*/
|
|
356
529
|
serverIdentifier?: string;
|
|
530
|
+
/**
|
|
531
|
+
* @alpha
|
|
532
|
+
*
|
|
533
|
+
* Language of the language server
|
|
534
|
+
*/
|
|
357
535
|
serverLanguage?: string;
|
|
536
|
+
/**
|
|
537
|
+
* @alpha
|
|
538
|
+
*
|
|
539
|
+
* Should log all communication?
|
|
540
|
+
*/
|
|
358
541
|
logAllCommunication: boolean;
|
|
359
|
-
|
|
542
|
+
/**
|
|
543
|
+
* @alpha
|
|
544
|
+
*
|
|
545
|
+
* Notifications that come from the client.
|
|
546
|
+
*/
|
|
360
547
|
clientNotifications: ClientNotifications;
|
|
548
|
+
/**
|
|
549
|
+
* @alpha
|
|
550
|
+
*
|
|
551
|
+
* Notifications that come from the server.
|
|
552
|
+
*/
|
|
361
553
|
serverNotifications: ServerNotifications;
|
|
554
|
+
/**
|
|
555
|
+
* @alpha
|
|
556
|
+
*
|
|
557
|
+
* Requests that come from the client.
|
|
558
|
+
*/
|
|
362
559
|
clientRequests: ClientRequests;
|
|
560
|
+
/**
|
|
561
|
+
* @alpha
|
|
562
|
+
*
|
|
563
|
+
* Responses that come from the server.
|
|
564
|
+
*/
|
|
363
565
|
serverRequests: ServerRequests;
|
|
364
|
-
|
|
566
|
+
/**
|
|
567
|
+
* @alpha
|
|
568
|
+
*
|
|
569
|
+
* Signal emitted when the connection is closed.
|
|
570
|
+
*/
|
|
571
|
+
closeSignal: ISignal<ILSPConnection, boolean>;
|
|
572
|
+
/**
|
|
573
|
+
* @alpha
|
|
574
|
+
*
|
|
575
|
+
* Signal emitted when the connection receives an error
|
|
576
|
+
* message..
|
|
577
|
+
*/
|
|
578
|
+
errorSignal: ISignal<ILSPConnection, any>;
|
|
579
|
+
/**
|
|
580
|
+
* @alpha
|
|
581
|
+
*
|
|
582
|
+
* Signal emitted when the connection is initialized.
|
|
583
|
+
*/
|
|
584
|
+
serverInitialized: ISignal<ILSPConnection, lsp.ServerCapabilities<any>>;
|
|
585
|
+
/**
|
|
586
|
+
* @alpha
|
|
587
|
+
*
|
|
588
|
+
* Send the open request to the backend when the server is
|
|
589
|
+
* ready.
|
|
590
|
+
*/
|
|
365
591
|
sendOpenWhenReady(documentInfo: IDocumentInfo): void;
|
|
592
|
+
/**
|
|
593
|
+
* @alpha
|
|
594
|
+
*
|
|
595
|
+
* Send all changes to the server.
|
|
596
|
+
*/
|
|
366
597
|
sendFullTextChange(text: string, documentInfo: IDocumentInfo): void;
|
|
367
|
-
getCompletion(location: IPosition, token: ITokenInfo, documentInfo: IDocumentInfo, emit?: boolean, triggerCharacter?: string, triggerKind?: lsp.CompletionTriggerKind): Promise<lsp.CompletionItem[] | undefined>;
|
|
368
598
|
}
|
package/lib/tokens.js
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
1
3
|
import { Token } from '@lumino/coreutils';
|
|
2
4
|
export var ILanguageServerManager;
|
|
3
5
|
(function (ILanguageServerManager) {
|
|
6
|
+
/**
|
|
7
|
+
* LSP endpoint prefix.
|
|
8
|
+
*/
|
|
4
9
|
ILanguageServerManager.URL_NS = 'lsp';
|
|
5
10
|
})(ILanguageServerManager || (ILanguageServerManager = {}));
|
|
11
|
+
/**
|
|
12
|
+
* @alpha
|
|
13
|
+
*
|
|
14
|
+
* The virtual documents and language server connections manager
|
|
15
|
+
* Require this token in your extension to access the associated virtual
|
|
16
|
+
* document and LS connection of opened documents.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
6
19
|
export const ILSPDocumentConnectionManager = new Token('@jupyterlab/lsp:ILSPDocumentConnectionManager');
|
|
20
|
+
/**
|
|
21
|
+
* @alpha
|
|
22
|
+
*
|
|
23
|
+
* The language server feature manager. Require this token in your extension
|
|
24
|
+
* to register the client capabilities implemented by your extension.
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
7
27
|
export const ILSPFeatureManager = new Token('@jupyterlab/lsp:ILSPFeatureManager');
|
|
28
|
+
/**
|
|
29
|
+
* @alpha
|
|
30
|
+
*
|
|
31
|
+
* The code extractor manager. Require this token in your extension to
|
|
32
|
+
* register new code extractors. Code extractor allows creating multiple
|
|
33
|
+
* virtual documents from an opened document.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
8
36
|
export const ILSPCodeExtractorsManager = new Token('@jupyterlab/lsp:ILSPCodeExtractorsManager');
|
|
9
37
|
/**
|
|
10
38
|
* Method strings are reproduced here because a non-typing import of
|
package/lib/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAI3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA6I1C,MAAM,KAAW,sBAAsB,CA0CtC;AA1CD,WAAiB,sBAAsB;IACrC;;OAEG;IACU,6BAAM,GAAG,KAAK,CAAC;AAsC9B,CAAC,EA1CgB,sBAAsB,KAAtB,sBAAsB,QA0CtC;AA4OD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,IAAI,KAAK,CACP,+CAA+C,CAChD,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,KAAK,CACzC,oCAAoC,CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,KAAK,CAChD,2CAA2C,CAC5C,CAAC;AAiBF;;;GAGG;AACH,MAAM,KAAW,MAAM,CA0CtB;AA1CD,WAAiB,MAAM;IACrB,2BAA2B;IAC3B,IAAY,kBAKX;IALD,WAAY,kBAAkB;QAC5B,6EAAuD,CAAA;QACvD,yDAAmC,CAAA;QACnC,8CAAwB,CAAA;QACxB,uDAAiC,CAAA;IACnC,CAAC,EALW,kBAAkB,GAAlB,yBAAkB,KAAlB,yBAAkB,QAK7B;IAED,2BAA2B;IAC3B,IAAY,kBAOX;IAPD,WAAY,kBAAkB;QAC5B,2DAAqC,CAAA;QACrC,mFAA6D,CAAA;QAC7D,uDAAiC,CAAA;QACjC,uDAAiC,CAAA;QACjC,iDAA2B,CAAA;QAC3B,8CAAwB,CAAA;IAC1B,CAAC,EAPW,kBAAkB,GAAlB,yBAAkB,KAAlB,yBAAkB,QAO7B;IAED,sBAAsB;IACtB,IAAY,aAKX;IALD,WAAY,aAAa;QACvB,kEAAiD,CAAA;QACjD,mEAAkD,CAAA;QAClD,sEAAqD,CAAA;QACrD,oEAAmD,CAAA;IACrD,CAAC,EALW,aAAa,GAAb,oBAAa,KAAb,oBAAa,QAKxB;IAED,sBAAsB;IACtB,IAAY,aAaX;IAbD,WAAY,aAAa;QACvB,uDAAsC,CAAA;QACtC,mEAAkD,CAAA;QAClD,uDAAsC,CAAA;QACtC,sEAAqD,CAAA;QACrD,gEAA+C,CAAA;QAC/C,6CAA4B,CAAA;QAC5B,+DAA8C,CAAA;QAC9C,0CAAyB,CAAA;QACzB,uDAAsC,CAAA;QACtC,+CAA8B,CAAA;QAC9B,8DAA6C,CAAA;QAC7C,gEAA+C,CAAA;IACjD,CAAC,EAbW,aAAa,GAAb,oBAAa,KAAb,oBAAa,QAaxB;AACH,CAAC,EA1CgB,MAAM,KAAN,MAAM,QA0CtB"}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { ReadonlyJSONObject, ReadonlyJSONValue } from '@lumino/coreutils';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to wait for timeout.
|
|
4
|
+
*
|
|
5
|
+
* @param timeout - time out in ms
|
|
6
|
+
*/
|
|
2
7
|
export declare function sleep(timeout: number): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Wait for an event by pooling the `isReady` function.
|
|
10
|
+
*/
|
|
3
11
|
export declare function untilReady(isReady: CallableFunction, maxRetrials?: number, interval?: number, intervalModifier?: (i: number) => number): Promise<CallableFunction>;
|
|
4
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Convert dotted path into dictionary.
|
|
14
|
+
*/
|
|
15
|
+
export declare function expandDottedPaths(obj: ReadonlyJSONObject): ReadonlyJSONObject;
|
|
5
16
|
/**
|
|
6
17
|
* The docs for many language servers show settings in the
|
|
7
18
|
* VSCode format, e.g.: "pyls.plugins.pyflakes.enabled"
|
|
@@ -10,6 +21,9 @@ export declare const expandDottedPaths: (obj: ReadonlyJSONObject) => ReadonlyJSO
|
|
|
10
21
|
* as the language servers themselves don't accept that syntax.
|
|
11
22
|
*/
|
|
12
23
|
export declare const expandPath: (path: string[], value: ReadonlyJSONValue) => ReadonlyJSONObject;
|
|
24
|
+
/**
|
|
25
|
+
* An extended map which will create value for key on the fly.
|
|
26
|
+
*/
|
|
13
27
|
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
14
28
|
private defaultFactory;
|
|
15
29
|
constructor(defaultFactory: (...args: any[]) => V, entries?: ReadonlyArray<readonly [K, V]> | null);
|
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
1
3
|
import mergeWith from 'lodash.mergewith';
|
|
4
|
+
/**
|
|
5
|
+
* Helper to wait for timeout.
|
|
6
|
+
*
|
|
7
|
+
* @param timeout - time out in ms
|
|
8
|
+
*/
|
|
2
9
|
export async function sleep(timeout) {
|
|
3
10
|
return new Promise(resolve => {
|
|
4
11
|
setTimeout(() => {
|
|
@@ -6,6 +13,9 @@ export async function sleep(timeout) {
|
|
|
6
13
|
}, timeout);
|
|
7
14
|
});
|
|
8
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Wait for an event by pooling the `isReady` function.
|
|
18
|
+
*/
|
|
9
19
|
export function untilReady(isReady, maxRetrials = 35, interval = 50, intervalModifier = (i) => i) {
|
|
10
20
|
return (async () => {
|
|
11
21
|
let i = 0;
|
|
@@ -20,14 +30,17 @@ export function untilReady(isReady, maxRetrials = 35, interval = 50, intervalMod
|
|
|
20
30
|
return isReady;
|
|
21
31
|
})();
|
|
22
32
|
}
|
|
23
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Convert dotted path into dictionary.
|
|
35
|
+
*/
|
|
36
|
+
export function expandDottedPaths(obj) {
|
|
24
37
|
const settings = [];
|
|
25
38
|
for (let key in obj) {
|
|
26
39
|
const parsed = expandPath(key.split('.'), obj[key]);
|
|
27
40
|
settings.push(parsed);
|
|
28
41
|
}
|
|
29
42
|
return mergeWith({}, ...settings);
|
|
30
|
-
}
|
|
43
|
+
}
|
|
31
44
|
/**
|
|
32
45
|
* The docs for many language servers show settings in the
|
|
33
46
|
* VSCode format, e.g.: "pyls.plugins.pyflakes.enabled"
|
|
@@ -49,6 +62,9 @@ export const expandPath = (path, value) => {
|
|
|
49
62
|
});
|
|
50
63
|
return obj;
|
|
51
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* An extended map which will create value for key on the fly.
|
|
67
|
+
*/
|
|
52
68
|
export class DefaultMap extends Map {
|
|
53
69
|
constructor(defaultFactory, entries) {
|
|
54
70
|
super(entries);
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"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"}
|