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