1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId]) {
10 /******/ return installedModules[moduleId].exports;
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
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 });
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' });
48 /******/ Object.defineProperty(exports, '__esModule', { value: true });
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));
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;
76 /******/ // Object.prototype.hasOwnProperty.call
77 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79 /******/ // __webpack_public_path__
80 /******/ __webpack_require__.p = "";
83 /******/ // Load entry module and return exports
84 /******/ return __webpack_require__(__webpack_require__.s = 0);
86 /************************************************************************/
89 /***/ (function(module, exports, __webpack_require__) {
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 * ------------------------------------------------------------------------------------------ */
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;
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 = {}));
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 = {}));
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 {
140 this._actions = new Map();
143 let result = this._actions.get(ruleId);
144 if (result === undefined) {
145 result = { fixes: [] };
146 this._actions.set(ruleId, result);
151 this._fixAll = action;
155 for (let actions of this._actions.values()) {
156 result.push(...actions.fixes);
157 if (actions.disable) {
158 result.push(actions.disable);
160 if (actions.fixAll) {
161 result.push(actions.fixAll);
163 if (actions.disableFile) {
164 result.push(actions.disableFile);
166 if (actions.showDocumentation) {
167 result.push(actions.showDocumentation);
170 if (this._fixAll !== undefined) {
171 result.push(this._fixAll);
177 for (let actions of this._actions.values()) {
178 result += actions.fixes.length;
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;
193 severity: convertSeverity(problem.severity),
196 start: { line: startLine, character: startChar },
197 end: { line: endLine, character: endChar }
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}`;
206 let codeActions = new Map();
207 function recordCodeAction(document, diagnostic, problem) {
208 if (!problem.ruleId) {
211 let uri = document.uri;
212 let edits = codeActions.get(uri);
215 codeActions.set(uri, edits);
217 edits.set(computeKey(diagnostic), { label: `Fix this ${problem.ruleId} problem`, documentVersion: document.version, ruleId: problem.ruleId, edit: problem.fix, line: problem.line });
219 function convertSeverity(severity) {
221 // Eslint 1 is warning
223 return vscode_languageserver_1.DiagnosticSeverity.Warning;
225 return vscode_languageserver_1.DiagnosticSeverity.Error;
227 return vscode_languageserver_1.DiagnosticSeverity.Error;
231 * Check if the path follows this pattern: `\\hostname\sharename`.
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
237 function isUNC(path) {
238 if (process.platform !== 'win32') {
239 // UNC is a windows concept
242 if (!path || path.length < 5) {
246 let code = path.charCodeAt(0);
247 if (code !== 92 /* Backslash */) {
250 code = path.charCodeAt(1);
251 if (code !== 92 /* Backslash */) {
256 for (; pos < path.length; pos++) {
257 code = path.charCodeAt(pos);
258 if (code === 92 /* Backslash */) {
265 code = path.charCodeAt(pos + 1);
266 if (isNaN(code) || code === 92 /* Backslash */) {
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);
283 function getFilePath(documentOrUri) {
284 if (!documentOrUri) {
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') {
293 return getFileSystemPath(uri);
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]);
304 process.on('uncaughtException', (error) => {
307 if (typeof error.stack === 'string') {
308 message = error.stack;
310 else if (typeof error.message === 'string') {
311 message = error.message;
313 else if (typeof error === 'string') {
318 message = JSON.stringify(error, undefined, 4);
321 // Should not happen.
325 connection.console.error(`Uncaught exception recevied.
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();
332 function globalNpmPath() {
333 if (_globalNpmPath === void 0) {
334 _globalNpmPath = vscode_languageserver_1.Files.resolveGlobalNodePath(trace);
335 if (_globalNpmPath === void 0) {
336 _globalNpmPath = null;
339 if (_globalNpmPath === null) {
342 return _globalNpmPath;
345 function globalYarnPath() {
346 if (_globalYarnPath === void 0) {
347 _globalYarnPath = vscode_languageserver_1.Files.resolveGlobalYarnPath(trace);
348 if (_globalYarnPath === void 0) {
349 _globalYarnPath = null;
352 if (_globalYarnPath === null) {
355 return _globalYarnPath;
357 let path2Library = new Map();
358 let document2Settings = new Map();
363 function resolveSettings(document) {
364 let uri = document.uri;
365 let resultPromise = document2Settings.get(uri);
367 return resultPromise;
369 resultPromise = connection.workspace
370 .getConfiguration({ scopeUri: uri, section: '' })
371 .then((settings) => {
373 if (settings.nodePath) {
374 nodePath = settings.nodePath;
375 if (nodePath.startsWith('~')) {
376 nodePath = nodePath.replace(/^~/, os.homedir());
378 if (!path.isAbsolute(nodePath)) {
379 nodePath = path.join(vscode_uri_1.URI.parse(settings.workspaceFolder.uri).fsPath, nodePath);
382 else if (settings.packageManager === 'npm') {
383 nodePath = globalNpmPath();
385 else if (settings.packageManager === 'yarn') {
386 nodePath = globalYarnPath();
388 let uri = vscode_uri_1.URI.parse(document.uri);
391 if (uri.scheme === 'file') {
392 directory = path.dirname(uri.fsPath);
395 directory = settings.workspaceFolder ? vscode_uri_1.URI.parse(settings.workspaceFolder.uri).fsPath : undefined;
397 promise = util_1.resolveModule('eslint', directory, nodePath);
398 return promise.then(path => {
399 let library = path2Library.get(path);
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`);
407 connection.console.info(`ESLint library loaded from: ${path}`);
408 settings.library = library;
410 path2Library.set(path, library);
413 settings.library = library;
417 settings.validate = false;
418 connection.sendRequest(NoESLintLibraryRequest.type, {
419 source: { uri: document.uri }
424 document2Settings.set(uri, resultPromise);
425 return resultPromise;
428 (function (Request) {
430 let candidate = value;
433 !!candidate.resolve &&
437 })(Request || (Request = {}));
439 (function (Thenable) {
441 let candidate = value;
442 return candidate && typeof candidate.then === 'function';
445 })(Thenable || (Thenable = {}));
446 class BufferedMessageQueue {
447 constructor(connection) {
448 this.connection = connection;
450 this.requestHandlers = new Map();
451 this.notificationHandlers = new Map();
453 registerRequest(type, handler, versionProvider) {
454 this.connection.onRequest(type, (params, token) => {
455 return new Promise((resolve, reject) => {
459 documentVersion: versionProvider
460 ? versionProvider(params)
469 this.requestHandlers.set(type.method, { handler, versionProvider });
471 registerNotification(type, handler, versionProvider) {
472 connection.onNotification(type, params => {
476 documentVersion: versionProvider ? versionProvider(params) : undefined
480 this.notificationHandlers.set(type.method, { handler, versionProvider });
482 addNotificationMessage(type, params, version) {
486 documentVersion: version
490 onNotification(type, handler, versionProvider) {
491 this.notificationHandlers.set(type.method, { handler, versionProvider });
494 if (this.timer || this.queue.length === 0) {
497 this.timer = setImmediate(() => {
498 this.timer = undefined;
503 let message = this.queue.shift();
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'));
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'));
525 let result = elem.handler(requestMessage.params, requestMessage.token);
526 if (Thenable.is(result)) {
527 result.then(value => {
528 requestMessage.resolve(value);
530 requestMessage.reject(error);
534 requestMessage.resolve(result);
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)) {
546 elem.handler(notificationMessage.params);
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);
559 return document.version;
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) {
569 if (settings.run === 'onSave') {
570 messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
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') {
580 messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
583 documents.onWillSaveWaitUntil(event => {
584 if (event.reason === vscode_languageserver_1.TextDocumentSaveReason.AfterDelay) {
587 let document = event.document;
588 return resolveSettings(document).then(settings => {
589 if (!settings.autoFixOnSave) {
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));
599 return util_1.getAllFixEdits(document, settings);
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') {
609 messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
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: [] });
622 function environmentChanged() {
623 document2Settings.clear();
624 for (let document of documents.all()) {
625 messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
628 function trace(message, verbose) {
629 connection.tracer.log(message, verbose);
631 connection.onInitialize(_params => {
636 change: vscode_languageserver_1.TextDocumentSyncKind.Full,
637 willSaveWaitUntil: true,
642 codeActionProvider: true,
643 executeCommandProvider: {
645 CommandIds.applySingleFix,
646 CommandIds.applySameFixes,
647 CommandIds.applyAllFixes,
648 CommandIds.applyAutoFix,
649 CommandIds.applyDisableLine,
650 CommandIds.applyDisableFile,
651 CommandIds.openRuleDoc,
657 connection.onInitialized(() => {
658 connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type, undefined);
660 messageQueue.registerNotification(vscode_languageserver_1.DidChangeConfigurationNotification.type, _params => {
661 environmentChanged();
663 // messageQueue.registerNotification(
664 // DidChangeWorkspaceFoldersNotification.type,
666 // environmentChanged()
669 const singleErrorHandlers = [
671 tryHandleConfigError,
672 tryHandleMissingModule,
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);
681 return resolveSettings(document).then(settings => {
682 if (!settings.validate) {
686 validate(document, settings, publishDiagnostics);
687 connection.sendNotification(StatusNotification.type, { state: Status.ok });
691 for (let handler of singleErrorHandlers) {
692 status = handler(err, document, settings.library);
697 status = status || Status.error;
698 connection.sendNotification(StatusNotification.type, { state: status });
702 function validateMany(documents) {
703 documents.forEach(document => {
704 messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
707 function getMessage(err, document) {
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);
717 result = `An unknown error occured while validating document: ${document.uri}`;
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();
729 if (settings.workingDirectory) {
730 newOptions.cwd = settings.workingDirectory.directory;
731 if (settings.workingDirectory.changeProcessCWD) {
732 process.chdir(settings.workingDirectory.directory);
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);
743 else if (!settings.workspaceFolder && !isUNC(file)) {
744 let directory = path.dirname(file);
746 if (path.isAbsolute(directory)) {
747 newOptions.cwd = directory;
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 => {
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
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);
777 recordCodeAction(document, diagnostic, problem);
784 if (publishDiagnostics) {
785 connection.sendDiagnostics({ uri, diagnostics });
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);
798 if (cwd !== process.cwd()) {
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.');
809 function tryHandleNoConfig(error, document, library) {
810 if (!isNoConfigFoundError(error)) {
813 if (!noConfigReported.has(document.uri)) {
815 .sendRequest(NoConfigRequest.type, {
816 message: getMessage(error, document),
821 .then(undefined, () => {
824 noConfigReported.set(document.uri, library);
828 let configErrorReported = new Map();
829 function tryHandleConfigError(error, document, library) {
830 if (!error.message) {
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));
839 configErrorReported.set(filename, library);
843 let matches = /Cannot read config file:\s+(.*)\nError:\s+(.*)/.exec(error.message);
844 if (matches && matches.length === 3) {
845 return handleFileName(matches[1]);
847 matches = /(.*):\n\s*Configuration for rule \"(.*)\" is /.exec(error.message);
848 if (matches && matches.length === 3) {
849 return handleFileName(matches[1]);
851 matches = /Cannot find module '([^']*)'\nReferenced from:\s+(.*)/.exec(error.message);
852 if (matches && matches.length === 3) {
853 return handleFileName(matches[2]);
857 let missingModuleReported = new Map();
858 function tryHandleMissingModule(error, document, library) {
859 if (!error.message) {
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([
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.`,
876 `Consider running eslint --debug ${fsPath ? fsPath : document.uri} from a terminal to obtain a trace about the configuration files used.`
880 connection.console.error([
881 `${error.message.toString()}`,
882 `Happend while validating ${fsPath ? fsPath : document.uri}`
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);
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);
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)) {
912 let dirname = path.dirname(fsPath);
914 let library = configErrorReported.get(fsPath);
916 let cli = new library.CLIEngine({});
918 cli.executeOnText('', path.join(dirname, '___test___.js'));
919 configErrorReported.delete(fsPath);
927 validateMany(documents.all());
933 static overlaps(lastEdit, newEdit) {
934 return !!lastEdit && lastEdit.edit.range[1] > newEdit.edit.range[0];
937 return this.edits.size === 0;
939 getDocumentVersion() {
940 if (this.isEmpty()) {
941 throw new Error('No edits recorded.');
943 return this.edits.values().next().value.documentVersion;
945 getScoped(diagnostics) {
947 for (let diagnostic of diagnostics) {
948 let key = computeKey(diagnostic);
949 let editInfo = this.edits.get(key);
951 result.push(editInfo);
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];
964 if (a.edit.range[1] === 0) {
967 if (b.edit.range[1] === 0) {
970 return a.edit.range[1] - b.edit.range[1];
974 let sorted = this.getAllSorted();
975 if (sorted.length <= 1) {
979 let last = sorted[0];
981 for (let i = 1; i < sorted.length; i++) {
982 let current = sorted[i];
983 if (!Fixes.overlaps(last, current)) {
984 result.push(current);
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);
999 let fixes = new Fixes(edits);
1000 if (fixes.isEmpty())
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 || '');
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`);
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}`);
1014 function createDisableFileTextEdit(editInfo) {
1015 return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(0, 0), `/* eslint-disable ${editInfo.ruleId} */\n`);
1017 function getLastEdit(array) {
1018 let length = array.length;
1022 return array[length - 1];
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));
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));
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));
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);
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);
1063 if (result.length > 0) {
1064 let sameProblems = new Map(allFixableRuleIds.map(s => [s, []]));
1066 for (let editInfo of fixes.getAllSorted()) {
1067 if (documentVersion === -1) {
1068 documentVersion = editInfo.documentVersion;
1070 if (sameProblems.has(editInfo.ruleId)) {
1071 let same = sameProblems.get(editInfo.ruleId);
1072 if (!Fixes.overlaps(getLastEdit(same), editInfo)) {
1073 same.push(editInfo);
1076 if (!Fixes.overlaps(getLastEdit(all), editInfo)) {
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);
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);
1101 return result.all();
1104 let document = documents.get(params.textDocument.uri);
1105 return document ? document.version : undefined;
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:')) {
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));
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}`);
1128 else if (params.command === CommandIds.openRuleDoc) {
1129 let ruleId = params.arguments[0];
1130 let url = ruleDocData.urls.get(ruleId);
1132 connection.sendRequest(OpenESLintDocRequest.type, { url });
1136 workspaceChange = commands.get(params.command);
1139 if (!workspaceChange) {
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}`);
1149 connection.console.error(`Failed to apply command: ${params.command}`);
1153 if (params.command === CommandIds.applyAutoFix) {
1154 let identifier = params.arguments[0];
1155 return identifier.version;
1161 connection.tracer.connection.listen();
1162 //# sourceMappingURL=index.js.map
1166 /***/ (function(module, __webpack_exports__, __webpack_require__) {
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
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
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
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
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
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
1222 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
\r
1226 return __assign.apply(this, arguments);
\r
1229 function __rest(s, e) {
\r
1231 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
\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
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
1246 function __param(paramIndex, decorator) {
\r
1247 return function (target, key) { decorator(target, key, paramIndex); }
\r
1250 function __metadata(metadataKey, metadataValue) {
\r
1251 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
\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
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
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
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
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
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
1291 function __exportStar(m, exports) {
\r
1292 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\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
1299 next: function () {
\r
1300 if (o && i >= o.length) o = void 0;
\r
1301 return { value: o && o[i++], done: !o };
\r
1306 function __read(o, n) {
\r
1307 var m = typeof Symbol === "function" && o[Symbol.iterator];
\r
1309 var i = m.call(o), r, ar = [], e;
\r
1311 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
\r
1313 catch (error) { e = { error: error }; }
\r
1316 if (r && !r.done && (m = i["return"])) m.call(i);
\r
1318 finally { if (e) throw e.error; }
\r
1323 function __spread() {
\r
1324 for (var ar = [], i = 0; i < arguments.length; i++)
\r
1325 ar = ar.concat(__read(arguments[i]));
\r
1329 function __await(v) {
\r
1330 return this instanceof __await ? (this.v = v, this) : new __await(v);
\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
1345 function __asyncDelegator(o) {
\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
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
1359 function __makeTemplateObject(cooked, raw) {
\r
1360 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
\r
1364 function __importStar(mod) {
\r
1365 if (mod && mod.__esModule) return mod;
\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
1372 function __importDefault(mod) {
\r
1373 return (mod && mod.__esModule) ? mod : { default: mod };
\r
1379 /***/ (function(module, exports) {
1381 module.exports = require("os");
1385 /***/ (function(module, exports) {
1387 module.exports = require("path");
1391 /***/ (function(module, exports, __webpack_require__) {
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
1400 function __export(m) {
\r
1401 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\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
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
1429 let processId = parseInt(value);
\r
1430 if (!isNaN(processId)) {
\r
1431 exitTimer = setInterval(() => {
\r
1433 process.kill(processId, 0);
\r
1436 // Parent process doesn't exist anymore. Exit the server.
\r
1437 process.exit(shutdownReceived ? 0 : 1);
\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
1453 let args = arg.split('=');
\r
1454 if (args[0] === argName) {
\r
1455 runTimer(args[1]);
\r
1461 function null2Undefined(value) {
\r
1462 if (value === null) {
\r
1468 * A manager for simple text documents
\r
1470 class TextDocuments {
\r
1472 * Create a new text document manager.
\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
1483 * Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by
\r
1484 * this text document manager.
\r
1487 return vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
\r
1490 * An event that fires when a text document managed by this manager
\r
1491 * has been opened or the content changes.
\r
1493 get onDidChangeContent() {
\r
1494 return this._onDidChangeContent.event;
\r
1497 * An event that fires when a text document managed by this manager
\r
1498 * has been opened.
\r
1501 return this._onDidOpen.event;
\r
1504 * An event that fires when a text document managed by this manager
\r
1507 get onWillSave() {
\r
1508 return this._onWillSave.event;
\r
1511 * Sets a handler that will be called if a participant wants to provide
\r
1512 * edits during a text document save.
\r
1514 onWillSaveWaitUntil(handler) {
\r
1515 this._willSaveWaitUntil = handler;
\r
1518 * An event that fires when a text document managed by this manager
\r
1522 return this._onDidSave.event;
\r
1525 * An event that fires when a text document managed by this manager
\r
1526 * has been closed.
\r
1528 get onDidClose() {
\r
1529 return this._onDidClose.event;
\r
1532 * Returns the document for the given URI. Returns undefined if
\r
1533 * the document is not mananged by this instance.
\r
1535 * @param uri The text document's URI to retrieve.
\r
1536 * @return the text document or `undefined`.
\r
1539 return this._documents[uri];
\r
1542 * Returns all text documents managed by this instance.
\r
1544 * @return all text documents.
\r
1547 return Object.keys(this._documents).map(key => this._documents[key]);
\r
1550 * Returns the URIs of all text documents managed by this instance.
\r
1552 * @return the URI's of all text documents.
\r
1555 return Object.keys(this._documents);
\r
1558 * Listens for `low level` notification on the given connection to
\r
1559 * update the text documents managed by this instance.
\r
1561 * @param connection The connection to listen on.
\r
1563 listen(connection) {
\r
1564 function isUpdateableDocument(value) {
\r
1565 return Is.func(value.update);
\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
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
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
1586 document.update(last, td.version);
\r
1587 this._onDidChangeContent.fire(Object.freeze({ document }));
\r
1591 connection.onDidCloseTextDocument((event) => {
\r
1592 let document = this._documents[event.textDocument.uri];
\r
1594 delete this._documents[event.textDocument.uri];
\r
1595 this._onDidClose.fire(Object.freeze({ document }));
\r
1598 connection.onWillSaveTextDocument((event) => {
\r
1599 let document = this._documents[event.textDocument.uri];
\r
1601 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
\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
1613 connection.onDidSaveTextDocument((event) => {
\r
1614 let document = this._documents[event.textDocument.uri];
\r
1616 this._onDidSave.fire(Object.freeze({ document }));
\r
1621 exports.TextDocuments = TextDocuments;
\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
1628 class ErrorMessageTracker {
\r
1630 this._messages = Object.create(null);
\r
1633 * Add a message to the tracker.
\r
1635 * @param message The message to add.
\r
1638 let count = this._messages[message];
\r
1643 this._messages[message] = count;
\r
1646 * Send all tracked messages to the connection's window.
\r
1648 * @param connection The connection established between client and server.
\r
1650 sendErrors(connection) {
\r
1651 Object.keys(this._messages).forEach(message => {
\r
1652 connection.window.showErrorMessage(message);
\r
1656 exports.ErrorMessageTracker = ErrorMessageTracker;
\r
1657 var BulkRegistration;
\r
1658 (function (BulkRegistration) {
\r
1660 * Creates a new bulk registration.
\r
1661 * @return an empty bulk registration.
\r
1663 function create() {
\r
1664 return new BulkRegistrationImpl();
\r
1666 BulkRegistration.create = create;
\r
1667 })(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
\r
1668 class BulkRegistrationImpl {
\r
1670 this._registrations = [];
\r
1671 this._registered = new Set();
\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
1678 const id = UUID.generateUuid();
\r
1679 this._registrations.push({
\r
1682 registerOptions: registerOptions || {}
\r
1684 this._registered.add(method);
\r
1686 asRegistrationParams() {
\r
1688 registrations: this._registrations
\r
1692 var BulkUnregistration;
\r
1693 (function (BulkUnregistration) {
\r
1694 function create() {
\r
1695 return new BulkUnregistrationImpl(undefined, []);
\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
1707 get isAttached() {
\r
1708 return !!this._connection;
\r
1710 attach(connection) {
\r
1711 this._connection = connection;
\r
1713 add(unregistration) {
\r
1714 this._unregistrations.set(unregistration.method, unregistration);
\r
1717 let unregistrations = [];
\r
1718 for (let unregistration of this._unregistrations.values()) {
\r
1719 unregistrations.push(unregistration);
\r
1722 unregisterations: unregistrations
\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
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
1735 unregisterations: [unregistration]
\r
1737 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
\r
1738 this._unregistrations.delete(method);
\r
1740 this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);
\r
1745 class ConnectionLogger {
\r
1748 rawAttach(connection) {
\r
1749 this._rawConnection = connection;
\r
1751 attach(connection) {
\r
1752 this._connection = connection;
\r
1754 get connection() {
\r
1755 if (!this._connection) {
\r
1756 throw new Error('Remote is not attached to a connection yet.');
\r
1758 return this._connection;
\r
1760 fillServerCapabilities(_capabilities) {
\r
1762 initialize(_capabilities) {
\r
1765 this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
\r
1768 this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
\r
1771 this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
\r
1774 this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
\r
1776 send(type, message) {
\r
1777 if (this._rawConnection) {
\r
1778 this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
\r
1782 class RemoteWindowImpl {
\r
1785 attach(connection) {
\r
1786 this._connection = connection;
\r
1788 get connection() {
\r
1789 if (!this._connection) {
\r
1790 throw new Error('Remote is not attached to a connection yet.');
\r
1792 return this._connection;
\r
1794 initialize(_capabilities) {
\r
1796 fillServerCapabilities(_capabilities) {
\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
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
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
1811 class RemoteClientImpl {
\r
1812 attach(connection) {
\r
1813 this._connection = connection;
\r
1815 get connection() {
\r
1816 if (!this._connection) {
\r
1817 throw new Error('Remote is not attached to a connection yet.');
\r
1819 return this._connection;
\r
1821 initialize(_capabilities) {
\r
1823 fillServerCapabilities(_capabilities) {
\r
1825 register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
\r
1826 if (typeOrRegistrations instanceof BulkRegistrationImpl) {
\r
1827 return this.registerMany(typeOrRegistrations);
\r
1829 else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
\r
1830 return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
\r
1833 return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
\r
1836 registerSingle1(unregistration, type, registerOptions) {
\r
1837 const method = Is.string(type) ? type : type.method;
\r
1838 const id = UUID.generateUuid();
\r
1840 registrations: [{ id, method, registerOptions: registerOptions || {} }]
\r
1842 if (!unregistration.isAttached) {
\r
1843 unregistration.attach(this._connection);
\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
1849 this.connection.console.info(`Registering request handler for ${method} failed.`);
\r
1850 return Promise.reject(_error);
\r
1853 registerSingle2(type, registerOptions) {
\r
1854 const method = Is.string(type) ? type : type.method;
\r
1855 const id = UUID.generateUuid();
\r
1857 registrations: [{ id, method, registerOptions: registerOptions || {} }]
\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
1864 this.connection.console.info(`Registering request handler for ${method} failed.`);
\r
1865 return Promise.reject(_error);
\r
1868 unregisterSingle(id, method) {
\r
1870 unregisterations: [{ id, method }]
\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
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
1881 this.connection.console.info(`Bulk registration failed.`);
\r
1882 return Promise.reject(_error);
\r
1886 class _RemoteWorkspaceImpl {
\r
1889 attach(connection) {
\r
1890 this._connection = connection;
\r
1892 get connection() {
\r
1893 if (!this._connection) {
\r
1894 throw new Error('Remote is not attached to a connection yet.');
\r
1896 return this._connection;
\r
1898 initialize(_capabilities) {
\r
1900 fillServerCapabilities(_capabilities) {
\r
1902 applyEdit(paramOrEdit) {
\r
1903 function isApplyWorkspaceEditParams(value) {
\r
1904 return value && !!value.edit;
\r
1906 let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
\r
1907 return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
\r
1910 const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));
\r
1911 class TracerImpl {
\r
1913 this._trace = vscode_languageserver_protocol_1.Trace.Off;
\r
1915 attach(connection) {
\r
1916 this._connection = connection;
\r
1918 get connection() {
\r
1919 if (!this._connection) {
\r
1920 throw new Error('Remote is not attached to a connection yet.');
\r
1922 return this._connection;
\r
1924 initialize(_capabilities) {
\r
1926 fillServerCapabilities(_capabilities) {
\r
1928 set trace(value) {
\r
1929 this._trace = value;
\r
1931 log(message, verbose) {
\r
1932 if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
\r
1935 this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
\r
1937 verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
\r
1941 class TelemetryImpl {
\r
1944 attach(connection) {
\r
1945 this._connection = connection;
\r
1947 get connection() {
\r
1948 if (!this._connection) {
\r
1949 throw new Error('Remote is not attached to a connection yet.');
\r
1951 return this._connection;
\r
1953 initialize(_capabilities) {
\r
1955 fillServerCapabilities(_capabilities) {
\r
1958 this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
\r
1961 function combineConsoleFeatures(one, two) {
\r
1962 return function (Base) {
\r
1963 return two(one(Base));
\r
1966 exports.combineConsoleFeatures = combineConsoleFeatures;
\r
1967 function combineTelemetryFeatures(one, two) {
\r
1968 return function (Base) {
\r
1969 return two(one(Base));
\r
1972 exports.combineTelemetryFeatures = combineTelemetryFeatures;
\r
1973 function combineTracerFeatures(one, two) {
\r
1974 return function (Base) {
\r
1975 return two(one(Base));
\r
1978 exports.combineTracerFeatures = combineTracerFeatures;
\r
1979 function combineClientFeatures(one, two) {
\r
1980 return function (Base) {
\r
1981 return two(one(Base));
\r
1984 exports.combineClientFeatures = combineClientFeatures;
\r
1985 function combineWindowFeatures(one, two) {
\r
1986 return function (Base) {
\r
1987 return two(one(Base));
\r
1990 exports.combineWindowFeatures = combineWindowFeatures;
\r
1991 function combineWorkspaceFeatures(one, two) {
\r
1992 return function (Base) {
\r
1993 return two(one(Base));
\r
1996 exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
\r
1997 function combineFeatures(one, two) {
\r
1998 function combine(one, two, func) {
\r
2000 return func(one, two);
\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
2020 exports.combineFeatures = combineFeatures;
\r
2021 function createConnection(arg1, arg2, arg3, arg4) {
\r
2026 if (arg1 !== void 0 && arg1.__brand === 'features') {
\r
2032 if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {
\r
2040 return _createConnection(input, output, strategy, factories);
\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
2055 else if (arg === '--stdio') {
\r
2056 input = process.stdin;
\r
2057 output = process.stdout;
\r
2060 else if (arg === '--socket') {
\r
2061 port = parseInt(argv[i + 1]);
\r
2064 else if (arg === '--pipe') {
\r
2065 pipeName = argv[i + 1];
\r
2069 var args = arg.split('=');
\r
2070 if (args[0] === '--socket') {
\r
2071 port = parseInt(args[1]);
\r
2074 else if (args[0] === '--pipe') {
\r
2075 pipeName = args[1];
\r
2081 let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);
\r
2082 input = transport[0];
\r
2083 output = transport[1];
\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
2091 var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";
\r
2093 throw new Error("Connection input stream is not set. " + commandLineMessage);
\r
2096 throw new Error("Connection output stream is not set. " + commandLineMessage);
\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
2104 inputStream.on('close', () => {
\r
2105 process.exit(shutdownReceived ? 0 : 1);
\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
2122 return Promise.resolve(value);
\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
2138 connection.sendNotification(method, param);
\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
2190 for (let remote of allRemotes) {
\r
2191 remote.attach(protocolConnection);
\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
2200 process.kill(processId, 0);
\r
2203 // Parent process doesn't exist anymore. Exit the server.
\r
2204 process.exit(shutdownReceived ? 0 : 1);
\r
2208 if (Is.string(params.trace)) {
\r
2209 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
\r
2211 for (let remote of allRemotes) {
\r
2212 remote.initialize(params.capabilities);
\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
2220 let result = value;
\r
2222 result = { capabilities: {} };
\r
2224 let capabilities = result.capabilities;
\r
2225 if (!capabilities) {
\r
2226 capabilities = {};
\r
2227 result.capabilities = capabilities;
\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
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
2235 for (let remote of allRemotes) {
\r
2236 remote.fillServerCapabilities(capabilities);
\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
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
2258 connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
\r
2260 if (exitHandler) {
\r
2265 if (shutdownReceived) {
\r
2273 connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
\r
2274 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
\r
2276 return protocolConnection;
\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
2284 })(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
\r
2289 /***/ (function(module, exports, __webpack_require__) {
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
2297 function __export(m) {
\r
2298 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\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
2334 exports.createProtocolConnection = createProtocolConnection;
\r
2339 /***/ (function(module, exports, __webpack_require__) {
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
2348 function __export(m) {
\r
2349 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\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
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
2421 return Trace.Messages;
\r
2423 return Trace.Verbose;
\r
2428 Trace.fromString = fromString;
\r
2429 function toString(value) {
\r
2433 case Trace.Messages:
\r
2434 return 'messages';
\r
2435 case Trace.Verbose:
\r
2441 Trace.toString = toString;
\r
2442 })(Trace = exports.Trace || (exports.Trace = {}));
\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
2455 return TraceFormat.Text;
\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
2471 * The connection is closed.
\r
2473 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
2475 * The connection got disposed.
\r
2477 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
2479 * The connection is already in listening mode.
\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
2487 Object.setPrototypeOf(this, ConnectionError.prototype);
\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
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
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
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
2530 function createResponseQueueKey(id) {
\r
2531 if (id === null) {
\r
2532 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
2535 return 'res-' + id.toString();
\r
2538 function createNotificationQueueKey() {
\r
2539 return 'not-' + (++notificationSquenceNumber).toString();
\r
2541 function addMessageToQueue(queue, message) {
\r
2542 if (messages_1.isRequestMessage(message)) {
\r
2543 queue.set(createRequestQueueKey(message.id), message);
\r
2545 else if (messages_1.isResponseMessage(message)) {
\r
2546 queue.set(createResponseQueueKey(message.id), message);
\r
2549 queue.set(createNotificationQueueKey(), message);
\r
2552 function cancelUndispatched(_message) {
\r
2555 function isListening() {
\r
2556 return state === ConnectionState.Listening;
\r
2558 function isClosed() {
\r
2559 return state === ConnectionState.Closed;
\r
2561 function isDisposed() {
\r
2562 return state === ConnectionState.Disposed;
\r
2564 function closeHandler() {
\r
2565 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
2566 state = ConnectionState.Closed;
\r
2567 closeEmitter.fire(undefined);
\r
2569 // If the connection is disposed don't sent close events.
\r
2572 function readErrorHandler(error) {
\r
2573 errorEmitter.fire([error, undefined, undefined]);
\r
2575 function writeErrorHandler(data) {
\r
2576 errorEmitter.fire(data);
\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
2586 timer = setImmediate(() => {
\r
2587 timer = undefined;
\r
2588 processMessageQueue();
\r
2591 function processMessageQueue() {
\r
2592 if (messageQueue.size === 0) {
\r
2595 let message = messageQueue.shift();
\r
2597 if (messages_1.isRequestMessage(message)) {
\r
2598 handleRequest(message);
\r
2600 else if (messages_1.isNotificationMessage(message)) {
\r
2601 handleNotification(message);
\r
2603 else if (messages_1.isResponseMessage(message)) {
\r
2604 handleResponse(message);
\r
2607 handleInvalidMessage(message);
\r
2611 triggerMessageQueue();
\r
2614 let callback = (message) => {
\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
2632 addMessageToQueue(messageQueue, message);
\r
2635 triggerMessageQueue();
\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
2644 function reply(resultOrError, method, startTime) {
\r
2647 id: requestMessage.id
\r
2649 if (resultOrError instanceof messages_1.ResponseError) {
\r
2650 message.error = resultOrError.toJson();
\r
2653 message.result = resultOrError === void 0 ? null : resultOrError;
\r
2655 traceSendingResponse(message, method, startTime);
\r
2656 messageWriter.write(message);
\r
2658 function replyError(error, method, startTime) {
\r
2661 id: requestMessage.id,
\r
2662 error: error.toJson()
\r
2664 traceSendingResponse(message, method, startTime);
\r
2665 messageWriter.write(message);
\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
2675 id: requestMessage.id,
\r
2678 traceSendingResponse(message, method, startTime);
\r
2679 messageWriter.write(message);
\r
2681 traceReceivedRequest(requestMessage);
\r
2682 let element = requestHandlers[requestMessage.method];
\r
2684 let requestHandler;
\r
2686 type = element.type;
\r
2687 requestHandler = element.handler;
\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
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
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
2707 handlerResult = requestHandler
\r
2708 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
2709 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
2711 let promise = handlerResult;
\r
2712 if (!handlerResult) {
\r
2713 delete requestTokens[tokenKey];
\r
2714 replySuccess(handlerResult, requestMessage.method, startTime);
\r
2716 else if (promise.then) {
\r
2717 promise.then((resultOrError) => {
\r
2718 delete requestTokens[tokenKey];
\r
2719 reply(resultOrError, requestMessage.method, startTime);
\r
2721 delete requestTokens[tokenKey];
\r
2722 if (error instanceof messages_1.ResponseError) {
\r
2723 replyError(error, requestMessage.method, startTime);
\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
2729 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
2734 delete requestTokens[tokenKey];
\r
2735 reply(handlerResult, requestMessage.method, startTime);
\r
2739 delete requestTokens[tokenKey];
\r
2740 if (error instanceof messages_1.ResponseError) {
\r
2741 reply(error, requestMessage.method, startTime);
\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
2747 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
2752 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
2755 function handleResponse(responseMessage) {
\r
2756 if (isDisposed()) {
\r
2757 // See handle request.
\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
2765 logger.error(`Received response message without id. No further error information provided.`);
\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
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
2779 else if (responseMessage.result !== void 0) {
\r
2780 responsePromise.resolve(responseMessage.result);
\r
2783 throw new Error('Should never happen.');
\r
2787 if (error.message) {
\r
2788 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
2791 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
2797 function handleNotification(message) {
\r
2798 if (isDisposed()) {
\r
2799 // See handle request.
\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
2814 let element = notificationHandlers[message.method];
\r
2816 notificationHandler = element.handler;
\r
2817 type = element.type;
\r
2820 if (notificationHandler || starNotificationHandler) {
\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
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
2830 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
2834 if (error.message) {
\r
2835 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
2838 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
2843 unhandledNotificationEmitter.fire(message);
\r
2846 function handleInvalidMessage(message) {
\r
2848 logger.error('Received empty message.');
\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
2862 function traceSendingRequest(message) {
\r
2863 if (trace === Trace.Off || !tracer) {
\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
2871 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
2874 logLSPMessage('send-request', message);
\r
2877 function traceSendingNotification(message) {
\r
2878 if (trace === Trace.Off || !tracer) {
\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
2888 data = 'No parameters provided.\n\n';
\r
2891 tracer.log(`Sending notification '${message.method}'.`, data);
\r
2894 logLSPMessage('send-notification', message);
\r
2897 function traceSendingResponse(message, method, startTime) {
\r
2898 if (trace === Trace.Off || !tracer) {
\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
2908 if (message.result) {
\r
2909 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
2911 else if (message.error === void 0) {
\r
2912 data = 'No result returned.\n\n';
\r
2916 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
2919 logLSPMessage('send-response', message);
\r
2922 function traceReceivedRequest(message) {
\r
2923 if (trace === Trace.Off || !tracer) {
\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
2931 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
2934 logLSPMessage('receive-request', message);
\r
2937 function traceReceivedNotification(message) {
\r
2938 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\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
2948 data = 'No parameters provided.\n\n';
\r
2951 tracer.log(`Received notification '${message.method}'.`, data);
\r
2954 logLSPMessage('receive-notification', message);
\r
2957 function traceReceivedResponse(message, responsePromise) {
\r
2958 if (trace === Trace.Off || !tracer) {
\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
2968 if (message.result) {
\r
2969 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
2971 else if (message.error === void 0) {
\r
2972 data = 'No result returned.\n\n';
\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
2981 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
2985 logLSPMessage('receive-response', message);
\r
2988 function logLSPMessage(type, message) {
\r
2989 if (!tracer || trace === Trace.Off) {
\r
2992 const lspMessage = {
\r
2993 isLSPMessage: true,
\r
2996 timestamp: Date.now()
\r
2998 tracer.log(lspMessage);
\r
3000 function throwIfClosedOrDisposed() {
\r
3002 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
3004 if (isDisposed()) {
\r
3005 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
3008 function throwIfListening() {
\r
3009 if (isListening()) {
\r
3010 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
3013 function throwIfNotListening() {
\r
3014 if (!isListening()) {
\r
3015 throw new Error('Call listen() first.');
\r
3018 function undefinedToNull(param) {
\r
3019 if (param === void 0) {
\r
3026 function computeMessageParams(type, params) {
\r
3028 let numberOfParams = type.numberOfParams;
\r
3029 switch (numberOfParams) {
\r
3034 result = undefinedToNull(params[0]);
\r
3038 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
3039 result.push(undefinedToNull(params[i]));
\r
3041 if (params.length < numberOfParams) {
\r
3042 for (let i = params.length; i < numberOfParams; i++) {
\r
3043 result.push(null);
\r
3050 let connection = {
\r
3051 sendNotification: (type, ...params) => {
\r
3052 throwIfClosedOrDisposed();
\r
3054 let messageParams;
\r
3055 if (Is.string(type)) {
\r
3057 switch (params.length) {
\r
3059 messageParams = null;
\r
3062 messageParams = params[0];
\r
3065 messageParams = params;
\r
3070 method = type.method;
\r
3071 messageParams = computeMessageParams(type, params);
\r
3073 let notificationMessage = {
\r
3076 params: messageParams
\r
3078 traceSendingNotification(notificationMessage);
\r
3079 messageWriter.write(notificationMessage);
\r
3081 onNotification: (type, handler) => {
\r
3082 throwIfClosedOrDisposed();
\r
3083 if (Is.func(type)) {
\r
3084 starNotificationHandler = type;
\r
3086 else if (handler) {
\r
3087 if (Is.string(type)) {
\r
3088 notificationHandlers[type] = { type: undefined, handler };
\r
3091 notificationHandlers[type.method] = { type, handler };
\r
3095 sendRequest: (type, ...params) => {
\r
3096 throwIfClosedOrDisposed();
\r
3097 throwIfNotListening();
\r
3099 let messageParams;
\r
3100 let token = undefined;
\r
3101 if (Is.string(type)) {
\r
3103 switch (params.length) {
\r
3105 messageParams = null;
\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
3114 messageParams = undefinedToNull(params[0]);
\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
3125 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
3129 messageParams = params.map(value => undefinedToNull(value));
\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
3140 let id = sequenceNumber++;
\r
3141 let result = new Promise((resolve, reject) => {
\r
3142 let requestMessage = {
\r
3146 params: messageParams
\r
3148 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
3149 traceSendingRequest(requestMessage);
\r
3151 messageWriter.write(requestMessage);
\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
3158 if (responsePromise) {
\r
3159 responsePromises[String(id)] = responsePromise;
\r
3163 token.onCancellationRequested(() => {
\r
3164 connection.sendNotification(CancelNotification.type, { id });
\r
3169 onRequest: (type, handler) => {
\r
3170 throwIfClosedOrDisposed();
\r
3171 if (Is.func(type)) {
\r
3172 starRequestHandler = type;
\r
3174 else if (handler) {
\r
3175 if (Is.string(type)) {
\r
3176 requestHandlers[type] = { type: undefined, handler };
\r
3179 requestHandlers[type.method] = { type, handler };
\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
3191 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
3192 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
3196 traceFormat = _traceFormat;
\r
3197 if (trace === Trace.Off) {
\r
3198 tracer = undefined;
\r
3203 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
3204 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
3207 onError: errorEmitter.event,
\r
3208 onClose: closeEmitter.event,
\r
3209 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
3210 onDispose: disposeEmitter.event,
\r
3212 if (isDisposed()) {
\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
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
3228 if (Is.func(messageReader.dispose)) {
\r
3229 messageReader.dispose();
\r
3233 throwIfClosedOrDisposed();
\r
3234 throwIfListening();
\r
3235 state = ConnectionState.Listening;
\r
3236 messageReader.listen(callback);
\r
3239 console.log("inspect");
\r
3242 connection.onNotification(LogTraceNotification.type, (params) => {
\r
3243 if (trace === Trace.Off || !tracer) {
\r
3246 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
3248 return connection;
\r
3250 function isMessageReader(value) {
\r
3251 return value.listen !== void 0 && value.read === void 0;
\r
3253 function isMessageWriter(value) {
\r
3254 return value.write !== void 0 && value.end === void 0;
\r
3256 function createMessageConnection(input, output, logger, strategy) {
\r
3258 logger = exports.NullLogger;
\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
3264 exports.createMessageConnection = createMessageConnection;
\r
3269 /***/ (function(module, exports, __webpack_require__) {
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
3277 Object.defineProperty(exports, "__esModule", { value: true });
\r
3278 function boolean(value) {
\r
3279 return value === true || value === false;
\r
3281 exports.boolean = boolean;
\r
3282 function string(value) {
\r
3283 return typeof value === 'string' || value instanceof String;
\r
3285 exports.string = string;
\r
3286 function number(value) {
\r
3287 return typeof value === 'number' || value instanceof Number;
\r
3289 exports.number = number;
\r
3290 function error(value) {
\r
3291 return value instanceof Error;
\r
3293 exports.error = error;
\r
3294 function func(value) {
\r
3295 return typeof value === 'function';
\r
3297 exports.func = func;
\r
3298 function array(value) {
\r
3299 return Array.isArray(value);
\r
3301 exports.array = array;
\r
3302 function stringArray(value) {
\r
3303 return array(value) && value.every(elem => string(elem));
\r
3305 exports.stringArray = stringArray;
\r
3310 /***/ (function(module, exports, __webpack_require__) {
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
3318 Object.defineProperty(exports, "__esModule", { value: true });
\r
3319 const is = __webpack_require__(7);
\r
3321 * Predefined error codes.
\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
3342 * An error object return in a response in case a request
\r
3345 class ResponseError extends Error {
\r
3346 constructor(code, message, data) {
\r
3348 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
3350 Object.setPrototypeOf(this, ResponseError.prototype);
\r
3355 message: this.message,
\r
3360 exports.ResponseError = ResponseError;
\r
3362 * An abstract implementation of a MessageType.
\r
3364 class AbstractMessageType {
\r
3365 constructor(_method, _numberOfParams) {
\r
3366 this._method = _method;
\r
3367 this._numberOfParams = _numberOfParams;
\r
3370 return this._method;
\r
3372 get numberOfParams() {
\r
3373 return this._numberOfParams;
\r
3376 exports.AbstractMessageType = AbstractMessageType;
\r
3378 * Classes to type request response pairs
\r
3380 class RequestType0 extends AbstractMessageType {
\r
3381 constructor(method) {
\r
3383 this._ = undefined;
\r
3386 exports.RequestType0 = RequestType0;
\r
3387 class RequestType extends AbstractMessageType {
\r
3388 constructor(method) {
\r
3390 this._ = undefined;
\r
3393 exports.RequestType = RequestType;
\r
3394 class RequestType1 extends AbstractMessageType {
\r
3395 constructor(method) {
\r
3397 this._ = undefined;
\r
3400 exports.RequestType1 = RequestType1;
\r
3401 class RequestType2 extends AbstractMessageType {
\r
3402 constructor(method) {
\r
3404 this._ = undefined;
\r
3407 exports.RequestType2 = RequestType2;
\r
3408 class RequestType3 extends AbstractMessageType {
\r
3409 constructor(method) {
\r
3411 this._ = undefined;
\r
3414 exports.RequestType3 = RequestType3;
\r
3415 class RequestType4 extends AbstractMessageType {
\r
3416 constructor(method) {
\r
3418 this._ = undefined;
\r
3421 exports.RequestType4 = RequestType4;
\r
3422 class RequestType5 extends AbstractMessageType {
\r
3423 constructor(method) {
\r
3425 this._ = undefined;
\r
3428 exports.RequestType5 = RequestType5;
\r
3429 class RequestType6 extends AbstractMessageType {
\r
3430 constructor(method) {
\r
3432 this._ = undefined;
\r
3435 exports.RequestType6 = RequestType6;
\r
3436 class RequestType7 extends AbstractMessageType {
\r
3437 constructor(method) {
\r
3439 this._ = undefined;
\r
3442 exports.RequestType7 = RequestType7;
\r
3443 class RequestType8 extends AbstractMessageType {
\r
3444 constructor(method) {
\r
3446 this._ = undefined;
\r
3449 exports.RequestType8 = RequestType8;
\r
3450 class RequestType9 extends AbstractMessageType {
\r
3451 constructor(method) {
\r
3453 this._ = undefined;
\r
3456 exports.RequestType9 = RequestType9;
\r
3457 class NotificationType extends AbstractMessageType {
\r
3458 constructor(method) {
\r
3460 this._ = undefined;
\r
3463 exports.NotificationType = NotificationType;
\r
3464 class NotificationType0 extends AbstractMessageType {
\r
3465 constructor(method) {
\r
3467 this._ = undefined;
\r
3470 exports.NotificationType0 = NotificationType0;
\r
3471 class NotificationType1 extends AbstractMessageType {
\r
3472 constructor(method) {
\r
3474 this._ = undefined;
\r
3477 exports.NotificationType1 = NotificationType1;
\r
3478 class NotificationType2 extends AbstractMessageType {
\r
3479 constructor(method) {
\r
3481 this._ = undefined;
\r
3484 exports.NotificationType2 = NotificationType2;
\r
3485 class NotificationType3 extends AbstractMessageType {
\r
3486 constructor(method) {
\r
3488 this._ = undefined;
\r
3491 exports.NotificationType3 = NotificationType3;
\r
3492 class NotificationType4 extends AbstractMessageType {
\r
3493 constructor(method) {
\r
3495 this._ = undefined;
\r
3498 exports.NotificationType4 = NotificationType4;
\r
3499 class NotificationType5 extends AbstractMessageType {
\r
3500 constructor(method) {
\r
3502 this._ = undefined;
\r
3505 exports.NotificationType5 = NotificationType5;
\r
3506 class NotificationType6 extends AbstractMessageType {
\r
3507 constructor(method) {
\r
3509 this._ = undefined;
\r
3512 exports.NotificationType6 = NotificationType6;
\r
3513 class NotificationType7 extends AbstractMessageType {
\r
3514 constructor(method) {
\r
3516 this._ = undefined;
\r
3519 exports.NotificationType7 = NotificationType7;
\r
3520 class NotificationType8 extends AbstractMessageType {
\r
3521 constructor(method) {
\r
3523 this._ = undefined;
\r
3526 exports.NotificationType8 = NotificationType8;
\r
3527 class NotificationType9 extends AbstractMessageType {
\r
3528 constructor(method) {
\r
3530 this._ = undefined;
\r
3533 exports.NotificationType9 = NotificationType9;
\r
3535 * Tests if the given message is a request message
\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
3541 exports.isRequestMessage = isRequestMessage;
\r
3543 * Tests if the given message is a notification message
\r
3545 function isNotificationMessage(message) {
\r
3546 let candidate = message;
\r
3547 return candidate && is.string(candidate.method) && message.id === void 0;
\r
3549 exports.isNotificationMessage = isNotificationMessage;
\r
3551 * Tests if the given message is a response message
\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
3557 exports.isResponseMessage = isResponseMessage;
\r
3562 /***/ (function(module, exports, __webpack_require__) {
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
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
3581 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
3584 var toAppend = chunk;
\r
3585 if (typeof (chunk) === 'string') {
\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
3591 if (this.buffer.length - this.index >= toAppend.length) {
\r
3592 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\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
3601 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
3604 this.index += toAppend.length;
\r
3606 tryReadHeaders() {
\r
3607 let result = undefined;
\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
3612 // No header / body separator found (e.g CRLFCRLF)
\r
3613 if (current + 3 >= this.index) {
\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
3623 let key = header.substr(0, index);
\r
3624 let value = header.substr(index + 1).trim();
\r
3625 result[key] = value;
\r
3627 let nextStart = current + 4;
\r
3628 this.buffer = this.buffer.slice(nextStart);
\r
3629 this.index = this.index - nextStart;
\r
3632 tryReadContent(length) {
\r
3633 if (this.index < length) {
\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
3642 get numberOfBytes() {
\r
3643 return this.index;
\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
3653 MessageReader.is = is;
\r
3654 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
3655 class AbstractMessageReader {
\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
3662 this.errorEmitter.dispose();
\r
3663 this.closeEmitter.dispose();
\r
3666 return this.errorEmitter.event;
\r
3668 fireError(error) {
\r
3669 this.errorEmitter.fire(this.asError(error));
\r
3672 return this.closeEmitter.event;
\r
3675 this.closeEmitter.fire(undefined);
\r
3677 get onPartialMessage() {
\r
3678 return this.partialMessageEmitter.event;
\r
3680 firePartialMessage(info) {
\r
3681 this.partialMessageEmitter.fire(info);
\r
3684 if (error instanceof Error) {
\r
3688 return new Error(`Reader recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
3692 exports.AbstractMessageReader = AbstractMessageReader;
\r
3693 class StreamMessageReader extends AbstractMessageReader {
\r
3694 constructor(readable, encoding = 'utf8') {
\r
3696 this.readable = readable;
\r
3697 this.buffer = new MessageBuffer(encoding);
\r
3698 this._partialMessageTimeout = 10000;
\r
3700 set partialMessageTimeout(timeout) {
\r
3701 this._partialMessageTimeout = timeout;
\r
3703 get partialMessageTimeout() {
\r
3704 return this._partialMessageTimeout;
\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
3714 this.readable.on('error', (error) => this.fireError(error));
\r
3715 this.readable.on('close', () => this.fireClose());
\r
3718 this.buffer.append(data);
\r
3720 if (this.nextMessageLength === -1) {
\r
3721 let headers = this.buffer.tryReadHeaders();
\r
3725 let contentLength = headers['Content-Length'];
\r
3726 if (!contentLength) {
\r
3727 throw new Error('Header must provide a Content-Length property.');
\r
3729 let length = parseInt(contentLength);
\r
3730 if (isNaN(length)) {
\r
3731 throw new Error('Content-Length value must be a number.');
\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
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
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
3750 clearPartialMessageTimer() {
\r
3751 if (this.partialMessageTimer) {
\r
3752 clearTimeout(this.partialMessageTimer);
\r
3753 this.partialMessageTimer = undefined;
\r
3756 setPartialMessageTimer() {
\r
3757 this.clearPartialMessageTimer();
\r
3758 if (this._partialMessageTimeout <= 0) {
\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
3767 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
3770 exports.StreamMessageReader = StreamMessageReader;
\r
3771 class IPCMessageReader extends AbstractMessageReader {
\r
3772 constructor(process) {
\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
3779 listen(callback) {
\r
3780 this.process.on('message', callback);
\r
3783 exports.IPCMessageReader = IPCMessageReader;
\r
3784 class SocketMessageReader extends StreamMessageReader {
\r
3785 constructor(socket, encoding = 'utf-8') {
\r
3786 super(socket, encoding);
\r
3789 exports.SocketMessageReader = SocketMessageReader;
\r
3794 /***/ (function(module, exports, __webpack_require__) {
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
3802 Object.defineProperty(exports, "__esModule", { value: true });
\r
3804 (function (Disposable) {
\r
3805 function create(func) {
\r
3810 Disposable.create = create;
\r
3811 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\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
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
3829 remove(callback, context = null) {
\r
3830 if (!this._callbacks) {
\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
3843 foundCallbackWithDifferentContext = true;
\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
3852 if (!this._callbacks) {
\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
3858 ret.push(callbacks[i].apply(contexts[i], args));
\r
3867 return !this._callbacks || this._callbacks.length === 0;
\r
3870 this._callbacks = undefined;
\r
3871 this._contexts = undefined;
\r
3875 constructor(_options) {
\r
3876 this._options = _options;
\r
3879 * For the public to allow to subscribe
\r
3880 * to events from this Emitter
\r
3883 if (!this._event) {
\r
3884 this._event = (listener, thisArgs, disposables) => {
\r
3885 if (!this._callbacks) {
\r
3886 this._callbacks = new CallbackList();
\r
3888 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
3889 this._options.onFirstListenerAdd(this);
\r
3891 this._callbacks.add(listener, thisArgs);
\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
3902 if (Array.isArray(disposables)) {
\r
3903 disposables.push(result);
\r
3908 return this._event;
\r
3911 * To be kept private to fire an event to
\r
3915 if (this._callbacks) {
\r
3916 this._callbacks.invoke.call(this._callbacks, event);
\r
3920 if (this._callbacks) {
\r
3921 this._callbacks.dispose();
\r
3922 this._callbacks = undefined;
\r
3926 Emitter._noop = function () { };
\r
3927 exports.Emitter = Emitter;
\r
3932 /***/ (function(module, exports, __webpack_require__) {
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
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
3952 MessageWriter.is = is;
\r
3953 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
3954 class AbstractMessageWriter {
\r
3956 this.errorEmitter = new events_1.Emitter();
\r
3957 this.closeEmitter = new events_1.Emitter();
\r
3960 this.errorEmitter.dispose();
\r
3961 this.closeEmitter.dispose();
\r
3964 return this.errorEmitter.event;
\r
3966 fireError(error, message, count) {
\r
3967 this.errorEmitter.fire([this.asError(error), message, count]);
\r
3970 return this.closeEmitter.event;
\r
3973 this.closeEmitter.fire(undefined);
\r
3976 if (error instanceof Error) {
\r
3980 return new Error(`Writer recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
3984 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
3985 class StreamMessageWriter extends AbstractMessageWriter {
\r
3986 constructor(writable, encoding = 'utf8') {
\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
3995 let json = JSON.stringify(msg);
\r
3996 let contentLength = Buffer.byteLength(json, this.encoding);
\r
3998 ContentLength, contentLength.toString(), CRLF,
\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
4009 this.errorCount++;
\r
4010 this.fireError(error, msg, this.errorCount);
\r
4014 exports.StreamMessageWriter = StreamMessageWriter;
\r
4015 class IPCMessageWriter extends AbstractMessageWriter {
\r
4016 constructor(process) {
\r
4018 this.process = process;
\r
4019 this.errorCount = 0;
\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
4027 if (!this.sending && this.queue.length === 0) {
\r
4028 // See https://github.com/nodejs/node/issues/7657
\r
4029 this.doWriteMessage(msg);
\r
4032 this.queue.push(msg);
\r
4035 doWriteMessage(msg) {
\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
4042 this.errorCount++;
\r
4043 this.fireError(error, msg, this.errorCount);
\r
4046 this.errorCount = 0;
\r
4048 if (this.queue.length > 0) {
\r
4049 this.doWriteMessage(this.queue.shift());
\r
4055 this.errorCount++;
\r
4056 this.fireError(error, msg, this.errorCount);
\r
4060 exports.IPCMessageWriter = IPCMessageWriter;
\r
4061 class SocketMessageWriter extends AbstractMessageWriter {
\r
4062 constructor(socket, encoding = 'utf8') {
\r
4064 this.socket = socket;
\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
4073 if (!this.sending && this.queue.length === 0) {
\r
4074 // See https://github.com/nodejs/node/issues/7657
\r
4075 this.doWriteMessage(msg);
\r
4078 this.queue.push(msg);
\r
4081 doWriteMessage(msg) {
\r
4082 let json = JSON.stringify(msg);
\r
4083 let contentLength = Buffer.byteLength(json, this.encoding);
\r
4085 ContentLength, contentLength.toString(), CRLF,
\r
4089 // Header must be written in ASCII encoding
\r
4090 this.sending = true;
\r
4091 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
4093 this.handleError(error, msg);
\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
4100 this.handleError(error, msg);
\r
4103 this.errorCount = 0;
\r
4105 if (this.queue.length > 0) {
\r
4106 this.doWriteMessage(this.queue.shift());
\r
4111 this.handleError(error, msg);
\r
4116 this.handleError(error, msg);
\r
4119 handleError(error, msg) {
\r
4120 this.errorCount++;
\r
4121 this.fireError(error, msg, this.errorCount);
\r
4124 exports.SocketMessageWriter = SocketMessageWriter;
\r
4129 /***/ (function(module, exports, __webpack_require__) {
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
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
4146 CancellationToken.Cancelled = Object.freeze({
\r
4147 isCancellationRequested: true,
\r
4148 onCancellationRequested: events_1.Event.None
\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
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
4162 class MutableToken {
\r
4164 this._isCancelled = false;
\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
4175 get isCancellationRequested() {
\r
4176 return this._isCancelled;
\r
4178 get onCancellationRequested() {
\r
4179 if (this._isCancelled) {
\r
4180 return shortcutEvent;
\r
4182 if (!this._emitter) {
\r
4183 this._emitter = new events_1.Emitter();
\r
4185 return this._emitter.event;
\r
4188 class CancellationTokenSource {
\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
4195 return this._token;
\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
4205 this._token.cancel();
\r
4212 exports.CancellationTokenSource = CancellationTokenSource;
\r
4217 /***/ (function(module, exports, __webpack_require__) {
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
4227 (function (Touch) {
\r
4231 })(Touch = exports.Touch || (exports.Touch = {}));
\r
4234 this._map = new Map();
\r
4235 this._head = undefined;
\r
4236 this._tail = undefined;
\r
4240 this._map.clear();
\r
4241 this._head = undefined;
\r
4242 this._tail = undefined;
\r
4246 return !this._head && !this._tail;
\r
4249 return this._size;
\r
4252 return this._map.has(key);
\r
4255 const item = this._map.get(key);
\r
4259 return item.value;
\r
4261 set(key, value, touch = Touch.None) {
\r
4262 let item = this._map.get(key);
\r
4264 item.value = value;
\r
4265 if (touch !== Touch.None) {
\r
4266 this.touch(item, touch);
\r
4270 item = { key, value, next: undefined, previous: undefined };
\r
4273 this.addItemLast(item);
\r
4276 this.addItemFirst(item);
\r
4279 this.addItemLast(item);
\r
4282 this.addItemLast(item);
\r
4285 this._map.set(key, item);
\r
4290 const item = this._map.get(key);
\r
4294 this._map.delete(key);
\r
4295 this.removeItem(item);
\r
4300 if (!this._head && !this._tail) {
\r
4303 if (!this._head || !this._tail) {
\r
4304 throw new Error('Invalid list');
\r
4306 const item = this._head;
\r
4307 this._map.delete(item.key);
\r
4308 this.removeItem(item);
\r
4310 return item.value;
\r
4312 forEach(callbackfn, thisArg) {
\r
4313 let current = this._head;
\r
4316 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
4319 callbackfn(current.value, current.key, this);
\r
4321 current = current.next;
\r
4324 forEachReverse(callbackfn, thisArg) {
\r
4325 let current = this._tail;
\r
4328 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
4331 callbackfn(current.value, current.key, this);
\r
4333 current = current.previous;
\r
4338 let current = this._head;
\r
4340 result.push(current.value);
\r
4341 current = current.next;
\r
4347 let current = this._head;
\r
4349 result.push(current.key);
\r
4350 current = current.next;
\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
4361 next():IteratorResult<K> {
\r
4363 let result = { value: current.key, done: false };
\r
4364 current = current.next;
\r
4367 return { value: undefined, done: true };
\r
4374 public values(): IterableIterator<V> {
\r
4375 let current = this._head;
\r
4376 let iterator: IterableIterator<V> = {
\r
4377 [Symbol.iterator]() {
\r
4380 next():IteratorResult<V> {
\r
4382 let result = { value: current.value, done: false };
\r
4383 current = current.next;
\r
4386 return { value: undefined, done: true };
\r
4393 addItemFirst(item) {
\r
4394 // First time Insert
\r
4395 if (!this._head && !this._tail) {
\r
4396 this._tail = item;
\r
4398 else if (!this._head) {
\r
4399 throw new Error('Invalid list');
\r
4402 item.next = this._head;
\r
4403 this._head.previous = item;
\r
4405 this._head = item;
\r
4407 addItemLast(item) {
\r
4408 // First time Insert
\r
4409 if (!this._head && !this._tail) {
\r
4410 this._head = item;
\r
4412 else if (!this._tail) {
\r
4413 throw new Error('Invalid list');
\r
4416 item.previous = this._tail;
\r
4417 this._tail.next = item;
\r
4419 this._tail = item;
\r
4421 removeItem(item) {
\r
4422 if (item === this._head && item === this._tail) {
\r
4423 this._head = undefined;
\r
4424 this._tail = undefined;
\r
4426 else if (item === this._head) {
\r
4427 this._head = item.next;
\r
4429 else if (item === this._tail) {
\r
4430 this._tail = item.previous;
\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
4438 next.previous = previous;
\r
4439 previous.next = next;
\r
4442 touch(item, touch) {
\r
4443 if (!this._head || !this._tail) {
\r
4444 throw new Error('Invalid list');
\r
4446 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
4449 if (touch === Touch.First) {
\r
4450 if (item === this._head) {
\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
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
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
4473 else if (touch === Touch.Last) {
\r
4474 if (item === this._tail) {
\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
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
4491 item.next = undefined;
\r
4492 item.previous = this._tail;
\r
4493 this._tail.next = item;
\r
4494 this._tail = item;
\r
4498 exports.LinkedMap = LinkedMap;
\r
4503 /***/ (function(module, exports, __webpack_require__) {
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
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
4524 // Mac/Unix: use socket file
\r
4525 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\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
4534 return new Promise((resolve, reject) => {
\r
4535 let server = net_1.createServer((socket) => {
\r
4538 new messageReader_1.SocketMessageReader(socket, encoding),
\r
4539 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
4542 server.on('error', reject);
\r
4543 server.listen(pipeName, () => {
\r
4544 server.removeListener('error', reject);
\r
4546 onConnected: () => { return connected; }
\r
4551 exports.createClientPipeTransport = createClientPipeTransport;
\r
4552 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
4553 const socket = net_1.createConnection(pipeName);
\r
4555 new messageReader_1.SocketMessageReader(socket, encoding),
\r
4556 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
4559 exports.createServerPipeTransport = createServerPipeTransport;
\r
4564 /***/ (function(module, exports) {
4566 module.exports = require("crypto");
4570 /***/ (function(module, exports) {
4572 module.exports = require("net");
4576 /***/ (function(module, exports, __webpack_require__) {
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
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
4593 return new Promise((resolve, reject) => {
\r
4594 let server = net_1.createServer((socket) => {
\r
4597 new messageReader_1.SocketMessageReader(socket, encoding),
\r
4598 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
4601 server.on('error', reject);
\r
4602 server.listen(port, '127.0.0.1', () => {
\r
4603 server.removeListener('error', reject);
\r
4605 onConnected: () => { return connected; }
\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
4614 new messageReader_1.SocketMessageReader(socket, encoding),
\r
4615 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
4618 exports.createServerSocketTransport = createServerSocketTransport;
\r
4623 /***/ (function(module, __webpack_exports__, __webpack_require__) {
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
4680 * The Position namespace provides helper functions to work with
\r
4681 * [Position](#Position) literals.
\r
4684 (function (Position) {
\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
4690 function create(line, character) {
\r
4691 return { line: line, character: character };
\r
4693 Position.create = create;
\r
4695 * Checks whether the given liternal conforms to the [Position](#Position) interface.
\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
4702 })(Position || (Position = {}));
\r
4704 * The Range namespace provides helper functions to work with
\r
4705 * [Range](#Range) literals.
\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
4713 else if (Position.is(one) && Position.is(two)) {
\r
4714 return { start: one, end: two };
\r
4717 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
\r
4720 Range.create = create;
\r
4722 * Checks whether the given literal conforms to the [Range](#Range) interface.
\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
4729 })(Range || (Range = {}));
\r
4731 * The Location namespace provides helper functions to work with
\r
4732 * [Location](#Location) literals.
\r
4735 (function (Location) {
\r
4737 * Creates a Location literal.
\r
4738 * @param uri The location's uri.
\r
4739 * @param range The location's range.
\r
4741 function create(uri, range) {
\r
4742 return { uri: uri, range: range };
\r
4744 Location.create = create;
\r
4746 * Checks whether the given literal conforms to the [Location](#Location) interface.
\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
4753 })(Location || (Location = {}));
\r
4755 * The LocationLink namespace provides helper functions to work with
\r
4756 * [LocationLink](#LocationLink) literals.
\r
4759 (function (LocationLink) {
\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
4767 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
\r
4768 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
\r
4770 LocationLink.create = create;
\r
4772 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
\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
4780 LocationLink.is = is;
\r
4781 })(LocationLink || (LocationLink = {}));
\r
4783 * The Color namespace provides helper functions to work with
\r
4784 * [Color](#Color) literals.
\r
4787 (function (Color) {
\r
4789 * Creates a new Color literal.
\r
4791 function create(red, green, blue, alpha) {
\r
4799 Color.create = create;
\r
4801 * Checks whether the given literal conforms to the [Color](#Color) interface.
\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
4811 })(Color || (Color = {}));
\r
4813 * The ColorInformation namespace provides helper functions to work with
\r
4814 * [ColorInformation](#ColorInformation) literals.
\r
4816 var ColorInformation;
\r
4817 (function (ColorInformation) {
\r
4819 * Creates a new ColorInformation literal.
\r
4821 function create(range, color) {
\r
4827 ColorInformation.create = create;
\r
4829 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
4831 function is(value) {
\r
4832 var candidate = value;
\r
4833 return Range.is(candidate.range) && Color.is(candidate.color);
\r
4835 ColorInformation.is = is;
\r
4836 })(ColorInformation || (ColorInformation = {}));
\r
4838 * The Color namespace provides helper functions to work with
\r
4839 * [ColorPresentation](#ColorPresentation) literals.
\r
4841 var ColorPresentation;
\r
4842 (function (ColorPresentation) {
\r
4844 * Creates a new ColorInformation literal.
\r
4846 function create(label, textEdit, additionalTextEdits) {
\r
4849 textEdit: textEdit,
\r
4850 additionalTextEdits: additionalTextEdits,
\r
4853 ColorPresentation.create = create;
\r
4855 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\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
4863 ColorPresentation.is = is;
\r
4864 })(ColorPresentation || (ColorPresentation = {}));
\r
4866 * Enum of known range kinds
\r
4868 var FoldingRangeKind;
\r
4869 (function (FoldingRangeKind) {
\r
4871 * Folding range for a comment
\r
4873 FoldingRangeKind["Comment"] = "comment";
\r
4875 * Folding range for a imports or includes
\r
4877 FoldingRangeKind["Imports"] = "imports";
\r
4879 * Folding range for a region (e.g. `#region`)
\r
4881 FoldingRangeKind["Region"] = "region";
\r
4882 })(FoldingRangeKind || (FoldingRangeKind = {}));
\r
4884 * The folding range namespace provides helper functions to work with
\r
4885 * [FoldingRange](#FoldingRange) literals.
\r
4888 (function (FoldingRange) {
\r
4890 * Creates a new FoldingRange literal.
\r
4892 function create(startLine, endLine, startCharacter, endCharacter, kind) {
\r
4894 startLine: startLine,
\r
4897 if (Is.defined(startCharacter)) {
\r
4898 result.startCharacter = startCharacter;
\r
4900 if (Is.defined(endCharacter)) {
\r
4901 result.endCharacter = endCharacter;
\r
4903 if (Is.defined(kind)) {
\r
4904 result.kind = kind;
\r
4908 FoldingRange.create = create;
\r
4910 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
\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
4919 FoldingRange.is = is;
\r
4920 })(FoldingRange || (FoldingRange = {}));
\r
4922 * The DiagnosticRelatedInformation namespace provides helper functions to work with
\r
4923 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
\r
4925 var DiagnosticRelatedInformation;
\r
4926 (function (DiagnosticRelatedInformation) {
\r
4928 * Creates a new DiagnosticRelatedInformation literal.
\r
4930 function create(location, message) {
\r
4932 location: location,
\r
4936 DiagnosticRelatedInformation.create = create;
\r
4938 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
\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
4944 DiagnosticRelatedInformation.is = is;
\r
4945 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
\r
4947 * The diagnostic's severity.
\r
4949 var DiagnosticSeverity;
\r
4950 (function (DiagnosticSeverity) {
\r
4952 * Reports an error.
\r
4954 DiagnosticSeverity.Error = 1;
\r
4956 * Reports a warning.
\r
4958 DiagnosticSeverity.Warning = 2;
\r
4960 * Reports an information.
\r
4962 DiagnosticSeverity.Information = 3;
\r
4966 DiagnosticSeverity.Hint = 4;
\r
4967 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
\r
4969 * The Diagnostic namespace provides helper functions to work with
\r
4970 * [Diagnostic](#Diagnostic) literals.
\r
4973 (function (Diagnostic) {
\r
4975 * Creates a new Diagnostic literal.
\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
4982 if (Is.defined(code)) {
\r
4983 result.code = code;
\r
4985 if (Is.defined(source)) {
\r
4986 result.source = source;
\r
4988 if (Is.defined(relatedInformation)) {
\r
4989 result.relatedInformation = relatedInformation;
\r
4993 Diagnostic.create = create;
\r
4995 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
\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
5007 Diagnostic.is = is;
\r
5008 })(Diagnostic || (Diagnostic = {}));
\r
5010 * The Command namespace provides helper functions to work with
\r
5011 * [Command](#Command) literals.
\r
5014 (function (Command) {
\r
5016 * Creates a new Command literal.
\r
5018 function create(title, command) {
\r
5020 for (var _i = 2; _i < arguments.length; _i++) {
\r
5021 args[_i - 2] = arguments[_i];
\r
5023 var result = { title: title, command: command };
\r
5024 if (Is.defined(args) && args.length > 0) {
\r
5025 result.arguments = args;
\r
5029 Command.create = create;
\r
5031 * Checks whether the given literal conforms to the [Command](#Command) interface.
\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
5038 })(Command || (Command = {}));
\r
5040 * The TextEdit namespace provides helper function to create replace,
\r
5041 * insert and delete edits more easily.
\r
5044 (function (TextEdit) {
\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
5050 function replace(range, newText) {
\r
5051 return { range: range, newText: newText };
\r
5053 TextEdit.replace = replace;
\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
5059 function insert(position, newText) {
\r
5060 return { range: { start: position, end: position }, newText: newText };
\r
5062 TextEdit.insert = insert;
\r
5064 * Creates a delete text edit.
\r
5065 * @param range The range of text to be deleted.
\r
5067 function del(range) {
\r
5068 return { range: range, newText: '' };
\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
5078 })(TextEdit || (TextEdit = {}));
\r
5080 * The TextDocumentEdit namespace provides helper function to create
\r
5081 * an edit that manipulates a text document.
\r
5083 var TextDocumentEdit;
\r
5084 (function (TextDocumentEdit) {
\r
5086 * Creates a new `TextDocumentEdit`
\r
5088 function create(textDocument, edits) {
\r
5089 return { textDocument: textDocument, edits: edits };
\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
5098 TextDocumentEdit.is = is;
\r
5099 })(TextDocumentEdit || (TextDocumentEdit = {}));
\r
5101 (function (CreateFile) {
\r
5102 function create(uri, options) {
\r
5107 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
5108 result.options = options;
\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
5119 CreateFile.is = is;
\r
5120 })(CreateFile || (CreateFile = {}));
\r
5122 (function (RenameFile) {
\r
5123 function create(oldUri, newUri, options) {
\r
5129 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
5130 result.options = options;
\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
5141 RenameFile.is = is;
\r
5142 })(RenameFile || (RenameFile = {}));
\r
5144 (function (DeleteFile) {
\r
5145 function create(uri, options) {
\r
5150 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
\r
5151 result.options = options;
\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
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
5175 return TextDocumentEdit.is(change);
\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
5185 TextEditChangeImpl.prototype.insert = function (position, newText) {
\r
5186 this.edits.push(TextEdit.insert(position, newText));
\r
5188 TextEditChangeImpl.prototype.replace = function (range, newText) {
\r
5189 this.edits.push(TextEdit.replace(range, newText));
\r
5191 TextEditChangeImpl.prototype.delete = function (range) {
\r
5192 this.edits.push(TextEdit.del(range));
\r
5194 TextEditChangeImpl.prototype.add = function (edit) {
\r
5195 this.edits.push(edit);
\r
5197 TextEditChangeImpl.prototype.all = function () {
\r
5198 return this.edits;
\r
5200 TextEditChangeImpl.prototype.clear = function () {
\r
5201 this.edits.splice(0, this.edits.length);
\r
5203 return TextEditChangeImpl;
\r
5206 * A workspace change helps constructing changes to a workspace.
\r
5208 var WorkspaceChange = /** @class */ (function () {
\r
5209 function WorkspaceChange(workspaceEdit) {
\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
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
5230 Object.defineProperty(WorkspaceChange.prototype, "edit", {
\r
5232 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
\r
5233 * use to be returned from a workspace edit operation like rename.
\r
5235 get: function () {
\r
5236 return this._workspaceEdit;
\r
5239 configurable: true
\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
5248 if (!this._workspaceEdit.documentChanges) {
\r
5249 throw new Error('Workspace edit is not configured for document changes.');
\r
5251 var textDocument = key;
\r
5252 var result = this._textEditChanges[textDocument.uri];
\r
5255 var textDocumentEdit = {
\r
5256 textDocument: textDocument,
\r
5259 this._workspaceEdit.documentChanges.push(textDocumentEdit);
\r
5260 result = new TextEditChangeImpl(edits);
\r
5261 this._textEditChanges[textDocument.uri] = result;
\r
5266 if (!this._workspaceEdit) {
\r
5267 this._workspaceEdit = {
\r
5268 changes: Object.create(null)
\r
5271 if (!this._workspaceEdit.changes) {
\r
5272 throw new Error('Workspace edit is not configured for normal text edit changes.');
\r
5274 var result = this._textEditChanges[key];
\r
5277 this._workspaceEdit.changes[key] = edits;
\r
5278 result = new TextEditChangeImpl(edits);
\r
5279 this._textEditChanges[key] = result;
\r
5284 WorkspaceChange.prototype.createFile = function (uri, options) {
\r
5285 this.checkDocumentChanges();
\r
5286 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
\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
5292 WorkspaceChange.prototype.deleteFile = function (uri, options) {
\r
5293 this.checkDocumentChanges();
\r
5294 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
\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
5301 return WorkspaceChange;
\r
5305 * The TextDocumentIdentifier namespace provides helper functions to work with
\r
5306 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
\r
5308 var TextDocumentIdentifier;
\r
5309 (function (TextDocumentIdentifier) {
\r
5311 * Creates a new TextDocumentIdentifier literal.
\r
5312 * @param uri The document's uri.
\r
5314 function create(uri) {
\r
5315 return { uri: uri };
\r
5317 TextDocumentIdentifier.create = create;
\r
5319 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
\r
5321 function is(value) {
\r
5322 var candidate = value;
\r
5323 return Is.defined(candidate) && Is.string(candidate.uri);
\r
5325 TextDocumentIdentifier.is = is;
\r
5326 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
\r
5328 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
\r
5329 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
\r
5331 var VersionedTextDocumentIdentifier;
\r
5332 (function (VersionedTextDocumentIdentifier) {
\r
5334 * Creates a new VersionedTextDocumentIdentifier literal.
\r
5335 * @param uri The document's uri.
\r
5336 * @param uri The document's text.
\r
5338 function create(uri, version) {
\r
5339 return { uri: uri, version: version };
\r
5341 VersionedTextDocumentIdentifier.create = create;
\r
5343 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
\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
5349 VersionedTextDocumentIdentifier.is = is;
\r
5350 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
\r
5352 * The TextDocumentItem namespace provides helper functions to work with
\r
5353 * [TextDocumentItem](#TextDocumentItem) literals.
\r
5355 var TextDocumentItem;
\r
5356 (function (TextDocumentItem) {
\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
5364 function create(uri, languageId, version, text) {
\r
5365 return { uri: uri, languageId: languageId, version: version, text: text };
\r
5367 TextDocumentItem.create = create;
\r
5369 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
\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
5375 TextDocumentItem.is = is;
\r
5376 })(TextDocumentItem || (TextDocumentItem = {}));
\r
5378 * Describes the content type that a client supports in various
\r
5379 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
\r
5381 * Please note that `MarkupKinds` must not start with a `$`. This kinds
\r
5382 * are reserved for internal usage.
\r
5385 (function (MarkupKind) {
\r
5387 * Plain text is supported as a content format
\r
5389 MarkupKind.PlainText = 'plaintext';
\r
5391 * Markdown is supported as a content format
\r
5393 MarkupKind.Markdown = 'markdown';
\r
5394 })(MarkupKind || (MarkupKind = {}));
\r
5395 (function (MarkupKind) {
\r
5397 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
\r
5399 function is(value) {
\r
5400 var candidate = value;
\r
5401 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
\r
5403 MarkupKind.is = is;
\r
5404 })(MarkupKind || (MarkupKind = {}));
\r
5405 var MarkupContent;
\r
5406 (function (MarkupContent) {
\r
5408 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
\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
5414 MarkupContent.is = is;
\r
5415 })(MarkupContent || (MarkupContent = {}));
\r
5417 * The kind of a completion entry.
\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
5448 * Defines whether the insert text in a completion item should be interpreted as
\r
5449 * plain text or a snippet.
\r
5451 var InsertTextFormat;
\r
5452 (function (InsertTextFormat) {
\r
5454 * The primary text to be inserted is treated as a plain string.
\r
5456 InsertTextFormat.PlainText = 1;
\r
5458 * The primary text to be inserted is treated as a snippet.
\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
5465 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
\r
5467 InsertTextFormat.Snippet = 2;
\r
5468 })(InsertTextFormat || (InsertTextFormat = {}));
\r
5470 * The CompletionItem namespace provides functions to deal with
\r
5471 * completion items.
\r
5473 var CompletionItem;
\r
5474 (function (CompletionItem) {
\r
5476 * Create a completion item and seed it with a label.
\r
5477 * @param label The completion item's label
\r
5479 function create(label) {
\r
5480 return { label: label };
\r
5482 CompletionItem.create = create;
\r
5483 })(CompletionItem || (CompletionItem = {}));
\r
5485 * The CompletionList namespace provides functions to deal with
\r
5486 * completion lists.
\r
5488 var CompletionList;
\r
5489 (function (CompletionList) {
\r
5491 * Creates a new completion list.
\r
5493 * @param items The completion items.
\r
5494 * @param isIncomplete The list is not complete.
\r
5496 function create(items, isIncomplete) {
\r
5497 return { items: items ? items : [], isIncomplete: !!isIncomplete };
\r
5499 CompletionList.create = create;
\r
5500 })(CompletionList || (CompletionList = {}));
\r
5502 (function (MarkedString) {
\r
5504 * Creates a marked string from plain text.
\r
5506 * @param plainText The plain text.
\r
5508 function fromPlainText(plainText) {
\r
5509 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
\r
5511 MarkedString.fromPlainText = fromPlainText;
\r
5513 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
\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
5519 MarkedString.is = is;
\r
5520 })(MarkedString || (MarkedString = {}));
\r
5522 (function (Hover) {
\r
5524 * Checks whether the given value conforms to the [Hover](#Hover) interface.
\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
5533 })(Hover || (Hover = {}));
\r
5535 * The ParameterInformation namespace provides helper functions to work with
\r
5536 * [ParameterInformation](#ParameterInformation) literals.
\r
5538 var ParameterInformation;
\r
5539 (function (ParameterInformation) {
\r
5541 * Creates a new parameter information literal.
\r
5543 * @param label A label string.
\r
5544 * @param documentation A doc string.
\r
5546 function create(label, documentation) {
\r
5547 return documentation ? { label: label, documentation: documentation } : { label: label };
\r
5549 ParameterInformation.create = create;
\r
5551 })(ParameterInformation || (ParameterInformation = {}));
\r
5553 * The SignatureInformation namespace provides helper functions to work with
\r
5554 * [SignatureInformation](#SignatureInformation) literals.
\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
5563 var result = { label: label };
\r
5564 if (Is.defined(documentation)) {
\r
5565 result.documentation = documentation;
\r
5567 if (Is.defined(parameters)) {
\r
5568 result.parameters = parameters;
\r
5571 result.parameters = [];
\r
5575 SignatureInformation.create = create;
\r
5576 })(SignatureInformation || (SignatureInformation = {}));
\r
5578 * A document highlight kind.
\r
5580 var DocumentHighlightKind;
\r
5581 (function (DocumentHighlightKind) {
\r
5583 * A textual occurrence.
\r
5585 DocumentHighlightKind.Text = 1;
\r
5587 * Read-access of a symbol, like reading a variable.
\r
5589 DocumentHighlightKind.Read = 2;
\r
5591 * Write-access of a symbol, like writing to a variable.
\r
5593 DocumentHighlightKind.Write = 3;
\r
5594 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
\r
5596 * DocumentHighlight namespace to provide helper functions to work with
\r
5597 * [DocumentHighlight](#DocumentHighlight) literals.
\r
5599 var DocumentHighlight;
\r
5600 (function (DocumentHighlight) {
\r
5602 * Create a DocumentHighlight object.
\r
5603 * @param range The range the highlight applies to.
\r
5605 function create(range, kind) {
\r
5606 var result = { range: range };
\r
5607 if (Is.number(kind)) {
\r
5608 result.kind = kind;
\r
5612 DocumentHighlight.create = create;
\r
5613 })(DocumentHighlight || (DocumentHighlight = {}));
\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
5649 * Creates a new symbol information literal.
\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
5657 function create(name, kind, range, uri, containerName) {
\r
5661 location: { uri: uri, range: range }
\r
5663 if (containerName) {
\r
5664 result.containerName = containerName;
\r
5668 SymbolInformation.create = create;
\r
5669 })(SymbolInformation || (SymbolInformation = {}));
\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
5676 var DocumentSymbol = /** @class */ (function () {
\r
5677 function DocumentSymbol() {
\r
5679 return DocumentSymbol;
\r
5682 (function (DocumentSymbol) {
\r
5684 * Creates a new symbol information literal.
\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
5693 function create(name, detail, kind, range, selectionRange, children) {
\r
5699 selectionRange: selectionRange
\r
5701 if (children !== void 0) {
\r
5702 result.children = children;
\r
5706 DocumentSymbol.create = create;
\r
5708 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
\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
5719 DocumentSymbol.is = is;
\r
5720 })(DocumentSymbol || (DocumentSymbol = {}));
\r
5722 * A set of predefined code action kinds
\r
5724 var CodeActionKind;
\r
5725 (function (CodeActionKind) {
\r
5727 * Base kind for quickfix actions: 'quickfix'
\r
5729 CodeActionKind.QuickFix = 'quickfix';
\r
5731 * Base kind for refactoring actions: 'refactor'
\r
5733 CodeActionKind.Refactor = 'refactor';
\r
5735 * Base kind for refactoring extraction actions: 'refactor.extract'
\r
5737 * Example extract actions:
\r
5739 * - Extract method
\r
5740 * - Extract function
\r
5741 * - Extract variable
\r
5742 * - Extract interface from class
\r
5745 CodeActionKind.RefactorExtract = 'refactor.extract';
\r
5747 * Base kind for refactoring inline actions: 'refactor.inline'
\r
5749 * Example inline actions:
\r
5751 * - Inline function
\r
5752 * - Inline variable
\r
5753 * - Inline constant
\r
5756 CodeActionKind.RefactorInline = 'refactor.inline';
\r
5758 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
\r
5760 * Example rewrite actions:
\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
5769 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
\r
5771 * Base kind for source actions: `source`
\r
5773 * Source code actions apply to the entire file.
\r
5775 CodeActionKind.Source = 'source';
\r
5777 * Base kind for an organize imports source action: `source.organizeImports`
\r
5779 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
\r
5780 })(CodeActionKind || (CodeActionKind = {}));
\r
5782 * The CodeActionContext namespace provides helper functions to work with
\r
5783 * [CodeActionContext](#CodeActionContext) literals.
\r
5785 var CodeActionContext;
\r
5786 (function (CodeActionContext) {
\r
5788 * Creates a new CodeActionContext literal.
\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
5797 CodeActionContext.create = create;
\r
5799 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
\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
5805 CodeActionContext.is = is;
\r
5806 })(CodeActionContext || (CodeActionContext = {}));
\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
5815 result.edit = commandOrEdit;
\r
5817 if (kind !== void null) {
\r
5818 result.kind = kind;
\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
5832 CodeAction.is = is;
\r
5833 })(CodeAction || (CodeAction = {}));
\r
5835 * The CodeLens namespace provides helper functions to work with
\r
5836 * [CodeLens](#CodeLens) literals.
\r
5839 (function (CodeLens) {
\r
5841 * Creates a new CodeLens literal.
\r
5843 function create(range, data) {
\r
5844 var result = { range: range };
\r
5845 if (Is.defined(data))
\r
5846 result.data = data;
\r
5849 CodeLens.create = create;
\r
5851 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
\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
5858 })(CodeLens || (CodeLens = {}));
\r
5860 * The FormattingOptions namespace provides helper functions to work with
\r
5861 * [FormattingOptions](#FormattingOptions) literals.
\r
5863 var FormattingOptions;
\r
5864 (function (FormattingOptions) {
\r
5866 * Creates a new FormattingOptions literal.
\r
5868 function create(tabSize, insertSpaces) {
\r
5869 return { tabSize: tabSize, insertSpaces: insertSpaces };
\r
5871 FormattingOptions.create = create;
\r
5873 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
\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
5879 FormattingOptions.is = is;
\r
5880 })(FormattingOptions || (FormattingOptions = {}));
\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
5885 var DocumentLink = /** @class */ (function () {
\r
5886 function DocumentLink() {
\r
5888 return DocumentLink;
\r
5892 * The DocumentLink namespace provides helper functions to work with
\r
5893 * [DocumentLink](#DocumentLink) literals.
\r
5895 (function (DocumentLink) {
\r
5897 * Creates a new DocumentLink literal.
\r
5899 function create(range, target, data) {
\r
5900 return { range: range, target: target, data: data };
\r
5902 DocumentLink.create = create;
\r
5904 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
\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
5910 DocumentLink.is = is;
\r
5911 })(DocumentLink || (DocumentLink = {}));
\r
5912 var EOL = ['\n', '\r\n', '\r'];
\r
5914 (function (TextDocument) {
\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
5921 function create(uri, languageId, version, content) {
\r
5922 return new FullTextDocument(uri, languageId, version, content);
\r
5924 TextDocument.create = create;
\r
5926 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
\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
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
5939 return a.range.start.character - b.range.start.character;
\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
5952 throw new Error('Overlapping edit');
\r
5954 lastModifiedOffset = startOffset;
\r
5958 TextDocument.applyEdits = applyEdits;
\r
5959 function mergeSort(data, compare) {
\r
5960 if (data.length <= 1) {
\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
5972 while (leftIdx < left.length && rightIdx < right.length) {
\r
5973 var ret = compare(left[leftIdx], right[rightIdx]);
\r
5975 // smaller_equal -> take left to preserve order
\r
5976 data[i++] = left[leftIdx++];
\r
5979 // greater -> take right
\r
5980 data[i++] = right[rightIdx++];
\r
5983 while (leftIdx < left.length) {
\r
5984 data[i++] = left[leftIdx++];
\r
5986 while (rightIdx < right.length) {
\r
5987 data[i++] = right[rightIdx++];
\r
5991 })(TextDocument || (TextDocument = {}));
\r
5993 * Represents reasons why a text document is saved.
\r
5995 var TextDocumentSaveReason;
\r
5996 (function (TextDocumentSaveReason) {
\r
5998 * Manually triggered, e.g. by the user pressing save, by starting debugging,
\r
5999 * or by an API call.
\r
6001 TextDocumentSaveReason.Manual = 1;
\r
6003 * Automatic after a delay.
\r
6005 TextDocumentSaveReason.AfterDelay = 2;
\r
6007 * When the editor lost focus.
\r
6009 TextDocumentSaveReason.FocusOut = 3;
\r
6010 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));
\r
6011 var FullTextDocument = /** @class */ (function () {
\r
6012 function FullTextDocument(uri, languageId, version, content) {
\r
6014 this._languageId = languageId;
\r
6015 this._version = version;
\r
6016 this._content = content;
\r
6017 this._lineOffsets = null;
\r
6019 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
6020 get: function () {
\r
6024 configurable: true
\r
6026 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
6027 get: function () {
\r
6028 return this._languageId;
\r
6031 configurable: true
\r
6033 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
6034 get: function () {
\r
6035 return this._version;
\r
6038 configurable: true
\r
6040 FullTextDocument.prototype.getText = function (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
6046 return this._content;
\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
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
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
6069 if (isLineStart && text.length > 0) {
\r
6070 lineOffsets.push(text.length);
\r
6072 this._lineOffsets = lineOffsets;
\r
6074 return this._lineOffsets;
\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
6081 return Position.create(0, offset);
\r
6083 while (low < high) {
\r
6084 var mid = Math.floor((low + high) / 2);
\r
6085 if (lineOffsets[mid] > offset) {
\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
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
6102 else if (position.line < 0) {
\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
6109 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
6110 get: function () {
\r
6111 return this.getLineOffsets().length;
\r
6114 configurable: true
\r
6116 return FullTextDocument;
\r
6120 var toString = Object.prototype.toString;
\r
6121 function defined(value) {
\r
6122 return typeof value !== 'undefined';
\r
6124 Is.defined = defined;
\r
6125 function undefined(value) {
\r
6126 return typeof value === 'undefined';
\r
6128 Is.undefined = undefined;
\r
6129 function boolean(value) {
\r
6130 return value === true || value === false;
\r
6132 Is.boolean = boolean;
\r
6133 function string(value) {
\r
6134 return toString.call(value) === '[object String]';
\r
6136 Is.string = string;
\r
6137 function number(value) {
\r
6138 return toString.call(value) === '[object Number]';
\r
6140 Is.number = number;
\r
6141 function func(value) {
\r
6142 return toString.call(value) === '[object Function]';
\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
6151 Is.objectLiteral = objectLiteral;
\r
6152 function typedArray(value, check) {
\r
6153 return Array.isArray(value) && value.every(check);
\r
6155 Is.typedArray = typedArray;
\r
6156 })(Is || (Is = {}));
\r
6161 /***/ (function(module, exports, __webpack_require__) {
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
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
6199 DocumentFilter.is = is;
\r
6200 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
\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
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
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
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
6220 * Supports creating new files and folders.
\r
6222 ResourceOperationKind.Create = 'create';
\r
6224 * Supports renaming existing files and folders.
\r
6226 ResourceOperationKind.Rename = 'rename';
\r
6228 * Supports deleting existing files and folders.
\r
6230 ResourceOperationKind.Delete = 'delete';
\r
6231 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
\r
6232 var FailureHandlingKind;
\r
6233 (function (FailureHandlingKind) {
\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
6238 FailureHandlingKind.Abort = 'abort';
\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
6243 FailureHandlingKind.Transactional = 'transactional';
\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
6249 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
\r
6251 * The client tries to undo the operations already executed. But there is no
\r
6252 * guaruntee that this is succeeding.
\r
6254 FailureHandlingKind.Undo = 'undo';
\r
6255 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
\r
6257 * Defines how the host (editor) should sync
\r
6258 * document changes to the language server.
\r
6260 var TextDocumentSyncKind;
\r
6261 (function (TextDocumentSyncKind) {
\r
6263 * Documents should not be synced at all.
\r
6265 TextDocumentSyncKind.None = 0;
\r
6267 * Documents are synced by always sending the full content
\r
6268 * of the document.
\r
6270 TextDocumentSyncKind.Full = 1;
\r
6272 * Documents are synced by sending the full content on open.
\r
6273 * After that only incremental updates to the document are
\r
6276 TextDocumentSyncKind.Incremental = 2;
\r
6277 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
\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
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
6290 * Known error codes for an `InitializeError`;
\r
6292 var InitializeError;
\r
6293 (function (InitializeError) {
\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
6299 InitializeError.unknownProtocolVersion = 1;
\r
6300 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
\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
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
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
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
6323 * The exit event is sent from the client to the server to
\r
6324 * ask the server to exit its process.
\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
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
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
6342 * The message type
\r
6345 (function (MessageType) {
\r
6347 * An error message.
\r
6349 MessageType.Error = 1;
\r
6351 * A warning message.
\r
6353 MessageType.Warning = 2;
\r
6355 * An information message.
\r
6357 MessageType.Info = 3;
\r
6361 MessageType.Log = 4;
\r
6362 })(MessageType = exports.MessageType || (exports.MessageType = {}));
\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
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
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
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
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
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
6389 * The telemetry event notification is sent from the server to the client to ask
\r
6390 * the client to log telemetry data.
\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
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
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
6411 * The document change notification is sent from the client to the server to signal
\r
6412 * changes to a text document.
\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
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
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
6432 * The document save notification is sent from the client to the server when
\r
6433 * the document got saved in the client.
\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
6440 * A document will save notification is sent from the client to the server before
\r
6441 * the document is actually saved.
\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
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
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
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
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
6469 * The file event type
\r
6471 var FileChangeType;
\r
6472 (function (FileChangeType) {
\r
6474 * The file got created.
\r
6476 FileChangeType.Created = 1;
\r
6478 * The file got changed.
\r
6480 FileChangeType.Changed = 2;
\r
6482 * The file got deleted.
\r
6484 FileChangeType.Deleted = 3;
\r
6485 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
\r
6487 (function (WatchKind) {
\r
6489 * Interested in create events.
\r
6491 WatchKind.Create = 1;
\r
6493 * Interested in change events
\r
6495 WatchKind.Change = 2;
\r
6497 * Interested in delete events
\r
6499 WatchKind.Delete = 4;
\r
6500 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
\r
6501 //---- Diagnostic notification ----
\r
6503 * Diagnostics notification are sent from the server to the client to signal
\r
6504 * results of validation runs.
\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
6511 * How a completion was triggered
\r
6513 var CompletionTriggerKind;
\r
6514 (function (CompletionTriggerKind) {
\r
6516 * Completion was triggered by typing an identifier (24x7 code
\r
6517 * complete), manual invocation (e.g Ctrl+Space) or via API.
\r
6519 CompletionTriggerKind.Invoked = 1;
\r
6521 * Completion was triggered by a trigger character specified by
\r
6522 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
\r
6524 CompletionTriggerKind.TriggerCharacter = 2;
\r
6526 * Completion was re-triggered as current completion list is incomplete
\r
6528 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
\r
6529 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
\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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
6624 * A request to provide commands for the given text document and range.
\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
6631 * A request to provide code lens for the given text document.
\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
6638 * A request to resolve a command for a given code lens.
\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
6645 * A request to to format a whole document.
\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
6652 * A request to to format a range in a document.
\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
6659 * A request to format a document on type.
\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
6666 * A request to rename a symbol.
\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
6673 * A request to test and perform the setup necessary for a rename.
\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
6680 * A request to provide document links
\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
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
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
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
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
6704 * A request sent from the server to the client to modified certain resources.
\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
6714 /***/ (function(module, exports, __webpack_require__) {
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
6722 Object.defineProperty(exports, "__esModule", { value: true });
\r
6723 function boolean(value) {
\r
6724 return value === true || value === false;
\r
6726 exports.boolean = boolean;
\r
6727 function string(value) {
\r
6728 return typeof value === 'string' || value instanceof String;
\r
6730 exports.string = string;
\r
6731 function number(value) {
\r
6732 return typeof value === 'number' || value instanceof Number;
\r
6734 exports.number = number;
\r
6735 function error(value) {
\r
6736 return value instanceof Error;
\r
6738 exports.error = error;
\r
6739 function func(value) {
\r
6740 return typeof value === 'function';
\r
6742 exports.func = func;
\r
6743 function array(value) {
\r
6744 return Array.isArray(value);
\r
6746 exports.array = array;
\r
6747 function stringArray(value) {
\r
6748 return array(value) && value.every(elem => string(elem));
\r
6750 exports.stringArray = stringArray;
\r
6751 function typedArray(value, check) {
\r
6752 return Array.isArray(value) && value.every(check);
\r
6754 exports.typedArray = typedArray;
\r
6755 function thenable(value) {
\r
6756 return value && func(value.then);
\r
6758 exports.thenable = thenable;
\r
6763 /***/ (function(module, exports, __webpack_require__) {
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
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
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
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
6789 /***/ (function(module, exports, __webpack_require__) {
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
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
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
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
6815 /***/ (function(module, exports, __webpack_require__) {
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
6823 Object.defineProperty(exports, "__esModule", { value: true });
\r
6824 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
6826 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
\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
6833 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
\r
6834 * folder configuration changes.
\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
6844 /***/ (function(module, exports, __webpack_require__) {
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
6852 Object.defineProperty(exports, "__esModule", { value: true });
\r
6853 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
6855 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
\r
6856 * configuration setting.
\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
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
6871 /***/ (function(module, exports, __webpack_require__) {
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
6879 Object.defineProperty(exports, "__esModule", { value: true });
\r
6880 const vscode_jsonrpc_1 = __webpack_require__(6);
\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
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
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
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
6905 /***/ (function(module, exports, __webpack_require__) {
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
6916 * Enum of known range kinds
\r
6918 var FoldingRangeKind;
\r
6919 (function (FoldingRangeKind) {
\r
6921 * Folding range for a comment
\r
6923 FoldingRangeKind["Comment"] = "comment";
\r
6925 * Folding range for a imports or includes
\r
6927 FoldingRangeKind["Imports"] = "imports";
\r
6929 * Folding range for a region (e.g. `#region`)
\r
6931 FoldingRangeKind["Region"] = "region";
\r
6932 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
\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
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
6947 /***/ (function(module, exports, __webpack_require__) {
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
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
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
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
6974 /***/ (function(module, exports, __webpack_require__) {
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
6985 * Enum of known selection range kinds
\r
6987 var SelectionRangeKind;
\r
6988 (function (SelectionRangeKind) {
\r
6992 SelectionRangeKind["Empty"] = "";
\r
6994 * The statment kind, its value is `statement`, possible extensions can be
\r
6995 * `statement.if` etc
\r
6997 SelectionRangeKind["Statement"] = "statement";
\r
6999 * The declaration kind, its value is `declaration`, possible extensions can be
\r
7000 * `declaration.function`, `declaration.class` etc.
\r
7002 SelectionRangeKind["Declaration"] = "declaration";
\r
7003 })(SelectionRangeKind = exports.SelectionRangeKind || (exports.SelectionRangeKind = {}));
\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
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
7018 /***/ (function(module, exports, __webpack_require__) {
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
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
7033 return this._getConfiguration({});
\r
7035 else if (Is.string(arg)) {
\r
7036 return this._getConfiguration({ section: arg });
\r
7039 return this._getConfiguration(arg);
\r
7042 _getConfiguration(arg) {
\r
7044 items: Array.isArray(arg) ? arg : [arg]
\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
7056 /***/ (function(module, exports, __webpack_require__) {
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
7064 Object.defineProperty(exports, "__esModule", { value: true });
\r
7065 function boolean(value) {
\r
7066 return value === true || value === false;
\r
7068 exports.boolean = boolean;
\r
7069 function string(value) {
\r
7070 return typeof value === 'string' || value instanceof String;
\r
7072 exports.string = string;
\r
7073 function number(value) {
\r
7074 return typeof value === 'number' || value instanceof Number;
\r
7076 exports.number = number;
\r
7077 function error(value) {
\r
7078 return value instanceof Error;
\r
7080 exports.error = error;
\r
7081 function func(value) {
\r
7082 return typeof value === 'function';
\r
7084 exports.func = func;
\r
7085 function array(value) {
\r
7086 return Array.isArray(value);
\r
7088 exports.array = array;
\r
7089 function stringArray(value) {
\r
7090 return array(value) && value.every(elem => string(elem));
\r
7092 exports.stringArray = stringArray;
\r
7093 function typedArray(value, check) {
\r
7094 return Array.isArray(value) && value.every(check);
\r
7096 exports.typedArray = typedArray;
\r
7097 function thenable(value) {
\r
7098 return value && func(value.then);
\r
7100 exports.thenable = thenable;
\r
7105 /***/ (function(module, exports, __webpack_require__) {
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
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
7126 getWorkspaceFolders() {
\r
7127 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
\r
7129 get onDidChangeWorkspaceFolders() {
\r
7130 if (!this._onDidChangeWorkspaceFolders) {
\r
7131 throw new Error('Client doesn\'t support sending workspace folder change events.');
\r
7133 if (!this._unregistration) {
\r
7134 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
\r
7136 return this._onDidChangeWorkspaceFolders.event;
\r
7144 /***/ (function(module, exports, __webpack_require__) {
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
7152 Object.defineProperty(exports, "__esModule", { value: true });
\r
7154 constructor(_value) {
\r
7155 this._value = _value;
\r
7159 return this._value;
\r
7162 return this.asHex() === other.asHex();
\r
7165 class V4UUID extends ValueUUID {
\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
7177 V4UUID._randomHex(),
\r
7178 V4UUID._randomHex(),
\r
7179 V4UUID._randomHex(),
\r
7180 V4UUID._randomHex(),
\r
7183 V4UUID._randomHex(),
\r
7184 V4UUID._randomHex(),
\r
7185 V4UUID._randomHex(),
\r
7187 V4UUID._oneOf(V4UUID._timeHighBits),
\r
7188 V4UUID._randomHex(),
\r
7189 V4UUID._randomHex(),
\r
7190 V4UUID._randomHex(),
\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
7206 static _oneOf(array) {
\r
7207 return array[Math.floor(array.length * Math.random())];
\r
7209 static _randomHex() {
\r
7210 return V4UUID._oneOf(V4UUID._chars);
\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
7216 * An empty UUID that contains only zeros.
\r
7218 exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
\r
7220 return new V4UUID();
\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
7227 exports.isUUID = isUUID;
\r
7229 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
\r
7230 * @param value A uuid string.
\r
7232 function parse(value) {
\r
7233 if (!isUUID(value)) {
\r
7234 throw new Error('invalid uuid');
\r
7236 return new ValueUUID(value);
\r
7238 exports.parse = parse;
\r
7239 function generateUuid() {
\r
7240 return v4().asHex();
\r
7242 exports.generateUuid = generateUuid;
\r
7247 /***/ (function(module, exports, __webpack_require__) {
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
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
7261 * @deprecated Use the `vscode-uri` npm module which provides a more
\r
7262 * complete implementation of handling VS Code URIs.
\r
7264 function uriToFilePath(uri) {
\r
7265 let parsed = url.parse(uri);
\r
7266 if (parsed.protocol !== 'file:' || !parsed.path) {
\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
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
7283 return path.normalize(segments.join('/'));
\r
7285 exports.uriToFilePath = uriToFilePath;
\r
7286 function isWindows() {
\r
7287 return process.platform === 'win32';
\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
7296 child_process_1.exec('npm config get prefix', (error, stdout, _stderr) => {
\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
7304 nodePath.push(path.join(globalPath, 'lib', 'node_modules'));
\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
7316 newEnv[nodePathKey] = nodePath.join(separator);
\r
7318 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
\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
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
7331 cp.send({ command: 'exit' });
\r
7333 resolve(__webpack_require__(37)(toRequire));
\r
7341 command: 'resolve',
\r
7352 exports.resolveModule = resolveModule;
\r
7353 function resolve(moduleName, nodePath, cwd, tracer) {
\r
7354 const nodePathKey = 'NODE_PATH';
\r
7356 "var p = process;",
\r
7357 "p.on('message',function(m){",
\r
7361 "else if(m.c==='rs'){",
\r
7363 "var r=require.resolve(m.a);",
\r
7364 "p.send({c:'r',s:true,r:r});",
\r
7367 "p.send({c:'r',s:false});",
\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
7377 if (newEnv[nodePathKey]) {
\r
7378 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
\r
7381 newEnv[nodePathKey] = nodePath;
\r
7384 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
\r
7387 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
\r
7389 let cp = child_process_1.fork('', [], {
\r
7392 execArgv: ['-e', app]
\r
7394 if (cp.pid === void 0) {
\r
7395 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
\r
7398 cp.on('error', (error) => {
\r
7401 cp.on('message', (message) => {
\r
7402 if (message.c === 'r') {
\r
7403 cp.send({ c: 'e' });
\r
7405 resolve(message.r);
\r
7408 reject(new Error(`Failed to resolve module: ${moduleName}`));
\r
7423 exports.resolve = resolve;
\r
7424 function resolveGlobalNodePath(tracer) {
\r
7425 let npmCommand = 'npm';
\r
7429 if (isWindows()) {
\r
7430 npmCommand = 'npm.cmd';
\r
7431 options.shell = true;
\r
7433 let handler = () => { };
\r
7435 process.on('SIGPIPE', handler);
\r
7436 let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
\r
7439 tracer(`'npm config get prefix' didn't return a value.`);
\r
7443 let prefix = stdout.trim();
\r
7445 tracer(`'npm config get prefix' value is: ${prefix}`);
\r
7447 if (prefix.length > 0) {
\r
7448 if (isWindows()) {
\r
7449 return path.join(prefix, 'node_modules');
\r
7452 return path.join(prefix, 'lib', 'node_modules');
\r
7461 process.removeListener('SIGPIPE', handler);
\r
7464 exports.resolveGlobalNodePath = resolveGlobalNodePath;
\r
7465 function resolveGlobalYarnPath(tracer) {
\r
7466 let yarnCommand = 'yarn';
\r
7470 if (isWindows()) {
\r
7471 yarnCommand = 'yarn.cmd';
\r
7472 options.shell = true;
\r
7474 let handler = () => { };
\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
7481 tracer(`'yarn global dir' didn't return a value.`);
\r
7482 if (results.stderr) {
\r
7483 tracer(results.stderr);
\r
7488 let lines = stdout.trim().split(/\r?\n/);
\r
7489 for (let line of lines) {
\r
7491 let yarn = JSON.parse(line);
\r
7492 if (yarn.type === 'log') {
\r
7493 return path.join(yarn.data, 'node_modules');
\r
7497 // Do nothing. Ignore the line
\r
7506 process.removeListener('SIGPIPE', handler);
\r
7509 exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
\r
7511 (function (FileSystem) {
\r
7512 let _isCaseSensitive = undefined;
\r
7513 function isCaseSensitive() {
\r
7514 if (_isCaseSensitive !== void 0) {
\r
7515 return _isCaseSensitive;
\r
7517 if (process.platform === 'win32') {
\r
7518 _isCaseSensitive = false;
\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
7525 return _isCaseSensitive;
\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
7533 return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) == 0;
\r
7536 FileSystem.isParent = isParent;
\r
7537 })(FileSystem = exports.FileSystem || (exports.FileSystem = {}));
\r
7538 function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
\r
7540 if (!path.isAbsolute(nodePath)) {
\r
7541 nodePath = path.join(workspaceRoot, nodePath);
\r
7543 return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
\r
7544 if (FileSystem.isParent(nodePath, value)) {
\r
7548 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
\r
7550 }).then(undefined, (_error) => {
\r
7551 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
\r
7555 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
\r
7558 exports.resolveModulePath = resolveModulePath;
\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
7563 function resolveModule2(workspaceRoot, moduleName, nodePath, tracer) {
\r
7564 return resolveModulePath(workspaceRoot, moduleName, nodePath, tracer).then((path) => {
\r
7566 tracer(`Module ${moduleName} got resolved to ${path}`);
\r
7568 return __webpack_require__(37)(path);
\r
7571 exports.resolveModule2 = resolveModule2;
\r
7576 /***/ (function(module, exports) {
7578 module.exports = require("url");
7582 /***/ (function(module, exports) {
7584 module.exports = require("fs");
7588 /***/ (function(module, exports) {
7590 module.exports = require("child_process");
7594 /***/ (function(module, exports) {
7596 function webpackEmptyContext(req) {
7597 var e = new Error("Cannot find module '" + req + "'");
7598 e.code = 'MODULE_NOT_FOUND';
7601 webpackEmptyContext.keys = function() { return []; };
7602 webpackEmptyContext.resolve = webpackEmptyContext;
7603 module.exports = webpackEmptyContext;
7604 webpackEmptyContext.id = 37;
7608 /***/ (function(module, __webpack_exports__, __webpack_require__) {
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 *--------------------------------------------------------------------------------------------*/
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 __());
7630 if (typeof process === 'object') {
7631 isWindows = process.platform === 'win32';
7633 else if (typeof navigator === 'object') {
7634 var userAgent = navigator.userAgent;
7635 isWindows = userAgent.indexOf('Windows') >= 0;
7638 var _schemePattern = /^\w[\w\d+.-]*$/;
7639 var _singleSlashStart = /^\//;
7640 var _doubleSlashStart = /^\/\//;
7641 var _throwOnMissingSchema = true;
7645 function setUriThrowOnMissingScheme(value) {
7646 var old = _throwOnMissingSchema;
7647 _throwOnMissingSchema = value;
7650 function _validateUri(ret, _strict) {
7651 // scheme, must be set
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 + "\"}");
7657 // console.warn(`[UriError]: Scheme is missing: {scheme: "", authority: "${ret.authority}", path: "${ret.path}", query: "${ret.query}", fragment: "${ret.fragment}"}`);
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.');
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 ("//").
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');
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 ("//")');
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
7687 function _schemeFix(scheme, _strict) {
7688 if (_strict || _throwOnMissingSchema) {
7689 return scheme || _empty;
7692 // console.trace('BAD uri lacks scheme, falling back to file-scheme.');
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
7710 else if (path[0] !== _slash) {
7711 path = _slash + path;
7719 var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
7720 function _isQueryStringScheme(scheme) {
7724 switch (scheme.toLowerCase()) {
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
7738 * foo://example.com:8042/over/there?name=ferret#nose
7739 * \_/ \______________/\_________/ \_________/ \__/
7741 * scheme authority path query fragment
7742 * | _____________________|__
7744 * urn:example:animal:ferret:nose
7746 var URI = (function () {
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);
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);
7771 URI.isUri = function (thing) {
7772 if (thing instanceof URI) {
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';
7787 Object.defineProperty(URI.prototype, "fsPath", {
7788 // ---- filesystem path -----------------------
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.
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.
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).
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'
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).
7814 // if (this.scheme !== 'file') {
7815 // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
7817 return _makeFsPath(this);
7822 // ---- modify to new -------------------------
7823 URI.prototype.with = function (change) {
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;
7831 else if (scheme === null) {
7834 if (authority === undefined) {
7835 authority = this.authority;
7837 else if (authority === null) {
7840 if (path === undefined) {
7843 else if (path === null) {
7846 if (query === undefined) {
7849 else if (query === null) {
7852 if (fragment === undefined) {
7853 fragment = this.fragment;
7855 else if (fragment === null) {
7858 if (scheme === this.scheme
7859 && authority === this.authority
7860 && path === this.path
7861 && query === this.query
7862 && fragment === this.fragment) {
7865 return new _URI(scheme, authority, path, query, fragment);
7867 // ---- parse & validate ------------------------
7869 * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
7870 * `file:///usr/home`, or `scheme:with/path`.
7872 * @param value A string which represents an URI (see `URI#toString`).
7874 URI.parse = function (value, _strict) {
7875 if (_strict === void 0) { _strict = false; }
7876 var match = _regexp.exec(value);
7878 return new _URI(_empty, _empty, _empty, _empty, _empty, _strict);
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);
7883 * Creates a new URI from a file system path, e.g. `c:\my\files`,
7884 * `/usr/home`, or `\\server\share\some\path`.
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:
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';
7901 * @param path A file system path (see `URI#fsPath`)
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
7909 path = path.replace(/\\/g, _slash);
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);
7916 authority = path.substring(2);
7920 authority = path.substring(2, idx);
7921 path = path.substring(idx) || _slash;
7924 return new _URI('file', authority, path, _empty, _empty);
7926 URI.from = function (components) {
7927 return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
7929 // ---- printing/externalize ---------------------------
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
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.
7939 * @param skipEncoding Do not encode the result, default is `false`
7941 URI.prototype.toString = function (skipEncoding) {
7942 if (skipEncoding === void 0) { skipEncoding = false; }
7943 return _asFormatted(this, skipEncoding);
7945 URI.prototype.toJSON = function () {
7948 URI.revive = function (data) {
7952 else if (data instanceof URI) {
7956 var result = new _URI(data);
7957 result._formatted = data.external;
7958 result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
7965 var _pathSepMarker = isWindows ? 1 : undefined;
7966 // tslint:disable-next-line:class-name
7967 var _URI = (function (_super) {
7968 __extends(_URI, _super);
7970 var _this = _super !== null && _super.apply(this, arguments) || this;
7971 _this._formatted = null;
7972 _this._fsPath = null;
7975 Object.defineProperty(_URI.prototype, "fsPath", {
7977 if (!this._fsPath) {
7978 this._fsPath = _makeFsPath(this);
7980 return this._fsPath;
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);
7991 return this._formatted;
7994 // we don't cache that
7995 return _asFormatted(this, true);
7998 _URI.prototype.toJSON = function () {
8004 res.fsPath = this._fsPath;
8005 res._sep = _pathSepMarker;
8007 if (this._formatted) {
8008 res.external = this._formatted;
8012 res.path = this.path;
8015 res.scheme = this.scheme;
8017 if (this.authority) {
8018 res.authority = this.authority;
8021 res.query = this.query;
8023 if (this.fragment) {
8024 res.fragment = this.fragment;
8030 function isHex(value, pos) {
8031 if (pos >= value.length) {
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
8039 function decodeURIComponentFast(uriComponent, isPath, isQueryString) {
8041 var nativeDecodePos = -1;
8042 for (var pos = 0; pos < uriComponent.length; pos++) {
8043 var code = uriComponent.charCodeAt(pos);
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 */))
8052 (isQueryString && ((chA === 50 /* Digit2 */ && chB === 54 /* Digit6 */) // %26
8054 (chA === 51 /* Digit3 */ && (chB === 66 /* B */ || chB === 98 /* b */ || chB === 68 /* D */ || chB === 100 /* d */)) // %3D, %3D
8056 if (nativeDecodePos !== -1) {
8057 res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
8058 nativeDecodePos = -1;
8060 if (res !== undefined) {
8061 res += uriComponent.substr(pos, 3);
8066 if (res === undefined) {
8067 res = uriComponent.substring(0, pos);
8069 if (nativeDecodePos === -1) {
8070 nativeDecodePos = pos;
8075 if (nativeDecodePos !== -1) {
8076 res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
8077 nativeDecodePos = -1;
8079 if (res !== undefined) {
8080 res += String.fromCharCode(code);
8084 if (nativeDecodePos !== -1) {
8085 res += decodeURIComponent(uriComponent.substr(nativeDecodePos));
8087 return res !== undefined ? res : uriComponent;
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',
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 &=;
8127 // check if we are delaying native encode
8128 if (nativeEncodePos !== -1) {
8129 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
8130 nativeEncodePos = -1;
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);
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;
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);
8151 // encoding needed, we need to allocate a new string
8152 if (res === undefined) {
8153 res = uriComponent.substr(0, pos);
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;
8163 // append escaped variant to result
8166 else if (nativeEncodePos === -1) {
8167 // use native encode only when needed
8168 nativeEncodePos = pos;
8172 if (nativeEncodePos !== -1) {
8173 res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
8175 return res !== undefined ? res : uriComponent;
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);
8185 res += encodeTable[code];
8188 if (res !== undefined) {
8193 return res !== undefined ? res : path;
8196 * Compute `fsPath` for the given uri
8198 function _makeFsPath(uri) {
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;
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);
8215 value = value.replace(/\//g, '\\');
8220 * Create the external version of a uri
8222 function _asFormatted(uri, skipEncoding) {
8223 var encoder = !skipEncoding
8224 ? encodeURIComponentFast
8225 : encodeURIComponentMinimal;
8227 var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
8232 if (authority || scheme === 'file') {
8237 var idx = authority.indexOf('@');
8240 var userinfo = authority.substr(0, idx);
8241 authority = authority.substr(idx + 1);
8242 idx = userinfo.indexOf(':');
8244 res += encoder(userinfo, false, false);
8247 // <user>:<pass>@<auth>
8248 res += encoder(userinfo.substr(0, idx), false, false);
8250 res += encoder(userinfo.substr(idx + 1), false, false);
8254 authority = authority.toLowerCase();
8255 idx = authority.indexOf(':');
8257 res += encoder(authority, false, false);
8261 res += encoder(authority.substr(0, idx), false, false);
8262 res += authority.substr(idx);
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
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
8279 // encode the rest of the path
8280 res += encoder(path, true, false);
8284 res += encoder(query, false, _isQueryStringScheme(scheme));
8288 res += !skipEncoding ? encodeURIComponentFast(fragment, false, false) : fragment;
8297 /***/ (function(module, exports, __webpack_require__) {
8301 Object.defineProperty(exports, "__esModule", { value: true });
8304 const toString = Object.prototype.toString;
8305 function boolean(value) {
8306 return value === true || value === false;
8308 Is.boolean = boolean;
8309 function string(value) {
8310 return toString.call(value) === '[object String]';
8313 })(Is = exports.Is || (exports.Is = {}));
8315 (function (DirectoryItem) {
8317 let candidate = item;
8318 return (candidate &&
8319 Is.string(candidate.directory) &&
8320 (Is.boolean(candidate.changeProcessCWD) ||
8321 candidate.changeProcessCWD === void 0));
8323 DirectoryItem.is = is;
8324 })(DirectoryItem = exports.DirectoryItem || (exports.DirectoryItem = {}));
8325 //# sourceMappingURL=types.js.map
8329 /***/ (function(module, exports, __webpack_require__) {
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')
8342 let content = textDocument.getText();
8343 let newOptions = Object.assign({}, settings.options, {
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)
8351 let { output } = res.results[0];
8354 let change = getChange(content, output);
8357 start: textDocument.positionAt(change.start),
8358 end: textDocument.positionAt(change.end)
8360 newText: change.newText
8363 exports.getAllFixEdits = getAllFixEdits;
8364 function getChange(oldStr, newStr) {
8365 let result = fast_diff_1.default(oldStr, newStr, 1);
8371 for (let item of result) {
8372 let [t, str] = item;
8375 curr = curr + str.length;
8377 remain = remain + str;
8383 newText = newText + remain + str;
8387 newText = newText + remain;
8388 end = curr + str.length;
8392 curr = curr + str.length;
8395 return { start, end, newText };
8397 exports.getChange = getChange;
8398 function resolveModule(name, localPath, globalPath) {
8400 let path = resolve_from_1.default.silent(localPath, name);
8402 return Promise.resolve(path);
8405 let path = resolve_from_1.default(globalPath, name);
8406 return Promise.resolve(path);
8409 return Promise.reject(e);
8412 exports.resolveModule = resolveModule;
8413 //# sourceMappingURL=util.js.map
8417 /***/ (function(module, exports) {
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:
8426 * Diff Match and Patch
8428 * Copyright 2006 Google Inc.
8429 * http://code.google.com/p/google-diff-match-patch/
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
8435 * http://www.apache.org/licenses/LICENSE-2.0
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.
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.'
8450 var DIFF_DELETE = -1;
8451 var DIFF_INSERT = 1;
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.
8463 function diff_main(text1, text2, cursor_pos, _fix_unicode) {
8464 // Check for equality
8465 if (text1 === text2) {
8467 return [[DIFF_EQUAL, text1]];
8472 if (cursor_pos != null) {
8473 var editdiff = find_cursor_edit_diff(text1, text2, cursor_pos);
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);
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);
8491 // Compute the diff on the middle block.
8492 var diffs = diff_compute_(text1, text2);
8494 // Restore the prefix and suffix.
8496 diffs.unshift([DIFF_EQUAL, commonprefix]);
8499 diffs.push([DIFF_EQUAL, commonsuffix]);
8501 diff_cleanupMerge(diffs, _fix_unicode);
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.
8513 function diff_compute_(text1, text2) {
8517 // Just add some text (speedup).
8518 return [[DIFF_INSERT, text2]];
8522 // Just delete some text (speedup).
8523 return [[DIFF_DELETE, text1]];
8526 var longtext = text1.length > text2.length ? text1 : text2;
8527 var shorttext = text1.length > text2.length ? text2 : text1;
8528 var i = longtext.indexOf(shorttext);
8530 // Shorter text is inside the longer text (speedup).
8532 [DIFF_INSERT, longtext.substring(0, i)],
8533 [DIFF_EQUAL, shorttext],
8534 [DIFF_INSERT, longtext.substring(i + shorttext.length)]
8536 // Swap insertions for deletions if diff is reversed.
8537 if (text1.length > text2.length) {
8538 diffs[0][0] = diffs[2][0] = DIFF_DELETE;
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]];
8549 // Check to see if the problem can be split in two.
8550 var hm = diff_halfMatch_(text1, text2);
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);
8565 return diff_bisect_(text1, text2);
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.
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++) {
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.
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;
8610 if (k1 === -d || (k1 !== d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
8611 x1 = v1[k1_offset + 1];
8613 x1 = v1[k1_offset - 1] + 1;
8617 x1 < text1_length && y1 < text2_length &&
8618 text1.charAt(x1) === text2.charAt(y1)
8624 if (x1 > text1_length) {
8625 // Ran off the right of the graph.
8627 } else if (y1 > text2_length) {
8628 // Ran off the bottom of the graph.
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];
8636 // Overlap detected.
8637 return diff_bisectSplit_(text1, text2, x1, y1);
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;
8647 if (k2 === -d || (k2 !== d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
8648 x2 = v2[k2_offset + 1];
8650 x2 = v2[k2_offset - 1] + 1;
8654 x2 < text1_length && y2 < text2_length &&
8655 text1.charAt(text1_length - x2 - 1) === text2.charAt(text2_length - y2 - 1)
8661 if (x2 > text1_length) {
8662 // Ran off the left of the graph.
8664 } else if (y2 > text2_length) {
8665 // Ran off the top of the graph.
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;
8675 // Overlap detected.
8676 return diff_bisectSplit_(text1, text2, x1, y1);
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]];
8689 * Given the location of the 'middle snake', split the diff in two parts
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.
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);
8703 // Compute both diffs serially.
8704 var diffs = diff_main(text1a, text2a);
8705 var diffsb = diff_main(text1b, text2b);
8707 return diffs.concat(diffsb);
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
8718 function diff_commonPrefix(text1, text2) {
8719 // Quick check for common null cases.
8720 if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
8724 // Performance analysis: http://neil.fraser.name/news/2007/10/09/
8726 var pointermax = Math.min(text1.length, text2.length);
8727 var pointermid = pointermax;
8728 var pointerstart = 0;
8729 while (pointermin < pointermid) {
8731 text1.substring(pointerstart, pointermid) ==
8732 text2.substring(pointerstart, pointermid)
8734 pointermin = pointermid;
8735 pointerstart = pointermin;
8737 pointermax = pointermid;
8739 pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
8742 if (is_surrogate_pair_start(text1.charCodeAt(pointermid - 1))) {
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.
8756 function diff_commonSuffix(text1, text2) {
8757 // Quick check for common null cases.
8758 if (!text1 || !text2 || text1.slice(-1) !== text2.slice(-1)) {
8762 // Performance analysis: http://neil.fraser.name/news/2007/10/09/
8764 var pointermax = Math.min(text1.length, text2.length);
8765 var pointermid = pointermax;
8767 while (pointermin < pointermid) {
8769 text1.substring(text1.length - pointermid, text1.length - pointerend) ==
8770 text2.substring(text2.length - pointermid, text2.length - pointerend)
8772 pointermin = pointermid;
8773 pointerend = pointermin;
8775 pointermax = pointermid;
8777 pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
8780 if (is_surrogate_pair_end(text1.charCodeAt(text1.length - pointermid))) {
8789 * Do the two texts share a substring which is at least half the length of the
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.
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.
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.
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));
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);
8837 if (best_common.length * 2 >= longtext.length) {
8839 best_longtext_a, best_longtext_b,
8840 best_shorttext_a, best_shorttext_b, best_common
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));
8859 // Both matched. Select the longest.
8860 hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
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) {
8876 var mid_common = hm[4];
8877 return [text1_a, text1_b, text2_a, text2_b, mid_common];
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
8887 function diff_cleanupMerge(diffs, fix_unicode) {
8888 diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
8890 var count_delete = 0;
8891 var count_insert = 0;
8892 var text_delete = '';
8893 var text_insert = '';
8895 while (pointer < diffs.length) {
8896 if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
8897 diffs.splice(pointer, 1);
8900 switch (diffs[pointer][0]) {
8904 text_insert += diffs[pointer][1];
8909 text_delete += diffs[pointer][1];
8913 var previous_equality = pointer - count_insert - count_delete - 1;
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);
8934 var k = previous_equality - 1;
8935 if (diffs[k] && diffs[k][0] === DIFF_INSERT) {
8937 text_insert = diffs[k][1] + text_insert;
8940 if (diffs[k] && diffs[k][0] === DIFF_DELETE) {
8942 text_delete = diffs[k][1] + text_delete;
8945 previous_equality = k;
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;
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);
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);
8969 diffs.splice(0, 0, [DIFF_EQUAL, text_insert.substring(0, commonlength)]);
8972 text_insert = text_insert.substring(commonlength);
8973 text_delete = text_delete.substring(commonlength);
8975 // Factor out any common suffixes.
8976 commonlength = diff_commonSuffix(text_insert, text_delete);
8977 if (commonlength !== 0) {
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);
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;
8996 diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete], [DIFF_INSERT, text_insert]);
8997 pointer = pointer - n + 2;
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);
9014 if (diffs[diffs.length - 1][1] === '') {
9015 diffs.pop(); // Remove the dummy entry at the end.
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;
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);
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];
9042 diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
9043 diffs[pointer + 1][1];
9044 diffs.splice(pointer + 1, 1);
9050 // If shifts were made, the diff needs reordering and another shift sweep.
9052 diff_cleanupMerge(diffs, fix_unicode);
9056 function is_surrogate_pair_start(charCode) {
9057 return charCode >= 0xD800 && charCode <= 0xDBFF;
9060 function is_surrogate_pair_end(charCode) {
9061 return charCode >= 0xDC00 && charCode <= 0xDFFF;
9064 function starts_with_pair_end(str) {
9065 return is_surrogate_pair_end(str.charCodeAt(0));
9068 function ends_with_pair_start(str) {
9069 return is_surrogate_pair_start(str.charCodeAt(str.length - 1));
9072 function remove_empty_tuples(tuples) {
9074 for (var i = 0; i < tuples.length; i++) {
9075 if (tuples[i][1].length > 0) {
9076 ret.push(tuples[i]);
9082 function make_edit_splice(before, oldMiddle, newMiddle, after) {
9083 if (ends_with_pair_start(before) || starts_with_pair_end(after)) {
9086 return remove_empty_tuples([
9087 [DIFF_EQUAL, before],
9088 [DIFF_DELETE, oldMiddle],
9089 [DIFF_INSERT, newMiddle],
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;
9113 // is this an insert or delete right before oldCursor?
9114 var newCursor = oldCursor + newLength - oldLength;
9115 if (maybeNewCursor !== null && maybeNewCursor !== newCursor) {
9118 if (newCursor < 0 || newCursor > newLength) {
9121 var newBefore = newText.slice(0, newCursor);
9122 var newAfter = newText.slice(newCursor);
9123 if (newAfter !== oldAfter) {
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) {
9132 var oldMiddle = oldBefore.slice(prefixLength);
9133 var newMiddle = newBefore.slice(prefixLength);
9134 return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldAfter);
9137 // is this an insert or delete right after oldCursor?
9138 if (maybeNewCursor !== null && maybeNewCursor !== oldCursor) {
9141 var cursor = oldCursor;
9142 var newBefore = newText.slice(0, cursor);
9143 var newAfter = newText.slice(cursor);
9144 if (newBefore !== oldBefore) {
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) {
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);
9158 if (oldRange.length > 0 && newRange && newRange.length === 0) {
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) {
9168 var newPrefix = newText.slice(0, prefixLength);
9169 var newSuffix = newText.slice(newLength - suffixLength);
9170 if (oldPrefix !== newPrefix || oldSuffix !== newSuffix) {
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);
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);
9188 diff.INSERT = DIFF_INSERT;
9189 diff.DELETE = DIFF_DELETE;
9190 diff.EQUAL = DIFF_EQUAL;
9192 module.exports = diff;
9197 /***/ (function(module, exports, __webpack_require__) {
9201 const path = __webpack_require__(3);
9202 const Module = __webpack_require__(43);
9203 const fs = __webpack_require__(35);
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}\``);
9210 if (typeof moduleId !== 'string') {
9211 throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
9215 fromDirectory = fs.realpathSync(fromDirectory);
9217 if (error.code === 'ENOENT') {
9218 fromDirectory = path.resolve(fromDirectory);
9219 } else if (silent) {
9226 const fromFile = path.join(fromDirectory, 'noop.js');
9228 const resolveFileName = () => Module._resolveFilename(moduleId, {
9231 paths: Module._nodeModulePaths(fromDirectory)
9236 return resolveFileName();
9242 return resolveFileName();
9245 module.exports = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId);
9246 module.exports.silent = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId, true);
9251 /***/ (function(module, exports) {
9253 module.exports = require("module");