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