Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-html / lib / index.js
1 (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
2 /******/        // The module cache
3 /******/        var installedModules = {};
4 /******/
5 /******/        // The require function
6 /******/        function __webpack_require__(moduleId) {
7 /******/
8 /******/                // Check if module is in cache
9 /******/                if(installedModules[moduleId]) {
10 /******/                        return installedModules[moduleId].exports;
11 /******/                }
12 /******/                // Create a new module (and put it into the cache)
13 /******/                var module = installedModules[moduleId] = {
14 /******/                        i: moduleId,
15 /******/                        l: false,
16 /******/                        exports: {}
17 /******/                };
18 /******/
19 /******/                // Execute the module function
20 /******/                modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 /******/
22 /******/                // Flag the module as loaded
23 /******/                module.l = true;
24 /******/
25 /******/                // Return the exports of the module
26 /******/                return module.exports;
27 /******/        }
28 /******/
29 /******/
30 /******/        // expose the modules object (__webpack_modules__)
31 /******/        __webpack_require__.m = modules;
32 /******/
33 /******/        // expose the module cache
34 /******/        __webpack_require__.c = installedModules;
35 /******/
36 /******/        // define getter function for harmony exports
37 /******/        __webpack_require__.d = function(exports, name, getter) {
38 /******/                if(!__webpack_require__.o(exports, name)) {
39 /******/                        Object.defineProperty(exports, name, { enumerable: true, get: getter });
40 /******/                }
41 /******/        };
42 /******/
43 /******/        // define __esModule on exports
44 /******/        __webpack_require__.r = function(exports) {
45 /******/                if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/                        Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47 /******/                }
48 /******/                Object.defineProperty(exports, '__esModule', { value: true });
49 /******/        };
50 /******/
51 /******/        // create a fake namespace object
52 /******/        // mode & 1: value is a module id, require it
53 /******/        // mode & 2: merge all properties of value into the ns
54 /******/        // mode & 4: return value when already ns object
55 /******/        // mode & 8|1: behave like require
56 /******/        __webpack_require__.t = function(value, mode) {
57 /******/                if(mode & 1) value = __webpack_require__(value);
58 /******/                if(mode & 8) return value;
59 /******/                if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/                var ns = Object.create(null);
61 /******/                __webpack_require__.r(ns);
62 /******/                Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/                if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64 /******/                return ns;
65 /******/        };
66 /******/
67 /******/        // getDefaultExport function for compatibility with non-harmony modules
68 /******/        __webpack_require__.n = function(module) {
69 /******/                var getter = module && module.__esModule ?
70 /******/                        function getDefault() { return module['default']; } :
71 /******/                        function getModuleExports() { return module; };
72 /******/                __webpack_require__.d(getter, 'a', getter);
73 /******/                return getter;
74 /******/        };
75 /******/
76 /******/        // Object.prototype.hasOwnProperty.call
77 /******/        __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78 /******/
79 /******/        // __webpack_public_path__
80 /******/        __webpack_require__.p = "";
81 /******/
82 /******/
83 /******/        // Load entry module and return exports
84 /******/        return __webpack_require__(__webpack_require__.s = 0);
85 /******/ })
86 /************************************************************************/
87 /******/ ([
88 /* 0 */
89 /***/ (function(module, exports, __webpack_require__) {
90
91 "use strict";
92
93 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
94     return new (P || (P = Promise))(function (resolve, reject) {
95         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
96         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
97         function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
98         step((generator = generator.apply(thisArg, _arguments || [])).next());
99     });
100 };
101 Object.defineProperty(exports, "__esModule", { value: true });
102 const coc_nvim_1 = __webpack_require__(1);
103 const customData_1 = __webpack_require__(2);
104 const vscode_languageserver_protocol_1 = __webpack_require__(4);
105 const tagClosing_1 = __webpack_require__(31);
106 var TagCloseRequest;
107 (function (TagCloseRequest) {
108     TagCloseRequest.type = new vscode_languageserver_protocol_1.RequestType('html/tag');
109 })(TagCloseRequest || (TagCloseRequest = {}));
110 function activate(context) {
111     return __awaiter(this, void 0, void 0, function* () {
112         let { subscriptions } = context;
113         const config = coc_nvim_1.workspace.getConfiguration().get('html', {});
114         const enable = config.enable;
115         if (enable === false)
116             return;
117         const file = context.asAbsolutePath('lib/server.js');
118         const selector = config.filetypes || ['html', 'handlebars', 'htmldjango'];
119         const embeddedLanguages = { css: true, javascript: true };
120         let serverOptions = {
121             module: file,
122             args: ['--node-ipc'],
123             transport: coc_nvim_1.TransportKind.ipc,
124             options: {
125                 cwd: coc_nvim_1.workspace.root,
126                 execArgv: config.execArgv || []
127             }
128         };
129         let dataPaths = [
130             ...customData_1.getCustomDataPathsInAllWorkspaces(),
131             ...customData_1.getCustomDataPathsFromAllExtensions()
132         ];
133         let clientOptions = {
134             documentSelector: selector,
135             synchronize: {
136                 configurationSection: ['html', 'css', 'javascript']
137             },
138             outputChannelName: 'html',
139             initializationOptions: {
140                 embeddedLanguages,
141                 dataPaths
142             }
143         };
144         let client = new coc_nvim_1.LanguageClient('html', 'HTML language server', serverOptions, clientOptions);
145         client.onReady().then(() => {
146             selector.forEach(selector => {
147                 context.subscriptions.push(coc_nvim_1.languages.registerSelectionRangeProvider(selector, {
148                     provideSelectionRanges(document, positions) {
149                         return __awaiter(this, void 0, void 0, function* () {
150                             const textDocument = { uri: document.uri };
151                             return yield Promise.resolve(client.sendRequest('$/textDocument/selectionRanges', { textDocument, positions }));
152                         });
153                     }
154                 }));
155             });
156             const tagRequestor = (document, position) => {
157                 const param = {
158                     textDocument: {
159                         uri: document.uri,
160                     },
161                     position,
162                 };
163                 return client.sendRequest(TagCloseRequest.type, param);
164             };
165             context.subscriptions.push(tagClosing_1.activateTagClosing(tagRequestor, selector, 'html.autoClosingTags'));
166         }, _e => {
167             // noop
168         });
169         subscriptions.push(coc_nvim_1.services.registLanguageClient(client));
170     });
171 }
172 exports.activate = activate;
173
174
175 /***/ }),
176 /* 1 */
177 /***/ (function(module, exports) {
178
179 module.exports = require("coc.nvim");
180
181 /***/ }),
182 /* 2 */
183 /***/ (function(module, exports, __webpack_require__) {
184
185 "use strict";
186
187 /*---------------------------------------------------------------------------------------------
188  *  Copyright (c) Microsoft Corporation. All rights reserved.
189  *  Licensed under the MIT License. See License.txt in the project root for license information.
190  *--------------------------------------------------------------------------------------------*/
191 var __importStar = (this && this.__importStar) || function (mod) {
192     if (mod && mod.__esModule) return mod;
193     var result = {};
194     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
195     result["default"] = mod;
196     return result;
197 };
198 Object.defineProperty(exports, "__esModule", { value: true });
199 const path = __importStar(__webpack_require__(3));
200 const coc_nvim_1 = __webpack_require__(1);
201 function getCustomDataPathsInAllWorkspaces() {
202     const dataPaths = [];
203     const workspaceFolders = coc_nvim_1.workspace.workspaceFolders;
204     if (!workspaceFolders) {
205         return dataPaths;
206     }
207     workspaceFolders.forEach(wf => {
208         const allHtmlConfig = coc_nvim_1.workspace.getConfiguration(undefined, wf.uri);
209         const wfHtmlConfig = allHtmlConfig.inspect('html');
210         if (wfHtmlConfig &&
211             wfHtmlConfig.workspaceFolderValue &&
212             wfHtmlConfig.workspaceFolderValue.experimental &&
213             wfHtmlConfig.workspaceFolderValue.experimental.customData) {
214             const customData = wfHtmlConfig.workspaceFolderValue.experimental.customData;
215             if (Array.isArray(customData)) {
216                 customData.forEach(t => {
217                     if (typeof t === 'string') {
218                         dataPaths.push(path.resolve(coc_nvim_1.Uri.parse(wf.uri).fsPath, t));
219                     }
220                 });
221             }
222         }
223     });
224     return dataPaths;
225 }
226 exports.getCustomDataPathsInAllWorkspaces = getCustomDataPathsInAllWorkspaces;
227 function getCustomDataPathsFromAllExtensions() {
228     const dataPaths = [];
229     for (const extension of coc_nvim_1.extensions.all) {
230         const contributes = extension.packageJSON && extension.packageJSON.contributes;
231         if (contributes &&
232             contributes.html &&
233             contributes.html.experimental.customData &&
234             Array.isArray(contributes.html.experimental.customData)) {
235             const relativePaths = contributes.html.experimental.customData;
236             relativePaths.forEach(rp => {
237                 dataPaths.push(path.resolve(extension.extensionPath, rp));
238             });
239         }
240     }
241     return dataPaths;
242 }
243 exports.getCustomDataPathsFromAllExtensions = getCustomDataPathsFromAllExtensions;
244
245
246 /***/ }),
247 /* 3 */
248 /***/ (function(module, exports) {
249
250 module.exports = require("path");
251
252 /***/ }),
253 /* 4 */
254 /***/ (function(module, exports, __webpack_require__) {
255
256 "use strict";
257 /* --------------------------------------------------------------------------------------------
258  * Copyright (c) Microsoft Corporation. All rights reserved.
259  * Licensed under the MIT License. See License.txt in the project root for license information.
260  * ------------------------------------------------------------------------------------------ */
261
262 function __export(m) {
263     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
264 }
265 Object.defineProperty(exports, "__esModule", { value: true });
266 const vscode_jsonrpc_1 = __webpack_require__(5);
267 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
268 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
269 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
270 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
271 exports.Disposable = vscode_jsonrpc_1.Disposable;
272 exports.Event = vscode_jsonrpc_1.Event;
273 exports.Emitter = vscode_jsonrpc_1.Emitter;
274 exports.Trace = vscode_jsonrpc_1.Trace;
275 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
276 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
277 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
278 exports.RequestType = vscode_jsonrpc_1.RequestType;
279 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
280 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
281 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
282 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
283 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
284 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
285 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
286 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
287 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
288 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
289 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
290 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
291 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
292 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
293 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
294 __export(__webpack_require__(18));
295 __export(__webpack_require__(19));
296 const callHierarchy = __webpack_require__(29);
297 const progress = __webpack_require__(30);
298 var Proposed;
299 (function (Proposed) {
300     let CallHierarchyRequest;
301     (function (CallHierarchyRequest) {
302         CallHierarchyRequest.type = callHierarchy.CallHierarchyRequest.type;
303     })(CallHierarchyRequest = Proposed.CallHierarchyRequest || (Proposed.CallHierarchyRequest = {}));
304     let CallHierarchyDirection;
305     (function (CallHierarchyDirection) {
306         CallHierarchyDirection.CallsFrom = callHierarchy.CallHierarchyDirection.CallsFrom;
307         CallHierarchyDirection.CallsTo = callHierarchy.CallHierarchyDirection.CallsTo;
308     })(CallHierarchyDirection = Proposed.CallHierarchyDirection || (Proposed.CallHierarchyDirection = {}));
309     let ProgressStartNotification;
310     (function (ProgressStartNotification) {
311         ProgressStartNotification.type = progress.ProgressStartNotification.type;
312     })(ProgressStartNotification = Proposed.ProgressStartNotification || (Proposed.ProgressStartNotification = {}));
313     let ProgressReportNotification;
314     (function (ProgressReportNotification) {
315         ProgressReportNotification.type = progress.ProgressReportNotification.type;
316     })(ProgressReportNotification = Proposed.ProgressReportNotification || (Proposed.ProgressReportNotification = {}));
317     let ProgressDoneNotification;
318     (function (ProgressDoneNotification) {
319         ProgressDoneNotification.type = progress.ProgressDoneNotification.type;
320     })(ProgressDoneNotification = Proposed.ProgressDoneNotification || (Proposed.ProgressDoneNotification = {}));
321     let ProgressCancelNotification;
322     (function (ProgressCancelNotification) {
323         ProgressCancelNotification.type = progress.ProgressCancelNotification.type;
324     })(ProgressCancelNotification = Proposed.ProgressCancelNotification || (Proposed.ProgressCancelNotification = {}));
325 })(Proposed = exports.Proposed || (exports.Proposed = {}));
326 function createProtocolConnection(reader, writer, logger, strategy) {
327     return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
328 }
329 exports.createProtocolConnection = createProtocolConnection;
330
331
332 /***/ }),
333 /* 5 */
334 /***/ (function(module, exports, __webpack_require__) {
335
336 "use strict";
337 /* --------------------------------------------------------------------------------------------\r
338  * Copyright (c) Microsoft Corporation. All rights reserved.\r
339  * Licensed under the MIT License. See License.txt in the project root for license information.\r
340  * ------------------------------------------------------------------------------------------ */\r
341 /// <reference path="./thenable.ts" />\r
342 \r
343 function __export(m) {\r
344     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
345 }\r
346 Object.defineProperty(exports, "__esModule", { value: true });\r
347 const Is = __webpack_require__(6);\r
348 const messages_1 = __webpack_require__(7);\r
349 exports.RequestType = messages_1.RequestType;\r
350 exports.RequestType0 = messages_1.RequestType0;\r
351 exports.RequestType1 = messages_1.RequestType1;\r
352 exports.RequestType2 = messages_1.RequestType2;\r
353 exports.RequestType3 = messages_1.RequestType3;\r
354 exports.RequestType4 = messages_1.RequestType4;\r
355 exports.RequestType5 = messages_1.RequestType5;\r
356 exports.RequestType6 = messages_1.RequestType6;\r
357 exports.RequestType7 = messages_1.RequestType7;\r
358 exports.RequestType8 = messages_1.RequestType8;\r
359 exports.RequestType9 = messages_1.RequestType9;\r
360 exports.ResponseError = messages_1.ResponseError;\r
361 exports.ErrorCodes = messages_1.ErrorCodes;\r
362 exports.NotificationType = messages_1.NotificationType;\r
363 exports.NotificationType0 = messages_1.NotificationType0;\r
364 exports.NotificationType1 = messages_1.NotificationType1;\r
365 exports.NotificationType2 = messages_1.NotificationType2;\r
366 exports.NotificationType3 = messages_1.NotificationType3;\r
367 exports.NotificationType4 = messages_1.NotificationType4;\r
368 exports.NotificationType5 = messages_1.NotificationType5;\r
369 exports.NotificationType6 = messages_1.NotificationType6;\r
370 exports.NotificationType7 = messages_1.NotificationType7;\r
371 exports.NotificationType8 = messages_1.NotificationType8;\r
372 exports.NotificationType9 = messages_1.NotificationType9;\r
373 const messageReader_1 = __webpack_require__(8);\r
374 exports.MessageReader = messageReader_1.MessageReader;\r
375 exports.StreamMessageReader = messageReader_1.StreamMessageReader;\r
376 exports.IPCMessageReader = messageReader_1.IPCMessageReader;\r
377 exports.SocketMessageReader = messageReader_1.SocketMessageReader;\r
378 const messageWriter_1 = __webpack_require__(10);\r
379 exports.MessageWriter = messageWriter_1.MessageWriter;\r
380 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;\r
381 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;\r
382 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;\r
383 const events_1 = __webpack_require__(9);\r
384 exports.Disposable = events_1.Disposable;\r
385 exports.Event = events_1.Event;\r
386 exports.Emitter = events_1.Emitter;\r
387 const cancellation_1 = __webpack_require__(11);\r
388 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;\r
389 exports.CancellationToken = cancellation_1.CancellationToken;\r
390 const linkedMap_1 = __webpack_require__(12);\r
391 __export(__webpack_require__(13));\r
392 __export(__webpack_require__(17));\r
393 var CancelNotification;\r
394 (function (CancelNotification) {\r
395     CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');\r
396 })(CancelNotification || (CancelNotification = {}));\r
397 exports.NullLogger = Object.freeze({\r
398     error: () => { },\r
399     warn: () => { },\r
400     info: () => { },\r
401     log: () => { }\r
402 });\r
403 var Trace;\r
404 (function (Trace) {\r
405     Trace[Trace["Off"] = 0] = "Off";\r
406     Trace[Trace["Messages"] = 1] = "Messages";\r
407     Trace[Trace["Verbose"] = 2] = "Verbose";\r
408 })(Trace = exports.Trace || (exports.Trace = {}));\r
409 (function (Trace) {\r
410     function fromString(value) {\r
411         value = value.toLowerCase();\r
412         switch (value) {\r
413             case 'off':\r
414                 return Trace.Off;\r
415             case 'messages':\r
416                 return Trace.Messages;\r
417             case 'verbose':\r
418                 return Trace.Verbose;\r
419             default:\r
420                 return Trace.Off;\r
421         }\r
422     }\r
423     Trace.fromString = fromString;\r
424     function toString(value) {\r
425         switch (value) {\r
426             case Trace.Off:\r
427                 return 'off';\r
428             case Trace.Messages:\r
429                 return 'messages';\r
430             case Trace.Verbose:\r
431                 return 'verbose';\r
432             default:\r
433                 return 'off';\r
434         }\r
435     }\r
436     Trace.toString = toString;\r
437 })(Trace = exports.Trace || (exports.Trace = {}));\r
438 var TraceFormat;\r
439 (function (TraceFormat) {\r
440     TraceFormat["Text"] = "text";\r
441     TraceFormat["JSON"] = "json";\r
442 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));\r
443 (function (TraceFormat) {\r
444     function fromString(value) {\r
445         value = value.toLowerCase();\r
446         if (value === 'json') {\r
447             return TraceFormat.JSON;\r
448         }\r
449         else {\r
450             return TraceFormat.Text;\r
451         }\r
452     }\r
453     TraceFormat.fromString = fromString;\r
454 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));\r
455 var SetTraceNotification;\r
456 (function (SetTraceNotification) {\r
457     SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');\r
458 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));\r
459 var LogTraceNotification;\r
460 (function (LogTraceNotification) {\r
461     LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');\r
462 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));\r
463 var ConnectionErrors;\r
464 (function (ConnectionErrors) {\r
465     /**\r
466      * The connection is closed.\r
467      */\r
468     ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";\r
469     /**\r
470      * The connection got disposed.\r
471      */\r
472     ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";\r
473     /**\r
474      * The connection is already in listening mode.\r
475      */\r
476     ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";\r
477 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));\r
478 class ConnectionError extends Error {\r
479     constructor(code, message) {\r
480         super(message);\r
481         this.code = code;\r
482         Object.setPrototypeOf(this, ConnectionError.prototype);\r
483     }\r
484 }\r
485 exports.ConnectionError = ConnectionError;\r
486 var ConnectionStrategy;\r
487 (function (ConnectionStrategy) {\r
488     function is(value) {\r
489         let candidate = value;\r
490         return candidate && Is.func(candidate.cancelUndispatched);\r
491     }\r
492     ConnectionStrategy.is = is;\r
493 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));\r
494 var ConnectionState;\r
495 (function (ConnectionState) {\r
496     ConnectionState[ConnectionState["New"] = 1] = "New";\r
497     ConnectionState[ConnectionState["Listening"] = 2] = "Listening";\r
498     ConnectionState[ConnectionState["Closed"] = 3] = "Closed";\r
499     ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";\r
500 })(ConnectionState || (ConnectionState = {}));\r
501 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {\r
502     let sequenceNumber = 0;\r
503     let notificationSquenceNumber = 0;\r
504     let unknownResponseSquenceNumber = 0;\r
505     const version = '2.0';\r
506     let starRequestHandler = undefined;\r
507     let requestHandlers = Object.create(null);\r
508     let starNotificationHandler = undefined;\r
509     let notificationHandlers = Object.create(null);\r
510     let timer;\r
511     let messageQueue = new linkedMap_1.LinkedMap();\r
512     let responsePromises = Object.create(null);\r
513     let requestTokens = Object.create(null);\r
514     let trace = Trace.Off;\r
515     let traceFormat = TraceFormat.Text;\r
516     let tracer;\r
517     let state = ConnectionState.New;\r
518     let errorEmitter = new events_1.Emitter();\r
519     let closeEmitter = new events_1.Emitter();\r
520     let unhandledNotificationEmitter = new events_1.Emitter();\r
521     let disposeEmitter = new events_1.Emitter();\r
522     function createRequestQueueKey(id) {\r
523         return 'req-' + id.toString();\r
524     }\r
525     function createResponseQueueKey(id) {\r
526         if (id === null) {\r
527             return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();\r
528         }\r
529         else {\r
530             return 'res-' + id.toString();\r
531         }\r
532     }\r
533     function createNotificationQueueKey() {\r
534         return 'not-' + (++notificationSquenceNumber).toString();\r
535     }\r
536     function addMessageToQueue(queue, message) {\r
537         if (messages_1.isRequestMessage(message)) {\r
538             queue.set(createRequestQueueKey(message.id), message);\r
539         }\r
540         else if (messages_1.isResponseMessage(message)) {\r
541             queue.set(createResponseQueueKey(message.id), message);\r
542         }\r
543         else {\r
544             queue.set(createNotificationQueueKey(), message);\r
545         }\r
546     }\r
547     function cancelUndispatched(_message) {\r
548         return undefined;\r
549     }\r
550     function isListening() {\r
551         return state === ConnectionState.Listening;\r
552     }\r
553     function isClosed() {\r
554         return state === ConnectionState.Closed;\r
555     }\r
556     function isDisposed() {\r
557         return state === ConnectionState.Disposed;\r
558     }\r
559     function closeHandler() {\r
560         if (state === ConnectionState.New || state === ConnectionState.Listening) {\r
561             state = ConnectionState.Closed;\r
562             closeEmitter.fire(undefined);\r
563         }\r
564         // If the connection is disposed don't sent close events.\r
565     }\r
566     ;\r
567     function readErrorHandler(error) {\r
568         errorEmitter.fire([error, undefined, undefined]);\r
569     }\r
570     function writeErrorHandler(data) {\r
571         errorEmitter.fire(data);\r
572     }\r
573     messageReader.onClose(closeHandler);\r
574     messageReader.onError(readErrorHandler);\r
575     messageWriter.onClose(closeHandler);\r
576     messageWriter.onError(writeErrorHandler);\r
577     function triggerMessageQueue() {\r
578         if (timer || messageQueue.size === 0) {\r
579             return;\r
580         }\r
581         timer = setImmediate(() => {\r
582             timer = undefined;\r
583             processMessageQueue();\r
584         });\r
585     }\r
586     function processMessageQueue() {\r
587         if (messageQueue.size === 0) {\r
588             return;\r
589         }\r
590         let message = messageQueue.shift();\r
591         try {\r
592             if (messages_1.isRequestMessage(message)) {\r
593                 handleRequest(message);\r
594             }\r
595             else if (messages_1.isNotificationMessage(message)) {\r
596                 handleNotification(message);\r
597             }\r
598             else if (messages_1.isResponseMessage(message)) {\r
599                 handleResponse(message);\r
600             }\r
601             else {\r
602                 handleInvalidMessage(message);\r
603             }\r
604         }\r
605         finally {\r
606             triggerMessageQueue();\r
607         }\r
608     }\r
609     let callback = (message) => {\r
610         try {\r
611             // We have received a cancellation message. Check if the message is still in the queue\r
612             // and cancel it if allowed to do so.\r
613             if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {\r
614                 let key = createRequestQueueKey(message.params.id);\r
615                 let toCancel = messageQueue.get(key);\r
616                 if (messages_1.isRequestMessage(toCancel)) {\r
617                     let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);\r
618                     if (response && (response.error !== void 0 || response.result !== void 0)) {\r
619                         messageQueue.delete(key);\r
620                         response.id = toCancel.id;\r
621                         traceSendingResponse(response, message.method, Date.now());\r
622                         messageWriter.write(response);\r
623                         return;\r
624                     }\r
625                 }\r
626             }\r
627             addMessageToQueue(messageQueue, message);\r
628         }\r
629         finally {\r
630             triggerMessageQueue();\r
631         }\r
632     };\r
633     function handleRequest(requestMessage) {\r
634         if (isDisposed()) {\r
635             // we return here silently since we fired an event when the\r
636             // connection got disposed.\r
637             return;\r
638         }\r
639         function reply(resultOrError, method, startTime) {\r
640             let message = {\r
641                 jsonrpc: version,\r
642                 id: requestMessage.id\r
643             };\r
644             if (resultOrError instanceof messages_1.ResponseError) {\r
645                 message.error = resultOrError.toJson();\r
646             }\r
647             else {\r
648                 message.result = resultOrError === void 0 ? null : resultOrError;\r
649             }\r
650             traceSendingResponse(message, method, startTime);\r
651             messageWriter.write(message);\r
652         }\r
653         function replyError(error, method, startTime) {\r
654             let message = {\r
655                 jsonrpc: version,\r
656                 id: requestMessage.id,\r
657                 error: error.toJson()\r
658             };\r
659             traceSendingResponse(message, method, startTime);\r
660             messageWriter.write(message);\r
661         }\r
662         function replySuccess(result, method, startTime) {\r
663             // The JSON RPC defines that a response must either have a result or an error\r
664             // So we can't treat undefined as a valid response result.\r
665             if (result === void 0) {\r
666                 result = null;\r
667             }\r
668             let message = {\r
669                 jsonrpc: version,\r
670                 id: requestMessage.id,\r
671                 result: result\r
672             };\r
673             traceSendingResponse(message, method, startTime);\r
674             messageWriter.write(message);\r
675         }\r
676         traceReceivedRequest(requestMessage);\r
677         let element = requestHandlers[requestMessage.method];\r
678         let type;\r
679         let requestHandler;\r
680         if (element) {\r
681             type = element.type;\r
682             requestHandler = element.handler;\r
683         }\r
684         let startTime = Date.now();\r
685         if (requestHandler || starRequestHandler) {\r
686             let cancellationSource = new cancellation_1.CancellationTokenSource();\r
687             let tokenKey = String(requestMessage.id);\r
688             requestTokens[tokenKey] = cancellationSource;\r
689             try {\r
690                 let handlerResult;\r
691                 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {\r
692                     handlerResult = requestHandler\r
693                         ? requestHandler(cancellationSource.token)\r
694                         : starRequestHandler(requestMessage.method, cancellationSource.token);\r
695                 }\r
696                 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {\r
697                     handlerResult = requestHandler\r
698                         ? requestHandler(...requestMessage.params, cancellationSource.token)\r
699                         : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);\r
700                 }\r
701                 else {\r
702                     handlerResult = requestHandler\r
703                         ? requestHandler(requestMessage.params, cancellationSource.token)\r
704                         : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);\r
705                 }\r
706                 let promise = handlerResult;\r
707                 if (!handlerResult) {\r
708                     delete requestTokens[tokenKey];\r
709                     replySuccess(handlerResult, requestMessage.method, startTime);\r
710                 }\r
711                 else if (promise.then) {\r
712                     promise.then((resultOrError) => {\r
713                         delete requestTokens[tokenKey];\r
714                         reply(resultOrError, requestMessage.method, startTime);\r
715                     }, error => {\r
716                         delete requestTokens[tokenKey];\r
717                         if (error instanceof messages_1.ResponseError) {\r
718                             replyError(error, requestMessage.method, startTime);\r
719                         }\r
720                         else if (error && Is.string(error.message)) {\r
721                             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);\r
722                         }\r
723                         else {\r
724                             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);\r
725                         }\r
726                     });\r
727                 }\r
728                 else {\r
729                     delete requestTokens[tokenKey];\r
730                     reply(handlerResult, requestMessage.method, startTime);\r
731                 }\r
732             }\r
733             catch (error) {\r
734                 delete requestTokens[tokenKey];\r
735                 if (error instanceof messages_1.ResponseError) {\r
736                     reply(error, requestMessage.method, startTime);\r
737                 }\r
738                 else if (error && Is.string(error.message)) {\r
739                     replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);\r
740                 }\r
741                 else {\r
742                     replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);\r
743                 }\r
744             }\r
745         }\r
746         else {\r
747             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);\r
748         }\r
749     }\r
750     function handleResponse(responseMessage) {\r
751         if (isDisposed()) {\r
752             // See handle request.\r
753             return;\r
754         }\r
755         if (responseMessage.id === null) {\r
756             if (responseMessage.error) {\r
757                 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);\r
758             }\r
759             else {\r
760                 logger.error(`Received response message without id. No further error information provided.`);\r
761             }\r
762         }\r
763         else {\r
764             let key = String(responseMessage.id);\r
765             let responsePromise = responsePromises[key];\r
766             traceReceivedResponse(responseMessage, responsePromise);\r
767             if (responsePromise) {\r
768                 delete responsePromises[key];\r
769                 try {\r
770                     if (responseMessage.error) {\r
771                         let error = responseMessage.error;\r
772                         responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));\r
773                     }\r
774                     else if (responseMessage.result !== void 0) {\r
775                         responsePromise.resolve(responseMessage.result);\r
776                     }\r
777                     else {\r
778                         throw new Error('Should never happen.');\r
779                     }\r
780                 }\r
781                 catch (error) {\r
782                     if (error.message) {\r
783                         logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);\r
784                     }\r
785                     else {\r
786                         logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);\r
787                     }\r
788                 }\r
789             }\r
790         }\r
791     }\r
792     function handleNotification(message) {\r
793         if (isDisposed()) {\r
794             // See handle request.\r
795             return;\r
796         }\r
797         let type = undefined;\r
798         let notificationHandler;\r
799         if (message.method === CancelNotification.type.method) {\r
800             notificationHandler = (params) => {\r
801                 let id = params.id;\r
802                 let source = requestTokens[String(id)];\r
803                 if (source) {\r
804                     source.cancel();\r
805                 }\r
806             };\r
807         }\r
808         else {\r
809             let element = notificationHandlers[message.method];\r
810             if (element) {\r
811                 notificationHandler = element.handler;\r
812                 type = element.type;\r
813             }\r
814         }\r
815         if (notificationHandler || starNotificationHandler) {\r
816             try {\r
817                 traceReceivedNotification(message);\r
818                 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {\r
819                     notificationHandler ? notificationHandler() : starNotificationHandler(message.method);\r
820                 }\r
821                 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {\r
822                     notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);\r
823                 }\r
824                 else {\r
825                     notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);\r
826                 }\r
827             }\r
828             catch (error) {\r
829                 if (error.message) {\r
830                     logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);\r
831                 }\r
832                 else {\r
833                     logger.error(`Notification handler '${message.method}' failed unexpectedly.`);\r
834                 }\r
835             }\r
836         }\r
837         else {\r
838             unhandledNotificationEmitter.fire(message);\r
839         }\r
840     }\r
841     function handleInvalidMessage(message) {\r
842         if (!message) {\r
843             logger.error('Received empty message.');\r
844             return;\r
845         }\r
846         logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);\r
847         // Test whether we find an id to reject the promise\r
848         let responseMessage = message;\r
849         if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {\r
850             let key = String(responseMessage.id);\r
851             let responseHandler = responsePromises[key];\r
852             if (responseHandler) {\r
853                 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));\r
854             }\r
855         }\r
856     }\r
857     function traceSendingRequest(message) {\r
858         if (trace === Trace.Off || !tracer) {\r
859             return;\r
860         }\r
861         if (traceFormat === TraceFormat.Text) {\r
862             let data = undefined;\r
863             if (trace === Trace.Verbose && message.params) {\r
864                 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
865             }\r
866             tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);\r
867         }\r
868         else {\r
869             logLSPMessage('send-request', message);\r
870         }\r
871     }\r
872     function traceSendingNotification(message) {\r
873         if (trace === Trace.Off || !tracer) {\r
874             return;\r
875         }\r
876         if (traceFormat === TraceFormat.Text) {\r
877             let data = undefined;\r
878             if (trace === Trace.Verbose) {\r
879                 if (message.params) {\r
880                     data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
881                 }\r
882                 else {\r
883                     data = 'No parameters provided.\n\n';\r
884                 }\r
885             }\r
886             tracer.log(`Sending notification '${message.method}'.`, data);\r
887         }\r
888         else {\r
889             logLSPMessage('send-notification', message);\r
890         }\r
891     }\r
892     function traceSendingResponse(message, method, startTime) {\r
893         if (trace === Trace.Off || !tracer) {\r
894             return;\r
895         }\r
896         if (traceFormat === TraceFormat.Text) {\r
897             let data = undefined;\r
898             if (trace === Trace.Verbose) {\r
899                 if (message.error && message.error.data) {\r
900                     data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;\r
901                 }\r
902                 else {\r
903                     if (message.result) {\r
904                         data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;\r
905                     }\r
906                     else if (message.error === void 0) {\r
907                         data = 'No result returned.\n\n';\r
908                     }\r
909                 }\r
910             }\r
911             tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);\r
912         }\r
913         else {\r
914             logLSPMessage('send-response', message);\r
915         }\r
916     }\r
917     function traceReceivedRequest(message) {\r
918         if (trace === Trace.Off || !tracer) {\r
919             return;\r
920         }\r
921         if (traceFormat === TraceFormat.Text) {\r
922             let data = undefined;\r
923             if (trace === Trace.Verbose && message.params) {\r
924                 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
925             }\r
926             tracer.log(`Received request '${message.method} - (${message.id})'.`, data);\r
927         }\r
928         else {\r
929             logLSPMessage('receive-request', message);\r
930         }\r
931     }\r
932     function traceReceivedNotification(message) {\r
933         if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {\r
934             return;\r
935         }\r
936         if (traceFormat === TraceFormat.Text) {\r
937             let data = undefined;\r
938             if (trace === Trace.Verbose) {\r
939                 if (message.params) {\r
940                     data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
941                 }\r
942                 else {\r
943                     data = 'No parameters provided.\n\n';\r
944                 }\r
945             }\r
946             tracer.log(`Received notification '${message.method}'.`, data);\r
947         }\r
948         else {\r
949             logLSPMessage('receive-notification', message);\r
950         }\r
951     }\r
952     function traceReceivedResponse(message, responsePromise) {\r
953         if (trace === Trace.Off || !tracer) {\r
954             return;\r
955         }\r
956         if (traceFormat === TraceFormat.Text) {\r
957             let data = undefined;\r
958             if (trace === Trace.Verbose) {\r
959                 if (message.error && message.error.data) {\r
960                     data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;\r
961                 }\r
962                 else {\r
963                     if (message.result) {\r
964                         data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;\r
965                     }\r
966                     else if (message.error === void 0) {\r
967                         data = 'No result returned.\n\n';\r
968                     }\r
969                 }\r
970             }\r
971             if (responsePromise) {\r
972                 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';\r
973                 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);\r
974             }\r
975             else {\r
976                 tracer.log(`Received response ${message.id} without active response promise.`, data);\r
977             }\r
978         }\r
979         else {\r
980             logLSPMessage('receive-response', message);\r
981         }\r
982     }\r
983     function logLSPMessage(type, message) {\r
984         if (!tracer || trace === Trace.Off) {\r
985             return;\r
986         }\r
987         const lspMessage = {\r
988             isLSPMessage: true,\r
989             type,\r
990             message,\r
991             timestamp: Date.now()\r
992         };\r
993         tracer.log(lspMessage);\r
994     }\r
995     function throwIfClosedOrDisposed() {\r
996         if (isClosed()) {\r
997             throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');\r
998         }\r
999         if (isDisposed()) {\r
1000             throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');\r
1001         }\r
1002     }\r
1003     function throwIfListening() {\r
1004         if (isListening()) {\r
1005             throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');\r
1006         }\r
1007     }\r
1008     function throwIfNotListening() {\r
1009         if (!isListening()) {\r
1010             throw new Error('Call listen() first.');\r
1011         }\r
1012     }\r
1013     function undefinedToNull(param) {\r
1014         if (param === void 0) {\r
1015             return null;\r
1016         }\r
1017         else {\r
1018             return param;\r
1019         }\r
1020     }\r
1021     function computeMessageParams(type, params) {\r
1022         let result;\r
1023         let numberOfParams = type.numberOfParams;\r
1024         switch (numberOfParams) {\r
1025             case 0:\r
1026                 result = null;\r
1027                 break;\r
1028             case 1:\r
1029                 result = undefinedToNull(params[0]);\r
1030                 break;\r
1031             default:\r
1032                 result = [];\r
1033                 for (let i = 0; i < params.length && i < numberOfParams; i++) {\r
1034                     result.push(undefinedToNull(params[i]));\r
1035                 }\r
1036                 if (params.length < numberOfParams) {\r
1037                     for (let i = params.length; i < numberOfParams; i++) {\r
1038                         result.push(null);\r
1039                     }\r
1040                 }\r
1041                 break;\r
1042         }\r
1043         return result;\r
1044     }\r
1045     let connection = {\r
1046         sendNotification: (type, ...params) => {\r
1047             throwIfClosedOrDisposed();\r
1048             let method;\r
1049             let messageParams;\r
1050             if (Is.string(type)) {\r
1051                 method = type;\r
1052                 switch (params.length) {\r
1053                     case 0:\r
1054                         messageParams = null;\r
1055                         break;\r
1056                     case 1:\r
1057                         messageParams = params[0];\r
1058                         break;\r
1059                     default:\r
1060                         messageParams = params;\r
1061                         break;\r
1062                 }\r
1063             }\r
1064             else {\r
1065                 method = type.method;\r
1066                 messageParams = computeMessageParams(type, params);\r
1067             }\r
1068             let notificationMessage = {\r
1069                 jsonrpc: version,\r
1070                 method: method,\r
1071                 params: messageParams\r
1072             };\r
1073             traceSendingNotification(notificationMessage);\r
1074             messageWriter.write(notificationMessage);\r
1075         },\r
1076         onNotification: (type, handler) => {\r
1077             throwIfClosedOrDisposed();\r
1078             if (Is.func(type)) {\r
1079                 starNotificationHandler = type;\r
1080             }\r
1081             else if (handler) {\r
1082                 if (Is.string(type)) {\r
1083                     notificationHandlers[type] = { type: undefined, handler };\r
1084                 }\r
1085                 else {\r
1086                     notificationHandlers[type.method] = { type, handler };\r
1087                 }\r
1088             }\r
1089         },\r
1090         sendRequest: (type, ...params) => {\r
1091             throwIfClosedOrDisposed();\r
1092             throwIfNotListening();\r
1093             let method;\r
1094             let messageParams;\r
1095             let token = undefined;\r
1096             if (Is.string(type)) {\r
1097                 method = type;\r
1098                 switch (params.length) {\r
1099                     case 0:\r
1100                         messageParams = null;\r
1101                         break;\r
1102                     case 1:\r
1103                         // The cancellation token is optional so it can also be undefined.\r
1104                         if (cancellation_1.CancellationToken.is(params[0])) {\r
1105                             messageParams = null;\r
1106                             token = params[0];\r
1107                         }\r
1108                         else {\r
1109                             messageParams = undefinedToNull(params[0]);\r
1110                         }\r
1111                         break;\r
1112                     default:\r
1113                         const last = params.length - 1;\r
1114                         if (cancellation_1.CancellationToken.is(params[last])) {\r
1115                             token = params[last];\r
1116                             if (params.length === 2) {\r
1117                                 messageParams = undefinedToNull(params[0]);\r
1118                             }\r
1119                             else {\r
1120                                 messageParams = params.slice(0, last).map(value => undefinedToNull(value));\r
1121                             }\r
1122                         }\r
1123                         else {\r
1124                             messageParams = params.map(value => undefinedToNull(value));\r
1125                         }\r
1126                         break;\r
1127                 }\r
1128             }\r
1129             else {\r
1130                 method = type.method;\r
1131                 messageParams = computeMessageParams(type, params);\r
1132                 let numberOfParams = type.numberOfParams;\r
1133                 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;\r
1134             }\r
1135             let id = sequenceNumber++;\r
1136             let result = new Promise((resolve, reject) => {\r
1137                 let requestMessage = {\r
1138                     jsonrpc: version,\r
1139                     id: id,\r
1140                     method: method,\r
1141                     params: messageParams\r
1142                 };\r
1143                 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };\r
1144                 traceSendingRequest(requestMessage);\r
1145                 try {\r
1146                     messageWriter.write(requestMessage);\r
1147                 }\r
1148                 catch (e) {\r
1149                     // Writing the message failed. So we need to reject the promise.\r
1150                     responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));\r
1151                     responsePromise = null;\r
1152                 }\r
1153                 if (responsePromise) {\r
1154                     responsePromises[String(id)] = responsePromise;\r
1155                 }\r
1156             });\r
1157             if (token) {\r
1158                 token.onCancellationRequested(() => {\r
1159                     connection.sendNotification(CancelNotification.type, { id });\r
1160                 });\r
1161             }\r
1162             return result;\r
1163         },\r
1164         onRequest: (type, handler) => {\r
1165             throwIfClosedOrDisposed();\r
1166             if (Is.func(type)) {\r
1167                 starRequestHandler = type;\r
1168             }\r
1169             else if (handler) {\r
1170                 if (Is.string(type)) {\r
1171                     requestHandlers[type] = { type: undefined, handler };\r
1172                 }\r
1173                 else {\r
1174                     requestHandlers[type.method] = { type, handler };\r
1175                 }\r
1176             }\r
1177         },\r
1178         trace: (_value, _tracer, sendNotificationOrTraceOptions) => {\r
1179             let _sendNotification = false;\r
1180             let _traceFormat = TraceFormat.Text;\r
1181             if (sendNotificationOrTraceOptions !== void 0) {\r
1182                 if (Is.boolean(sendNotificationOrTraceOptions)) {\r
1183                     _sendNotification = sendNotificationOrTraceOptions;\r
1184                 }\r
1185                 else {\r
1186                     _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;\r
1187                     _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;\r
1188                 }\r
1189             }\r
1190             trace = _value;\r
1191             traceFormat = _traceFormat;\r
1192             if (trace === Trace.Off) {\r
1193                 tracer = undefined;\r
1194             }\r
1195             else {\r
1196                 tracer = _tracer;\r
1197             }\r
1198             if (_sendNotification && !isClosed() && !isDisposed()) {\r
1199                 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });\r
1200             }\r
1201         },\r
1202         onError: errorEmitter.event,\r
1203         onClose: closeEmitter.event,\r
1204         onUnhandledNotification: unhandledNotificationEmitter.event,\r
1205         onDispose: disposeEmitter.event,\r
1206         dispose: () => {\r
1207             if (isDisposed()) {\r
1208                 return;\r
1209             }\r
1210             state = ConnectionState.Disposed;\r
1211             disposeEmitter.fire(undefined);\r
1212             let error = new Error('Connection got disposed.');\r
1213             Object.keys(responsePromises).forEach((key) => {\r
1214                 responsePromises[key].reject(error);\r
1215             });\r
1216             responsePromises = Object.create(null);\r
1217             requestTokens = Object.create(null);\r
1218             messageQueue = new linkedMap_1.LinkedMap();\r
1219             // Test for backwards compatibility\r
1220             if (Is.func(messageWriter.dispose)) {\r
1221                 messageWriter.dispose();\r
1222             }\r
1223             if (Is.func(messageReader.dispose)) {\r
1224                 messageReader.dispose();\r
1225             }\r
1226         },\r
1227         listen: () => {\r
1228             throwIfClosedOrDisposed();\r
1229             throwIfListening();\r
1230             state = ConnectionState.Listening;\r
1231             messageReader.listen(callback);\r
1232         },\r
1233         inspect: () => {\r
1234             console.log("inspect");\r
1235         }\r
1236     };\r
1237     connection.onNotification(LogTraceNotification.type, (params) => {\r
1238         if (trace === Trace.Off || !tracer) {\r
1239             return;\r
1240         }\r
1241         tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);\r
1242     });\r
1243     return connection;\r
1244 }\r
1245 function isMessageReader(value) {\r
1246     return value.listen !== void 0 && value.read === void 0;\r
1247 }\r
1248 function isMessageWriter(value) {\r
1249     return value.write !== void 0 && value.end === void 0;\r
1250 }\r
1251 function createMessageConnection(input, output, logger, strategy) {\r
1252     if (!logger) {\r
1253         logger = exports.NullLogger;\r
1254     }\r
1255     let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);\r
1256     let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);\r
1257     return _createMessageConnection(reader, writer, logger, strategy);\r
1258 }\r
1259 exports.createMessageConnection = createMessageConnection;\r
1260
1261
1262 /***/ }),
1263 /* 6 */
1264 /***/ (function(module, exports, __webpack_require__) {
1265
1266 "use strict";
1267 /* --------------------------------------------------------------------------------------------\r
1268  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1269  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1270  * ------------------------------------------------------------------------------------------ */\r
1271 \r
1272 Object.defineProperty(exports, "__esModule", { value: true });\r
1273 function boolean(value) {\r
1274     return value === true || value === false;\r
1275 }\r
1276 exports.boolean = boolean;\r
1277 function string(value) {\r
1278     return typeof value === 'string' || value instanceof String;\r
1279 }\r
1280 exports.string = string;\r
1281 function number(value) {\r
1282     return typeof value === 'number' || value instanceof Number;\r
1283 }\r
1284 exports.number = number;\r
1285 function error(value) {\r
1286     return value instanceof Error;\r
1287 }\r
1288 exports.error = error;\r
1289 function func(value) {\r
1290     return typeof value === 'function';\r
1291 }\r
1292 exports.func = func;\r
1293 function array(value) {\r
1294     return Array.isArray(value);\r
1295 }\r
1296 exports.array = array;\r
1297 function stringArray(value) {\r
1298     return array(value) && value.every(elem => string(elem));\r
1299 }\r
1300 exports.stringArray = stringArray;\r
1301
1302
1303 /***/ }),
1304 /* 7 */
1305 /***/ (function(module, exports, __webpack_require__) {
1306
1307 "use strict";
1308 /* --------------------------------------------------------------------------------------------\r
1309  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1310  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1311  * ------------------------------------------------------------------------------------------ */\r
1312 \r
1313 Object.defineProperty(exports, "__esModule", { value: true });\r
1314 const is = __webpack_require__(6);\r
1315 /**\r
1316  * Predefined error codes.\r
1317  */\r
1318 var ErrorCodes;\r
1319 (function (ErrorCodes) {\r
1320     // Defined by JSON RPC\r
1321     ErrorCodes.ParseError = -32700;\r
1322     ErrorCodes.InvalidRequest = -32600;\r
1323     ErrorCodes.MethodNotFound = -32601;\r
1324     ErrorCodes.InvalidParams = -32602;\r
1325     ErrorCodes.InternalError = -32603;\r
1326     ErrorCodes.serverErrorStart = -32099;\r
1327     ErrorCodes.serverErrorEnd = -32000;\r
1328     ErrorCodes.ServerNotInitialized = -32002;\r
1329     ErrorCodes.UnknownErrorCode = -32001;\r
1330     // Defined by the protocol.\r
1331     ErrorCodes.RequestCancelled = -32800;\r
1332     ErrorCodes.ContentModified = -32801;\r
1333     // Defined by VSCode library.\r
1334     ErrorCodes.MessageWriteError = 1;\r
1335     ErrorCodes.MessageReadError = 2;\r
1336 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));\r
1337 /**\r
1338  * An error object return in a response in case a request\r
1339  * has failed.\r
1340  */\r
1341 class ResponseError extends Error {\r
1342     constructor(code, message, data) {\r
1343         super(message);\r
1344         this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;\r
1345         this.data = data;\r
1346         Object.setPrototypeOf(this, ResponseError.prototype);\r
1347     }\r
1348     toJson() {\r
1349         return {\r
1350             code: this.code,\r
1351             message: this.message,\r
1352             data: this.data,\r
1353         };\r
1354     }\r
1355 }\r
1356 exports.ResponseError = ResponseError;\r
1357 /**\r
1358  * An abstract implementation of a MessageType.\r
1359  */\r
1360 class AbstractMessageType {\r
1361     constructor(_method, _numberOfParams) {\r
1362         this._method = _method;\r
1363         this._numberOfParams = _numberOfParams;\r
1364     }\r
1365     get method() {\r
1366         return this._method;\r
1367     }\r
1368     get numberOfParams() {\r
1369         return this._numberOfParams;\r
1370     }\r
1371 }\r
1372 exports.AbstractMessageType = AbstractMessageType;\r
1373 /**\r
1374  * Classes to type request response pairs\r
1375  */\r
1376 class RequestType0 extends AbstractMessageType {\r
1377     constructor(method) {\r
1378         super(method, 0);\r
1379         this._ = undefined;\r
1380     }\r
1381 }\r
1382 exports.RequestType0 = RequestType0;\r
1383 class RequestType extends AbstractMessageType {\r
1384     constructor(method) {\r
1385         super(method, 1);\r
1386         this._ = undefined;\r
1387     }\r
1388 }\r
1389 exports.RequestType = RequestType;\r
1390 class RequestType1 extends AbstractMessageType {\r
1391     constructor(method) {\r
1392         super(method, 1);\r
1393         this._ = undefined;\r
1394     }\r
1395 }\r
1396 exports.RequestType1 = RequestType1;\r
1397 class RequestType2 extends AbstractMessageType {\r
1398     constructor(method) {\r
1399         super(method, 2);\r
1400         this._ = undefined;\r
1401     }\r
1402 }\r
1403 exports.RequestType2 = RequestType2;\r
1404 class RequestType3 extends AbstractMessageType {\r
1405     constructor(method) {\r
1406         super(method, 3);\r
1407         this._ = undefined;\r
1408     }\r
1409 }\r
1410 exports.RequestType3 = RequestType3;\r
1411 class RequestType4 extends AbstractMessageType {\r
1412     constructor(method) {\r
1413         super(method, 4);\r
1414         this._ = undefined;\r
1415     }\r
1416 }\r
1417 exports.RequestType4 = RequestType4;\r
1418 class RequestType5 extends AbstractMessageType {\r
1419     constructor(method) {\r
1420         super(method, 5);\r
1421         this._ = undefined;\r
1422     }\r
1423 }\r
1424 exports.RequestType5 = RequestType5;\r
1425 class RequestType6 extends AbstractMessageType {\r
1426     constructor(method) {\r
1427         super(method, 6);\r
1428         this._ = undefined;\r
1429     }\r
1430 }\r
1431 exports.RequestType6 = RequestType6;\r
1432 class RequestType7 extends AbstractMessageType {\r
1433     constructor(method) {\r
1434         super(method, 7);\r
1435         this._ = undefined;\r
1436     }\r
1437 }\r
1438 exports.RequestType7 = RequestType7;\r
1439 class RequestType8 extends AbstractMessageType {\r
1440     constructor(method) {\r
1441         super(method, 8);\r
1442         this._ = undefined;\r
1443     }\r
1444 }\r
1445 exports.RequestType8 = RequestType8;\r
1446 class RequestType9 extends AbstractMessageType {\r
1447     constructor(method) {\r
1448         super(method, 9);\r
1449         this._ = undefined;\r
1450     }\r
1451 }\r
1452 exports.RequestType9 = RequestType9;\r
1453 class NotificationType extends AbstractMessageType {\r
1454     constructor(method) {\r
1455         super(method, 1);\r
1456         this._ = undefined;\r
1457     }\r
1458 }\r
1459 exports.NotificationType = NotificationType;\r
1460 class NotificationType0 extends AbstractMessageType {\r
1461     constructor(method) {\r
1462         super(method, 0);\r
1463         this._ = undefined;\r
1464     }\r
1465 }\r
1466 exports.NotificationType0 = NotificationType0;\r
1467 class NotificationType1 extends AbstractMessageType {\r
1468     constructor(method) {\r
1469         super(method, 1);\r
1470         this._ = undefined;\r
1471     }\r
1472 }\r
1473 exports.NotificationType1 = NotificationType1;\r
1474 class NotificationType2 extends AbstractMessageType {\r
1475     constructor(method) {\r
1476         super(method, 2);\r
1477         this._ = undefined;\r
1478     }\r
1479 }\r
1480 exports.NotificationType2 = NotificationType2;\r
1481 class NotificationType3 extends AbstractMessageType {\r
1482     constructor(method) {\r
1483         super(method, 3);\r
1484         this._ = undefined;\r
1485     }\r
1486 }\r
1487 exports.NotificationType3 = NotificationType3;\r
1488 class NotificationType4 extends AbstractMessageType {\r
1489     constructor(method) {\r
1490         super(method, 4);\r
1491         this._ = undefined;\r
1492     }\r
1493 }\r
1494 exports.NotificationType4 = NotificationType4;\r
1495 class NotificationType5 extends AbstractMessageType {\r
1496     constructor(method) {\r
1497         super(method, 5);\r
1498         this._ = undefined;\r
1499     }\r
1500 }\r
1501 exports.NotificationType5 = NotificationType5;\r
1502 class NotificationType6 extends AbstractMessageType {\r
1503     constructor(method) {\r
1504         super(method, 6);\r
1505         this._ = undefined;\r
1506     }\r
1507 }\r
1508 exports.NotificationType6 = NotificationType6;\r
1509 class NotificationType7 extends AbstractMessageType {\r
1510     constructor(method) {\r
1511         super(method, 7);\r
1512         this._ = undefined;\r
1513     }\r
1514 }\r
1515 exports.NotificationType7 = NotificationType7;\r
1516 class NotificationType8 extends AbstractMessageType {\r
1517     constructor(method) {\r
1518         super(method, 8);\r
1519         this._ = undefined;\r
1520     }\r
1521 }\r
1522 exports.NotificationType8 = NotificationType8;\r
1523 class NotificationType9 extends AbstractMessageType {\r
1524     constructor(method) {\r
1525         super(method, 9);\r
1526         this._ = undefined;\r
1527     }\r
1528 }\r
1529 exports.NotificationType9 = NotificationType9;\r
1530 /**\r
1531  * Tests if the given message is a request message\r
1532  */\r
1533 function isRequestMessage(message) {\r
1534     let candidate = message;\r
1535     return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));\r
1536 }\r
1537 exports.isRequestMessage = isRequestMessage;\r
1538 /**\r
1539  * Tests if the given message is a notification message\r
1540  */\r
1541 function isNotificationMessage(message) {\r
1542     let candidate = message;\r
1543     return candidate && is.string(candidate.method) && message.id === void 0;\r
1544 }\r
1545 exports.isNotificationMessage = isNotificationMessage;\r
1546 /**\r
1547  * Tests if the given message is a response message\r
1548  */\r
1549 function isResponseMessage(message) {\r
1550     let candidate = message;\r
1551     return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);\r
1552 }\r
1553 exports.isResponseMessage = isResponseMessage;\r
1554
1555
1556 /***/ }),
1557 /* 8 */
1558 /***/ (function(module, exports, __webpack_require__) {
1559
1560 "use strict";
1561 /* --------------------------------------------------------------------------------------------\r
1562  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1563  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1564  * ------------------------------------------------------------------------------------------ */\r
1565 \r
1566 Object.defineProperty(exports, "__esModule", { value: true });\r
1567 const events_1 = __webpack_require__(9);\r
1568 const Is = __webpack_require__(6);\r
1569 let DefaultSize = 8192;\r
1570 let CR = Buffer.from('\r', 'ascii')[0];\r
1571 let LF = Buffer.from('\n', 'ascii')[0];\r
1572 let CRLF = '\r\n';\r
1573 class MessageBuffer {\r
1574     constructor(encoding = 'utf8') {\r
1575         this.encoding = encoding;\r
1576         this.index = 0;\r
1577         this.buffer = Buffer.allocUnsafe(DefaultSize);\r
1578     }\r
1579     append(chunk) {\r
1580         var toAppend = chunk;\r
1581         if (typeof (chunk) === 'string') {\r
1582             var str = chunk;\r
1583             var bufferLen = Buffer.byteLength(str, this.encoding);\r
1584             toAppend = Buffer.allocUnsafe(bufferLen);\r
1585             toAppend.write(str, 0, bufferLen, this.encoding);\r
1586         }\r
1587         if (this.buffer.length - this.index >= toAppend.length) {\r
1588             toAppend.copy(this.buffer, this.index, 0, toAppend.length);\r
1589         }\r
1590         else {\r
1591             var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;\r
1592             if (this.index === 0) {\r
1593                 this.buffer = Buffer.allocUnsafe(newSize);\r
1594                 toAppend.copy(this.buffer, 0, 0, toAppend.length);\r
1595             }\r
1596             else {\r
1597                 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);\r
1598             }\r
1599         }\r
1600         this.index += toAppend.length;\r
1601     }\r
1602     tryReadHeaders() {\r
1603         let result = undefined;\r
1604         let current = 0;\r
1605         while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {\r
1606             current++;\r
1607         }\r
1608         // No header / body separator found (e.g CRLFCRLF)\r
1609         if (current + 3 >= this.index) {\r
1610             return result;\r
1611         }\r
1612         result = Object.create(null);\r
1613         let headers = this.buffer.toString('ascii', 0, current).split(CRLF);\r
1614         headers.forEach((header) => {\r
1615             let index = header.indexOf(':');\r
1616             if (index === -1) {\r
1617                 throw new Error('Message header must separate key and value using :');\r
1618             }\r
1619             let key = header.substr(0, index);\r
1620             let value = header.substr(index + 1).trim();\r
1621             result[key] = value;\r
1622         });\r
1623         let nextStart = current + 4;\r
1624         this.buffer = this.buffer.slice(nextStart);\r
1625         this.index = this.index - nextStart;\r
1626         return result;\r
1627     }\r
1628     tryReadContent(length) {\r
1629         if (this.index < length) {\r
1630             return null;\r
1631         }\r
1632         let result = this.buffer.toString(this.encoding, 0, length);\r
1633         let nextStart = length;\r
1634         this.buffer.copy(this.buffer, 0, nextStart);\r
1635         this.index = this.index - nextStart;\r
1636         return result;\r
1637     }\r
1638     get numberOfBytes() {\r
1639         return this.index;\r
1640     }\r
1641 }\r
1642 var MessageReader;\r
1643 (function (MessageReader) {\r
1644     function is(value) {\r
1645         let candidate = value;\r
1646         return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&\r
1647             Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);\r
1648     }\r
1649     MessageReader.is = is;\r
1650 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));\r
1651 class AbstractMessageReader {\r
1652     constructor() {\r
1653         this.errorEmitter = new events_1.Emitter();\r
1654         this.closeEmitter = new events_1.Emitter();\r
1655         this.partialMessageEmitter = new events_1.Emitter();\r
1656     }\r
1657     dispose() {\r
1658         this.errorEmitter.dispose();\r
1659         this.closeEmitter.dispose();\r
1660     }\r
1661     get onError() {\r
1662         return this.errorEmitter.event;\r
1663     }\r
1664     fireError(error) {\r
1665         this.errorEmitter.fire(this.asError(error));\r
1666     }\r
1667     get onClose() {\r
1668         return this.closeEmitter.event;\r
1669     }\r
1670     fireClose() {\r
1671         this.closeEmitter.fire(undefined);\r
1672     }\r
1673     get onPartialMessage() {\r
1674         return this.partialMessageEmitter.event;\r
1675     }\r
1676     firePartialMessage(info) {\r
1677         this.partialMessageEmitter.fire(info);\r
1678     }\r
1679     asError(error) {\r
1680         if (error instanceof Error) {\r
1681             return error;\r
1682         }\r
1683         else {\r
1684             return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);\r
1685         }\r
1686     }\r
1687 }\r
1688 exports.AbstractMessageReader = AbstractMessageReader;\r
1689 class StreamMessageReader extends AbstractMessageReader {\r
1690     constructor(readable, encoding = 'utf8') {\r
1691         super();\r
1692         this.readable = readable;\r
1693         this.buffer = new MessageBuffer(encoding);\r
1694         this._partialMessageTimeout = 10000;\r
1695     }\r
1696     set partialMessageTimeout(timeout) {\r
1697         this._partialMessageTimeout = timeout;\r
1698     }\r
1699     get partialMessageTimeout() {\r
1700         return this._partialMessageTimeout;\r
1701     }\r
1702     listen(callback) {\r
1703         this.nextMessageLength = -1;\r
1704         this.messageToken = 0;\r
1705         this.partialMessageTimer = undefined;\r
1706         this.callback = callback;\r
1707         this.readable.on('data', (data) => {\r
1708             this.onData(data);\r
1709         });\r
1710         this.readable.on('error', (error) => this.fireError(error));\r
1711         this.readable.on('close', () => this.fireClose());\r
1712     }\r
1713     onData(data) {\r
1714         this.buffer.append(data);\r
1715         while (true) {\r
1716             if (this.nextMessageLength === -1) {\r
1717                 let headers = this.buffer.tryReadHeaders();\r
1718                 if (!headers) {\r
1719                     return;\r
1720                 }\r
1721                 let contentLength = headers['Content-Length'];\r
1722                 if (!contentLength) {\r
1723                     throw new Error('Header must provide a Content-Length property.');\r
1724                 }\r
1725                 let length = parseInt(contentLength);\r
1726                 if (isNaN(length)) {\r
1727                     throw new Error('Content-Length value must be a number.');\r
1728                 }\r
1729                 this.nextMessageLength = length;\r
1730                 // Take the encoding form the header. For compatibility\r
1731                 // treat both utf-8 and utf8 as node utf8\r
1732             }\r
1733             var msg = this.buffer.tryReadContent(this.nextMessageLength);\r
1734             if (msg === null) {\r
1735                 /** We haven't received the full message yet. */\r
1736                 this.setPartialMessageTimer();\r
1737                 return;\r
1738             }\r
1739             this.clearPartialMessageTimer();\r
1740             this.nextMessageLength = -1;\r
1741             this.messageToken++;\r
1742             var json = JSON.parse(msg);\r
1743             this.callback(json);\r
1744         }\r
1745     }\r
1746     clearPartialMessageTimer() {\r
1747         if (this.partialMessageTimer) {\r
1748             clearTimeout(this.partialMessageTimer);\r
1749             this.partialMessageTimer = undefined;\r
1750         }\r
1751     }\r
1752     setPartialMessageTimer() {\r
1753         this.clearPartialMessageTimer();\r
1754         if (this._partialMessageTimeout <= 0) {\r
1755             return;\r
1756         }\r
1757         this.partialMessageTimer = setTimeout((token, timeout) => {\r
1758             this.partialMessageTimer = undefined;\r
1759             if (token === this.messageToken) {\r
1760                 this.firePartialMessage({ messageToken: token, waitingTime: timeout });\r
1761                 this.setPartialMessageTimer();\r
1762             }\r
1763         }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);\r
1764     }\r
1765 }\r
1766 exports.StreamMessageReader = StreamMessageReader;\r
1767 class IPCMessageReader extends AbstractMessageReader {\r
1768     constructor(process) {\r
1769         super();\r
1770         this.process = process;\r
1771         let eventEmitter = this.process;\r
1772         eventEmitter.on('error', (error) => this.fireError(error));\r
1773         eventEmitter.on('close', () => this.fireClose());\r
1774     }\r
1775     listen(callback) {\r
1776         this.process.on('message', callback);\r
1777     }\r
1778 }\r
1779 exports.IPCMessageReader = IPCMessageReader;\r
1780 class SocketMessageReader extends StreamMessageReader {\r
1781     constructor(socket, encoding = 'utf-8') {\r
1782         super(socket, encoding);\r
1783     }\r
1784 }\r
1785 exports.SocketMessageReader = SocketMessageReader;\r
1786
1787
1788 /***/ }),
1789 /* 9 */
1790 /***/ (function(module, exports, __webpack_require__) {
1791
1792 "use strict";
1793 /* --------------------------------------------------------------------------------------------\r
1794  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1795  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1796  * ------------------------------------------------------------------------------------------ */\r
1797 \r
1798 Object.defineProperty(exports, "__esModule", { value: true });\r
1799 var Disposable;\r
1800 (function (Disposable) {\r
1801     function create(func) {\r
1802         return {\r
1803             dispose: func\r
1804         };\r
1805     }\r
1806     Disposable.create = create;\r
1807 })(Disposable = exports.Disposable || (exports.Disposable = {}));\r
1808 var Event;\r
1809 (function (Event) {\r
1810     const _disposable = { dispose() { } };\r
1811     Event.None = function () { return _disposable; };\r
1812 })(Event = exports.Event || (exports.Event = {}));\r
1813 class CallbackList {\r
1814     add(callback, context = null, bucket) {\r
1815         if (!this._callbacks) {\r
1816             this._callbacks = [];\r
1817             this._contexts = [];\r
1818         }\r
1819         this._callbacks.push(callback);\r
1820         this._contexts.push(context);\r
1821         if (Array.isArray(bucket)) {\r
1822             bucket.push({ dispose: () => this.remove(callback, context) });\r
1823         }\r
1824     }\r
1825     remove(callback, context = null) {\r
1826         if (!this._callbacks) {\r
1827             return;\r
1828         }\r
1829         var foundCallbackWithDifferentContext = false;\r
1830         for (var i = 0, len = this._callbacks.length; i < len; i++) {\r
1831             if (this._callbacks[i] === callback) {\r
1832                 if (this._contexts[i] === context) {\r
1833                     // callback & context match => remove it\r
1834                     this._callbacks.splice(i, 1);\r
1835                     this._contexts.splice(i, 1);\r
1836                     return;\r
1837                 }\r
1838                 else {\r
1839                     foundCallbackWithDifferentContext = true;\r
1840                 }\r
1841             }\r
1842         }\r
1843         if (foundCallbackWithDifferentContext) {\r
1844             throw new Error('When adding a listener with a context, you should remove it with the same context');\r
1845         }\r
1846     }\r
1847     invoke(...args) {\r
1848         if (!this._callbacks) {\r
1849             return [];\r
1850         }\r
1851         var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);\r
1852         for (var i = 0, len = callbacks.length; i < len; i++) {\r
1853             try {\r
1854                 ret.push(callbacks[i].apply(contexts[i], args));\r
1855             }\r
1856             catch (e) {\r
1857                 console.error(e);\r
1858             }\r
1859         }\r
1860         return ret;\r
1861     }\r
1862     isEmpty() {\r
1863         return !this._callbacks || this._callbacks.length === 0;\r
1864     }\r
1865     dispose() {\r
1866         this._callbacks = undefined;\r
1867         this._contexts = undefined;\r
1868     }\r
1869 }\r
1870 class Emitter {\r
1871     constructor(_options) {\r
1872         this._options = _options;\r
1873     }\r
1874     /**\r
1875      * For the public to allow to subscribe\r
1876      * to events from this Emitter\r
1877      */\r
1878     get event() {\r
1879         if (!this._event) {\r
1880             this._event = (listener, thisArgs, disposables) => {\r
1881                 if (!this._callbacks) {\r
1882                     this._callbacks = new CallbackList();\r
1883                 }\r
1884                 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {\r
1885                     this._options.onFirstListenerAdd(this);\r
1886                 }\r
1887                 this._callbacks.add(listener, thisArgs);\r
1888                 let result;\r
1889                 result = {\r
1890                     dispose: () => {\r
1891                         this._callbacks.remove(listener, thisArgs);\r
1892                         result.dispose = Emitter._noop;\r
1893                         if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {\r
1894                             this._options.onLastListenerRemove(this);\r
1895                         }\r
1896                     }\r
1897                 };\r
1898                 if (Array.isArray(disposables)) {\r
1899                     disposables.push(result);\r
1900                 }\r
1901                 return result;\r
1902             };\r
1903         }\r
1904         return this._event;\r
1905     }\r
1906     /**\r
1907      * To be kept private to fire an event to\r
1908      * subscribers\r
1909      */\r
1910     fire(event) {\r
1911         if (this._callbacks) {\r
1912             this._callbacks.invoke.call(this._callbacks, event);\r
1913         }\r
1914     }\r
1915     dispose() {\r
1916         if (this._callbacks) {\r
1917             this._callbacks.dispose();\r
1918             this._callbacks = undefined;\r
1919         }\r
1920     }\r
1921 }\r
1922 Emitter._noop = function () { };\r
1923 exports.Emitter = Emitter;\r
1924
1925
1926 /***/ }),
1927 /* 10 */
1928 /***/ (function(module, exports, __webpack_require__) {
1929
1930 "use strict";
1931 /* --------------------------------------------------------------------------------------------\r
1932  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1933  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1934  * ------------------------------------------------------------------------------------------ */\r
1935 \r
1936 Object.defineProperty(exports, "__esModule", { value: true });\r
1937 const events_1 = __webpack_require__(9);\r
1938 const Is = __webpack_require__(6);\r
1939 let ContentLength = 'Content-Length: ';\r
1940 let CRLF = '\r\n';\r
1941 var MessageWriter;\r
1942 (function (MessageWriter) {\r
1943     function is(value) {\r
1944         let candidate = value;\r
1945         return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&\r
1946             Is.func(candidate.onError) && Is.func(candidate.write);\r
1947     }\r
1948     MessageWriter.is = is;\r
1949 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));\r
1950 class AbstractMessageWriter {\r
1951     constructor() {\r
1952         this.errorEmitter = new events_1.Emitter();\r
1953         this.closeEmitter = new events_1.Emitter();\r
1954     }\r
1955     dispose() {\r
1956         this.errorEmitter.dispose();\r
1957         this.closeEmitter.dispose();\r
1958     }\r
1959     get onError() {\r
1960         return this.errorEmitter.event;\r
1961     }\r
1962     fireError(error, message, count) {\r
1963         this.errorEmitter.fire([this.asError(error), message, count]);\r
1964     }\r
1965     get onClose() {\r
1966         return this.closeEmitter.event;\r
1967     }\r
1968     fireClose() {\r
1969         this.closeEmitter.fire(undefined);\r
1970     }\r
1971     asError(error) {\r
1972         if (error instanceof Error) {\r
1973             return error;\r
1974         }\r
1975         else {\r
1976             return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);\r
1977         }\r
1978     }\r
1979 }\r
1980 exports.AbstractMessageWriter = AbstractMessageWriter;\r
1981 class StreamMessageWriter extends AbstractMessageWriter {\r
1982     constructor(writable, encoding = 'utf8') {\r
1983         super();\r
1984         this.writable = writable;\r
1985         this.encoding = encoding;\r
1986         this.errorCount = 0;\r
1987         this.writable.on('error', (error) => this.fireError(error));\r
1988         this.writable.on('close', () => this.fireClose());\r
1989     }\r
1990     write(msg) {\r
1991         let json = JSON.stringify(msg);\r
1992         let contentLength = Buffer.byteLength(json, this.encoding);\r
1993         let headers = [\r
1994             ContentLength, contentLength.toString(), CRLF,\r
1995             CRLF\r
1996         ];\r
1997         try {\r
1998             // Header must be written in ASCII encoding\r
1999             this.writable.write(headers.join(''), 'ascii');\r
2000             // Now write the content. This can be written in any encoding\r
2001             this.writable.write(json, this.encoding);\r
2002             this.errorCount = 0;\r
2003         }\r
2004         catch (error) {\r
2005             this.errorCount++;\r
2006             this.fireError(error, msg, this.errorCount);\r
2007         }\r
2008     }\r
2009 }\r
2010 exports.StreamMessageWriter = StreamMessageWriter;\r
2011 class IPCMessageWriter extends AbstractMessageWriter {\r
2012     constructor(process) {\r
2013         super();\r
2014         this.process = process;\r
2015         this.errorCount = 0;\r
2016         this.queue = [];\r
2017         this.sending = false;\r
2018         let eventEmitter = this.process;\r
2019         eventEmitter.on('error', (error) => this.fireError(error));\r
2020         eventEmitter.on('close', () => this.fireClose);\r
2021     }\r
2022     write(msg) {\r
2023         if (!this.sending && this.queue.length === 0) {\r
2024             // See https://github.com/nodejs/node/issues/7657\r
2025             this.doWriteMessage(msg);\r
2026         }\r
2027         else {\r
2028             this.queue.push(msg);\r
2029         }\r
2030     }\r
2031     doWriteMessage(msg) {\r
2032         try {\r
2033             if (this.process.send) {\r
2034                 this.sending = true;\r
2035                 this.process.send(msg, undefined, undefined, (error) => {\r
2036                     this.sending = false;\r
2037                     if (error) {\r
2038                         this.errorCount++;\r
2039                         this.fireError(error, msg, this.errorCount);\r
2040                     }\r
2041                     else {\r
2042                         this.errorCount = 0;\r
2043                     }\r
2044                     if (this.queue.length > 0) {\r
2045                         this.doWriteMessage(this.queue.shift());\r
2046                     }\r
2047                 });\r
2048             }\r
2049         }\r
2050         catch (error) {\r
2051             this.errorCount++;\r
2052             this.fireError(error, msg, this.errorCount);\r
2053         }\r
2054     }\r
2055 }\r
2056 exports.IPCMessageWriter = IPCMessageWriter;\r
2057 class SocketMessageWriter extends AbstractMessageWriter {\r
2058     constructor(socket, encoding = 'utf8') {\r
2059         super();\r
2060         this.socket = socket;\r
2061         this.queue = [];\r
2062         this.sending = false;\r
2063         this.encoding = encoding;\r
2064         this.errorCount = 0;\r
2065         this.socket.on('error', (error) => this.fireError(error));\r
2066         this.socket.on('close', () => this.fireClose());\r
2067     }\r
2068     dispose() {\r
2069         super.dispose();\r
2070         this.socket.destroy();\r
2071     }\r
2072     write(msg) {\r
2073         if (!this.sending && this.queue.length === 0) {\r
2074             // See https://github.com/nodejs/node/issues/7657\r
2075             this.doWriteMessage(msg);\r
2076         }\r
2077         else {\r
2078             this.queue.push(msg);\r
2079         }\r
2080     }\r
2081     doWriteMessage(msg) {\r
2082         let json = JSON.stringify(msg);\r
2083         let contentLength = Buffer.byteLength(json, this.encoding);\r
2084         let headers = [\r
2085             ContentLength, contentLength.toString(), CRLF,\r
2086             CRLF\r
2087         ];\r
2088         try {\r
2089             // Header must be written in ASCII encoding\r
2090             this.sending = true;\r
2091             this.socket.write(headers.join(''), 'ascii', (error) => {\r
2092                 if (error) {\r
2093                     this.handleError(error, msg);\r
2094                 }\r
2095                 try {\r
2096                     // Now write the content. This can be written in any encoding\r
2097                     this.socket.write(json, this.encoding, (error) => {\r
2098                         this.sending = false;\r
2099                         if (error) {\r
2100                             this.handleError(error, msg);\r
2101                         }\r
2102                         else {\r
2103                             this.errorCount = 0;\r
2104                         }\r
2105                         if (this.queue.length > 0) {\r
2106                             this.doWriteMessage(this.queue.shift());\r
2107                         }\r
2108                     });\r
2109                 }\r
2110                 catch (error) {\r
2111                     this.handleError(error, msg);\r
2112                 }\r
2113             });\r
2114         }\r
2115         catch (error) {\r
2116             this.handleError(error, msg);\r
2117         }\r
2118     }\r
2119     handleError(error, msg) {\r
2120         this.errorCount++;\r
2121         this.fireError(error, msg, this.errorCount);\r
2122     }\r
2123 }\r
2124 exports.SocketMessageWriter = SocketMessageWriter;\r
2125
2126
2127 /***/ }),
2128 /* 11 */
2129 /***/ (function(module, exports, __webpack_require__) {
2130
2131 "use strict";
2132 /*---------------------------------------------------------------------------------------------\r
2133  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
2134  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
2135  *--------------------------------------------------------------------------------------------*/\r
2136 \r
2137 Object.defineProperty(exports, "__esModule", { value: true });\r
2138 const events_1 = __webpack_require__(9);\r
2139 const Is = __webpack_require__(6);\r
2140 var CancellationToken;\r
2141 (function (CancellationToken) {\r
2142     CancellationToken.None = Object.freeze({\r
2143         isCancellationRequested: false,\r
2144         onCancellationRequested: events_1.Event.None\r
2145     });\r
2146     CancellationToken.Cancelled = Object.freeze({\r
2147         isCancellationRequested: true,\r
2148         onCancellationRequested: events_1.Event.None\r
2149     });\r
2150     function is(value) {\r
2151         let candidate = value;\r
2152         return candidate && (candidate === CancellationToken.None\r
2153             || candidate === CancellationToken.Cancelled\r
2154             || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));\r
2155     }\r
2156     CancellationToken.is = is;\r
2157 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));\r
2158 const shortcutEvent = Object.freeze(function (callback, context) {\r
2159     let handle = setTimeout(callback.bind(context), 0);\r
2160     return { dispose() { clearTimeout(handle); } };\r
2161 });\r
2162 class MutableToken {\r
2163     constructor() {\r
2164         this._isCancelled = false;\r
2165     }\r
2166     cancel() {\r
2167         if (!this._isCancelled) {\r
2168             this._isCancelled = true;\r
2169             if (this._emitter) {\r
2170                 this._emitter.fire(undefined);\r
2171                 this.dispose();\r
2172             }\r
2173         }\r
2174     }\r
2175     get isCancellationRequested() {\r
2176         return this._isCancelled;\r
2177     }\r
2178     get onCancellationRequested() {\r
2179         if (this._isCancelled) {\r
2180             return shortcutEvent;\r
2181         }\r
2182         if (!this._emitter) {\r
2183             this._emitter = new events_1.Emitter();\r
2184         }\r
2185         return this._emitter.event;\r
2186     }\r
2187     dispose() {\r
2188         if (this._emitter) {\r
2189             this._emitter.dispose();\r
2190             this._emitter = undefined;\r
2191         }\r
2192     }\r
2193 }\r
2194 class CancellationTokenSource {\r
2195     get token() {\r
2196         if (!this._token) {\r
2197             // be lazy and create the token only when\r
2198             // actually needed\r
2199             this._token = new MutableToken();\r
2200         }\r
2201         return this._token;\r
2202     }\r
2203     cancel() {\r
2204         if (!this._token) {\r
2205             // save an object by returning the default\r
2206             // cancelled token when cancellation happens\r
2207             // before someone asks for the token\r
2208             this._token = CancellationToken.Cancelled;\r
2209         }\r
2210         else {\r
2211             this._token.cancel();\r
2212         }\r
2213     }\r
2214     dispose() {\r
2215         if (!this._token) {\r
2216             // ensure to initialize with an empty token if we had none\r
2217             this._token = CancellationToken.None;\r
2218         }\r
2219         else if (this._token instanceof MutableToken) {\r
2220             // actually dispose\r
2221             this._token.dispose();\r
2222         }\r
2223     }\r
2224 }\r
2225 exports.CancellationTokenSource = CancellationTokenSource;\r
2226
2227
2228 /***/ }),
2229 /* 12 */
2230 /***/ (function(module, exports, __webpack_require__) {
2231
2232 "use strict";
2233 \r
2234 /*---------------------------------------------------------------------------------------------\r
2235  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
2236  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
2237  *--------------------------------------------------------------------------------------------*/\r
2238 Object.defineProperty(exports, "__esModule", { value: true });\r
2239 var Touch;\r
2240 (function (Touch) {\r
2241     Touch.None = 0;\r
2242     Touch.First = 1;\r
2243     Touch.Last = 2;\r
2244 })(Touch = exports.Touch || (exports.Touch = {}));\r
2245 class LinkedMap {\r
2246     constructor() {\r
2247         this._map = new Map();\r
2248         this._head = undefined;\r
2249         this._tail = undefined;\r
2250         this._size = 0;\r
2251     }\r
2252     clear() {\r
2253         this._map.clear();\r
2254         this._head = undefined;\r
2255         this._tail = undefined;\r
2256         this._size = 0;\r
2257     }\r
2258     isEmpty() {\r
2259         return !this._head && !this._tail;\r
2260     }\r
2261     get size() {\r
2262         return this._size;\r
2263     }\r
2264     has(key) {\r
2265         return this._map.has(key);\r
2266     }\r
2267     get(key) {\r
2268         const item = this._map.get(key);\r
2269         if (!item) {\r
2270             return undefined;\r
2271         }\r
2272         return item.value;\r
2273     }\r
2274     set(key, value, touch = Touch.None) {\r
2275         let item = this._map.get(key);\r
2276         if (item) {\r
2277             item.value = value;\r
2278             if (touch !== Touch.None) {\r
2279                 this.touch(item, touch);\r
2280             }\r
2281         }\r
2282         else {\r
2283             item = { key, value, next: undefined, previous: undefined };\r
2284             switch (touch) {\r
2285                 case Touch.None:\r
2286                     this.addItemLast(item);\r
2287                     break;\r
2288                 case Touch.First:\r
2289                     this.addItemFirst(item);\r
2290                     break;\r
2291                 case Touch.Last:\r
2292                     this.addItemLast(item);\r
2293                     break;\r
2294                 default:\r
2295                     this.addItemLast(item);\r
2296                     break;\r
2297             }\r
2298             this._map.set(key, item);\r
2299             this._size++;\r
2300         }\r
2301     }\r
2302     delete(key) {\r
2303         const item = this._map.get(key);\r
2304         if (!item) {\r
2305             return false;\r
2306         }\r
2307         this._map.delete(key);\r
2308         this.removeItem(item);\r
2309         this._size--;\r
2310         return true;\r
2311     }\r
2312     shift() {\r
2313         if (!this._head && !this._tail) {\r
2314             return undefined;\r
2315         }\r
2316         if (!this._head || !this._tail) {\r
2317             throw new Error('Invalid list');\r
2318         }\r
2319         const item = this._head;\r
2320         this._map.delete(item.key);\r
2321         this.removeItem(item);\r
2322         this._size--;\r
2323         return item.value;\r
2324     }\r
2325     forEach(callbackfn, thisArg) {\r
2326         let current = this._head;\r
2327         while (current) {\r
2328             if (thisArg) {\r
2329                 callbackfn.bind(thisArg)(current.value, current.key, this);\r
2330             }\r
2331             else {\r
2332                 callbackfn(current.value, current.key, this);\r
2333             }\r
2334             current = current.next;\r
2335         }\r
2336     }\r
2337     forEachReverse(callbackfn, thisArg) {\r
2338         let current = this._tail;\r
2339         while (current) {\r
2340             if (thisArg) {\r
2341                 callbackfn.bind(thisArg)(current.value, current.key, this);\r
2342             }\r
2343             else {\r
2344                 callbackfn(current.value, current.key, this);\r
2345             }\r
2346             current = current.previous;\r
2347         }\r
2348     }\r
2349     values() {\r
2350         let result = [];\r
2351         let current = this._head;\r
2352         while (current) {\r
2353             result.push(current.value);\r
2354             current = current.next;\r
2355         }\r
2356         return result;\r
2357     }\r
2358     keys() {\r
2359         let result = [];\r
2360         let current = this._head;\r
2361         while (current) {\r
2362             result.push(current.key);\r
2363             current = current.next;\r
2364         }\r
2365         return result;\r
2366     }\r
2367     /* JSON RPC run on es5 which has no Symbol.iterator\r
2368     public keys(): IterableIterator<K> {\r
2369         let current = this._head;\r
2370         let iterator: IterableIterator<K> = {\r
2371             [Symbol.iterator]() {\r
2372                 return iterator;\r
2373             },\r
2374             next():IteratorResult<K> {\r
2375                 if (current) {\r
2376                     let result = { value: current.key, done: false };\r
2377                     current = current.next;\r
2378                     return result;\r
2379                 } else {\r
2380                     return { value: undefined, done: true };\r
2381                 }\r
2382             }\r
2383         };\r
2384         return iterator;\r
2385     }\r
2386 \r
2387     public values(): IterableIterator<V> {\r
2388         let current = this._head;\r
2389         let iterator: IterableIterator<V> = {\r
2390             [Symbol.iterator]() {\r
2391                 return iterator;\r
2392             },\r
2393             next():IteratorResult<V> {\r
2394                 if (current) {\r
2395                     let result = { value: current.value, done: false };\r
2396                     current = current.next;\r
2397                     return result;\r
2398                 } else {\r
2399                     return { value: undefined, done: true };\r
2400                 }\r
2401             }\r
2402         };\r
2403         return iterator;\r
2404     }\r
2405     */\r
2406     addItemFirst(item) {\r
2407         // First time Insert\r
2408         if (!this._head && !this._tail) {\r
2409             this._tail = item;\r
2410         }\r
2411         else if (!this._head) {\r
2412             throw new Error('Invalid list');\r
2413         }\r
2414         else {\r
2415             item.next = this._head;\r
2416             this._head.previous = item;\r
2417         }\r
2418         this._head = item;\r
2419     }\r
2420     addItemLast(item) {\r
2421         // First time Insert\r
2422         if (!this._head && !this._tail) {\r
2423             this._head = item;\r
2424         }\r
2425         else if (!this._tail) {\r
2426             throw new Error('Invalid list');\r
2427         }\r
2428         else {\r
2429             item.previous = this._tail;\r
2430             this._tail.next = item;\r
2431         }\r
2432         this._tail = item;\r
2433     }\r
2434     removeItem(item) {\r
2435         if (item === this._head && item === this._tail) {\r
2436             this._head = undefined;\r
2437             this._tail = undefined;\r
2438         }\r
2439         else if (item === this._head) {\r
2440             this._head = item.next;\r
2441         }\r
2442         else if (item === this._tail) {\r
2443             this._tail = item.previous;\r
2444         }\r
2445         else {\r
2446             const next = item.next;\r
2447             const previous = item.previous;\r
2448             if (!next || !previous) {\r
2449                 throw new Error('Invalid list');\r
2450             }\r
2451             next.previous = previous;\r
2452             previous.next = next;\r
2453         }\r
2454     }\r
2455     touch(item, touch) {\r
2456         if (!this._head || !this._tail) {\r
2457             throw new Error('Invalid list');\r
2458         }\r
2459         if ((touch !== Touch.First && touch !== Touch.Last)) {\r
2460             return;\r
2461         }\r
2462         if (touch === Touch.First) {\r
2463             if (item === this._head) {\r
2464                 return;\r
2465             }\r
2466             const next = item.next;\r
2467             const previous = item.previous;\r
2468             // Unlink the item\r
2469             if (item === this._tail) {\r
2470                 // previous must be defined since item was not head but is tail\r
2471                 // So there are more than on item in the map\r
2472                 previous.next = undefined;\r
2473                 this._tail = previous;\r
2474             }\r
2475             else {\r
2476                 // Both next and previous are not undefined since item was neither head nor tail.\r
2477                 next.previous = previous;\r
2478                 previous.next = next;\r
2479             }\r
2480             // Insert the node at head\r
2481             item.previous = undefined;\r
2482             item.next = this._head;\r
2483             this._head.previous = item;\r
2484             this._head = item;\r
2485         }\r
2486         else if (touch === Touch.Last) {\r
2487             if (item === this._tail) {\r
2488                 return;\r
2489             }\r
2490             const next = item.next;\r
2491             const previous = item.previous;\r
2492             // Unlink the item.\r
2493             if (item === this._head) {\r
2494                 // next must be defined since item was not tail but is head\r
2495                 // So there are more than on item in the map\r
2496                 next.previous = undefined;\r
2497                 this._head = next;\r
2498             }\r
2499             else {\r
2500                 // Both next and previous are not undefined since item was neither head nor tail.\r
2501                 next.previous = previous;\r
2502                 previous.next = next;\r
2503             }\r
2504             item.next = undefined;\r
2505             item.previous = this._tail;\r
2506             this._tail.next = item;\r
2507             this._tail = item;\r
2508         }\r
2509     }\r
2510 }\r
2511 exports.LinkedMap = LinkedMap;\r
2512
2513
2514 /***/ }),
2515 /* 13 */
2516 /***/ (function(module, exports, __webpack_require__) {
2517
2518 "use strict";
2519 /* --------------------------------------------------------------------------------------------\r
2520  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2521  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2522  * ------------------------------------------------------------------------------------------ */\r
2523 \r
2524 Object.defineProperty(exports, "__esModule", { value: true });\r
2525 const path_1 = __webpack_require__(3);\r
2526 const os_1 = __webpack_require__(14);\r
2527 const crypto_1 = __webpack_require__(15);\r
2528 const net_1 = __webpack_require__(16);\r
2529 const messageReader_1 = __webpack_require__(8);\r
2530 const messageWriter_1 = __webpack_require__(10);\r
2531 function generateRandomPipeName() {\r
2532     const randomSuffix = crypto_1.randomBytes(21).toString('hex');\r
2533     if (process.platform === 'win32') {\r
2534         return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;\r
2535     }\r
2536     else {\r
2537         // Mac/Unix: use socket file\r
2538         return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);\r
2539     }\r
2540 }\r
2541 exports.generateRandomPipeName = generateRandomPipeName;\r
2542 function createClientPipeTransport(pipeName, encoding = 'utf-8') {\r
2543     let connectResolve;\r
2544     let connected = new Promise((resolve, _reject) => {\r
2545         connectResolve = resolve;\r
2546     });\r
2547     return new Promise((resolve, reject) => {\r
2548         let server = net_1.createServer((socket) => {\r
2549             server.close();\r
2550             connectResolve([\r
2551                 new messageReader_1.SocketMessageReader(socket, encoding),\r
2552                 new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2553             ]);\r
2554         });\r
2555         server.on('error', reject);\r
2556         server.listen(pipeName, () => {\r
2557             server.removeListener('error', reject);\r
2558             resolve({\r
2559                 onConnected: () => { return connected; }\r
2560             });\r
2561         });\r
2562     });\r
2563 }\r
2564 exports.createClientPipeTransport = createClientPipeTransport;\r
2565 function createServerPipeTransport(pipeName, encoding = 'utf-8') {\r
2566     const socket = net_1.createConnection(pipeName);\r
2567     return [\r
2568         new messageReader_1.SocketMessageReader(socket, encoding),\r
2569         new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2570     ];\r
2571 }\r
2572 exports.createServerPipeTransport = createServerPipeTransport;\r
2573
2574
2575 /***/ }),
2576 /* 14 */
2577 /***/ (function(module, exports) {
2578
2579 module.exports = require("os");
2580
2581 /***/ }),
2582 /* 15 */
2583 /***/ (function(module, exports) {
2584
2585 module.exports = require("crypto");
2586
2587 /***/ }),
2588 /* 16 */
2589 /***/ (function(module, exports) {
2590
2591 module.exports = require("net");
2592
2593 /***/ }),
2594 /* 17 */
2595 /***/ (function(module, exports, __webpack_require__) {
2596
2597 "use strict";
2598 /* --------------------------------------------------------------------------------------------\r
2599  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2600  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2601  * ------------------------------------------------------------------------------------------ */\r
2602 \r
2603 Object.defineProperty(exports, "__esModule", { value: true });\r
2604 const net_1 = __webpack_require__(16);\r
2605 const messageReader_1 = __webpack_require__(8);\r
2606 const messageWriter_1 = __webpack_require__(10);\r
2607 function createClientSocketTransport(port, encoding = 'utf-8') {\r
2608     let connectResolve;\r
2609     let connected = new Promise((resolve, _reject) => {\r
2610         connectResolve = resolve;\r
2611     });\r
2612     return new Promise((resolve, reject) => {\r
2613         let server = net_1.createServer((socket) => {\r
2614             server.close();\r
2615             connectResolve([\r
2616                 new messageReader_1.SocketMessageReader(socket, encoding),\r
2617                 new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2618             ]);\r
2619         });\r
2620         server.on('error', reject);\r
2621         server.listen(port, '127.0.0.1', () => {\r
2622             server.removeListener('error', reject);\r
2623             resolve({\r
2624                 onConnected: () => { return connected; }\r
2625             });\r
2626         });\r
2627     });\r
2628 }\r
2629 exports.createClientSocketTransport = createClientSocketTransport;\r
2630 function createServerSocketTransport(port, encoding = 'utf-8') {\r
2631     const socket = net_1.createConnection(port, '127.0.0.1');\r
2632     return [\r
2633         new messageReader_1.SocketMessageReader(socket, encoding),\r
2634         new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2635     ];\r
2636 }\r
2637 exports.createServerSocketTransport = createServerSocketTransport;\r
2638
2639
2640 /***/ }),
2641 /* 18 */
2642 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2643
2644 "use strict";
2645 __webpack_require__.r(__webpack_exports__);
2646 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2647 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2648 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2649 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2650 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2651 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2652 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2653 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2654 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2655 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2656 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2657 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
2658 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2659 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2660 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2661 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2662 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2663 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2664 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2665 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2666 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2667 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2668 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2669 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2670 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2671 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2672 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2673 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2674 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2675 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2676 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2677 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2678 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2679 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2680 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2681 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2682 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2683 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2684 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2685 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2686 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2687 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2688 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2689 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2690 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2691 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
2692 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2693 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2694 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
2695 /* --------------------------------------------------------------------------------------------
2696  * Copyright (c) Microsoft Corporation. All rights reserved.
2697  * Licensed under the MIT License. See License.txt in the project root for license information.
2698  * ------------------------------------------------------------------------------------------ */
2699
2700 /**
2701  * The Position namespace provides helper functions to work with
2702  * [Position](#Position) literals.
2703  */
2704 var Position;
2705 (function (Position) {
2706     /**
2707      * Creates a new Position literal from the given line and character.
2708      * @param line The position's line.
2709      * @param character The position's character.
2710      */
2711     function create(line, character) {
2712         return { line: line, character: character };
2713     }
2714     Position.create = create;
2715     /**
2716      * Checks whether the given liternal conforms to the [Position](#Position) interface.
2717      */
2718     function is(value) {
2719         var candidate = value;
2720         return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
2721     }
2722     Position.is = is;
2723 })(Position || (Position = {}));
2724 /**
2725  * The Range namespace provides helper functions to work with
2726  * [Range](#Range) literals.
2727  */
2728 var Range;
2729 (function (Range) {
2730     function create(one, two, three, four) {
2731         if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
2732             return { start: Position.create(one, two), end: Position.create(three, four) };
2733         }
2734         else if (Position.is(one) && Position.is(two)) {
2735             return { start: one, end: two };
2736         }
2737         else {
2738             throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
2739         }
2740     }
2741     Range.create = create;
2742     /**
2743      * Checks whether the given literal conforms to the [Range](#Range) interface.
2744      */
2745     function is(value) {
2746         var candidate = value;
2747         return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
2748     }
2749     Range.is = is;
2750 })(Range || (Range = {}));
2751 /**
2752  * The Location namespace provides helper functions to work with
2753  * [Location](#Location) literals.
2754  */
2755 var Location;
2756 (function (Location) {
2757     /**
2758      * Creates a Location literal.
2759      * @param uri The location's uri.
2760      * @param range The location's range.
2761      */
2762     function create(uri, range) {
2763         return { uri: uri, range: range };
2764     }
2765     Location.create = create;
2766     /**
2767      * Checks whether the given literal conforms to the [Location](#Location) interface.
2768      */
2769     function is(value) {
2770         var candidate = value;
2771         return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
2772     }
2773     Location.is = is;
2774 })(Location || (Location = {}));
2775 /**
2776  * The LocationLink namespace provides helper functions to work with
2777  * [LocationLink](#LocationLink) literals.
2778  */
2779 var LocationLink;
2780 (function (LocationLink) {
2781     /**
2782      * Creates a LocationLink literal.
2783      * @param targetUri The definition's uri.
2784      * @param targetRange The full range of the definition.
2785      * @param targetSelectionRange The span of the symbol definition at the target.
2786      * @param originSelectionRange The span of the symbol being defined in the originating source file.
2787      */
2788     function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
2789         return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
2790     }
2791     LocationLink.create = create;
2792     /**
2793      * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
2794      */
2795     function is(value) {
2796         var candidate = value;
2797         return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
2798             && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
2799             && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
2800     }
2801     LocationLink.is = is;
2802 })(LocationLink || (LocationLink = {}));
2803 /**
2804  * The Color namespace provides helper functions to work with
2805  * [Color](#Color) literals.
2806  */
2807 var Color;
2808 (function (Color) {
2809     /**
2810      * Creates a new Color literal.
2811      */
2812     function create(red, green, blue, alpha) {
2813         return {
2814             red: red,
2815             green: green,
2816             blue: blue,
2817             alpha: alpha,
2818         };
2819     }
2820     Color.create = create;
2821     /**
2822      * Checks whether the given literal conforms to the [Color](#Color) interface.
2823      */
2824     function is(value) {
2825         var candidate = value;
2826         return Is.number(candidate.red)
2827             && Is.number(candidate.green)
2828             && Is.number(candidate.blue)
2829             && Is.number(candidate.alpha);
2830     }
2831     Color.is = is;
2832 })(Color || (Color = {}));
2833 /**
2834  * The ColorInformation namespace provides helper functions to work with
2835  * [ColorInformation](#ColorInformation) literals.
2836  */
2837 var ColorInformation;
2838 (function (ColorInformation) {
2839     /**
2840      * Creates a new ColorInformation literal.
2841      */
2842     function create(range, color) {
2843         return {
2844             range: range,
2845             color: color,
2846         };
2847     }
2848     ColorInformation.create = create;
2849     /**
2850      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
2851      */
2852     function is(value) {
2853         var candidate = value;
2854         return Range.is(candidate.range) && Color.is(candidate.color);
2855     }
2856     ColorInformation.is = is;
2857 })(ColorInformation || (ColorInformation = {}));
2858 /**
2859  * The Color namespace provides helper functions to work with
2860  * [ColorPresentation](#ColorPresentation) literals.
2861  */
2862 var ColorPresentation;
2863 (function (ColorPresentation) {
2864     /**
2865      * Creates a new ColorInformation literal.
2866      */
2867     function create(label, textEdit, additionalTextEdits) {
2868         return {
2869             label: label,
2870             textEdit: textEdit,
2871             additionalTextEdits: additionalTextEdits,
2872         };
2873     }
2874     ColorPresentation.create = create;
2875     /**
2876      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
2877      */
2878     function is(value) {
2879         var candidate = value;
2880         return Is.string(candidate.label)
2881             && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
2882             && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
2883     }
2884     ColorPresentation.is = is;
2885 })(ColorPresentation || (ColorPresentation = {}));
2886 /**
2887  * Enum of known range kinds
2888  */
2889 var FoldingRangeKind;
2890 (function (FoldingRangeKind) {
2891     /**
2892      * Folding range for a comment
2893      */
2894     FoldingRangeKind["Comment"] = "comment";
2895     /**
2896      * Folding range for a imports or includes
2897      */
2898     FoldingRangeKind["Imports"] = "imports";
2899     /**
2900      * Folding range for a region (e.g. `#region`)
2901      */
2902     FoldingRangeKind["Region"] = "region";
2903 })(FoldingRangeKind || (FoldingRangeKind = {}));
2904 /**
2905  * The folding range namespace provides helper functions to work with
2906  * [FoldingRange](#FoldingRange) literals.
2907  */
2908 var FoldingRange;
2909 (function (FoldingRange) {
2910     /**
2911      * Creates a new FoldingRange literal.
2912      */
2913     function create(startLine, endLine, startCharacter, endCharacter, kind) {
2914         var result = {
2915             startLine: startLine,
2916             endLine: endLine
2917         };
2918         if (Is.defined(startCharacter)) {
2919             result.startCharacter = startCharacter;
2920         }
2921         if (Is.defined(endCharacter)) {
2922             result.endCharacter = endCharacter;
2923         }
2924         if (Is.defined(kind)) {
2925             result.kind = kind;
2926         }
2927         return result;
2928     }
2929     FoldingRange.create = create;
2930     /**
2931      * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
2932      */
2933     function is(value) {
2934         var candidate = value;
2935         return Is.number(candidate.startLine) && Is.number(candidate.startLine)
2936             && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
2937             && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
2938             && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
2939     }
2940     FoldingRange.is = is;
2941 })(FoldingRange || (FoldingRange = {}));
2942 /**
2943  * The DiagnosticRelatedInformation namespace provides helper functions to work with
2944  * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
2945  */
2946 var DiagnosticRelatedInformation;
2947 (function (DiagnosticRelatedInformation) {
2948     /**
2949      * Creates a new DiagnosticRelatedInformation literal.
2950      */
2951     function create(location, message) {
2952         return {
2953             location: location,
2954             message: message
2955         };
2956     }
2957     DiagnosticRelatedInformation.create = create;
2958     /**
2959      * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
2960      */
2961     function is(value) {
2962         var candidate = value;
2963         return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
2964     }
2965     DiagnosticRelatedInformation.is = is;
2966 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
2967 /**
2968  * The diagnostic's severity.
2969  */
2970 var DiagnosticSeverity;
2971 (function (DiagnosticSeverity) {
2972     /**
2973      * Reports an error.
2974      */
2975     DiagnosticSeverity.Error = 1;
2976     /**
2977      * Reports a warning.
2978      */
2979     DiagnosticSeverity.Warning = 2;
2980     /**
2981      * Reports an information.
2982      */
2983     DiagnosticSeverity.Information = 3;
2984     /**
2985      * Reports a hint.
2986      */
2987     DiagnosticSeverity.Hint = 4;
2988 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
2989 var DiagnosticTag;
2990 (function (DiagnosticTag) {
2991     /**
2992      * Unused or unnecessary code.
2993      *
2994      * Clients are allowed to render diagnostics with this tag faded out instead of having
2995      * an error squiggle.
2996      */
2997     DiagnosticTag.Unnecessary = 1;
2998 })(DiagnosticTag || (DiagnosticTag = {}));
2999 /**
3000  * The Diagnostic namespace provides helper functions to work with
3001  * [Diagnostic](#Diagnostic) literals.
3002  */
3003 var Diagnostic;
3004 (function (Diagnostic) {
3005     /**
3006      * Creates a new Diagnostic literal.
3007      */
3008     function create(range, message, severity, code, source, relatedInformation) {
3009         var result = { range: range, message: message };
3010         if (Is.defined(severity)) {
3011             result.severity = severity;
3012         }
3013         if (Is.defined(code)) {
3014             result.code = code;
3015         }
3016         if (Is.defined(source)) {
3017             result.source = source;
3018         }
3019         if (Is.defined(relatedInformation)) {
3020             result.relatedInformation = relatedInformation;
3021         }
3022         return result;
3023     }
3024     Diagnostic.create = create;
3025     /**
3026      * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
3027      */
3028     function is(value) {
3029         var candidate = value;
3030         return Is.defined(candidate)
3031             && Range.is(candidate.range)
3032             && Is.string(candidate.message)
3033             && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
3034             && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
3035             && (Is.string(candidate.source) || Is.undefined(candidate.source))
3036             && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
3037     }
3038     Diagnostic.is = is;
3039 })(Diagnostic || (Diagnostic = {}));
3040 /**
3041  * The Command namespace provides helper functions to work with
3042  * [Command](#Command) literals.
3043  */
3044 var Command;
3045 (function (Command) {
3046     /**
3047      * Creates a new Command literal.
3048      */
3049     function create(title, command) {
3050         var args = [];
3051         for (var _i = 2; _i < arguments.length; _i++) {
3052             args[_i - 2] = arguments[_i];
3053         }
3054         var result = { title: title, command: command };
3055         if (Is.defined(args) && args.length > 0) {
3056             result.arguments = args;
3057         }
3058         return result;
3059     }
3060     Command.create = create;
3061     /**
3062      * Checks whether the given literal conforms to the [Command](#Command) interface.
3063      */
3064     function is(value) {
3065         var candidate = value;
3066         return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
3067     }
3068     Command.is = is;
3069 })(Command || (Command = {}));
3070 /**
3071  * The TextEdit namespace provides helper function to create replace,
3072  * insert and delete edits more easily.
3073  */
3074 var TextEdit;
3075 (function (TextEdit) {
3076     /**
3077      * Creates a replace text edit.
3078      * @param range The range of text to be replaced.
3079      * @param newText The new text.
3080      */
3081     function replace(range, newText) {
3082         return { range: range, newText: newText };
3083     }
3084     TextEdit.replace = replace;
3085     /**
3086      * Creates a insert text edit.
3087      * @param position The position to insert the text at.
3088      * @param newText The text to be inserted.
3089      */
3090     function insert(position, newText) {
3091         return { range: { start: position, end: position }, newText: newText };
3092     }
3093     TextEdit.insert = insert;
3094     /**
3095      * Creates a delete text edit.
3096      * @param range The range of text to be deleted.
3097      */
3098     function del(range) {
3099         return { range: range, newText: '' };
3100     }
3101     TextEdit.del = del;
3102     function is(value) {
3103         var candidate = value;
3104         return Is.objectLiteral(candidate)
3105             && Is.string(candidate.newText)
3106             && Range.is(candidate.range);
3107     }
3108     TextEdit.is = is;
3109 })(TextEdit || (TextEdit = {}));
3110 /**
3111  * The TextDocumentEdit namespace provides helper function to create
3112  * an edit that manipulates a text document.
3113  */
3114 var TextDocumentEdit;
3115 (function (TextDocumentEdit) {
3116     /**
3117      * Creates a new `TextDocumentEdit`
3118      */
3119     function create(textDocument, edits) {
3120         return { textDocument: textDocument, edits: edits };
3121     }
3122     TextDocumentEdit.create = create;
3123     function is(value) {
3124         var candidate = value;
3125         return Is.defined(candidate)
3126             && VersionedTextDocumentIdentifier.is(candidate.textDocument)
3127             && Array.isArray(candidate.edits);
3128     }
3129     TextDocumentEdit.is = is;
3130 })(TextDocumentEdit || (TextDocumentEdit = {}));
3131 var CreateFile;
3132 (function (CreateFile) {
3133     function create(uri, options) {
3134         var result = {
3135             kind: 'create',
3136             uri: uri
3137         };
3138         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
3139             result.options = options;
3140         }
3141         return result;
3142     }
3143     CreateFile.create = create;
3144     function is(value) {
3145         var candidate = value;
3146         return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
3147             (candidate.options === void 0 ||
3148                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
3149     }
3150     CreateFile.is = is;
3151 })(CreateFile || (CreateFile = {}));
3152 var RenameFile;
3153 (function (RenameFile) {
3154     function create(oldUri, newUri, options) {
3155         var result = {
3156             kind: 'rename',
3157             oldUri: oldUri,
3158             newUri: newUri
3159         };
3160         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
3161             result.options = options;
3162         }
3163         return result;
3164     }
3165     RenameFile.create = create;
3166     function is(value) {
3167         var candidate = value;
3168         return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
3169             (candidate.options === void 0 ||
3170                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
3171     }
3172     RenameFile.is = is;
3173 })(RenameFile || (RenameFile = {}));
3174 var DeleteFile;
3175 (function (DeleteFile) {
3176     function create(uri, options) {
3177         var result = {
3178             kind: 'delete',
3179             uri: uri
3180         };
3181         if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
3182             result.options = options;
3183         }
3184         return result;
3185     }
3186     DeleteFile.create = create;
3187     function is(value) {
3188         var candidate = value;
3189         return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
3190             (candidate.options === void 0 ||
3191                 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
3192     }
3193     DeleteFile.is = is;
3194 })(DeleteFile || (DeleteFile = {}));
3195 var WorkspaceEdit;
3196 (function (WorkspaceEdit) {
3197     function is(value) {
3198         var candidate = value;
3199         return candidate &&
3200             (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
3201             (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
3202                 if (Is.string(change.kind)) {
3203                     return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
3204                 }
3205                 else {
3206                     return TextDocumentEdit.is(change);
3207                 }
3208             }));
3209     }
3210     WorkspaceEdit.is = is;
3211 })(WorkspaceEdit || (WorkspaceEdit = {}));
3212 var TextEditChangeImpl = /** @class */ (function () {
3213     function TextEditChangeImpl(edits) {
3214         this.edits = edits;
3215     }
3216     TextEditChangeImpl.prototype.insert = function (position, newText) {
3217         this.edits.push(TextEdit.insert(position, newText));
3218     };
3219     TextEditChangeImpl.prototype.replace = function (range, newText) {
3220         this.edits.push(TextEdit.replace(range, newText));
3221     };
3222     TextEditChangeImpl.prototype.delete = function (range) {
3223         this.edits.push(TextEdit.del(range));
3224     };
3225     TextEditChangeImpl.prototype.add = function (edit) {
3226         this.edits.push(edit);
3227     };
3228     TextEditChangeImpl.prototype.all = function () {
3229         return this.edits;
3230     };
3231     TextEditChangeImpl.prototype.clear = function () {
3232         this.edits.splice(0, this.edits.length);
3233     };
3234     return TextEditChangeImpl;
3235 }());
3236 /**
3237  * A workspace change helps constructing changes to a workspace.
3238  */
3239 var WorkspaceChange = /** @class */ (function () {
3240     function WorkspaceChange(workspaceEdit) {
3241         var _this = this;
3242         this._textEditChanges = Object.create(null);
3243         if (workspaceEdit) {
3244             this._workspaceEdit = workspaceEdit;
3245             if (workspaceEdit.documentChanges) {
3246                 workspaceEdit.documentChanges.forEach(function (change) {
3247                     if (TextDocumentEdit.is(change)) {
3248                         var textEditChange = new TextEditChangeImpl(change.edits);
3249                         _this._textEditChanges[change.textDocument.uri] = textEditChange;
3250                     }
3251                 });
3252             }
3253             else if (workspaceEdit.changes) {
3254                 Object.keys(workspaceEdit.changes).forEach(function (key) {
3255                     var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
3256                     _this._textEditChanges[key] = textEditChange;
3257                 });
3258             }
3259         }
3260     }
3261     Object.defineProperty(WorkspaceChange.prototype, "edit", {
3262         /**
3263          * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
3264          * use to be returned from a workspace edit operation like rename.
3265          */
3266         get: function () {
3267             return this._workspaceEdit;
3268         },
3269         enumerable: true,
3270         configurable: true
3271     });
3272     WorkspaceChange.prototype.getTextEditChange = function (key) {
3273         if (VersionedTextDocumentIdentifier.is(key)) {
3274             if (!this._workspaceEdit) {
3275                 this._workspaceEdit = {
3276                     documentChanges: []
3277                 };
3278             }
3279             if (!this._workspaceEdit.documentChanges) {
3280                 throw new Error('Workspace edit is not configured for document changes.');
3281             }
3282             var textDocument = key;
3283             var result = this._textEditChanges[textDocument.uri];
3284             if (!result) {
3285                 var edits = [];
3286                 var textDocumentEdit = {
3287                     textDocument: textDocument,
3288                     edits: edits
3289                 };
3290                 this._workspaceEdit.documentChanges.push(textDocumentEdit);
3291                 result = new TextEditChangeImpl(edits);
3292                 this._textEditChanges[textDocument.uri] = result;
3293             }
3294             return result;
3295         }
3296         else {
3297             if (!this._workspaceEdit) {
3298                 this._workspaceEdit = {
3299                     changes: Object.create(null)
3300                 };
3301             }
3302             if (!this._workspaceEdit.changes) {
3303                 throw new Error('Workspace edit is not configured for normal text edit changes.');
3304             }
3305             var result = this._textEditChanges[key];
3306             if (!result) {
3307                 var edits = [];
3308                 this._workspaceEdit.changes[key] = edits;
3309                 result = new TextEditChangeImpl(edits);
3310                 this._textEditChanges[key] = result;
3311             }
3312             return result;
3313         }
3314     };
3315     WorkspaceChange.prototype.createFile = function (uri, options) {
3316         this.checkDocumentChanges();
3317         this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
3318     };
3319     WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
3320         this.checkDocumentChanges();
3321         this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
3322     };
3323     WorkspaceChange.prototype.deleteFile = function (uri, options) {
3324         this.checkDocumentChanges();
3325         this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
3326     };
3327     WorkspaceChange.prototype.checkDocumentChanges = function () {
3328         if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
3329             throw new Error('Workspace edit is not configured for document changes.');
3330         }
3331     };
3332     return WorkspaceChange;
3333 }());
3334
3335 /**
3336  * The TextDocumentIdentifier namespace provides helper functions to work with
3337  * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
3338  */
3339 var TextDocumentIdentifier;
3340 (function (TextDocumentIdentifier) {
3341     /**
3342      * Creates a new TextDocumentIdentifier literal.
3343      * @param uri The document's uri.
3344      */
3345     function create(uri) {
3346         return { uri: uri };
3347     }
3348     TextDocumentIdentifier.create = create;
3349     /**
3350      * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
3351      */
3352     function is(value) {
3353         var candidate = value;
3354         return Is.defined(candidate) && Is.string(candidate.uri);
3355     }
3356     TextDocumentIdentifier.is = is;
3357 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
3358 /**
3359  * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
3360  * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
3361  */
3362 var VersionedTextDocumentIdentifier;
3363 (function (VersionedTextDocumentIdentifier) {
3364     /**
3365      * Creates a new VersionedTextDocumentIdentifier literal.
3366      * @param uri The document's uri.
3367      * @param uri The document's text.
3368      */
3369     function create(uri, version) {
3370         return { uri: uri, version: version };
3371     }
3372     VersionedTextDocumentIdentifier.create = create;
3373     /**
3374      * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
3375      */
3376     function is(value) {
3377         var candidate = value;
3378         return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
3379     }
3380     VersionedTextDocumentIdentifier.is = is;
3381 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
3382 /**
3383  * The TextDocumentItem namespace provides helper functions to work with
3384  * [TextDocumentItem](#TextDocumentItem) literals.
3385  */
3386 var TextDocumentItem;
3387 (function (TextDocumentItem) {
3388     /**
3389      * Creates a new TextDocumentItem literal.
3390      * @param uri The document's uri.
3391      * @param languageId The document's language identifier.
3392      * @param version The document's version number.
3393      * @param text The document's text.
3394      */
3395     function create(uri, languageId, version, text) {
3396         return { uri: uri, languageId: languageId, version: version, text: text };
3397     }
3398     TextDocumentItem.create = create;
3399     /**
3400      * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
3401      */
3402     function is(value) {
3403         var candidate = value;
3404         return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
3405     }
3406     TextDocumentItem.is = is;
3407 })(TextDocumentItem || (TextDocumentItem = {}));
3408 /**
3409  * Describes the content type that a client supports in various
3410  * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
3411  *
3412  * Please note that `MarkupKinds` must not start with a `$`. This kinds
3413  * are reserved for internal usage.
3414  */
3415 var MarkupKind;
3416 (function (MarkupKind) {
3417     /**
3418      * Plain text is supported as a content format
3419      */
3420     MarkupKind.PlainText = 'plaintext';
3421     /**
3422      * Markdown is supported as a content format
3423      */
3424     MarkupKind.Markdown = 'markdown';
3425 })(MarkupKind || (MarkupKind = {}));
3426 (function (MarkupKind) {
3427     /**
3428      * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
3429      */
3430     function is(value) {
3431         var candidate = value;
3432         return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
3433     }
3434     MarkupKind.is = is;
3435 })(MarkupKind || (MarkupKind = {}));
3436 var MarkupContent;
3437 (function (MarkupContent) {
3438     /**
3439      * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
3440      */
3441     function is(value) {
3442         var candidate = value;
3443         return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
3444     }
3445     MarkupContent.is = is;
3446 })(MarkupContent || (MarkupContent = {}));
3447 /**
3448  * The kind of a completion entry.
3449  */
3450 var CompletionItemKind;
3451 (function (CompletionItemKind) {
3452     CompletionItemKind.Text = 1;
3453     CompletionItemKind.Method = 2;
3454     CompletionItemKind.Function = 3;
3455     CompletionItemKind.Constructor = 4;
3456     CompletionItemKind.Field = 5;
3457     CompletionItemKind.Variable = 6;
3458     CompletionItemKind.Class = 7;
3459     CompletionItemKind.Interface = 8;
3460     CompletionItemKind.Module = 9;
3461     CompletionItemKind.Property = 10;
3462     CompletionItemKind.Unit = 11;
3463     CompletionItemKind.Value = 12;
3464     CompletionItemKind.Enum = 13;
3465     CompletionItemKind.Keyword = 14;
3466     CompletionItemKind.Snippet = 15;
3467     CompletionItemKind.Color = 16;
3468     CompletionItemKind.File = 17;
3469     CompletionItemKind.Reference = 18;
3470     CompletionItemKind.Folder = 19;
3471     CompletionItemKind.EnumMember = 20;
3472     CompletionItemKind.Constant = 21;
3473     CompletionItemKind.Struct = 22;
3474     CompletionItemKind.Event = 23;
3475     CompletionItemKind.Operator = 24;
3476     CompletionItemKind.TypeParameter = 25;
3477 })(CompletionItemKind || (CompletionItemKind = {}));
3478 /**
3479  * Defines whether the insert text in a completion item should be interpreted as
3480  * plain text or a snippet.
3481  */
3482 var InsertTextFormat;
3483 (function (InsertTextFormat) {
3484     /**
3485      * The primary text to be inserted is treated as a plain string.
3486      */
3487     InsertTextFormat.PlainText = 1;
3488     /**
3489      * The primary text to be inserted is treated as a snippet.
3490      *
3491      * A snippet can define tab stops and placeholders with `$1`, `$2`
3492      * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
3493      * the end of the snippet. Placeholders with equal identifiers are linked,
3494      * that is typing in one will update others too.
3495      *
3496      * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
3497      */
3498     InsertTextFormat.Snippet = 2;
3499 })(InsertTextFormat || (InsertTextFormat = {}));
3500 /**
3501  * The CompletionItem namespace provides functions to deal with
3502  * completion items.
3503  */
3504 var CompletionItem;
3505 (function (CompletionItem) {
3506     /**
3507      * Create a completion item and seed it with a label.
3508      * @param label The completion item's label
3509      */
3510     function create(label) {
3511         return { label: label };
3512     }
3513     CompletionItem.create = create;
3514 })(CompletionItem || (CompletionItem = {}));
3515 /**
3516  * The CompletionList namespace provides functions to deal with
3517  * completion lists.
3518  */
3519 var CompletionList;
3520 (function (CompletionList) {
3521     /**
3522      * Creates a new completion list.
3523      *
3524      * @param items The completion items.
3525      * @param isIncomplete The list is not complete.
3526      */
3527     function create(items, isIncomplete) {
3528         return { items: items ? items : [], isIncomplete: !!isIncomplete };
3529     }
3530     CompletionList.create = create;
3531 })(CompletionList || (CompletionList = {}));
3532 var MarkedString;
3533 (function (MarkedString) {
3534     /**
3535      * Creates a marked string from plain text.
3536      *
3537      * @param plainText The plain text.
3538      */
3539     function fromPlainText(plainText) {
3540         return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
3541     }
3542     MarkedString.fromPlainText = fromPlainText;
3543     /**
3544      * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
3545      */
3546     function is(value) {
3547         var candidate = value;
3548         return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
3549     }
3550     MarkedString.is = is;
3551 })(MarkedString || (MarkedString = {}));
3552 var Hover;
3553 (function (Hover) {
3554     /**
3555      * Checks whether the given value conforms to the [Hover](#Hover) interface.
3556      */
3557     function is(value) {
3558         var candidate = value;
3559         return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
3560             MarkedString.is(candidate.contents) ||
3561             Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
3562     }
3563     Hover.is = is;
3564 })(Hover || (Hover = {}));
3565 /**
3566  * The ParameterInformation namespace provides helper functions to work with
3567  * [ParameterInformation](#ParameterInformation) literals.
3568  */
3569 var ParameterInformation;
3570 (function (ParameterInformation) {
3571     /**
3572      * Creates a new parameter information literal.
3573      *
3574      * @param label A label string.
3575      * @param documentation A doc string.
3576      */
3577     function create(label, documentation) {
3578         return documentation ? { label: label, documentation: documentation } : { label: label };
3579     }
3580     ParameterInformation.create = create;
3581     ;
3582 })(ParameterInformation || (ParameterInformation = {}));
3583 /**
3584  * The SignatureInformation namespace provides helper functions to work with
3585  * [SignatureInformation](#SignatureInformation) literals.
3586  */
3587 var SignatureInformation;
3588 (function (SignatureInformation) {
3589     function create(label, documentation) {
3590         var parameters = [];
3591         for (var _i = 2; _i < arguments.length; _i++) {
3592             parameters[_i - 2] = arguments[_i];
3593         }
3594         var result = { label: label };
3595         if (Is.defined(documentation)) {
3596             result.documentation = documentation;
3597         }
3598         if (Is.defined(parameters)) {
3599             result.parameters = parameters;
3600         }
3601         else {
3602             result.parameters = [];
3603         }
3604         return result;
3605     }
3606     SignatureInformation.create = create;
3607 })(SignatureInformation || (SignatureInformation = {}));
3608 /**
3609  * A document highlight kind.
3610  */
3611 var DocumentHighlightKind;
3612 (function (DocumentHighlightKind) {
3613     /**
3614      * A textual occurrence.
3615      */
3616     DocumentHighlightKind.Text = 1;
3617     /**
3618      * Read-access of a symbol, like reading a variable.
3619      */
3620     DocumentHighlightKind.Read = 2;
3621     /**
3622      * Write-access of a symbol, like writing to a variable.
3623      */
3624     DocumentHighlightKind.Write = 3;
3625 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
3626 /**
3627  * DocumentHighlight namespace to provide helper functions to work with
3628  * [DocumentHighlight](#DocumentHighlight) literals.
3629  */
3630 var DocumentHighlight;
3631 (function (DocumentHighlight) {
3632     /**
3633      * Create a DocumentHighlight object.
3634      * @param range The range the highlight applies to.
3635      */
3636     function create(range, kind) {
3637         var result = { range: range };
3638         if (Is.number(kind)) {
3639             result.kind = kind;
3640         }
3641         return result;
3642     }
3643     DocumentHighlight.create = create;
3644 })(DocumentHighlight || (DocumentHighlight = {}));
3645 /**
3646  * A symbol kind.
3647  */
3648 var SymbolKind;
3649 (function (SymbolKind) {
3650     SymbolKind.File = 1;
3651     SymbolKind.Module = 2;
3652     SymbolKind.Namespace = 3;
3653     SymbolKind.Package = 4;
3654     SymbolKind.Class = 5;
3655     SymbolKind.Method = 6;
3656     SymbolKind.Property = 7;
3657     SymbolKind.Field = 8;
3658     SymbolKind.Constructor = 9;
3659     SymbolKind.Enum = 10;
3660     SymbolKind.Interface = 11;
3661     SymbolKind.Function = 12;
3662     SymbolKind.Variable = 13;
3663     SymbolKind.Constant = 14;
3664     SymbolKind.String = 15;
3665     SymbolKind.Number = 16;
3666     SymbolKind.Boolean = 17;
3667     SymbolKind.Array = 18;
3668     SymbolKind.Object = 19;
3669     SymbolKind.Key = 20;
3670     SymbolKind.Null = 21;
3671     SymbolKind.EnumMember = 22;
3672     SymbolKind.Struct = 23;
3673     SymbolKind.Event = 24;
3674     SymbolKind.Operator = 25;
3675     SymbolKind.TypeParameter = 26;
3676 })(SymbolKind || (SymbolKind = {}));
3677 var SymbolInformation;
3678 (function (SymbolInformation) {
3679     /**
3680      * Creates a new symbol information literal.
3681      *
3682      * @param name The name of the symbol.
3683      * @param kind The kind of the symbol.
3684      * @param range The range of the location of the symbol.
3685      * @param uri The resource of the location of symbol, defaults to the current document.
3686      * @param containerName The name of the symbol containing the symbol.
3687      */
3688     function create(name, kind, range, uri, containerName) {
3689         var result = {
3690             name: name,
3691             kind: kind,
3692             location: { uri: uri, range: range }
3693         };
3694         if (containerName) {
3695             result.containerName = containerName;
3696         }
3697         return result;
3698     }
3699     SymbolInformation.create = create;
3700 })(SymbolInformation || (SymbolInformation = {}));
3701 /**
3702  * Represents programming constructs like variables, classes, interfaces etc.
3703  * that appear in a document. Document symbols can be hierarchical and they
3704  * have two ranges: one that encloses its definition and one that points to
3705  * its most interesting range, e.g. the range of an identifier.
3706  */
3707 var DocumentSymbol = /** @class */ (function () {
3708     function DocumentSymbol() {
3709     }
3710     return DocumentSymbol;
3711 }());
3712
3713 (function (DocumentSymbol) {
3714     /**
3715      * Creates a new symbol information literal.
3716      *
3717      * @param name The name of the symbol.
3718      * @param detail The detail of the symbol.
3719      * @param kind The kind of the symbol.
3720      * @param range The range of the symbol.
3721      * @param selectionRange The selectionRange of the symbol.
3722      * @param children Children of the symbol.
3723      */
3724     function create(name, detail, kind, range, selectionRange, children) {
3725         var result = {
3726             name: name,
3727             detail: detail,
3728             kind: kind,
3729             range: range,
3730             selectionRange: selectionRange
3731         };
3732         if (children !== void 0) {
3733             result.children = children;
3734         }
3735         return result;
3736     }
3737     DocumentSymbol.create = create;
3738     /**
3739      * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
3740      */
3741     function is(value) {
3742         var candidate = value;
3743         return candidate &&
3744             Is.string(candidate.name) && Is.number(candidate.kind) &&
3745             Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
3746             (candidate.detail === void 0 || Is.string(candidate.detail)) &&
3747             (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
3748             (candidate.children === void 0 || Array.isArray(candidate.children));
3749     }
3750     DocumentSymbol.is = is;
3751 })(DocumentSymbol || (DocumentSymbol = {}));
3752 /**
3753  * A set of predefined code action kinds
3754  */
3755 var CodeActionKind;
3756 (function (CodeActionKind) {
3757     /**
3758      * Base kind for quickfix actions: 'quickfix'
3759      */
3760     CodeActionKind.QuickFix = 'quickfix';
3761     /**
3762      * Base kind for refactoring actions: 'refactor'
3763      */
3764     CodeActionKind.Refactor = 'refactor';
3765     /**
3766      * Base kind for refactoring extraction actions: 'refactor.extract'
3767      *
3768      * Example extract actions:
3769      *
3770      * - Extract method
3771      * - Extract function
3772      * - Extract variable
3773      * - Extract interface from class
3774      * - ...
3775      */
3776     CodeActionKind.RefactorExtract = 'refactor.extract';
3777     /**
3778      * Base kind for refactoring inline actions: 'refactor.inline'
3779      *
3780      * Example inline actions:
3781      *
3782      * - Inline function
3783      * - Inline variable
3784      * - Inline constant
3785      * - ...
3786      */
3787     CodeActionKind.RefactorInline = 'refactor.inline';
3788     /**
3789      * Base kind for refactoring rewrite actions: 'refactor.rewrite'
3790      *
3791      * Example rewrite actions:
3792      *
3793      * - Convert JavaScript function to class
3794      * - Add or remove parameter
3795      * - Encapsulate field
3796      * - Make method static
3797      * - Move method to base class
3798      * - ...
3799      */
3800     CodeActionKind.RefactorRewrite = 'refactor.rewrite';
3801     /**
3802      * Base kind for source actions: `source`
3803      *
3804      * Source code actions apply to the entire file.
3805      */
3806     CodeActionKind.Source = 'source';
3807     /**
3808      * Base kind for an organize imports source action: `source.organizeImports`
3809      */
3810     CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
3811 })(CodeActionKind || (CodeActionKind = {}));
3812 /**
3813  * The CodeActionContext namespace provides helper functions to work with
3814  * [CodeActionContext](#CodeActionContext) literals.
3815  */
3816 var CodeActionContext;
3817 (function (CodeActionContext) {
3818     /**
3819      * Creates a new CodeActionContext literal.
3820      */
3821     function create(diagnostics, only) {
3822         var result = { diagnostics: diagnostics };
3823         if (only !== void 0 && only !== null) {
3824             result.only = only;
3825         }
3826         return result;
3827     }
3828     CodeActionContext.create = create;
3829     /**
3830      * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
3831      */
3832     function is(value) {
3833         var candidate = value;
3834         return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
3835     }
3836     CodeActionContext.is = is;
3837 })(CodeActionContext || (CodeActionContext = {}));
3838 var CodeAction;
3839 (function (CodeAction) {
3840     function create(title, commandOrEdit, kind) {
3841         var result = { title: title };
3842         if (Command.is(commandOrEdit)) {
3843             result.command = commandOrEdit;
3844         }
3845         else {
3846             result.edit = commandOrEdit;
3847         }
3848         if (kind !== void null) {
3849             result.kind = kind;
3850         }
3851         return result;
3852     }
3853     CodeAction.create = create;
3854     function is(value) {
3855         var candidate = value;
3856         return candidate && Is.string(candidate.title) &&
3857             (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
3858             (candidate.kind === void 0 || Is.string(candidate.kind)) &&
3859             (candidate.edit !== void 0 || candidate.command !== void 0) &&
3860             (candidate.command === void 0 || Command.is(candidate.command)) &&
3861             (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
3862     }
3863     CodeAction.is = is;
3864 })(CodeAction || (CodeAction = {}));
3865 /**
3866  * The CodeLens namespace provides helper functions to work with
3867  * [CodeLens](#CodeLens) literals.
3868  */
3869 var CodeLens;
3870 (function (CodeLens) {
3871     /**
3872      * Creates a new CodeLens literal.
3873      */
3874     function create(range, data) {
3875         var result = { range: range };
3876         if (Is.defined(data))
3877             result.data = data;
3878         return result;
3879     }
3880     CodeLens.create = create;
3881     /**
3882      * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
3883      */
3884     function is(value) {
3885         var candidate = value;
3886         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
3887     }
3888     CodeLens.is = is;
3889 })(CodeLens || (CodeLens = {}));
3890 /**
3891  * The FormattingOptions namespace provides helper functions to work with
3892  * [FormattingOptions](#FormattingOptions) literals.
3893  */
3894 var FormattingOptions;
3895 (function (FormattingOptions) {
3896     /**
3897      * Creates a new FormattingOptions literal.
3898      */
3899     function create(tabSize, insertSpaces) {
3900         return { tabSize: tabSize, insertSpaces: insertSpaces };
3901     }
3902     FormattingOptions.create = create;
3903     /**
3904      * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
3905      */
3906     function is(value) {
3907         var candidate = value;
3908         return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
3909     }
3910     FormattingOptions.is = is;
3911 })(FormattingOptions || (FormattingOptions = {}));
3912 /**
3913  * A document link is a range in a text document that links to an internal or external resource, like another
3914  * text document or a web site.
3915  */
3916 var DocumentLink = /** @class */ (function () {
3917     function DocumentLink() {
3918     }
3919     return DocumentLink;
3920 }());
3921
3922 /**
3923  * The DocumentLink namespace provides helper functions to work with
3924  * [DocumentLink](#DocumentLink) literals.
3925  */
3926 (function (DocumentLink) {
3927     /**
3928      * Creates a new DocumentLink literal.
3929      */
3930     function create(range, target, data) {
3931         return { range: range, target: target, data: data };
3932     }
3933     DocumentLink.create = create;
3934     /**
3935      * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
3936      */
3937     function is(value) {
3938         var candidate = value;
3939         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
3940     }
3941     DocumentLink.is = is;
3942 })(DocumentLink || (DocumentLink = {}));
3943 /**
3944  * The SelectionRange namespace provides helper function to work with
3945  * SelectionRange literals.
3946  */
3947 var SelectionRange;
3948 (function (SelectionRange) {
3949     /**
3950      * Creates a new SelectionRange
3951      * @param range the range.
3952      * @param parent an optional parent.
3953      */
3954     function create(range, parent) {
3955         return { range: range, parent: parent };
3956     }
3957     SelectionRange.create = create;
3958     function is(value) {
3959         var candidate = value;
3960         return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
3961     }
3962     SelectionRange.is = is;
3963 })(SelectionRange || (SelectionRange = {}));
3964 var EOL = ['\n', '\r\n', '\r'];
3965 var TextDocument;
3966 (function (TextDocument) {
3967     /**
3968      * Creates a new ITextDocument literal from the given uri and content.
3969      * @param uri The document's uri.
3970      * @param languageId  The document's language Id.
3971      * @param content The document's content.
3972      */
3973     function create(uri, languageId, version, content) {
3974         return new FullTextDocument(uri, languageId, version, content);
3975     }
3976     TextDocument.create = create;
3977     /**
3978      * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
3979      */
3980     function is(value) {
3981         var candidate = value;
3982         return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
3983             && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
3984     }
3985     TextDocument.is = is;
3986     function applyEdits(document, edits) {
3987         var text = document.getText();
3988         var sortedEdits = mergeSort(edits, function (a, b) {
3989             var diff = a.range.start.line - b.range.start.line;
3990             if (diff === 0) {
3991                 return a.range.start.character - b.range.start.character;
3992             }
3993             return diff;
3994         });
3995         var lastModifiedOffset = text.length;
3996         for (var i = sortedEdits.length - 1; i >= 0; i--) {
3997             var e = sortedEdits[i];
3998             var startOffset = document.offsetAt(e.range.start);
3999             var endOffset = document.offsetAt(e.range.end);
4000             if (endOffset <= lastModifiedOffset) {
4001                 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
4002             }
4003             else {
4004                 throw new Error('Overlapping edit');
4005             }
4006             lastModifiedOffset = startOffset;
4007         }
4008         return text;
4009     }
4010     TextDocument.applyEdits = applyEdits;
4011     function mergeSort(data, compare) {
4012         if (data.length <= 1) {
4013             // sorted
4014             return data;
4015         }
4016         var p = (data.length / 2) | 0;
4017         var left = data.slice(0, p);
4018         var right = data.slice(p);
4019         mergeSort(left, compare);
4020         mergeSort(right, compare);
4021         var leftIdx = 0;
4022         var rightIdx = 0;
4023         var i = 0;
4024         while (leftIdx < left.length && rightIdx < right.length) {
4025             var ret = compare(left[leftIdx], right[rightIdx]);
4026             if (ret <= 0) {
4027                 // smaller_equal -> take left to preserve order
4028                 data[i++] = left[leftIdx++];
4029             }
4030             else {
4031                 // greater -> take right
4032                 data[i++] = right[rightIdx++];
4033             }
4034         }
4035         while (leftIdx < left.length) {
4036             data[i++] = left[leftIdx++];
4037         }
4038         while (rightIdx < right.length) {
4039             data[i++] = right[rightIdx++];
4040         }
4041         return data;
4042     }
4043 })(TextDocument || (TextDocument = {}));
4044 /**
4045  * Represents reasons why a text document is saved.
4046  */
4047 var TextDocumentSaveReason;
4048 (function (TextDocumentSaveReason) {
4049     /**
4050      * Manually triggered, e.g. by the user pressing save, by starting debugging,
4051      * or by an API call.
4052      */
4053     TextDocumentSaveReason.Manual = 1;
4054     /**
4055      * Automatic after a delay.
4056      */
4057     TextDocumentSaveReason.AfterDelay = 2;
4058     /**
4059      * When the editor lost focus.
4060      */
4061     TextDocumentSaveReason.FocusOut = 3;
4062 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));
4063 var FullTextDocument = /** @class */ (function () {
4064     function FullTextDocument(uri, languageId, version, content) {
4065         this._uri = uri;
4066         this._languageId = languageId;
4067         this._version = version;
4068         this._content = content;
4069         this._lineOffsets = null;
4070     }
4071     Object.defineProperty(FullTextDocument.prototype, "uri", {
4072         get: function () {
4073             return this._uri;
4074         },
4075         enumerable: true,
4076         configurable: true
4077     });
4078     Object.defineProperty(FullTextDocument.prototype, "languageId", {
4079         get: function () {
4080             return this._languageId;
4081         },
4082         enumerable: true,
4083         configurable: true
4084     });
4085     Object.defineProperty(FullTextDocument.prototype, "version", {
4086         get: function () {
4087             return this._version;
4088         },
4089         enumerable: true,
4090         configurable: true
4091     });
4092     FullTextDocument.prototype.getText = function (range) {
4093         if (range) {
4094             var start = this.offsetAt(range.start);
4095             var end = this.offsetAt(range.end);
4096             return this._content.substring(start, end);
4097         }
4098         return this._content;
4099     };
4100     FullTextDocument.prototype.update = function (event, version) {
4101         this._content = event.text;
4102         this._version = version;
4103         this._lineOffsets = null;
4104     };
4105     FullTextDocument.prototype.getLineOffsets = function () {
4106         if (this._lineOffsets === null) {
4107             var lineOffsets = [];
4108             var text = this._content;
4109             var isLineStart = true;
4110             for (var i = 0; i < text.length; i++) {
4111                 if (isLineStart) {
4112                     lineOffsets.push(i);
4113                     isLineStart = false;
4114                 }
4115                 var ch = text.charAt(i);
4116                 isLineStart = (ch === '\r' || ch === '\n');
4117                 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
4118                     i++;
4119                 }
4120             }
4121             if (isLineStart && text.length > 0) {
4122                 lineOffsets.push(text.length);
4123             }
4124             this._lineOffsets = lineOffsets;
4125         }
4126         return this._lineOffsets;
4127     };
4128     FullTextDocument.prototype.positionAt = function (offset) {
4129         offset = Math.max(Math.min(offset, this._content.length), 0);
4130         var lineOffsets = this.getLineOffsets();
4131         var low = 0, high = lineOffsets.length;
4132         if (high === 0) {
4133             return Position.create(0, offset);
4134         }
4135         while (low < high) {
4136             var mid = Math.floor((low + high) / 2);
4137             if (lineOffsets[mid] > offset) {
4138                 high = mid;
4139             }
4140             else {
4141                 low = mid + 1;
4142             }
4143         }
4144         // low is the least x for which the line offset is larger than the current offset
4145         // or array.length if no line offset is larger than the current offset
4146         var line = low - 1;
4147         return Position.create(line, offset - lineOffsets[line]);
4148     };
4149     FullTextDocument.prototype.offsetAt = function (position) {
4150         var lineOffsets = this.getLineOffsets();
4151         if (position.line >= lineOffsets.length) {
4152             return this._content.length;
4153         }
4154         else if (position.line < 0) {
4155             return 0;
4156         }
4157         var lineOffset = lineOffsets[position.line];
4158         var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
4159         return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
4160     };
4161     Object.defineProperty(FullTextDocument.prototype, "lineCount", {
4162         get: function () {
4163             return this.getLineOffsets().length;
4164         },
4165         enumerable: true,
4166         configurable: true
4167     });
4168     return FullTextDocument;
4169 }());
4170 var Is;
4171 (function (Is) {
4172     var toString = Object.prototype.toString;
4173     function defined(value) {
4174         return typeof value !== 'undefined';
4175     }
4176     Is.defined = defined;
4177     function undefined(value) {
4178         return typeof value === 'undefined';
4179     }
4180     Is.undefined = undefined;
4181     function boolean(value) {
4182         return value === true || value === false;
4183     }
4184     Is.boolean = boolean;
4185     function string(value) {
4186         return toString.call(value) === '[object String]';
4187     }
4188     Is.string = string;
4189     function number(value) {
4190         return toString.call(value) === '[object Number]';
4191     }
4192     Is.number = number;
4193     function func(value) {
4194         return toString.call(value) === '[object Function]';
4195     }
4196     Is.func = func;
4197     function objectLiteral(value) {
4198         // Strictly speaking class instances pass this check as well. Since the LSP
4199         // doesn't use classes we ignore this for now. If we do we need to add something
4200         // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
4201         return value !== null && typeof value === 'object';
4202     }
4203     Is.objectLiteral = objectLiteral;
4204     function typedArray(value, check) {
4205         return Array.isArray(value) && value.every(check);
4206     }
4207     Is.typedArray = typedArray;
4208 })(Is || (Is = {}));
4209
4210
4211 /***/ }),
4212 /* 19 */
4213 /***/ (function(module, exports, __webpack_require__) {
4214
4215 "use strict";
4216 /* --------------------------------------------------------------------------------------------
4217  * Copyright (c) Microsoft Corporation. All rights reserved.
4218  * Licensed under the MIT License. See License.txt in the project root for license information.
4219  * ------------------------------------------------------------------------------------------ */
4220
4221 Object.defineProperty(exports, "__esModule", { value: true });
4222 const Is = __webpack_require__(20);
4223 const vscode_jsonrpc_1 = __webpack_require__(5);
4224 const protocol_implementation_1 = __webpack_require__(21);
4225 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
4226 const protocol_typeDefinition_1 = __webpack_require__(22);
4227 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
4228 const protocol_workspaceFolders_1 = __webpack_require__(23);
4229 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
4230 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
4231 const protocol_configuration_1 = __webpack_require__(24);
4232 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
4233 const protocol_colorProvider_1 = __webpack_require__(25);
4234 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
4235 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
4236 const protocol_foldingRange_1 = __webpack_require__(26);
4237 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
4238 const protocol_declaration_1 = __webpack_require__(27);
4239 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
4240 const protocol_selectionRange_1 = __webpack_require__(28);
4241 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
4242 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
4243 let __noDynamicImport;
4244 var DocumentFilter;
4245 (function (DocumentFilter) {
4246     function is(value) {
4247         let candidate = value;
4248         return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
4249     }
4250     DocumentFilter.is = is;
4251 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
4252 /**
4253  * The `client/registerCapability` request is sent from the server to the client to register a new capability
4254  * handler on the client side.
4255  */
4256 var RegistrationRequest;
4257 (function (RegistrationRequest) {
4258     RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');
4259 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
4260 /**
4261  * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
4262  * handler on the client side.
4263  */
4264 var UnregistrationRequest;
4265 (function (UnregistrationRequest) {
4266     UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');
4267 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
4268 var ResourceOperationKind;
4269 (function (ResourceOperationKind) {
4270     /**
4271      * Supports creating new files and folders.
4272      */
4273     ResourceOperationKind.Create = 'create';
4274     /**
4275      * Supports renaming existing files and folders.
4276      */
4277     ResourceOperationKind.Rename = 'rename';
4278     /**
4279      * Supports deleting existing files and folders.
4280      */
4281     ResourceOperationKind.Delete = 'delete';
4282 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
4283 var FailureHandlingKind;
4284 (function (FailureHandlingKind) {
4285     /**
4286      * Applying the workspace change is simply aborted if one of the changes provided
4287      * fails. All operations executed before the failing operation stay executed.
4288      */
4289     FailureHandlingKind.Abort = 'abort';
4290     /**
4291      * All operations are executed transactional. That means they either all
4292      * succeed or no changes at all are applied to the workspace.
4293      */
4294     FailureHandlingKind.Transactional = 'transactional';
4295     /**
4296      * If the workspace edit contains only textual file changes they are executed transactional.
4297      * If resource changes (create, rename or delete file) are part of the change the failure
4298      * handling startegy is abort.
4299      */
4300     FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
4301     /**
4302      * The client tries to undo the operations already executed. But there is no
4303      * guaruntee that this is succeeding.
4304      */
4305     FailureHandlingKind.Undo = 'undo';
4306 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
4307 /**
4308  * Defines how the host (editor) should sync
4309  * document changes to the language server.
4310  */
4311 var TextDocumentSyncKind;
4312 (function (TextDocumentSyncKind) {
4313     /**
4314      * Documents should not be synced at all.
4315      */
4316     TextDocumentSyncKind.None = 0;
4317     /**
4318      * Documents are synced by always sending the full content
4319      * of the document.
4320      */
4321     TextDocumentSyncKind.Full = 1;
4322     /**
4323      * Documents are synced by sending the full content on open.
4324      * After that only incremental updates to the document are
4325      * send.
4326      */
4327     TextDocumentSyncKind.Incremental = 2;
4328 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
4329 /**
4330  * The initialize request is sent from the client to the server.
4331  * It is sent once as the request after starting up the server.
4332  * The requests parameter is of type [InitializeParams](#InitializeParams)
4333  * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
4334  * resolves to such.
4335  */
4336 var InitializeRequest;
4337 (function (InitializeRequest) {
4338     InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');
4339 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
4340 /**
4341  * Known error codes for an `InitializeError`;
4342  */
4343 var InitializeError;
4344 (function (InitializeError) {
4345     /**
4346      * If the protocol version provided by the client can't be handled by the server.
4347      * @deprecated This initialize error got replaced by client capabilities. There is
4348      * no version handshake in version 3.0x
4349      */
4350     InitializeError.unknownProtocolVersion = 1;
4351 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
4352 /**
4353  * The intialized notification is sent from the client to the
4354  * server after the client is fully initialized and the server
4355  * is allowed to send requests from the server to the client.
4356  */
4357 var InitializedNotification;
4358 (function (InitializedNotification) {
4359     InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');
4360 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
4361 //---- Shutdown Method ----
4362 /**
4363  * A shutdown request is sent from the client to the server.
4364  * It is sent once when the client decides to shutdown the
4365  * server. The only notification that is sent after a shutdown request
4366  * is the exit event.
4367  */
4368 var ShutdownRequest;
4369 (function (ShutdownRequest) {
4370     ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');
4371 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
4372 //---- Exit Notification ----
4373 /**
4374  * The exit event is sent from the client to the server to
4375  * ask the server to exit its process.
4376  */
4377 var ExitNotification;
4378 (function (ExitNotification) {
4379     ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');
4380 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
4381 //---- Configuration notification ----
4382 /**
4383  * The configuration change notification is sent from the client to the server
4384  * when the client's configuration has changed. The notification contains
4385  * the changed configuration as defined by the language client.
4386  */
4387 var DidChangeConfigurationNotification;
4388 (function (DidChangeConfigurationNotification) {
4389     DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');
4390 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
4391 //---- Message show and log notifications ----
4392 /**
4393  * The message type
4394  */
4395 var MessageType;
4396 (function (MessageType) {
4397     /**
4398      * An error message.
4399      */
4400     MessageType.Error = 1;
4401     /**
4402      * A warning message.
4403      */
4404     MessageType.Warning = 2;
4405     /**
4406      * An information message.
4407      */
4408     MessageType.Info = 3;
4409     /**
4410      * A log message.
4411      */
4412     MessageType.Log = 4;
4413 })(MessageType = exports.MessageType || (exports.MessageType = {}));
4414 /**
4415  * The show message notification is sent from a server to a client to ask
4416  * the client to display a particular message in the user interface.
4417  */
4418 var ShowMessageNotification;
4419 (function (ShowMessageNotification) {
4420     ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');
4421 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
4422 /**
4423  * The show message request is sent from the server to the client to show a message
4424  * and a set of options actions to the user.
4425  */
4426 var ShowMessageRequest;
4427 (function (ShowMessageRequest) {
4428     ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');
4429 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
4430 /**
4431  * The log message notification is sent from the server to the client to ask
4432  * the client to log a particular message.
4433  */
4434 var LogMessageNotification;
4435 (function (LogMessageNotification) {
4436     LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');
4437 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
4438 //---- Telemetry notification
4439 /**
4440  * The telemetry event notification is sent from the server to the client to ask
4441  * the client to log telemetry data.
4442  */
4443 var TelemetryEventNotification;
4444 (function (TelemetryEventNotification) {
4445     TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');
4446 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
4447 /**
4448  * The document open notification is sent from the client to the server to signal
4449  * newly opened text documents. The document's truth is now managed by the client
4450  * and the server must not try to read the document's truth using the document's
4451  * uri. Open in this sense means it is managed by the client. It doesn't necessarily
4452  * mean that its content is presented in an editor. An open notification must not
4453  * be sent more than once without a corresponding close notification send before.
4454  * This means open and close notification must be balanced and the max open count
4455  * is one.
4456  */
4457 var DidOpenTextDocumentNotification;
4458 (function (DidOpenTextDocumentNotification) {
4459     DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');
4460 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
4461 /**
4462  * The document change notification is sent from the client to the server to signal
4463  * changes to a text document.
4464  */
4465 var DidChangeTextDocumentNotification;
4466 (function (DidChangeTextDocumentNotification) {
4467     DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');
4468 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
4469 /**
4470  * The document close notification is sent from the client to the server when
4471  * the document got closed in the client. The document's truth now exists where
4472  * the document's uri points to (e.g. if the document's uri is a file uri the
4473  * truth now exists on disk). As with the open notification the close notification
4474  * is about managing the document's content. Receiving a close notification
4475  * doesn't mean that the document was open in an editor before. A close
4476  * notification requires a previous open notification to be sent.
4477  */
4478 var DidCloseTextDocumentNotification;
4479 (function (DidCloseTextDocumentNotification) {
4480     DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');
4481 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
4482 /**
4483  * The document save notification is sent from the client to the server when
4484  * the document got saved in the client.
4485  */
4486 var DidSaveTextDocumentNotification;
4487 (function (DidSaveTextDocumentNotification) {
4488     DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');
4489 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
4490 /**
4491  * A document will save notification is sent from the client to the server before
4492  * the document is actually saved.
4493  */
4494 var WillSaveTextDocumentNotification;
4495 (function (WillSaveTextDocumentNotification) {
4496     WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');
4497 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
4498 /**
4499  * A document will save request is sent from the client to the server before
4500  * the document is actually saved. The request can return an array of TextEdits
4501  * which will be applied to the text document before it is saved. Please note that
4502  * clients might drop results if computing the text edits took too long or if a
4503  * server constantly fails on this request. This is done to keep the save fast and
4504  * reliable.
4505  */
4506 var WillSaveTextDocumentWaitUntilRequest;
4507 (function (WillSaveTextDocumentWaitUntilRequest) {
4508     WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');
4509 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
4510 //---- File eventing ----
4511 /**
4512  * The watched files notification is sent from the client to the server when
4513  * the client detects changes to file watched by the language client.
4514  */
4515 var DidChangeWatchedFilesNotification;
4516 (function (DidChangeWatchedFilesNotification) {
4517     DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');
4518 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
4519 /**
4520  * The file event type
4521  */
4522 var FileChangeType;
4523 (function (FileChangeType) {
4524     /**
4525      * The file got created.
4526      */
4527     FileChangeType.Created = 1;
4528     /**
4529      * The file got changed.
4530      */
4531     FileChangeType.Changed = 2;
4532     /**
4533      * The file got deleted.
4534      */
4535     FileChangeType.Deleted = 3;
4536 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
4537 var WatchKind;
4538 (function (WatchKind) {
4539     /**
4540      * Interested in create events.
4541      */
4542     WatchKind.Create = 1;
4543     /**
4544      * Interested in change events
4545      */
4546     WatchKind.Change = 2;
4547     /**
4548      * Interested in delete events
4549      */
4550     WatchKind.Delete = 4;
4551 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
4552 //---- Diagnostic notification ----
4553 /**
4554  * Diagnostics notification are sent from the server to the client to signal
4555  * results of validation runs.
4556  */
4557 var PublishDiagnosticsNotification;
4558 (function (PublishDiagnosticsNotification) {
4559     PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');
4560 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
4561 /**
4562  * How a completion was triggered
4563  */
4564 var CompletionTriggerKind;
4565 (function (CompletionTriggerKind) {
4566     /**
4567      * Completion was triggered by typing an identifier (24x7 code
4568      * complete), manual invocation (e.g Ctrl+Space) or via API.
4569      */
4570     CompletionTriggerKind.Invoked = 1;
4571     /**
4572      * Completion was triggered by a trigger character specified by
4573      * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
4574      */
4575     CompletionTriggerKind.TriggerCharacter = 2;
4576     /**
4577      * Completion was re-triggered as current completion list is incomplete
4578      */
4579     CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
4580 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
4581 /**
4582  * Request to request completion at a given text document position. The request's
4583  * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
4584  * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
4585  * or a Thenable that resolves to such.
4586  *
4587  * The request can delay the computation of the [`detail`](#CompletionItem.detail)
4588  * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
4589  * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
4590  * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
4591  */
4592 var CompletionRequest;
4593 (function (CompletionRequest) {
4594     CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');
4595 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
4596 /**
4597  * Request to resolve additional information for a given completion item.The request's
4598  * parameter is of type [CompletionItem](#CompletionItem) the response
4599  * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
4600  */
4601 var CompletionResolveRequest;
4602 (function (CompletionResolveRequest) {
4603     CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');
4604 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
4605 //---- Hover Support -------------------------------
4606 /**
4607  * Request to request hover information at a given text document position. The request's
4608  * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
4609  * type [Hover](#Hover) or a Thenable that resolves to such.
4610  */
4611 var HoverRequest;
4612 (function (HoverRequest) {
4613     HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');
4614 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
4615 var SignatureHelpRequest;
4616 (function (SignatureHelpRequest) {
4617     SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');
4618 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
4619 //---- Goto Definition -------------------------------------
4620 /**
4621  * A request to resolve the definition location of a symbol at a given text
4622  * document position. The request's parameter is of type [TextDocumentPosition]
4623  * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
4624  * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
4625  * to such.
4626  */
4627 var DefinitionRequest;
4628 (function (DefinitionRequest) {
4629     DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');
4630 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
4631 /**
4632  * A request to resolve project-wide references for the symbol denoted
4633  * by the given text document position. The request's parameter is of
4634  * type [ReferenceParams](#ReferenceParams) the response is of type
4635  * [Location[]](#Location) or a Thenable that resolves to such.
4636  */
4637 var ReferencesRequest;
4638 (function (ReferencesRequest) {
4639     ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');
4640 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
4641 //---- Document Highlight ----------------------------------
4642 /**
4643  * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
4644  * text document position. The request's parameter is of type [TextDocumentPosition]
4645  * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
4646  * (#DocumentHighlight) or a Thenable that resolves to such.
4647  */
4648 var DocumentHighlightRequest;
4649 (function (DocumentHighlightRequest) {
4650     DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');
4651 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
4652 //---- Document Symbol Provider ---------------------------
4653 /**
4654  * A request to list all symbols found in a given text document. The request's
4655  * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
4656  * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
4657  * that resolves to such.
4658  */
4659 var DocumentSymbolRequest;
4660 (function (DocumentSymbolRequest) {
4661     DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');
4662 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
4663 //---- Workspace Symbol Provider ---------------------------
4664 /**
4665  * A request to list project-wide symbols matching the query string given
4666  * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
4667  * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
4668  * resolves to such.
4669  */
4670 var WorkspaceSymbolRequest;
4671 (function (WorkspaceSymbolRequest) {
4672     WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');
4673 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
4674 /**
4675  * A request to provide commands for the given text document and range.
4676  */
4677 var CodeActionRequest;
4678 (function (CodeActionRequest) {
4679     CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');
4680 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
4681 /**
4682  * A request to provide code lens for the given text document.
4683  */
4684 var CodeLensRequest;
4685 (function (CodeLensRequest) {
4686     CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');
4687 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
4688 /**
4689  * A request to resolve a command for a given code lens.
4690  */
4691 var CodeLensResolveRequest;
4692 (function (CodeLensResolveRequest) {
4693     CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');
4694 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
4695 /**
4696  * A request to to format a whole document.
4697  */
4698 var DocumentFormattingRequest;
4699 (function (DocumentFormattingRequest) {
4700     DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');
4701 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
4702 /**
4703  * A request to to format a range in a document.
4704  */
4705 var DocumentRangeFormattingRequest;
4706 (function (DocumentRangeFormattingRequest) {
4707     DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');
4708 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
4709 /**
4710  * A request to format a document on type.
4711  */
4712 var DocumentOnTypeFormattingRequest;
4713 (function (DocumentOnTypeFormattingRequest) {
4714     DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');
4715 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
4716 /**
4717  * A request to rename a symbol.
4718  */
4719 var RenameRequest;
4720 (function (RenameRequest) {
4721     RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');
4722 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
4723 /**
4724  * A request to test and perform the setup necessary for a rename.
4725  */
4726 var PrepareRenameRequest;
4727 (function (PrepareRenameRequest) {
4728     PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');
4729 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
4730 /**
4731  * A request to provide document links
4732  */
4733 var DocumentLinkRequest;
4734 (function (DocumentLinkRequest) {
4735     DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');
4736 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
4737 /**
4738  * Request to resolve additional information for a given document link. The request's
4739  * parameter is of type [DocumentLink](#DocumentLink) the response
4740  * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
4741  */
4742 var DocumentLinkResolveRequest;
4743 (function (DocumentLinkResolveRequest) {
4744     DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');
4745 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
4746 /**
4747  * A request send from the client to the server to execute a command. The request might return
4748  * a workspace edit which the client will apply to the workspace.
4749  */
4750 var ExecuteCommandRequest;
4751 (function (ExecuteCommandRequest) {
4752     ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');
4753 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
4754 /**
4755  * A request sent from the server to the client to modified certain resources.
4756  */
4757 var ApplyWorkspaceEditRequest;
4758 (function (ApplyWorkspaceEditRequest) {
4759     ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');
4760 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
4761
4762
4763 /***/ }),
4764 /* 20 */
4765 /***/ (function(module, exports, __webpack_require__) {
4766
4767 "use strict";
4768 /* --------------------------------------------------------------------------------------------
4769  * Copyright (c) Microsoft Corporation. All rights reserved.
4770  * Licensed under the MIT License. See License.txt in the project root for license information.
4771  * ------------------------------------------------------------------------------------------ */
4772
4773 Object.defineProperty(exports, "__esModule", { value: true });
4774 function boolean(value) {
4775     return value === true || value === false;
4776 }
4777 exports.boolean = boolean;
4778 function string(value) {
4779     return typeof value === 'string' || value instanceof String;
4780 }
4781 exports.string = string;
4782 function number(value) {
4783     return typeof value === 'number' || value instanceof Number;
4784 }
4785 exports.number = number;
4786 function error(value) {
4787     return value instanceof Error;
4788 }
4789 exports.error = error;
4790 function func(value) {
4791     return typeof value === 'function';
4792 }
4793 exports.func = func;
4794 function array(value) {
4795     return Array.isArray(value);
4796 }
4797 exports.array = array;
4798 function stringArray(value) {
4799     return array(value) && value.every(elem => string(elem));
4800 }
4801 exports.stringArray = stringArray;
4802 function typedArray(value, check) {
4803     return Array.isArray(value) && value.every(check);
4804 }
4805 exports.typedArray = typedArray;
4806 function thenable(value) {
4807     return value && func(value.then);
4808 }
4809 exports.thenable = thenable;
4810
4811
4812 /***/ }),
4813 /* 21 */
4814 /***/ (function(module, exports, __webpack_require__) {
4815
4816 "use strict";
4817 /* --------------------------------------------------------------------------------------------
4818  * Copyright (c) Microsoft Corporation. All rights reserved.
4819  * Licensed under the MIT License. See License.txt in the project root for license information.
4820  * ------------------------------------------------------------------------------------------ */
4821
4822 Object.defineProperty(exports, "__esModule", { value: true });
4823 const vscode_jsonrpc_1 = __webpack_require__(5);
4824 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
4825 let __noDynamicImport;
4826 /**
4827  * A request to resolve the implementation locations of a symbol at a given text
4828  * document position. The request's parameter is of type [TextDocumentPositioParams]
4829  * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
4830  * Thenable that resolves to such.
4831  */
4832 var ImplementationRequest;
4833 (function (ImplementationRequest) {
4834     ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');
4835 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
4836
4837
4838 /***/ }),
4839 /* 22 */
4840 /***/ (function(module, exports, __webpack_require__) {
4841
4842 "use strict";
4843 /* --------------------------------------------------------------------------------------------
4844  * Copyright (c) Microsoft Corporation. All rights reserved.
4845  * Licensed under the MIT License. See License.txt in the project root for license information.
4846  * ------------------------------------------------------------------------------------------ */
4847
4848 Object.defineProperty(exports, "__esModule", { value: true });
4849 const vscode_jsonrpc_1 = __webpack_require__(5);
4850 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
4851 let __noDynamicImport;
4852 /**
4853  * A request to resolve the type definition locations of a symbol at a given text
4854  * document position. The request's parameter is of type [TextDocumentPositioParams]
4855  * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
4856  * Thenable that resolves to such.
4857  */
4858 var TypeDefinitionRequest;
4859 (function (TypeDefinitionRequest) {
4860     TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');
4861 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
4862
4863
4864 /***/ }),
4865 /* 23 */
4866 /***/ (function(module, exports, __webpack_require__) {
4867
4868 "use strict";
4869 /* --------------------------------------------------------------------------------------------
4870  * Copyright (c) Microsoft Corporation. All rights reserved.
4871  * Licensed under the MIT License. See License.txt in the project root for license information.
4872  * ------------------------------------------------------------------------------------------ */
4873
4874 Object.defineProperty(exports, "__esModule", { value: true });
4875 const vscode_jsonrpc_1 = __webpack_require__(5);
4876 /**
4877  * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
4878  */
4879 var WorkspaceFoldersRequest;
4880 (function (WorkspaceFoldersRequest) {
4881     WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');
4882 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
4883 /**
4884  * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
4885  * folder configuration changes.
4886  */
4887 var DidChangeWorkspaceFoldersNotification;
4888 (function (DidChangeWorkspaceFoldersNotification) {
4889     DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');
4890 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
4891
4892
4893 /***/ }),
4894 /* 24 */
4895 /***/ (function(module, exports, __webpack_require__) {
4896
4897 "use strict";
4898 /* --------------------------------------------------------------------------------------------
4899  * Copyright (c) Microsoft Corporation. All rights reserved.
4900  * Licensed under the MIT License. See License.txt in the project root for license information.
4901  * ------------------------------------------------------------------------------------------ */
4902
4903 Object.defineProperty(exports, "__esModule", { value: true });
4904 const vscode_jsonrpc_1 = __webpack_require__(5);
4905 /**
4906  * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
4907  * configuration setting.
4908  *
4909  * This pull model replaces the old push model were the client signaled configuration change via an
4910  * event. If the server still needs to react to configuration changes (since the server caches the
4911  * result of `workspace/configuration` requests) the server should register for an empty configuration
4912  * change event and empty the cache if such an event is received.
4913  */
4914 var ConfigurationRequest;
4915 (function (ConfigurationRequest) {
4916     ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');
4917 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
4918
4919
4920 /***/ }),
4921 /* 25 */
4922 /***/ (function(module, exports, __webpack_require__) {
4923
4924 "use strict";
4925 /* --------------------------------------------------------------------------------------------
4926  * Copyright (c) Microsoft Corporation. All rights reserved.
4927  * Licensed under the MIT License. See License.txt in the project root for license information.
4928  * ------------------------------------------------------------------------------------------ */
4929
4930 Object.defineProperty(exports, "__esModule", { value: true });
4931 const vscode_jsonrpc_1 = __webpack_require__(5);
4932 /**
4933  * A request to list all color symbols found in a given text document. The request's
4934  * parameter is of type [DocumentColorParams](#DocumentColorParams) the
4935  * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4936  * that resolves to such.
4937  */
4938 var DocumentColorRequest;
4939 (function (DocumentColorRequest) {
4940     DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');
4941 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
4942 /**
4943  * A request to list all presentation for a color. The request's
4944  * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
4945  * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4946  * that resolves to such.
4947  */
4948 var ColorPresentationRequest;
4949 (function (ColorPresentationRequest) {
4950     ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');
4951 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
4952
4953
4954 /***/ }),
4955 /* 26 */
4956 /***/ (function(module, exports, __webpack_require__) {
4957
4958 "use strict";
4959
4960 /*---------------------------------------------------------------------------------------------
4961  *  Copyright (c) Microsoft Corporation. All rights reserved.
4962  *  Licensed under the MIT License. See License.txt in the project root for license information.
4963  *--------------------------------------------------------------------------------------------*/
4964 Object.defineProperty(exports, "__esModule", { value: true });
4965 const vscode_jsonrpc_1 = __webpack_require__(5);
4966 /**
4967  * Enum of known range kinds
4968  */
4969 var FoldingRangeKind;
4970 (function (FoldingRangeKind) {
4971     /**
4972      * Folding range for a comment
4973      */
4974     FoldingRangeKind["Comment"] = "comment";
4975     /**
4976      * Folding range for a imports or includes
4977      */
4978     FoldingRangeKind["Imports"] = "imports";
4979     /**
4980      * Folding range for a region (e.g. `#region`)
4981      */
4982     FoldingRangeKind["Region"] = "region";
4983 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
4984 /**
4985  * A request to provide folding ranges in a document. The request's
4986  * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
4987  * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
4988  * that resolves to such.
4989  */
4990 var FoldingRangeRequest;
4991 (function (FoldingRangeRequest) {
4992     FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');
4993 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
4994
4995
4996 /***/ }),
4997 /* 27 */
4998 /***/ (function(module, exports, __webpack_require__) {
4999
5000 "use strict";
5001 /* --------------------------------------------------------------------------------------------
5002  * Copyright (c) Microsoft Corporation. All rights reserved.
5003  * Licensed under the MIT License. See License.txt in the project root for license information.
5004  * ------------------------------------------------------------------------------------------ */
5005
5006 Object.defineProperty(exports, "__esModule", { value: true });
5007 const vscode_jsonrpc_1 = __webpack_require__(5);
5008 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
5009 let __noDynamicImport;
5010 /**
5011  * A request to resolve the type definition locations of a symbol at a given text
5012  * document position. The request's parameter is of type [TextDocumentPositioParams]
5013  * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
5014  * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
5015  * to such.
5016  */
5017 var DeclarationRequest;
5018 (function (DeclarationRequest) {
5019     DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');
5020 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
5021
5022
5023 /***/ }),
5024 /* 28 */
5025 /***/ (function(module, exports, __webpack_require__) {
5026
5027 "use strict";
5028
5029 /*---------------------------------------------------------------------------------------------
5030  *  Copyright (c) Microsoft Corporation. All rights reserved.
5031  *  Licensed under the MIT License. See License.txt in the project root for license information.
5032  *--------------------------------------------------------------------------------------------*/
5033 Object.defineProperty(exports, "__esModule", { value: true });
5034 const vscode_jsonrpc_1 = __webpack_require__(5);
5035 /**
5036  * A request to provide selection ranges in a document. The request's
5037  * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
5038  * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
5039  * that resolves to such.
5040  */
5041 var SelectionRangeRequest;
5042 (function (SelectionRangeRequest) {
5043     SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/selectionRange');
5044 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
5045
5046
5047 /***/ }),
5048 /* 29 */
5049 /***/ (function(module, exports, __webpack_require__) {
5050
5051 "use strict";
5052 /* --------------------------------------------------------------------------------------------
5053  * Copyright (c) TypeFox and others. All rights reserved.
5054  * Licensed under the MIT License. See License.txt in the project root for license information.
5055  * ------------------------------------------------------------------------------------------ */
5056
5057 Object.defineProperty(exports, "__esModule", { value: true });
5058 const vscode_jsonrpc_1 = __webpack_require__(5);
5059 /**
5060  * The direction of a call hierarchy request.
5061  */
5062 var CallHierarchyDirection;
5063 (function (CallHierarchyDirection) {
5064     /**
5065      * The callers
5066      */
5067     CallHierarchyDirection.CallsFrom = 1;
5068     /**
5069      * The callees
5070      */
5071     CallHierarchyDirection.CallsTo = 2;
5072 })(CallHierarchyDirection = exports.CallHierarchyDirection || (exports.CallHierarchyDirection = {}));
5073 /**
5074  * Request to provide the call hierarchy at a given text document position.
5075  *
5076  * The request's parameter is of type [CallHierarchyParams](#CallHierarchyParams). The response
5077  * is of type [CallHierarchyCall[]](#CallHierarchyCall) or a Thenable that resolves to such.
5078  *
5079  * Evaluates the symbol defined (or referenced) at the given position, and returns all incoming or outgoing calls to the symbol(s).
5080  */
5081 var CallHierarchyRequest;
5082 (function (CallHierarchyRequest) {
5083     CallHierarchyRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/callHierarchy');
5084 })(CallHierarchyRequest = exports.CallHierarchyRequest || (exports.CallHierarchyRequest = {}));
5085
5086
5087 /***/ }),
5088 /* 30 */
5089 /***/ (function(module, exports, __webpack_require__) {
5090
5091 "use strict";
5092 /* --------------------------------------------------------------------------------------------
5093  * Copyright (c) Microsoft Corporation. All rights reserved.
5094  * Licensed under the MIT License. See License.txt in the project root for license information.
5095  * ------------------------------------------------------------------------------------------ */
5096
5097 Object.defineProperty(exports, "__esModule", { value: true });
5098 const vscode_jsonrpc_1 = __webpack_require__(5);
5099 /**
5100  * The `window/progress/start` notification is sent from the server to the client
5101  * to initiate a progress.
5102  */
5103 var ProgressStartNotification;
5104 (function (ProgressStartNotification) {
5105     ProgressStartNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/start');
5106 })(ProgressStartNotification = exports.ProgressStartNotification || (exports.ProgressStartNotification = {}));
5107 /**
5108  * The `window/progress/report` notification is sent from the server to the client
5109  * to initiate a progress.
5110  */
5111 var ProgressReportNotification;
5112 (function (ProgressReportNotification) {
5113     ProgressReportNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/report');
5114 })(ProgressReportNotification = exports.ProgressReportNotification || (exports.ProgressReportNotification = {}));
5115 /**
5116  * The `window/progress/done` notification is sent from the server to the client
5117  * to initiate a progress.
5118  */
5119 var ProgressDoneNotification;
5120 (function (ProgressDoneNotification) {
5121     ProgressDoneNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/done');
5122 })(ProgressDoneNotification = exports.ProgressDoneNotification || (exports.ProgressDoneNotification = {}));
5123 /**
5124  * The `window/progress/cancel` notification is sent client to the server to cancel a progress
5125  * initiated on the server side.
5126  */
5127 var ProgressCancelNotification;
5128 (function (ProgressCancelNotification) {
5129     ProgressCancelNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/cancel');
5130 })(ProgressCancelNotification = exports.ProgressCancelNotification || (exports.ProgressCancelNotification = {}));
5131
5132
5133 /***/ }),
5134 /* 31 */
5135 /***/ (function(module, exports, __webpack_require__) {
5136
5137 "use strict";
5138
5139 /*---------------------------------------------------------------------------------------------
5140  *  Copyright (c) Microsoft Corporation. All rights reserved.
5141  *  Licensed under the MIT License. See License.txt in the project root for license information.
5142  *--------------------------------------------------------------------------------------------*/
5143 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5144     return new (P || (P = Promise))(function (resolve, reject) {
5145         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5146         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5147         function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
5148         step((generator = generator.apply(thisArg, _arguments || [])).next());
5149     });
5150 };
5151 Object.defineProperty(exports, "__esModule", { value: true });
5152 const coc_nvim_1 = __webpack_require__(1);
5153 const vscode_languageserver_protocol_1 = __webpack_require__(4);
5154 function activateTagClosing(tagProvider, supportedLanguages, configName) {
5155     let disposables = [];
5156     coc_nvim_1.workspace.onDidChangeTextDocument(event => {
5157         const document = coc_nvim_1.workspace.getDocument(event.textDocument.uri);
5158         if (!document) {
5159             return;
5160         }
5161         onDidChangeTextDocument(document.textDocument, event.contentChanges)
5162             .catch(() => {
5163             // noop
5164         });
5165     }, null, disposables);
5166     let isEnabled = false;
5167     updateEnabledState().catch(() => {
5168         // noop
5169     });
5170     disposables.push(coc_nvim_1.workspace.registerAutocmd({
5171         event: ['BufEnter'],
5172         request: false,
5173         callback: updateEnabledState,
5174     }));
5175     let timeout;
5176     function updateEnabledState() {
5177         return __awaiter(this, void 0, void 0, function* () {
5178             isEnabled = false;
5179             const doc = yield coc_nvim_1.workspace.document;
5180             if (!doc) {
5181                 return;
5182             }
5183             const document = doc.textDocument;
5184             if (supportedLanguages.indexOf(document.languageId) === -1) {
5185                 return;
5186             }
5187             if (!coc_nvim_1.workspace.getConfiguration(undefined, document.uri).get(configName)) {
5188                 return;
5189             }
5190             isEnabled = true;
5191         });
5192     }
5193     function onDidChangeTextDocument(document, changes) {
5194         return __awaiter(this, void 0, void 0, function* () {
5195             if (!isEnabled) {
5196                 return;
5197             }
5198             const doc = yield coc_nvim_1.workspace.document;
5199             if (!doc) {
5200                 return;
5201             }
5202             let activeDocument = doc.textDocument;
5203             if (document !== activeDocument || changes.length === 0) {
5204                 return;
5205             }
5206             if (typeof timeout !== 'undefined') {
5207                 clearTimeout(timeout);
5208             }
5209             let lastChange = changes[changes.length - 1];
5210             let lastCharacter = lastChange.text[lastChange.text.length - 1];
5211             if (lastChange.rangeLength > 0 || lastCharacter !== '>' && lastCharacter !== '/') {
5212                 return;
5213             }
5214             let rangeStart = lastChange.range.start;
5215             let version = document.version;
5216             timeout = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
5217                 let position = vscode_languageserver_protocol_1.Position.create(rangeStart.line, rangeStart.character + lastChange.text.length);
5218                 tagProvider(document, position).then((text) => __awaiter(this, void 0, void 0, function* () {
5219                     if (text && isEnabled) {
5220                         const doc = yield coc_nvim_1.workspace.document;
5221                         if (!doc) {
5222                             return;
5223                         }
5224                         let activeDocument = doc.textDocument;
5225                         if (document === activeDocument && activeDocument.version === version) {
5226                             coc_nvim_1.snippetManager.insertSnippet(text, false, vscode_languageserver_protocol_1.Range.create(position, position))
5227                                 .catch(() => {
5228                                 // noop
5229                             });
5230                         }
5231                     }
5232                 }));
5233                 timeout = undefined;
5234             }), 0);
5235         });
5236     }
5237     return coc_nvim_1.Disposable.create(() => {
5238         disposables.forEach(disposable => {
5239             disposable.dispose();
5240         });
5241         disposables = [];
5242     });
5243 }
5244 exports.activateTagClosing = activateTagClosing;
5245
5246
5247 /***/ })
5248 /******/ ])));