@depup/vscode-languageserver 10.1.1-depup.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.
- package/License.txt +11 -0
- package/README.md +25 -0
- package/bin/installServerIntoExtension +73 -0
- package/changes.json +5 -0
- package/eslint.config.js +10 -0
- package/lib/browser/main.d.ts +20 -0
- package/lib/browser/main.js +61 -0
- package/lib/common/api.d.ts +15 -0
- package/lib/common/api.js +35 -0
- package/lib/common/callHierarchy.d.ts +15 -0
- package/lib/common/callHierarchy.js +34 -0
- package/lib/common/configuration.d.ts +9 -0
- package/lib/common/configuration.js +71 -0
- package/lib/common/diagnostic.d.ts +29 -0
- package/lib/common/diagnostic.js +30 -0
- package/lib/common/fileOperations.d.ts +16 -0
- package/lib/common/fileOperations.js +43 -0
- package/lib/common/foldingRange.d.ts +22 -0
- package/lib/common/foldingRange.js +26 -0
- package/lib/common/inlayHint.d.ts +28 -0
- package/lib/common/inlayHint.js +30 -0
- package/lib/common/inlineCompletion.d.ts +18 -0
- package/lib/common/inlineCompletion.js +22 -0
- package/lib/common/inlineValue.d.ts +22 -0
- package/lib/common/inlineValue.js +25 -0
- package/lib/common/linkedEditingRange.d.ts +16 -0
- package/lib/common/linkedEditingRange.js +18 -0
- package/lib/common/moniker.d.ts +13 -0
- package/lib/common/moniker.js +23 -0
- package/lib/common/notebook.d.ts +99 -0
- package/lib/common/notebook.js +262 -0
- package/lib/common/progress.d.ts +25 -0
- package/lib/common/progress.js +172 -0
- package/lib/common/semanticTokens.d.ts +43 -0
- package/lib/common/semanticTokens.js +251 -0
- package/lib/common/server.d.ts +812 -0
- package/lib/common/server.js +798 -0
- package/lib/common/showDocument.d.ts +6 -0
- package/lib/common/showDocument.js +16 -0
- package/lib/common/textDocumentContent.d.ts +14 -0
- package/lib/common/textDocumentContent.js +25 -0
- package/lib/common/textDocuments.d.ts +133 -0
- package/lib/common/textDocuments.js +180 -0
- package/lib/common/typeHierarchy.d.ts +15 -0
- package/lib/common/typeHierarchy.js +34 -0
- package/lib/common/utils/is.d.ts +9 -0
- package/lib/common/utils/is.js +42 -0
- package/lib/common/utils/uuid.d.ts +22 -0
- package/lib/common/utils/uuid.js +98 -0
- package/lib/common/workspaceFolder.d.ts +7 -0
- package/lib/common/workspaceFolder.js +47 -0
- package/lib/node/files.d.ts +19 -0
- package/lib/node/files.js +295 -0
- package/lib/node/main.d.ts +60 -0
- package/lib/node/main.js +295 -0
- package/lib/node/resolve.d.ts +1 -0
- package/lib/node/resolve.js +20 -0
- package/package.json +65 -0
- package/thirdpartynotices.txt +84 -0
- package/typings/thenable.d.ts +5 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* --------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
* ------------------------------------------------------------------------------------------ */
|
|
6
|
+
/// <reference path="../../typings/thenable.d.ts" preserve: true/>
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports._NotebooksImpl = exports._LanguagesImpl = exports.BulkUnregistration = exports.BulkRegistration = exports.ErrorMessageTracker = void 0;
|
|
42
|
+
exports.combineConsoleFeatures = combineConsoleFeatures;
|
|
43
|
+
exports.combineTelemetryFeatures = combineTelemetryFeatures;
|
|
44
|
+
exports.combineTracerFeatures = combineTracerFeatures;
|
|
45
|
+
exports.combineClientFeatures = combineClientFeatures;
|
|
46
|
+
exports.combineWindowFeatures = combineWindowFeatures;
|
|
47
|
+
exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
|
|
48
|
+
exports.combineLanguagesFeatures = combineLanguagesFeatures;
|
|
49
|
+
exports.combineNotebooksFeatures = combineNotebooksFeatures;
|
|
50
|
+
exports.combineFeatures = combineFeatures;
|
|
51
|
+
exports.createConnection = createConnection;
|
|
52
|
+
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
|
|
53
|
+
const Is = __importStar(require("./utils/is"));
|
|
54
|
+
const UUID = __importStar(require("./utils/uuid"));
|
|
55
|
+
const progress_1 = require("./progress");
|
|
56
|
+
const configuration_1 = require("./configuration");
|
|
57
|
+
const workspaceFolder_1 = require("./workspaceFolder");
|
|
58
|
+
const callHierarchy_1 = require("./callHierarchy");
|
|
59
|
+
const semanticTokens_1 = require("./semanticTokens");
|
|
60
|
+
const showDocument_1 = require("./showDocument");
|
|
61
|
+
const fileOperations_1 = require("./fileOperations");
|
|
62
|
+
const linkedEditingRange_1 = require("./linkedEditingRange");
|
|
63
|
+
const typeHierarchy_1 = require("./typeHierarchy");
|
|
64
|
+
const inlineValue_1 = require("./inlineValue");
|
|
65
|
+
const foldingRange_1 = require("./foldingRange");
|
|
66
|
+
// import { InlineCompletionFeatureShape, InlineCompletionFeature } from './inlineCompletion.proposed';
|
|
67
|
+
const inlayHint_1 = require("./inlayHint");
|
|
68
|
+
const diagnostic_1 = require("./diagnostic");
|
|
69
|
+
const notebook_1 = require("./notebook");
|
|
70
|
+
const moniker_1 = require("./moniker");
|
|
71
|
+
const inlineCompletion_1 = require("./inlineCompletion");
|
|
72
|
+
const textDocumentContent_1 = require("./textDocumentContent");
|
|
73
|
+
function null2Undefined(value) {
|
|
74
|
+
if (value === null) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Helps tracking error message. Equal occurrences of the same
|
|
81
|
+
* message are only stored once. This class is for example
|
|
82
|
+
* useful if text documents are validated in a loop and equal
|
|
83
|
+
* error message should be folded into one.
|
|
84
|
+
*/
|
|
85
|
+
class ErrorMessageTracker {
|
|
86
|
+
_messages;
|
|
87
|
+
constructor() {
|
|
88
|
+
this._messages = Object.create(null);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Add a message to the tracker.
|
|
92
|
+
*
|
|
93
|
+
* @param message The message to add.
|
|
94
|
+
*/
|
|
95
|
+
add(message) {
|
|
96
|
+
let count = this._messages[message];
|
|
97
|
+
if (!count) {
|
|
98
|
+
count = 0;
|
|
99
|
+
}
|
|
100
|
+
count++;
|
|
101
|
+
this._messages[message] = count;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Send all tracked messages to the connection's window.
|
|
105
|
+
*
|
|
106
|
+
* @param connection The connection established between client and server.
|
|
107
|
+
*/
|
|
108
|
+
sendErrors(connection) {
|
|
109
|
+
Object.keys(this._messages).forEach(message => {
|
|
110
|
+
connection.window.showErrorMessage(message);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.ErrorMessageTracker = ErrorMessageTracker;
|
|
115
|
+
class RemoteConsoleImpl {
|
|
116
|
+
_rawConnection;
|
|
117
|
+
_connection;
|
|
118
|
+
constructor() {
|
|
119
|
+
}
|
|
120
|
+
rawAttach(connection) {
|
|
121
|
+
this._rawConnection = connection;
|
|
122
|
+
}
|
|
123
|
+
attach(connection) {
|
|
124
|
+
this._connection = connection;
|
|
125
|
+
}
|
|
126
|
+
get connection() {
|
|
127
|
+
if (!this._connection) {
|
|
128
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
129
|
+
}
|
|
130
|
+
return this._connection;
|
|
131
|
+
}
|
|
132
|
+
fillServerCapabilities(_capabilities) {
|
|
133
|
+
}
|
|
134
|
+
initialize(_capabilities) {
|
|
135
|
+
}
|
|
136
|
+
error(message) {
|
|
137
|
+
this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
|
|
138
|
+
}
|
|
139
|
+
warn(message) {
|
|
140
|
+
this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
|
|
141
|
+
}
|
|
142
|
+
info(message) {
|
|
143
|
+
this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
|
|
144
|
+
}
|
|
145
|
+
log(message) {
|
|
146
|
+
this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
|
|
147
|
+
}
|
|
148
|
+
debug(message) {
|
|
149
|
+
this.send(vscode_languageserver_protocol_1.MessageType.Debug, message);
|
|
150
|
+
}
|
|
151
|
+
send(type, message) {
|
|
152
|
+
if (this._rawConnection) {
|
|
153
|
+
this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message }).catch(() => {
|
|
154
|
+
(0, vscode_languageserver_protocol_1.RAL)().console.error(`Sending log message failed`);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
class _RemoteWindowImpl {
|
|
160
|
+
_connection;
|
|
161
|
+
constructor() {
|
|
162
|
+
}
|
|
163
|
+
attach(connection) {
|
|
164
|
+
this._connection = connection;
|
|
165
|
+
}
|
|
166
|
+
get connection() {
|
|
167
|
+
if (!this._connection) {
|
|
168
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
169
|
+
}
|
|
170
|
+
return this._connection;
|
|
171
|
+
}
|
|
172
|
+
initialize(_capabilities) {
|
|
173
|
+
}
|
|
174
|
+
fillServerCapabilities(_capabilities) {
|
|
175
|
+
}
|
|
176
|
+
showErrorMessage(message, ...actions) {
|
|
177
|
+
const params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
|
|
178
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
|
|
179
|
+
}
|
|
180
|
+
showWarningMessage(message, ...actions) {
|
|
181
|
+
const params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
|
|
182
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
|
|
183
|
+
}
|
|
184
|
+
showInformationMessage(message, ...actions) {
|
|
185
|
+
const params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
|
|
186
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const RemoteWindowImpl = (0, showDocument_1.ShowDocumentFeature)((0, progress_1.ProgressFeature)(_RemoteWindowImpl));
|
|
190
|
+
var BulkRegistration;
|
|
191
|
+
(function (BulkRegistration) {
|
|
192
|
+
/**
|
|
193
|
+
* Creates a new bulk registration.
|
|
194
|
+
* @return an empty bulk registration.
|
|
195
|
+
*/
|
|
196
|
+
function create() {
|
|
197
|
+
return new BulkRegistrationImpl();
|
|
198
|
+
}
|
|
199
|
+
BulkRegistration.create = create;
|
|
200
|
+
})(BulkRegistration || (exports.BulkRegistration = BulkRegistration = {}));
|
|
201
|
+
class BulkRegistrationImpl {
|
|
202
|
+
_registrations = [];
|
|
203
|
+
_registered = new Set();
|
|
204
|
+
add(type, registerOptions) {
|
|
205
|
+
const method = Is.string(type) ? type : type.method;
|
|
206
|
+
if (this._registered.has(method)) {
|
|
207
|
+
throw new Error(`${method} is already added to this registration`);
|
|
208
|
+
}
|
|
209
|
+
const id = UUID.generateUuid();
|
|
210
|
+
this._registrations.push({
|
|
211
|
+
id: id,
|
|
212
|
+
method: method,
|
|
213
|
+
registerOptions: registerOptions || {}
|
|
214
|
+
});
|
|
215
|
+
this._registered.add(method);
|
|
216
|
+
}
|
|
217
|
+
asRegistrationParams() {
|
|
218
|
+
return {
|
|
219
|
+
registrations: this._registrations
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
var BulkUnregistration;
|
|
224
|
+
(function (BulkUnregistration) {
|
|
225
|
+
function create() {
|
|
226
|
+
return new BulkUnregistrationImpl(undefined, []);
|
|
227
|
+
}
|
|
228
|
+
BulkUnregistration.create = create;
|
|
229
|
+
})(BulkUnregistration || (exports.BulkUnregistration = BulkUnregistration = {}));
|
|
230
|
+
class BulkUnregistrationImpl {
|
|
231
|
+
_connection;
|
|
232
|
+
_unregistrations = new Map();
|
|
233
|
+
constructor(_connection, unregistrations) {
|
|
234
|
+
this._connection = _connection;
|
|
235
|
+
unregistrations.forEach(unregistration => {
|
|
236
|
+
this._unregistrations.set(unregistration.method, unregistration);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
get isAttached() {
|
|
240
|
+
return !!this._connection;
|
|
241
|
+
}
|
|
242
|
+
attach(connection) {
|
|
243
|
+
this._connection = connection;
|
|
244
|
+
}
|
|
245
|
+
add(unregistration) {
|
|
246
|
+
this._unregistrations.set(unregistration.method, unregistration);
|
|
247
|
+
}
|
|
248
|
+
dispose() {
|
|
249
|
+
const unregistrations = [];
|
|
250
|
+
for (const unregistration of this._unregistrations.values()) {
|
|
251
|
+
unregistrations.push(unregistration);
|
|
252
|
+
}
|
|
253
|
+
const params = {
|
|
254
|
+
unregisterations: unregistrations
|
|
255
|
+
};
|
|
256
|
+
this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).catch(() => {
|
|
257
|
+
this._connection.console.info(`Bulk unregistration failed.`);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
disposeSingle(arg) {
|
|
261
|
+
const method = Is.string(arg) ? arg : arg.method;
|
|
262
|
+
const unregistration = this._unregistrations.get(method);
|
|
263
|
+
if (!unregistration) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
const params = {
|
|
267
|
+
unregisterations: [unregistration]
|
|
268
|
+
};
|
|
269
|
+
this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
|
|
270
|
+
this._unregistrations.delete(method);
|
|
271
|
+
}, (_error) => {
|
|
272
|
+
this._connection.console.info(`Un-registering request handler for ${unregistration.id} failed.`);
|
|
273
|
+
});
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
class RemoteClientImpl {
|
|
278
|
+
_connection;
|
|
279
|
+
attach(connection) {
|
|
280
|
+
this._connection = connection;
|
|
281
|
+
}
|
|
282
|
+
get connection() {
|
|
283
|
+
if (!this._connection) {
|
|
284
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
285
|
+
}
|
|
286
|
+
return this._connection;
|
|
287
|
+
}
|
|
288
|
+
initialize(_capabilities) {
|
|
289
|
+
}
|
|
290
|
+
fillServerCapabilities(_capabilities) {
|
|
291
|
+
}
|
|
292
|
+
register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
|
|
293
|
+
if (typeOrRegistrations instanceof BulkRegistrationImpl) {
|
|
294
|
+
return this.registerMany(typeOrRegistrations);
|
|
295
|
+
}
|
|
296
|
+
else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
|
|
297
|
+
return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
registerSingle1(unregistration, type, registerOptions) {
|
|
304
|
+
const method = Is.string(type) ? type : type.method;
|
|
305
|
+
const id = UUID.generateUuid();
|
|
306
|
+
const params = {
|
|
307
|
+
registrations: [{ id, method, registerOptions: registerOptions || {} }]
|
|
308
|
+
};
|
|
309
|
+
if (!unregistration.isAttached) {
|
|
310
|
+
unregistration.attach(this.connection);
|
|
311
|
+
}
|
|
312
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
|
|
313
|
+
unregistration.add({ id: id, method: method });
|
|
314
|
+
return unregistration;
|
|
315
|
+
}, (_error) => {
|
|
316
|
+
this.connection.console.info(`Registering request handler for ${method} failed.`);
|
|
317
|
+
return Promise.reject(_error);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
registerSingle2(type, registerOptions) {
|
|
321
|
+
const method = Is.string(type) ? type : type.method;
|
|
322
|
+
const id = UUID.generateUuid();
|
|
323
|
+
const params = {
|
|
324
|
+
registrations: [{ id, method, registerOptions: registerOptions || {} }]
|
|
325
|
+
};
|
|
326
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
|
|
327
|
+
return vscode_languageserver_protocol_1.Disposable.create(() => {
|
|
328
|
+
this.unregisterSingle(id, method).catch(() => { this.connection.console.info(`Un-registering capability with id ${id} failed.`); });
|
|
329
|
+
});
|
|
330
|
+
}, (_error) => {
|
|
331
|
+
this.connection.console.info(`Registering request handler for ${method} failed.`);
|
|
332
|
+
return Promise.reject(_error);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
unregisterSingle(id, method) {
|
|
336
|
+
const params = {
|
|
337
|
+
unregisterations: [{ id, method }]
|
|
338
|
+
};
|
|
339
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).catch(() => {
|
|
340
|
+
this.connection.console.info(`Un-registering request handler for ${id} failed.`);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
registerMany(registrations) {
|
|
344
|
+
const params = registrations.asRegistrationParams();
|
|
345
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
|
|
346
|
+
return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
|
|
347
|
+
}, (_error) => {
|
|
348
|
+
this.connection.console.info(`Bulk registration failed.`);
|
|
349
|
+
return Promise.reject(_error);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
class _RemoteWorkspaceImpl {
|
|
354
|
+
_connection;
|
|
355
|
+
constructor() {
|
|
356
|
+
}
|
|
357
|
+
attach(connection) {
|
|
358
|
+
this._connection = connection;
|
|
359
|
+
}
|
|
360
|
+
get connection() {
|
|
361
|
+
if (!this._connection) {
|
|
362
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
363
|
+
}
|
|
364
|
+
return this._connection;
|
|
365
|
+
}
|
|
366
|
+
initialize(_capabilities) {
|
|
367
|
+
}
|
|
368
|
+
fillServerCapabilities(_capabilities) {
|
|
369
|
+
}
|
|
370
|
+
applyEdit(paramOrEdit) {
|
|
371
|
+
function isApplyWorkspaceEditParams(value) {
|
|
372
|
+
return value && !!value.edit;
|
|
373
|
+
}
|
|
374
|
+
const params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
|
|
375
|
+
return this.connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const RemoteWorkspaceImpl = (0, textDocumentContent_1.TextDocumentContentFeature)((0, fileOperations_1.FileOperationsFeature)((0, workspaceFolder_1.WorkspaceFoldersFeature)((0, configuration_1.ConfigurationFeature)(_RemoteWorkspaceImpl))));
|
|
379
|
+
class TracerImpl {
|
|
380
|
+
_trace;
|
|
381
|
+
_connection;
|
|
382
|
+
constructor() {
|
|
383
|
+
this._trace = vscode_languageserver_protocol_1.Trace.Off;
|
|
384
|
+
}
|
|
385
|
+
attach(connection) {
|
|
386
|
+
this._connection = connection;
|
|
387
|
+
}
|
|
388
|
+
get connection() {
|
|
389
|
+
if (!this._connection) {
|
|
390
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
391
|
+
}
|
|
392
|
+
return this._connection;
|
|
393
|
+
}
|
|
394
|
+
initialize(_capabilities) {
|
|
395
|
+
}
|
|
396
|
+
fillServerCapabilities(_capabilities) {
|
|
397
|
+
}
|
|
398
|
+
set trace(value) {
|
|
399
|
+
this._trace = value;
|
|
400
|
+
}
|
|
401
|
+
log(message, verbose) {
|
|
402
|
+
if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
this.connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
|
|
406
|
+
message: message,
|
|
407
|
+
verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
|
|
408
|
+
}).catch(() => {
|
|
409
|
+
// Very hard to decide what to do. We tried to send a log
|
|
410
|
+
// message which failed so we can't simply send another :-(.
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
class TelemetryImpl {
|
|
415
|
+
_connection;
|
|
416
|
+
constructor() {
|
|
417
|
+
}
|
|
418
|
+
attach(connection) {
|
|
419
|
+
this._connection = connection;
|
|
420
|
+
}
|
|
421
|
+
get connection() {
|
|
422
|
+
if (!this._connection) {
|
|
423
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
424
|
+
}
|
|
425
|
+
return this._connection;
|
|
426
|
+
}
|
|
427
|
+
initialize(_capabilities) {
|
|
428
|
+
}
|
|
429
|
+
fillServerCapabilities(_capabilities) {
|
|
430
|
+
}
|
|
431
|
+
logEvent(data) {
|
|
432
|
+
this.connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data).catch(() => {
|
|
433
|
+
this.connection.console.log(`Sending TelemetryEventNotification failed`);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
class _LanguagesImpl {
|
|
438
|
+
_connection;
|
|
439
|
+
constructor() {
|
|
440
|
+
}
|
|
441
|
+
attach(connection) {
|
|
442
|
+
this._connection = connection;
|
|
443
|
+
}
|
|
444
|
+
get connection() {
|
|
445
|
+
if (!this._connection) {
|
|
446
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
447
|
+
}
|
|
448
|
+
return this._connection;
|
|
449
|
+
}
|
|
450
|
+
initialize(_capabilities) {
|
|
451
|
+
}
|
|
452
|
+
fillServerCapabilities(_capabilities) {
|
|
453
|
+
}
|
|
454
|
+
attachWorkDoneProgress(params) {
|
|
455
|
+
return (0, progress_1.attachWorkDone)(this.connection, params);
|
|
456
|
+
}
|
|
457
|
+
attachPartialResultProgress(_type, params) {
|
|
458
|
+
return (0, progress_1.attachPartialResult)(this.connection, params);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
exports._LanguagesImpl = _LanguagesImpl;
|
|
462
|
+
const LanguagesImpl = (0, inlineCompletion_1.InlineCompletionFeature)((0, foldingRange_1.FoldingRangeFeature)((0, moniker_1.MonikerFeature)((0, diagnostic_1.DiagnosticFeature)((0, inlayHint_1.InlayHintFeature)((0, inlineValue_1.InlineValueFeature)((0, typeHierarchy_1.TypeHierarchyFeature)((0, linkedEditingRange_1.LinkedEditingRangeFeature)((0, semanticTokens_1.SemanticTokensFeature)((0, callHierarchy_1.CallHierarchyFeature)(_LanguagesImpl))))))))));
|
|
463
|
+
class _NotebooksImpl {
|
|
464
|
+
_connection;
|
|
465
|
+
constructor() {
|
|
466
|
+
}
|
|
467
|
+
attach(connection) {
|
|
468
|
+
this._connection = connection;
|
|
469
|
+
}
|
|
470
|
+
get connection() {
|
|
471
|
+
if (!this._connection) {
|
|
472
|
+
throw new Error('Remote is not attached to a connection yet.');
|
|
473
|
+
}
|
|
474
|
+
return this._connection;
|
|
475
|
+
}
|
|
476
|
+
initialize(_capabilities) {
|
|
477
|
+
}
|
|
478
|
+
fillServerCapabilities(_capabilities) {
|
|
479
|
+
}
|
|
480
|
+
attachWorkDoneProgress(params) {
|
|
481
|
+
return (0, progress_1.attachWorkDone)(this.connection, params);
|
|
482
|
+
}
|
|
483
|
+
attachPartialResultProgress(_type, params) {
|
|
484
|
+
return (0, progress_1.attachPartialResult)(this.connection, params);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
exports._NotebooksImpl = _NotebooksImpl;
|
|
488
|
+
const NotebooksImpl = (0, notebook_1.NotebookSyncFeature)(_NotebooksImpl);
|
|
489
|
+
function combineConsoleFeatures(one, two) {
|
|
490
|
+
return function (Base) {
|
|
491
|
+
return two(one(Base));
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function combineTelemetryFeatures(one, two) {
|
|
495
|
+
return function (Base) {
|
|
496
|
+
return two(one(Base));
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function combineTracerFeatures(one, two) {
|
|
500
|
+
return function (Base) {
|
|
501
|
+
return two(one(Base));
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function combineClientFeatures(one, two) {
|
|
505
|
+
return function (Base) {
|
|
506
|
+
return two(one(Base));
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function combineWindowFeatures(one, two) {
|
|
510
|
+
return function (Base) {
|
|
511
|
+
return two(one(Base));
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function combineWorkspaceFeatures(one, two) {
|
|
515
|
+
return function (Base) {
|
|
516
|
+
return two(one(Base));
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function combineLanguagesFeatures(one, two) {
|
|
520
|
+
return function (Base) {
|
|
521
|
+
return two(one(Base));
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
function combineNotebooksFeatures(one, two) {
|
|
525
|
+
return function (Base) {
|
|
526
|
+
return two(one(Base));
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function combineFeatures(one, two) {
|
|
530
|
+
function combine(one, two, func) {
|
|
531
|
+
if (one && two) {
|
|
532
|
+
return func(one, two);
|
|
533
|
+
}
|
|
534
|
+
else if (one) {
|
|
535
|
+
return one;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
return two;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
const result = {
|
|
542
|
+
__brand: 'features',
|
|
543
|
+
console: combine(one.console, two.console, combineConsoleFeatures),
|
|
544
|
+
tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
|
|
545
|
+
telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
|
|
546
|
+
client: combine(one.client, two.client, combineClientFeatures),
|
|
547
|
+
window: combine(one.window, two.window, combineWindowFeatures),
|
|
548
|
+
workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures),
|
|
549
|
+
languages: combine(one.languages, two.languages, combineLanguagesFeatures),
|
|
550
|
+
notebooks: combine(one.notebooks, two.notebooks, combineNotebooksFeatures)
|
|
551
|
+
};
|
|
552
|
+
return result;
|
|
553
|
+
}
|
|
554
|
+
function createConnection(connectionFactory, watchDog, factories) {
|
|
555
|
+
const logger = (factories && factories.console ? new (factories.console(RemoteConsoleImpl))() : new RemoteConsoleImpl());
|
|
556
|
+
const connection = connectionFactory(logger);
|
|
557
|
+
logger.rawAttach(connection);
|
|
558
|
+
const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
|
|
559
|
+
const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
|
|
560
|
+
const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
|
|
561
|
+
const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
|
|
562
|
+
const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
|
|
563
|
+
const languages = (factories && factories.languages ? new (factories.languages(LanguagesImpl))() : new LanguagesImpl());
|
|
564
|
+
const notebooks = (factories && factories.notebooks ? new (factories.notebooks(NotebooksImpl))() : new NotebooksImpl());
|
|
565
|
+
const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages, notebooks];
|
|
566
|
+
function asPromise(value) {
|
|
567
|
+
if (value instanceof Promise) {
|
|
568
|
+
return value;
|
|
569
|
+
}
|
|
570
|
+
else if (Is.thenable(value)) {
|
|
571
|
+
return new Promise((resolve, reject) => {
|
|
572
|
+
value.then((resolved) => resolve(resolved), (error) => reject(error));
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return Promise.resolve(value);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
let shutdownHandler = undefined;
|
|
580
|
+
let initializeHandler = undefined;
|
|
581
|
+
let exitHandler = undefined;
|
|
582
|
+
const protocolConnection = {
|
|
583
|
+
listen: () => connection.listen(),
|
|
584
|
+
sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
|
|
585
|
+
onRequest: (type, handler) => connection.onRequest(type, handler),
|
|
586
|
+
sendNotification: (type, param) => {
|
|
587
|
+
const method = Is.string(type) ? type : type.method;
|
|
588
|
+
return connection.sendNotification(method, param);
|
|
589
|
+
},
|
|
590
|
+
onNotification: (type, handler) => connection.onNotification(type, handler),
|
|
591
|
+
onProgress: connection.onProgress,
|
|
592
|
+
sendProgress: connection.sendProgress,
|
|
593
|
+
onInitialize: (handler) => {
|
|
594
|
+
initializeHandler = handler;
|
|
595
|
+
return {
|
|
596
|
+
dispose: () => {
|
|
597
|
+
initializeHandler = undefined;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
},
|
|
601
|
+
onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
|
|
602
|
+
onShutdown: (handler) => {
|
|
603
|
+
shutdownHandler = handler;
|
|
604
|
+
return {
|
|
605
|
+
dispose: () => {
|
|
606
|
+
shutdownHandler = undefined;
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
},
|
|
610
|
+
onExit: (handler) => {
|
|
611
|
+
exitHandler = handler;
|
|
612
|
+
return {
|
|
613
|
+
dispose: () => {
|
|
614
|
+
exitHandler = undefined;
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
},
|
|
618
|
+
get console() { return logger; },
|
|
619
|
+
get telemetry() { return telemetry; },
|
|
620
|
+
get tracer() { return tracer; },
|
|
621
|
+
get client() { return client; },
|
|
622
|
+
get window() { return remoteWindow; },
|
|
623
|
+
get workspace() { return workspace; },
|
|
624
|
+
get languages() { return languages; },
|
|
625
|
+
get notebooks() { return notebooks; },
|
|
626
|
+
onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
|
|
627
|
+
onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
|
|
628
|
+
__textDocumentSync: undefined,
|
|
629
|
+
onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
|
|
630
|
+
onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
|
|
631
|
+
onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
|
|
632
|
+
onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
|
|
633
|
+
onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
|
|
634
|
+
onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
|
|
635
|
+
sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
|
|
636
|
+
onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
|
|
637
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
638
|
+
}),
|
|
639
|
+
onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
|
|
640
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
641
|
+
}),
|
|
642
|
+
onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
|
|
643
|
+
onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
|
|
644
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
645
|
+
}),
|
|
646
|
+
onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
|
|
647
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
648
|
+
}),
|
|
649
|
+
onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
|
|
650
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
651
|
+
}),
|
|
652
|
+
onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
|
|
653
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
654
|
+
}),
|
|
655
|
+
onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
|
|
656
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
657
|
+
}),
|
|
658
|
+
onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
|
|
659
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
660
|
+
}),
|
|
661
|
+
onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
|
|
662
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
663
|
+
}),
|
|
664
|
+
onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
|
|
665
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
666
|
+
}),
|
|
667
|
+
onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
|
|
668
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
669
|
+
}),
|
|
670
|
+
onWorkspaceSymbolResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolResolveRequest.type, handler),
|
|
671
|
+
onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
|
|
672
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
673
|
+
}),
|
|
674
|
+
onCodeActionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionResolveRequest.type, (params, cancel) => {
|
|
675
|
+
return handler(params, cancel);
|
|
676
|
+
}),
|
|
677
|
+
onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
|
|
678
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
679
|
+
}),
|
|
680
|
+
onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
|
|
681
|
+
return handler(params, cancel);
|
|
682
|
+
}),
|
|
683
|
+
onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
|
|
684
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
685
|
+
}),
|
|
686
|
+
onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
|
|
687
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
688
|
+
}),
|
|
689
|
+
onDocumentRangesFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangesFormattingRequest.type, (params, cancel) => {
|
|
690
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
691
|
+
}),
|
|
692
|
+
onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, (params, cancel) => {
|
|
693
|
+
return handler(params, cancel);
|
|
694
|
+
}),
|
|
695
|
+
onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
|
|
696
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
697
|
+
}),
|
|
698
|
+
onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
|
|
699
|
+
return handler(params, cancel);
|
|
700
|
+
}),
|
|
701
|
+
onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
|
|
702
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
703
|
+
}),
|
|
704
|
+
onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
|
|
705
|
+
return handler(params, cancel);
|
|
706
|
+
}),
|
|
707
|
+
onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
|
|
708
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
709
|
+
}),
|
|
710
|
+
onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
|
|
711
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
712
|
+
}),
|
|
713
|
+
onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
|
|
714
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
715
|
+
}),
|
|
716
|
+
onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
|
|
717
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
|
|
718
|
+
}),
|
|
719
|
+
onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
|
|
720
|
+
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
721
|
+
}),
|
|
722
|
+
dispose: () => connection.dispose()
|
|
723
|
+
};
|
|
724
|
+
for (const remote of allRemotes) {
|
|
725
|
+
remote.attach(protocolConnection);
|
|
726
|
+
}
|
|
727
|
+
connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
|
|
728
|
+
watchDog.initialize(params);
|
|
729
|
+
if (Is.string(params.trace)) {
|
|
730
|
+
tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
|
|
731
|
+
}
|
|
732
|
+
for (const remote of allRemotes) {
|
|
733
|
+
remote.initialize(params.capabilities);
|
|
734
|
+
}
|
|
735
|
+
if (initializeHandler) {
|
|
736
|
+
const result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, (0, progress_1.attachWorkDone)(connection, params), undefined);
|
|
737
|
+
return asPromise(result).then((value) => {
|
|
738
|
+
if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
|
|
739
|
+
return value;
|
|
740
|
+
}
|
|
741
|
+
let result = value;
|
|
742
|
+
if (!result) {
|
|
743
|
+
result = { capabilities: {} };
|
|
744
|
+
}
|
|
745
|
+
let capabilities = result.capabilities;
|
|
746
|
+
if (!capabilities) {
|
|
747
|
+
capabilities = {};
|
|
748
|
+
result.capabilities = capabilities;
|
|
749
|
+
}
|
|
750
|
+
if (capabilities.textDocumentSync === undefined || capabilities.textDocumentSync === null) {
|
|
751
|
+
capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
|
|
752
|
+
}
|
|
753
|
+
else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
|
|
754
|
+
capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
|
|
755
|
+
}
|
|
756
|
+
for (const remote of allRemotes) {
|
|
757
|
+
remote.fillServerCapabilities(capabilities);
|
|
758
|
+
}
|
|
759
|
+
return result;
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
const result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
|
|
764
|
+
for (const remote of allRemotes) {
|
|
765
|
+
remote.fillServerCapabilities(result.capabilities);
|
|
766
|
+
}
|
|
767
|
+
return result;
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
|
|
771
|
+
watchDog.shutdownReceived = true;
|
|
772
|
+
if (shutdownHandler) {
|
|
773
|
+
return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
return undefined;
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
|
|
780
|
+
try {
|
|
781
|
+
if (exitHandler) {
|
|
782
|
+
return exitHandler();
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
finally {
|
|
786
|
+
if (watchDog.shutdownReceived) {
|
|
787
|
+
watchDog.exit(0);
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
watchDog.exit(1);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
|
|
795
|
+
tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
|
|
796
|
+
});
|
|
797
|
+
return protocolConnection;
|
|
798
|
+
}
|