@jupyterlab/lsp 4.0.0-alpha.11

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.
Files changed (51) hide show
  1. package/lib/adapters/adapter.d.ts +125 -0
  2. package/lib/adapters/adapter.js +382 -0
  3. package/lib/adapters/adapter.js.map +1 -0
  4. package/lib/connection.d.ts +65 -0
  5. package/lib/connection.js +309 -0
  6. package/lib/connection.js.map +1 -0
  7. package/lib/connection_manager.d.ts +71 -0
  8. package/lib/connection_manager.js +312 -0
  9. package/lib/connection_manager.js.map +1 -0
  10. package/lib/extractors/manager.d.ts +13 -0
  11. package/lib/extractors/manager.js +44 -0
  12. package/lib/extractors/manager.js.map +1 -0
  13. package/lib/extractors/text_extractor.d.ts +28 -0
  14. package/lib/extractors/text_extractor.js +27 -0
  15. package/lib/extractors/text_extractor.js.map +1 -0
  16. package/lib/extractors/types.d.ts +65 -0
  17. package/lib/extractors/types.js +2 -0
  18. package/lib/extractors/types.js.map +1 -0
  19. package/lib/feature.d.ts +11 -0
  20. package/lib/feature.js +31 -0
  21. package/lib/feature.js.map +1 -0
  22. package/lib/index.d.ts +17 -0
  23. package/lib/index.js +22 -0
  24. package/lib/index.js.map +1 -0
  25. package/lib/lsp.d.ts +129 -0
  26. package/lib/lsp.js +125 -0
  27. package/lib/lsp.js.map +1 -0
  28. package/lib/manager.d.ts +29 -0
  29. package/lib/manager.js +130 -0
  30. package/lib/manager.js.map +1 -0
  31. package/lib/plugin.d.ts +45 -0
  32. package/lib/plugin.js +3 -0
  33. package/lib/plugin.js.map +1 -0
  34. package/lib/positioning.d.ts +28 -0
  35. package/lib/positioning.js +49 -0
  36. package/lib/positioning.js.map +1 -0
  37. package/lib/schema.d.ts +228 -0
  38. package/lib/schema.js +3 -0
  39. package/lib/schema.js.map +1 -0
  40. package/lib/tokens.d.ts +368 -0
  41. package/lib/tokens.js +58 -0
  42. package/lib/tokens.js.map +1 -0
  43. package/lib/utils.d.ts +18 -0
  44. package/lib/utils.js +71 -0
  45. package/lib/utils.js.map +1 -0
  46. package/lib/virtual/document.d.ts +270 -0
  47. package/lib/virtual/document.js +600 -0
  48. package/lib/virtual/document.js.map +1 -0
  49. package/package.json +75 -0
  50. package/style/index.css +11 -0
  51. package/style/index.js +11 -0
@@ -0,0 +1,309 @@
1
+ // Disclaimer/acknowledgement: Fragments are based on LspWsConnection, which is copyright of wylieconlon and contributors and ISC licenced.
2
+ // ISC licence is, quote, "functionally equivalent to the simplified BSD and MIT licenses,
3
+ // but without language deemed unnecessary following the Berne Convention." (Wikipedia).
4
+ // Introduced modifications are BSD licenced, copyright JupyterLab development team.
5
+ import { Signal } from '@lumino/signaling';
6
+ import { LspWsConnection } from 'lsp-ws-connection';
7
+ import { registerServerCapability, unregisterServerCapability } from 'lsp-ws-connection/lib/server-capability-registration';
8
+ import { Method } from './tokens';
9
+ import { untilReady } from './utils';
10
+ class ClientRequestHandler {
11
+ constructor(connection, method, emitter) {
12
+ this.connection = connection;
13
+ this.method = method;
14
+ this.emitter = emitter;
15
+ }
16
+ request(params) {
17
+ // TODO check if is ready?
18
+ this.emitter.log(MessageKind.clientRequested, {
19
+ method: this.method,
20
+ message: params
21
+ });
22
+ return this.connection
23
+ .sendRequest(this.method, params)
24
+ .then((result) => {
25
+ this.emitter.log(MessageKind.resultForClient, {
26
+ method: this.method,
27
+ message: params
28
+ });
29
+ return result;
30
+ });
31
+ }
32
+ }
33
+ class ServerRequestHandler {
34
+ constructor(connection, method, emitter) {
35
+ this.connection = connection;
36
+ this.method = method;
37
+ this.emitter = emitter;
38
+ // on request accepts "thenable"
39
+ this.connection.onRequest(method, this.handle.bind(this));
40
+ this._handler = null;
41
+ }
42
+ handle(request) {
43
+ this.emitter.log(MessageKind.serverRequested, {
44
+ method: this.method,
45
+ message: request
46
+ });
47
+ if (!this._handler) {
48
+ return new Promise(() => undefined);
49
+ }
50
+ return this._handler(request, this.emitter).then(result => {
51
+ this.emitter.log(MessageKind.responseForServer, {
52
+ method: this.method,
53
+ message: result
54
+ });
55
+ return result;
56
+ });
57
+ }
58
+ setHandler(handler) {
59
+ this._handler = handler;
60
+ }
61
+ clearHandler() {
62
+ this._handler = null;
63
+ }
64
+ }
65
+ export const Provider = {
66
+ TEXT_DOCUMENT_SYNC: 'textDocumentSync',
67
+ COMPLETION: 'completionProvider',
68
+ HOVER: 'hoverProvider',
69
+ SIGNATURE_HELP: 'signatureHelpProvider',
70
+ DECLARATION: 'declarationProvider',
71
+ DEFINITION: 'definitionProvider',
72
+ TYPE_DEFINITION: 'typeDefinitionProvider',
73
+ IMPLEMENTATION: 'implementationProvider',
74
+ REFERENCES: 'referencesProvider',
75
+ DOCUMENT_HIGHLIGHT: 'documentHighlightProvider',
76
+ DOCUMENT_SYMBOL: 'documentSymbolProvider',
77
+ CODE_ACTION: 'codeActionProvider',
78
+ CODE_LENS: 'codeLensProvider',
79
+ DOCUMENT_LINK: 'documentLinkProvider',
80
+ COLOR: 'colorProvider',
81
+ DOCUMENT_FORMATTING: 'documentFormattingProvider',
82
+ DOCUMENT_RANGE_FORMATTING: 'documentRangeFormattingProvider',
83
+ DOCUMENT_ON_TYPE_FORMATTING: 'documentOnTypeFormattingProvider',
84
+ RENAME: 'renameProvider',
85
+ FOLDING_RANGE: 'foldingRangeProvider',
86
+ EXECUTE_COMMAND: 'executeCommandProvider',
87
+ SELECTION_RANGE: 'selectionRangeProvider',
88
+ WORKSPACE_SYMBOL: 'workspaceSymbolProvider',
89
+ WORKSPACE: 'workspace'
90
+ };
91
+ function createMethodMap(methods, handlerFactory) {
92
+ const result = {};
93
+ for (let method of Object.values(methods)) {
94
+ result[method] = handlerFactory(method);
95
+ }
96
+ return result;
97
+ }
98
+ var MessageKind;
99
+ (function (MessageKind) {
100
+ MessageKind[MessageKind["clientNotifiedServer"] = 0] = "clientNotifiedServer";
101
+ MessageKind[MessageKind["serverNotifiedClient"] = 1] = "serverNotifiedClient";
102
+ MessageKind[MessageKind["serverRequested"] = 2] = "serverRequested";
103
+ MessageKind[MessageKind["clientRequested"] = 3] = "clientRequested";
104
+ MessageKind[MessageKind["resultForClient"] = 4] = "resultForClient";
105
+ MessageKind[MessageKind["responseForServer"] = 5] = "responseForServer";
106
+ })(MessageKind || (MessageKind = {}));
107
+ export class LSPConnection extends LspWsConnection {
108
+ constructor(options) {
109
+ super(options);
110
+ this.closingManually = false;
111
+ this._options = options;
112
+ this.logAllCommunication = false;
113
+ this.serverIdentifier = options.serverIdentifier;
114
+ this.serverLanguage = options.languageId;
115
+ this.documentsToOpen = [];
116
+ this.clientNotifications =
117
+ this.constructNotificationHandlers(Method.ClientNotification);
118
+ this.serverNotifications =
119
+ this.constructNotificationHandlers(Method.ServerNotification);
120
+ }
121
+ log(kind, message) {
122
+ if (this.logAllCommunication) {
123
+ console.log(kind, message);
124
+ }
125
+ }
126
+ constructNotificationHandlers(methods) {
127
+ return createMethodMap(methods, () => new Signal(this));
128
+ }
129
+ constructClientRequestHandler(methods) {
130
+ return createMethodMap(methods, method => new ClientRequestHandler(this.connection, method, this));
131
+ }
132
+ constructServerRequestHandler(methods) {
133
+ return createMethodMap(methods, method => new ServerRequestHandler(this.connection, method, this));
134
+ }
135
+ /**
136
+ * Initialization parameters to be sent to the language server.
137
+ * Subclasses can overload this when adding more features.
138
+ */
139
+ initializeParams() {
140
+ return Object.assign(Object.assign({}, super.initializeParams()), {
141
+ // TODO: remove as `lsp.ClientCapabilities` after upgrading to 3.17
142
+ // which should finally include a fix for moniker issue:
143
+ // https://github.com/microsoft/vscode-languageserver-node/pull/720
144
+ capabilities: this._options.capabilities, initializationOptions: null, processId: null, workspaceFolders: null });
145
+ }
146
+ sendOpenWhenReady(documentInfo) {
147
+ if (this.isReady) {
148
+ this.sendOpen(documentInfo);
149
+ }
150
+ else {
151
+ this.documentsToOpen.push(documentInfo);
152
+ }
153
+ }
154
+ onServerInitialized(params) {
155
+ this.afterInitialized();
156
+ super.onServerInitialized(params);
157
+ while (this.documentsToOpen.length) {
158
+ this.sendOpen(this.documentsToOpen.pop());
159
+ }
160
+ }
161
+ afterInitialized() {
162
+ for (const method of Object.values(Method.ServerNotification)) {
163
+ const signal = this.serverNotifications[method];
164
+ this.connection.onNotification(method, params => {
165
+ this.log(MessageKind.serverNotifiedClient, {
166
+ method,
167
+ message: params
168
+ });
169
+ signal.emit(params);
170
+ });
171
+ }
172
+ for (const method of Object.values(Method.ClientNotification)) {
173
+ const signal = this.clientNotifications[method];
174
+ signal.connect((emitter, params) => {
175
+ this.log(MessageKind.clientNotifiedServer, {
176
+ method,
177
+ message: params
178
+ });
179
+ this.connection.sendNotification(method, params);
180
+ });
181
+ }
182
+ this.clientRequests = this.constructClientRequestHandler(Method.ClientRequest);
183
+ this.serverRequests = this.constructServerRequestHandler(Method.ServerRequest);
184
+ this.serverRequests['client/registerCapability'].setHandler(async (params) => {
185
+ params.registrations.forEach((capabilityRegistration) => {
186
+ try {
187
+ const updatedCapabilities = registerServerCapability(this.serverCapabilities, capabilityRegistration);
188
+ if (updatedCapabilities === null) {
189
+ console.error(`Failed to register server capability: ${capabilityRegistration}`);
190
+ return;
191
+ }
192
+ this.serverCapabilities = updatedCapabilities;
193
+ }
194
+ catch (err) {
195
+ console.error(err);
196
+ }
197
+ });
198
+ });
199
+ this.serverRequests['client/unregisterCapability'].setHandler(async (params) => {
200
+ params.unregisterations.forEach((capabilityUnregistration) => {
201
+ this.serverCapabilities = unregisterServerCapability(this.serverCapabilities, capabilityUnregistration);
202
+ });
203
+ });
204
+ this.serverRequests['workspace/configuration'].setHandler(async (params) => {
205
+ return params.items.map(item => {
206
+ // LSP: "If the client can’t provide a configuration setting for a given scope
207
+ // then `null` needs to be present in the returned array."
208
+ // for now we do not support configuration, but yaml server does not respect
209
+ // client capability so we have a handler just for that
210
+ return null;
211
+ });
212
+ });
213
+ }
214
+ sendSelectiveChange(changeEvent, documentInfo) {
215
+ this._sendChange([changeEvent], documentInfo);
216
+ }
217
+ sendFullTextChange(text, documentInfo) {
218
+ this._sendChange([{ text }], documentInfo);
219
+ }
220
+ /**
221
+ * @deprecated The method should not be used in new code. Use provides() instead.
222
+ */
223
+ isRenameSupported() {
224
+ return !!(this.serverCapabilities && this.serverCapabilities.renameProvider);
225
+ }
226
+ provides(provider) {
227
+ return !!(this.serverCapabilities && this.serverCapabilities[provider]);
228
+ }
229
+ /**
230
+ * @deprecated The method should not be used in new code
231
+ */
232
+ async rename(location, documentInfo, newName, emit = true) {
233
+ if (!this.isReady || !this.isRenameSupported()) {
234
+ return null;
235
+ }
236
+ const params = {
237
+ textDocument: {
238
+ uri: documentInfo.uri
239
+ },
240
+ position: {
241
+ line: location.line,
242
+ character: location.ch
243
+ },
244
+ newName
245
+ };
246
+ const edit = await this.connection.sendRequest('textDocument/rename', params);
247
+ if (emit) {
248
+ this.emit('renamed', edit);
249
+ }
250
+ return edit;
251
+ }
252
+ connect(socket) {
253
+ super.connect(socket);
254
+ untilReady(() => {
255
+ return this.isConnected;
256
+ }, -1)
257
+ .then(() => {
258
+ this.connection.onClose(() => {
259
+ this.isConnected = false;
260
+ this.emit('close', this.closingManually);
261
+ });
262
+ })
263
+ .catch(() => {
264
+ console.error('Could not connect onClose signal');
265
+ });
266
+ return this;
267
+ }
268
+ close() {
269
+ try {
270
+ this.closingManually = true;
271
+ super.close();
272
+ }
273
+ catch (e) {
274
+ this.closingManually = false;
275
+ }
276
+ }
277
+ _sendChange(changeEvents, documentInfo) {
278
+ if (!this.isReady) {
279
+ return;
280
+ }
281
+ if (!this.openedUris.get(documentInfo.uri)) {
282
+ this.sendOpen(documentInfo);
283
+ }
284
+ const textDocumentChange = {
285
+ textDocument: {
286
+ uri: documentInfo.uri,
287
+ version: documentInfo.version
288
+ },
289
+ contentChanges: changeEvents
290
+ };
291
+ this.connection.sendNotification('textDocument/didChange', textDocumentChange);
292
+ documentInfo.version++;
293
+ }
294
+ async getCompletionResolve(completionItem) {
295
+ if (!this.isReady || !this.isCompletionResolveProvider()) {
296
+ return;
297
+ }
298
+ return this.connection.sendRequest('completionItem/resolve', completionItem);
299
+ }
300
+ /**
301
+ * Does support completionItem/resolve?
302
+ * @deprecated The method should not be used in new code
303
+ */
304
+ isCompletionResolveProvider() {
305
+ var _a, _b;
306
+ return (((_b = (_a = this.serverCapabilities) === null || _a === void 0 ? void 0 : _a.completionProvider) === null || _b === void 0 ? void 0 : _b.resolveProvider) || false);
307
+ }
308
+ }
309
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,2IAA2I;AAC3I,0FAA0F;AAC1F,wFAAwF;AACxF,oFAAoF;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAA4B,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,sDAAsD,CAAC;AAE9D,OAAO,EAWL,MAAM,EAGP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMrC,MAAM,oBAAoB;IAIxB,YACY,UAA6B,EAC7B,MAAS,EACT,OAAsB;QAFtB,eAAU,GAAV,UAAU,CAAmB;QAC7B,WAAM,GAAN,MAAM,CAAG;QACT,YAAO,GAAP,OAAO,CAAe;IAC/B,CAAC;IACJ,OAAO,CAAC,MAA+B;QACrC,0BAA0B;QAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,eAAe,EAAE;YAC5C,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,UAAU;aACnB,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,MAAwB,EAAE,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,eAAe,EAAE;gBAC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AAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;YAC1C,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;SAC7B;QACD,MAAM,kBAAkB,GAAoC;YAC1D,YAAY,EAAE;gBACZ,GAAG,EAAE,YAAY,CAAC,GAAG;gBACrB,OAAO,EAAE,YAAY,CAAC,OAAO;aACS;YACxC,cAAc,EAAE,YAAY;SAC7B,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAC9B,wBAAwB,EACxB,kBAAkB,CACnB,CAAC;QACF,YAAY,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,cAAkC;QAElC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAE;YACxD,OAAO;SACR;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,wBAAwB,EACxB,cAAc,CACf,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,2BAA2B;;QAChC,OAAO,CACL,CAAA,MAAA,MAAA,IAAI,CAAC,kBAAkB,0CAAE,kBAAkB,0CAAE,eAAe,KAAI,KAAK,CACtE,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,71 @@
1
+ import { IDocumentWidget } from '@jupyterlab/docregistry';
2
+ import { Signal } from '@lumino/signaling';
3
+ import { WidgetAdapter } from './adapters/adapter';
4
+ import { LSPConnection } from './connection';
5
+ import { AskServersToSendTraceNotifications } from './plugin';
6
+ import { IDocumentConnectionData, ILanguageServerManager, ILSPConnection, ILSPDocumentConnectionManager, ISocketConnectionOptions, TLanguageServerConfigurations, TLanguageServerId } from './tokens';
7
+ import { IForeignContext, VirtualDocument } from './virtual/document';
8
+ /**
9
+ * Each Widget with a document (whether file or a notebook) has the same DocumentConnectionManager
10
+ * (see JupyterLabWidgetAdapter). Using id_path instead of uri led to documents being overwritten
11
+ * as two identical id_paths could be created for two different notebooks.
12
+ */
13
+ export declare class DocumentConnectionManager implements ILSPDocumentConnectionManager {
14
+ connections: Map<VirtualDocument.uri, LSPConnection>;
15
+ adapters: Map<string, WidgetAdapter<IDocumentWidget>>;
16
+ documents: Map<VirtualDocument.uri, VirtualDocument>;
17
+ initialized: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
18
+ connected: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
19
+ /**
20
+ * Connection temporarily lost or could not be fully established; a re-connection will be attempted;
21
+ */
22
+ disconnected: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
23
+ /**
24
+ * Connection was closed permanently and no-reconnection will be attempted, e.g.:
25
+ * - there was a serious server error
26
+ * - user closed the connection,
27
+ * - re-connection attempts exceeded,
28
+ */
29
+ closed: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
30
+ documentsChanged: Signal<ILSPDocumentConnectionManager, Map<VirtualDocument.uri, VirtualDocument>>;
31
+ languageServerManager: ILanguageServerManager;
32
+ initialConfigurations: TLanguageServerConfigurations;
33
+ private ignoredLanguages;
34
+ constructor(options: DocumentConnectionManager.IOptions);
35
+ connectDocumentSignals(virtualDocument: VirtualDocument): void;
36
+ disconnectDocumentSignals(virtualDocument: VirtualDocument, emit?: boolean): void;
37
+ onForeignDocumentOpened(_host: VirtualDocument, context: IForeignContext): void;
38
+ onForeignDocumentClosed(_host: VirtualDocument, context: IForeignContext): void;
39
+ private connectSocket;
40
+ registerAdapter(path: string, adapter: WidgetAdapter<IDocumentWidget>): void;
41
+ updateConfiguration(allServerSettings: TLanguageServerConfigurations): void;
42
+ updateServerConfigurations(allServerSettings: TLanguageServerConfigurations): void;
43
+ /**
44
+ * Fired the first time a connection is opened. These _should_ be the only
45
+ * invocation of `.on` (once remaining LSPFeature.connection_handlers are made
46
+ * singletons).
47
+ */
48
+ onNewConnection: (connection: LSPConnection) => void;
49
+ /**
50
+ * TODO: presently no longer referenced. A failing connection would close
51
+ * the socket, triggering the language server on the other end to exit
52
+ */
53
+ retryToConnect(options: ISocketConnectionOptions, reconnectDelay: number, retrialsLeft?: number): Promise<void>;
54
+ disconnect(languageId: TLanguageServerId): void;
55
+ connect(options: ISocketConnectionOptions, firstTimeoutSeconds?: number, secondTimeoutMinutes?: number): Promise<ILSPConnection | undefined>;
56
+ unregisterDocument(virtualDocument: VirtualDocument, emit?: boolean): void;
57
+ updateLogging(logAllCommunication: boolean, setTrace: AskServersToSendTraceNotifications): void;
58
+ private forEachDocumentOfConnection;
59
+ }
60
+ export declare namespace DocumentConnectionManager {
61
+ interface IOptions {
62
+ languageServerManager: ILanguageServerManager;
63
+ }
64
+ function solveUris(virtualDocument: VirtualDocument, language: string): IURIs;
65
+ interface IURIs {
66
+ base: string;
67
+ document: string;
68
+ server: string;
69
+ socket: string;
70
+ }
71
+ }