@codingame/monaco-languageclient-wrapper 5.0.0-update-monaco.4 → 5.0.0

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 (71) hide show
  1. package/dist/createLanguageClient.js +130 -0
  2. package/dist/{src/customRequests.js → customRequests.js} +11 -11
  3. package/dist/{src/extensionConfiguration.js → extensionConfiguration.js} +1 -1
  4. package/dist/extensions/cobol.js +27 -0
  5. package/dist/extensions/csharp.js +27 -0
  6. package/dist/extensions/java/commands.js +70 -70
  7. package/dist/extensions/java/extension.js +9 -8
  8. package/dist/extensions/java/inlayHintsProvider.js +43 -42
  9. package/dist/extensions/java/protocol.js +19 -19
  10. package/dist/extensions/java/sourceAction.js +328 -328
  11. package/dist/extensions/java.js +34 -0
  12. package/dist/extensions/tools.js +66 -0
  13. package/dist/extensions.js +171 -0
  14. package/dist/index.js +5 -5
  15. package/dist/infrastructure.js +89 -0
  16. package/dist/languageClient.js +314 -0
  17. package/dist/languageClientOptions.js +16 -0
  18. package/dist/node_modules/tslib/tslib.es6.js +9 -9
  19. package/dist/services.js +8 -0
  20. package/dist/staticOptions.js +421 -0
  21. package/package.json +12 -13
  22. package/stats.html +1 -1
  23. package/dist/_virtual/_commonjsHelpers.js +0 -5
  24. package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -50
  25. package/dist/_virtual/api.js +0 -2
  26. package/dist/_virtual/cancellation.js +0 -2
  27. package/dist/_virtual/connection.js +0 -2
  28. package/dist/_virtual/disposable.js +0 -2
  29. package/dist/_virtual/events.js +0 -2
  30. package/dist/_virtual/is.js +0 -2
  31. package/dist/_virtual/linkedMap.js +0 -2
  32. package/dist/_virtual/main.js +0 -2
  33. package/dist/_virtual/messageBuffer.js +0 -2
  34. package/dist/_virtual/messageReader.js +0 -2
  35. package/dist/_virtual/messageWriter.js +0 -2
  36. package/dist/_virtual/messages.js +0 -2
  37. package/dist/_virtual/once.js +0 -2
  38. package/dist/_virtual/ral.js +0 -2
  39. package/dist/_virtual/ril.js +0 -2
  40. package/dist/_virtual/semaphore.js +0 -2
  41. package/dist/_virtual/sharedArrayCancellation.js +0 -2
  42. package/dist/node_modules/delay/index.js +0 -45
  43. package/dist/node_modules/once/once.js +0 -44
  44. package/dist/node_modules/vscode-jsonrpc/lib/browser/main.js +0 -77
  45. package/dist/node_modules/vscode-jsonrpc/lib/browser/ril.js +0 -153
  46. package/dist/node_modules/vscode-jsonrpc/lib/common/api.js +0 -96
  47. package/dist/node_modules/vscode-jsonrpc/lib/common/cancellation.js +0 -95
  48. package/dist/node_modules/vscode-jsonrpc/lib/common/connection.js +0 -1182
  49. package/dist/node_modules/vscode-jsonrpc/lib/common/disposable.js +0 -19
  50. package/dist/node_modules/vscode-jsonrpc/lib/common/events.js +0 -121
  51. package/dist/node_modules/vscode-jsonrpc/lib/common/is.js +0 -38
  52. package/dist/node_modules/vscode-jsonrpc/lib/common/linkedMap.js +0 -386
  53. package/dist/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js +0 -149
  54. package/dist/node_modules/vscode-jsonrpc/lib/common/messageReader.js +0 -198
  55. package/dist/node_modules/vscode-jsonrpc/lib/common/messageWriter.js +0 -122
  56. package/dist/node_modules/vscode-jsonrpc/lib/common/messages.js +0 -240
  57. package/dist/node_modules/vscode-jsonrpc/lib/common/ral.js +0 -26
  58. package/dist/node_modules/vscode-jsonrpc/lib/common/semaphore.js +0 -72
  59. package/dist/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +0 -80
  60. package/dist/node_modules/wrappy/wrappy.js +0 -25
  61. package/dist/src/createLanguageClient.js +0 -131
  62. package/dist/src/extensions/cobol.js +0 -24
  63. package/dist/src/extensions/csharp.js +0 -29
  64. package/dist/src/extensions/java.js +0 -36
  65. package/dist/src/extensions/tools.js +0 -91
  66. package/dist/src/extensions.js +0 -172
  67. package/dist/src/infrastructure.js +0 -87
  68. package/dist/src/languageClient.js +0 -305
  69. package/dist/src/languageClientOptions.js +0 -16
  70. package/dist/src/services.js +0 -8
  71. package/dist/src/staticOptions.js +0 -441
@@ -1,305 +0,0 @@
1
- import { defineProperty as _defineProperty, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { State, CloseAction, ErrorAction } from 'vscode-languageclient';
3
- import delay from '../node_modules/delay/index.js';
4
- import { Emitter, LogMessageNotification } from 'vscode-languageserver-protocol';
5
- import * as vscode from 'vscode';
6
- import { errorHandler } from 'vscode/monaco';
7
- import once from '../node_modules/once/once.js';
8
- import { DisposableCollection } from 'vscode-ws-jsonrpc';
9
- import { initializePromise } from '@codingame/monaco-editor-wrapper';
10
- import { updateServices } from './services.js';
11
- import createLanguageClient from './createLanguageClient.js';
12
- import { WillDisposeFeature, FileSystemFeature, InitializeTextDocumentFeature } from './extensions.js';
13
- import { loadExtensionConfigurations } from './extensionConfiguration.js';
14
- import { getLanguageClientOptions } from './languageClientOptions.js';
15
- const RETRY_CONNECTION_DELAY = 3000;
16
- class LanguageClientManager {
17
- constructor(id, clientOptions, infrastructure, managerOptions) {
18
- this.id = id;
19
- this.clientOptions = clientOptions;
20
- this.infrastructure = infrastructure;
21
- this.managerOptions = managerOptions;
22
- _defineProperty(this, "languageClient", void 0);
23
- _defineProperty(this, "disposed", false);
24
- _defineProperty(this, "onDidChangeStatusEmitter", new Emitter());
25
- _defineProperty(this, "onErrorEmitter", new Emitter());
26
- _defineProperty(this, "onDidCloseEmitter", new Emitter());
27
- _defineProperty(this, "onWillShutdownEmitter", new Emitter());
28
- _defineProperty(this, "currentStatus", 'connecting');
29
- _defineProperty(this, "useMutualizedProxy", void 0);
30
- _defineProperty(this, "startPromise", void 0);
31
- _defineProperty(this, "handleClose", () => {
32
- return {
33
- action: CloseAction.DoNotRestart
34
- };
35
- });
36
- _defineProperty(this, "handleError", error => {
37
- errorHandler.onUnexpectedError(new Error('[LSP] Language client error', {
38
- cause: error
39
- }));
40
- this.onErrorEmitter.fire(error);
41
- this.updateStatus('error');
42
- return {
43
- action: ErrorAction.Shutdown
44
- };
45
- });
46
- _defineProperty(this, "prepare", once(async () => {
47
- try {
48
- await initializePromise;
49
- await loadExtensionConfigurations([this.clientOptions]);
50
- } catch (error) {
51
- errorHandler.onUnexpectedError(new Error('[LSP] Unable to load extension configuration', {
52
- cause: error
53
- }));
54
- }
55
- }));
56
- this.useMutualizedProxy = this.infrastructure.useMutualizedProxy(this.id, this.clientOptions);
57
- }
58
- updateStatus(status) {
59
- this.currentStatus = status;
60
- this.notifyStatusChanged();
61
- }
62
- notifyStatusChanged() {
63
- this.onDidChangeStatusEmitter.fire({
64
- status: this.currentStatus
65
- });
66
- }
67
- isConnected() {
68
- return ['connected', 'ready'].includes(this.currentStatus);
69
- }
70
- async dispose(timeout) {
71
- this.disposed = true;
72
- try {
73
- if (this.startPromise != null) {
74
- try {
75
- await this.startPromise;
76
- } catch (error) {
77
- }
78
- }
79
- if (this.languageClient != null) {
80
- const languageClient = this.languageClient;
81
- this.languageClient = undefined;
82
- await languageClient.dispose(timeout);
83
- }
84
- } finally {
85
- this.onDidCloseEmitter.fire();
86
- }
87
- }
88
- get onDidChangeStatus() {
89
- return this.onDidChangeStatusEmitter.event;
90
- }
91
- get onDidClose() {
92
- return this.onDidCloseEmitter.event;
93
- }
94
- get onWillShutdown() {
95
- return this.onWillShutdownEmitter.event;
96
- }
97
- get onError() {
98
- return this.onErrorEmitter.event;
99
- }
100
- isModelManaged(document) {
101
- if (this.clientOptions.documentSelector == null) {
102
- return false;
103
- }
104
- return vscode.languages.match(this.clientOptions.documentSelector, document) > 0;
105
- }
106
- isDisposed() {
107
- return this.disposed;
108
- }
109
- async start() {
110
- let started = false;
111
- let attempt = 0;
112
- const maxStartAttemptCount = this.managerOptions.maxStartAttemptCount;
113
- while (!this.isDisposed() && !started) {
114
- if (maxStartAttemptCount != null && attempt >= maxStartAttemptCount) {
115
- throw new Error("Max connection attempt count exceeded: ".concat(maxStartAttemptCount));
116
- }
117
- try {
118
- var _this$languageClient$, _this$languageClient;
119
- this.startPromise = this._start();
120
- await this.startPromise;
121
- if (!((_this$languageClient$ = (_this$languageClient = this.languageClient) === null || _this$languageClient === void 0 ? void 0 : _this$languageClient.isRunning()) !== null && _this$languageClient$ !== void 0 ? _this$languageClient$ : false)) {
122
- throw new Error('Language server not running');
123
- }
124
- started = true;
125
- } catch (error) {
126
- this.languageClient = undefined;
127
- this.startPromise = undefined;
128
- errorHandler.onUnexpectedError(new Error("[LSP] Unable to start language client, retrying in ".concat(RETRY_CONNECTION_DELAY, " ms"), {
129
- cause: error
130
- }));
131
- await delay(RETRY_CONNECTION_DELAY);
132
- }
133
- ++attempt;
134
- }
135
- }
136
- async _start() {
137
- var _this$clientOptions$m;
138
- await this.prepare();
139
- const onServerResponse = new Emitter();
140
- const languageClient = await createLanguageClient(this.id, this.infrastructure, this.clientOptions, {
141
- error: this.handleError,
142
- closed: this.handleClose
143
- }, _objectSpread2(_objectSpread2({}, (_this$clientOptions$m = this.clientOptions.middleware) !== null && _this$clientOptions$m !== void 0 ? _this$clientOptions$m : {}), {}, {
144
- handleDiagnostics: (uri, diagnostics, next) => {
145
- var _this$clientOptions$m2;
146
- if (((_this$clientOptions$m2 = this.clientOptions.middleware) === null || _this$clientOptions$m2 === void 0 ? void 0 : _this$clientOptions$m2.handleDiagnostics) != null) {
147
- this.clientOptions.middleware.handleDiagnostics(uri, diagnostics, next);
148
- } else {
149
- next(uri, diagnostics);
150
- }
151
- onServerResponse.fire();
152
- },
153
- provideCodeActions: async (document, range, context, token, next) => {
154
- try {
155
- var _this$clientOptions$m3;
156
- if (((_this$clientOptions$m3 = this.clientOptions.middleware) === null || _this$clientOptions$m3 === void 0 ? void 0 : _this$clientOptions$m3.provideCodeActions) != null) {
157
- return await this.clientOptions.middleware.provideCodeActions(document, range, context, token, next);
158
- } else {
159
- return await next(document, range, context, token);
160
- }
161
- } finally {
162
- onServerResponse.fire();
163
- }
164
- },
165
- provideDocumentRangeSemanticTokens: async (document, range, token, next) => {
166
- try {
167
- var _this$clientOptions$m4;
168
- if (((_this$clientOptions$m4 = this.clientOptions.middleware) === null || _this$clientOptions$m4 === void 0 ? void 0 : _this$clientOptions$m4.provideDocumentRangeSemanticTokens) != null) {
169
- return await this.clientOptions.middleware.provideDocumentRangeSemanticTokens(document, range, token, next);
170
- } else {
171
- return await next(document, range, token);
172
- }
173
- } finally {
174
- onServerResponse.fire();
175
- }
176
- },
177
- provideDocumentSemanticTokens: async (document, token, next) => {
178
- try {
179
- var _this$clientOptions$m5;
180
- if (((_this$clientOptions$m5 = this.clientOptions.middleware) === null || _this$clientOptions$m5 === void 0 ? void 0 : _this$clientOptions$m5.provideDocumentSemanticTokens) != null) {
181
- return await this.clientOptions.middleware.provideDocumentSemanticTokens(document, token, next);
182
- } else {
183
- return await next(document, token);
184
- }
185
- } finally {
186
- onServerResponse.fire();
187
- }
188
- },
189
- handleWorkDoneProgress: async (token, params, next) => {
190
- var _this$clientOptions$m6;
191
- if (((_this$clientOptions$m6 = this.clientOptions.middleware) === null || _this$clientOptions$m6 === void 0 ? void 0 : _this$clientOptions$m6.handleWorkDoneProgress) != null) {
192
- this.clientOptions.middleware.handleWorkDoneProgress(token, params, next);
193
- } else {
194
- next(token, params);
195
- }
196
- if (params.kind === 'end') {
197
- onServerResponse.fire();
198
- }
199
- },
200
- provideHover: async (document, position, token, next) => {
201
- try {
202
- var _this$clientOptions$m7;
203
- if (((_this$clientOptions$m7 = this.clientOptions.middleware) === null || _this$clientOptions$m7 === void 0 ? void 0 : _this$clientOptions$m7.provideHover) != null) {
204
- return await this.clientOptions.middleware.provideHover(document, position, token, next);
205
- } else {
206
- return await next(document, position, token);
207
- }
208
- } finally {
209
- onServerResponse.fire();
210
- }
211
- }
212
- }));
213
- this.languageClient = languageClient;
214
- let readyPromise = null;
215
- languageClient.onDidChangeState(async state => {
216
- switch (state.newState) {
217
- case State.Starting:
218
- {
219
- this.updateStatus('connecting');
220
- readyPromise = Promise.resolve().then(async () => {
221
- const disposableCollection = new DisposableCollection();
222
- let readyPromise;
223
- const {
224
- maxInitializeDuration,
225
- readinessMessageMatcher
226
- } = this.clientOptions;
227
- if (readinessMessageMatcher != null && !this.useMutualizedProxy) {
228
- readyPromise = new Promise(resolve => {
229
- disposableCollection.push(languageClient.onNotification(LogMessageNotification.type, logMessage => {
230
- if (readinessMessageMatcher.exec(logMessage.message) != null) {
231
- resolve();
232
- }
233
- }));
234
- });
235
- } else {
236
- readyPromise = new Promise(resolve => {
237
- disposableCollection.push(onServerResponse.event(resolve));
238
- });
239
- }
240
- await Promise.race([readyPromise, delay(maxInitializeDuration !== null && maxInitializeDuration !== void 0 ? maxInitializeDuration : 15000)]);
241
- disposableCollection.dispose();
242
- }, error => {
243
- errorHandler.onUnexpectedError(new Error("[LSP] Error while waiting for the ".concat(this.id, " language client to be ready"), {
244
- cause: error
245
- }));
246
- });
247
- break;
248
- }
249
- case State.Running:
250
- {
251
- this.updateStatus('connected');
252
- await readyPromise;
253
- this.updateStatus('ready');
254
- break;
255
- }
256
- case State.Stopped:
257
- {
258
- this.updateStatus('closed');
259
- setTimeout(() => {
260
- void languageClient.dispose();
261
- });
262
- if (state.oldState === State.Running && !this.isDisposed() && this.languageClient === languageClient) {
263
- this.languageClient = undefined;
264
- console.info('[LSP] Restarting language client', state);
265
- this.start().catch(error => {
266
- errorHandler.onUnexpectedError(new Error('[LSP] Language client stopped', {
267
- cause: error
268
- }));
269
- });
270
- }
271
- break;
272
- }
273
- }
274
- });
275
- this.languageClient.registerFeature(new WillDisposeFeature(this.languageClient, this.onWillShutdownEmitter));
276
- if (this.infrastructure.getFileContent != null) {
277
- this.languageClient.registerFeature(new FileSystemFeature(this.infrastructure, this));
278
- }
279
- if (!this.infrastructure.automaticTextDocumentUpdate) {
280
- this.languageClient.registerFeature(new InitializeTextDocumentFeature(this, this.infrastructure));
281
- }
282
- await this.languageClient.start();
283
- }
284
- async sendNotification(type, params) {
285
- await this.languageClient.sendNotification(type, params);
286
- }
287
- sendRequest(type, params) {
288
- return this.languageClient.sendRequest(type, params);
289
- }
290
- }
291
- function createLanguageClientManager(id, infrastructure) {
292
- let clientOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getLanguageClientOptions(id);
293
- let managerOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
294
- if (clientOptions == null) {
295
- throw new Error("Unknown ".concat(id, " language server"));
296
- }
297
- if (infrastructure.useMutualizedProxy(id, clientOptions) && clientOptions.mutualizable) {
298
- clientOptions = _objectSpread2(_objectSpread2({}, clientOptions), {}, {
299
- synchronize: undefined
300
- });
301
- }
302
- updateServices(infrastructure);
303
- return new LanguageClientManager(id, clientOptions, infrastructure, managerOptions);
304
- }
305
- export { LanguageClientManager, createLanguageClientManager };
@@ -1,16 +0,0 @@
1
- import { Disposable } from 'vscode-languageserver-protocol';
2
- import staticOptions from './staticOptions.js';
3
- const dynamicOptions = {};
4
- function registerLanguageClient(id, options) {
5
- dynamicOptions[id] = options;
6
- return Disposable.create(() => {
7
- if (dynamicOptions[id] === options) {
8
- delete dynamicOptions[id];
9
- }
10
- });
11
- }
12
- function getLanguageClientOptions(id) {
13
- var _dynamicOptions$id;
14
- return (_dynamicOptions$id = dynamicOptions[id]) !== null && _dynamicOptions$id !== void 0 ? _dynamicOptions$id : staticOptions[id];
15
- }
16
- export { getLanguageClientOptions, registerLanguageClient };
@@ -1,8 +0,0 @@
1
- import * as vscode from 'vscode';
2
- function updateServices(infrastructure) {
3
- if (infrastructure.workspaceFolders != null) {
4
- var _vscode$workspace$wor;
5
- vscode.workspace.updateWorkspaceFolders(0, (_vscode$workspace$wor = vscode.workspace.workspaceFolders) === null || _vscode$workspace$wor === void 0 ? void 0 : _vscode$workspace$wor.length, ...infrastructure.workspaceFolders);
6
- }
7
- }
8
- export { updateServices };