minor adjustment to readme
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-eslint / .release / lib / server / index.js
1 /******/ (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  * Copyright (c) Microsoft Corporation. All rights reserved.
94  * Licensed under the MIT License. See License.txt in the project root for license information.
95  * ------------------------------------------------------------------------------------------ */
96
97 Object.defineProperty(exports, "__esModule", { value: true });
98 const tslib_1 = __webpack_require__(1);
99 const os = tslib_1.__importStar(__webpack_require__(2));
100 const path = tslib_1.__importStar(__webpack_require__(3));
101 const vscode_languageserver_1 = __webpack_require__(4);
102 const vscode_uri_1 = __webpack_require__(38);
103 const types_1 = __webpack_require__(39);
104 const util_1 = __webpack_require__(40);
105 const requireFunc =  true ? require : undefined;
106 var CommandIds;
107 (function (CommandIds) {
108     CommandIds.applySingleFix = 'eslint.applySingleFix';
109     CommandIds.applySameFixes = 'eslint.applySameFixes';
110     CommandIds.applyAllFixes = 'eslint.applyAllFixes';
111     CommandIds.applyAutoFix = 'eslint.applyAutoFix';
112     CommandIds.applyDisableLine = 'eslint.applyDisableLine';
113     CommandIds.applyDisableFile = 'eslint.applyDisableFile';
114     CommandIds.openRuleDoc = 'eslint.openRuleDoc';
115 })(CommandIds || (CommandIds = {}));
116 var OpenESLintDocRequest;
117 (function (OpenESLintDocRequest) {
118     OpenESLintDocRequest.type = new vscode_languageserver_1.RequestType('eslint/openDoc');
119 })(OpenESLintDocRequest || (OpenESLintDocRequest = {}));
120 var Status;
121 (function (Status) {
122     Status[Status["ok"] = 1] = "ok";
123     Status[Status["warn"] = 2] = "warn";
124     Status[Status["error"] = 3] = "error";
125 })(Status || (Status = {}));
126 var StatusNotification;
127 (function (StatusNotification) {
128     StatusNotification.type = new vscode_languageserver_1.NotificationType('eslint/status');
129 })(StatusNotification || (StatusNotification = {}));
130 var NoConfigRequest;
131 (function (NoConfigRequest) {
132     NoConfigRequest.type = new vscode_languageserver_1.RequestType('eslint/noConfig');
133 })(NoConfigRequest || (NoConfigRequest = {}));
134 var NoESLintLibraryRequest;
135 (function (NoESLintLibraryRequest) {
136     NoESLintLibraryRequest.type = new vscode_languageserver_1.RequestType('eslint/noLibrary');
137 })(NoESLintLibraryRequest || (NoESLintLibraryRequest = {}));
138 class CodeActionResult {
139     constructor() {
140         this._actions = new Map();
141     }
142     get(ruleId) {
143         let result = this._actions.get(ruleId);
144         if (result === undefined) {
145             result = { fixes: [] };
146             this._actions.set(ruleId, result);
147         }
148         return result;
149     }
150     set fixAll(action) {
151         this._fixAll = action;
152     }
153     all() {
154         let result = [];
155         for (let actions of this._actions.values()) {
156             result.push(...actions.fixes);
157             if (actions.disable) {
158                 result.push(actions.disable);
159             }
160             if (actions.fixAll) {
161                 result.push(actions.fixAll);
162             }
163             if (actions.disableFile) {
164                 result.push(actions.disableFile);
165             }
166             if (actions.showDocumentation) {
167                 result.push(actions.showDocumentation);
168             }
169         }
170         if (this._fixAll !== undefined) {
171             result.push(this._fixAll);
172         }
173         return result;
174     }
175     get length() {
176         let result = 0;
177         for (let actions of this._actions.values()) {
178             result += actions.fixes.length;
179         }
180         return result;
181     }
182 }
183 function makeDiagnostic(problem) {
184     let message = problem.ruleId != null
185         ? `${problem.message} (${problem.ruleId})`
186         : `${problem.message}`;
187     let startLine = Math.max(0, problem.line - 1);
188     let startChar = Math.max(0, problem.column - 1);
189     let endLine = problem.endLine != null ? Math.max(0, problem.endLine - 1) : startLine;
190     let endChar = problem.endColumn != null ? Math.max(0, problem.endColumn - 1) : startChar;
191     return {
192         message,
193         severity: convertSeverity(problem.severity),
194         source: 'eslint',
195         range: {
196             start: { line: startLine, character: startChar },
197             end: { line: endLine, character: endChar }
198         },
199         code: problem.ruleId
200     };
201 }
202 function computeKey(diagnostic) {
203     let range = diagnostic.range;
204     return `[${range.start.line},${range.start.character},${range.end.line},${range.end.character}]-${diagnostic.code}`;
205 }
206 let codeActions = new Map();
207 function recordCodeAction(document, diagnostic, problem) {
208     if (!problem.ruleId) {
209         return;
210     }
211     let uri = document.uri;
212     let edits = codeActions.get(uri);
213     if (!edits) {
214         edits = new Map();
215         codeActions.set(uri, edits);
216     }
217     edits.set(computeKey(diagnostic), { label: `Fix this ${problem.ruleId} problem`, documentVersion: document.version, ruleId: problem.ruleId, edit: problem.fix, line: problem.line });
218 }
219 function convertSeverity(severity) {
220     switch (severity) {
221         // Eslint 1 is warning
222         case 1:
223             return vscode_languageserver_1.DiagnosticSeverity.Warning;
224         case 2:
225             return vscode_languageserver_1.DiagnosticSeverity.Error;
226         default:
227             return vscode_languageserver_1.DiagnosticSeverity.Error;
228     }
229 }
230 /**
231  * Check if the path follows this pattern: `\\hostname\sharename`.
232  *
233  * @see https://msdn.microsoft.com/en-us/library/gg465305.aspx
234  * @return A boolean indication if the path is a UNC path, on none-windows
235  * always false.
236  */
237 function isUNC(path) {
238     if (process.platform !== 'win32') {
239         // UNC is a windows concept
240         return false;
241     }
242     if (!path || path.length < 5) {
243         // at least \\a\b
244         return false;
245     }
246     let code = path.charCodeAt(0);
247     if (code !== 92 /* Backslash */) {
248         return false;
249     }
250     code = path.charCodeAt(1);
251     if (code !== 92 /* Backslash */) {
252         return false;
253     }
254     let pos = 2;
255     let start = pos;
256     for (; pos < path.length; pos++) {
257         code = path.charCodeAt(pos);
258         if (code === 92 /* Backslash */) {
259             break;
260         }
261     }
262     if (start === pos) {
263         return false;
264     }
265     code = path.charCodeAt(pos + 1);
266     if (isNaN(code) || code === 92 /* Backslash */) {
267         return false;
268     }
269     return true;
270 }
271 function getFileSystemPath(uri) {
272     let result = uri.fsPath;
273     if (process.platform === 'win32' && result.length >= 2 && result[1] === ':') {
274         // Node by default uses an upper case drive letter and ESLint uses
275         // === to compare pathes which results in the equal check failing
276         // if the drive letter is lower case in th URI. Ensure upper case.
277         return result[0].toUpperCase() + result.substr(1);
278     }
279     else {
280         return result;
281     }
282 }
283 function getFilePath(documentOrUri) {
284     if (!documentOrUri) {
285         return undefined;
286     }
287     let uri = types_1.Is.string(documentOrUri)
288         ? vscode_uri_1.URI.parse(documentOrUri)
289         : vscode_uri_1.URI.parse(documentOrUri.uri);
290     if (uri.scheme !== 'file') {
291         return undefined;
292     }
293     return getFileSystemPath(uri);
294 }
295 const exitCalled = new vscode_languageserver_1.NotificationType('eslint/exitCalled');
296 const nodeExit = process.exit;
297 process.exit = ((code) => {
298     let stack = new Error('stack');
299     connection.sendNotification(exitCalled, [code ? code : 0, stack.stack]);
300     setTimeout(() => {
301         nodeExit(code);
302     }, 1000);
303 });
304 process.on('uncaughtException', (error) => {
305     let message;
306     if (error) {
307         if (typeof error.stack === 'string') {
308             message = error.stack;
309         }
310         else if (typeof error.message === 'string') {
311             message = error.message;
312         }
313         else if (typeof error === 'string') {
314             message = error;
315         }
316         if (!message) {
317             try {
318                 message = JSON.stringify(error, undefined, 4);
319             }
320             catch (e) {
321                 // Should not happen.
322             }
323         }
324     }
325     connection.console.error(`Uncaught exception recevied.
326   ${message || ''}`);
327 });
328 let connection = vscode_languageserver_1.createConnection();
329 connection.console.info(`ESLint server running in node ${process.version}`);
330 let documents = new vscode_languageserver_1.TextDocuments();
331 let _globalNpmPath;
332 function globalNpmPath() {
333     if (_globalNpmPath === void 0) {
334         _globalNpmPath = vscode_languageserver_1.Files.resolveGlobalNodePath(trace);
335         if (_globalNpmPath === void 0) {
336             _globalNpmPath = null;
337         }
338     }
339     if (_globalNpmPath === null) {
340         return undefined;
341     }
342     return _globalNpmPath;
343 }
344 let _globalYarnPath;
345 function globalYarnPath() {
346     if (_globalYarnPath === void 0) {
347         _globalYarnPath = vscode_languageserver_1.Files.resolveGlobalYarnPath(trace);
348         if (_globalYarnPath === void 0) {
349             _globalYarnPath = null;
350         }
351     }
352     if (_globalYarnPath === null) {
353         return undefined;
354     }
355     return _globalYarnPath;
356 }
357 let path2Library = new Map();
358 let document2Settings = new Map();
359 let ruleDocData = {
360     handled: new Set(),
361     urls: new Map()
362 };
363 function resolveSettings(document) {
364     let uri = document.uri;
365     let resultPromise = document2Settings.get(uri);
366     if (resultPromise) {
367         return resultPromise;
368     }
369     resultPromise = connection.workspace
370         .getConfiguration({ scopeUri: uri, section: '' })
371         .then((settings) => {
372         let nodePath;
373         if (settings.nodePath) {
374             nodePath = settings.nodePath;
375             if (nodePath.startsWith('~')) {
376                 nodePath = nodePath.replace(/^~/, os.homedir());
377             }
378             if (!path.isAbsolute(nodePath)) {
379                 nodePath = path.join(vscode_uri_1.URI.parse(settings.workspaceFolder.uri).fsPath, nodePath);
380             }
381         }
382         else if (settings.packageManager === 'npm') {
383             nodePath = globalNpmPath();
384         }
385         else if (settings.packageManager === 'yarn') {
386             nodePath = globalYarnPath();
387         }
388         let uri = vscode_uri_1.URI.parse(document.uri);
389         let promise;
390         let directory;
391         if (uri.scheme === 'file') {
392             directory = path.dirname(uri.fsPath);
393         }
394         else {
395             directory = settings.workspaceFolder ? vscode_uri_1.URI.parse(settings.workspaceFolder.uri).fsPath : undefined;
396         }
397         promise = util_1.resolveModule('eslint', directory, nodePath);
398         return promise.then(path => {
399             let library = path2Library.get(path);
400             if (!library) {
401                 library = requireFunc(path);
402                 if (!library.CLIEngine) {
403                     settings.validate = false;
404                     connection.console.error(`The eslint library loaded from ${path} doesn\'t export a CLIEngine. You need at least eslint@1.0.0`);
405                 }
406                 else {
407                     connection.console.info(`ESLint library loaded from: ${path}`);
408                     settings.library = library;
409                 }
410                 path2Library.set(path, library);
411             }
412             else {
413                 settings.library = library;
414             }
415             return settings;
416         }, () => {
417             settings.validate = false;
418             connection.sendRequest(NoESLintLibraryRequest.type, {
419                 source: { uri: document.uri }
420             });
421             return settings;
422         });
423     });
424     document2Settings.set(uri, resultPromise);
425     return resultPromise;
426 }
427 var Request;
428 (function (Request) {
429     function is(value) {
430         let candidate = value;
431         return (candidate &&
432             !!candidate.token &&
433             !!candidate.resolve &&
434             !!candidate.reject);
435     }
436     Request.is = is;
437 })(Request || (Request = {}));
438 var Thenable;
439 (function (Thenable) {
440     function is(value) {
441         let candidate = value;
442         return candidate && typeof candidate.then === 'function';
443     }
444     Thenable.is = is;
445 })(Thenable || (Thenable = {}));
446 class BufferedMessageQueue {
447     constructor(connection) {
448         this.connection = connection;
449         this.queue = [];
450         this.requestHandlers = new Map();
451         this.notificationHandlers = new Map();
452     }
453     registerRequest(type, handler, versionProvider) {
454         this.connection.onRequest(type, (params, token) => {
455             return new Promise((resolve, reject) => {
456                 this.queue.push({
457                     method: type.method,
458                     params,
459                     documentVersion: versionProvider
460                         ? versionProvider(params)
461                         : undefined,
462                     resolve,
463                     reject,
464                     token
465                 });
466                 this.trigger();
467             });
468         });
469         this.requestHandlers.set(type.method, { handler, versionProvider });
470     }
471     registerNotification(type, handler, versionProvider) {
472         connection.onNotification(type, params => {
473             this.queue.push({
474                 method: type.method,
475                 params,
476                 documentVersion: versionProvider ? versionProvider(params) : undefined
477             });
478             this.trigger();
479         });
480         this.notificationHandlers.set(type.method, { handler, versionProvider });
481     }
482     addNotificationMessage(type, params, version) {
483         this.queue.push({
484             method: type.method,
485             params,
486             documentVersion: version
487         });
488         this.trigger();
489     }
490     onNotification(type, handler, versionProvider) {
491         this.notificationHandlers.set(type.method, { handler, versionProvider });
492     }
493     trigger() {
494         if (this.timer || this.queue.length === 0) {
495             return;
496         }
497         this.timer = setImmediate(() => {
498             this.timer = undefined;
499             this.processQueue();
500         });
501     }
502     processQueue() {
503         let message = this.queue.shift();
504         if (!message) {
505             return;
506         }
507         if (Request.is(message)) {
508             let requestMessage = message;
509             if (requestMessage.token.isCancellationRequested) {
510                 requestMessage.reject(
511                 // tslint:disable-next-line: no-inferred-empty-object-type
512                 new vscode_languageserver_1.ResponseError(vscode_languageserver_1.ErrorCodes.RequestCancelled, 'Request got cancelled'));
513                 return;
514             }
515             let elem = this.requestHandlers.get(requestMessage.method);
516             if (elem.versionProvider &&
517                 requestMessage.documentVersion !== void 0 &&
518                 requestMessage.documentVersion !==
519                     elem.versionProvider(requestMessage.params)) {
520                 requestMessage.reject(
521                 // tslint:disable-next-line: no-inferred-empty-object-type
522                 new vscode_languageserver_1.ResponseError(vscode_languageserver_1.ErrorCodes.RequestCancelled, 'Request got cancelled'));
523                 return;
524             }
525             let result = elem.handler(requestMessage.params, requestMessage.token);
526             if (Thenable.is(result)) {
527                 result.then(value => {
528                     requestMessage.resolve(value);
529                 }, error => {
530                     requestMessage.reject(error);
531                 });
532             }
533             else {
534                 requestMessage.resolve(result);
535             }
536         }
537         else {
538             let notificationMessage = message;
539             let elem = this.notificationHandlers.get(notificationMessage.method);
540             if (elem.versionProvider &&
541                 notificationMessage.documentVersion !== void 0 &&
542                 notificationMessage.documentVersion !==
543                     elem.versionProvider(notificationMessage.params)) {
544                 return;
545             }
546             elem.handler(notificationMessage.params);
547         }
548         this.trigger();
549     }
550 }
551 let messageQueue = new BufferedMessageQueue(connection);
552 var ValidateNotification;
553 (function (ValidateNotification) {
554     ValidateNotification.type = new vscode_languageserver_1.NotificationType('eslint/validate');
555 })(ValidateNotification || (ValidateNotification = {}));
556 messageQueue.onNotification(ValidateNotification.type, document => {
557     validateSingle(document, true);
558 }, (document) => {
559     return document.version;
560 });
561 // The documents manager listen for text document create, change
562 // and close on the connection
563 documents.listen(connection);
564 documents.onDidOpen(event => {
565     resolveSettings(event.document).then(settings => {
566         if (!settings.validate) {
567             return;
568         }
569         if (settings.run === 'onSave') {
570             messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
571         }
572     });
573 });
574 // A text document has changed. Validate the document according the run setting.
575 documents.onDidChangeContent(event => {
576     resolveSettings(event.document).then(settings => {
577         if (!settings.validate || settings.run !== 'onType') {
578             return;
579         }
580         messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
581     });
582 });
583 documents.onWillSaveWaitUntil(event => {
584     if (event.reason === vscode_languageserver_1.TextDocumentSaveReason.AfterDelay) {
585         return [];
586     }
587     let document = event.document;
588     return resolveSettings(document).then(settings => {
589         if (!settings.autoFixOnSave) {
590             return [];
591         }
592         // If we validate on save and want to apply fixes on will save
593         // we need to validate the file.
594         if (settings.run === 'onSave') {
595             // Do not queue this since we want to get the fixes as fast as possible.
596             return validateSingle(document, false).then(() => util_1.getAllFixEdits(document, settings));
597         }
598         else {
599             return util_1.getAllFixEdits(document, settings);
600         }
601     });
602 });
603 // A text document has been saved. Validate the document according the run setting.
604 documents.onDidSave(event => {
605     resolveSettings(event.document).then(settings => {
606         if (!settings.validate || settings.run !== 'onSave') {
607             return;
608         }
609         messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
610     });
611 });
612 documents.onDidClose(event => {
613     resolveSettings(event.document).then(settings => {
614         let uri = event.document.uri;
615         document2Settings.delete(uri);
616         codeActions.delete(uri);
617         if (settings.validate) {
618             connection.sendDiagnostics({ uri, diagnostics: [] });
619         }
620     });
621 });
622 function environmentChanged() {
623     document2Settings.clear();
624     for (let document of documents.all()) {
625         messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
626     }
627 }
628 function trace(message, verbose) {
629     connection.tracer.log(message, verbose);
630 }
631 connection.onInitialize(_params => {
632     return {
633         capabilities: {
634             textDocumentSync: {
635                 openClose: true,
636                 change: vscode_languageserver_1.TextDocumentSyncKind.Full,
637                 willSaveWaitUntil: true,
638                 save: {
639                     includeText: false
640                 }
641             },
642             codeActionProvider: true,
643             executeCommandProvider: {
644                 commands: [
645                     CommandIds.applySingleFix,
646                     CommandIds.applySameFixes,
647                     CommandIds.applyAllFixes,
648                     CommandIds.applyAutoFix,
649                     CommandIds.applyDisableLine,
650                     CommandIds.applyDisableFile,
651                     CommandIds.openRuleDoc,
652                 ]
653             }
654         }
655     };
656 });
657 connection.onInitialized(() => {
658     connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type, undefined);
659 });
660 messageQueue.registerNotification(vscode_languageserver_1.DidChangeConfigurationNotification.type, _params => {
661     environmentChanged();
662 });
663 // messageQueue.registerNotification(
664 //   DidChangeWorkspaceFoldersNotification.type,
665 //   _params => {
666 //     environmentChanged()
667 //   }
668 // )
669 const singleErrorHandlers = [
670     tryHandleNoConfig,
671     tryHandleConfigError,
672     tryHandleMissingModule,
673     showErrorMessage
674 ];
675 function validateSingle(document, publishDiagnostics = true) {
676     // We validate document in a queue but open / close documents directly. So we need to deal with the
677     // fact that a document might be gone from the server.
678     if (!documents.get(document.uri)) {
679         return Promise.resolve(undefined);
680     }
681     return resolveSettings(document).then(settings => {
682         if (!settings.validate) {
683             return;
684         }
685         try {
686             validate(document, settings, publishDiagnostics);
687             connection.sendNotification(StatusNotification.type, { state: Status.ok });
688         }
689         catch (err) {
690             let status;
691             for (let handler of singleErrorHandlers) {
692                 status = handler(err, document, settings.library);
693                 if (status) {
694                     break;
695                 }
696             }
697             status = status || Status.error;
698             connection.sendNotification(StatusNotification.type, { state: status });
699         }
700     });
701 }
702 function validateMany(documents) {
703     documents.forEach(document => {
704         messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
705     });
706 }
707 function getMessage(err, document) {
708     let result = null;
709     if (typeof err.message === 'string' || err.message instanceof String) {
710         result = err.message;
711         result = result.replace(/\r?\n/g, ' ');
712         if (/^CLI: /.test(result)) {
713             result = result.substr(5);
714         }
715     }
716     else {
717         result = `An unknown error occured while validating document: ${document.uri}`;
718     }
719     return result;
720 }
721 function validate(document, settings, publishDiagnostics = true) {
722     let newOptions = Object.assign(Object.create(null), settings.options);
723     let content = document.getText();
724     let uri = document.uri;
725     let file = getFilePath(document);
726     let cwd = process.cwd();
727     try {
728         if (file) {
729             if (settings.workingDirectory) {
730                 newOptions.cwd = settings.workingDirectory.directory;
731                 if (settings.workingDirectory.changeProcessCWD) {
732                     process.chdir(settings.workingDirectory.directory);
733                 }
734             }
735             else if (settings.workspaceFolder) {
736                 let workspaceFolderUri = vscode_uri_1.URI.parse(settings.workspaceFolder.uri);
737                 if (workspaceFolderUri.scheme === 'file') {
738                     const fsPath = getFileSystemPath(workspaceFolderUri);
739                     newOptions.cwd = fsPath;
740                     process.chdir(fsPath);
741                 }
742             }
743             else if (!settings.workspaceFolder && !isUNC(file)) {
744                 let directory = path.dirname(file);
745                 if (directory) {
746                     if (path.isAbsolute(directory)) {
747                         newOptions.cwd = directory;
748                     }
749                 }
750             }
751         }
752         let cli = new settings.library.CLIEngine(newOptions);
753         // Clean previously computed code actions.
754         codeActions.delete(uri);
755         let report = cli.executeOnText(content, file);
756         let diagnostics = [];
757         if (report && report.results && Array.isArray(report.results) && report.results.length > 0) {
758             let docReport = report.results[0];
759             if (docReport.messages && Array.isArray(docReport.messages)) {
760                 docReport.messages.forEach(problem => {
761                     if (problem) {
762                         const isWarning = convertSeverity(problem.severity) === vscode_languageserver_1.DiagnosticSeverity.Warning;
763                         if (settings.quiet && isWarning) {
764                             // Filter out warnings when quiet mode is enabled
765                             return;
766                         }
767                         let diagnostic = makeDiagnostic(problem);
768                         diagnostics.push(diagnostic);
769                         if (settings.autoFix) {
770                             if (typeof cli.getRules === 'function' && problem.ruleId !== undefined && problem.fix !== undefined) {
771                                 let rule = cli.getRules().get(problem.ruleId);
772                                 if (rule !== undefined && rule.meta && typeof rule.meta.fixable == 'string') {
773                                     recordCodeAction(document, diagnostic, problem);
774                                 }
775                             }
776                             else {
777                                 recordCodeAction(document, diagnostic, problem);
778                             }
779                         }
780                     }
781                 });
782             }
783         }
784         if (publishDiagnostics) {
785             connection.sendDiagnostics({ uri, diagnostics });
786         }
787         // cache documentation urls for all rules
788         if (typeof cli.getRules === 'function' && !ruleDocData.handled.has(uri)) {
789             ruleDocData.handled.add(uri);
790             cli.getRules().forEach((rule, key) => {
791                 if (rule.meta && rule.meta.docs && types_1.Is.string(rule.meta.docs.url)) {
792                     ruleDocData.urls.set(key, rule.meta.docs.url);
793                 }
794             });
795         }
796     }
797     finally {
798         if (cwd !== process.cwd()) {
799             process.chdir(cwd);
800         }
801     }
802 }
803 let noConfigReported = new Map();
804 function isNoConfigFoundError(error) {
805     let candidate = error;
806     return (candidate.messageTemplate === 'no-config-found' ||
807         candidate.message === 'No ESLint configuration found.');
808 }
809 function tryHandleNoConfig(error, document, library) {
810     if (!isNoConfigFoundError(error)) {
811         return undefined;
812     }
813     if (!noConfigReported.has(document.uri)) {
814         connection
815             .sendRequest(NoConfigRequest.type, {
816             message: getMessage(error, document),
817             document: {
818                 uri: document.uri
819             }
820         })
821             .then(undefined, () => {
822             // noop
823         });
824         noConfigReported.set(document.uri, library);
825     }
826     return Status.warn;
827 }
828 let configErrorReported = new Map();
829 function tryHandleConfigError(error, document, library) {
830     if (!error.message) {
831         return undefined;
832     }
833     function handleFileName(filename) {
834         if (!configErrorReported.has(filename)) {
835             connection.console.error(getMessage(error, document));
836             if (!documents.get(vscode_uri_1.URI.file(filename).toString())) {
837                 connection.window.showInformationMessage(getMessage(error, document));
838             }
839             configErrorReported.set(filename, library);
840         }
841         return Status.warn;
842     }
843     let matches = /Cannot read config file:\s+(.*)\nError:\s+(.*)/.exec(error.message);
844     if (matches && matches.length === 3) {
845         return handleFileName(matches[1]);
846     }
847     matches = /(.*):\n\s*Configuration for rule \"(.*)\" is /.exec(error.message);
848     if (matches && matches.length === 3) {
849         return handleFileName(matches[1]);
850     }
851     matches = /Cannot find module '([^']*)'\nReferenced from:\s+(.*)/.exec(error.message);
852     if (matches && matches.length === 3) {
853         return handleFileName(matches[2]);
854     }
855     return undefined;
856 }
857 let missingModuleReported = new Map();
858 function tryHandleMissingModule(error, document, library) {
859     if (!error.message) {
860         return undefined;
861     }
862     function handleMissingModule(plugin, module, error) {
863         if (!missingModuleReported.has(plugin)) {
864             let fsPath = getFilePath(document);
865             missingModuleReported.set(plugin, library);
866             if (error.messageTemplate === 'plugin-missing') {
867                 connection.console.error([
868                     '',
869                     `${error.message.toString()}`,
870                     `Happened while validating ${fsPath ? fsPath : document.uri}`,
871                     `This can happen for a couple of reasons:`,
872                     `1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).`,
873                     `2. If ESLint is installed globally, then make sure ${module} is installed globally as well.`,
874                     `3. If ESLint is installed locally, then ${module} isn't installed correctly.`,
875                     '',
876                     `Consider running eslint --debug ${fsPath ? fsPath : document.uri} from a terminal to obtain a trace about the configuration files used.`
877                 ].join('\n'));
878             }
879             else {
880                 connection.console.error([
881                     `${error.message.toString()}`,
882                     `Happend while validating ${fsPath ? fsPath : document.uri}`
883                 ].join('\n'));
884             }
885         }
886         return Status.warn;
887     }
888     let matches = /Failed to load plugin (.*): Cannot find module (.*)/.exec(error.message);
889     if (matches && matches.length === 3) {
890         return handleMissingModule(matches[1], matches[2], error);
891     }
892     return undefined;
893 }
894 function showErrorMessage(error, document) {
895     connection.window.showErrorMessage(`ESLint: ${getMessage(error, document)}. Please see the 'ESLint' output channel for details.`);
896     if (types_1.Is.string(error.stack)) {
897         connection.console.error('ESLint stack trace:');
898         connection.console.error(error.stack);
899     }
900     return Status.error;
901 }
902 messageQueue.registerNotification(vscode_languageserver_1.DidChangeWatchedFilesNotification.type, params => {
903     // A .eslintrc has change. No smartness here.
904     // Simply revalidate all file.
905     noConfigReported = new Map();
906     missingModuleReported = new Map();
907     params.changes.forEach(change => {
908         let fsPath = getFilePath(change.uri);
909         if (!fsPath || isUNC(fsPath)) {
910             return;
911         }
912         let dirname = path.dirname(fsPath);
913         if (dirname) {
914             let library = configErrorReported.get(fsPath);
915             if (library) {
916                 let cli = new library.CLIEngine({});
917                 try {
918                     cli.executeOnText('', path.join(dirname, '___test___.js'));
919                     configErrorReported.delete(fsPath);
920                 }
921                 catch (error) {
922                     // noop
923                 }
924             }
925         }
926     });
927     validateMany(documents.all());
928 });
929 class Fixes {
930     constructor(edits) {
931         this.edits = edits;
932     }
933     static overlaps(lastEdit, newEdit) {
934         return !!lastEdit && lastEdit.edit.range[1] > newEdit.edit.range[0];
935     }
936     isEmpty() {
937         return this.edits.size === 0;
938     }
939     getDocumentVersion() {
940         if (this.isEmpty()) {
941             throw new Error('No edits recorded.');
942         }
943         return this.edits.values().next().value.documentVersion;
944     }
945     getScoped(diagnostics) {
946         let result = [];
947         for (let diagnostic of diagnostics) {
948             let key = computeKey(diagnostic);
949             let editInfo = this.edits.get(key);
950             if (editInfo) {
951                 result.push(editInfo);
952             }
953         }
954         return result;
955     }
956     getAllSorted() {
957         let result = [];
958         this.edits.forEach(value => result.push(value));
959         return result.sort((a, b) => {
960             let d = a.edit.range[0] - b.edit.range[0];
961             if (d !== 0) {
962                 return d;
963             }
964             if (a.edit.range[1] === 0) {
965                 return -1;
966             }
967             if (b.edit.range[1] === 0) {
968                 return 1;
969             }
970             return a.edit.range[1] - b.edit.range[1];
971         });
972     }
973     getOverlapFree() {
974         let sorted = this.getAllSorted();
975         if (sorted.length <= 1) {
976             return sorted;
977         }
978         let result = [];
979         let last = sorted[0];
980         result.push(last);
981         for (let i = 1; i < sorted.length; i++) {
982             let current = sorted[i];
983             if (!Fixes.overlaps(last, current)) {
984                 result.push(current);
985                 last = current;
986             }
987         }
988         return result;
989     }
990 }
991 let commands;
992 messageQueue.registerRequest(vscode_languageserver_1.CodeActionRequest.type, params => {
993     commands = new Map();
994     let result = new CodeActionResult();
995     let uri = params.textDocument.uri;
996     let edits = codeActions.get(uri);
997     if (!edits)
998         return [];
999     let fixes = new Fixes(edits);
1000     if (fixes.isEmpty())
1001         return [];
1002     let textDocument = documents.get(uri);
1003     let documentVersion = -1;
1004     let allFixableRuleIds = [];
1005     function createTextEdit(editInfo) {
1006         return vscode_languageserver_1.TextEdit.replace(vscode_languageserver_1.Range.create(textDocument.positionAt(editInfo.edit.range[0]), textDocument.positionAt(editInfo.edit.range[1])), editInfo.edit.text || '');
1007     }
1008     function createDisableLineTextEdit(editInfo, indentationText) {
1009         return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(editInfo.line - 1, 0), `${indentationText}// eslint-disable-next-line ${editInfo.ruleId}\n`);
1010     }
1011     function createDisableSameLineTextEdit(editInfo) {
1012         return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(editInfo.line - 1, Number.MAX_VALUE), ` // eslint-disable-line ${editInfo.ruleId}`);
1013     }
1014     function createDisableFileTextEdit(editInfo) {
1015         return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(0, 0), `/* eslint-disable ${editInfo.ruleId} */\n`);
1016     }
1017     function getLastEdit(array) {
1018         let length = array.length;
1019         if (length === 0) {
1020             return undefined;
1021         }
1022         return array[length - 1];
1023     }
1024     return resolveSettings(textDocument).then(settings => {
1025         for (let editInfo of fixes.getScoped(params.context.diagnostics)) {
1026             documentVersion = editInfo.documentVersion;
1027             let ruleId = editInfo.ruleId;
1028             allFixableRuleIds.push(ruleId);
1029             if (!!editInfo.edit) {
1030                 let workspaceChange = new vscode_languageserver_1.WorkspaceChange();
1031                 workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createTextEdit(editInfo));
1032                 commands.set(`${CommandIds.applySingleFix}:${ruleId}`, workspaceChange);
1033                 result.get(ruleId).fixes.push(vscode_languageserver_1.CodeAction.create(editInfo.label, vscode_languageserver_1.Command.create(editInfo.label, CommandIds.applySingleFix, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix));
1034             }
1035             if (settings.codeAction.disableRuleComment.enable) {
1036                 let workspaceChange = new vscode_languageserver_1.WorkspaceChange();
1037                 if (settings.codeAction.disableRuleComment.location === 'sameLine') {
1038                     workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableSameLineTextEdit(editInfo));
1039                 }
1040                 else {
1041                     let lineText = textDocument.getText(vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(editInfo.line - 1, 0), vscode_languageserver_1.Position.create(editInfo.line - 1, Number.MAX_VALUE)));
1042                     let indentationText = /^([ \t]*)/.exec(lineText)[1];
1043                     workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableLineTextEdit(editInfo, indentationText));
1044                 }
1045                 commands.set(`${CommandIds.applyDisableLine}:${ruleId}`, workspaceChange);
1046                 let title = `Disable ${ruleId} for this line`;
1047                 result.get(ruleId).disable = vscode_languageserver_1.CodeAction.create(title, vscode_languageserver_1.Command.create(title, CommandIds.applyDisableLine, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix);
1048                 if (result.get(ruleId).disableFile === undefined) {
1049                     workspaceChange = new vscode_languageserver_1.WorkspaceChange();
1050                     workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableFileTextEdit(editInfo));
1051                     commands.set(`${CommandIds.applyDisableFile}:${ruleId}`, workspaceChange);
1052                     title = `Disable ${ruleId} for the entire file`;
1053                     result.get(ruleId).disableFile = vscode_languageserver_1.CodeAction.create(title, vscode_languageserver_1.Command.create(title, CommandIds.applyDisableFile, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix);
1054                 }
1055             }
1056             if (settings.codeAction.showDocumentation.enable && result.get(ruleId).showDocumentation === undefined) {
1057                 if (ruleDocData.urls.has(ruleId)) {
1058                     let title = `Show documentation for ${ruleId}`;
1059                     result.get(ruleId).showDocumentation = vscode_languageserver_1.CodeAction.create(title, vscode_languageserver_1.Command.create(title, CommandIds.openRuleDoc, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix);
1060                 }
1061             }
1062         }
1063         if (result.length > 0) {
1064             let sameProblems = new Map(allFixableRuleIds.map(s => [s, []]));
1065             let all = [];
1066             for (let editInfo of fixes.getAllSorted()) {
1067                 if (documentVersion === -1) {
1068                     documentVersion = editInfo.documentVersion;
1069                 }
1070                 if (sameProblems.has(editInfo.ruleId)) {
1071                     let same = sameProblems.get(editInfo.ruleId);
1072                     if (!Fixes.overlaps(getLastEdit(same), editInfo)) {
1073                         same.push(editInfo);
1074                     }
1075                 }
1076                 if (!Fixes.overlaps(getLastEdit(all), editInfo)) {
1077                     all.push(editInfo);
1078                 }
1079             }
1080             sameProblems.forEach((same, ruleId) => {
1081                 if (same.length > 1) {
1082                     let sameFixes = new vscode_languageserver_1.WorkspaceChange();
1083                     let sameTextChange = sameFixes.getTextEditChange({ uri, version: documentVersion });
1084                     same.map(createTextEdit).forEach(edit => sameTextChange.add(edit));
1085                     commands.set(CommandIds.applySameFixes, sameFixes);
1086                     let title = `Fix all ${ruleId} problems`;
1087                     let command = vscode_languageserver_1.Command.create(title, CommandIds.applySameFixes);
1088                     result.get(ruleId).fixAll = vscode_languageserver_1.CodeAction.create(title, command, vscode_languageserver_1.CodeActionKind.QuickFix);
1089                 }
1090             });
1091             if (all.length > 1) {
1092                 let allFixes = new vscode_languageserver_1.WorkspaceChange();
1093                 let allTextChange = allFixes.getTextEditChange({ uri, version: documentVersion });
1094                 all.map(createTextEdit).forEach(edit => allTextChange.add(edit));
1095                 commands.set(CommandIds.applyAllFixes, allFixes);
1096                 let title = `Fix all auto-fixable problems`;
1097                 let command = vscode_languageserver_1.Command.create(title, CommandIds.applyAllFixes);
1098                 result.fixAll = vscode_languageserver_1.CodeAction.create(title, command, vscode_languageserver_1.CodeActionKind.QuickFix);
1099             }
1100         }
1101         return result.all();
1102     });
1103 }, (params) => {
1104     let document = documents.get(params.textDocument.uri);
1105     return document ? document.version : undefined;
1106 });
1107 messageQueue.registerRequest(vscode_languageserver_1.ExecuteCommandRequest.type, (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
1108     let workspaceChange;
1109     if (params.command === CommandIds.applyAutoFix) {
1110         let identifier = params.arguments[0];
1111         if (!identifier.uri.startsWith('file:')) {
1112             return {};
1113         }
1114         let textDocument = documents.get(identifier.uri);
1115         let settings = yield Promise.resolve(resolveSettings(textDocument));
1116         let edits = util_1.getAllFixEdits(textDocument, settings);
1117         if (edits && edits.length) {
1118             workspaceChange = new vscode_languageserver_1.WorkspaceChange();
1119             let textChange = workspaceChange.getTextEditChange(identifier);
1120             edits.forEach(edit => textChange.add(edit));
1121         }
1122     }
1123     else {
1124         if ([CommandIds.applySingleFix, CommandIds.applyDisableLine, CommandIds.applyDisableFile].indexOf(params.command) !== -1) {
1125             let ruleId = params.arguments[0];
1126             workspaceChange = commands.get(`${params.command}:${ruleId}`);
1127         }
1128         else if (params.command === CommandIds.openRuleDoc) {
1129             let ruleId = params.arguments[0];
1130             let url = ruleDocData.urls.get(ruleId);
1131             if (url) {
1132                 connection.sendRequest(OpenESLintDocRequest.type, { url });
1133             }
1134         }
1135         else {
1136             workspaceChange = commands.get(params.command);
1137         }
1138     }
1139     if (!workspaceChange) {
1140         return {};
1141     }
1142     try {
1143         let response = yield Promise.resolve(connection.workspace.applyEdit(workspaceChange.edit));
1144         if (!response.applied) {
1145             connection.console.error(`Failed to apply command: ${params.command}`);
1146         }
1147     }
1148     catch (e) {
1149         connection.console.error(`Failed to apply command: ${params.command}`);
1150     }
1151     return {};
1152 }), (params) => {
1153     if (params.command === CommandIds.applyAutoFix) {
1154         let identifier = params.arguments[0];
1155         return identifier.version;
1156     }
1157     else {
1158         return undefined;
1159     }
1160 });
1161 connection.tracer.connection.listen();
1162 //# sourceMappingURL=index.js.map
1163
1164 /***/ }),
1165 /* 1 */
1166 /***/ (function(module, __webpack_exports__, __webpack_require__) {
1167
1168 "use strict";
1169 __webpack_require__.r(__webpack_exports__);
1170 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
1171 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
1172 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
1173 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
1174 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
1175 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
1176 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
1177 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
1178 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
1179 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
1180 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
1181 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
1182 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
1183 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
1184 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
1185 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
1186 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
1187 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
1188 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
1189 /*! *****************************************************************************\r
1190 Copyright (c) Microsoft Corporation. All rights reserved.\r
1191 Licensed under the Apache License, Version 2.0 (the "License"); you may not use\r
1192 this file except in compliance with the License. You may obtain a copy of the\r
1193 License at http://www.apache.org/licenses/LICENSE-2.0\r
1194 \r
1195 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
1196 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r
1197 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r
1198 MERCHANTABLITY OR NON-INFRINGEMENT.\r
1199 \r
1200 See the Apache Version 2.0 License for specific language governing permissions\r
1201 and limitations under the License.\r
1202 ***************************************************************************** */\r
1203 /* global Reflect, Promise */\r
1204 \r
1205 var extendStatics = function(d, b) {\r
1206     extendStatics = Object.setPrototypeOf ||\r
1207         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r
1208         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r
1209     return extendStatics(d, b);\r
1210 };\r
1211 \r
1212 function __extends(d, b) {\r
1213     extendStatics(d, b);\r
1214     function __() { this.constructor = d; }\r
1215     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r
1216 }\r
1217 \r
1218 var __assign = function() {\r
1219     __assign = Object.assign || function __assign(t) {\r
1220         for (var s, i = 1, n = arguments.length; i < n; i++) {\r
1221             s = arguments[i];\r
1222             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r
1223         }\r
1224         return t;\r
1225     }\r
1226     return __assign.apply(this, arguments);\r
1227 }\r
1228 \r
1229 function __rest(s, e) {\r
1230     var t = {};\r
1231     for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r
1232         t[p] = s[p];\r
1233     if (s != null && typeof Object.getOwnPropertySymbols === "function")\r
1234         for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\r
1235             t[p[i]] = s[p[i]];\r
1236     return t;\r
1237 }\r
1238 \r
1239 function __decorate(decorators, target, key, desc) {\r
1240     var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r
1241     if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);\r
1242     else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r
1243     return c > 3 && r && Object.defineProperty(target, key, r), r;\r
1244 }\r
1245 \r
1246 function __param(paramIndex, decorator) {\r
1247     return function (target, key) { decorator(target, key, paramIndex); }\r
1248 }\r
1249 \r
1250 function __metadata(metadataKey, metadataValue) {\r
1251     if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);\r
1252 }\r
1253 \r
1254 function __awaiter(thisArg, _arguments, P, generator) {\r
1255     return new (P || (P = Promise))(function (resolve, reject) {\r
1256         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r
1257         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }\r
1258         function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r
1259         step((generator = generator.apply(thisArg, _arguments || [])).next());\r
1260     });\r
1261 }\r
1262 \r
1263 function __generator(thisArg, body) {\r
1264     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r
1265     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;\r
1266     function verb(n) { return function (v) { return step([n, v]); }; }\r
1267     function step(op) {\r
1268         if (f) throw new TypeError("Generator is already executing.");\r
1269         while (_) try {\r
1270             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r
1271             if (y = 0, t) op = [op[0] & 2, t.value];\r
1272             switch (op[0]) {\r
1273                 case 0: case 1: t = op; break;\r
1274                 case 4: _.label++; return { value: op[1], done: false };\r
1275                 case 5: _.label++; y = op[1]; op = [0]; continue;\r
1276                 case 7: op = _.ops.pop(); _.trys.pop(); continue;\r
1277                 default:\r
1278                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r
1279                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r
1280                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r
1281                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r
1282                     if (t[2]) _.ops.pop();\r
1283                     _.trys.pop(); continue;\r
1284             }\r
1285             op = body.call(thisArg, _);\r
1286         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r
1287         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r
1288     }\r
1289 }\r
1290 \r
1291 function __exportStar(m, exports) {\r
1292     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
1293 }\r
1294 \r
1295 function __values(o) {\r
1296     var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;\r
1297     if (m) return m.call(o);\r
1298     return {\r
1299         next: function () {\r
1300             if (o && i >= o.length) o = void 0;\r
1301             return { value: o && o[i++], done: !o };\r
1302         }\r
1303     };\r
1304 }\r
1305 \r
1306 function __read(o, n) {\r
1307     var m = typeof Symbol === "function" && o[Symbol.iterator];\r
1308     if (!m) return o;\r
1309     var i = m.call(o), r, ar = [], e;\r
1310     try {\r
1311         while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r
1312     }\r
1313     catch (error) { e = { error: error }; }\r
1314     finally {\r
1315         try {\r
1316             if (r && !r.done && (m = i["return"])) m.call(i);\r
1317         }\r
1318         finally { if (e) throw e.error; }\r
1319     }\r
1320     return ar;\r
1321 }\r
1322 \r
1323 function __spread() {\r
1324     for (var ar = [], i = 0; i < arguments.length; i++)\r
1325         ar = ar.concat(__read(arguments[i]));\r
1326     return ar;\r
1327 }\r
1328 \r
1329 function __await(v) {\r
1330     return this instanceof __await ? (this.v = v, this) : new __await(v);\r
1331 }\r
1332 \r
1333 function __asyncGenerator(thisArg, _arguments, generator) {\r
1334     if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");\r
1335     var g = generator.apply(thisArg, _arguments || []), i, q = [];\r
1336     return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;\r
1337     function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r
1338     function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r
1339     function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r
1340     function fulfill(value) { resume("next", value); }\r
1341     function reject(value) { resume("throw", value); }\r
1342     function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r
1343 }\r
1344 \r
1345 function __asyncDelegator(o) {\r
1346     var i, p;\r
1347     return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;\r
1348     function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }\r
1349 }\r
1350 \r
1351 function __asyncValues(o) {\r
1352     if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");\r
1353     var m = o[Symbol.asyncIterator], i;\r
1354     return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);\r
1355     function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r
1356     function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r
1357 }\r
1358 \r
1359 function __makeTemplateObject(cooked, raw) {\r
1360     if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }\r
1361     return cooked;\r
1362 };\r
1363 \r
1364 function __importStar(mod) {\r
1365     if (mod && mod.__esModule) return mod;\r
1366     var result = {};\r
1367     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r
1368     result.default = mod;\r
1369     return result;\r
1370 }\r
1371 \r
1372 function __importDefault(mod) {\r
1373     return (mod && mod.__esModule) ? mod : { default: mod };\r
1374 }\r
1375
1376
1377 /***/ }),
1378 /* 2 */
1379 /***/ (function(module, exports) {
1380
1381 module.exports = require("os");
1382
1383 /***/ }),
1384 /* 3 */
1385 /***/ (function(module, exports) {
1386
1387 module.exports = require("path");
1388
1389 /***/ }),
1390 /* 4 */
1391 /***/ (function(module, exports, __webpack_require__) {
1392
1393 "use strict";
1394 /* --------------------------------------------------------------------------------------------\r
1395  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1396  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1397  * ------------------------------------------------------------------------------------------ */\r
1398 /// <reference path="./thenable.ts" />\r
1399 \r
1400 function __export(m) {\r
1401     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
1402 }\r
1403 Object.defineProperty(exports, "__esModule", { value: true });\r
1404 const vscode_languageserver_protocol_1 = __webpack_require__(5);\r
1405 exports.Event = vscode_languageserver_protocol_1.Event;\r
1406 const configuration_1 = __webpack_require__(29);\r
1407 const workspaceFolders_1 = __webpack_require__(31);\r
1408 const Is = __webpack_require__(30);\r
1409 const UUID = __webpack_require__(32);\r
1410 // ------------- Reexport the API surface of the language worker API ----------------------\r
1411 __export(__webpack_require__(5));\r
1412 const fm = __webpack_require__(33);\r
1413 var Files;\r
1414 (function (Files) {\r
1415     Files.uriToFilePath = fm.uriToFilePath;\r
1416     Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;\r
1417     Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;\r
1418     Files.resolve = fm.resolve;\r
1419     Files.resolveModule = fm.resolveModule;\r
1420     Files.resolveModule2 = fm.resolveModule2;\r
1421     Files.resolveModulePath = fm.resolveModulePath;\r
1422 })(Files = exports.Files || (exports.Files = {}));\r
1423 let shutdownReceived = false;\r
1424 let exitTimer = undefined;\r
1425 function setupExitTimer() {\r
1426     const argName = '--clientProcessId';\r
1427     function runTimer(value) {\r
1428         try {\r
1429             let processId = parseInt(value);\r
1430             if (!isNaN(processId)) {\r
1431                 exitTimer = setInterval(() => {\r
1432                     try {\r
1433                         process.kill(processId, 0);\r
1434                     }\r
1435                     catch (ex) {\r
1436                         // Parent process doesn't exist anymore. Exit the server.\r
1437                         process.exit(shutdownReceived ? 0 : 1);\r
1438                     }\r
1439                 }, 3000);\r
1440             }\r
1441         }\r
1442         catch (e) {\r
1443             // Ignore errors;\r
1444         }\r
1445     }\r
1446     for (let i = 2; i < process.argv.length; i++) {\r
1447         let arg = process.argv[i];\r
1448         if (arg === argName && i + 1 < process.argv.length) {\r
1449             runTimer(process.argv[i + 1]);\r
1450             return;\r
1451         }\r
1452         else {\r
1453             let args = arg.split('=');\r
1454             if (args[0] === argName) {\r
1455                 runTimer(args[1]);\r
1456             }\r
1457         }\r
1458     }\r
1459 }\r
1460 setupExitTimer();\r
1461 function null2Undefined(value) {\r
1462     if (value === null) {\r
1463         return void 0;\r
1464     }\r
1465     return value;\r
1466 }\r
1467 /**\r
1468  * A manager for simple text documents\r
1469  */\r
1470 class TextDocuments {\r
1471     /**\r
1472      * Create a new text document manager.\r
1473      */\r
1474     constructor() {\r
1475         this._documents = Object.create(null);\r
1476         this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();\r
1477         this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();\r
1478         this._onDidClose = new vscode_languageserver_protocol_1.Emitter();\r
1479         this._onDidSave = new vscode_languageserver_protocol_1.Emitter();\r
1480         this._onWillSave = new vscode_languageserver_protocol_1.Emitter();\r
1481     }\r
1482     /**\r
1483      * Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by\r
1484      * this text document manager.\r
1485      */\r
1486     get syncKind() {\r
1487         return vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;\r
1488     }\r
1489     /**\r
1490      * An event that fires when a text document managed by this manager\r
1491      * has been opened or the content changes.\r
1492      */\r
1493     get onDidChangeContent() {\r
1494         return this._onDidChangeContent.event;\r
1495     }\r
1496     /**\r
1497      * An event that fires when a text document managed by this manager\r
1498      * has been opened.\r
1499      */\r
1500     get onDidOpen() {\r
1501         return this._onDidOpen.event;\r
1502     }\r
1503     /**\r
1504      * An event that fires when a text document managed by this manager\r
1505      * will be saved.\r
1506      */\r
1507     get onWillSave() {\r
1508         return this._onWillSave.event;\r
1509     }\r
1510     /**\r
1511      * Sets a handler that will be called if a participant wants to provide\r
1512      * edits during a text document save.\r
1513      */\r
1514     onWillSaveWaitUntil(handler) {\r
1515         this._willSaveWaitUntil = handler;\r
1516     }\r
1517     /**\r
1518      * An event that fires when a text document managed by this manager\r
1519      * has been saved.\r
1520      */\r
1521     get onDidSave() {\r
1522         return this._onDidSave.event;\r
1523     }\r
1524     /**\r
1525      * An event that fires when a text document managed by this manager\r
1526      * has been closed.\r
1527      */\r
1528     get onDidClose() {\r
1529         return this._onDidClose.event;\r
1530     }\r
1531     /**\r
1532      * Returns the document for the given URI. Returns undefined if\r
1533      * the document is not mananged by this instance.\r
1534      *\r
1535      * @param uri The text document's URI to retrieve.\r
1536      * @return the text document or `undefined`.\r
1537      */\r
1538     get(uri) {\r
1539         return this._documents[uri];\r
1540     }\r
1541     /**\r
1542      * Returns all text documents managed by this instance.\r
1543      *\r
1544      * @return all text documents.\r
1545      */\r
1546     all() {\r
1547         return Object.keys(this._documents).map(key => this._documents[key]);\r
1548     }\r
1549     /**\r
1550      * Returns the URIs of all text documents managed by this instance.\r
1551      *\r
1552      * @return the URI's of all text documents.\r
1553      */\r
1554     keys() {\r
1555         return Object.keys(this._documents);\r
1556     }\r
1557     /**\r
1558      * Listens for `low level` notification on the given connection to\r
1559      * update the text documents managed by this instance.\r
1560      *\r
1561      * @param connection The connection to listen on.\r
1562      */\r
1563     listen(connection) {\r
1564         function isUpdateableDocument(value) {\r
1565             return Is.func(value.update);\r
1566         }\r
1567         connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;\r
1568         connection.onDidOpenTextDocument((event) => {\r
1569             let td = event.textDocument;\r
1570             let document = vscode_languageserver_protocol_1.TextDocument.create(td.uri, td.languageId, td.version, td.text);\r
1571             this._documents[td.uri] = document;\r
1572             let toFire = Object.freeze({ document });\r
1573             this._onDidOpen.fire(toFire);\r
1574             this._onDidChangeContent.fire(toFire);\r
1575         });\r
1576         connection.onDidChangeTextDocument((event) => {\r
1577             let td = event.textDocument;\r
1578             let changes = event.contentChanges;\r
1579             let last = changes.length > 0 ? changes[changes.length - 1] : undefined;\r
1580             if (last) {\r
1581                 let document = this._documents[td.uri];\r
1582                 if (document && isUpdateableDocument(document)) {\r
1583                     if (td.version === null || td.version === void 0) {\r
1584                         throw new Error(`Received document change event for ${td.uri} without valid version identifier`);\r
1585                     }\r
1586                     document.update(last, td.version);\r
1587                     this._onDidChangeContent.fire(Object.freeze({ document }));\r
1588                 }\r
1589             }\r
1590         });\r
1591         connection.onDidCloseTextDocument((event) => {\r
1592             let document = this._documents[event.textDocument.uri];\r
1593             if (document) {\r
1594                 delete this._documents[event.textDocument.uri];\r
1595                 this._onDidClose.fire(Object.freeze({ document }));\r
1596             }\r
1597         });\r
1598         connection.onWillSaveTextDocument((event) => {\r
1599             let document = this._documents[event.textDocument.uri];\r
1600             if (document) {\r
1601                 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));\r
1602             }\r
1603         });\r
1604         connection.onWillSaveTextDocumentWaitUntil((event, token) => {\r
1605             let document = this._documents[event.textDocument.uri];\r
1606             if (document && this._willSaveWaitUntil) {\r
1607                 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);\r
1608             }\r
1609             else {\r
1610                 return [];\r
1611             }\r
1612         });\r
1613         connection.onDidSaveTextDocument((event) => {\r
1614             let document = this._documents[event.textDocument.uri];\r
1615             if (document) {\r
1616                 this._onDidSave.fire(Object.freeze({ document }));\r
1617             }\r
1618         });\r
1619     }\r
1620 }\r
1621 exports.TextDocuments = TextDocuments;\r
1622 /**\r
1623  * Helps tracking error message. Equal occurences of the same\r
1624  * message are only stored once. This class is for example\r
1625  * useful if text documents are validated in a loop and equal\r
1626  * error message should be folded into one.\r
1627  */\r
1628 class ErrorMessageTracker {\r
1629     constructor() {\r
1630         this._messages = Object.create(null);\r
1631     }\r
1632     /**\r
1633      * Add a message to the tracker.\r
1634      *\r
1635      * @param message The message to add.\r
1636      */\r
1637     add(message) {\r
1638         let count = this._messages[message];\r
1639         if (!count) {\r
1640             count = 0;\r
1641         }\r
1642         count++;\r
1643         this._messages[message] = count;\r
1644     }\r
1645     /**\r
1646      * Send all tracked messages to the connection's window.\r
1647      *\r
1648      * @param connection The connection established between client and server.\r
1649      */\r
1650     sendErrors(connection) {\r
1651         Object.keys(this._messages).forEach(message => {\r
1652             connection.window.showErrorMessage(message);\r
1653         });\r
1654     }\r
1655 }\r
1656 exports.ErrorMessageTracker = ErrorMessageTracker;\r
1657 var BulkRegistration;\r
1658 (function (BulkRegistration) {\r
1659     /**\r
1660      * Creates a new bulk registration.\r
1661      * @return an empty bulk registration.\r
1662      */\r
1663     function create() {\r
1664         return new BulkRegistrationImpl();\r
1665     }\r
1666     BulkRegistration.create = create;\r
1667 })(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));\r
1668 class BulkRegistrationImpl {\r
1669     constructor() {\r
1670         this._registrations = [];\r
1671         this._registered = new Set();\r
1672     }\r
1673     add(type, registerOptions) {\r
1674         const method = Is.string(type) ? type : type.method;\r
1675         if (this._registered.has(method)) {\r
1676             throw new Error(`${method} is already added to this registration`);\r
1677         }\r
1678         const id = UUID.generateUuid();\r
1679         this._registrations.push({\r
1680             id: id,\r
1681             method: method,\r
1682             registerOptions: registerOptions || {}\r
1683         });\r
1684         this._registered.add(method);\r
1685     }\r
1686     asRegistrationParams() {\r
1687         return {\r
1688             registrations: this._registrations\r
1689         };\r
1690     }\r
1691 }\r
1692 var BulkUnregistration;\r
1693 (function (BulkUnregistration) {\r
1694     function create() {\r
1695         return new BulkUnregistrationImpl(undefined, []);\r
1696     }\r
1697     BulkUnregistration.create = create;\r
1698 })(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));\r
1699 class BulkUnregistrationImpl {\r
1700     constructor(_connection, unregistrations) {\r
1701         this._connection = _connection;\r
1702         this._unregistrations = new Map();\r
1703         unregistrations.forEach(unregistration => {\r
1704             this._unregistrations.set(unregistration.method, unregistration);\r
1705         });\r
1706     }\r
1707     get isAttached() {\r
1708         return !!this._connection;\r
1709     }\r
1710     attach(connection) {\r
1711         this._connection = connection;\r
1712     }\r
1713     add(unregistration) {\r
1714         this._unregistrations.set(unregistration.method, unregistration);\r
1715     }\r
1716     dispose() {\r
1717         let unregistrations = [];\r
1718         for (let unregistration of this._unregistrations.values()) {\r
1719             unregistrations.push(unregistration);\r
1720         }\r
1721         let params = {\r
1722             unregisterations: unregistrations\r
1723         };\r
1724         this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {\r
1725             this._connection.console.info(`Bulk unregistration failed.`);\r
1726         });\r
1727     }\r
1728     disposeSingle(arg) {\r
1729         const method = Is.string(arg) ? arg : arg.method;\r
1730         const unregistration = this._unregistrations.get(method);\r
1731         if (!unregistration) {\r
1732             return false;\r
1733         }\r
1734         let params = {\r
1735             unregisterations: [unregistration]\r
1736         };\r
1737         this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {\r
1738             this._unregistrations.delete(method);\r
1739         }, (_error) => {\r
1740             this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);\r
1741         });\r
1742         return true;\r
1743     }\r
1744 }\r
1745 class ConnectionLogger {\r
1746     constructor() {\r
1747     }\r
1748     rawAttach(connection) {\r
1749         this._rawConnection = connection;\r
1750     }\r
1751     attach(connection) {\r
1752         this._connection = connection;\r
1753     }\r
1754     get connection() {\r
1755         if (!this._connection) {\r
1756             throw new Error('Remote is not attached to a connection yet.');\r
1757         }\r
1758         return this._connection;\r
1759     }\r
1760     fillServerCapabilities(_capabilities) {\r
1761     }\r
1762     initialize(_capabilities) {\r
1763     }\r
1764     error(message) {\r
1765         this.send(vscode_languageserver_protocol_1.MessageType.Error, message);\r
1766     }\r
1767     warn(message) {\r
1768         this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);\r
1769     }\r
1770     info(message) {\r
1771         this.send(vscode_languageserver_protocol_1.MessageType.Info, message);\r
1772     }\r
1773     log(message) {\r
1774         this.send(vscode_languageserver_protocol_1.MessageType.Log, message);\r
1775     }\r
1776     send(type, message) {\r
1777         if (this._rawConnection) {\r
1778             this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });\r
1779         }\r
1780     }\r
1781 }\r
1782 class RemoteWindowImpl {\r
1783     constructor() {\r
1784     }\r
1785     attach(connection) {\r
1786         this._connection = connection;\r
1787     }\r
1788     get connection() {\r
1789         if (!this._connection) {\r
1790             throw new Error('Remote is not attached to a connection yet.');\r
1791         }\r
1792         return this._connection;\r
1793     }\r
1794     initialize(_capabilities) {\r
1795     }\r
1796     fillServerCapabilities(_capabilities) {\r
1797     }\r
1798     showErrorMessage(message, ...actions) {\r
1799         let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };\r
1800         return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
1801     }\r
1802     showWarningMessage(message, ...actions) {\r
1803         let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };\r
1804         return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
1805     }\r
1806     showInformationMessage(message, ...actions) {\r
1807         let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };\r
1808         return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
1809     }\r
1810 }\r
1811 class RemoteClientImpl {\r
1812     attach(connection) {\r
1813         this._connection = connection;\r
1814     }\r
1815     get connection() {\r
1816         if (!this._connection) {\r
1817             throw new Error('Remote is not attached to a connection yet.');\r
1818         }\r
1819         return this._connection;\r
1820     }\r
1821     initialize(_capabilities) {\r
1822     }\r
1823     fillServerCapabilities(_capabilities) {\r
1824     }\r
1825     register(typeOrRegistrations, registerOptionsOrType, registerOptions) {\r
1826         if (typeOrRegistrations instanceof BulkRegistrationImpl) {\r
1827             return this.registerMany(typeOrRegistrations);\r
1828         }\r
1829         else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {\r
1830             return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);\r
1831         }\r
1832         else {\r
1833             return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);\r
1834         }\r
1835     }\r
1836     registerSingle1(unregistration, type, registerOptions) {\r
1837         const method = Is.string(type) ? type : type.method;\r
1838         const id = UUID.generateUuid();\r
1839         let params = {\r
1840             registrations: [{ id, method, registerOptions: registerOptions || {} }]\r
1841         };\r
1842         if (!unregistration.isAttached) {\r
1843             unregistration.attach(this._connection);\r
1844         }\r
1845         return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {\r
1846             unregistration.add({ id: id, method: method });\r
1847             return unregistration;\r
1848         }, (_error) => {\r
1849             this.connection.console.info(`Registering request handler for ${method} failed.`);\r
1850             return Promise.reject(_error);\r
1851         });\r
1852     }\r
1853     registerSingle2(type, registerOptions) {\r
1854         const method = Is.string(type) ? type : type.method;\r
1855         const id = UUID.generateUuid();\r
1856         let params = {\r
1857             registrations: [{ id, method, registerOptions: registerOptions || {} }]\r
1858         };\r
1859         return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {\r
1860             return vscode_languageserver_protocol_1.Disposable.create(() => {\r
1861                 this.unregisterSingle(id, method);\r
1862             });\r
1863         }, (_error) => {\r
1864             this.connection.console.info(`Registering request handler for ${method} failed.`);\r
1865             return Promise.reject(_error);\r
1866         });\r
1867     }\r
1868     unregisterSingle(id, method) {\r
1869         let params = {\r
1870             unregisterations: [{ id, method }]\r
1871         };\r
1872         return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {\r
1873             this.connection.console.info(`Unregistering request handler for ${id} failed.`);\r
1874         });\r
1875     }\r
1876     registerMany(registrations) {\r
1877         let params = registrations.asRegistrationParams();\r
1878         return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {\r
1879             return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));\r
1880         }, (_error) => {\r
1881             this.connection.console.info(`Bulk registration failed.`);\r
1882             return Promise.reject(_error);\r
1883         });\r
1884     }\r
1885 }\r
1886 class _RemoteWorkspaceImpl {\r
1887     constructor() {\r
1888     }\r
1889     attach(connection) {\r
1890         this._connection = connection;\r
1891     }\r
1892     get connection() {\r
1893         if (!this._connection) {\r
1894             throw new Error('Remote is not attached to a connection yet.');\r
1895         }\r
1896         return this._connection;\r
1897     }\r
1898     initialize(_capabilities) {\r
1899     }\r
1900     fillServerCapabilities(_capabilities) {\r
1901     }\r
1902     applyEdit(paramOrEdit) {\r
1903         function isApplyWorkspaceEditParams(value) {\r
1904             return value && !!value.edit;\r
1905         }\r
1906         let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };\r
1907         return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);\r
1908     }\r
1909 }\r
1910 const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));\r
1911 class TracerImpl {\r
1912     constructor() {\r
1913         this._trace = vscode_languageserver_protocol_1.Trace.Off;\r
1914     }\r
1915     attach(connection) {\r
1916         this._connection = connection;\r
1917     }\r
1918     get connection() {\r
1919         if (!this._connection) {\r
1920             throw new Error('Remote is not attached to a connection yet.');\r
1921         }\r
1922         return this._connection;\r
1923     }\r
1924     initialize(_capabilities) {\r
1925     }\r
1926     fillServerCapabilities(_capabilities) {\r
1927     }\r
1928     set trace(value) {\r
1929         this._trace = value;\r
1930     }\r
1931     log(message, verbose) {\r
1932         if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {\r
1933             return;\r
1934         }\r
1935         this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {\r
1936             message: message,\r
1937             verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined\r
1938         });\r
1939     }\r
1940 }\r
1941 class TelemetryImpl {\r
1942     constructor() {\r
1943     }\r
1944     attach(connection) {\r
1945         this._connection = connection;\r
1946     }\r
1947     get connection() {\r
1948         if (!this._connection) {\r
1949             throw new Error('Remote is not attached to a connection yet.');\r
1950         }\r
1951         return this._connection;\r
1952     }\r
1953     initialize(_capabilities) {\r
1954     }\r
1955     fillServerCapabilities(_capabilities) {\r
1956     }\r
1957     logEvent(data) {\r
1958         this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);\r
1959     }\r
1960 }\r
1961 function combineConsoleFeatures(one, two) {\r
1962     return function (Base) {\r
1963         return two(one(Base));\r
1964     };\r
1965 }\r
1966 exports.combineConsoleFeatures = combineConsoleFeatures;\r
1967 function combineTelemetryFeatures(one, two) {\r
1968     return function (Base) {\r
1969         return two(one(Base));\r
1970     };\r
1971 }\r
1972 exports.combineTelemetryFeatures = combineTelemetryFeatures;\r
1973 function combineTracerFeatures(one, two) {\r
1974     return function (Base) {\r
1975         return two(one(Base));\r
1976     };\r
1977 }\r
1978 exports.combineTracerFeatures = combineTracerFeatures;\r
1979 function combineClientFeatures(one, two) {\r
1980     return function (Base) {\r
1981         return two(one(Base));\r
1982     };\r
1983 }\r
1984 exports.combineClientFeatures = combineClientFeatures;\r
1985 function combineWindowFeatures(one, two) {\r
1986     return function (Base) {\r
1987         return two(one(Base));\r
1988     };\r
1989 }\r
1990 exports.combineWindowFeatures = combineWindowFeatures;\r
1991 function combineWorkspaceFeatures(one, two) {\r
1992     return function (Base) {\r
1993         return two(one(Base));\r
1994     };\r
1995 }\r
1996 exports.combineWorkspaceFeatures = combineWorkspaceFeatures;\r
1997 function combineFeatures(one, two) {\r
1998     function combine(one, two, func) {\r
1999         if (one && two) {\r
2000             return func(one, two);\r
2001         }\r
2002         else if (one) {\r
2003             return one;\r
2004         }\r
2005         else {\r
2006             return two;\r
2007         }\r
2008     }\r
2009     let result = {\r
2010         __brand: 'features',\r
2011         console: combine(one.console, two.console, combineConsoleFeatures),\r
2012         tracer: combine(one.tracer, two.tracer, combineTracerFeatures),\r
2013         telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),\r
2014         client: combine(one.client, two.client, combineClientFeatures),\r
2015         window: combine(one.window, two.window, combineWindowFeatures),\r
2016         workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)\r
2017     };\r
2018     return result;\r
2019 }\r
2020 exports.combineFeatures = combineFeatures;\r
2021 function createConnection(arg1, arg2, arg3, arg4) {\r
2022     let factories;\r
2023     let input;\r
2024     let output;\r
2025     let strategy;\r
2026     if (arg1 !== void 0 && arg1.__brand === 'features') {\r
2027         factories = arg1;\r
2028         arg1 = arg2;\r
2029         arg2 = arg3;\r
2030         arg3 = arg4;\r
2031     }\r
2032     if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {\r
2033         strategy = arg1;\r
2034     }\r
2035     else {\r
2036         input = arg1;\r
2037         output = arg2;\r
2038         strategy = arg3;\r
2039     }\r
2040     return _createConnection(input, output, strategy, factories);\r
2041 }\r
2042 exports.createConnection = createConnection;\r
2043 function _createConnection(input, output, strategy, factories) {\r
2044     if (!input && !output && process.argv.length > 2) {\r
2045         let port = void 0;\r
2046         let pipeName = void 0;\r
2047         let argv = process.argv.slice(2);\r
2048         for (let i = 0; i < argv.length; i++) {\r
2049             let arg = argv[i];\r
2050             if (arg === '--node-ipc') {\r
2051                 input = new vscode_languageserver_protocol_1.IPCMessageReader(process);\r
2052                 output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);\r
2053                 break;\r
2054             }\r
2055             else if (arg === '--stdio') {\r
2056                 input = process.stdin;\r
2057                 output = process.stdout;\r
2058                 break;\r
2059             }\r
2060             else if (arg === '--socket') {\r
2061                 port = parseInt(argv[i + 1]);\r
2062                 break;\r
2063             }\r
2064             else if (arg === '--pipe') {\r
2065                 pipeName = argv[i + 1];\r
2066                 break;\r
2067             }\r
2068             else {\r
2069                 var args = arg.split('=');\r
2070                 if (args[0] === '--socket') {\r
2071                     port = parseInt(args[1]);\r
2072                     break;\r
2073                 }\r
2074                 else if (args[0] === '--pipe') {\r
2075                     pipeName = args[1];\r
2076                     break;\r
2077                 }\r
2078             }\r
2079         }\r
2080         if (port) {\r
2081             let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);\r
2082             input = transport[0];\r
2083             output = transport[1];\r
2084         }\r
2085         else if (pipeName) {\r
2086             let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);\r
2087             input = transport[0];\r
2088             output = transport[1];\r
2089         }\r
2090     }\r
2091     var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";\r
2092     if (!input) {\r
2093         throw new Error("Connection input stream is not set. " + commandLineMessage);\r
2094     }\r
2095     if (!output) {\r
2096         throw new Error("Connection output stream is not set. " + commandLineMessage);\r
2097     }\r
2098     // Backwards compatibility\r
2099     if (Is.func(input.read) && Is.func(input.on)) {\r
2100         let inputStream = input;\r
2101         inputStream.on('end', () => {\r
2102             process.exit(shutdownReceived ? 0 : 1);\r
2103         });\r
2104         inputStream.on('close', () => {\r
2105             process.exit(shutdownReceived ? 0 : 1);\r
2106         });\r
2107     }\r
2108     const logger = (factories && factories.console ? new (factories.console(ConnectionLogger))() : new ConnectionLogger());\r
2109     const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);\r
2110     logger.rawAttach(connection);\r
2111     const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());\r
2112     const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());\r
2113     const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());\r
2114     const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());\r
2115     const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());\r
2116     const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace];\r
2117     function asThenable(value) {\r
2118         if (Is.thenable(value)) {\r
2119             return value;\r
2120         }\r
2121         else {\r
2122             return Promise.resolve(value);\r
2123         }\r
2124     }\r
2125     let shutdownHandler = undefined;\r
2126     let initializeHandler = undefined;\r
2127     let exitHandler = undefined;\r
2128     let protocolConnection = {\r
2129         listen: () => connection.listen(),\r
2130         sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),\r
2131         onRequest: (type, handler) => connection.onRequest(type, handler),\r
2132         sendNotification: (type, param) => {\r
2133             const method = Is.string(type) ? type : type.method;\r
2134             if (arguments.length === 1) {\r
2135                 connection.sendNotification(method);\r
2136             }\r
2137             else {\r
2138                 connection.sendNotification(method, param);\r
2139             }\r
2140         },\r
2141         onNotification: (type, handler) => connection.onNotification(type, handler),\r
2142         onInitialize: (handler) => initializeHandler = handler,\r
2143         onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),\r
2144         onShutdown: (handler) => shutdownHandler = handler,\r
2145         onExit: (handler) => exitHandler = handler,\r
2146         get console() { return logger; },\r
2147         get telemetry() { return telemetry; },\r
2148         get tracer() { return tracer; },\r
2149         get client() { return client; },\r
2150         get window() { return remoteWindow; },\r
2151         get workspace() { return workspace; },\r
2152         onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),\r
2153         onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),\r
2154         __textDocumentSync: undefined,\r
2155         onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),\r
2156         onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),\r
2157         onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),\r
2158         onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),\r
2159         onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),\r
2160         onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),\r
2161         sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),\r
2162         onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, handler),\r
2163         onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, handler),\r
2164         onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),\r
2165         onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, handler),\r
2166         onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, handler),\r
2167         onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, handler),\r
2168         onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, handler),\r
2169         onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, handler),\r
2170         onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, handler),\r
2171         onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, handler),\r
2172         onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, handler),\r
2173         onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, handler),\r
2174         onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, handler),\r
2175         onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, handler),\r
2176         onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, handler),\r
2177         onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, handler),\r
2178         onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, handler),\r
2179         onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, handler),\r
2180         onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, handler),\r
2181         onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, handler),\r
2182         onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, handler),\r
2183         onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, handler),\r
2184         onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, handler),\r
2185         onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, handler),\r
2186         onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, handler),\r
2187         onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, handler),\r
2188         dispose: () => connection.dispose()\r
2189     };\r
2190     for (let remote of allRemotes) {\r
2191         remote.attach(protocolConnection);\r
2192     }\r
2193     connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {\r
2194         const processId = params.processId;\r
2195         if (Is.number(processId) && exitTimer === void 0) {\r
2196             // We received a parent process id. Set up a timer to periodically check\r
2197             // if the parent is still alive.\r
2198             setInterval(() => {\r
2199                 try {\r
2200                     process.kill(processId, 0);\r
2201                 }\r
2202                 catch (ex) {\r
2203                     // Parent process doesn't exist anymore. Exit the server.\r
2204                     process.exit(shutdownReceived ? 0 : 1);\r
2205                 }\r
2206             }, 3000);\r
2207         }\r
2208         if (Is.string(params.trace)) {\r
2209             tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);\r
2210         }\r
2211         for (let remote of allRemotes) {\r
2212             remote.initialize(params.capabilities);\r
2213         }\r
2214         if (initializeHandler) {\r
2215             let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token);\r
2216             return asThenable(result).then((value) => {\r
2217                 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {\r
2218                     return value;\r
2219                 }\r
2220                 let result = value;\r
2221                 if (!result) {\r
2222                     result = { capabilities: {} };\r
2223                 }\r
2224                 let capabilities = result.capabilities;\r
2225                 if (!capabilities) {\r
2226                     capabilities = {};\r
2227                     result.capabilities = capabilities;\r
2228                 }\r
2229                 if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {\r
2230                     capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;\r
2231                 }\r
2232                 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {\r
2233                     capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;\r
2234                 }\r
2235                 for (let remote of allRemotes) {\r
2236                     remote.fillServerCapabilities(capabilities);\r
2237                 }\r
2238                 return result;\r
2239             });\r
2240         }\r
2241         else {\r
2242             let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };\r
2243             for (let remote of allRemotes) {\r
2244                 remote.fillServerCapabilities(result.capabilities);\r
2245             }\r
2246             return result;\r
2247         }\r
2248     });\r
2249     connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {\r
2250         shutdownReceived = true;\r
2251         if (shutdownHandler) {\r
2252             return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);\r
2253         }\r
2254         else {\r
2255             return undefined;\r
2256         }\r
2257     });\r
2258     connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {\r
2259         try {\r
2260             if (exitHandler) {\r
2261                 exitHandler();\r
2262             }\r
2263         }\r
2264         finally {\r
2265             if (shutdownReceived) {\r
2266                 process.exit(0);\r
2267             }\r
2268             else {\r
2269                 process.exit(1);\r
2270             }\r
2271         }\r
2272     });\r
2273     connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {\r
2274         tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);\r
2275     });\r
2276     return protocolConnection;\r
2277 }\r
2278 // Export the protocol currently in proposed state.\r
2279 var ProposedFeatures;\r
2280 (function (ProposedFeatures) {\r
2281     ProposedFeatures.all = {\r
2282         __brand: 'features'\r
2283     };\r
2284 })(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));\r
2285
2286
2287 /***/ }),
2288 /* 5 */
2289 /***/ (function(module, exports, __webpack_require__) {
2290
2291 "use strict";
2292 /* --------------------------------------------------------------------------------------------\r
2293  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2294  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2295  * ------------------------------------------------------------------------------------------ */\r
2296 \r
2297 function __export(m) {\r
2298     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
2299 }\r
2300 Object.defineProperty(exports, "__esModule", { value: true });\r
2301 const vscode_jsonrpc_1 = __webpack_require__(6);\r
2302 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;\r
2303 exports.ResponseError = vscode_jsonrpc_1.ResponseError;\r
2304 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;\r
2305 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;\r
2306 exports.Disposable = vscode_jsonrpc_1.Disposable;\r
2307 exports.Event = vscode_jsonrpc_1.Event;\r
2308 exports.Emitter = vscode_jsonrpc_1.Emitter;\r
2309 exports.Trace = vscode_jsonrpc_1.Trace;\r
2310 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;\r
2311 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;\r
2312 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;\r
2313 exports.RequestType = vscode_jsonrpc_1.RequestType;\r
2314 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;\r
2315 exports.NotificationType = vscode_jsonrpc_1.NotificationType;\r
2316 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;\r
2317 exports.MessageReader = vscode_jsonrpc_1.MessageReader;\r
2318 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;\r
2319 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;\r
2320 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;\r
2321 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;\r
2322 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;\r
2323 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;\r
2324 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;\r
2325 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;\r
2326 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;\r
2327 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;\r
2328 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;\r
2329 __export(__webpack_require__(18));\r
2330 __export(__webpack_require__(19));\r
2331 function createProtocolConnection(reader, writer, logger, strategy) {\r
2332     return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);\r
2333 }\r
2334 exports.createProtocolConnection = createProtocolConnection;\r
2335
2336
2337 /***/ }),
2338 /* 6 */
2339 /***/ (function(module, exports, __webpack_require__) {
2340
2341 "use strict";
2342 /* --------------------------------------------------------------------------------------------\r
2343  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2344  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2345  * ------------------------------------------------------------------------------------------ */\r
2346 /// <reference path="./thenable.ts" />\r
2347 \r
2348 function __export(m) {\r
2349     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
2350 }\r
2351 Object.defineProperty(exports, "__esModule", { value: true });\r
2352 const Is = __webpack_require__(7);\r
2353 const messages_1 = __webpack_require__(8);\r
2354 exports.RequestType = messages_1.RequestType;\r
2355 exports.RequestType0 = messages_1.RequestType0;\r
2356 exports.RequestType1 = messages_1.RequestType1;\r
2357 exports.RequestType2 = messages_1.RequestType2;\r
2358 exports.RequestType3 = messages_1.RequestType3;\r
2359 exports.RequestType4 = messages_1.RequestType4;\r
2360 exports.RequestType5 = messages_1.RequestType5;\r
2361 exports.RequestType6 = messages_1.RequestType6;\r
2362 exports.RequestType7 = messages_1.RequestType7;\r
2363 exports.RequestType8 = messages_1.RequestType8;\r
2364 exports.RequestType9 = messages_1.RequestType9;\r
2365 exports.ResponseError = messages_1.ResponseError;\r
2366 exports.ErrorCodes = messages_1.ErrorCodes;\r
2367 exports.NotificationType = messages_1.NotificationType;\r
2368 exports.NotificationType0 = messages_1.NotificationType0;\r
2369 exports.NotificationType1 = messages_1.NotificationType1;\r
2370 exports.NotificationType2 = messages_1.NotificationType2;\r
2371 exports.NotificationType3 = messages_1.NotificationType3;\r
2372 exports.NotificationType4 = messages_1.NotificationType4;\r
2373 exports.NotificationType5 = messages_1.NotificationType5;\r
2374 exports.NotificationType6 = messages_1.NotificationType6;\r
2375 exports.NotificationType7 = messages_1.NotificationType7;\r
2376 exports.NotificationType8 = messages_1.NotificationType8;\r
2377 exports.NotificationType9 = messages_1.NotificationType9;\r
2378 const messageReader_1 = __webpack_require__(9);\r
2379 exports.MessageReader = messageReader_1.MessageReader;\r
2380 exports.StreamMessageReader = messageReader_1.StreamMessageReader;\r
2381 exports.IPCMessageReader = messageReader_1.IPCMessageReader;\r
2382 exports.SocketMessageReader = messageReader_1.SocketMessageReader;\r
2383 const messageWriter_1 = __webpack_require__(11);\r
2384 exports.MessageWriter = messageWriter_1.MessageWriter;\r
2385 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;\r
2386 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;\r
2387 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;\r
2388 const events_1 = __webpack_require__(10);\r
2389 exports.Disposable = events_1.Disposable;\r
2390 exports.Event = events_1.Event;\r
2391 exports.Emitter = events_1.Emitter;\r
2392 const cancellation_1 = __webpack_require__(12);\r
2393 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;\r
2394 exports.CancellationToken = cancellation_1.CancellationToken;\r
2395 const linkedMap_1 = __webpack_require__(13);\r
2396 __export(__webpack_require__(14));\r
2397 __export(__webpack_require__(17));\r
2398 var CancelNotification;\r
2399 (function (CancelNotification) {\r
2400     CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');\r
2401 })(CancelNotification || (CancelNotification = {}));\r
2402 exports.NullLogger = Object.freeze({\r
2403     error: () => { },\r
2404     warn: () => { },\r
2405     info: () => { },\r
2406     log: () => { }\r
2407 });\r
2408 var Trace;\r
2409 (function (Trace) {\r
2410     Trace[Trace["Off"] = 0] = "Off";\r
2411     Trace[Trace["Messages"] = 1] = "Messages";\r
2412     Trace[Trace["Verbose"] = 2] = "Verbose";\r
2413 })(Trace = exports.Trace || (exports.Trace = {}));\r
2414 (function (Trace) {\r
2415     function fromString(value) {\r
2416         value = value.toLowerCase();\r
2417         switch (value) {\r
2418             case 'off':\r
2419                 return Trace.Off;\r
2420             case 'messages':\r
2421                 return Trace.Messages;\r
2422             case 'verbose':\r
2423                 return Trace.Verbose;\r
2424             default:\r
2425                 return Trace.Off;\r
2426         }\r
2427     }\r
2428     Trace.fromString = fromString;\r
2429     function toString(value) {\r
2430         switch (value) {\r
2431             case Trace.Off:\r
2432                 return 'off';\r
2433             case Trace.Messages:\r
2434                 return 'messages';\r
2435             case Trace.Verbose:\r
2436                 return 'verbose';\r
2437             default:\r
2438                 return 'off';\r
2439         }\r
2440     }\r
2441     Trace.toString = toString;\r
2442 })(Trace = exports.Trace || (exports.Trace = {}));\r
2443 var TraceFormat;\r
2444 (function (TraceFormat) {\r
2445     TraceFormat["Text"] = "text";\r
2446     TraceFormat["JSON"] = "json";\r
2447 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));\r
2448 (function (TraceFormat) {\r
2449     function fromString(value) {\r
2450         value = value.toLowerCase();\r
2451         if (value === 'json') {\r
2452             return TraceFormat.JSON;\r
2453         }\r
2454         else {\r
2455             return TraceFormat.Text;\r
2456         }\r
2457     }\r
2458     TraceFormat.fromString = fromString;\r
2459 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));\r
2460 var SetTraceNotification;\r
2461 (function (SetTraceNotification) {\r
2462     SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');\r
2463 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));\r
2464 var LogTraceNotification;\r
2465 (function (LogTraceNotification) {\r
2466     LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');\r
2467 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));\r
2468 var ConnectionErrors;\r
2469 (function (ConnectionErrors) {\r
2470     /**\r
2471      * The connection is closed.\r
2472      */\r
2473     ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";\r
2474     /**\r
2475      * The connection got disposed.\r
2476      */\r
2477     ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";\r
2478     /**\r
2479      * The connection is already in listening mode.\r
2480      */\r
2481     ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";\r
2482 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));\r
2483 class ConnectionError extends Error {\r
2484     constructor(code, message) {\r
2485         super(message);\r
2486         this.code = code;\r
2487         Object.setPrototypeOf(this, ConnectionError.prototype);\r
2488     }\r
2489 }\r
2490 exports.ConnectionError = ConnectionError;\r
2491 var ConnectionStrategy;\r
2492 (function (ConnectionStrategy) {\r
2493     function is(value) {\r
2494         let candidate = value;\r
2495         return candidate && Is.func(candidate.cancelUndispatched);\r
2496     }\r
2497     ConnectionStrategy.is = is;\r
2498 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));\r
2499 var ConnectionState;\r
2500 (function (ConnectionState) {\r
2501     ConnectionState[ConnectionState["New"] = 1] = "New";\r
2502     ConnectionState[ConnectionState["Listening"] = 2] = "Listening";\r
2503     ConnectionState[ConnectionState["Closed"] = 3] = "Closed";\r
2504     ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";\r
2505 })(ConnectionState || (ConnectionState = {}));\r
2506 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {\r
2507     let sequenceNumber = 0;\r
2508     let notificationSquenceNumber = 0;\r
2509     let unknownResponseSquenceNumber = 0;\r
2510     const version = '2.0';\r
2511     let starRequestHandler = undefined;\r
2512     let requestHandlers = Object.create(null);\r
2513     let starNotificationHandler = undefined;\r
2514     let notificationHandlers = Object.create(null);\r
2515     let timer;\r
2516     let messageQueue = new linkedMap_1.LinkedMap();\r
2517     let responsePromises = Object.create(null);\r
2518     let requestTokens = Object.create(null);\r
2519     let trace = Trace.Off;\r
2520     let traceFormat = TraceFormat.Text;\r
2521     let tracer;\r
2522     let state = ConnectionState.New;\r
2523     let errorEmitter = new events_1.Emitter();\r
2524     let closeEmitter = new events_1.Emitter();\r
2525     let unhandledNotificationEmitter = new events_1.Emitter();\r
2526     let disposeEmitter = new events_1.Emitter();\r
2527     function createRequestQueueKey(id) {\r
2528         return 'req-' + id.toString();\r
2529     }\r
2530     function createResponseQueueKey(id) {\r
2531         if (id === null) {\r
2532             return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();\r
2533         }\r
2534         else {\r
2535             return 'res-' + id.toString();\r
2536         }\r
2537     }\r
2538     function createNotificationQueueKey() {\r
2539         return 'not-' + (++notificationSquenceNumber).toString();\r
2540     }\r
2541     function addMessageToQueue(queue, message) {\r
2542         if (messages_1.isRequestMessage(message)) {\r
2543             queue.set(createRequestQueueKey(message.id), message);\r
2544         }\r
2545         else if (messages_1.isResponseMessage(message)) {\r
2546             queue.set(createResponseQueueKey(message.id), message);\r
2547         }\r
2548         else {\r
2549             queue.set(createNotificationQueueKey(), message);\r
2550         }\r
2551     }\r
2552     function cancelUndispatched(_message) {\r
2553         return undefined;\r
2554     }\r
2555     function isListening() {\r
2556         return state === ConnectionState.Listening;\r
2557     }\r
2558     function isClosed() {\r
2559         return state === ConnectionState.Closed;\r
2560     }\r
2561     function isDisposed() {\r
2562         return state === ConnectionState.Disposed;\r
2563     }\r
2564     function closeHandler() {\r
2565         if (state === ConnectionState.New || state === ConnectionState.Listening) {\r
2566             state = ConnectionState.Closed;\r
2567             closeEmitter.fire(undefined);\r
2568         }\r
2569         // If the connection is disposed don't sent close events.\r
2570     }\r
2571     ;\r
2572     function readErrorHandler(error) {\r
2573         errorEmitter.fire([error, undefined, undefined]);\r
2574     }\r
2575     function writeErrorHandler(data) {\r
2576         errorEmitter.fire(data);\r
2577     }\r
2578     messageReader.onClose(closeHandler);\r
2579     messageReader.onError(readErrorHandler);\r
2580     messageWriter.onClose(closeHandler);\r
2581     messageWriter.onError(writeErrorHandler);\r
2582     function triggerMessageQueue() {\r
2583         if (timer || messageQueue.size === 0) {\r
2584             return;\r
2585         }\r
2586         timer = setImmediate(() => {\r
2587             timer = undefined;\r
2588             processMessageQueue();\r
2589         });\r
2590     }\r
2591     function processMessageQueue() {\r
2592         if (messageQueue.size === 0) {\r
2593             return;\r
2594         }\r
2595         let message = messageQueue.shift();\r
2596         try {\r
2597             if (messages_1.isRequestMessage(message)) {\r
2598                 handleRequest(message);\r
2599             }\r
2600             else if (messages_1.isNotificationMessage(message)) {\r
2601                 handleNotification(message);\r
2602             }\r
2603             else if (messages_1.isResponseMessage(message)) {\r
2604                 handleResponse(message);\r
2605             }\r
2606             else {\r
2607                 handleInvalidMessage(message);\r
2608             }\r
2609         }\r
2610         finally {\r
2611             triggerMessageQueue();\r
2612         }\r
2613     }\r
2614     let callback = (message) => {\r
2615         try {\r
2616             // We have received a cancellation message. Check if the message is still in the queue\r
2617             // and cancel it if allowed to do so.\r
2618             if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {\r
2619                 let key = createRequestQueueKey(message.params.id);\r
2620                 let toCancel = messageQueue.get(key);\r
2621                 if (messages_1.isRequestMessage(toCancel)) {\r
2622                     let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);\r
2623                     if (response && (response.error !== void 0 || response.result !== void 0)) {\r
2624                         messageQueue.delete(key);\r
2625                         response.id = toCancel.id;\r
2626                         traceSendingResponse(response, message.method, Date.now());\r
2627                         messageWriter.write(response);\r
2628                         return;\r
2629                     }\r
2630                 }\r
2631             }\r
2632             addMessageToQueue(messageQueue, message);\r
2633         }\r
2634         finally {\r
2635             triggerMessageQueue();\r
2636         }\r
2637     };\r
2638     function handleRequest(requestMessage) {\r
2639         if (isDisposed()) {\r
2640             // we return here silently since we fired an event when the\r
2641             // connection got disposed.\r
2642             return;\r
2643         }\r
2644         function reply(resultOrError, method, startTime) {\r
2645             let message = {\r
2646                 jsonrpc: version,\r
2647                 id: requestMessage.id\r
2648             };\r
2649             if (resultOrError instanceof messages_1.ResponseError) {\r
2650                 message.error = resultOrError.toJson();\r
2651             }\r
2652             else {\r
2653                 message.result = resultOrError === void 0 ? null : resultOrError;\r
2654             }\r
2655             traceSendingResponse(message, method, startTime);\r
2656             messageWriter.write(message);\r
2657         }\r
2658         function replyError(error, method, startTime) {\r
2659             let message = {\r
2660                 jsonrpc: version,\r
2661                 id: requestMessage.id,\r
2662                 error: error.toJson()\r
2663             };\r
2664             traceSendingResponse(message, method, startTime);\r
2665             messageWriter.write(message);\r
2666         }\r
2667         function replySuccess(result, method, startTime) {\r
2668             // The JSON RPC defines that a response must either have a result or an error\r
2669             // So we can't treat undefined as a valid response result.\r
2670             if (result === void 0) {\r
2671                 result = null;\r
2672             }\r
2673             let message = {\r
2674                 jsonrpc: version,\r
2675                 id: requestMessage.id,\r
2676                 result: result\r
2677             };\r
2678             traceSendingResponse(message, method, startTime);\r
2679             messageWriter.write(message);\r
2680         }\r
2681         traceReceivedRequest(requestMessage);\r
2682         let element = requestHandlers[requestMessage.method];\r
2683         let type;\r
2684         let requestHandler;\r
2685         if (element) {\r
2686             type = element.type;\r
2687             requestHandler = element.handler;\r
2688         }\r
2689         let startTime = Date.now();\r
2690         if (requestHandler || starRequestHandler) {\r
2691             let cancellationSource = new cancellation_1.CancellationTokenSource();\r
2692             let tokenKey = String(requestMessage.id);\r
2693             requestTokens[tokenKey] = cancellationSource;\r
2694             try {\r
2695                 let handlerResult;\r
2696                 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {\r
2697                     handlerResult = requestHandler\r
2698                         ? requestHandler(cancellationSource.token)\r
2699                         : starRequestHandler(requestMessage.method, cancellationSource.token);\r
2700                 }\r
2701                 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {\r
2702                     handlerResult = requestHandler\r
2703                         ? requestHandler(...requestMessage.params, cancellationSource.token)\r
2704                         : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);\r
2705                 }\r
2706                 else {\r
2707                     handlerResult = requestHandler\r
2708                         ? requestHandler(requestMessage.params, cancellationSource.token)\r
2709                         : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);\r
2710                 }\r
2711                 let promise = handlerResult;\r
2712                 if (!handlerResult) {\r
2713                     delete requestTokens[tokenKey];\r
2714                     replySuccess(handlerResult, requestMessage.method, startTime);\r
2715                 }\r
2716                 else if (promise.then) {\r
2717                     promise.then((resultOrError) => {\r
2718                         delete requestTokens[tokenKey];\r
2719                         reply(resultOrError, requestMessage.method, startTime);\r
2720                     }, error => {\r
2721                         delete requestTokens[tokenKey];\r
2722                         if (error instanceof messages_1.ResponseError) {\r
2723                             replyError(error, requestMessage.method, startTime);\r
2724                         }\r
2725                         else if (error && Is.string(error.message)) {\r
2726                             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);\r
2727                         }\r
2728                         else {\r
2729                             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);\r
2730                         }\r
2731                     });\r
2732                 }\r
2733                 else {\r
2734                     delete requestTokens[tokenKey];\r
2735                     reply(handlerResult, requestMessage.method, startTime);\r
2736                 }\r
2737             }\r
2738             catch (error) {\r
2739                 delete requestTokens[tokenKey];\r
2740                 if (error instanceof messages_1.ResponseError) {\r
2741                     reply(error, requestMessage.method, startTime);\r
2742                 }\r
2743                 else if (error && Is.string(error.message)) {\r
2744                     replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);\r
2745                 }\r
2746                 else {\r
2747                     replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);\r
2748                 }\r
2749             }\r
2750         }\r
2751         else {\r
2752             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);\r
2753         }\r
2754     }\r
2755     function handleResponse(responseMessage) {\r
2756         if (isDisposed()) {\r
2757             // See handle request.\r
2758             return;\r
2759         }\r
2760         if (responseMessage.id === null) {\r
2761             if (responseMessage.error) {\r
2762                 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);\r
2763             }\r
2764             else {\r
2765                 logger.error(`Received response message without id. No further error information provided.`);\r
2766             }\r
2767         }\r
2768         else {\r
2769             let key = String(responseMessage.id);\r
2770             let responsePromise = responsePromises[key];\r
2771             traceReceivedResponse(responseMessage, responsePromise);\r
2772             if (responsePromise) {\r
2773                 delete responsePromises[key];\r
2774                 try {\r
2775                     if (responseMessage.error) {\r
2776                         let error = responseMessage.error;\r
2777                         responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));\r
2778                     }\r
2779                     else if (responseMessage.result !== void 0) {\r
2780                         responsePromise.resolve(responseMessage.result);\r
2781                     }\r
2782                     else {\r
2783                         throw new Error('Should never happen.');\r
2784                     }\r
2785                 }\r
2786                 catch (error) {\r
2787                     if (error.message) {\r
2788                         logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);\r
2789                     }\r
2790                     else {\r
2791                         logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);\r
2792                     }\r
2793                 }\r
2794             }\r
2795         }\r
2796     }\r
2797     function handleNotification(message) {\r
2798         if (isDisposed()) {\r
2799             // See handle request.\r
2800             return;\r
2801         }\r
2802         let type = undefined;\r
2803         let notificationHandler;\r
2804         if (message.method === CancelNotification.type.method) {\r
2805             notificationHandler = (params) => {\r
2806                 let id = params.id;\r
2807                 let source = requestTokens[String(id)];\r
2808                 if (source) {\r
2809                     source.cancel();\r
2810                 }\r
2811             };\r
2812         }\r
2813         else {\r
2814             let element = notificationHandlers[message.method];\r
2815             if (element) {\r
2816                 notificationHandler = element.handler;\r
2817                 type = element.type;\r
2818             }\r
2819         }\r
2820         if (notificationHandler || starNotificationHandler) {\r
2821             try {\r
2822                 traceReceivedNotification(message);\r
2823                 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {\r
2824                     notificationHandler ? notificationHandler() : starNotificationHandler(message.method);\r
2825                 }\r
2826                 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {\r
2827                     notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);\r
2828                 }\r
2829                 else {\r
2830                     notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);\r
2831                 }\r
2832             }\r
2833             catch (error) {\r
2834                 if (error.message) {\r
2835                     logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);\r
2836                 }\r
2837                 else {\r
2838                     logger.error(`Notification handler '${message.method}' failed unexpectedly.`);\r
2839                 }\r
2840             }\r
2841         }\r
2842         else {\r
2843             unhandledNotificationEmitter.fire(message);\r
2844         }\r
2845     }\r
2846     function handleInvalidMessage(message) {\r
2847         if (!message) {\r
2848             logger.error('Received empty message.');\r
2849             return;\r
2850         }\r
2851         logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);\r
2852         // Test whether we find an id to reject the promise\r
2853         let responseMessage = message;\r
2854         if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {\r
2855             let key = String(responseMessage.id);\r
2856             let responseHandler = responsePromises[key];\r
2857             if (responseHandler) {\r
2858                 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));\r
2859             }\r
2860         }\r
2861     }\r
2862     function traceSendingRequest(message) {\r
2863         if (trace === Trace.Off || !tracer) {\r
2864             return;\r
2865         }\r
2866         if (traceFormat === TraceFormat.Text) {\r
2867             let data = undefined;\r
2868             if (trace === Trace.Verbose && message.params) {\r
2869                 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
2870             }\r
2871             tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);\r
2872         }\r
2873         else {\r
2874             logLSPMessage('send-request', message);\r
2875         }\r
2876     }\r
2877     function traceSendingNotification(message) {\r
2878         if (trace === Trace.Off || !tracer) {\r
2879             return;\r
2880         }\r
2881         if (traceFormat === TraceFormat.Text) {\r
2882             let data = undefined;\r
2883             if (trace === Trace.Verbose) {\r
2884                 if (message.params) {\r
2885                     data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
2886                 }\r
2887                 else {\r
2888                     data = 'No parameters provided.\n\n';\r
2889                 }\r
2890             }\r
2891             tracer.log(`Sending notification '${message.method}'.`, data);\r
2892         }\r
2893         else {\r
2894             logLSPMessage('send-notification', message);\r
2895         }\r
2896     }\r
2897     function traceSendingResponse(message, method, startTime) {\r
2898         if (trace === Trace.Off || !tracer) {\r
2899             return;\r
2900         }\r
2901         if (traceFormat === TraceFormat.Text) {\r
2902             let data = undefined;\r
2903             if (trace === Trace.Verbose) {\r
2904                 if (message.error && message.error.data) {\r
2905                     data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;\r
2906                 }\r
2907                 else {\r
2908                     if (message.result) {\r
2909                         data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;\r
2910                     }\r
2911                     else if (message.error === void 0) {\r
2912                         data = 'No result returned.\n\n';\r
2913                     }\r
2914                 }\r
2915             }\r
2916             tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);\r
2917         }\r
2918         else {\r
2919             logLSPMessage('send-response', message);\r
2920         }\r
2921     }\r
2922     function traceReceivedRequest(message) {\r
2923         if (trace === Trace.Off || !tracer) {\r
2924             return;\r
2925         }\r
2926         if (traceFormat === TraceFormat.Text) {\r
2927             let data = undefined;\r
2928             if (trace === Trace.Verbose && message.params) {\r
2929                 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
2930             }\r
2931             tracer.log(`Received request '${message.method} - (${message.id})'.`, data);\r
2932         }\r
2933         else {\r
2934             logLSPMessage('receive-request', message);\r
2935         }\r
2936     }\r
2937     function traceReceivedNotification(message) {\r
2938         if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {\r
2939             return;\r
2940         }\r
2941         if (traceFormat === TraceFormat.Text) {\r
2942             let data = undefined;\r
2943             if (trace === Trace.Verbose) {\r
2944                 if (message.params) {\r
2945                     data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
2946                 }\r
2947                 else {\r
2948                     data = 'No parameters provided.\n\n';\r
2949                 }\r
2950             }\r
2951             tracer.log(`Received notification '${message.method}'.`, data);\r
2952         }\r
2953         else {\r
2954             logLSPMessage('receive-notification', message);\r
2955         }\r
2956     }\r
2957     function traceReceivedResponse(message, responsePromise) {\r
2958         if (trace === Trace.Off || !tracer) {\r
2959             return;\r
2960         }\r
2961         if (traceFormat === TraceFormat.Text) {\r
2962             let data = undefined;\r
2963             if (trace === Trace.Verbose) {\r
2964                 if (message.error && message.error.data) {\r
2965                     data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;\r
2966                 }\r
2967                 else {\r
2968                     if (message.result) {\r
2969                         data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;\r
2970                     }\r
2971                     else if (message.error === void 0) {\r
2972                         data = 'No result returned.\n\n';\r
2973                     }\r
2974                 }\r
2975             }\r
2976             if (responsePromise) {\r
2977                 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';\r
2978                 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);\r
2979             }\r
2980             else {\r
2981                 tracer.log(`Received response ${message.id} without active response promise.`, data);\r
2982             }\r
2983         }\r
2984         else {\r
2985             logLSPMessage('receive-response', message);\r
2986         }\r
2987     }\r
2988     function logLSPMessage(type, message) {\r
2989         if (!tracer || trace === Trace.Off) {\r
2990             return;\r
2991         }\r
2992         const lspMessage = {\r
2993             isLSPMessage: true,\r
2994             type,\r
2995             message,\r
2996             timestamp: Date.now()\r
2997         };\r
2998         tracer.log(lspMessage);\r
2999     }\r
3000     function throwIfClosedOrDisposed() {\r
3001         if (isClosed()) {\r
3002             throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');\r
3003         }\r
3004         if (isDisposed()) {\r
3005             throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');\r
3006         }\r
3007     }\r
3008     function throwIfListening() {\r
3009         if (isListening()) {\r
3010             throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');\r
3011         }\r
3012     }\r
3013     function throwIfNotListening() {\r
3014         if (!isListening()) {\r
3015             throw new Error('Call listen() first.');\r
3016         }\r
3017     }\r
3018     function undefinedToNull(param) {\r
3019         if (param === void 0) {\r
3020             return null;\r
3021         }\r
3022         else {\r
3023             return param;\r
3024         }\r
3025     }\r
3026     function computeMessageParams(type, params) {\r
3027         let result;\r
3028         let numberOfParams = type.numberOfParams;\r
3029         switch (numberOfParams) {\r
3030             case 0:\r
3031                 result = null;\r
3032                 break;\r
3033             case 1:\r
3034                 result = undefinedToNull(params[0]);\r
3035                 break;\r
3036             default:\r
3037                 result = [];\r
3038                 for (let i = 0; i < params.length && i < numberOfParams; i++) {\r
3039                     result.push(undefinedToNull(params[i]));\r
3040                 }\r
3041                 if (params.length < numberOfParams) {\r
3042                     for (let i = params.length; i < numberOfParams; i++) {\r
3043                         result.push(null);\r
3044                     }\r
3045                 }\r
3046                 break;\r
3047         }\r
3048         return result;\r
3049     }\r
3050     let connection = {\r
3051         sendNotification: (type, ...params) => {\r
3052             throwIfClosedOrDisposed();\r
3053             let method;\r
3054             let messageParams;\r
3055             if (Is.string(type)) {\r
3056                 method = type;\r
3057                 switch (params.length) {\r
3058                     case 0:\r
3059                         messageParams = null;\r
3060                         break;\r
3061                     case 1:\r
3062                         messageParams = params[0];\r
3063                         break;\r
3064                     default:\r
3065                         messageParams = params;\r
3066                         break;\r
3067                 }\r
3068             }\r
3069             else {\r
3070                 method = type.method;\r
3071                 messageParams = computeMessageParams(type, params);\r
3072             }\r
3073             let notificationMessage = {\r
3074                 jsonrpc: version,\r
3075                 method: method,\r
3076                 params: messageParams\r
3077             };\r
3078             traceSendingNotification(notificationMessage);\r
3079             messageWriter.write(notificationMessage);\r
3080         },\r
3081         onNotification: (type, handler) => {\r
3082             throwIfClosedOrDisposed();\r
3083             if (Is.func(type)) {\r
3084                 starNotificationHandler = type;\r
3085             }\r
3086             else if (handler) {\r
3087                 if (Is.string(type)) {\r
3088                     notificationHandlers[type] = { type: undefined, handler };\r
3089                 }\r
3090                 else {\r
3091                     notificationHandlers[type.method] = { type, handler };\r
3092                 }\r
3093             }\r
3094         },\r
3095         sendRequest: (type, ...params) => {\r
3096             throwIfClosedOrDisposed();\r
3097             throwIfNotListening();\r
3098             let method;\r
3099             let messageParams;\r
3100             let token = undefined;\r
3101             if (Is.string(type)) {\r
3102                 method = type;\r
3103                 switch (params.length) {\r
3104                     case 0:\r
3105                         messageParams = null;\r
3106                         break;\r
3107                     case 1:\r
3108                         // The cancellation token is optional so it can also be undefined.\r
3109                         if (cancellation_1.CancellationToken.is(params[0])) {\r
3110                             messageParams = null;\r
3111                             token = params[0];\r
3112                         }\r
3113                         else {\r
3114                             messageParams = undefinedToNull(params[0]);\r
3115                         }\r
3116                         break;\r
3117                     default:\r
3118                         const last = params.length - 1;\r
3119                         if (cancellation_1.CancellationToken.is(params[last])) {\r
3120                             token = params[last];\r
3121                             if (params.length === 2) {\r
3122                                 messageParams = undefinedToNull(params[0]);\r
3123                             }\r
3124                             else {\r
3125                                 messageParams = params.slice(0, last).map(value => undefinedToNull(value));\r
3126                             }\r
3127                         }\r
3128                         else {\r
3129                             messageParams = params.map(value => undefinedToNull(value));\r
3130                         }\r
3131                         break;\r
3132                 }\r
3133             }\r
3134             else {\r
3135                 method = type.method;\r
3136                 messageParams = computeMessageParams(type, params);\r
3137                 let numberOfParams = type.numberOfParams;\r
3138                 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;\r
3139             }\r
3140             let id = sequenceNumber++;\r
3141             let result = new Promise((resolve, reject) => {\r
3142                 let requestMessage = {\r
3143                     jsonrpc: version,\r
3144                     id: id,\r
3145                     method: method,\r
3146                     params: messageParams\r
3147                 };\r
3148                 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };\r
3149                 traceSendingRequest(requestMessage);\r
3150                 try {\r
3151                     messageWriter.write(requestMessage);\r
3152                 }\r
3153                 catch (e) {\r
3154                     // Writing the message failed. So we need to reject the promise.\r
3155                     responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));\r
3156                     responsePromise = null;\r
3157                 }\r
3158                 if (responsePromise) {\r
3159                     responsePromises[String(id)] = responsePromise;\r
3160                 }\r
3161             });\r
3162             if (token) {\r
3163                 token.onCancellationRequested(() => {\r
3164                     connection.sendNotification(CancelNotification.type, { id });\r
3165                 });\r
3166             }\r
3167             return result;\r
3168         },\r
3169         onRequest: (type, handler) => {\r
3170             throwIfClosedOrDisposed();\r
3171             if (Is.func(type)) {\r
3172                 starRequestHandler = type;\r
3173             }\r
3174             else if (handler) {\r
3175                 if (Is.string(type)) {\r
3176                     requestHandlers[type] = { type: undefined, handler };\r
3177                 }\r
3178                 else {\r
3179                     requestHandlers[type.method] = { type, handler };\r
3180                 }\r
3181             }\r
3182         },\r
3183         trace: (_value, _tracer, sendNotificationOrTraceOptions) => {\r
3184             let _sendNotification = false;\r
3185             let _traceFormat = TraceFormat.Text;\r
3186             if (sendNotificationOrTraceOptions !== void 0) {\r
3187                 if (Is.boolean(sendNotificationOrTraceOptions)) {\r
3188                     _sendNotification = sendNotificationOrTraceOptions;\r
3189                 }\r
3190                 else {\r
3191                     _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;\r
3192                     _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;\r
3193                 }\r
3194             }\r
3195             trace = _value;\r
3196             traceFormat = _traceFormat;\r
3197             if (trace === Trace.Off) {\r
3198                 tracer = undefined;\r
3199             }\r
3200             else {\r
3201                 tracer = _tracer;\r
3202             }\r
3203             if (_sendNotification && !isClosed() && !isDisposed()) {\r
3204                 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });\r
3205             }\r
3206         },\r
3207         onError: errorEmitter.event,\r
3208         onClose: closeEmitter.event,\r
3209         onUnhandledNotification: unhandledNotificationEmitter.event,\r
3210         onDispose: disposeEmitter.event,\r
3211         dispose: () => {\r
3212             if (isDisposed()) {\r
3213                 return;\r
3214             }\r
3215             state = ConnectionState.Disposed;\r
3216             disposeEmitter.fire(undefined);\r
3217             let error = new Error('Connection got disposed.');\r
3218             Object.keys(responsePromises).forEach((key) => {\r
3219                 responsePromises[key].reject(error);\r
3220             });\r
3221             responsePromises = Object.create(null);\r
3222             requestTokens = Object.create(null);\r
3223             messageQueue = new linkedMap_1.LinkedMap();\r
3224             // Test for backwards compatibility\r
3225             if (Is.func(messageWriter.dispose)) {\r
3226                 messageWriter.dispose();\r
3227             }\r
3228             if (Is.func(messageReader.dispose)) {\r
3229                 messageReader.dispose();\r
3230             }\r
3231         },\r
3232         listen: () => {\r
3233             throwIfClosedOrDisposed();\r
3234             throwIfListening();\r
3235             state = ConnectionState.Listening;\r
3236             messageReader.listen(callback);\r
3237         },\r
3238         inspect: () => {\r
3239             console.log("inspect");\r
3240         }\r
3241     };\r
3242     connection.onNotification(LogTraceNotification.type, (params) => {\r
3243         if (trace === Trace.Off || !tracer) {\r
3244             return;\r
3245         }\r
3246         tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);\r
3247     });\r
3248     return connection;\r
3249 }\r
3250 function isMessageReader(value) {\r
3251     return value.listen !== void 0 && value.read === void 0;\r
3252 }\r
3253 function isMessageWriter(value) {\r
3254     return value.write !== void 0 && value.end === void 0;\r
3255 }\r
3256 function createMessageConnection(input, output, logger, strategy) {\r
3257     if (!logger) {\r
3258         logger = exports.NullLogger;\r
3259     }\r
3260     let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);\r
3261     let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);\r
3262     return _createMessageConnection(reader, writer, logger, strategy);\r
3263 }\r
3264 exports.createMessageConnection = createMessageConnection;\r
3265
3266
3267 /***/ }),
3268 /* 7 */
3269 /***/ (function(module, exports, __webpack_require__) {
3270
3271 "use strict";
3272 /* --------------------------------------------------------------------------------------------\r
3273  * Copyright (c) Microsoft Corporation. All rights reserved.\r
3274  * Licensed under the MIT License. See License.txt in the project root for license information.\r
3275  * ------------------------------------------------------------------------------------------ */\r
3276 \r
3277 Object.defineProperty(exports, "__esModule", { value: true });\r
3278 function boolean(value) {\r
3279     return value === true || value === false;\r
3280 }\r
3281 exports.boolean = boolean;\r
3282 function string(value) {\r
3283     return typeof value === 'string' || value instanceof String;\r
3284 }\r
3285 exports.string = string;\r
3286 function number(value) {\r
3287     return typeof value === 'number' || value instanceof Number;\r
3288 }\r
3289 exports.number = number;\r
3290 function error(value) {\r
3291     return value instanceof Error;\r
3292 }\r
3293 exports.error = error;\r
3294 function func(value) {\r
3295     return typeof value === 'function';\r
3296 }\r
3297 exports.func = func;\r
3298 function array(value) {\r
3299     return Array.isArray(value);\r
3300 }\r
3301 exports.array = array;\r
3302 function stringArray(value) {\r
3303     return array(value) && value.every(elem => string(elem));\r
3304 }\r
3305 exports.stringArray = stringArray;\r
3306
3307
3308 /***/ }),
3309 /* 8 */
3310 /***/ (function(module, exports, __webpack_require__) {
3311
3312 "use strict";
3313 /* --------------------------------------------------------------------------------------------\r
3314  * Copyright (c) Microsoft Corporation. All rights reserved.\r
3315  * Licensed under the MIT License. See License.txt in the project root for license information.\r
3316  * ------------------------------------------------------------------------------------------ */\r
3317 \r
3318 Object.defineProperty(exports, "__esModule", { value: true });\r
3319 const is = __webpack_require__(7);\r
3320 /**\r
3321  * Predefined error codes.\r
3322  */\r
3323 var ErrorCodes;\r
3324 (function (ErrorCodes) {\r
3325     // Defined by JSON RPC\r
3326     ErrorCodes.ParseError = -32700;\r
3327     ErrorCodes.InvalidRequest = -32600;\r
3328     ErrorCodes.MethodNotFound = -32601;\r
3329     ErrorCodes.InvalidParams = -32602;\r
3330     ErrorCodes.InternalError = -32603;\r
3331     ErrorCodes.serverErrorStart = -32099;\r
3332     ErrorCodes.serverErrorEnd = -32000;\r
3333     ErrorCodes.ServerNotInitialized = -32002;\r
3334     ErrorCodes.UnknownErrorCode = -32001;\r
3335     // Defined by the protocol.\r
3336     ErrorCodes.RequestCancelled = -32800;\r
3337     // Defined by VSCode library.\r
3338     ErrorCodes.MessageWriteError = 1;\r
3339     ErrorCodes.MessageReadError = 2;\r
3340 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));\r
3341 /**\r
3342  * An error object return in a response in case a request\r
3343  * has failed.\r
3344  */\r
3345 class ResponseError extends Error {\r
3346     constructor(code, message, data) {\r
3347         super(message);\r
3348         this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;\r
3349         this.data = data;\r
3350         Object.setPrototypeOf(this, ResponseError.prototype);\r
3351     }\r
3352     toJson() {\r
3353         return {\r
3354             code: this.code,\r
3355             message: this.message,\r
3356             data: this.data,\r
3357         };\r
3358     }\r
3359 }\r
3360 exports.ResponseError = ResponseError;\r
3361 /**\r
3362  * An abstract implementation of a MessageType.\r
3363  */\r
3364 class AbstractMessageType {\r
3365     constructor(_method, _numberOfParams) {\r
3366         this._method = _method;\r
3367         this._numberOfParams = _numberOfParams;\r
3368     }\r
3369     get method() {\r
3370         return this._method;\r
3371     }\r
3372     get numberOfParams() {\r
3373         return this._numberOfParams;\r
3374     }\r
3375 }\r
3376 exports.AbstractMessageType = AbstractMessageType;\r
3377 /**\r
3378  * Classes to type request response pairs\r
3379  */\r
3380 class RequestType0 extends AbstractMessageType {\r
3381     constructor(method) {\r
3382         super(method, 0);\r
3383         this._ = undefined;\r
3384     }\r
3385 }\r
3386 exports.RequestType0 = RequestType0;\r
3387 class RequestType extends AbstractMessageType {\r
3388     constructor(method) {\r
3389         super(method, 1);\r
3390         this._ = undefined;\r
3391     }\r
3392 }\r
3393 exports.RequestType = RequestType;\r
3394 class RequestType1 extends AbstractMessageType {\r
3395     constructor(method) {\r
3396         super(method, 1);\r
3397         this._ = undefined;\r
3398     }\r
3399 }\r
3400 exports.RequestType1 = RequestType1;\r
3401 class RequestType2 extends AbstractMessageType {\r
3402     constructor(method) {\r
3403         super(method, 2);\r
3404         this._ = undefined;\r
3405     }\r
3406 }\r
3407 exports.RequestType2 = RequestType2;\r
3408 class RequestType3 extends AbstractMessageType {\r
3409     constructor(method) {\r
3410         super(method, 3);\r
3411         this._ = undefined;\r
3412     }\r
3413 }\r
3414 exports.RequestType3 = RequestType3;\r
3415 class RequestType4 extends AbstractMessageType {\r
3416     constructor(method) {\r
3417         super(method, 4);\r
3418         this._ = undefined;\r
3419     }\r
3420 }\r
3421 exports.RequestType4 = RequestType4;\r
3422 class RequestType5 extends AbstractMessageType {\r
3423     constructor(method) {\r
3424         super(method, 5);\r
3425         this._ = undefined;\r
3426     }\r
3427 }\r
3428 exports.RequestType5 = RequestType5;\r
3429 class RequestType6 extends AbstractMessageType {\r
3430     constructor(method) {\r
3431         super(method, 6);\r
3432         this._ = undefined;\r
3433     }\r
3434 }\r
3435 exports.RequestType6 = RequestType6;\r
3436 class RequestType7 extends AbstractMessageType {\r
3437     constructor(method) {\r
3438         super(method, 7);\r
3439         this._ = undefined;\r
3440     }\r
3441 }\r
3442 exports.RequestType7 = RequestType7;\r
3443 class RequestType8 extends AbstractMessageType {\r
3444     constructor(method) {\r
3445         super(method, 8);\r
3446         this._ = undefined;\r
3447     }\r
3448 }\r
3449 exports.RequestType8 = RequestType8;\r
3450 class RequestType9 extends AbstractMessageType {\r
3451     constructor(method) {\r
3452         super(method, 9);\r
3453         this._ = undefined;\r
3454     }\r
3455 }\r
3456 exports.RequestType9 = RequestType9;\r
3457 class NotificationType extends AbstractMessageType {\r
3458     constructor(method) {\r
3459         super(method, 1);\r
3460         this._ = undefined;\r
3461     }\r
3462 }\r
3463 exports.NotificationType = NotificationType;\r
3464 class NotificationType0 extends AbstractMessageType {\r
3465     constructor(method) {\r
3466         super(method, 0);\r
3467         this._ = undefined;\r
3468     }\r
3469 }\r
3470 exports.NotificationType0 = NotificationType0;\r
3471 class NotificationType1 extends AbstractMessageType {\r
3472     constructor(method) {\r
3473         super(method, 1);\r
3474         this._ = undefined;\r
3475     }\r
3476 }\r
3477 exports.NotificationType1 = NotificationType1;\r
3478 class NotificationType2 extends AbstractMessageType {\r
3479     constructor(method) {\r
3480         super(method, 2);\r
3481         this._ = undefined;\r
3482     }\r
3483 }\r
3484 exports.NotificationType2 = NotificationType2;\r
3485 class NotificationType3 extends AbstractMessageType {\r
3486     constructor(method) {\r
3487         super(method, 3);\r
3488         this._ = undefined;\r
3489     }\r
3490 }\r
3491 exports.NotificationType3 = NotificationType3;\r
3492 class NotificationType4 extends AbstractMessageType {\r
3493     constructor(method) {\r
3494         super(method, 4);\r
3495         this._ = undefined;\r
3496     }\r
3497 }\r
3498 exports.NotificationType4 = NotificationType4;\r
3499 class NotificationType5 extends AbstractMessageType {\r
3500     constructor(method) {\r
3501         super(method, 5);\r
3502         this._ = undefined;\r
3503     }\r
3504 }\r
3505 exports.NotificationType5 = NotificationType5;\r
3506 class NotificationType6 extends AbstractMessageType {\r
3507     constructor(method) {\r
3508         super(method, 6);\r
3509         this._ = undefined;\r
3510     }\r
3511 }\r
3512 exports.NotificationType6 = NotificationType6;\r
3513 class NotificationType7 extends AbstractMessageType {\r
3514     constructor(method) {\r
3515         super(method, 7);\r
3516         this._ = undefined;\r
3517     }\r
3518 }\r
3519 exports.NotificationType7 = NotificationType7;\r
3520 class NotificationType8 extends AbstractMessageType {\r
3521     constructor(method) {\r
3522         super(method, 8);\r
3523         this._ = undefined;\r
3524     }\r
3525 }\r
3526 exports.NotificationType8 = NotificationType8;\r
3527 class NotificationType9 extends AbstractMessageType {\r
3528     constructor(method) {\r
3529         super(method, 9);\r
3530         this._ = undefined;\r
3531     }\r
3532 }\r
3533 exports.NotificationType9 = NotificationType9;\r
3534 /**\r
3535  * Tests if the given message is a request message\r
3536  */\r
3537 function isRequestMessage(message) {\r
3538     let candidate = message;\r
3539     return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));\r
3540 }\r
3541 exports.isRequestMessage = isRequestMessage;\r
3542 /**\r
3543  * Tests if the given message is a notification message\r
3544  */\r
3545 function isNotificationMessage(message) {\r
3546     let candidate = message;\r
3547     return candidate && is.string(candidate.method) && message.id === void 0;\r
3548 }\r
3549 exports.isNotificationMessage = isNotificationMessage;\r
3550 /**\r
3551  * Tests if the given message is a response message\r
3552  */\r
3553 function isResponseMessage(message) {\r
3554     let candidate = message;\r
3555     return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);\r
3556 }\r
3557 exports.isResponseMessage = isResponseMessage;\r
3558
3559
3560 /***/ }),
3561 /* 9 */
3562 /***/ (function(module, exports, __webpack_require__) {
3563
3564 "use strict";
3565 /* --------------------------------------------------------------------------------------------\r
3566  * Copyright (c) Microsoft Corporation. All rights reserved.\r
3567  * Licensed under the MIT License. See License.txt in the project root for license information.\r
3568  * ------------------------------------------------------------------------------------------ */\r
3569 \r
3570 Object.defineProperty(exports, "__esModule", { value: true });\r
3571 const events_1 = __webpack_require__(10);\r
3572 const Is = __webpack_require__(7);\r
3573 let DefaultSize = 8192;\r
3574 let CR = Buffer.from('\r', 'ascii')[0];\r
3575 let LF = Buffer.from('\n', 'ascii')[0];\r
3576 let CRLF = '\r\n';\r
3577 class MessageBuffer {\r
3578     constructor(encoding = 'utf8') {\r
3579         this.encoding = encoding;\r
3580         this.index = 0;\r
3581         this.buffer = Buffer.allocUnsafe(DefaultSize);\r
3582     }\r
3583     append(chunk) {\r
3584         var toAppend = chunk;\r
3585         if (typeof (chunk) === 'string') {\r
3586             var str = chunk;\r
3587             var bufferLen = Buffer.byteLength(str, this.encoding);\r
3588             toAppend = Buffer.allocUnsafe(bufferLen);\r
3589             toAppend.write(str, 0, bufferLen, this.encoding);\r
3590         }\r
3591         if (this.buffer.length - this.index >= toAppend.length) {\r
3592             toAppend.copy(this.buffer, this.index, 0, toAppend.length);\r
3593         }\r
3594         else {\r
3595             var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;\r
3596             if (this.index === 0) {\r
3597                 this.buffer = Buffer.allocUnsafe(newSize);\r
3598                 toAppend.copy(this.buffer, 0, 0, toAppend.length);\r
3599             }\r
3600             else {\r
3601                 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);\r
3602             }\r
3603         }\r
3604         this.index += toAppend.length;\r
3605     }\r
3606     tryReadHeaders() {\r
3607         let result = undefined;\r
3608         let current = 0;\r
3609         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
3610             current++;\r
3611         }\r
3612         // No header / body separator found (e.g CRLFCRLF)\r
3613         if (current + 3 >= this.index) {\r
3614             return result;\r
3615         }\r
3616         result = Object.create(null);\r
3617         let headers = this.buffer.toString('ascii', 0, current).split(CRLF);\r
3618         headers.forEach((header) => {\r
3619             let index = header.indexOf(':');\r
3620             if (index === -1) {\r
3621                 throw new Error('Message header must separate key and value using :');\r
3622             }\r
3623             let key = header.substr(0, index);\r
3624             let value = header.substr(index + 1).trim();\r
3625             result[key] = value;\r
3626         });\r
3627         let nextStart = current + 4;\r
3628         this.buffer = this.buffer.slice(nextStart);\r
3629         this.index = this.index - nextStart;\r
3630         return result;\r
3631     }\r
3632     tryReadContent(length) {\r
3633         if (this.index < length) {\r
3634             return null;\r
3635         }\r
3636         let result = this.buffer.toString(this.encoding, 0, length);\r
3637         let nextStart = length;\r
3638         this.buffer.copy(this.buffer, 0, nextStart);\r
3639         this.index = this.index - nextStart;\r
3640         return result;\r
3641     }\r
3642     get numberOfBytes() {\r
3643         return this.index;\r
3644     }\r
3645 }\r
3646 var MessageReader;\r
3647 (function (MessageReader) {\r
3648     function is(value) {\r
3649         let candidate = value;\r
3650         return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&\r
3651             Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);\r
3652     }\r
3653     MessageReader.is = is;\r
3654 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));\r
3655 class AbstractMessageReader {\r
3656     constructor() {\r
3657         this.errorEmitter = new events_1.Emitter();\r
3658         this.closeEmitter = new events_1.Emitter();\r
3659         this.partialMessageEmitter = new events_1.Emitter();\r
3660     }\r
3661     dispose() {\r
3662         this.errorEmitter.dispose();\r
3663         this.closeEmitter.dispose();\r
3664     }\r
3665     get onError() {\r
3666         return this.errorEmitter.event;\r
3667     }\r
3668     fireError(error) {\r
3669         this.errorEmitter.fire(this.asError(error));\r
3670     }\r
3671     get onClose() {\r
3672         return this.closeEmitter.event;\r
3673     }\r
3674     fireClose() {\r
3675         this.closeEmitter.fire(undefined);\r
3676     }\r
3677     get onPartialMessage() {\r
3678         return this.partialMessageEmitter.event;\r
3679     }\r
3680     firePartialMessage(info) {\r
3681         this.partialMessageEmitter.fire(info);\r
3682     }\r
3683     asError(error) {\r
3684         if (error instanceof Error) {\r
3685             return error;\r
3686         }\r
3687         else {\r
3688             return new Error(`Reader recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);\r
3689         }\r
3690     }\r
3691 }\r
3692 exports.AbstractMessageReader = AbstractMessageReader;\r
3693 class StreamMessageReader extends AbstractMessageReader {\r
3694     constructor(readable, encoding = 'utf8') {\r
3695         super();\r
3696         this.readable = readable;\r
3697         this.buffer = new MessageBuffer(encoding);\r
3698         this._partialMessageTimeout = 10000;\r
3699     }\r
3700     set partialMessageTimeout(timeout) {\r
3701         this._partialMessageTimeout = timeout;\r
3702     }\r
3703     get partialMessageTimeout() {\r
3704         return this._partialMessageTimeout;\r
3705     }\r
3706     listen(callback) {\r
3707         this.nextMessageLength = -1;\r
3708         this.messageToken = 0;\r
3709         this.partialMessageTimer = undefined;\r
3710         this.callback = callback;\r
3711         this.readable.on('data', (data) => {\r
3712             this.onData(data);\r
3713         });\r
3714         this.readable.on('error', (error) => this.fireError(error));\r
3715         this.readable.on('close', () => this.fireClose());\r
3716     }\r
3717     onData(data) {\r
3718         this.buffer.append(data);\r
3719         while (true) {\r
3720             if (this.nextMessageLength === -1) {\r
3721                 let headers = this.buffer.tryReadHeaders();\r
3722                 if (!headers) {\r
3723                     return;\r
3724                 }\r
3725                 let contentLength = headers['Content-Length'];\r
3726                 if (!contentLength) {\r
3727                     throw new Error('Header must provide a Content-Length property.');\r
3728                 }\r
3729                 let length = parseInt(contentLength);\r
3730                 if (isNaN(length)) {\r
3731                     throw new Error('Content-Length value must be a number.');\r
3732                 }\r
3733                 this.nextMessageLength = length;\r
3734                 // Take the encoding form the header. For compatibility\r
3735                 // treat both utf-8 and utf8 as node utf8\r
3736             }\r
3737             var msg = this.buffer.tryReadContent(this.nextMessageLength);\r
3738             if (msg === null) {\r
3739                 /** We haven't recevied the full message yet. */\r
3740                 this.setPartialMessageTimer();\r
3741                 return;\r
3742             }\r
3743             this.clearPartialMessageTimer();\r
3744             this.nextMessageLength = -1;\r
3745             this.messageToken++;\r
3746             var json = JSON.parse(msg);\r
3747             this.callback(json);\r
3748         }\r
3749     }\r
3750     clearPartialMessageTimer() {\r
3751         if (this.partialMessageTimer) {\r
3752             clearTimeout(this.partialMessageTimer);\r
3753             this.partialMessageTimer = undefined;\r
3754         }\r
3755     }\r
3756     setPartialMessageTimer() {\r
3757         this.clearPartialMessageTimer();\r
3758         if (this._partialMessageTimeout <= 0) {\r
3759             return;\r
3760         }\r
3761         this.partialMessageTimer = setTimeout((token, timeout) => {\r
3762             this.partialMessageTimer = undefined;\r
3763             if (token === this.messageToken) {\r
3764                 this.firePartialMessage({ messageToken: token, waitingTime: timeout });\r
3765                 this.setPartialMessageTimer();\r
3766             }\r
3767         }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);\r
3768     }\r
3769 }\r
3770 exports.StreamMessageReader = StreamMessageReader;\r
3771 class IPCMessageReader extends AbstractMessageReader {\r
3772     constructor(process) {\r
3773         super();\r
3774         this.process = process;\r
3775         let eventEmitter = this.process;\r
3776         eventEmitter.on('error', (error) => this.fireError(error));\r
3777         eventEmitter.on('close', () => this.fireClose());\r
3778     }\r
3779     listen(callback) {\r
3780         this.process.on('message', callback);\r
3781     }\r
3782 }\r
3783 exports.IPCMessageReader = IPCMessageReader;\r
3784 class SocketMessageReader extends StreamMessageReader {\r
3785     constructor(socket, encoding = 'utf-8') {\r
3786         super(socket, encoding);\r
3787     }\r
3788 }\r
3789 exports.SocketMessageReader = SocketMessageReader;\r
3790
3791
3792 /***/ }),
3793 /* 10 */
3794 /***/ (function(module, exports, __webpack_require__) {
3795
3796 "use strict";
3797 /* --------------------------------------------------------------------------------------------\r
3798  * Copyright (c) Microsoft Corporation. All rights reserved.\r
3799  * Licensed under the MIT License. See License.txt in the project root for license information.\r
3800  * ------------------------------------------------------------------------------------------ */\r
3801 \r
3802 Object.defineProperty(exports, "__esModule", { value: true });\r
3803 var Disposable;\r
3804 (function (Disposable) {\r
3805     function create(func) {\r
3806         return {\r
3807             dispose: func\r
3808         };\r
3809     }\r
3810     Disposable.create = create;\r
3811 })(Disposable = exports.Disposable || (exports.Disposable = {}));\r
3812 var Event;\r
3813 (function (Event) {\r
3814     const _disposable = { dispose() { } };\r
3815     Event.None = function () { return _disposable; };\r
3816 })(Event = exports.Event || (exports.Event = {}));\r
3817 class CallbackList {\r
3818     add(callback, context = null, bucket) {\r
3819         if (!this._callbacks) {\r
3820             this._callbacks = [];\r
3821             this._contexts = [];\r
3822         }\r
3823         this._callbacks.push(callback);\r
3824         this._contexts.push(context);\r
3825         if (Array.isArray(bucket)) {\r
3826             bucket.push({ dispose: () => this.remove(callback, context) });\r
3827         }\r
3828     }\r
3829     remove(callback, context = null) {\r
3830         if (!this._callbacks) {\r
3831             return;\r
3832         }\r
3833         var foundCallbackWithDifferentContext = false;\r
3834         for (var i = 0, len = this._callbacks.length; i < len; i++) {\r
3835             if (this._callbacks[i] === callback) {\r
3836                 if (this._contexts[i] === context) {\r
3837                     // callback & context match => remove it\r
3838                     this._callbacks.splice(i, 1);\r
3839                     this._contexts.splice(i, 1);\r
3840                     return;\r
3841                 }\r
3842                 else {\r
3843                     foundCallbackWithDifferentContext = true;\r
3844                 }\r
3845             }\r
3846         }\r
3847         if (foundCallbackWithDifferentContext) {\r
3848             throw new Error('When adding a listener with a context, you should remove it with the same context');\r
3849         }\r
3850     }\r
3851     invoke(...args) {\r
3852         if (!this._callbacks) {\r
3853             return [];\r
3854         }\r
3855         var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);\r
3856         for (var i = 0, len = callbacks.length; i < len; i++) {\r
3857             try {\r
3858                 ret.push(callbacks[i].apply(contexts[i], args));\r
3859             }\r
3860             catch (e) {\r
3861                 console.error(e);\r
3862             }\r
3863         }\r
3864         return ret;\r
3865     }\r
3866     isEmpty() {\r
3867         return !this._callbacks || this._callbacks.length === 0;\r
3868     }\r
3869     dispose() {\r
3870         this._callbacks = undefined;\r
3871         this._contexts = undefined;\r
3872     }\r
3873 }\r
3874 class Emitter {\r
3875     constructor(_options) {\r
3876         this._options = _options;\r
3877     }\r
3878     /**\r
3879      * For the public to allow to subscribe\r
3880      * to events from this Emitter\r
3881      */\r
3882     get event() {\r
3883         if (!this._event) {\r
3884             this._event = (listener, thisArgs, disposables) => {\r
3885                 if (!this._callbacks) {\r
3886                     this._callbacks = new CallbackList();\r
3887                 }\r
3888                 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {\r
3889                     this._options.onFirstListenerAdd(this);\r
3890                 }\r
3891                 this._callbacks.add(listener, thisArgs);\r
3892                 let result;\r
3893                 result = {\r
3894                     dispose: () => {\r
3895                         this._callbacks.remove(listener, thisArgs);\r
3896                         result.dispose = Emitter._noop;\r
3897                         if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {\r
3898                             this._options.onLastListenerRemove(this);\r
3899                         }\r
3900                     }\r
3901                 };\r
3902                 if (Array.isArray(disposables)) {\r
3903                     disposables.push(result);\r
3904                 }\r
3905                 return result;\r
3906             };\r
3907         }\r
3908         return this._event;\r
3909     }\r
3910     /**\r
3911      * To be kept private to fire an event to\r
3912      * subscribers\r
3913      */\r
3914     fire(event) {\r
3915         if (this._callbacks) {\r
3916             this._callbacks.invoke.call(this._callbacks, event);\r
3917         }\r
3918     }\r
3919     dispose() {\r
3920         if (this._callbacks) {\r
3921             this._callbacks.dispose();\r
3922             this._callbacks = undefined;\r
3923         }\r
3924     }\r
3925 }\r
3926 Emitter._noop = function () { };\r
3927 exports.Emitter = Emitter;\r
3928
3929
3930 /***/ }),
3931 /* 11 */
3932 /***/ (function(module, exports, __webpack_require__) {
3933
3934 "use strict";
3935 /* --------------------------------------------------------------------------------------------\r
3936  * Copyright (c) Microsoft Corporation. All rights reserved.\r
3937  * Licensed under the MIT License. See License.txt in the project root for license information.\r
3938  * ------------------------------------------------------------------------------------------ */\r
3939 \r
3940 Object.defineProperty(exports, "__esModule", { value: true });\r
3941 const events_1 = __webpack_require__(10);\r
3942 const Is = __webpack_require__(7);\r
3943 let ContentLength = 'Content-Length: ';\r
3944 let CRLF = '\r\n';\r
3945 var MessageWriter;\r
3946 (function (MessageWriter) {\r
3947     function is(value) {\r
3948         let candidate = value;\r
3949         return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&\r
3950             Is.func(candidate.onError) && Is.func(candidate.write);\r
3951     }\r
3952     MessageWriter.is = is;\r
3953 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));\r
3954 class AbstractMessageWriter {\r
3955     constructor() {\r
3956         this.errorEmitter = new events_1.Emitter();\r
3957         this.closeEmitter = new events_1.Emitter();\r
3958     }\r
3959     dispose() {\r
3960         this.errorEmitter.dispose();\r
3961         this.closeEmitter.dispose();\r
3962     }\r
3963     get onError() {\r
3964         return this.errorEmitter.event;\r
3965     }\r
3966     fireError(error, message, count) {\r
3967         this.errorEmitter.fire([this.asError(error), message, count]);\r
3968     }\r
3969     get onClose() {\r
3970         return this.closeEmitter.event;\r
3971     }\r
3972     fireClose() {\r
3973         this.closeEmitter.fire(undefined);\r
3974     }\r
3975     asError(error) {\r
3976         if (error instanceof Error) {\r
3977             return error;\r
3978         }\r
3979         else {\r
3980             return new Error(`Writer recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);\r
3981         }\r
3982     }\r
3983 }\r
3984 exports.AbstractMessageWriter = AbstractMessageWriter;\r
3985 class StreamMessageWriter extends AbstractMessageWriter {\r
3986     constructor(writable, encoding = 'utf8') {\r
3987         super();\r
3988         this.writable = writable;\r
3989         this.encoding = encoding;\r
3990         this.errorCount = 0;\r
3991         this.writable.on('error', (error) => this.fireError(error));\r
3992         this.writable.on('close', () => this.fireClose());\r
3993     }\r
3994     write(msg) {\r
3995         let json = JSON.stringify(msg);\r
3996         let contentLength = Buffer.byteLength(json, this.encoding);\r
3997         let headers = [\r
3998             ContentLength, contentLength.toString(), CRLF,\r
3999             CRLF\r
4000         ];\r
4001         try {\r
4002             // Header must be written in ASCII encoding\r
4003             this.writable.write(headers.join(''), 'ascii');\r
4004             // Now write the content. This can be written in any encoding\r
4005             this.writable.write(json, this.encoding);\r
4006             this.errorCount = 0;\r
4007         }\r
4008         catch (error) {\r
4009             this.errorCount++;\r
4010             this.fireError(error, msg, this.errorCount);\r
4011         }\r
4012     }\r
4013 }\r
4014 exports.StreamMessageWriter = StreamMessageWriter;\r
4015 class IPCMessageWriter extends AbstractMessageWriter {\r
4016     constructor(process) {\r
4017         super();\r
4018         this.process = process;\r
4019         this.errorCount = 0;\r
4020         this.queue = [];\r
4021         this.sending = false;\r
4022         let eventEmitter = this.process;\r
4023         eventEmitter.on('error', (error) => this.fireError(error));\r
4024         eventEmitter.on('close', () => this.fireClose);\r
4025     }\r
4026     write(msg) {\r
4027         if (!this.sending && this.queue.length === 0) {\r
4028             // See https://github.com/nodejs/node/issues/7657\r
4029             this.doWriteMessage(msg);\r
4030         }\r
4031         else {\r
4032             this.queue.push(msg);\r
4033         }\r
4034     }\r
4035     doWriteMessage(msg) {\r
4036         try {\r
4037             if (this.process.send) {\r
4038                 this.sending = true;\r
4039                 this.process.send(msg, undefined, undefined, (error) => {\r
4040                     this.sending = false;\r
4041                     if (error) {\r
4042                         this.errorCount++;\r
4043                         this.fireError(error, msg, this.errorCount);\r
4044                     }\r
4045                     else {\r
4046                         this.errorCount = 0;\r
4047                     }\r
4048                     if (this.queue.length > 0) {\r
4049                         this.doWriteMessage(this.queue.shift());\r
4050                     }\r
4051                 });\r
4052             }\r
4053         }\r
4054         catch (error) {\r
4055             this.errorCount++;\r
4056             this.fireError(error, msg, this.errorCount);\r
4057         }\r
4058     }\r
4059 }\r
4060 exports.IPCMessageWriter = IPCMessageWriter;\r
4061 class SocketMessageWriter extends AbstractMessageWriter {\r
4062     constructor(socket, encoding = 'utf8') {\r
4063         super();\r
4064         this.socket = socket;\r
4065         this.queue = [];\r
4066         this.sending = false;\r
4067         this.encoding = encoding;\r
4068         this.errorCount = 0;\r
4069         this.socket.on('error', (error) => this.fireError(error));\r
4070         this.socket.on('close', () => this.fireClose());\r
4071     }\r
4072     write(msg) {\r
4073         if (!this.sending && this.queue.length === 0) {\r
4074             // See https://github.com/nodejs/node/issues/7657\r
4075             this.doWriteMessage(msg);\r
4076         }\r
4077         else {\r
4078             this.queue.push(msg);\r
4079         }\r
4080     }\r
4081     doWriteMessage(msg) {\r
4082         let json = JSON.stringify(msg);\r
4083         let contentLength = Buffer.byteLength(json, this.encoding);\r
4084         let headers = [\r
4085             ContentLength, contentLength.toString(), CRLF,\r
4086             CRLF\r
4087         ];\r
4088         try {\r
4089             // Header must be written in ASCII encoding\r
4090             this.sending = true;\r
4091             this.socket.write(headers.join(''), 'ascii', (error) => {\r
4092                 if (error) {\r
4093                     this.handleError(error, msg);\r
4094                 }\r
4095                 try {\r
4096                     // Now write the content. This can be written in any encoding\r
4097                     this.socket.write(json, this.encoding, (error) => {\r
4098                         this.sending = false;\r
4099                         if (error) {\r
4100                             this.handleError(error, msg);\r
4101                         }\r
4102                         else {\r
4103                             this.errorCount = 0;\r
4104                         }\r
4105                         if (this.queue.length > 0) {\r
4106                             this.doWriteMessage(this.queue.shift());\r
4107                         }\r
4108                     });\r
4109                 }\r
4110                 catch (error) {\r
4111                     this.handleError(error, msg);\r
4112                 }\r
4113             });\r
4114         }\r
4115         catch (error) {\r
4116             this.handleError(error, msg);\r
4117         }\r
4118     }\r
4119     handleError(error, msg) {\r
4120         this.errorCount++;\r
4121         this.fireError(error, msg, this.errorCount);\r
4122     }\r
4123 }\r
4124 exports.SocketMessageWriter = SocketMessageWriter;\r
4125
4126
4127 /***/ }),
4128 /* 12 */
4129 /***/ (function(module, exports, __webpack_require__) {
4130
4131 "use strict";
4132 /*---------------------------------------------------------------------------------------------\r
4133  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
4134  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
4135  *--------------------------------------------------------------------------------------------*/\r
4136 \r
4137 Object.defineProperty(exports, "__esModule", { value: true });\r
4138 const events_1 = __webpack_require__(10);\r
4139 const Is = __webpack_require__(7);\r
4140 var CancellationToken;\r
4141 (function (CancellationToken) {\r
4142     CancellationToken.None = Object.freeze({\r
4143         isCancellationRequested: false,\r
4144         onCancellationRequested: events_1.Event.None\r
4145     });\r
4146     CancellationToken.Cancelled = Object.freeze({\r
4147         isCancellationRequested: true,\r
4148         onCancellationRequested: events_1.Event.None\r
4149     });\r
4150     function is(value) {\r
4151         let candidate = value;\r
4152         return candidate && (candidate === CancellationToken.None\r
4153             || candidate === CancellationToken.Cancelled\r
4154             || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));\r
4155     }\r
4156     CancellationToken.is = is;\r
4157 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));\r
4158 const shortcutEvent = Object.freeze(function (callback, context) {\r
4159     let handle = setTimeout(callback.bind(context), 0);\r
4160     return { dispose() { clearTimeout(handle); } };\r
4161 });\r
4162 class MutableToken {\r
4163     constructor() {\r
4164         this._isCancelled = false;\r
4165     }\r
4166     cancel() {\r
4167         if (!this._isCancelled) {\r
4168             this._isCancelled = true;\r
4169             if (this._emitter) {\r
4170                 this._emitter.fire(undefined);\r
4171                 this._emitter = undefined;\r
4172             }\r
4173         }\r
4174     }\r
4175     get isCancellationRequested() {\r
4176         return this._isCancelled;\r
4177     }\r
4178     get onCancellationRequested() {\r
4179         if (this._isCancelled) {\r
4180             return shortcutEvent;\r
4181         }\r
4182         if (!this._emitter) {\r
4183             this._emitter = new events_1.Emitter();\r
4184         }\r
4185         return this._emitter.event;\r
4186     }\r
4187 }\r
4188 class CancellationTokenSource {\r
4189     get token() {\r
4190         if (!this._token) {\r
4191             // be lazy and create the token only when\r
4192             // actually needed\r
4193             this._token = new MutableToken();\r
4194         }\r
4195         return this._token;\r
4196     }\r
4197     cancel() {\r
4198         if (!this._token) {\r
4199             // save an object by returning the default\r
4200             // cancelled token when cancellation happens\r
4201             // before someone asks for the token\r
4202             this._token = CancellationToken.Cancelled;\r
4203         }\r
4204         else {\r
4205             this._token.cancel();\r
4206         }\r
4207     }\r
4208     dispose() {\r
4209         this.cancel();\r
4210     }\r
4211 }\r
4212 exports.CancellationTokenSource = CancellationTokenSource;\r
4213
4214
4215 /***/ }),
4216 /* 13 */
4217 /***/ (function(module, exports, __webpack_require__) {
4218
4219 "use strict";
4220 \r
4221 /*---------------------------------------------------------------------------------------------\r
4222  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
4223  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
4224  *--------------------------------------------------------------------------------------------*/\r
4225 Object.defineProperty(exports, "__esModule", { value: true });\r
4226 var Touch;\r
4227 (function (Touch) {\r
4228     Touch.None = 0;\r
4229     Touch.First = 1;\r
4230     Touch.Last = 2;\r
4231 })(Touch = exports.Touch || (exports.Touch = {}));\r
4232 class LinkedMap {\r
4233     constructor() {\r
4234         this._map = new Map();\r
4235         this._head = undefined;\r
4236         this._tail = undefined;\r
4237         this._size = 0;\r
4238     }\r
4239     clear() {\r
4240         this._map.clear();\r
4241         this._head = undefined;\r
4242         this._tail = undefined;\r
4243         this._size = 0;\r
4244     }\r
4245     isEmpty() {\r
4246         return !this._head && !this._tail;\r
4247     }\r
4248     get size() {\r
4249         return this._size;\r
4250     }\r
4251     has(key) {\r
4252         return this._map.has(key);\r
4253     }\r
4254     get(key) {\r
4255         const item = this._map.get(key);\r
4256         if (!item) {\r
4257             return undefined;\r
4258         }\r
4259         return item.value;\r
4260     }\r
4261     set(key, value, touch = Touch.None) {\r
4262         let item = this._map.get(key);\r
4263         if (item) {\r
4264             item.value = value;\r
4265             if (touch !== Touch.None) {\r
4266                 this.touch(item, touch);\r
4267             }\r
4268         }\r
4269         else {\r
4270             item = { key, value, next: undefined, previous: undefined };\r
4271             switch (touch) {\r
4272                 case Touch.None:\r
4273                     this.addItemLast(item);\r
4274                     break;\r
4275                 case Touch.First:\r
4276                     this.addItemFirst(item);\r
4277                     break;\r
4278                 case Touch.Last:\r
4279                     this.addItemLast(item);\r
4280                     break;\r
4281                 default:\r
4282                     this.addItemLast(item);\r
4283                     break;\r
4284             }\r
4285             this._map.set(key, item);\r
4286             this._size++;\r
4287         }\r
4288     }\r
4289     delete(key) {\r
4290         const item = this._map.get(key);\r
4291         if (!item) {\r
4292             return false;\r
4293         }\r
4294         this._map.delete(key);\r
4295         this.removeItem(item);\r
4296         this._size--;\r
4297         return true;\r
4298     }\r
4299     shift() {\r
4300         if (!this._head && !this._tail) {\r
4301             return undefined;\r
4302         }\r
4303         if (!this._head || !this._tail) {\r
4304             throw new Error('Invalid list');\r
4305         }\r
4306         const item = this._head;\r
4307         this._map.delete(item.key);\r
4308         this.removeItem(item);\r
4309         this._size--;\r
4310         return item.value;\r
4311     }\r
4312     forEach(callbackfn, thisArg) {\r
4313         let current = this._head;\r
4314         while (current) {\r
4315             if (thisArg) {\r
4316                 callbackfn.bind(thisArg)(current.value, current.key, this);\r
4317             }\r
4318             else {\r
4319                 callbackfn(current.value, current.key, this);\r
4320             }\r
4321             current = current.next;\r
4322         }\r
4323     }\r
4324     forEachReverse(callbackfn, thisArg) {\r
4325         let current = this._tail;\r
4326         while (current) {\r
4327             if (thisArg) {\r
4328                 callbackfn.bind(thisArg)(current.value, current.key, this);\r
4329             }\r
4330             else {\r
4331                 callbackfn(current.value, current.key, this);\r
4332             }\r
4333             current = current.previous;\r
4334         }\r
4335     }\r
4336     values() {\r
4337         let result = [];\r
4338         let current = this._head;\r
4339         while (current) {\r
4340             result.push(current.value);\r
4341             current = current.next;\r
4342         }\r
4343         return result;\r
4344     }\r
4345     keys() {\r
4346         let result = [];\r
4347         let current = this._head;\r
4348         while (current) {\r
4349             result.push(current.key);\r
4350             current = current.next;\r
4351         }\r
4352         return result;\r
4353     }\r
4354     /* JSON RPC run on es5 which has no Symbol.iterator\r
4355     public keys(): IterableIterator<K> {\r
4356         let current = this._head;\r
4357         let iterator: IterableIterator<K> = {\r
4358             [Symbol.iterator]() {\r
4359                 return iterator;\r
4360             },\r
4361             next():IteratorResult<K> {\r
4362                 if (current) {\r
4363                     let result = { value: current.key, done: false };\r
4364                     current = current.next;\r
4365                     return result;\r
4366                 } else {\r
4367                     return { value: undefined, done: true };\r
4368                 }\r
4369             }\r
4370         };\r
4371         return iterator;\r
4372     }\r
4373 \r
4374     public values(): IterableIterator<V> {\r
4375         let current = this._head;\r
4376         let iterator: IterableIterator<V> = {\r
4377             [Symbol.iterator]() {\r
4378                 return iterator;\r
4379             },\r
4380             next():IteratorResult<V> {\r
4381                 if (current) {\r
4382                     let result = { value: current.value, done: false };\r
4383                     current = current.next;\r
4384                     return result;\r
4385                 } else {\r
4386                     return { value: undefined, done: true };\r
4387                 }\r
4388             }\r
4389         };\r
4390         return iterator;\r
4391     }\r
4392     */\r
4393     addItemFirst(item) {\r
4394         // First time Insert\r
4395         if (!this._head && !this._tail) {\r
4396             this._tail = item;\r
4397         }\r
4398         else if (!this._head) {\r
4399             throw new Error('Invalid list');\r
4400         }\r
4401         else {\r
4402             item.next = this._head;\r
4403             this._head.previous = item;\r
4404         }\r
4405         this._head = item;\r
4406     }\r
4407     addItemLast(item) {\r
4408         // First time Insert\r
4409         if (!this._head && !this._tail) {\r
4410             this._head = item;\r
4411         }\r
4412         else if (!this._tail) {\r
4413             throw new Error('Invalid list');\r
4414         }\r
4415         else {\r
4416             item.previous = this._tail;\r
4417             this._tail.next = item;\r
4418         }\r
4419         this._tail = item;\r
4420     }\r
4421     removeItem(item) {\r
4422         if (item === this._head && item === this._tail) {\r
4423             this._head = undefined;\r
4424             this._tail = undefined;\r
4425         }\r
4426         else if (item === this._head) {\r
4427             this._head = item.next;\r
4428         }\r
4429         else if (item === this._tail) {\r
4430             this._tail = item.previous;\r
4431         }\r
4432         else {\r
4433             const next = item.next;\r
4434             const previous = item.previous;\r
4435             if (!next || !previous) {\r
4436                 throw new Error('Invalid list');\r
4437             }\r
4438             next.previous = previous;\r
4439             previous.next = next;\r
4440         }\r
4441     }\r
4442     touch(item, touch) {\r
4443         if (!this._head || !this._tail) {\r
4444             throw new Error('Invalid list');\r
4445         }\r
4446         if ((touch !== Touch.First && touch !== Touch.Last)) {\r
4447             return;\r
4448         }\r
4449         if (touch === Touch.First) {\r
4450             if (item === this._head) {\r
4451                 return;\r
4452             }\r
4453             const next = item.next;\r
4454             const previous = item.previous;\r
4455             // Unlink the item\r
4456             if (item === this._tail) {\r
4457                 // previous must be defined since item was not head but is tail\r
4458                 // So there are more than on item in the map\r
4459                 previous.next = undefined;\r
4460                 this._tail = previous;\r
4461             }\r
4462             else {\r
4463                 // Both next and previous are not undefined since item was neither head nor tail.\r
4464                 next.previous = previous;\r
4465                 previous.next = next;\r
4466             }\r
4467             // Insert the node at head\r
4468             item.previous = undefined;\r
4469             item.next = this._head;\r
4470             this._head.previous = item;\r
4471             this._head = item;\r
4472         }\r
4473         else if (touch === Touch.Last) {\r
4474             if (item === this._tail) {\r
4475                 return;\r
4476             }\r
4477             const next = item.next;\r
4478             const previous = item.previous;\r
4479             // Unlink the item.\r
4480             if (item === this._head) {\r
4481                 // next must be defined since item was not tail but is head\r
4482                 // So there are more than on item in the map\r
4483                 next.previous = undefined;\r
4484                 this._head = next;\r
4485             }\r
4486             else {\r
4487                 // Both next and previous are not undefined since item was neither head nor tail.\r
4488                 next.previous = previous;\r
4489                 previous.next = next;\r
4490             }\r
4491             item.next = undefined;\r
4492             item.previous = this._tail;\r
4493             this._tail.next = item;\r
4494             this._tail = item;\r
4495         }\r
4496     }\r
4497 }\r
4498 exports.LinkedMap = LinkedMap;\r
4499
4500
4501 /***/ }),
4502 /* 14 */
4503 /***/ (function(module, exports, __webpack_require__) {
4504
4505 "use strict";
4506 /* --------------------------------------------------------------------------------------------\r
4507  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4508  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4509  * ------------------------------------------------------------------------------------------ */\r
4510 \r
4511 Object.defineProperty(exports, "__esModule", { value: true });\r
4512 const path_1 = __webpack_require__(3);\r
4513 const os_1 = __webpack_require__(2);\r
4514 const crypto_1 = __webpack_require__(15);\r
4515 const net_1 = __webpack_require__(16);\r
4516 const messageReader_1 = __webpack_require__(9);\r
4517 const messageWriter_1 = __webpack_require__(11);\r
4518 function generateRandomPipeName() {\r
4519     const randomSuffix = crypto_1.randomBytes(21).toString('hex');\r
4520     if (process.platform === 'win32') {\r
4521         return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;\r
4522     }\r
4523     else {\r
4524         // Mac/Unix: use socket file\r
4525         return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);\r
4526     }\r
4527 }\r
4528 exports.generateRandomPipeName = generateRandomPipeName;\r
4529 function createClientPipeTransport(pipeName, encoding = 'utf-8') {\r
4530     let connectResolve;\r
4531     let connected = new Promise((resolve, _reject) => {\r
4532         connectResolve = resolve;\r
4533     });\r
4534     return new Promise((resolve, reject) => {\r
4535         let server = net_1.createServer((socket) => {\r
4536             server.close();\r
4537             connectResolve([\r
4538                 new messageReader_1.SocketMessageReader(socket, encoding),\r
4539                 new messageWriter_1.SocketMessageWriter(socket, encoding)\r
4540             ]);\r
4541         });\r
4542         server.on('error', reject);\r
4543         server.listen(pipeName, () => {\r
4544             server.removeListener('error', reject);\r
4545             resolve({\r
4546                 onConnected: () => { return connected; }\r
4547             });\r
4548         });\r
4549     });\r
4550 }\r
4551 exports.createClientPipeTransport = createClientPipeTransport;\r
4552 function createServerPipeTransport(pipeName, encoding = 'utf-8') {\r
4553     const socket = net_1.createConnection(pipeName);\r
4554     return [\r
4555         new messageReader_1.SocketMessageReader(socket, encoding),\r
4556         new messageWriter_1.SocketMessageWriter(socket, encoding)\r
4557     ];\r
4558 }\r
4559 exports.createServerPipeTransport = createServerPipeTransport;\r
4560
4561
4562 /***/ }),
4563 /* 15 */
4564 /***/ (function(module, exports) {
4565
4566 module.exports = require("crypto");
4567
4568 /***/ }),
4569 /* 16 */
4570 /***/ (function(module, exports) {
4571
4572 module.exports = require("net");
4573
4574 /***/ }),
4575 /* 17 */
4576 /***/ (function(module, exports, __webpack_require__) {
4577
4578 "use strict";
4579 /* --------------------------------------------------------------------------------------------\r
4580  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4581  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4582  * ------------------------------------------------------------------------------------------ */\r
4583 \r
4584 Object.defineProperty(exports, "__esModule", { value: true });\r
4585 const net_1 = __webpack_require__(16);\r
4586 const messageReader_1 = __webpack_require__(9);\r
4587 const messageWriter_1 = __webpack_require__(11);\r
4588 function createClientSocketTransport(port, encoding = 'utf-8') {\r
4589     let connectResolve;\r
4590     let connected = new Promise((resolve, _reject) => {\r
4591         connectResolve = resolve;\r
4592     });\r
4593     return new Promise((resolve, reject) => {\r
4594         let server = net_1.createServer((socket) => {\r
4595             server.close();\r
4596             connectResolve([\r
4597                 new messageReader_1.SocketMessageReader(socket, encoding),\r
4598                 new messageWriter_1.SocketMessageWriter(socket, encoding)\r
4599             ]);\r
4600         });\r
4601         server.on('error', reject);\r
4602         server.listen(port, '127.0.0.1', () => {\r
4603             server.removeListener('error', reject);\r
4604             resolve({\r
4605                 onConnected: () => { return connected; }\r
4606             });\r
4607         });\r
4608     });\r
4609 }\r
4610 exports.createClientSocketTransport = createClientSocketTransport;\r
4611 function createServerSocketTransport(port, encoding = 'utf-8') {\r
4612     const socket = net_1.createConnection(port, '127.0.0.1');\r
4613     return [\r
4614         new messageReader_1.SocketMessageReader(socket, encoding),\r
4615         new messageWriter_1.SocketMessageWriter(socket, encoding)\r
4616     ];\r
4617 }\r
4618 exports.createServerSocketTransport = createServerSocketTransport;\r
4619
4620
4621 /***/ }),
4622 /* 18 */
4623 /***/ (function(module, __webpack_exports__, __webpack_require__) {
4624
4625 "use strict";
4626 __webpack_require__.r(__webpack_exports__);
4627 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
4628 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
4629 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
4630 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
4631 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
4632 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
4633 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
4634 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
4635 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
4636 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
4637 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
4638 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
4639 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
4640 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
4641 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
4642 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
4643 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
4644 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
4645 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
4646 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
4647 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
4648 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
4649 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
4650 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
4651 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
4652 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
4653 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
4654 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
4655 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
4656 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
4657 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
4658 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
4659 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
4660 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
4661 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
4662 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
4663 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
4664 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
4665 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
4666 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
4667 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
4668 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
4669 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
4670 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
4671 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
4672 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
4673 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
4674 /* --------------------------------------------------------------------------------------------\r
4675  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4676  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4677  * ------------------------------------------------------------------------------------------ */\r
4678 \r
4679 /**\r
4680  * The Position namespace provides helper functions to work with\r
4681  * [Position](#Position) literals.\r
4682  */\r
4683 var Position;\r
4684 (function (Position) {\r
4685     /**\r
4686      * Creates a new Position literal from the given line and character.\r
4687      * @param line The position's line.\r
4688      * @param character The position's character.\r
4689      */\r
4690     function create(line, character) {\r
4691         return { line: line, character: character };\r
4692     }\r
4693     Position.create = create;\r
4694     /**\r
4695      * Checks whether the given liternal conforms to the [Position](#Position) interface.\r
4696      */\r
4697     function is(value) {\r
4698         var candidate = value;\r
4699         return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);\r
4700     }\r
4701     Position.is = is;\r
4702 })(Position || (Position = {}));\r
4703 /**\r
4704  * The Range namespace provides helper functions to work with\r
4705  * [Range](#Range) literals.\r
4706  */\r
4707 var Range;\r
4708 (function (Range) {\r
4709     function create(one, two, three, four) {\r
4710         if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {\r
4711             return { start: Position.create(one, two), end: Position.create(three, four) };\r
4712         }\r
4713         else if (Position.is(one) && Position.is(two)) {\r
4714             return { start: one, end: two };\r
4715         }\r
4716         else {\r
4717             throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");\r
4718         }\r
4719     }\r
4720     Range.create = create;\r
4721     /**\r
4722      * Checks whether the given literal conforms to the [Range](#Range) interface.\r
4723      */\r
4724     function is(value) {\r
4725         var candidate = value;\r
4726         return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);\r
4727     }\r
4728     Range.is = is;\r
4729 })(Range || (Range = {}));\r
4730 /**\r
4731  * The Location namespace provides helper functions to work with\r
4732  * [Location](#Location) literals.\r
4733  */\r
4734 var Location;\r
4735 (function (Location) {\r
4736     /**\r
4737      * Creates a Location literal.\r
4738      * @param uri The location's uri.\r
4739      * @param range The location's range.\r
4740      */\r
4741     function create(uri, range) {\r
4742         return { uri: uri, range: range };\r
4743     }\r
4744     Location.create = create;\r
4745     /**\r
4746      * Checks whether the given literal conforms to the [Location](#Location) interface.\r
4747      */\r
4748     function is(value) {\r
4749         var candidate = value;\r
4750         return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));\r
4751     }\r
4752     Location.is = is;\r
4753 })(Location || (Location = {}));\r
4754 /**\r
4755  * The LocationLink namespace provides helper functions to work with\r
4756  * [LocationLink](#LocationLink) literals.\r
4757  */\r
4758 var LocationLink;\r
4759 (function (LocationLink) {\r
4760     /**\r
4761      * Creates a LocationLink literal.\r
4762      * @param targetUri The definition's uri.\r
4763      * @param targetRange The full range of the definition.\r
4764      * @param targetSelectionRange The span of the symbol definition at the target.\r
4765      * @param originSelectionRange The span of the symbol being defined in the originating source file.\r
4766      */\r
4767     function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {\r
4768         return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };\r
4769     }\r
4770     LocationLink.create = create;\r
4771     /**\r
4772      * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.\r
4773      */\r
4774     function is(value) {\r
4775         var candidate = value;\r
4776         return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)\r
4777             && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))\r
4778             && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));\r
4779     }\r
4780     LocationLink.is = is;\r
4781 })(LocationLink || (LocationLink = {}));\r
4782 /**\r
4783  * The Color namespace provides helper functions to work with\r
4784  * [Color](#Color) literals.\r
4785  */\r
4786 var Color;\r
4787 (function (Color) {\r
4788     /**\r
4789      * Creates a new Color literal.\r
4790      */\r
4791     function create(red, green, blue, alpha) {\r
4792         return {\r
4793             red: red,\r
4794             green: green,\r
4795             blue: blue,\r
4796             alpha: alpha,\r
4797         };\r
4798     }\r
4799     Color.create = create;\r
4800     /**\r
4801      * Checks whether the given literal conforms to the [Color](#Color) interface.\r
4802      */\r
4803     function is(value) {\r
4804         var candidate = value;\r
4805         return Is.number(candidate.red)\r
4806             && Is.number(candidate.green)\r
4807             && Is.number(candidate.blue)\r
4808             && Is.number(candidate.alpha);\r
4809     }\r
4810     Color.is = is;\r
4811 })(Color || (Color = {}));\r
4812 /**\r
4813  * The ColorInformation namespace provides helper functions to work with\r
4814  * [ColorInformation](#ColorInformation) literals.\r
4815  */\r
4816 var ColorInformation;\r
4817 (function (ColorInformation) {\r
4818     /**\r
4819      * Creates a new ColorInformation literal.\r
4820      */\r
4821     function create(range, color) {\r
4822         return {\r
4823             range: range,\r
4824             color: color,\r
4825         };\r
4826     }\r
4827     ColorInformation.create = create;\r
4828     /**\r
4829      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.\r
4830      */\r
4831     function is(value) {\r
4832         var candidate = value;\r
4833         return Range.is(candidate.range) && Color.is(candidate.color);\r
4834     }\r
4835     ColorInformation.is = is;\r
4836 })(ColorInformation || (ColorInformation = {}));\r
4837 /**\r
4838  * The Color namespace provides helper functions to work with\r
4839  * [ColorPresentation](#ColorPresentation) literals.\r
4840  */\r
4841 var ColorPresentation;\r
4842 (function (ColorPresentation) {\r
4843     /**\r
4844      * Creates a new ColorInformation literal.\r
4845      */\r
4846     function create(label, textEdit, additionalTextEdits) {\r
4847         return {\r
4848             label: label,\r
4849             textEdit: textEdit,\r
4850             additionalTextEdits: additionalTextEdits,\r
4851         };\r
4852     }\r
4853     ColorPresentation.create = create;\r
4854     /**\r
4855      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.\r
4856      */\r
4857     function is(value) {\r
4858         var candidate = value;\r
4859         return Is.string(candidate.label)\r
4860             && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))\r
4861             && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));\r
4862     }\r
4863     ColorPresentation.is = is;\r
4864 })(ColorPresentation || (ColorPresentation = {}));\r
4865 /**\r
4866  * Enum of known range kinds\r
4867  */\r
4868 var FoldingRangeKind;\r
4869 (function (FoldingRangeKind) {\r
4870     /**\r
4871      * Folding range for a comment\r
4872      */\r
4873     FoldingRangeKind["Comment"] = "comment";\r
4874     /**\r
4875      * Folding range for a imports or includes\r
4876      */\r
4877     FoldingRangeKind["Imports"] = "imports";\r
4878     /**\r
4879      * Folding range for a region (e.g. `#region`)\r
4880      */\r
4881     FoldingRangeKind["Region"] = "region";\r
4882 })(FoldingRangeKind || (FoldingRangeKind = {}));\r
4883 /**\r
4884  * The folding range namespace provides helper functions to work with\r
4885  * [FoldingRange](#FoldingRange) literals.\r
4886  */\r
4887 var FoldingRange;\r
4888 (function (FoldingRange) {\r
4889     /**\r
4890      * Creates a new FoldingRange literal.\r
4891      */\r
4892     function create(startLine, endLine, startCharacter, endCharacter, kind) {\r
4893         var result = {\r
4894             startLine: startLine,\r
4895             endLine: endLine\r
4896         };\r
4897         if (Is.defined(startCharacter)) {\r
4898             result.startCharacter = startCharacter;\r
4899         }\r
4900         if (Is.defined(endCharacter)) {\r
4901             result.endCharacter = endCharacter;\r
4902         }\r
4903         if (Is.defined(kind)) {\r
4904             result.kind = kind;\r
4905         }\r
4906         return result;\r
4907     }\r
4908     FoldingRange.create = create;\r
4909     /**\r
4910      * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.\r
4911      */\r
4912     function is(value) {\r
4913         var candidate = value;\r
4914         return Is.number(candidate.startLine) && Is.number(candidate.startLine)\r
4915             && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))\r
4916             && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))\r
4917             && (Is.undefined(candidate.kind) || Is.string(candidate.kind));\r
4918     }\r
4919     FoldingRange.is = is;\r
4920 })(FoldingRange || (FoldingRange = {}));\r
4921 /**\r
4922  * The DiagnosticRelatedInformation namespace provides helper functions to work with\r
4923  * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.\r
4924  */\r
4925 var DiagnosticRelatedInformation;\r
4926 (function (DiagnosticRelatedInformation) {\r
4927     /**\r
4928      * Creates a new DiagnosticRelatedInformation literal.\r
4929      */\r
4930     function create(location, message) {\r
4931         return {\r
4932             location: location,\r
4933             message: message\r
4934         };\r
4935     }\r
4936     DiagnosticRelatedInformation.create = create;\r
4937     /**\r
4938      * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.\r
4939      */\r
4940     function is(value) {\r
4941         var candidate = value;\r
4942         return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);\r
4943     }\r
4944     DiagnosticRelatedInformation.is = is;\r
4945 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));\r
4946 /**\r
4947  * The diagnostic's severity.\r
4948  */\r
4949 var DiagnosticSeverity;\r
4950 (function (DiagnosticSeverity) {\r
4951     /**\r
4952      * Reports an error.\r
4953      */\r
4954     DiagnosticSeverity.Error = 1;\r
4955     /**\r
4956      * Reports a warning.\r
4957      */\r
4958     DiagnosticSeverity.Warning = 2;\r
4959     /**\r
4960      * Reports an information.\r
4961      */\r
4962     DiagnosticSeverity.Information = 3;\r
4963     /**\r
4964      * Reports a hint.\r
4965      */\r
4966     DiagnosticSeverity.Hint = 4;\r
4967 })(DiagnosticSeverity || (DiagnosticSeverity = {}));\r
4968 /**\r
4969  * The Diagnostic namespace provides helper functions to work with\r
4970  * [Diagnostic](#Diagnostic) literals.\r
4971  */\r
4972 var Diagnostic;\r
4973 (function (Diagnostic) {\r
4974     /**\r
4975      * Creates a new Diagnostic literal.\r
4976      */\r
4977     function create(range, message, severity, code, source, relatedInformation) {\r
4978         var result = { range: range, message: message };\r
4979         if (Is.defined(severity)) {\r
4980             result.severity = severity;\r
4981         }\r
4982         if (Is.defined(code)) {\r
4983             result.code = code;\r
4984         }\r
4985         if (Is.defined(source)) {\r
4986             result.source = source;\r
4987         }\r
4988         if (Is.defined(relatedInformation)) {\r
4989             result.relatedInformation = relatedInformation;\r
4990         }\r
4991         return result;\r
4992     }\r
4993     Diagnostic.create = create;\r
4994     /**\r
4995      * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.\r
4996      */\r
4997     function is(value) {\r
4998         var candidate = value;\r
4999         return Is.defined(candidate)\r
5000             && Range.is(candidate.range)\r
5001             && Is.string(candidate.message)\r
5002             && (Is.number(candidate.severity) || Is.undefined(candidate.severity))\r
5003             && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))\r
5004             && (Is.string(candidate.source) || Is.undefined(candidate.source))\r
5005             && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));\r
5006     }\r
5007     Diagnostic.is = is;\r
5008 })(Diagnostic || (Diagnostic = {}));\r
5009 /**\r
5010  * The Command namespace provides helper functions to work with\r
5011  * [Command](#Command) literals.\r
5012  */\r
5013 var Command;\r
5014 (function (Command) {\r
5015     /**\r
5016      * Creates a new Command literal.\r
5017      */\r
5018     function create(title, command) {\r
5019         var args = [];\r
5020         for (var _i = 2; _i < arguments.length; _i++) {\r
5021             args[_i - 2] = arguments[_i];\r
5022         }\r
5023         var result = { title: title, command: command };\r
5024         if (Is.defined(args) && args.length > 0) {\r
5025             result.arguments = args;\r
5026         }\r
5027         return result;\r
5028     }\r
5029     Command.create = create;\r
5030     /**\r
5031      * Checks whether the given literal conforms to the [Command](#Command) interface.\r
5032      */\r
5033     function is(value) {\r
5034         var candidate = value;\r
5035         return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);\r
5036     }\r
5037     Command.is = is;\r
5038 })(Command || (Command = {}));\r
5039 /**\r
5040  * The TextEdit namespace provides helper function to create replace,\r
5041  * insert and delete edits more easily.\r
5042  */\r
5043 var TextEdit;\r
5044 (function (TextEdit) {\r
5045     /**\r
5046      * Creates a replace text edit.\r
5047      * @param range The range of text to be replaced.\r
5048      * @param newText The new text.\r
5049      */\r
5050     function replace(range, newText) {\r
5051         return { range: range, newText: newText };\r
5052     }\r
5053     TextEdit.replace = replace;\r
5054     /**\r
5055      * Creates a insert text edit.\r
5056      * @param position The position to insert the text at.\r
5057      * @param newText The text to be inserted.\r
5058      */\r
5059     function insert(position, newText) {\r
5060         return { range: { start: position, end: position }, newText: newText };\r
5061     }\r
5062     TextEdit.insert = insert;\r
5063     /**\r
5064      * Creates a delete text edit.\r
5065      * @param range The range of text to be deleted.\r
5066      */\r
5067     function del(range) {\r
5068         return { range: range, newText: '' };\r
5069     }\r
5070     TextEdit.del = del;\r
5071     function is(value) {\r
5072         var candidate = value;\r
5073         return Is.objectLiteral(candidate)\r
5074             && Is.string(candidate.newText)\r
5075             && Range.is(candidate.range);\r
5076     }\r
5077     TextEdit.is = is;\r
5078 })(TextEdit || (TextEdit = {}));\r
5079 /**\r
5080  * The TextDocumentEdit namespace provides helper function to create\r
5081  * an edit that manipulates a text document.\r
5082  */\r
5083 var TextDocumentEdit;\r
5084 (function (TextDocumentEdit) {\r
5085     /**\r
5086      * Creates a new `TextDocumentEdit`\r
5087      */\r
5088     function create(textDocument, edits) {\r
5089         return { textDocument: textDocument, edits: edits };\r
5090     }\r
5091     TextDocumentEdit.create = create;\r
5092     function is(value) {\r
5093         var candidate = value;\r
5094         return Is.defined(candidate)\r
5095             && VersionedTextDocumentIdentifier.is(candidate.textDocument)\r
5096             && Array.isArray(candidate.edits);\r
5097     }\r
5098     TextDocumentEdit.is = is;\r
5099 })(TextDocumentEdit || (TextDocumentEdit = {}));\r
5100 var CreateFile;\r
5101 (function (CreateFile) {\r
5102     function create(uri, options) {\r
5103         var result = {\r
5104             kind: 'create',\r
5105             uri: uri\r
5106         };\r
5107         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {\r
5108             result.options = options;\r
5109         }\r
5110         return result;\r
5111     }\r
5112     CreateFile.create = create;\r
5113     function is(value) {\r
5114         var candidate = value;\r
5115         return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&\r
5116             (candidate.options === void 0 ||\r
5117                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));\r
5118     }\r
5119     CreateFile.is = is;\r
5120 })(CreateFile || (CreateFile = {}));\r
5121 var RenameFile;\r
5122 (function (RenameFile) {\r
5123     function create(oldUri, newUri, options) {\r
5124         var result = {\r
5125             kind: 'rename',\r
5126             oldUri: oldUri,\r
5127             newUri: newUri\r
5128         };\r
5129         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {\r
5130             result.options = options;\r
5131         }\r
5132         return result;\r
5133     }\r
5134     RenameFile.create = create;\r
5135     function is(value) {\r
5136         var candidate = value;\r
5137         return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&\r
5138             (candidate.options === void 0 ||\r
5139                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));\r
5140     }\r
5141     RenameFile.is = is;\r
5142 })(RenameFile || (RenameFile = {}));\r
5143 var DeleteFile;\r
5144 (function (DeleteFile) {\r
5145     function create(uri, options) {\r
5146         var result = {\r
5147             kind: 'delete',\r
5148             uri: uri\r
5149         };\r
5150         if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {\r
5151             result.options = options;\r
5152         }\r
5153         return result;\r
5154     }\r
5155     DeleteFile.create = create;\r
5156     function is(value) {\r
5157         var candidate = value;\r
5158         return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&\r
5159             (candidate.options === void 0 ||\r
5160                 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));\r
5161     }\r
5162     DeleteFile.is = is;\r
5163 })(DeleteFile || (DeleteFile = {}));\r
5164 var WorkspaceEdit;\r
5165 (function (WorkspaceEdit) {\r
5166     function is(value) {\r
5167         var candidate = value;\r
5168         return candidate &&\r
5169             (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&\r
5170             (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {\r
5171                 if (Is.string(change.kind)) {\r
5172                     return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);\r
5173                 }\r
5174                 else {\r
5175                     return TextDocumentEdit.is(change);\r
5176                 }\r
5177             }));\r
5178     }\r
5179     WorkspaceEdit.is = is;\r
5180 })(WorkspaceEdit || (WorkspaceEdit = {}));\r
5181 var TextEditChangeImpl = /** @class */ (function () {\r
5182     function TextEditChangeImpl(edits) {\r
5183         this.edits = edits;\r
5184     }\r
5185     TextEditChangeImpl.prototype.insert = function (position, newText) {\r
5186         this.edits.push(TextEdit.insert(position, newText));\r
5187     };\r
5188     TextEditChangeImpl.prototype.replace = function (range, newText) {\r
5189         this.edits.push(TextEdit.replace(range, newText));\r
5190     };\r
5191     TextEditChangeImpl.prototype.delete = function (range) {\r
5192         this.edits.push(TextEdit.del(range));\r
5193     };\r
5194     TextEditChangeImpl.prototype.add = function (edit) {\r
5195         this.edits.push(edit);\r
5196     };\r
5197     TextEditChangeImpl.prototype.all = function () {\r
5198         return this.edits;\r
5199     };\r
5200     TextEditChangeImpl.prototype.clear = function () {\r
5201         this.edits.splice(0, this.edits.length);\r
5202     };\r
5203     return TextEditChangeImpl;\r
5204 }());\r
5205 /**\r
5206  * A workspace change helps constructing changes to a workspace.\r
5207  */\r
5208 var WorkspaceChange = /** @class */ (function () {\r
5209     function WorkspaceChange(workspaceEdit) {\r
5210         var _this = this;\r
5211         this._textEditChanges = Object.create(null);\r
5212         if (workspaceEdit) {\r
5213             this._workspaceEdit = workspaceEdit;\r
5214             if (workspaceEdit.documentChanges) {\r
5215                 workspaceEdit.documentChanges.forEach(function (change) {\r
5216                     if (TextDocumentEdit.is(change)) {\r
5217                         var textEditChange = new TextEditChangeImpl(change.edits);\r
5218                         _this._textEditChanges[change.textDocument.uri] = textEditChange;\r
5219                     }\r
5220                 });\r
5221             }\r
5222             else if (workspaceEdit.changes) {\r
5223                 Object.keys(workspaceEdit.changes).forEach(function (key) {\r
5224                     var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);\r
5225                     _this._textEditChanges[key] = textEditChange;\r
5226                 });\r
5227             }\r
5228         }\r
5229     }\r
5230     Object.defineProperty(WorkspaceChange.prototype, "edit", {\r
5231         /**\r
5232          * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal\r
5233          * use to be returned from a workspace edit operation like rename.\r
5234          */\r
5235         get: function () {\r
5236             return this._workspaceEdit;\r
5237         },\r
5238         enumerable: true,\r
5239         configurable: true\r
5240     });\r
5241     WorkspaceChange.prototype.getTextEditChange = function (key) {\r
5242         if (VersionedTextDocumentIdentifier.is(key)) {\r
5243             if (!this._workspaceEdit) {\r
5244                 this._workspaceEdit = {\r
5245                     documentChanges: []\r
5246                 };\r
5247             }\r
5248             if (!this._workspaceEdit.documentChanges) {\r
5249                 throw new Error('Workspace edit is not configured for document changes.');\r
5250             }\r
5251             var textDocument = key;\r
5252             var result = this._textEditChanges[textDocument.uri];\r
5253             if (!result) {\r
5254                 var edits = [];\r
5255                 var textDocumentEdit = {\r
5256                     textDocument: textDocument,\r
5257                     edits: edits\r
5258                 };\r
5259                 this._workspaceEdit.documentChanges.push(textDocumentEdit);\r
5260                 result = new TextEditChangeImpl(edits);\r
5261                 this._textEditChanges[textDocument.uri] = result;\r
5262             }\r
5263             return result;\r
5264         }\r
5265         else {\r
5266             if (!this._workspaceEdit) {\r
5267                 this._workspaceEdit = {\r
5268                     changes: Object.create(null)\r
5269                 };\r
5270             }\r
5271             if (!this._workspaceEdit.changes) {\r
5272                 throw new Error('Workspace edit is not configured for normal text edit changes.');\r
5273             }\r
5274             var result = this._textEditChanges[key];\r
5275             if (!result) {\r
5276                 var edits = [];\r
5277                 this._workspaceEdit.changes[key] = edits;\r
5278                 result = new TextEditChangeImpl(edits);\r
5279                 this._textEditChanges[key] = result;\r
5280             }\r
5281             return result;\r
5282         }\r
5283     };\r
5284     WorkspaceChange.prototype.createFile = function (uri, options) {\r
5285         this.checkDocumentChanges();\r
5286         this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));\r
5287     };\r
5288     WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {\r
5289         this.checkDocumentChanges();\r
5290         this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));\r
5291     };\r
5292     WorkspaceChange.prototype.deleteFile = function (uri, options) {\r
5293         this.checkDocumentChanges();\r
5294         this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));\r
5295     };\r
5296     WorkspaceChange.prototype.checkDocumentChanges = function () {\r
5297         if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {\r
5298             throw new Error('Workspace edit is not configured for document changes.');\r
5299         }\r
5300     };\r
5301     return WorkspaceChange;\r
5302 }());\r
5303 \r
5304 /**\r
5305  * The TextDocumentIdentifier namespace provides helper functions to work with\r
5306  * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.\r
5307  */\r
5308 var TextDocumentIdentifier;\r
5309 (function (TextDocumentIdentifier) {\r
5310     /**\r
5311      * Creates a new TextDocumentIdentifier literal.\r
5312      * @param uri The document's uri.\r
5313      */\r
5314     function create(uri) {\r
5315         return { uri: uri };\r
5316     }\r
5317     TextDocumentIdentifier.create = create;\r
5318     /**\r
5319      * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.\r
5320      */\r
5321     function is(value) {\r
5322         var candidate = value;\r
5323         return Is.defined(candidate) && Is.string(candidate.uri);\r
5324     }\r
5325     TextDocumentIdentifier.is = is;\r
5326 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));\r
5327 /**\r
5328  * The VersionedTextDocumentIdentifier namespace provides helper functions to work with\r
5329  * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.\r
5330  */\r
5331 var VersionedTextDocumentIdentifier;\r
5332 (function (VersionedTextDocumentIdentifier) {\r
5333     /**\r
5334      * Creates a new VersionedTextDocumentIdentifier literal.\r
5335      * @param uri The document's uri.\r
5336      * @param uri The document's text.\r
5337      */\r
5338     function create(uri, version) {\r
5339         return { uri: uri, version: version };\r
5340     }\r
5341     VersionedTextDocumentIdentifier.create = create;\r
5342     /**\r
5343      * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.\r
5344      */\r
5345     function is(value) {\r
5346         var candidate = value;\r
5347         return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));\r
5348     }\r
5349     VersionedTextDocumentIdentifier.is = is;\r
5350 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));\r
5351 /**\r
5352  * The TextDocumentItem namespace provides helper functions to work with\r
5353  * [TextDocumentItem](#TextDocumentItem) literals.\r
5354  */\r
5355 var TextDocumentItem;\r
5356 (function (TextDocumentItem) {\r
5357     /**\r
5358      * Creates a new TextDocumentItem literal.\r
5359      * @param uri The document's uri.\r
5360      * @param languageId The document's language identifier.\r
5361      * @param version The document's version number.\r
5362      * @param text The document's text.\r
5363      */\r
5364     function create(uri, languageId, version, text) {\r
5365         return { uri: uri, languageId: languageId, version: version, text: text };\r
5366     }\r
5367     TextDocumentItem.create = create;\r
5368     /**\r
5369      * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.\r
5370      */\r
5371     function is(value) {\r
5372         var candidate = value;\r
5373         return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);\r
5374     }\r
5375     TextDocumentItem.is = is;\r
5376 })(TextDocumentItem || (TextDocumentItem = {}));\r
5377 /**\r
5378  * Describes the content type that a client supports in various\r
5379  * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.\r
5380  *\r
5381  * Please note that `MarkupKinds` must not start with a `$`. This kinds\r
5382  * are reserved for internal usage.\r
5383  */\r
5384 var MarkupKind;\r
5385 (function (MarkupKind) {\r
5386     /**\r
5387      * Plain text is supported as a content format\r
5388      */\r
5389     MarkupKind.PlainText = 'plaintext';\r
5390     /**\r
5391      * Markdown is supported as a content format\r
5392      */\r
5393     MarkupKind.Markdown = 'markdown';\r
5394 })(MarkupKind || (MarkupKind = {}));\r
5395 (function (MarkupKind) {\r
5396     /**\r
5397      * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.\r
5398      */\r
5399     function is(value) {\r
5400         var candidate = value;\r
5401         return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;\r
5402     }\r
5403     MarkupKind.is = is;\r
5404 })(MarkupKind || (MarkupKind = {}));\r
5405 var MarkupContent;\r
5406 (function (MarkupContent) {\r
5407     /**\r
5408      * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.\r
5409      */\r
5410     function is(value) {\r
5411         var candidate = value;\r
5412         return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);\r
5413     }\r
5414     MarkupContent.is = is;\r
5415 })(MarkupContent || (MarkupContent = {}));\r
5416 /**\r
5417  * The kind of a completion entry.\r
5418  */\r
5419 var CompletionItemKind;\r
5420 (function (CompletionItemKind) {\r
5421     CompletionItemKind.Text = 1;\r
5422     CompletionItemKind.Method = 2;\r
5423     CompletionItemKind.Function = 3;\r
5424     CompletionItemKind.Constructor = 4;\r
5425     CompletionItemKind.Field = 5;\r
5426     CompletionItemKind.Variable = 6;\r
5427     CompletionItemKind.Class = 7;\r
5428     CompletionItemKind.Interface = 8;\r
5429     CompletionItemKind.Module = 9;\r
5430     CompletionItemKind.Property = 10;\r
5431     CompletionItemKind.Unit = 11;\r
5432     CompletionItemKind.Value = 12;\r
5433     CompletionItemKind.Enum = 13;\r
5434     CompletionItemKind.Keyword = 14;\r
5435     CompletionItemKind.Snippet = 15;\r
5436     CompletionItemKind.Color = 16;\r
5437     CompletionItemKind.File = 17;\r
5438     CompletionItemKind.Reference = 18;\r
5439     CompletionItemKind.Folder = 19;\r
5440     CompletionItemKind.EnumMember = 20;\r
5441     CompletionItemKind.Constant = 21;\r
5442     CompletionItemKind.Struct = 22;\r
5443     CompletionItemKind.Event = 23;\r
5444     CompletionItemKind.Operator = 24;\r
5445     CompletionItemKind.TypeParameter = 25;\r
5446 })(CompletionItemKind || (CompletionItemKind = {}));\r
5447 /**\r
5448  * Defines whether the insert text in a completion item should be interpreted as\r
5449  * plain text or a snippet.\r
5450  */\r
5451 var InsertTextFormat;\r
5452 (function (InsertTextFormat) {\r
5453     /**\r
5454      * The primary text to be inserted is treated as a plain string.\r
5455      */\r
5456     InsertTextFormat.PlainText = 1;\r
5457     /**\r
5458      * The primary text to be inserted is treated as a snippet.\r
5459      *\r
5460      * A snippet can define tab stops and placeholders with `$1`, `$2`\r
5461      * and `${3:foo}`. `$0` defines the final tab stop, it defaults to\r
5462      * the end of the snippet. Placeholders with equal identifiers are linked,\r
5463      * that is typing in one will update others too.\r
5464      *\r
5465      * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md\r
5466      */\r
5467     InsertTextFormat.Snippet = 2;\r
5468 })(InsertTextFormat || (InsertTextFormat = {}));\r
5469 /**\r
5470  * The CompletionItem namespace provides functions to deal with\r
5471  * completion items.\r
5472  */\r
5473 var CompletionItem;\r
5474 (function (CompletionItem) {\r
5475     /**\r
5476      * Create a completion item and seed it with a label.\r
5477      * @param label The completion item's label\r
5478      */\r
5479     function create(label) {\r
5480         return { label: label };\r
5481     }\r
5482     CompletionItem.create = create;\r
5483 })(CompletionItem || (CompletionItem = {}));\r
5484 /**\r
5485  * The CompletionList namespace provides functions to deal with\r
5486  * completion lists.\r
5487  */\r
5488 var CompletionList;\r
5489 (function (CompletionList) {\r
5490     /**\r
5491      * Creates a new completion list.\r
5492      *\r
5493      * @param items The completion items.\r
5494      * @param isIncomplete The list is not complete.\r
5495      */\r
5496     function create(items, isIncomplete) {\r
5497         return { items: items ? items : [], isIncomplete: !!isIncomplete };\r
5498     }\r
5499     CompletionList.create = create;\r
5500 })(CompletionList || (CompletionList = {}));\r
5501 var MarkedString;\r
5502 (function (MarkedString) {\r
5503     /**\r
5504      * Creates a marked string from plain text.\r
5505      *\r
5506      * @param plainText The plain text.\r
5507      */\r
5508     function fromPlainText(plainText) {\r
5509         return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\r
5510     }\r
5511     MarkedString.fromPlainText = fromPlainText;\r
5512     /**\r
5513      * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.\r
5514      */\r
5515     function is(value) {\r
5516         var candidate = value;\r
5517         return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));\r
5518     }\r
5519     MarkedString.is = is;\r
5520 })(MarkedString || (MarkedString = {}));\r
5521 var Hover;\r
5522 (function (Hover) {\r
5523     /**\r
5524      * Checks whether the given value conforms to the [Hover](#Hover) interface.\r
5525      */\r
5526     function is(value) {\r
5527         var candidate = value;\r
5528         return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||\r
5529             MarkedString.is(candidate.contents) ||\r
5530             Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));\r
5531     }\r
5532     Hover.is = is;\r
5533 })(Hover || (Hover = {}));\r
5534 /**\r
5535  * The ParameterInformation namespace provides helper functions to work with\r
5536  * [ParameterInformation](#ParameterInformation) literals.\r
5537  */\r
5538 var ParameterInformation;\r
5539 (function (ParameterInformation) {\r
5540     /**\r
5541      * Creates a new parameter information literal.\r
5542      *\r
5543      * @param label A label string.\r
5544      * @param documentation A doc string.\r
5545      */\r
5546     function create(label, documentation) {\r
5547         return documentation ? { label: label, documentation: documentation } : { label: label };\r
5548     }\r
5549     ParameterInformation.create = create;\r
5550     ;\r
5551 })(ParameterInformation || (ParameterInformation = {}));\r
5552 /**\r
5553  * The SignatureInformation namespace provides helper functions to work with\r
5554  * [SignatureInformation](#SignatureInformation) literals.\r
5555  */\r
5556 var SignatureInformation;\r
5557 (function (SignatureInformation) {\r
5558     function create(label, documentation) {\r
5559         var parameters = [];\r
5560         for (var _i = 2; _i < arguments.length; _i++) {\r
5561             parameters[_i - 2] = arguments[_i];\r
5562         }\r
5563         var result = { label: label };\r
5564         if (Is.defined(documentation)) {\r
5565             result.documentation = documentation;\r
5566         }\r
5567         if (Is.defined(parameters)) {\r
5568             result.parameters = parameters;\r
5569         }\r
5570         else {\r
5571             result.parameters = [];\r
5572         }\r
5573         return result;\r
5574     }\r
5575     SignatureInformation.create = create;\r
5576 })(SignatureInformation || (SignatureInformation = {}));\r
5577 /**\r
5578  * A document highlight kind.\r
5579  */\r
5580 var DocumentHighlightKind;\r
5581 (function (DocumentHighlightKind) {\r
5582     /**\r
5583      * A textual occurrence.\r
5584      */\r
5585     DocumentHighlightKind.Text = 1;\r
5586     /**\r
5587      * Read-access of a symbol, like reading a variable.\r
5588      */\r
5589     DocumentHighlightKind.Read = 2;\r
5590     /**\r
5591      * Write-access of a symbol, like writing to a variable.\r
5592      */\r
5593     DocumentHighlightKind.Write = 3;\r
5594 })(DocumentHighlightKind || (DocumentHighlightKind = {}));\r
5595 /**\r
5596  * DocumentHighlight namespace to provide helper functions to work with\r
5597  * [DocumentHighlight](#DocumentHighlight) literals.\r
5598  */\r
5599 var DocumentHighlight;\r
5600 (function (DocumentHighlight) {\r
5601     /**\r
5602      * Create a DocumentHighlight object.\r
5603      * @param range The range the highlight applies to.\r
5604      */\r
5605     function create(range, kind) {\r
5606         var result = { range: range };\r
5607         if (Is.number(kind)) {\r
5608             result.kind = kind;\r
5609         }\r
5610         return result;\r
5611     }\r
5612     DocumentHighlight.create = create;\r
5613 })(DocumentHighlight || (DocumentHighlight = {}));\r
5614 /**\r
5615  * A symbol kind.\r
5616  */\r
5617 var SymbolKind;\r
5618 (function (SymbolKind) {\r
5619     SymbolKind.File = 1;\r
5620     SymbolKind.Module = 2;\r
5621     SymbolKind.Namespace = 3;\r
5622     SymbolKind.Package = 4;\r
5623     SymbolKind.Class = 5;\r
5624     SymbolKind.Method = 6;\r
5625     SymbolKind.Property = 7;\r
5626     SymbolKind.Field = 8;\r
5627     SymbolKind.Constructor = 9;\r
5628     SymbolKind.Enum = 10;\r
5629     SymbolKind.Interface = 11;\r
5630     SymbolKind.Function = 12;\r
5631     SymbolKind.Variable = 13;\r
5632     SymbolKind.Constant = 14;\r
5633     SymbolKind.String = 15;\r
5634     SymbolKind.Number = 16;\r
5635     SymbolKind.Boolean = 17;\r
5636     SymbolKind.Array = 18;\r
5637     SymbolKind.Object = 19;\r
5638     SymbolKind.Key = 20;\r
5639     SymbolKind.Null = 21;\r
5640     SymbolKind.EnumMember = 22;\r
5641     SymbolKind.Struct = 23;\r
5642     SymbolKind.Event = 24;\r
5643     SymbolKind.Operator = 25;\r
5644     SymbolKind.TypeParameter = 26;\r
5645 })(SymbolKind || (SymbolKind = {}));\r
5646 var SymbolInformation;\r
5647 (function (SymbolInformation) {\r
5648     /**\r
5649      * Creates a new symbol information literal.\r
5650      *\r
5651      * @param name The name of the symbol.\r
5652      * @param kind The kind of the symbol.\r
5653      * @param range The range of the location of the symbol.\r
5654      * @param uri The resource of the location of symbol, defaults to the current document.\r
5655      * @param containerName The name of the symbol containing the symbol.\r
5656      */\r
5657     function create(name, kind, range, uri, containerName) {\r
5658         var result = {\r
5659             name: name,\r
5660             kind: kind,\r
5661             location: { uri: uri, range: range }\r
5662         };\r
5663         if (containerName) {\r
5664             result.containerName = containerName;\r
5665         }\r
5666         return result;\r
5667     }\r
5668     SymbolInformation.create = create;\r
5669 })(SymbolInformation || (SymbolInformation = {}));\r
5670 /**\r
5671  * Represents programming constructs like variables, classes, interfaces etc.\r
5672  * that appear in a document. Document symbols can be hierarchical and they\r
5673  * have two ranges: one that encloses its definition and one that points to\r
5674  * its most interesting range, e.g. the range of an identifier.\r
5675  */\r
5676 var DocumentSymbol = /** @class */ (function () {\r
5677     function DocumentSymbol() {\r
5678     }\r
5679     return DocumentSymbol;\r
5680 }());\r
5681 \r
5682 (function (DocumentSymbol) {\r
5683     /**\r
5684      * Creates a new symbol information literal.\r
5685      *\r
5686      * @param name The name of the symbol.\r
5687      * @param detail The detail of the symbol.\r
5688      * @param kind The kind of the symbol.\r
5689      * @param range The range of the symbol.\r
5690      * @param selectionRange The selectionRange of the symbol.\r
5691      * @param children Children of the symbol.\r
5692      */\r
5693     function create(name, detail, kind, range, selectionRange, children) {\r
5694         var result = {\r
5695             name: name,\r
5696             detail: detail,\r
5697             kind: kind,\r
5698             range: range,\r
5699             selectionRange: selectionRange\r
5700         };\r
5701         if (children !== void 0) {\r
5702             result.children = children;\r
5703         }\r
5704         return result;\r
5705     }\r
5706     DocumentSymbol.create = create;\r
5707     /**\r
5708      * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.\r
5709      */\r
5710     function is(value) {\r
5711         var candidate = value;\r
5712         return candidate &&\r
5713             Is.string(candidate.name) && Is.number(candidate.kind) &&\r
5714             Range.is(candidate.range) && Range.is(candidate.selectionRange) &&\r
5715             (candidate.detail === void 0 || Is.string(candidate.detail)) &&\r
5716             (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&\r
5717             (candidate.children === void 0 || Array.isArray(candidate.children));\r
5718     }\r
5719     DocumentSymbol.is = is;\r
5720 })(DocumentSymbol || (DocumentSymbol = {}));\r
5721 /**\r
5722  * A set of predefined code action kinds\r
5723  */\r
5724 var CodeActionKind;\r
5725 (function (CodeActionKind) {\r
5726     /**\r
5727      * Base kind for quickfix actions: 'quickfix'\r
5728      */\r
5729     CodeActionKind.QuickFix = 'quickfix';\r
5730     /**\r
5731      * Base kind for refactoring actions: 'refactor'\r
5732      */\r
5733     CodeActionKind.Refactor = 'refactor';\r
5734     /**\r
5735      * Base kind for refactoring extraction actions: 'refactor.extract'\r
5736      *\r
5737      * Example extract actions:\r
5738      *\r
5739      * - Extract method\r
5740      * - Extract function\r
5741      * - Extract variable\r
5742      * - Extract interface from class\r
5743      * - ...\r
5744      */\r
5745     CodeActionKind.RefactorExtract = 'refactor.extract';\r
5746     /**\r
5747      * Base kind for refactoring inline actions: 'refactor.inline'\r
5748      *\r
5749      * Example inline actions:\r
5750      *\r
5751      * - Inline function\r
5752      * - Inline variable\r
5753      * - Inline constant\r
5754      * - ...\r
5755      */\r
5756     CodeActionKind.RefactorInline = 'refactor.inline';\r
5757     /**\r
5758      * Base kind for refactoring rewrite actions: 'refactor.rewrite'\r
5759      *\r
5760      * Example rewrite actions:\r
5761      *\r
5762      * - Convert JavaScript function to class\r
5763      * - Add or remove parameter\r
5764      * - Encapsulate field\r
5765      * - Make method static\r
5766      * - Move method to base class\r
5767      * - ...\r
5768      */\r
5769     CodeActionKind.RefactorRewrite = 'refactor.rewrite';\r
5770     /**\r
5771      * Base kind for source actions: `source`\r
5772      *\r
5773      * Source code actions apply to the entire file.\r
5774      */\r
5775     CodeActionKind.Source = 'source';\r
5776     /**\r
5777      * Base kind for an organize imports source action: `source.organizeImports`\r
5778      */\r
5779     CodeActionKind.SourceOrganizeImports = 'source.organizeImports';\r
5780 })(CodeActionKind || (CodeActionKind = {}));\r
5781 /**\r
5782  * The CodeActionContext namespace provides helper functions to work with\r
5783  * [CodeActionContext](#CodeActionContext) literals.\r
5784  */\r
5785 var CodeActionContext;\r
5786 (function (CodeActionContext) {\r
5787     /**\r
5788      * Creates a new CodeActionContext literal.\r
5789      */\r
5790     function create(diagnostics, only) {\r
5791         var result = { diagnostics: diagnostics };\r
5792         if (only !== void 0 && only !== null) {\r
5793             result.only = only;\r
5794         }\r
5795         return result;\r
5796     }\r
5797     CodeActionContext.create = create;\r
5798     /**\r
5799      * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.\r
5800      */\r
5801     function is(value) {\r
5802         var candidate = value;\r
5803         return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));\r
5804     }\r
5805     CodeActionContext.is = is;\r
5806 })(CodeActionContext || (CodeActionContext = {}));\r
5807 var CodeAction;\r
5808 (function (CodeAction) {\r
5809     function create(title, commandOrEdit, kind) {\r
5810         var result = { title: title };\r
5811         if (Command.is(commandOrEdit)) {\r
5812             result.command = commandOrEdit;\r
5813         }\r
5814         else {\r
5815             result.edit = commandOrEdit;\r
5816         }\r
5817         if (kind !== void null) {\r
5818             result.kind = kind;\r
5819         }\r
5820         return result;\r
5821     }\r
5822     CodeAction.create = create;\r
5823     function is(value) {\r
5824         var candidate = value;\r
5825         return candidate && Is.string(candidate.title) &&\r
5826             (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&\r
5827             (candidate.kind === void 0 || Is.string(candidate.kind)) &&\r
5828             (candidate.edit !== void 0 || candidate.command !== void 0) &&\r
5829             (candidate.command === void 0 || Command.is(candidate.command)) &&\r
5830             (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));\r
5831     }\r
5832     CodeAction.is = is;\r
5833 })(CodeAction || (CodeAction = {}));\r
5834 /**\r
5835  * The CodeLens namespace provides helper functions to work with\r
5836  * [CodeLens](#CodeLens) literals.\r
5837  */\r
5838 var CodeLens;\r
5839 (function (CodeLens) {\r
5840     /**\r
5841      * Creates a new CodeLens literal.\r
5842      */\r
5843     function create(range, data) {\r
5844         var result = { range: range };\r
5845         if (Is.defined(data))\r
5846             result.data = data;\r
5847         return result;\r
5848     }\r
5849     CodeLens.create = create;\r
5850     /**\r
5851      * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.\r
5852      */\r
5853     function is(value) {\r
5854         var candidate = value;\r
5855         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));\r
5856     }\r
5857     CodeLens.is = is;\r
5858 })(CodeLens || (CodeLens = {}));\r
5859 /**\r
5860  * The FormattingOptions namespace provides helper functions to work with\r
5861  * [FormattingOptions](#FormattingOptions) literals.\r
5862  */\r
5863 var FormattingOptions;\r
5864 (function (FormattingOptions) {\r
5865     /**\r
5866      * Creates a new FormattingOptions literal.\r
5867      */\r
5868     function create(tabSize, insertSpaces) {\r
5869         return { tabSize: tabSize, insertSpaces: insertSpaces };\r
5870     }\r
5871     FormattingOptions.create = create;\r
5872     /**\r
5873      * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.\r
5874      */\r
5875     function is(value) {\r
5876         var candidate = value;\r
5877         return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);\r
5878     }\r
5879     FormattingOptions.is = is;\r
5880 })(FormattingOptions || (FormattingOptions = {}));\r
5881 /**\r
5882  * A document link is a range in a text document that links to an internal or external resource, like another\r
5883  * text document or a web site.\r
5884  */\r
5885 var DocumentLink = /** @class */ (function () {\r
5886     function DocumentLink() {\r
5887     }\r
5888     return DocumentLink;\r
5889 }());\r
5890 \r
5891 /**\r
5892  * The DocumentLink namespace provides helper functions to work with\r
5893  * [DocumentLink](#DocumentLink) literals.\r
5894  */\r
5895 (function (DocumentLink) {\r
5896     /**\r
5897      * Creates a new DocumentLink literal.\r
5898      */\r
5899     function create(range, target, data) {\r
5900         return { range: range, target: target, data: data };\r
5901     }\r
5902     DocumentLink.create = create;\r
5903     /**\r
5904      * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.\r
5905      */\r
5906     function is(value) {\r
5907         var candidate = value;\r
5908         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));\r
5909     }\r
5910     DocumentLink.is = is;\r
5911 })(DocumentLink || (DocumentLink = {}));\r
5912 var EOL = ['\n', '\r\n', '\r'];\r
5913 var TextDocument;\r
5914 (function (TextDocument) {\r
5915     /**\r
5916      * Creates a new ITextDocument literal from the given uri and content.\r
5917      * @param uri The document's uri.\r
5918      * @param languageId  The document's language Id.\r
5919      * @param content The document's content.\r
5920      */\r
5921     function create(uri, languageId, version, content) {\r
5922         return new FullTextDocument(uri, languageId, version, content);\r
5923     }\r
5924     TextDocument.create = create;\r
5925     /**\r
5926      * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.\r
5927      */\r
5928     function is(value) {\r
5929         var candidate = value;\r
5930         return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)\r
5931             && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;\r
5932     }\r
5933     TextDocument.is = is;\r
5934     function applyEdits(document, edits) {\r
5935         var text = document.getText();\r
5936         var sortedEdits = mergeSort(edits, function (a, b) {\r
5937             var diff = a.range.start.line - b.range.start.line;\r
5938             if (diff === 0) {\r
5939                 return a.range.start.character - b.range.start.character;\r
5940             }\r
5941             return diff;\r
5942         });\r
5943         var lastModifiedOffset = text.length;\r
5944         for (var i = sortedEdits.length - 1; i >= 0; i--) {\r
5945             var e = sortedEdits[i];\r
5946             var startOffset = document.offsetAt(e.range.start);\r
5947             var endOffset = document.offsetAt(e.range.end);\r
5948             if (endOffset <= lastModifiedOffset) {\r
5949                 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);\r
5950             }\r
5951             else {\r
5952                 throw new Error('Overlapping edit');\r
5953             }\r
5954             lastModifiedOffset = startOffset;\r
5955         }\r
5956         return text;\r
5957     }\r
5958     TextDocument.applyEdits = applyEdits;\r
5959     function mergeSort(data, compare) {\r
5960         if (data.length <= 1) {\r
5961             // sorted\r
5962             return data;\r
5963         }\r
5964         var p = (data.length / 2) | 0;\r
5965         var left = data.slice(0, p);\r
5966         var right = data.slice(p);\r
5967         mergeSort(left, compare);\r
5968         mergeSort(right, compare);\r
5969         var leftIdx = 0;\r
5970         var rightIdx = 0;\r
5971         var i = 0;\r
5972         while (leftIdx < left.length && rightIdx < right.length) {\r
5973             var ret = compare(left[leftIdx], right[rightIdx]);\r
5974             if (ret <= 0) {\r
5975                 // smaller_equal -> take left to preserve order\r
5976                 data[i++] = left[leftIdx++];\r
5977             }\r
5978             else {\r
5979                 // greater -> take right\r
5980                 data[i++] = right[rightIdx++];\r
5981             }\r
5982         }\r
5983         while (leftIdx < left.length) {\r
5984             data[i++] = left[leftIdx++];\r
5985         }\r
5986         while (rightIdx < right.length) {\r
5987             data[i++] = right[rightIdx++];\r
5988         }\r
5989         return data;\r
5990     }\r
5991 })(TextDocument || (TextDocument = {}));\r
5992 /**\r
5993  * Represents reasons why a text document is saved.\r
5994  */\r
5995 var TextDocumentSaveReason;\r
5996 (function (TextDocumentSaveReason) {\r
5997     /**\r
5998      * Manually triggered, e.g. by the user pressing save, by starting debugging,\r
5999      * or by an API call.\r
6000      */\r
6001     TextDocumentSaveReason.Manual = 1;\r
6002     /**\r
6003      * Automatic after a delay.\r
6004      */\r
6005     TextDocumentSaveReason.AfterDelay = 2;\r
6006     /**\r
6007      * When the editor lost focus.\r
6008      */\r
6009     TextDocumentSaveReason.FocusOut = 3;\r
6010 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));\r
6011 var FullTextDocument = /** @class */ (function () {\r
6012     function FullTextDocument(uri, languageId, version, content) {\r
6013         this._uri = uri;\r
6014         this._languageId = languageId;\r
6015         this._version = version;\r
6016         this._content = content;\r
6017         this._lineOffsets = null;\r
6018     }\r
6019     Object.defineProperty(FullTextDocument.prototype, "uri", {\r
6020         get: function () {\r
6021             return this._uri;\r
6022         },\r
6023         enumerable: true,\r
6024         configurable: true\r
6025     });\r
6026     Object.defineProperty(FullTextDocument.prototype, "languageId", {\r
6027         get: function () {\r
6028             return this._languageId;\r
6029         },\r
6030         enumerable: true,\r
6031         configurable: true\r
6032     });\r
6033     Object.defineProperty(FullTextDocument.prototype, "version", {\r
6034         get: function () {\r
6035             return this._version;\r
6036         },\r
6037         enumerable: true,\r
6038         configurable: true\r
6039     });\r
6040     FullTextDocument.prototype.getText = function (range) {\r
6041         if (range) {\r
6042             var start = this.offsetAt(range.start);\r
6043             var end = this.offsetAt(range.end);\r
6044             return this._content.substring(start, end);\r
6045         }\r
6046         return this._content;\r
6047     };\r
6048     FullTextDocument.prototype.update = function (event, version) {\r
6049         this._content = event.text;\r
6050         this._version = version;\r
6051         this._lineOffsets = null;\r
6052     };\r
6053     FullTextDocument.prototype.getLineOffsets = function () {\r
6054         if (this._lineOffsets === null) {\r
6055             var lineOffsets = [];\r
6056             var text = this._content;\r
6057             var isLineStart = true;\r
6058             for (var i = 0; i < text.length; i++) {\r
6059                 if (isLineStart) {\r
6060                     lineOffsets.push(i);\r
6061                     isLineStart = false;\r
6062                 }\r
6063                 var ch = text.charAt(i);\r
6064                 isLineStart = (ch === '\r' || ch === '\n');\r
6065                 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {\r
6066                     i++;\r
6067                 }\r
6068             }\r
6069             if (isLineStart && text.length > 0) {\r
6070                 lineOffsets.push(text.length);\r
6071             }\r
6072             this._lineOffsets = lineOffsets;\r
6073         }\r
6074         return this._lineOffsets;\r
6075     };\r
6076     FullTextDocument.prototype.positionAt = function (offset) {\r
6077         offset = Math.max(Math.min(offset, this._content.length), 0);\r
6078         var lineOffsets = this.getLineOffsets();\r
6079         var low = 0, high = lineOffsets.length;\r
6080         if (high === 0) {\r
6081             return Position.create(0, offset);\r
6082         }\r
6083         while (low < high) {\r
6084             var mid = Math.floor((low + high) / 2);\r
6085             if (lineOffsets[mid] > offset) {\r
6086                 high = mid;\r
6087             }\r
6088             else {\r
6089                 low = mid + 1;\r
6090             }\r
6091         }\r
6092         // low is the least x for which the line offset is larger than the current offset\r
6093         // or array.length if no line offset is larger than the current offset\r
6094         var line = low - 1;\r
6095         return Position.create(line, offset - lineOffsets[line]);\r
6096     };\r
6097     FullTextDocument.prototype.offsetAt = function (position) {\r
6098         var lineOffsets = this.getLineOffsets();\r
6099         if (position.line >= lineOffsets.length) {\r
6100             return this._content.length;\r
6101         }\r
6102         else if (position.line < 0) {\r
6103             return 0;\r
6104         }\r
6105         var lineOffset = lineOffsets[position.line];\r
6106         var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;\r
6107         return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);\r
6108     };\r
6109     Object.defineProperty(FullTextDocument.prototype, "lineCount", {\r
6110         get: function () {\r
6111             return this.getLineOffsets().length;\r
6112         },\r
6113         enumerable: true,\r
6114         configurable: true\r
6115     });\r
6116     return FullTextDocument;\r
6117 }());\r
6118 var Is;\r
6119 (function (Is) {\r
6120     var toString = Object.prototype.toString;\r
6121     function defined(value) {\r
6122         return typeof value !== 'undefined';\r
6123     }\r
6124     Is.defined = defined;\r
6125     function undefined(value) {\r
6126         return typeof value === 'undefined';\r
6127     }\r
6128     Is.undefined = undefined;\r
6129     function boolean(value) {\r
6130         return value === true || value === false;\r
6131     }\r
6132     Is.boolean = boolean;\r
6133     function string(value) {\r
6134         return toString.call(value) === '[object String]';\r
6135     }\r
6136     Is.string = string;\r
6137     function number(value) {\r
6138         return toString.call(value) === '[object Number]';\r
6139     }\r
6140     Is.number = number;\r
6141     function func(value) {\r
6142         return toString.call(value) === '[object Function]';\r
6143     }\r
6144     Is.func = func;\r
6145     function objectLiteral(value) {\r
6146         // Strictly speaking class instances pass this check as well. Since the LSP\r
6147         // doesn't use classes we ignore this for now. If we do we need to add something\r
6148         // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`\r
6149         return value !== null && typeof value === 'object';\r
6150     }\r
6151     Is.objectLiteral = objectLiteral;\r
6152     function typedArray(value, check) {\r
6153         return Array.isArray(value) && value.every(check);\r
6154     }\r
6155     Is.typedArray = typedArray;\r
6156 })(Is || (Is = {}));\r
6157
6158
6159 /***/ }),
6160 /* 19 */
6161 /***/ (function(module, exports, __webpack_require__) {
6162
6163 "use strict";
6164 /* --------------------------------------------------------------------------------------------\r
6165  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6166  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6167  * ------------------------------------------------------------------------------------------ */\r
6168 \r
6169 Object.defineProperty(exports, "__esModule", { value: true });\r
6170 const Is = __webpack_require__(20);\r
6171 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6172 const protocol_implementation_1 = __webpack_require__(21);\r
6173 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;\r
6174 const protocol_typeDefinition_1 = __webpack_require__(22);\r
6175 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;\r
6176 const protocol_workspaceFolders_1 = __webpack_require__(23);\r
6177 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;\r
6178 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;\r
6179 const protocol_configuration_1 = __webpack_require__(24);\r
6180 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;\r
6181 const protocol_colorProvider_1 = __webpack_require__(25);\r
6182 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;\r
6183 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;\r
6184 const protocol_foldingRange_1 = __webpack_require__(26);\r
6185 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;\r
6186 const protocol_declaration_1 = __webpack_require__(27);\r
6187 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;\r
6188 const protocol_selectionRange_1 = __webpack_require__(28);\r
6189 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;\r
6190 exports.SelectionRangeKind = protocol_selectionRange_1.SelectionRangeKind;\r
6191 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
6192 let __noDynamicImport;\r
6193 var DocumentFilter;\r
6194 (function (DocumentFilter) {\r
6195     function is(value) {\r
6196         let candidate = value;\r
6197         return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);\r
6198     }\r
6199     DocumentFilter.is = is;\r
6200 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));\r
6201 /**\r
6202  * The `client/registerCapability` request is sent from the server to the client to register a new capability\r
6203  * handler on the client side.\r
6204  */\r
6205 var RegistrationRequest;\r
6206 (function (RegistrationRequest) {\r
6207     RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');\r
6208 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));\r
6209 /**\r
6210  * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability\r
6211  * handler on the client side.\r
6212  */\r
6213 var UnregistrationRequest;\r
6214 (function (UnregistrationRequest) {\r
6215     UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');\r
6216 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));\r
6217 var ResourceOperationKind;\r
6218 (function (ResourceOperationKind) {\r
6219     /**\r
6220      * Supports creating new files and folders.\r
6221      */\r
6222     ResourceOperationKind.Create = 'create';\r
6223     /**\r
6224      * Supports renaming existing files and folders.\r
6225      */\r
6226     ResourceOperationKind.Rename = 'rename';\r
6227     /**\r
6228      * Supports deleting existing files and folders.\r
6229      */\r
6230     ResourceOperationKind.Delete = 'delete';\r
6231 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));\r
6232 var FailureHandlingKind;\r
6233 (function (FailureHandlingKind) {\r
6234     /**\r
6235      * Applying the workspace change is simply aborted if one of the changes provided\r
6236      * fails. All operations executed before the failing operation stay executed.\r
6237      */\r
6238     FailureHandlingKind.Abort = 'abort';\r
6239     /**\r
6240      * All operations are executed transactional. That means they either all\r
6241      * succeed or no changes at all are applied to the workspace.\r
6242      */\r
6243     FailureHandlingKind.Transactional = 'transactional';\r
6244     /**\r
6245      * If the workspace edit contains only textual file changes they are executed transactional.\r
6246      * If resource changes (create, rename or delete file) are part of the change the failure\r
6247      * handling startegy is abort.\r
6248      */\r
6249     FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';\r
6250     /**\r
6251      * The client tries to undo the operations already executed. But there is no\r
6252      * guaruntee that this is succeeding.\r
6253      */\r
6254     FailureHandlingKind.Undo = 'undo';\r
6255 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));\r
6256 /**\r
6257  * Defines how the host (editor) should sync\r
6258  * document changes to the language server.\r
6259  */\r
6260 var TextDocumentSyncKind;\r
6261 (function (TextDocumentSyncKind) {\r
6262     /**\r
6263      * Documents should not be synced at all.\r
6264      */\r
6265     TextDocumentSyncKind.None = 0;\r
6266     /**\r
6267      * Documents are synced by always sending the full content\r
6268      * of the document.\r
6269      */\r
6270     TextDocumentSyncKind.Full = 1;\r
6271     /**\r
6272      * Documents are synced by sending the full content on open.\r
6273      * After that only incremental updates to the document are\r
6274      * send.\r
6275      */\r
6276     TextDocumentSyncKind.Incremental = 2;\r
6277 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));\r
6278 /**\r
6279  * The initialize request is sent from the client to the server.\r
6280  * It is sent once as the request after starting up the server.\r
6281  * The requests parameter is of type [InitializeParams](#InitializeParams)\r
6282  * the response if of type [InitializeResult](#InitializeResult) of a Thenable that\r
6283  * resolves to such.\r
6284  */\r
6285 var InitializeRequest;\r
6286 (function (InitializeRequest) {\r
6287     InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');\r
6288 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));\r
6289 /**\r
6290  * Known error codes for an `InitializeError`;\r
6291  */\r
6292 var InitializeError;\r
6293 (function (InitializeError) {\r
6294     /**\r
6295      * If the protocol version provided by the client can't be handled by the server.\r
6296      * @deprecated This initialize error got replaced by client capabilities. There is\r
6297      * no version handshake in version 3.0x\r
6298      */\r
6299     InitializeError.unknownProtocolVersion = 1;\r
6300 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));\r
6301 /**\r
6302  * The intialized notification is sent from the client to the\r
6303  * server after the client is fully initialized and the server\r
6304  * is allowed to send requests from the server to the client.\r
6305  */\r
6306 var InitializedNotification;\r
6307 (function (InitializedNotification) {\r
6308     InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');\r
6309 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));\r
6310 //---- Shutdown Method ----\r
6311 /**\r
6312  * A shutdown request is sent from the client to the server.\r
6313  * It is sent once when the client decides to shutdown the\r
6314  * server. The only notification that is sent after a shutdown request\r
6315  * is the exit event.\r
6316  */\r
6317 var ShutdownRequest;\r
6318 (function (ShutdownRequest) {\r
6319     ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');\r
6320 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));\r
6321 //---- Exit Notification ----\r
6322 /**\r
6323  * The exit event is sent from the client to the server to\r
6324  * ask the server to exit its process.\r
6325  */\r
6326 var ExitNotification;\r
6327 (function (ExitNotification) {\r
6328     ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');\r
6329 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));\r
6330 //---- Configuration notification ----\r
6331 /**\r
6332  * The configuration change notification is sent from the client to the server\r
6333  * when the client's configuration has changed. The notification contains\r
6334  * the changed configuration as defined by the language client.\r
6335  */\r
6336 var DidChangeConfigurationNotification;\r
6337 (function (DidChangeConfigurationNotification) {\r
6338     DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');\r
6339 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));\r
6340 //---- Message show and log notifications ----\r
6341 /**\r
6342  * The message type\r
6343  */\r
6344 var MessageType;\r
6345 (function (MessageType) {\r
6346     /**\r
6347      * An error message.\r
6348      */\r
6349     MessageType.Error = 1;\r
6350     /**\r
6351      * A warning message.\r
6352      */\r
6353     MessageType.Warning = 2;\r
6354     /**\r
6355      * An information message.\r
6356      */\r
6357     MessageType.Info = 3;\r
6358     /**\r
6359      * A log message.\r
6360      */\r
6361     MessageType.Log = 4;\r
6362 })(MessageType = exports.MessageType || (exports.MessageType = {}));\r
6363 /**\r
6364  * The show message notification is sent from a server to a client to ask\r
6365  * the client to display a particular message in the user interface.\r
6366  */\r
6367 var ShowMessageNotification;\r
6368 (function (ShowMessageNotification) {\r
6369     ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');\r
6370 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));\r
6371 /**\r
6372  * The show message request is sent from the server to the client to show a message\r
6373  * and a set of options actions to the user.\r
6374  */\r
6375 var ShowMessageRequest;\r
6376 (function (ShowMessageRequest) {\r
6377     ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');\r
6378 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));\r
6379 /**\r
6380  * The log message notification is sent from the server to the client to ask\r
6381  * the client to log a particular message.\r
6382  */\r
6383 var LogMessageNotification;\r
6384 (function (LogMessageNotification) {\r
6385     LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');\r
6386 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));\r
6387 //---- Telemetry notification\r
6388 /**\r
6389  * The telemetry event notification is sent from the server to the client to ask\r
6390  * the client to log telemetry data.\r
6391  */\r
6392 var TelemetryEventNotification;\r
6393 (function (TelemetryEventNotification) {\r
6394     TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');\r
6395 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));\r
6396 /**\r
6397  * The document open notification is sent from the client to the server to signal\r
6398  * newly opened text documents. The document's truth is now managed by the client\r
6399  * and the server must not try to read the document's truth using the document's\r
6400  * uri. Open in this sense means it is managed by the client. It doesn't necessarily\r
6401  * mean that its content is presented in an editor. An open notification must not\r
6402  * be sent more than once without a corresponding close notification send before.\r
6403  * This means open and close notification must be balanced and the max open count\r
6404  * is one.\r
6405  */\r
6406 var DidOpenTextDocumentNotification;\r
6407 (function (DidOpenTextDocumentNotification) {\r
6408     DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');\r
6409 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));\r
6410 /**\r
6411  * The document change notification is sent from the client to the server to signal\r
6412  * changes to a text document.\r
6413  */\r
6414 var DidChangeTextDocumentNotification;\r
6415 (function (DidChangeTextDocumentNotification) {\r
6416     DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');\r
6417 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));\r
6418 /**\r
6419  * The document close notification is sent from the client to the server when\r
6420  * the document got closed in the client. The document's truth now exists where\r
6421  * the document's uri points to (e.g. if the document's uri is a file uri the\r
6422  * truth now exists on disk). As with the open notification the close notification\r
6423  * is about managing the document's content. Receiving a close notification\r
6424  * doesn't mean that the document was open in an editor before. A close\r
6425  * notification requires a previous open notification to be sent.\r
6426  */\r
6427 var DidCloseTextDocumentNotification;\r
6428 (function (DidCloseTextDocumentNotification) {\r
6429     DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');\r
6430 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));\r
6431 /**\r
6432  * The document save notification is sent from the client to the server when\r
6433  * the document got saved in the client.\r
6434  */\r
6435 var DidSaveTextDocumentNotification;\r
6436 (function (DidSaveTextDocumentNotification) {\r
6437     DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');\r
6438 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));\r
6439 /**\r
6440  * A document will save notification is sent from the client to the server before\r
6441  * the document is actually saved.\r
6442  */\r
6443 var WillSaveTextDocumentNotification;\r
6444 (function (WillSaveTextDocumentNotification) {\r
6445     WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');\r
6446 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));\r
6447 /**\r
6448  * A document will save request is sent from the client to the server before\r
6449  * the document is actually saved. The request can return an array of TextEdits\r
6450  * which will be applied to the text document before it is saved. Please note that\r
6451  * clients might drop results if computing the text edits took too long or if a\r
6452  * server constantly fails on this request. This is done to keep the save fast and\r
6453  * reliable.\r
6454  */\r
6455 var WillSaveTextDocumentWaitUntilRequest;\r
6456 (function (WillSaveTextDocumentWaitUntilRequest) {\r
6457     WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');\r
6458 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));\r
6459 //---- File eventing ----\r
6460 /**\r
6461  * The watched files notification is sent from the client to the server when\r
6462  * the client detects changes to file watched by the language client.\r
6463  */\r
6464 var DidChangeWatchedFilesNotification;\r
6465 (function (DidChangeWatchedFilesNotification) {\r
6466     DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');\r
6467 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));\r
6468 /**\r
6469  * The file event type\r
6470  */\r
6471 var FileChangeType;\r
6472 (function (FileChangeType) {\r
6473     /**\r
6474      * The file got created.\r
6475      */\r
6476     FileChangeType.Created = 1;\r
6477     /**\r
6478      * The file got changed.\r
6479      */\r
6480     FileChangeType.Changed = 2;\r
6481     /**\r
6482      * The file got deleted.\r
6483      */\r
6484     FileChangeType.Deleted = 3;\r
6485 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));\r
6486 var WatchKind;\r
6487 (function (WatchKind) {\r
6488     /**\r
6489      * Interested in create events.\r
6490      */\r
6491     WatchKind.Create = 1;\r
6492     /**\r
6493      * Interested in change events\r
6494      */\r
6495     WatchKind.Change = 2;\r
6496     /**\r
6497      * Interested in delete events\r
6498      */\r
6499     WatchKind.Delete = 4;\r
6500 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));\r
6501 //---- Diagnostic notification ----\r
6502 /**\r
6503  * Diagnostics notification are sent from the server to the client to signal\r
6504  * results of validation runs.\r
6505  */\r
6506 var PublishDiagnosticsNotification;\r
6507 (function (PublishDiagnosticsNotification) {\r
6508     PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');\r
6509 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));\r
6510 /**\r
6511  * How a completion was triggered\r
6512  */\r
6513 var CompletionTriggerKind;\r
6514 (function (CompletionTriggerKind) {\r
6515     /**\r
6516      * Completion was triggered by typing an identifier (24x7 code\r
6517      * complete), manual invocation (e.g Ctrl+Space) or via API.\r
6518      */\r
6519     CompletionTriggerKind.Invoked = 1;\r
6520     /**\r
6521      * Completion was triggered by a trigger character specified by\r
6522      * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.\r
6523      */\r
6524     CompletionTriggerKind.TriggerCharacter = 2;\r
6525     /**\r
6526      * Completion was re-triggered as current completion list is incomplete\r
6527      */\r
6528     CompletionTriggerKind.TriggerForIncompleteCompletions = 3;\r
6529 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));\r
6530 /**\r
6531  * Request to request completion at a given text document position. The request's\r
6532  * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response\r
6533  * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)\r
6534  * or a Thenable that resolves to such.\r
6535  *\r
6536  * The request can delay the computation of the [`detail`](#CompletionItem.detail)\r
6537  * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`\r
6538  * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,\r
6539  * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.\r
6540  */\r
6541 var CompletionRequest;\r
6542 (function (CompletionRequest) {\r
6543     CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');\r
6544 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));\r
6545 /**\r
6546  * Request to resolve additional information for a given completion item.The request's\r
6547  * parameter is of type [CompletionItem](#CompletionItem) the response\r
6548  * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.\r
6549  */\r
6550 var CompletionResolveRequest;\r
6551 (function (CompletionResolveRequest) {\r
6552     CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');\r
6553 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));\r
6554 //---- Hover Support -------------------------------\r
6555 /**\r
6556  * Request to request hover information at a given text document position. The request's\r
6557  * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of\r
6558  * type [Hover](#Hover) or a Thenable that resolves to such.\r
6559  */\r
6560 var HoverRequest;\r
6561 (function (HoverRequest) {\r
6562     HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');\r
6563 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));\r
6564 var SignatureHelpRequest;\r
6565 (function (SignatureHelpRequest) {\r
6566     SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');\r
6567 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));\r
6568 //---- Goto Definition -------------------------------------\r
6569 /**\r
6570  * A request to resolve the definition location of a symbol at a given text\r
6571  * document position. The request's parameter is of type [TextDocumentPosition]\r
6572  * (#TextDocumentPosition) the response is of either type [Definition](#Definition)\r
6573  * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves\r
6574  * to such.\r
6575  */\r
6576 var DefinitionRequest;\r
6577 (function (DefinitionRequest) {\r
6578     DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');\r
6579 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));\r
6580 /**\r
6581  * A request to resolve project-wide references for the symbol denoted\r
6582  * by the given text document position. The request's parameter is of\r
6583  * type [ReferenceParams](#ReferenceParams) the response is of type\r
6584  * [Location[]](#Location) or a Thenable that resolves to such.\r
6585  */\r
6586 var ReferencesRequest;\r
6587 (function (ReferencesRequest) {\r
6588     ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');\r
6589 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));\r
6590 //---- Document Highlight ----------------------------------\r
6591 /**\r
6592  * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given\r
6593  * text document position. The request's parameter is of type [TextDocumentPosition]\r
6594  * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]\r
6595  * (#DocumentHighlight) or a Thenable that resolves to such.\r
6596  */\r
6597 var DocumentHighlightRequest;\r
6598 (function (DocumentHighlightRequest) {\r
6599     DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');\r
6600 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));\r
6601 //---- Document Symbol Provider ---------------------------\r
6602 /**\r
6603  * A request to list all symbols found in a given text document. The request's\r
6604  * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the\r
6605  * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable\r
6606  * that resolves to such.\r
6607  */\r
6608 var DocumentSymbolRequest;\r
6609 (function (DocumentSymbolRequest) {\r
6610     DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');\r
6611 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));\r
6612 //---- Workspace Symbol Provider ---------------------------\r
6613 /**\r
6614  * A request to list project-wide symbols matching the query string given\r
6615  * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is\r
6616  * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that\r
6617  * resolves to such.\r
6618  */\r
6619 var WorkspaceSymbolRequest;\r
6620 (function (WorkspaceSymbolRequest) {\r
6621     WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');\r
6622 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));\r
6623 /**\r
6624  * A request to provide commands for the given text document and range.\r
6625  */\r
6626 var CodeActionRequest;\r
6627 (function (CodeActionRequest) {\r
6628     CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');\r
6629 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));\r
6630 /**\r
6631  * A request to provide code lens for the given text document.\r
6632  */\r
6633 var CodeLensRequest;\r
6634 (function (CodeLensRequest) {\r
6635     CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');\r
6636 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));\r
6637 /**\r
6638  * A request to resolve a command for a given code lens.\r
6639  */\r
6640 var CodeLensResolveRequest;\r
6641 (function (CodeLensResolveRequest) {\r
6642     CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');\r
6643 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));\r
6644 /**\r
6645  * A request to to format a whole document.\r
6646  */\r
6647 var DocumentFormattingRequest;\r
6648 (function (DocumentFormattingRequest) {\r
6649     DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');\r
6650 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));\r
6651 /**\r
6652  * A request to to format a range in a document.\r
6653  */\r
6654 var DocumentRangeFormattingRequest;\r
6655 (function (DocumentRangeFormattingRequest) {\r
6656     DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');\r
6657 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));\r
6658 /**\r
6659  * A request to format a document on type.\r
6660  */\r
6661 var DocumentOnTypeFormattingRequest;\r
6662 (function (DocumentOnTypeFormattingRequest) {\r
6663     DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');\r
6664 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));\r
6665 /**\r
6666  * A request to rename a symbol.\r
6667  */\r
6668 var RenameRequest;\r
6669 (function (RenameRequest) {\r
6670     RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');\r
6671 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));\r
6672 /**\r
6673  * A request to test and perform the setup necessary for a rename.\r
6674  */\r
6675 var PrepareRenameRequest;\r
6676 (function (PrepareRenameRequest) {\r
6677     PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');\r
6678 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));\r
6679 /**\r
6680  * A request to provide document links\r
6681  */\r
6682 var DocumentLinkRequest;\r
6683 (function (DocumentLinkRequest) {\r
6684     DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');\r
6685 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));\r
6686 /**\r
6687  * Request to resolve additional information for a given document link. The request's\r
6688  * parameter is of type [DocumentLink](#DocumentLink) the response\r
6689  * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.\r
6690  */\r
6691 var DocumentLinkResolveRequest;\r
6692 (function (DocumentLinkResolveRequest) {\r
6693     DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');\r
6694 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));\r
6695 /**\r
6696  * A request send from the client to the server to execute a command. The request might return\r
6697  * a workspace edit which the client will apply to the workspace.\r
6698  */\r
6699 var ExecuteCommandRequest;\r
6700 (function (ExecuteCommandRequest) {\r
6701     ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');\r
6702 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));\r
6703 /**\r
6704  * A request sent from the server to the client to modified certain resources.\r
6705  */\r
6706 var ApplyWorkspaceEditRequest;\r
6707 (function (ApplyWorkspaceEditRequest) {\r
6708     ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');\r
6709 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));\r
6710
6711
6712 /***/ }),
6713 /* 20 */
6714 /***/ (function(module, exports, __webpack_require__) {
6715
6716 "use strict";
6717 /* --------------------------------------------------------------------------------------------\r
6718  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6719  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6720  * ------------------------------------------------------------------------------------------ */\r
6721 \r
6722 Object.defineProperty(exports, "__esModule", { value: true });\r
6723 function boolean(value) {\r
6724     return value === true || value === false;\r
6725 }\r
6726 exports.boolean = boolean;\r
6727 function string(value) {\r
6728     return typeof value === 'string' || value instanceof String;\r
6729 }\r
6730 exports.string = string;\r
6731 function number(value) {\r
6732     return typeof value === 'number' || value instanceof Number;\r
6733 }\r
6734 exports.number = number;\r
6735 function error(value) {\r
6736     return value instanceof Error;\r
6737 }\r
6738 exports.error = error;\r
6739 function func(value) {\r
6740     return typeof value === 'function';\r
6741 }\r
6742 exports.func = func;\r
6743 function array(value) {\r
6744     return Array.isArray(value);\r
6745 }\r
6746 exports.array = array;\r
6747 function stringArray(value) {\r
6748     return array(value) && value.every(elem => string(elem));\r
6749 }\r
6750 exports.stringArray = stringArray;\r
6751 function typedArray(value, check) {\r
6752     return Array.isArray(value) && value.every(check);\r
6753 }\r
6754 exports.typedArray = typedArray;\r
6755 function thenable(value) {\r
6756     return value && func(value.then);\r
6757 }\r
6758 exports.thenable = thenable;\r
6759
6760
6761 /***/ }),
6762 /* 21 */
6763 /***/ (function(module, exports, __webpack_require__) {
6764
6765 "use strict";
6766 /* --------------------------------------------------------------------------------------------\r
6767  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6768  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6769  * ------------------------------------------------------------------------------------------ */\r
6770 \r
6771 Object.defineProperty(exports, "__esModule", { value: true });\r
6772 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6773 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
6774 let __noDynamicImport;\r
6775 /**\r
6776  * A request to resolve the implementation locations of a symbol at a given text\r
6777  * document position. The request's parameter is of type [TextDocumentPositioParams]\r
6778  * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a\r
6779  * Thenable that resolves to such.\r
6780  */\r
6781 var ImplementationRequest;\r
6782 (function (ImplementationRequest) {\r
6783     ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');\r
6784 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));\r
6785
6786
6787 /***/ }),
6788 /* 22 */
6789 /***/ (function(module, exports, __webpack_require__) {
6790
6791 "use strict";
6792 /* --------------------------------------------------------------------------------------------\r
6793  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6794  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6795  * ------------------------------------------------------------------------------------------ */\r
6796 \r
6797 Object.defineProperty(exports, "__esModule", { value: true });\r
6798 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6799 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
6800 let __noDynamicImport;\r
6801 /**\r
6802  * A request to resolve the type definition locations of a symbol at a given text\r
6803  * document position. The request's parameter is of type [TextDocumentPositioParams]\r
6804  * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a\r
6805  * Thenable that resolves to such.\r
6806  */\r
6807 var TypeDefinitionRequest;\r
6808 (function (TypeDefinitionRequest) {\r
6809     TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');\r
6810 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));\r
6811
6812
6813 /***/ }),
6814 /* 23 */
6815 /***/ (function(module, exports, __webpack_require__) {
6816
6817 "use strict";
6818 /* --------------------------------------------------------------------------------------------\r
6819  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6820  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6821  * ------------------------------------------------------------------------------------------ */\r
6822 \r
6823 Object.defineProperty(exports, "__esModule", { value: true });\r
6824 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6825 /**\r
6826  * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.\r
6827  */\r
6828 var WorkspaceFoldersRequest;\r
6829 (function (WorkspaceFoldersRequest) {\r
6830     WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');\r
6831 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));\r
6832 /**\r
6833  * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace\r
6834  * folder configuration changes.\r
6835  */\r
6836 var DidChangeWorkspaceFoldersNotification;\r
6837 (function (DidChangeWorkspaceFoldersNotification) {\r
6838     DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');\r
6839 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));\r
6840
6841
6842 /***/ }),
6843 /* 24 */
6844 /***/ (function(module, exports, __webpack_require__) {
6845
6846 "use strict";
6847 /* --------------------------------------------------------------------------------------------\r
6848  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6849  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6850  * ------------------------------------------------------------------------------------------ */\r
6851 \r
6852 Object.defineProperty(exports, "__esModule", { value: true });\r
6853 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6854 /**\r
6855  * The 'workspace/configuration' request is sent from the server to the client to fetch a certain\r
6856  * configuration setting.\r
6857  *\r
6858  * This pull model replaces the old push model were the client signaled configuration change via an\r
6859  * event. If the server still needs to react to configuration changes (since the server caches the\r
6860  * result of `workspace/configuration` requests) the server should register for an empty configuration\r
6861  * change event and empty the cache if such an event is received.\r
6862  */\r
6863 var ConfigurationRequest;\r
6864 (function (ConfigurationRequest) {\r
6865     ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');\r
6866 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));\r
6867
6868
6869 /***/ }),
6870 /* 25 */
6871 /***/ (function(module, exports, __webpack_require__) {
6872
6873 "use strict";
6874 /* --------------------------------------------------------------------------------------------\r
6875  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6876  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6877  * ------------------------------------------------------------------------------------------ */\r
6878 \r
6879 Object.defineProperty(exports, "__esModule", { value: true });\r
6880 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6881 /**\r
6882  * A request to list all color symbols found in a given text document. The request's\r
6883  * parameter is of type [DocumentColorParams](#DocumentColorParams) the\r
6884  * response is of type [ColorInformation[]](#ColorInformation) or a Thenable\r
6885  * that resolves to such.\r
6886  */\r
6887 var DocumentColorRequest;\r
6888 (function (DocumentColorRequest) {\r
6889     DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');\r
6890 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));\r
6891 /**\r
6892  * A request to list all presentation for a color. The request's\r
6893  * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the\r
6894  * response is of type [ColorInformation[]](#ColorInformation) or a Thenable\r
6895  * that resolves to such.\r
6896  */\r
6897 var ColorPresentationRequest;\r
6898 (function (ColorPresentationRequest) {\r
6899     ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');\r
6900 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));\r
6901
6902
6903 /***/ }),
6904 /* 26 */
6905 /***/ (function(module, exports, __webpack_require__) {
6906
6907 "use strict";
6908 \r
6909 /*---------------------------------------------------------------------------------------------\r
6910  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
6911  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
6912  *--------------------------------------------------------------------------------------------*/\r
6913 Object.defineProperty(exports, "__esModule", { value: true });\r
6914 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6915 /**\r
6916  * Enum of known range kinds\r
6917  */\r
6918 var FoldingRangeKind;\r
6919 (function (FoldingRangeKind) {\r
6920     /**\r
6921      * Folding range for a comment\r
6922      */\r
6923     FoldingRangeKind["Comment"] = "comment";\r
6924     /**\r
6925      * Folding range for a imports or includes\r
6926      */\r
6927     FoldingRangeKind["Imports"] = "imports";\r
6928     /**\r
6929      * Folding range for a region (e.g. `#region`)\r
6930      */\r
6931     FoldingRangeKind["Region"] = "region";\r
6932 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));\r
6933 /**\r
6934  * A request to provide folding ranges in a document. The request's\r
6935  * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the\r
6936  * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable\r
6937  * that resolves to such.\r
6938  */\r
6939 var FoldingRangeRequest;\r
6940 (function (FoldingRangeRequest) {\r
6941     FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');\r
6942 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));\r
6943
6944
6945 /***/ }),
6946 /* 27 */
6947 /***/ (function(module, exports, __webpack_require__) {
6948
6949 "use strict";
6950 /* --------------------------------------------------------------------------------------------\r
6951  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6952  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6953  * ------------------------------------------------------------------------------------------ */\r
6954 \r
6955 Object.defineProperty(exports, "__esModule", { value: true });\r
6956 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6957 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
6958 let __noDynamicImport;\r
6959 /**\r
6960  * A request to resolve the type definition locations of a symbol at a given text\r
6961  * document position. The request's parameter is of type [TextDocumentPositioParams]\r
6962  * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)\r
6963  * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves\r
6964  * to such.\r
6965  */\r
6966 var DeclarationRequest;\r
6967 (function (DeclarationRequest) {\r
6968     DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');\r
6969 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));\r
6970
6971
6972 /***/ }),
6973 /* 28 */
6974 /***/ (function(module, exports, __webpack_require__) {
6975
6976 "use strict";
6977 \r
6978 /*---------------------------------------------------------------------------------------------\r
6979  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
6980  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
6981  *--------------------------------------------------------------------------------------------*/\r
6982 Object.defineProperty(exports, "__esModule", { value: true });\r
6983 const vscode_jsonrpc_1 = __webpack_require__(6);\r
6984 /**\r
6985  * Enum of known selection range kinds\r
6986  */\r
6987 var SelectionRangeKind;\r
6988 (function (SelectionRangeKind) {\r
6989     /**\r
6990      * Empty Kind.\r
6991      */\r
6992     SelectionRangeKind["Empty"] = "";\r
6993     /**\r
6994      * The statment kind, its value is `statement`, possible extensions can be\r
6995      * `statement.if` etc\r
6996      */\r
6997     SelectionRangeKind["Statement"] = "statement";\r
6998     /**\r
6999      * The declaration kind, its value is `declaration`, possible extensions can be\r
7000      * `declaration.function`, `declaration.class` etc.\r
7001      */\r
7002     SelectionRangeKind["Declaration"] = "declaration";\r
7003 })(SelectionRangeKind = exports.SelectionRangeKind || (exports.SelectionRangeKind = {}));\r
7004 /**\r
7005  * A request to provide selection ranges in a document. The request's\r
7006  * parameter is of type [TextDocumentPositionParams](#TextDocumentPositionParams), the\r
7007  * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable\r
7008  * that resolves to such.\r
7009  */\r
7010 var SelectionRangeRequest;\r
7011 (function (SelectionRangeRequest) {\r
7012     SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/selectionRange');\r
7013 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));\r
7014
7015
7016 /***/ }),
7017 /* 29 */
7018 /***/ (function(module, exports, __webpack_require__) {
7019
7020 "use strict";
7021 /* --------------------------------------------------------------------------------------------\r
7022  * Copyright (c) Microsoft Corporation. All rights reserved.\r
7023  * Licensed under the MIT License. See License.txt in the project root for license information.\r
7024  * ------------------------------------------------------------------------------------------ */\r
7025 \r
7026 Object.defineProperty(exports, "__esModule", { value: true });\r
7027 const vscode_languageserver_protocol_1 = __webpack_require__(5);\r
7028 const Is = __webpack_require__(30);\r
7029 exports.ConfigurationFeature = (Base) => {\r
7030     return class extends Base {\r
7031         getConfiguration(arg) {\r
7032             if (!arg) {\r
7033                 return this._getConfiguration({});\r
7034             }\r
7035             else if (Is.string(arg)) {\r
7036                 return this._getConfiguration({ section: arg });\r
7037             }\r
7038             else {\r
7039                 return this._getConfiguration(arg);\r
7040             }\r
7041         }\r
7042         _getConfiguration(arg) {\r
7043             let params = {\r
7044                 items: Array.isArray(arg) ? arg : [arg]\r
7045             };\r
7046             return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {\r
7047                 return Array.isArray(arg) ? result : result[0];\r
7048             });\r
7049         }\r
7050     };\r
7051 };\r
7052
7053
7054 /***/ }),
7055 /* 30 */
7056 /***/ (function(module, exports, __webpack_require__) {
7057
7058 "use strict";
7059 /* --------------------------------------------------------------------------------------------\r
7060  * Copyright (c) Microsoft Corporation. All rights reserved.\r
7061  * Licensed under the MIT License. See License.txt in the project root for license information.\r
7062  * ------------------------------------------------------------------------------------------ */\r
7063 \r
7064 Object.defineProperty(exports, "__esModule", { value: true });\r
7065 function boolean(value) {\r
7066     return value === true || value === false;\r
7067 }\r
7068 exports.boolean = boolean;\r
7069 function string(value) {\r
7070     return typeof value === 'string' || value instanceof String;\r
7071 }\r
7072 exports.string = string;\r
7073 function number(value) {\r
7074     return typeof value === 'number' || value instanceof Number;\r
7075 }\r
7076 exports.number = number;\r
7077 function error(value) {\r
7078     return value instanceof Error;\r
7079 }\r
7080 exports.error = error;\r
7081 function func(value) {\r
7082     return typeof value === 'function';\r
7083 }\r
7084 exports.func = func;\r
7085 function array(value) {\r
7086     return Array.isArray(value);\r
7087 }\r
7088 exports.array = array;\r
7089 function stringArray(value) {\r
7090     return array(value) && value.every(elem => string(elem));\r
7091 }\r
7092 exports.stringArray = stringArray;\r
7093 function typedArray(value, check) {\r
7094     return Array.isArray(value) && value.every(check);\r
7095 }\r
7096 exports.typedArray = typedArray;\r
7097 function thenable(value) {\r
7098     return value && func(value.then);\r
7099 }\r
7100 exports.thenable = thenable;\r
7101
7102
7103 /***/ }),
7104 /* 31 */
7105 /***/ (function(module, exports, __webpack_require__) {
7106
7107 "use strict";
7108 /* --------------------------------------------------------------------------------------------\r
7109  * Copyright (c) Microsoft Corporation. All rights reserved.\r
7110  * Licensed under the MIT License. See License.txt in the project root for license information.\r
7111  * ------------------------------------------------------------------------------------------ */\r
7112 \r
7113 Object.defineProperty(exports, "__esModule", { value: true });\r
7114 const vscode_languageserver_protocol_1 = __webpack_require__(5);\r
7115 exports.WorkspaceFoldersFeature = (Base) => {\r
7116     return class extends Base {\r
7117         initialize(capabilities) {\r
7118             let workspaceCapabilities = capabilities.workspace;\r
7119             if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {\r
7120                 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();\r
7121                 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {\r
7122                     this._onDidChangeWorkspaceFolders.fire(params.event);\r
7123                 });\r
7124             }\r
7125         }\r
7126         getWorkspaceFolders() {\r
7127             return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);\r
7128         }\r
7129         get onDidChangeWorkspaceFolders() {\r
7130             if (!this._onDidChangeWorkspaceFolders) {\r
7131                 throw new Error('Client doesn\'t support sending workspace folder change events.');\r
7132             }\r
7133             if (!this._unregistration) {\r
7134                 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);\r
7135             }\r
7136             return this._onDidChangeWorkspaceFolders.event;\r
7137         }\r
7138     };\r
7139 };\r
7140
7141
7142 /***/ }),
7143 /* 32 */
7144 /***/ (function(module, exports, __webpack_require__) {
7145
7146 "use strict";
7147 /*---------------------------------------------------------------------------------------------\r
7148  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
7149  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
7150  *--------------------------------------------------------------------------------------------*/\r
7151 \r
7152 Object.defineProperty(exports, "__esModule", { value: true });\r
7153 class ValueUUID {\r
7154     constructor(_value) {\r
7155         this._value = _value;\r
7156         // empty\r
7157     }\r
7158     asHex() {\r
7159         return this._value;\r
7160     }\r
7161     equals(other) {\r
7162         return this.asHex() === other.asHex();\r
7163     }\r
7164 }\r
7165 class V4UUID extends ValueUUID {\r
7166     constructor() {\r
7167         super([\r
7168             V4UUID._randomHex(),\r
7169             V4UUID._randomHex(),\r
7170             V4UUID._randomHex(),\r
7171             V4UUID._randomHex(),\r
7172             V4UUID._randomHex(),\r
7173             V4UUID._randomHex(),\r
7174             V4UUID._randomHex(),\r
7175             V4UUID._randomHex(),\r
7176             '-',\r
7177             V4UUID._randomHex(),\r
7178             V4UUID._randomHex(),\r
7179             V4UUID._randomHex(),\r
7180             V4UUID._randomHex(),\r
7181             '-',\r
7182             '4',\r
7183             V4UUID._randomHex(),\r
7184             V4UUID._randomHex(),\r
7185             V4UUID._randomHex(),\r
7186             '-',\r
7187             V4UUID._oneOf(V4UUID._timeHighBits),\r
7188             V4UUID._randomHex(),\r
7189             V4UUID._randomHex(),\r
7190             V4UUID._randomHex(),\r
7191             '-',\r
7192             V4UUID._randomHex(),\r
7193             V4UUID._randomHex(),\r
7194             V4UUID._randomHex(),\r
7195             V4UUID._randomHex(),\r
7196             V4UUID._randomHex(),\r
7197             V4UUID._randomHex(),\r
7198             V4UUID._randomHex(),\r
7199             V4UUID._randomHex(),\r
7200             V4UUID._randomHex(),\r
7201             V4UUID._randomHex(),\r
7202             V4UUID._randomHex(),\r
7203             V4UUID._randomHex(),\r
7204         ].join(''));\r
7205     }\r
7206     static _oneOf(array) {\r
7207         return array[Math.floor(array.length * Math.random())];\r
7208     }\r
7209     static _randomHex() {\r
7210         return V4UUID._oneOf(V4UUID._chars);\r
7211     }\r
7212 }\r
7213 V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];\r
7214 V4UUID._timeHighBits = ['8', '9', 'a', 'b'];\r
7215 /**\r
7216  * An empty UUID that contains only zeros.\r
7217  */\r
7218 exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');\r
7219 function v4() {\r
7220     return new V4UUID();\r
7221 }\r
7222 exports.v4 = v4;\r
7223 const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\r
7224 function isUUID(value) {\r
7225     return _UUIDPattern.test(value);\r
7226 }\r
7227 exports.isUUID = isUUID;\r
7228 /**\r
7229  * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.\r
7230  * @param value A uuid string.\r
7231  */\r
7232 function parse(value) {\r
7233     if (!isUUID(value)) {\r
7234         throw new Error('invalid uuid');\r
7235     }\r
7236     return new ValueUUID(value);\r
7237 }\r
7238 exports.parse = parse;\r
7239 function generateUuid() {\r
7240     return v4().asHex();\r
7241 }\r
7242 exports.generateUuid = generateUuid;\r
7243
7244
7245 /***/ }),
7246 /* 33 */
7247 /***/ (function(module, exports, __webpack_require__) {
7248
7249 "use strict";
7250 /* --------------------------------------------------------------------------------------------\r
7251  * Copyright (c) Microsoft Corporation. All rights reserved.\r
7252  * Licensed under the MIT License. See License.txt in the project root for license information.\r
7253  * ------------------------------------------------------------------------------------------ */\r
7254 \r
7255 Object.defineProperty(exports, "__esModule", { value: true });\r
7256 const url = __webpack_require__(34);\r
7257 const path = __webpack_require__(3);\r
7258 const fs = __webpack_require__(35);\r
7259 const child_process_1 = __webpack_require__(36);\r
7260 /**\r
7261  * @deprecated Use the `vscode-uri` npm module which provides a more\r
7262  * complete implementation of handling VS Code URIs.\r
7263  */\r
7264 function uriToFilePath(uri) {\r
7265     let parsed = url.parse(uri);\r
7266     if (parsed.protocol !== 'file:' || !parsed.path) {\r
7267         return undefined;\r
7268     }\r
7269     let segments = parsed.path.split('/');\r
7270     for (var i = 0, len = segments.length; i < len; i++) {\r
7271         segments[i] = decodeURIComponent(segments[i]);\r
7272     }\r
7273     if (process.platform === 'win32' && segments.length > 1) {\r
7274         let first = segments[0];\r
7275         let second = segments[1];\r
7276         // Do we have a drive letter and we started with a / which is the\r
7277         // case if the first segement is empty (see split above)\r
7278         if (first.length === 0 && second.length > 1 && second[1] === ':') {\r
7279             // Remove first slash\r
7280             segments.shift();\r
7281         }\r
7282     }\r
7283     return path.normalize(segments.join('/'));\r
7284 }\r
7285 exports.uriToFilePath = uriToFilePath;\r
7286 function isWindows() {\r
7287     return process.platform === 'win32';\r
7288 }\r
7289 function resolveModule(workspaceRoot, moduleName) {\r
7290     let nodePathKey = 'NODE_PATH';\r
7291     return new Promise((resolve, reject) => {\r
7292         let nodePath = [];\r
7293         if (workspaceRoot) {\r
7294             nodePath.push(path.join(workspaceRoot, 'node_modules'));\r
7295         }\r
7296         child_process_1.exec('npm config get prefix', (error, stdout, _stderr) => {\r
7297             if (!error) {\r
7298                 let globalPath = stdout.replace(/[\s\r\n]+$/, '');\r
7299                 if (globalPath.length > 0) {\r
7300                     if (isWindows()) {\r
7301                         nodePath.push(path.join(globalPath, 'node_modules'));\r
7302                     }\r
7303                     else {\r
7304                         nodePath.push(path.join(globalPath, 'lib', 'node_modules'));\r
7305                     }\r
7306                 }\r
7307             }\r
7308             let separator = isWindows() ? ';' : ':';\r
7309             let env = process.env;\r
7310             let newEnv = Object.create(null);\r
7311             Object.keys(env).forEach(key => newEnv[key] = env[key]);\r
7312             if (newEnv[nodePathKey]) {\r
7313                 newEnv[nodePathKey] = nodePath.join(separator) + separator + newEnv[nodePathKey];\r
7314             }\r
7315             else {\r
7316                 newEnv[nodePathKey] = nodePath.join(separator);\r
7317             }\r
7318             newEnv['ELECTRON_RUN_AS_NODE'] = '1';\r
7319             try {\r
7320                 let cp = child_process_1.fork(path.join(__dirname, 'resolve.js'), [], { env: newEnv, execArgv: [] });\r
7321                 if (cp.pid === void 0) {\r
7322                     reject(new Error(`Starting process to resolve node module  ${moduleName} failed`));\r
7323                     return;\r
7324                 }\r
7325                 cp.on('message', (message) => {\r
7326                     if (message.command === 'resolve') {\r
7327                         let toRequire = moduleName;\r
7328                         if (message.success) {\r
7329                             toRequire = message.result;\r
7330                         }\r
7331                         cp.send({ command: 'exit' });\r
7332                         try {\r
7333                             resolve(__webpack_require__(37)(toRequire));\r
7334                         }\r
7335                         catch (error) {\r
7336                             reject(error);\r
7337                         }\r
7338                     }\r
7339                 });\r
7340                 let message = {\r
7341                     command: 'resolve',\r
7342                     args: moduleName\r
7343                 };\r
7344                 cp.send(message);\r
7345             }\r
7346             catch (error) {\r
7347                 reject(error);\r
7348             }\r
7349         });\r
7350     });\r
7351 }\r
7352 exports.resolveModule = resolveModule;\r
7353 function resolve(moduleName, nodePath, cwd, tracer) {\r
7354     const nodePathKey = 'NODE_PATH';\r
7355     const app = [\r
7356         "var p = process;",\r
7357         "p.on('message',function(m){",\r
7358         "if(m.c==='e'){",\r
7359         "p.exit(0);",\r
7360         "}",\r
7361         "else if(m.c==='rs'){",\r
7362         "try{",\r
7363         "var r=require.resolve(m.a);",\r
7364         "p.send({c:'r',s:true,r:r});",\r
7365         "}",\r
7366         "catch(err){",\r
7367         "p.send({c:'r',s:false});",\r
7368         "}",\r
7369         "}",\r
7370         "});"\r
7371     ].join('');\r
7372     return new Promise((resolve, reject) => {\r
7373         let env = process.env;\r
7374         let newEnv = Object.create(null);\r
7375         Object.keys(env).forEach(key => newEnv[key] = env[key]);\r
7376         if (nodePath) {\r
7377             if (newEnv[nodePathKey]) {\r
7378                 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];\r
7379             }\r
7380             else {\r
7381                 newEnv[nodePathKey] = nodePath;\r
7382             }\r
7383             if (tracer) {\r
7384                 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);\r
7385             }\r
7386         }\r
7387         newEnv['ELECTRON_RUN_AS_NODE'] = '1';\r
7388         try {\r
7389             let cp = child_process_1.fork('', [], {\r
7390                 cwd: cwd,\r
7391                 env: newEnv,\r
7392                 execArgv: ['-e', app]\r
7393             });\r
7394             if (cp.pid === void 0) {\r
7395                 reject(new Error(`Starting process to resolve node module  ${moduleName} failed`));\r
7396                 return;\r
7397             }\r
7398             cp.on('error', (error) => {\r
7399                 reject(error);\r
7400             });\r
7401             cp.on('message', (message) => {\r
7402                 if (message.c === 'r') {\r
7403                     cp.send({ c: 'e' });\r
7404                     if (message.s) {\r
7405                         resolve(message.r);\r
7406                     }\r
7407                     else {\r
7408                         reject(new Error(`Failed to resolve module: ${moduleName}`));\r
7409                     }\r
7410                 }\r
7411             });\r
7412             let message = {\r
7413                 c: 'rs',\r
7414                 a: moduleName\r
7415             };\r
7416             cp.send(message);\r
7417         }\r
7418         catch (error) {\r
7419             reject(error);\r
7420         }\r
7421     });\r
7422 }\r
7423 exports.resolve = resolve;\r
7424 function resolveGlobalNodePath(tracer) {\r
7425     let npmCommand = 'npm';\r
7426     let options = {\r
7427         encoding: 'utf8'\r
7428     };\r
7429     if (isWindows()) {\r
7430         npmCommand = 'npm.cmd';\r
7431         options.shell = true;\r
7432     }\r
7433     let handler = () => { };\r
7434     try {\r
7435         process.on('SIGPIPE', handler);\r
7436         let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;\r
7437         if (!stdout) {\r
7438             if (tracer) {\r
7439                 tracer(`'npm config get prefix' didn't return a value.`);\r
7440             }\r
7441             return undefined;\r
7442         }\r
7443         let prefix = stdout.trim();\r
7444         if (tracer) {\r
7445             tracer(`'npm config get prefix' value is: ${prefix}`);\r
7446         }\r
7447         if (prefix.length > 0) {\r
7448             if (isWindows()) {\r
7449                 return path.join(prefix, 'node_modules');\r
7450             }\r
7451             else {\r
7452                 return path.join(prefix, 'lib', 'node_modules');\r
7453             }\r
7454         }\r
7455         return undefined;\r
7456     }\r
7457     catch (err) {\r
7458         return undefined;\r
7459     }\r
7460     finally {\r
7461         process.removeListener('SIGPIPE', handler);\r
7462     }\r
7463 }\r
7464 exports.resolveGlobalNodePath = resolveGlobalNodePath;\r
7465 function resolveGlobalYarnPath(tracer) {\r
7466     let yarnCommand = 'yarn';\r
7467     let options = {\r
7468         encoding: 'utf8'\r
7469     };\r
7470     if (isWindows()) {\r
7471         yarnCommand = 'yarn.cmd';\r
7472         options.shell = true;\r
7473     }\r
7474     let handler = () => { };\r
7475     try {\r
7476         process.on('SIGPIPE', handler);\r
7477         let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);\r
7478         let stdout = results.stdout;\r
7479         if (!stdout) {\r
7480             if (tracer) {\r
7481                 tracer(`'yarn global dir' didn't return a value.`);\r
7482                 if (results.stderr) {\r
7483                     tracer(results.stderr);\r
7484                 }\r
7485             }\r
7486             return undefined;\r
7487         }\r
7488         let lines = stdout.trim().split(/\r?\n/);\r
7489         for (let line of lines) {\r
7490             try {\r
7491                 let yarn = JSON.parse(line);\r
7492                 if (yarn.type === 'log') {\r
7493                     return path.join(yarn.data, 'node_modules');\r
7494                 }\r
7495             }\r
7496             catch (e) {\r
7497                 // Do nothing. Ignore the line\r
7498             }\r
7499         }\r
7500         return undefined;\r
7501     }\r
7502     catch (err) {\r
7503         return undefined;\r
7504     }\r
7505     finally {\r
7506         process.removeListener('SIGPIPE', handler);\r
7507     }\r
7508 }\r
7509 exports.resolveGlobalYarnPath = resolveGlobalYarnPath;\r
7510 var FileSystem;\r
7511 (function (FileSystem) {\r
7512     let _isCaseSensitive = undefined;\r
7513     function isCaseSensitive() {\r
7514         if (_isCaseSensitive !== void 0) {\r
7515             return _isCaseSensitive;\r
7516         }\r
7517         if (process.platform === 'win32') {\r
7518             _isCaseSensitive = false;\r
7519         }\r
7520         else {\r
7521             // convert current file name to upper case / lower case and check if file exists\r
7522             // (guards against cases when name is already all uppercase or lowercase)\r
7523             _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());\r
7524         }\r
7525         return _isCaseSensitive;\r
7526     }\r
7527     FileSystem.isCaseSensitive = isCaseSensitive;\r
7528     function isParent(parent, child) {\r
7529         if (isCaseSensitive()) {\r
7530             return path.normalize(child).indexOf(path.normalize(parent)) === 0;\r
7531         }\r
7532         else {\r
7533             return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) == 0;\r
7534         }\r
7535     }\r
7536     FileSystem.isParent = isParent;\r
7537 })(FileSystem = exports.FileSystem || (exports.FileSystem = {}));\r
7538 function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {\r
7539     if (nodePath) {\r
7540         if (!path.isAbsolute(nodePath)) {\r
7541             nodePath = path.join(workspaceRoot, nodePath);\r
7542         }\r
7543         return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {\r
7544             if (FileSystem.isParent(nodePath, value)) {\r
7545                 return value;\r
7546             }\r
7547             else {\r
7548                 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));\r
7549             }\r
7550         }).then(undefined, (_error) => {\r
7551             return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);\r
7552         });\r
7553     }\r
7554     else {\r
7555         return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);\r
7556     }\r
7557 }\r
7558 exports.resolveModulePath = resolveModulePath;\r
7559 /**\r
7560  * Resolves the given module relative to the given workspace root. In contrast to\r
7561  * `resolveModule` this method considers the parent chain as well.\r
7562  */\r
7563 function resolveModule2(workspaceRoot, moduleName, nodePath, tracer) {\r
7564     return resolveModulePath(workspaceRoot, moduleName, nodePath, tracer).then((path) => {\r
7565         if (tracer) {\r
7566             tracer(`Module ${moduleName} got resolved to ${path}`);\r
7567         }\r
7568         return __webpack_require__(37)(path);\r
7569     });\r
7570 }\r
7571 exports.resolveModule2 = resolveModule2;\r
7572
7573
7574 /***/ }),
7575 /* 34 */
7576 /***/ (function(module, exports) {
7577
7578 module.exports = require("url");
7579
7580 /***/ }),
7581 /* 35 */
7582 /***/ (function(module, exports) {
7583
7584 module.exports = require("fs");
7585
7586 /***/ }),
7587 /* 36 */
7588 /***/ (function(module, exports) {
7589
7590 module.exports = require("child_process");
7591
7592 /***/ }),
7593 /* 37 */
7594 /***/ (function(module, exports) {
7595
7596 function webpackEmptyContext(req) {
7597         var e = new Error("Cannot find module '" + req + "'");
7598         e.code = 'MODULE_NOT_FOUND';
7599         throw e;
7600 }
7601 webpackEmptyContext.keys = function() { return []; };
7602 webpackEmptyContext.resolve = webpackEmptyContext;
7603 module.exports = webpackEmptyContext;
7604 webpackEmptyContext.id = 37;
7605
7606 /***/ }),
7607 /* 38 */
7608 /***/ (function(module, __webpack_exports__, __webpack_require__) {
7609
7610 "use strict";
7611 __webpack_require__.r(__webpack_exports__);
7612 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setUriThrowOnMissingScheme", function() { return setUriThrowOnMissingScheme; });
7613 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "URI", function() { return URI; });
7614 /*---------------------------------------------------------------------------------------------
7615  *  Copyright (c) Microsoft Corporation. All rights reserved.
7616  *  Licensed under the MIT License. See License.txt in the project root for license information.
7617  *--------------------------------------------------------------------------------------------*/
7618
7619 var __extends = (undefined && undefined.__extends) || (function () {
7620     var extendStatics = Object.setPrototypeOf ||
7621         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7622         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7623     return function (d, b) {
7624         extendStatics(d, b);
7625         function __() { this.constructor = d; }
7626         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7627     };
7628 })();
7629 var isWindows;
7630 if (typeof process === 'object') {
7631     isWindows = process.platform === 'win32';
7632 }
7633 else if (typeof navigator === 'object') {
7634     var userAgent = navigator.userAgent;
7635     isWindows = userAgent.indexOf('Windows') >= 0;
7636 }
7637 //#endregion
7638 var _schemePattern = /^\w[\w\d+.-]*$/;
7639 var _singleSlashStart = /^\//;
7640 var _doubleSlashStart = /^\/\//;
7641 var _throwOnMissingSchema = true;
7642 /**
7643  * @internal
7644  */
7645 function setUriThrowOnMissingScheme(value) {
7646     var old = _throwOnMissingSchema;
7647     _throwOnMissingSchema = value;
7648     return old;
7649 }
7650 function _validateUri(ret, _strict) {
7651     // scheme, must be set
7652     if (!ret.scheme) {
7653         if (_strict || _throwOnMissingSchema) {
7654             throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
7655         }
7656         else {
7657             // console.warn(`[UriError]: Scheme is missing: {scheme: "", authority: "${ret.authority}", path: "${ret.path}", query: "${ret.query}", fragment: "${ret.fragment}"}`);
7658         }
7659     }
7660     // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
7661     // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
7662     if (ret.scheme && !_schemePattern.test(ret.scheme)) {
7663         throw new Error('[UriError]: Scheme contains illegal characters.');
7664     }
7665     // path, http://tools.ietf.org/html/rfc3986#section-3.3
7666     // If a URI contains an authority component, then the path component
7667     // must either be empty or begin with a slash ("/") character.  If a URI
7668     // does not contain an authority component, then the path cannot begin
7669     // with two slash characters ("//").
7670     if (ret.path) {
7671         if (ret.authority) {
7672             if (!_singleSlashStart.test(ret.path)) {
7673                 throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
7674             }
7675         }
7676         else {
7677             if (_doubleSlashStart.test(ret.path)) {
7678                 throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
7679             }
7680         }
7681     }
7682 }
7683 // for a while we allowed uris *without* schemes and this is the migration
7684 // for them, e.g. an uri without scheme and without strict-mode warns and falls
7685 // back to the file-scheme. that should cause the least carnage and still be a
7686 // clear warning
7687 function _schemeFix(scheme, _strict) {
7688     if (_strict || _throwOnMissingSchema) {
7689         return scheme || _empty;
7690     }
7691     if (!scheme) {
7692         // console.trace('BAD uri lacks scheme, falling back to file-scheme.');
7693         scheme = 'file';
7694     }
7695     return scheme;
7696 }
7697 // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
7698 function _referenceResolution(scheme, path) {
7699     // the slash-character is our 'default base' as we don't
7700     // support constructing URIs relative to other URIs. This
7701     // also means that we alter and potentially break paths.
7702     // see https://tools.ietf.org/html/rfc3986#section-5.1.4
7703     switch (scheme) {
7704         case 'https':
7705         case 'http':
7706         case 'file':
7707             if (!path) {
7708                 path = _slash;
7709             }
7710             else if (path[0] !== _slash) {
7711                 path = _slash + path;
7712             }
7713             break;
7714     }
7715     return path;
7716 }
7717 var _empty = '';
7718 var _slash = '/';
7719 var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
7720 function _isQueryStringScheme(scheme) {
7721     if (!scheme) {
7722         return false;
7723     }
7724     switch (scheme.toLowerCase()) {
7725         case 'http':
7726         case 'https':
7727         case 'ftp':
7728             return true;
7729     }
7730     return false;
7731 }
7732 /**
7733  * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
7734  * This class is a simple parser which creates the basic component parts
7735  * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
7736  * and encoding.
7737  *
7738  *       foo://example.com:8042/over/there?name=ferret#nose
7739  *       \_/   \______________/\_________/ \_________/ \__/
7740  *        |           |            |            |        |
7741  *     scheme     authority       path        query   fragment
7742  *        |   _____________________|__
7743  *       / \ /                        \
7744  *       urn:example:animal:ferret:nose
7745  */
7746 var URI = (function () {
7747     /**
7748      * @internal
7749      */
7750     function URI(schemeOrData, authority, path, query, fragment, _strict) {
7751         if (_strict === void 0) { _strict = false; }
7752         if (typeof schemeOrData === 'object') {
7753             this.scheme = schemeOrData.scheme || _empty;
7754             this.authority = schemeOrData.authority || _empty;
7755             this.path = schemeOrData.path || _empty;
7756             this.query = schemeOrData.query || _empty;
7757             this.fragment = schemeOrData.fragment || _empty;
7758             // no validation because it's this URI
7759             // that creates uri components.
7760             // _validateUri(this);
7761         }
7762         else {
7763             this.scheme = _schemeFix(schemeOrData, _strict);
7764             this.authority = authority || _empty;
7765             this.path = _referenceResolution(this.scheme, path || _empty);
7766             this.query = query || _empty;
7767             this.fragment = fragment || _empty;
7768             _validateUri(this, _strict);
7769         }
7770     }
7771     URI.isUri = function (thing) {
7772         if (thing instanceof URI) {
7773             return true;
7774         }
7775         if (!thing) {
7776             return false;
7777         }
7778         return typeof thing.authority === 'string'
7779             && typeof thing.fragment === 'string'
7780             && typeof thing.path === 'string'
7781             && typeof thing.query === 'string'
7782             && typeof thing.scheme === 'string'
7783             && typeof thing.fsPath === 'function'
7784             && typeof thing.with === 'function'
7785             && typeof thing.toString === 'function';
7786     };
7787     Object.defineProperty(URI.prototype, "fsPath", {
7788         // ---- filesystem path -----------------------
7789         /**
7790          * Returns a string representing the corresponding file system path of this URI.
7791          * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
7792          * platform specific path separator.
7793          *
7794          * * Will *not* validate the path for invalid characters and semantics.
7795          * * Will *not* look at the scheme of this URI.
7796          * * The result shall *not* be used for display purposes but for accessing a file on disk.
7797          *
7798          *
7799          * The *difference* to `URI#path` is the use of the platform specific separator and the handling
7800          * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
7801          *
7802          * ```ts
7803             const u = URI.parse('file://server/c$/folder/file.txt')
7804             u.authority === 'server'
7805             u.path === '/shares/c$/file.txt'
7806             u.fsPath === '\\server\c$\folder\file.txt'
7807         ```
7808          *
7809          * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
7810          * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
7811          * with URIs that represent files on disk (`file` scheme).
7812          */
7813         get: function () {
7814             // if (this.scheme !== 'file') {
7815             //  console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
7816             // }
7817             return _makeFsPath(this);
7818         },
7819         enumerable: true,
7820         configurable: true
7821     });
7822     // ---- modify to new -------------------------
7823     URI.prototype.with = function (change) {
7824         if (!change) {
7825             return this;
7826         }
7827         var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
7828         if (scheme === undefined) {
7829             scheme = this.scheme;
7830         }
7831         else if (scheme === null) {
7832             scheme = _empty;
7833         }
7834         if (authority === undefined) {
7835             authority = this.authority;
7836         }
7837         else if (authority === null) {
7838             authority = _empty;
7839         }
7840         if (path === undefined) {
7841             path = this.path;
7842         }
7843         else if (path === null) {
7844             path = _empty;
7845         }
7846         if (query === undefined) {
7847             query = this.query;
7848         }
7849         else if (query === null) {
7850             query = _empty;
7851         }
7852         if (fragment === undefined) {
7853             fragment = this.fragment;
7854         }
7855         else if (fragment === null) {
7856             fragment = _empty;
7857         }
7858         if (scheme === this.scheme
7859             && authority === this.authority
7860             && path === this.path
7861             && query === this.query
7862             && fragment === this.fragment) {
7863             return this;
7864         }
7865         return new _URI(scheme, authority, path, query, fragment);
7866     };
7867     // ---- parse & validate ------------------------
7868     /**
7869      * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
7870      * `file:///usr/home`, or `scheme:with/path`.
7871      *
7872      * @param value A string which represents an URI (see `URI#toString`).
7873      */
7874     URI.parse = function (value, _strict) {
7875         if (_strict === void 0) { _strict = false; }
7876         var match = _regexp.exec(value);
7877         if (!match) {
7878             return new _URI(_empty, _empty, _empty, _empty, _empty, _strict);
7879         }
7880         return new _URI(match[2] || _empty, decodeURIComponentFast(match[4] || _empty, false, false), decodeURIComponentFast(match[5] || _empty, true, false), decodeURIComponentFast(match[7] || _empty, false, _isQueryStringScheme(match[2])), decodeURIComponentFast(match[9] || _empty, false, false), _strict);
7881     };
7882     /**
7883      * Creates a new URI from a file system path, e.g. `c:\my\files`,
7884      * `/usr/home`, or `\\server\share\some\path`.
7885      *
7886      * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
7887      * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
7888      * `URI.parse('file://' + path)` because the path might contain characters that are
7889      * interpreted (# and ?). See the following sample:
7890      * ```ts
7891     const good = URI.file('/coding/c#/project1');
7892     good.scheme === 'file';
7893     good.path === '/coding/c#/project1';
7894     good.fragment === '';
7895     const bad = URI.parse('file://' + '/coding/c#/project1');
7896     bad.scheme === 'file';
7897     bad.path === '/coding/c'; // path is now broken
7898     bad.fragment === '/project1';
7899     ```
7900      *
7901      * @param path A file system path (see `URI#fsPath`)
7902      */
7903     URI.file = function (path) {
7904         var authority = _empty;
7905         // normalize to fwd-slashes on windows,
7906         // on other systems bwd-slashes are valid
7907         // filename character, e.g. /f\oo/ba\r.txt
7908         if (isWindows) {
7909             path = path.replace(/\\/g, _slash);
7910         }
7911         // check for authority as used in UNC shares
7912         // or use the path as given
7913         if (path[0] === _slash && path[1] === _slash) {
7914             var idx = path.indexOf(_slash, 2);
7915             if (idx === -1) {
7916                 authority = path.substring(2);
7917                 path = _slash;
7918             }
7919             else {
7920                 authority = path.substring(2, idx);
7921                 path = path.substring(idx) || _slash;
7922             }
7923         }
7924         return new _URI('file', authority, path, _empty, _empty);
7925     };
7926     URI.from = function (components) {
7927         return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
7928     };
7929     // ---- printing/externalize ---------------------------
7930     /**
7931      * Creates a string representation for this URI. It's guaranteed that calling
7932      * `URI.parse` with the result of this function creates an URI which is equal
7933      * to this URI.
7934      *
7935      * * The result shall *not* be used for display purposes but for externalization or transport.
7936      * * The result will be encoded using the percentage encoding and encoding happens mostly
7937      * ignore the scheme-specific encoding rules.
7938      *
7939      * @param skipEncoding Do not encode the result, default is `false`
7940      */
7941     URI.prototype.toString = function (skipEncoding) {
7942         if (skipEncoding === void 0) { skipEncoding = false; }
7943         return _asFormatted(this, skipEncoding);
7944     };
7945     URI.prototype.toJSON = function () {
7946         return this;
7947     };
7948     URI.revive = function (data) {
7949         if (!data) {
7950             return data;
7951         }
7952         else if (data instanceof URI) {
7953             return data;
7954         }
7955         else {
7956             var result = new _URI(data);
7957             result._formatted = data.external;
7958             result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
7959             return result;
7960         }
7961     };
7962     return URI;
7963 }());
7964
7965 var _pathSepMarker = isWindows ? 1 : undefined;
7966 // tslint:disable-next-line:class-name
7967 var _URI = (function (_super) {
7968     __extends(_URI, _super);
7969     function _URI() {
7970         var _this = _super !== null && _super.apply(this, arguments) || this;
7971         _this._formatted = null;
7972         _this._fsPath = null;
7973         return _this;
7974     }
7975     Object.defineProperty(_URI.prototype, "fsPath", {
7976         get: function () {
7977             if (!this._fsPath) {
7978                 this._fsPath = _makeFsPath(this);
7979             }
7980             return this._fsPath;
7981         },
7982         enumerable: true,
7983         configurable: true
7984     });
7985     _URI.prototype.toString = function (skipEncoding) {
7986         if (skipEncoding === void 0) { skipEncoding = false; }
7987         if (!skipEncoding) {
7988             if (!this._formatted) {
7989                 this._formatted = _asFormatted(this, false);
7990             }
7991             return this._formatted;
7992         }
7993         else {
7994             // we don't cache that
7995             return _asFormatted(this, true);
7996         }
7997     };
7998     _URI.prototype.toJSON = function () {
7999         var res = {
8000             $mid: 1
8001         };
8002         // cached state
8003         if (this._fsPath) {
8004             res.fsPath = this._fsPath;
8005             res._sep = _pathSepMarker;
8006         }
8007         if (this._formatted) {
8008             res.external = this._formatted;
8009         }
8010         // uri components
8011         if (this.path) {
8012             res.path = this.path;
8013         }
8014         if (this.scheme) {
8015             res.scheme = this.scheme;
8016         }
8017         if (this.authority) {
8018             res.authority = this.authority;
8019         }
8020         if (this.query) {
8021             res.query = this.query;
8022         }
8023         if (this.fragment) {
8024             res.fragment = this.fragment;
8025         }
8026         return res;
8027     };
8028     return _URI;
8029 }(URI));
8030 function isHex(value, pos) {
8031     if (pos >= value.length) {
8032         return false;
8033     }
8034     var code = value.charCodeAt(pos);
8035     return (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) // 0-9
8036         || (code >= 97 /* a */ && code <= 102 /* f */) //a-f
8037         || (code >= 65 /* A */ && code <= 70 /* F */); //A-F
8038 }
8039 function decodeURIComponentFast(uriComponent, isPath, isQueryString) {
8040     var res;
8041     var nativeDecodePos = -1;
8042     for (var pos = 0; pos < uriComponent.length; pos++) {
8043         var code = uriComponent.charCodeAt(pos);
8044         // decoding needed
8045         if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
8046             var chA = uriComponent.charCodeAt(pos + 1);
8047             var chB = uriComponent.charCodeAt(pos + 2);
8048             // when in a path -> check and accept %2f and %2F (fwd slash)
8049             // when in a query string -> check and accept %3D, %26, and %3B (equals, ampersand, semi-colon)
8050             if ((isPath && chA === 50 /* Digit2 */ && (chB === 70 /* F */ || chB === 102 /* f */))
8051                 ||
8052                     (isQueryString && ((chA === 50 /* Digit2 */ && chB === 54 /* Digit6 */) // %26
8053                         ||
8054                             (chA === 51 /* Digit3 */ && (chB === 66 /* B */ || chB === 98 /* b */ || chB === 68 /* D */ || chB === 100 /* d */)) // %3D, %3D
8055                     ))) {
8056                 if (nativeDecodePos !== -1) {
8057                     res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
8058                     nativeDecodePos = -1;
8059                 }
8060                 if (res !== undefined) {
8061                     res += uriComponent.substr(pos, 3);
8062                 }
8063                 pos += 2;
8064                 continue;
8065             }
8066             if (res === undefined) {
8067                 res = uriComponent.substring(0, pos);
8068             }
8069             if (nativeDecodePos === -1) {
8070                 nativeDecodePos = pos;
8071             }
8072             pos += 2;
8073         }
8074         else {
8075             if (nativeDecodePos !== -1) {
8076                 res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
8077                 nativeDecodePos = -1;
8078             }
8079             if (res !== undefined) {
8080                 res += String.fromCharCode(code);
8081             }
8082         }
8083     }
8084     if (nativeDecodePos !== -1) {
8085         res += decodeURIComponent(uriComponent.substr(nativeDecodePos));
8086     }
8087     return res !== undefined ? res : uriComponent;
8088 }
8089 // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
8090 var encodeTable = (_a = {},
8091     _a[58 /* Colon */] = '%3A',
8092     _a[47 /* Slash */] = '%2F',
8093     _a[63 /* QuestionMark */] = '%3F',
8094     _a[35 /* Hash */] = '%23',
8095     _a[91 /* OpenSquareBracket */] = '%5B',
8096     _a[93 /* CloseSquareBracket */] = '%5D',
8097     _a[64 /* AtSign */] = '%40',
8098     _a[33 /* ExclamationMark */] = '%21',
8099     _a[36 /* DollarSign */] = '%24',
8100     _a[38 /* Ampersand */] = '%26',
8101     _a[39 /* SingleQuote */] = '%27',
8102     _a[40 /* OpenParen */] = '%28',
8103     _a[41 /* CloseParen */] = '%29',
8104     _a[42 /* Asterisk */] = '%2A',
8105     _a[43 /* Plus */] = '%2B',
8106     _a[44 /* Comma */] = '%2C',
8107     _a[59 /* Semicolon */] = '%3B',
8108     _a[61 /* Equals */] = '%3D',
8109     _a[32 /* Space */] = '%20',
8110     _a);
8111 function encodeURIComponentFast(uriComponent, isPath, isQueryString) {
8112     var res = undefined;
8113     var nativeEncodePos = -1;
8114     for (var pos = 0; pos < uriComponent.length; pos++) {
8115         var code = uriComponent.charCodeAt(pos);
8116         // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
8117         if ((code >= 97 /* a */ && code <= 122 /* z */)
8118             || (code >= 65 /* A */ && code <= 90 /* Z */)
8119             || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
8120             || code === 45 /* Dash */
8121             || code === 46 /* Period */
8122             || code === 95 /* Underline */
8123             || code === 126 /* Tilde */
8124             || (isPath && code === 47 /* Slash */) // path => allow slash AS-IS
8125             || (isQueryString && (code === 61 /* Equals */ || code === 38 /* Ampersand */ || code === 59 /* Semicolon */)) // query string => allow &=;
8126         ) {
8127             // check if we are delaying native encode
8128             if (nativeEncodePos !== -1) {
8129                 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
8130                 nativeEncodePos = -1;
8131             }
8132             // check if we write into a new string (by default we try to return the param)
8133             if (res !== undefined) {
8134                 res += uriComponent.charAt(pos);
8135             }
8136         }
8137         else if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
8138             // at percentage encoded value
8139             // check if we are delaying native encode
8140             if (nativeEncodePos !== -1) {
8141                 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
8142                 nativeEncodePos = -1;
8143             }
8144             // check if we write into a new string (by default we try to return the param)
8145             if (res !== undefined) {
8146                 res += uriComponent.substr(pos, 3);
8147             }
8148             pos += 2;
8149         }
8150         else {
8151             // encoding needed, we need to allocate a new string
8152             if (res === undefined) {
8153                 res = uriComponent.substr(0, pos);
8154             }
8155             // check with default table first
8156             var escaped = encodeTable[code];
8157             if (escaped !== undefined) {
8158                 // check if we are delaying native encode
8159                 if (nativeEncodePos !== -1) {
8160                     res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
8161                     nativeEncodePos = -1;
8162                 }
8163                 // append escaped variant to result
8164                 res += escaped;
8165             }
8166             else if (nativeEncodePos === -1) {
8167                 // use native encode only when needed
8168                 nativeEncodePos = pos;
8169             }
8170         }
8171     }
8172     if (nativeEncodePos !== -1) {
8173         res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
8174     }
8175     return res !== undefined ? res : uriComponent;
8176 }
8177 function encodeURIComponentMinimal(path) {
8178     var res = undefined;
8179     for (var pos = 0; pos < path.length; pos++) {
8180         var code = path.charCodeAt(pos);
8181         if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
8182             if (res === undefined) {
8183                 res = path.substr(0, pos);
8184             }
8185             res += encodeTable[code];
8186         }
8187         else {
8188             if (res !== undefined) {
8189                 res += path[pos];
8190             }
8191         }
8192     }
8193     return res !== undefined ? res : path;
8194 }
8195 /**
8196  * Compute `fsPath` for the given uri
8197  */
8198 function _makeFsPath(uri) {
8199     var value;
8200     if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
8201         // unc path: file://shares/c$/far/boo
8202         value = "//" + uri.authority + uri.path;
8203     }
8204     else if (uri.path.charCodeAt(0) === 47 /* Slash */
8205         && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
8206         && uri.path.charCodeAt(2) === 58 /* Colon */) {
8207         // windows drive letter: file:///c:/far/boo
8208         value = uri.path[1].toLowerCase() + uri.path.substr(2);
8209     }
8210     else {
8211         // other path
8212         value = uri.path;
8213     }
8214     if (isWindows) {
8215         value = value.replace(/\//g, '\\');
8216     }
8217     return value;
8218 }
8219 /**
8220  * Create the external version of a uri
8221  */
8222 function _asFormatted(uri, skipEncoding) {
8223     var encoder = !skipEncoding
8224         ? encodeURIComponentFast
8225         : encodeURIComponentMinimal;
8226     var res = '';
8227     var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
8228     if (scheme) {
8229         res += scheme;
8230         res += ':';
8231     }
8232     if (authority || scheme === 'file') {
8233         res += _slash;
8234         res += _slash;
8235     }
8236     if (authority) {
8237         var idx = authority.indexOf('@');
8238         if (idx !== -1) {
8239             // <user>@<auth>
8240             var userinfo = authority.substr(0, idx);
8241             authority = authority.substr(idx + 1);
8242             idx = userinfo.indexOf(':');
8243             if (idx === -1) {
8244                 res += encoder(userinfo, false, false);
8245             }
8246             else {
8247                 // <user>:<pass>@<auth>
8248                 res += encoder(userinfo.substr(0, idx), false, false);
8249                 res += ':';
8250                 res += encoder(userinfo.substr(idx + 1), false, false);
8251             }
8252             res += '@';
8253         }
8254         authority = authority.toLowerCase();
8255         idx = authority.indexOf(':');
8256         if (idx === -1) {
8257             res += encoder(authority, false, false);
8258         }
8259         else {
8260             // <auth>:<port>
8261             res += encoder(authority.substr(0, idx), false, false);
8262             res += authority.substr(idx);
8263         }
8264     }
8265     if (path) {
8266         // lower-case windows drive letters in /C:/fff or C:/fff
8267         if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
8268             var code = path.charCodeAt(1);
8269             if (code >= 65 /* A */ && code <= 90 /* Z */) {
8270                 path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
8271             }
8272         }
8273         else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
8274             var code = path.charCodeAt(0);
8275             if (code >= 65 /* A */ && code <= 90 /* Z */) {
8276                 path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
8277             }
8278         }
8279         // encode the rest of the path
8280         res += encoder(path, true, false);
8281     }
8282     if (query) {
8283         res += '?';
8284         res += encoder(query, false, _isQueryStringScheme(scheme));
8285     }
8286     if (fragment) {
8287         res += '#';
8288         res += !skipEncoding ? encodeURIComponentFast(fragment, false, false) : fragment;
8289     }
8290     return res;
8291 }
8292 var _a;
8293
8294
8295 /***/ }),
8296 /* 39 */
8297 /***/ (function(module, exports, __webpack_require__) {
8298
8299 "use strict";
8300
8301 Object.defineProperty(exports, "__esModule", { value: true });
8302 var Is;
8303 (function (Is) {
8304     const toString = Object.prototype.toString;
8305     function boolean(value) {
8306         return value === true || value === false;
8307     }
8308     Is.boolean = boolean;
8309     function string(value) {
8310         return toString.call(value) === '[object String]';
8311     }
8312     Is.string = string;
8313 })(Is = exports.Is || (exports.Is = {}));
8314 var DirectoryItem;
8315 (function (DirectoryItem) {
8316     function is(item) {
8317         let candidate = item;
8318         return (candidate &&
8319             Is.string(candidate.directory) &&
8320             (Is.boolean(candidate.changeProcessCWD) ||
8321                 candidate.changeProcessCWD === void 0));
8322     }
8323     DirectoryItem.is = is;
8324 })(DirectoryItem = exports.DirectoryItem || (exports.DirectoryItem = {}));
8325 //# sourceMappingURL=types.js.map
8326
8327 /***/ }),
8328 /* 40 */
8329 /***/ (function(module, exports, __webpack_require__) {
8330
8331 "use strict";
8332
8333 Object.defineProperty(exports, "__esModule", { value: true });
8334 const tslib_1 = __webpack_require__(1);
8335 const fast_diff_1 = tslib_1.__importDefault(__webpack_require__(41));
8336 const vscode_uri_1 = __webpack_require__(38);
8337 const resolve_from_1 = tslib_1.__importDefault(__webpack_require__(42));
8338 function getAllFixEdits(textDocument, settings) {
8339     let u = vscode_uri_1.URI.parse(textDocument.uri);
8340     if (u.scheme != 'file')
8341         return [];
8342     let content = textDocument.getText();
8343     let newOptions = Object.assign({}, settings.options, {
8344         fix: true
8345     });
8346     let filename = vscode_uri_1.URI.parse(textDocument.uri).fsPath;
8347     let engine = new settings.library.CLIEngine(newOptions);
8348     let res = engine.executeOnText(content, filename);
8349     if (!res.results.length)
8350         return [];
8351     let { output } = res.results[0];
8352     if (output == null)
8353         return [];
8354     let change = getChange(content, output);
8355     return [{
8356             range: {
8357                 start: textDocument.positionAt(change.start),
8358                 end: textDocument.positionAt(change.end)
8359             },
8360             newText: change.newText
8361         }];
8362 }
8363 exports.getAllFixEdits = getAllFixEdits;
8364 function getChange(oldStr, newStr) {
8365     let result = fast_diff_1.default(oldStr, newStr, 1);
8366     let curr = 0;
8367     let start = -1;
8368     let end = -1;
8369     let newText = '';
8370     let remain = '';
8371     for (let item of result) {
8372         let [t, str] = item;
8373         // equal
8374         if (t == 0) {
8375             curr = curr + str.length;
8376             if (start != -1)
8377                 remain = remain + str;
8378         }
8379         else {
8380             if (start == -1)
8381                 start = curr;
8382             if (t == 1) {
8383                 newText = newText + remain + str;
8384                 end = curr;
8385             }
8386             else {
8387                 newText = newText + remain;
8388                 end = curr + str.length;
8389             }
8390             remain = '';
8391             if (t == -1)
8392                 curr = curr + str.length;
8393         }
8394     }
8395     return { start, end, newText };
8396 }
8397 exports.getChange = getChange;
8398 function resolveModule(name, localPath, globalPath) {
8399     if (localPath) {
8400         let path = resolve_from_1.default.silent(localPath, name);
8401         if (path)
8402             return Promise.resolve(path);
8403     }
8404     try {
8405         let path = resolve_from_1.default(globalPath, name);
8406         return Promise.resolve(path);
8407     }
8408     catch (e) {
8409         return Promise.reject(e);
8410     }
8411 }
8412 exports.resolveModule = resolveModule;
8413 //# sourceMappingURL=util.js.map
8414
8415 /***/ }),
8416 /* 41 */
8417 /***/ (function(module, exports) {
8418
8419 /**
8420  * This library modifies the diff-patch-match library by Neil Fraser
8421  * by removing the patch and match functionality and certain advanced
8422  * options in the diff function. The original license is as follows:
8423  *
8424  * ===
8425  *
8426  * Diff Match and Patch
8427  *
8428  * Copyright 2006 Google Inc.
8429  * http://code.google.com/p/google-diff-match-patch/
8430  *
8431  * Licensed under the Apache License, Version 2.0 (the "License");
8432  * you may not use this file except in compliance with the License.
8433  * You may obtain a copy of the License at
8434  *
8435  *   http://www.apache.org/licenses/LICENSE-2.0
8436  *
8437  * Unless required by applicable law or agreed to in writing, software
8438  * distributed under the License is distributed on an "AS IS" BASIS,
8439  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8440  * See the License for the specific language governing permissions and
8441  * limitations under the License.
8442  */
8443
8444
8445 /**
8446  * The data structure representing a diff is an array of tuples:
8447  * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
8448  * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
8449  */
8450 var DIFF_DELETE = -1;
8451 var DIFF_INSERT = 1;
8452 var DIFF_EQUAL = 0;
8453
8454
8455 /**
8456  * Find the differences between two texts.  Simplifies the problem by stripping
8457  * any common prefix or suffix off the texts before diffing.
8458  * @param {string} text1 Old string to be diffed.
8459  * @param {string} text2 New string to be diffed.
8460  * @param {Int|Object} [cursor_pos] Edit position in text1 or object with more info
8461  * @return {Array} Array of diff tuples.
8462  */
8463 function diff_main(text1, text2, cursor_pos, _fix_unicode) {
8464   // Check for equality
8465   if (text1 === text2) {
8466     if (text1) {
8467       return [[DIFF_EQUAL, text1]];
8468     }
8469     return [];
8470   }
8471
8472   if (cursor_pos != null) {
8473     var editdiff = find_cursor_edit_diff(text1, text2, cursor_pos);
8474     if (editdiff) {
8475       return editdiff;
8476     }
8477   }
8478
8479   // Trim off common prefix (speedup).
8480   var commonlength = diff_commonPrefix(text1, text2);
8481   var commonprefix = text1.substring(0, commonlength);
8482   text1 = text1.substring(commonlength);
8483   text2 = text2.substring(commonlength);
8484
8485   // Trim off common suffix (speedup).
8486   commonlength = diff_commonSuffix(text1, text2);
8487   var commonsuffix = text1.substring(text1.length - commonlength);
8488   text1 = text1.substring(0, text1.length - commonlength);
8489   text2 = text2.substring(0, text2.length - commonlength);
8490
8491   // Compute the diff on the middle block.
8492   var diffs = diff_compute_(text1, text2);
8493
8494   // Restore the prefix and suffix.
8495   if (commonprefix) {
8496     diffs.unshift([DIFF_EQUAL, commonprefix]);
8497   }
8498   if (commonsuffix) {
8499     diffs.push([DIFF_EQUAL, commonsuffix]);
8500   }
8501   diff_cleanupMerge(diffs, _fix_unicode);
8502   return diffs;
8503 };
8504
8505
8506 /**
8507  * Find the differences between two texts.  Assumes that the texts do not
8508  * have any common prefix or suffix.
8509  * @param {string} text1 Old string to be diffed.
8510  * @param {string} text2 New string to be diffed.
8511  * @return {Array} Array of diff tuples.
8512  */
8513 function diff_compute_(text1, text2) {
8514   var diffs;
8515
8516   if (!text1) {
8517     // Just add some text (speedup).
8518     return [[DIFF_INSERT, text2]];
8519   }
8520
8521   if (!text2) {
8522     // Just delete some text (speedup).
8523     return [[DIFF_DELETE, text1]];
8524   }
8525
8526   var longtext = text1.length > text2.length ? text1 : text2;
8527   var shorttext = text1.length > text2.length ? text2 : text1;
8528   var i = longtext.indexOf(shorttext);
8529   if (i !== -1) {
8530     // Shorter text is inside the longer text (speedup).
8531     diffs = [
8532       [DIFF_INSERT, longtext.substring(0, i)],
8533       [DIFF_EQUAL, shorttext],
8534       [DIFF_INSERT, longtext.substring(i + shorttext.length)]
8535     ];
8536     // Swap insertions for deletions if diff is reversed.
8537     if (text1.length > text2.length) {
8538       diffs[0][0] = diffs[2][0] = DIFF_DELETE;
8539     }
8540     return diffs;
8541   }
8542
8543   if (shorttext.length === 1) {
8544     // Single character string.
8545     // After the previous speedup, the character can't be an equality.
8546     return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
8547   }
8548
8549   // Check to see if the problem can be split in two.
8550   var hm = diff_halfMatch_(text1, text2);
8551   if (hm) {
8552     // A half-match was found, sort out the return data.
8553     var text1_a = hm[0];
8554     var text1_b = hm[1];
8555     var text2_a = hm[2];
8556     var text2_b = hm[3];
8557     var mid_common = hm[4];
8558     // Send both pairs off for separate processing.
8559     var diffs_a = diff_main(text1_a, text2_a);
8560     var diffs_b = diff_main(text1_b, text2_b);
8561     // Merge the results.
8562     return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
8563   }
8564
8565   return diff_bisect_(text1, text2);
8566 };
8567
8568
8569 /**
8570  * Find the 'middle snake' of a diff, split the problem in two
8571  * and return the recursively constructed diff.
8572  * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
8573  * @param {string} text1 Old string to be diffed.
8574  * @param {string} text2 New string to be diffed.
8575  * @return {Array} Array of diff tuples.
8576  * @private
8577  */
8578 function diff_bisect_(text1, text2) {
8579   // Cache the text lengths to prevent multiple calls.
8580   var text1_length = text1.length;
8581   var text2_length = text2.length;
8582   var max_d = Math.ceil((text1_length + text2_length) / 2);
8583   var v_offset = max_d;
8584   var v_length = 2 * max_d;
8585   var v1 = new Array(v_length);
8586   var v2 = new Array(v_length);
8587   // Setting all elements to -1 is faster in Chrome & Firefox than mixing
8588   // integers and undefined.
8589   for (var x = 0; x < v_length; x++) {
8590     v1[x] = -1;
8591     v2[x] = -1;
8592   }
8593   v1[v_offset + 1] = 0;
8594   v2[v_offset + 1] = 0;
8595   var delta = text1_length - text2_length;
8596   // If the total number of characters is odd, then the front path will collide
8597   // with the reverse path.
8598   var front = (delta % 2 !== 0);
8599   // Offsets for start and end of k loop.
8600   // Prevents mapping of space beyond the grid.
8601   var k1start = 0;
8602   var k1end = 0;
8603   var k2start = 0;
8604   var k2end = 0;
8605   for (var d = 0; d < max_d; d++) {
8606     // Walk the front path one step.
8607     for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
8608       var k1_offset = v_offset + k1;
8609       var x1;
8610       if (k1 === -d || (k1 !== d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
8611         x1 = v1[k1_offset + 1];
8612       } else {
8613         x1 = v1[k1_offset - 1] + 1;
8614       }
8615       var y1 = x1 - k1;
8616       while (
8617         x1 < text1_length && y1 < text2_length &&
8618         text1.charAt(x1) === text2.charAt(y1)
8619       ) {
8620         x1++;
8621         y1++;
8622       }
8623       v1[k1_offset] = x1;
8624       if (x1 > text1_length) {
8625         // Ran off the right of the graph.
8626         k1end += 2;
8627       } else if (y1 > text2_length) {
8628         // Ran off the bottom of the graph.
8629         k1start += 2;
8630       } else if (front) {
8631         var k2_offset = v_offset + delta - k1;
8632         if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] !== -1) {
8633           // Mirror x2 onto top-left coordinate system.
8634           var x2 = text1_length - v2[k2_offset];
8635           if (x1 >= x2) {
8636             // Overlap detected.
8637             return diff_bisectSplit_(text1, text2, x1, y1);
8638           }
8639         }
8640       }
8641     }
8642
8643     // Walk the reverse path one step.
8644     for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
8645       var k2_offset = v_offset + k2;
8646       var x2;
8647       if (k2 === -d || (k2 !== d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
8648         x2 = v2[k2_offset + 1];
8649       } else {
8650         x2 = v2[k2_offset - 1] + 1;
8651       }
8652       var y2 = x2 - k2;
8653       while (
8654         x2 < text1_length && y2 < text2_length &&
8655         text1.charAt(text1_length - x2 - 1) === text2.charAt(text2_length - y2 - 1)
8656       ) {
8657         x2++;
8658         y2++;
8659       }
8660       v2[k2_offset] = x2;
8661       if (x2 > text1_length) {
8662         // Ran off the left of the graph.
8663         k2end += 2;
8664       } else if (y2 > text2_length) {
8665         // Ran off the top of the graph.
8666         k2start += 2;
8667       } else if (!front) {
8668         var k1_offset = v_offset + delta - k2;
8669         if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] !== -1) {
8670           var x1 = v1[k1_offset];
8671           var y1 = v_offset + x1 - k1_offset;
8672           // Mirror x2 onto top-left coordinate system.
8673           x2 = text1_length - x2;
8674           if (x1 >= x2) {
8675             // Overlap detected.
8676             return diff_bisectSplit_(text1, text2, x1, y1);
8677           }
8678         }
8679       }
8680     }
8681   }
8682   // Diff took too long and hit the deadline or
8683   // number of diffs equals number of characters, no commonality at all.
8684   return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
8685 };
8686
8687
8688 /**
8689  * Given the location of the 'middle snake', split the diff in two parts
8690  * and recurse.
8691  * @param {string} text1 Old string to be diffed.
8692  * @param {string} text2 New string to be diffed.
8693  * @param {number} x Index of split point in text1.
8694  * @param {number} y Index of split point in text2.
8695  * @return {Array} Array of diff tuples.
8696  */
8697 function diff_bisectSplit_(text1, text2, x, y) {
8698   var text1a = text1.substring(0, x);
8699   var text2a = text2.substring(0, y);
8700   var text1b = text1.substring(x);
8701   var text2b = text2.substring(y);
8702
8703   // Compute both diffs serially.
8704   var diffs = diff_main(text1a, text2a);
8705   var diffsb = diff_main(text1b, text2b);
8706
8707   return diffs.concat(diffsb);
8708 };
8709
8710
8711 /**
8712  * Determine the common prefix of two strings.
8713  * @param {string} text1 First string.
8714  * @param {string} text2 Second string.
8715  * @return {number} The number of characters common to the start of each
8716  *     string.
8717  */
8718 function diff_commonPrefix(text1, text2) {
8719   // Quick check for common null cases.
8720   if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
8721     return 0;
8722   }
8723   // Binary search.
8724   // Performance analysis: http://neil.fraser.name/news/2007/10/09/
8725   var pointermin = 0;
8726   var pointermax = Math.min(text1.length, text2.length);
8727   var pointermid = pointermax;
8728   var pointerstart = 0;
8729   while (pointermin < pointermid) {
8730     if (
8731       text1.substring(pointerstart, pointermid) ==
8732       text2.substring(pointerstart, pointermid)
8733     ) {
8734       pointermin = pointermid;
8735       pointerstart = pointermin;
8736     } else {
8737       pointermax = pointermid;
8738     }
8739     pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
8740   }
8741
8742   if (is_surrogate_pair_start(text1.charCodeAt(pointermid - 1))) {
8743     pointermid--;
8744   }
8745
8746   return pointermid;
8747 };
8748
8749
8750 /**
8751  * Determine the common suffix of two strings.
8752  * @param {string} text1 First string.
8753  * @param {string} text2 Second string.
8754  * @return {number} The number of characters common to the end of each string.
8755  */
8756 function diff_commonSuffix(text1, text2) {
8757   // Quick check for common null cases.
8758   if (!text1 || !text2 || text1.slice(-1) !== text2.slice(-1)) {
8759     return 0;
8760   }
8761   // Binary search.
8762   // Performance analysis: http://neil.fraser.name/news/2007/10/09/
8763   var pointermin = 0;
8764   var pointermax = Math.min(text1.length, text2.length);
8765   var pointermid = pointermax;
8766   var pointerend = 0;
8767   while (pointermin < pointermid) {
8768     if (
8769       text1.substring(text1.length - pointermid, text1.length - pointerend) ==
8770       text2.substring(text2.length - pointermid, text2.length - pointerend)
8771     ) {
8772       pointermin = pointermid;
8773       pointerend = pointermin;
8774     } else {
8775       pointermax = pointermid;
8776     }
8777     pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
8778   }
8779
8780   if (is_surrogate_pair_end(text1.charCodeAt(text1.length - pointermid))) {
8781     pointermid--;
8782   }
8783
8784   return pointermid;
8785 };
8786
8787
8788 /**
8789  * Do the two texts share a substring which is at least half the length of the
8790  * longer text?
8791  * This speedup can produce non-minimal diffs.
8792  * @param {string} text1 First string.
8793  * @param {string} text2 Second string.
8794  * @return {Array.<string>} Five element Array, containing the prefix of
8795  *     text1, the suffix of text1, the prefix of text2, the suffix of
8796  *     text2 and the common middle.  Or null if there was no match.
8797  */
8798 function diff_halfMatch_(text1, text2) {
8799   var longtext = text1.length > text2.length ? text1 : text2;
8800   var shorttext = text1.length > text2.length ? text2 : text1;
8801   if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
8802     return null;  // Pointless.
8803   }
8804
8805   /**
8806    * Does a substring of shorttext exist within longtext such that the substring
8807    * is at least half the length of longtext?
8808    * Closure, but does not reference any external variables.
8809    * @param {string} longtext Longer string.
8810    * @param {string} shorttext Shorter string.
8811    * @param {number} i Start index of quarter length substring within longtext.
8812    * @return {Array.<string>} Five element Array, containing the prefix of
8813    *     longtext, the suffix of longtext, the prefix of shorttext, the suffix
8814    *     of shorttext and the common middle.  Or null if there was no match.
8815    * @private
8816    */
8817   function diff_halfMatchI_(longtext, shorttext, i) {
8818     // Start with a 1/4 length substring at position i as a seed.
8819     var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
8820     var j = -1;
8821     var best_common = '';
8822     var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
8823     while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
8824       var prefixLength = diff_commonPrefix(
8825         longtext.substring(i), shorttext.substring(j));
8826       var suffixLength = diff_commonSuffix(
8827         longtext.substring(0, i), shorttext.substring(0, j));
8828       if (best_common.length < suffixLength + prefixLength) {
8829         best_common = shorttext.substring(
8830           j - suffixLength, j) + shorttext.substring(j, j + prefixLength);
8831         best_longtext_a = longtext.substring(0, i - suffixLength);
8832         best_longtext_b = longtext.substring(i + prefixLength);
8833         best_shorttext_a = shorttext.substring(0, j - suffixLength);
8834         best_shorttext_b = shorttext.substring(j + prefixLength);
8835       }
8836     }
8837     if (best_common.length * 2 >= longtext.length) {
8838       return [
8839         best_longtext_a, best_longtext_b,
8840         best_shorttext_a, best_shorttext_b, best_common
8841       ];
8842     } else {
8843       return null;
8844     }
8845   }
8846
8847   // First check if the second quarter is the seed for a half-match.
8848   var hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4));
8849   // Check again based on the third quarter.
8850   var hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
8851   var hm;
8852   if (!hm1 && !hm2) {
8853     return null;
8854   } else if (!hm2) {
8855     hm = hm1;
8856   } else if (!hm1) {
8857     hm = hm2;
8858   } else {
8859     // Both matched.  Select the longest.
8860     hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
8861   }
8862
8863   // A half-match was found, sort out the return data.
8864   var text1_a, text1_b, text2_a, text2_b;
8865   if (text1.length > text2.length) {
8866     text1_a = hm[0];
8867     text1_b = hm[1];
8868     text2_a = hm[2];
8869     text2_b = hm[3];
8870   } else {
8871     text2_a = hm[0];
8872     text2_b = hm[1];
8873     text1_a = hm[2];
8874     text1_b = hm[3];
8875   }
8876   var mid_common = hm[4];
8877   return [text1_a, text1_b, text2_a, text2_b, mid_common];
8878 };
8879
8880
8881 /**
8882  * Reorder and merge like edit sections.  Merge equalities.
8883  * Any edit section can move as long as it doesn't cross an equality.
8884  * @param {Array} diffs Array of diff tuples.
8885  * @param {boolean} fix_unicode Whether to normalize to a unicode-correct diff
8886  */
8887 function diff_cleanupMerge(diffs, fix_unicode) {
8888   diffs.push([DIFF_EQUAL, '']);  // Add a dummy entry at the end.
8889   var pointer = 0;
8890   var count_delete = 0;
8891   var count_insert = 0;
8892   var text_delete = '';
8893   var text_insert = '';
8894   var commonlength;
8895   while (pointer < diffs.length) {
8896     if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
8897       diffs.splice(pointer, 1);
8898       continue;
8899     }
8900     switch (diffs[pointer][0]) {
8901       case DIFF_INSERT:
8902
8903         count_insert++;
8904         text_insert += diffs[pointer][1];
8905         pointer++;
8906         break;
8907       case DIFF_DELETE:
8908         count_delete++;
8909         text_delete += diffs[pointer][1];
8910         pointer++;
8911         break;
8912       case DIFF_EQUAL:
8913         var previous_equality = pointer - count_insert - count_delete - 1;
8914         if (fix_unicode) {
8915           // prevent splitting of unicode surrogate pairs.  when fix_unicode is true,
8916           // we assume that the old and new text in the diff are complete and correct
8917           // unicode-encoded JS strings, but the tuple boundaries may fall between
8918           // surrogate pairs.  we fix this by shaving off stray surrogates from the end
8919           // of the previous equality and the beginning of this equality.  this may create
8920           // empty equalities or a common prefix or suffix.  for example, if AB and AC are
8921           // emojis, `[[0, 'A'], [-1, 'BA'], [0, 'C']]` would turn into deleting 'ABAC' and
8922           // inserting 'AC', and then the common suffix 'AC' will be eliminated.  in this
8923           // particular case, both equalities go away, we absorb any previous inequalities,
8924           // and we keep scanning for the next equality before rewriting the tuples.
8925           if (previous_equality >= 0 && ends_with_pair_start(diffs[previous_equality][1])) {
8926             var stray = diffs[previous_equality][1].slice(-1);
8927             diffs[previous_equality][1] = diffs[previous_equality][1].slice(0, -1);
8928             text_delete = stray + text_delete;
8929             text_insert = stray + text_insert;
8930             if (!diffs[previous_equality][1]) {
8931               // emptied out previous equality, so delete it and include previous delete/insert
8932               diffs.splice(previous_equality, 1);
8933               pointer--;
8934               var k = previous_equality - 1;
8935               if (diffs[k] && diffs[k][0] === DIFF_INSERT) {
8936                 count_insert++;
8937                 text_insert = diffs[k][1] + text_insert;
8938                 k--;
8939               }
8940               if (diffs[k] && diffs[k][0] === DIFF_DELETE) {
8941                 count_delete++;
8942                 text_delete = diffs[k][1] + text_delete;
8943                 k--;
8944               }
8945               previous_equality = k;
8946             }
8947           }
8948           if (starts_with_pair_end(diffs[pointer][1])) {
8949             var stray = diffs[pointer][1].charAt(0);
8950             diffs[pointer][1] = diffs[pointer][1].slice(1);
8951             text_delete += stray;
8952             text_insert += stray;
8953           }
8954         }
8955         if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
8956           // for empty equality not at end, wait for next equality
8957           diffs.splice(pointer, 1);
8958           break;
8959         }
8960         if (text_delete.length > 0 || text_insert.length > 0) {
8961           // note that diff_commonPrefix and diff_commonSuffix are unicode-aware
8962           if (text_delete.length > 0 && text_insert.length > 0) {
8963             // Factor out any common prefixes.
8964             commonlength = diff_commonPrefix(text_insert, text_delete);
8965             if (commonlength !== 0) {
8966               if (previous_equality >= 0) {
8967                 diffs[previous_equality][1] += text_insert.substring(0, commonlength);
8968               } else {
8969                 diffs.splice(0, 0, [DIFF_EQUAL, text_insert.substring(0, commonlength)]);
8970                 pointer++;
8971               }
8972               text_insert = text_insert.substring(commonlength);
8973               text_delete = text_delete.substring(commonlength);
8974             }
8975             // Factor out any common suffixes.
8976             commonlength = diff_commonSuffix(text_insert, text_delete);
8977             if (commonlength !== 0) {
8978               diffs[pointer][1] =
8979                 text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
8980               text_insert = text_insert.substring(0, text_insert.length - commonlength);
8981               text_delete = text_delete.substring(0, text_delete.length - commonlength);
8982             }
8983           }
8984           // Delete the offending records and add the merged ones.
8985           var n = count_insert + count_delete;
8986           if (text_delete.length === 0 && text_insert.length === 0) {
8987             diffs.splice(pointer - n, n);
8988             pointer = pointer - n;
8989           } else if (text_delete.length === 0) {
8990             diffs.splice(pointer - n, n, [DIFF_INSERT, text_insert]);
8991             pointer = pointer - n + 1;
8992           } else if (text_insert.length === 0) {
8993             diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete]);
8994             pointer = pointer - n + 1;
8995           } else {
8996             diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete], [DIFF_INSERT, text_insert]);
8997             pointer = pointer - n + 2;
8998           }
8999         }
9000         if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
9001           // Merge this equality with the previous one.
9002           diffs[pointer - 1][1] += diffs[pointer][1];
9003           diffs.splice(pointer, 1);
9004         } else {
9005           pointer++;
9006         }
9007         count_insert = 0;
9008         count_delete = 0;
9009         text_delete = '';
9010         text_insert = '';
9011         break;
9012     }
9013   }
9014   if (diffs[diffs.length - 1][1] === '') {
9015     diffs.pop();  // Remove the dummy entry at the end.
9016   }
9017
9018   // Second pass: look for single edits surrounded on both sides by equalities
9019   // which can be shifted sideways to eliminate an equality.
9020   // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
9021   var changes = false;
9022   pointer = 1;
9023   // Intentionally ignore the first and last element (don't need checking).
9024   while (pointer < diffs.length - 1) {
9025     if (diffs[pointer - 1][0] === DIFF_EQUAL &&
9026       diffs[pointer + 1][0] === DIFF_EQUAL) {
9027       // This is a single edit surrounded by equalities.
9028       if (diffs[pointer][1].substring(diffs[pointer][1].length -
9029         diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
9030         // Shift the edit over the previous equality.
9031         diffs[pointer][1] = diffs[pointer - 1][1] +
9032           diffs[pointer][1].substring(0, diffs[pointer][1].length -
9033             diffs[pointer - 1][1].length);
9034         diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
9035         diffs.splice(pointer - 1, 1);
9036         changes = true;
9037       } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
9038         diffs[pointer + 1][1]) {
9039         // Shift the edit over the next equality.
9040         diffs[pointer - 1][1] += diffs[pointer + 1][1];
9041         diffs[pointer][1] =
9042           diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
9043           diffs[pointer + 1][1];
9044         diffs.splice(pointer + 1, 1);
9045         changes = true;
9046       }
9047     }
9048     pointer++;
9049   }
9050   // If shifts were made, the diff needs reordering and another shift sweep.
9051   if (changes) {
9052     diff_cleanupMerge(diffs, fix_unicode);
9053   }
9054 };
9055
9056 function is_surrogate_pair_start(charCode) {
9057   return charCode >= 0xD800 && charCode <= 0xDBFF;
9058 }
9059
9060 function is_surrogate_pair_end(charCode) {
9061   return charCode >= 0xDC00 && charCode <= 0xDFFF;
9062 }
9063
9064 function starts_with_pair_end(str) {
9065   return is_surrogate_pair_end(str.charCodeAt(0));
9066 }
9067
9068 function ends_with_pair_start(str) {
9069   return is_surrogate_pair_start(str.charCodeAt(str.length - 1));
9070 }
9071
9072 function remove_empty_tuples(tuples) {
9073   var ret = [];
9074   for (var i = 0; i < tuples.length; i++) {
9075     if (tuples[i][1].length > 0) {
9076       ret.push(tuples[i]);
9077     }
9078   }
9079   return ret;
9080 }
9081
9082 function make_edit_splice(before, oldMiddle, newMiddle, after) {
9083   if (ends_with_pair_start(before) || starts_with_pair_end(after)) {
9084     return null;
9085   }
9086   return remove_empty_tuples([
9087     [DIFF_EQUAL, before],
9088     [DIFF_DELETE, oldMiddle],
9089     [DIFF_INSERT, newMiddle],
9090     [DIFF_EQUAL, after]
9091   ]);
9092 }
9093
9094 function find_cursor_edit_diff(oldText, newText, cursor_pos) {
9095   // note: this runs after equality check has ruled out exact equality
9096   var oldRange = typeof cursor_pos === 'number' ?
9097     { index: cursor_pos, length: 0 } : cursor_pos.oldRange;
9098   var newRange = typeof cursor_pos === 'number' ?
9099     null : cursor_pos.newRange;
9100   // take into account the old and new selection to generate the best diff
9101   // possible for a text edit.  for example, a text change from "xxx" to "xx"
9102   // could be a delete or forwards-delete of any one of the x's, or the
9103   // result of selecting two of the x's and typing "x".
9104   var oldLength = oldText.length;
9105   var newLength = newText.length;
9106   if (oldRange.length === 0 && (newRange === null || newRange.length === 0)) {
9107     // see if we have an insert or delete before or after cursor
9108     var oldCursor = oldRange.index;
9109     var oldBefore = oldText.slice(0, oldCursor);
9110     var oldAfter = oldText.slice(oldCursor);
9111     var maybeNewCursor = newRange ? newRange.index : null;
9112     editBefore: {
9113       // is this an insert or delete right before oldCursor?
9114       var newCursor = oldCursor + newLength - oldLength;
9115       if (maybeNewCursor !== null && maybeNewCursor !== newCursor) {
9116         break editBefore;
9117       }
9118       if (newCursor < 0 || newCursor > newLength) {
9119         break editBefore;
9120       }
9121       var newBefore = newText.slice(0, newCursor);
9122       var newAfter = newText.slice(newCursor);
9123       if (newAfter !== oldAfter) {
9124         break editBefore;
9125       }
9126       var prefixLength = Math.min(oldCursor, newCursor);
9127       var oldPrefix = oldBefore.slice(0, prefixLength);
9128       var newPrefix = newBefore.slice(0, prefixLength);
9129       if (oldPrefix !== newPrefix) {
9130         break editBefore;
9131       }
9132       var oldMiddle = oldBefore.slice(prefixLength);
9133       var newMiddle = newBefore.slice(prefixLength);
9134       return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldAfter);
9135     }
9136     editAfter: {
9137       // is this an insert or delete right after oldCursor?
9138       if (maybeNewCursor !== null && maybeNewCursor !== oldCursor) {
9139         break editAfter;
9140       }
9141       var cursor = oldCursor;
9142       var newBefore = newText.slice(0, cursor);
9143       var newAfter = newText.slice(cursor);
9144       if (newBefore !== oldBefore) {
9145         break editAfter;
9146       }
9147       var suffixLength = Math.min(oldLength - cursor, newLength - cursor);
9148       var oldSuffix = oldAfter.slice(oldAfter.length - suffixLength);
9149       var newSuffix = newAfter.slice(newAfter.length - suffixLength);
9150       if (oldSuffix !== newSuffix) {
9151         break editAfter;
9152       }
9153       var oldMiddle = oldAfter.slice(0, oldAfter.length - suffixLength);
9154       var newMiddle = newAfter.slice(0, newAfter.length - suffixLength);
9155       return make_edit_splice(oldBefore, oldMiddle, newMiddle, oldSuffix);
9156     }
9157   }
9158   if (oldRange.length > 0 && newRange && newRange.length === 0) {
9159     replaceRange: {
9160       // see if diff could be a splice of the old selection range
9161       var oldPrefix = oldText.slice(0, oldRange.index);
9162       var oldSuffix = oldText.slice(oldRange.index + oldRange.length);
9163       var prefixLength = oldPrefix.length;
9164       var suffixLength = oldSuffix.length;
9165       if (newLength < prefixLength + suffixLength) {
9166         break replaceRange;
9167       }
9168       var newPrefix = newText.slice(0, prefixLength);
9169       var newSuffix = newText.slice(newLength - suffixLength);
9170       if (oldPrefix !== newPrefix || oldSuffix !== newSuffix) {
9171         break replaceRange;
9172       }
9173       var oldMiddle = oldText.slice(prefixLength, oldLength - suffixLength);
9174       var newMiddle = newText.slice(prefixLength, newLength - suffixLength);
9175       return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldSuffix);
9176     }
9177   }
9178
9179   return null;
9180 }
9181
9182 function diff(text1, text2, cursor_pos) {
9183   // only pass fix_unicode=true at the top level, not when diff_main is
9184   // recursively invoked
9185   return diff_main(text1, text2, cursor_pos, true);
9186 }
9187
9188 diff.INSERT = DIFF_INSERT;
9189 diff.DELETE = DIFF_DELETE;
9190 diff.EQUAL = DIFF_EQUAL;
9191
9192 module.exports = diff;
9193
9194
9195 /***/ }),
9196 /* 42 */
9197 /***/ (function(module, exports, __webpack_require__) {
9198
9199 "use strict";
9200
9201 const path = __webpack_require__(3);
9202 const Module = __webpack_require__(43);
9203 const fs = __webpack_require__(35);
9204
9205 const resolveFrom = (fromDirectory, moduleId, silent) => {
9206         if (typeof fromDirectory !== 'string') {
9207                 throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDirectory}\``);
9208         }
9209
9210         if (typeof moduleId !== 'string') {
9211                 throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
9212         }
9213
9214         try {
9215                 fromDirectory = fs.realpathSync(fromDirectory);
9216         } catch (error) {
9217                 if (error.code === 'ENOENT') {
9218                         fromDirectory = path.resolve(fromDirectory);
9219                 } else if (silent) {
9220                         return;
9221                 } else {
9222                         throw error;
9223                 }
9224         }
9225
9226         const fromFile = path.join(fromDirectory, 'noop.js');
9227
9228         const resolveFileName = () => Module._resolveFilename(moduleId, {
9229                 id: fromFile,
9230                 filename: fromFile,
9231                 paths: Module._nodeModulePaths(fromDirectory)
9232         });
9233
9234         if (silent) {
9235                 try {
9236                         return resolveFileName();
9237                 } catch (error) {
9238                         return;
9239                 }
9240         }
9241
9242         return resolveFileName();
9243 };
9244
9245 module.exports = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId);
9246 module.exports.silent = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId, true);
9247
9248
9249 /***/ }),
9250 /* 43 */
9251 /***/ (function(module, exports) {
9252
9253 module.exports = require("module");
9254
9255 /***/ })
9256 /******/ ]);