1 (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (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__) {
93 Object.defineProperty(exports, "__esModule", { value: true });
94 const tslib_1 = __webpack_require__(1);
95 const coc_nvim_1 = __webpack_require__(2);
96 const fs_1 = tslib_1.__importDefault(__webpack_require__(3));
97 const path_1 = tslib_1.__importDefault(__webpack_require__(4));
98 const vscode_languageserver_protocol_1 = __webpack_require__(5);
99 const utils_1 = __webpack_require__(30);
100 const defaultLanguages = ['javascript', 'javascriptreact'];
103 const toString = Object.prototype.toString;
104 function boolean(value) {
105 return value === true || value === false;
107 Is.boolean = boolean;
108 function string(value) {
109 return toString.call(value) === '[object String]';
113 var OpenESLintDocRequest;
114 (function (OpenESLintDocRequest) {
115 OpenESLintDocRequest.type = new vscode_languageserver_protocol_1.RequestType('eslint/openDoc');
116 })(OpenESLintDocRequest || (OpenESLintDocRequest = {}));
118 (function (DirectoryItem) {
120 let candidate = item;
122 Is.string(candidate.directory) &&
123 (Is.boolean(candidate.changeProcessCWD) ||
124 candidate.changeProcessCWD === void 0));
126 DirectoryItem.is = is;
127 })(DirectoryItem || (DirectoryItem = {}));
129 (function (NoConfigRequest) {
130 NoConfigRequest.type = new vscode_languageserver_protocol_1.RequestType('eslint/noConfig');
131 })(NoConfigRequest || (NoConfigRequest = {}));
132 var NoESLintLibraryRequest;
133 (function (NoESLintLibraryRequest) {
134 NoESLintLibraryRequest.type = new vscode_languageserver_protocol_1.RequestType('eslint/noLibrary');
135 })(NoESLintLibraryRequest || (NoESLintLibraryRequest = {}));
136 const exitCalled = new vscode_languageserver_protocol_1.NotificationType('eslint/exitCalled');
137 function createDefaultConfiguration() {
138 return tslib_1.__awaiter(this, void 0, void 0, function* () {
139 let { root } = coc_nvim_1.workspace;
147 for (let configFile of configFiles) {
148 if (fs_1.default.existsSync(path_1.default.join(root, configFile))) {
149 coc_nvim_1.workspace.openResource(coc_nvim_1.Uri.file(root).toString()).catch(_e => {
155 const eslintCommand = yield utils_1.findEslint(root);
156 yield coc_nvim_1.workspace.nvim.call('coc#util#open_terminal', [{
157 cmd: eslintCommand + ' --init',
162 function shouldBeValidated(textDocument) {
163 let config = coc_nvim_1.workspace.getConfiguration('eslint', textDocument.uri);
164 if (!config.get('enable', true))
166 let filetypes = config.get('filetypes', defaultLanguages);
167 return filetypes.indexOf(textDocument.languageId) !== -1;
169 function activate(context) {
170 return tslib_1.__awaiter(this, void 0, void 0, function* () {
171 let { subscriptions } = context;
172 const config = coc_nvim_1.workspace.getConfiguration().get('eslint', {});
173 const filetypes = config.filetypes || ['javascript', 'javascriptreact'];
174 const selector = filetypes.reduce((res, filetype) => {
175 return res.concat([{ language: filetype, scheme: 'file' }, { language: filetype, scheme: 'untitled' }]);
177 let serverOptions = {
178 module: context.asAbsolutePath('./lib/server/index.js'),
179 args: ['--node-ipc'],
180 transport: coc_nvim_1.TransportKind.ipc,
182 cwd: coc_nvim_1.workspace.root,
183 execArgv: config.execArgv
186 const syncedDocuments = new Map();
187 let clientOptions = {
188 documentSelector: selector,
190 configurationSection: 'eslint',
192 coc_nvim_1.workspace.createFileSystemWatcher('**/.eslintr{c.js,c.yaml,c.yml,c,c.json}'),
193 coc_nvim_1.workspace.createFileSystemWatcher('**/.eslintignore'),
194 coc_nvim_1.workspace.createFileSystemWatcher('**/package.json')
197 outputChannelName: 'eslint',
198 initializationOptions: config.initializationOptions,
199 diagnosticCollectionName: 'eslint',
200 initializationFailedHandler: error => {
201 coc_nvim_1.workspace.showMessage(`Eslint server initialization failed: ${error.message}.`, 'error');
205 didOpen: (document, next) => {
206 if (shouldBeValidated(document)) {
208 syncedDocuments.set(document.uri.toString(), document);
212 didChange: (event, next) => {
213 if (syncedDocuments.has(event.textDocument.uri)) {
217 didClose: (document, next) => {
218 let uri = document.uri.toString();
219 if (syncedDocuments.has(uri)) {
220 syncedDocuments.delete(uri);
224 provideCodeActions: (document, range, context, token, next) => {
225 if (!syncedDocuments.has(document.uri.toString()) || !context.diagnostics || context.diagnostics.length === 0) {
228 let eslintDiagnostics = [];
229 for (let diagnostic of context.diagnostics) {
230 if (diagnostic.source === 'eslint') {
231 eslintDiagnostics.push(diagnostic);
234 if (eslintDiagnostics.length === 0) {
237 let newContext = Object.assign({}, context, {
238 diagnostics: eslintDiagnostics
240 return next(document, range, newContext, token);
243 configuration: (params, _token, _next) => {
244 return params.items.map(item => {
245 let uri = item.scopeUri;
246 let config = coc_nvim_1.workspace.getConfiguration('eslint', uri);
247 let pm = config.get('packageManager', 'npm');
249 packageManager: pm === 'yarn' ? 'yarn' : 'npm',
250 quiet: config.get('quiet', false),
251 validate: config.get('validate', true),
252 autoFix: config.get('autoFix', false),
253 autoFixOnSave: config.get('autoFixOnSave', false),
254 nodePath: config.get('nodePath', undefined),
255 options: config.get('options', {}),
256 run: config.get('run', 'onType'),
257 workspaceFolder: coc_nvim_1.workspace.workspaceFolder,
258 workingDirectory: undefined,
260 disableRuleComment: config.get('codeAction.disableRuleComment', { enable: true, location: 'separateLine' }),
261 showDocumentation: config.get('codeAction.showDocumentation', { enable: true })
270 let client = new coc_nvim_1.LanguageClient('eslint', 'eslint langserver', serverOptions, clientOptions);
271 subscriptions.push(coc_nvim_1.services.registLanguageClient(client));
272 function onDidChangeConfiguration(e) {
273 if (!e.affectsConfiguration('eslint'))
275 if (client.serviceState != coc_nvim_1.ServiceStat.Running)
277 for (let textDocument of syncedDocuments.values()) {
278 if (!shouldBeValidated(textDocument)) {
279 syncedDocuments.delete(textDocument.uri);
280 client.sendNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, { textDocument: { uri: textDocument.uri } });
283 for (let textDocument of coc_nvim_1.workspace.textDocuments) {
284 if (!syncedDocuments.has(textDocument.uri.toString()) && shouldBeValidated(textDocument)) {
285 client.sendNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, {
287 uri: textDocument.uri,
288 languageId: textDocument.languageId,
289 version: textDocument.version,
290 text: textDocument.getText()
293 syncedDocuments.set(textDocument.uri.toString(), textDocument);
297 subscriptions.push(coc_nvim_1.commands.registerCommand('eslint.createConfig', createDefaultConfiguration));
298 subscriptions.push(coc_nvim_1.commands.registerCommand('eslint.executeAutofix', () => tslib_1.__awaiter(this, void 0, void 0, function* () {
299 let document = yield coc_nvim_1.workspace.document;
302 version: document.version
305 command: 'eslint.applyAutoFix',
306 arguments: [textDocument]
308 client.sendRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, params)
309 .then(undefined, () => {
310 coc_nvim_1.workspace.showMessage('Failed to apply ESLint fixes to the document.', 'error');
313 client.onReady().then(() => {
314 client.onNotification(exitCalled, params => {
315 coc_nvim_1.workspace.showMessage(`Server process exited with code ${params[0]}. This usually indicates a misconfigured ESLint setup.`, 'error');
317 client.onRequest(NoConfigRequest.type, params => {
318 let document = coc_nvim_1.Uri.parse(params.document.uri);
319 let fileLocation = document.fsPath;
320 coc_nvim_1.workspace.showMessage(`No ESLint configuration (e.g .eslintrc) found for file: ${fileLocation}`, 'warning');
323 client.onRequest(NoESLintLibraryRequest.type, params => {
324 let uri = coc_nvim_1.Uri.parse(params.source.uri);
325 coc_nvim_1.workspace.showMessage(`Failed to load the ESLint library for the document ${uri.fsPath}`, 'warning');
328 client.onRequest(OpenESLintDocRequest.type, (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
329 yield coc_nvim_1.commands.executeCommand('vscode.open', coc_nvim_1.Uri.parse(params.url));
332 coc_nvim_1.workspace.onDidChangeConfiguration(onDidChangeConfiguration, null, subscriptions);
338 exports.activate = activate;
339 //# sourceMappingURL=index.js.map
343 /***/ (function(module, __webpack_exports__, __webpack_require__) {
346 __webpack_require__.r(__webpack_exports__);
347 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
348 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
349 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
350 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
351 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
352 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
353 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
354 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
355 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
356 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
357 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
358 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
359 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
360 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
361 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
362 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
363 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
364 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
365 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
366 /*! *****************************************************************************
\r
367 Copyright (c) Microsoft Corporation. All rights reserved.
\r
368 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
\r
369 this file except in compliance with the License. You may obtain a copy of the
\r
370 License at http://www.apache.org/licenses/LICENSE-2.0
\r
372 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
\r
373 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
\r
374 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
\r
375 MERCHANTABLITY OR NON-INFRINGEMENT.
\r
377 See the Apache Version 2.0 License for specific language governing permissions
\r
378 and limitations under the License.
\r
379 ***************************************************************************** */
\r
380 /* global Reflect, Promise */
\r
382 var extendStatics = function(d, b) {
\r
383 extendStatics = Object.setPrototypeOf ||
\r
384 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
\r
385 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
\r
386 return extendStatics(d, b);
\r
389 function __extends(d, b) {
\r
390 extendStatics(d, b);
\r
391 function __() { this.constructor = d; }
\r
392 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
\r
395 var __assign = function() {
\r
396 __assign = Object.assign || function __assign(t) {
\r
397 for (var s, i = 1, n = arguments.length; i < n; i++) {
\r
399 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
\r
403 return __assign.apply(this, arguments);
\r
406 function __rest(s, e) {
\r
408 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
\r
410 if (s != null && typeof Object.getOwnPropertySymbols === "function")
\r
411 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
\r
416 function __decorate(decorators, target, key, desc) {
\r
417 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
\r
418 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
\r
419 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
420 return c > 3 && r && Object.defineProperty(target, key, r), r;
\r
423 function __param(paramIndex, decorator) {
\r
424 return function (target, key) { decorator(target, key, paramIndex); }
\r
427 function __metadata(metadataKey, metadataValue) {
\r
428 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
\r
431 function __awaiter(thisArg, _arguments, P, generator) {
\r
432 return new (P || (P = Promise))(function (resolve, reject) {
\r
433 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
\r
434 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
\r
435 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
\r
436 step((generator = generator.apply(thisArg, _arguments || [])).next());
\r
440 function __generator(thisArg, body) {
\r
441 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
\r
442 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
\r
443 function verb(n) { return function (v) { return step([n, v]); }; }
\r
444 function step(op) {
\r
445 if (f) throw new TypeError("Generator is already executing.");
\r
447 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
448 if (y = 0, t) op = [op[0] & 2, t.value];
\r
450 case 0: case 1: t = op; break;
\r
451 case 4: _.label++; return { value: op[1], done: false };
\r
452 case 5: _.label++; y = op[1]; op = [0]; continue;
\r
453 case 7: op = _.ops.pop(); _.trys.pop(); continue;
\r
455 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
\r
456 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
\r
457 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
\r
458 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
\r
459 if (t[2]) _.ops.pop();
\r
460 _.trys.pop(); continue;
\r
462 op = body.call(thisArg, _);
\r
463 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
\r
464 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
\r
468 function __exportStar(m, exports) {
\r
469 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
472 function __values(o) {
\r
473 var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
\r
474 if (m) return m.call(o);
\r
476 next: function () {
\r
477 if (o && i >= o.length) o = void 0;
\r
478 return { value: o && o[i++], done: !o };
\r
483 function __read(o, n) {
\r
484 var m = typeof Symbol === "function" && o[Symbol.iterator];
\r
486 var i = m.call(o), r, ar = [], e;
\r
488 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
\r
490 catch (error) { e = { error: error }; }
\r
493 if (r && !r.done && (m = i["return"])) m.call(i);
\r
495 finally { if (e) throw e.error; }
\r
500 function __spread() {
\r
501 for (var ar = [], i = 0; i < arguments.length; i++)
\r
502 ar = ar.concat(__read(arguments[i]));
\r
506 function __await(v) {
\r
507 return this instanceof __await ? (this.v = v, this) : new __await(v);
\r
510 function __asyncGenerator(thisArg, _arguments, generator) {
\r
511 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
\r
512 var g = generator.apply(thisArg, _arguments || []), i, q = [];
\r
513 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
\r
514 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
515 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
\r
516 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
\r
517 function fulfill(value) { resume("next", value); }
\r
518 function reject(value) { resume("throw", value); }
\r
519 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
\r
522 function __asyncDelegator(o) {
\r
524 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
\r
525 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
528 function __asyncValues(o) {
\r
529 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
\r
530 var m = o[Symbol.asyncIterator], i;
\r
531 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
532 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
533 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
\r
536 function __makeTemplateObject(cooked, raw) {
\r
537 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
\r
541 function __importStar(mod) {
\r
542 if (mod && mod.__esModule) return mod;
\r
544 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
\r
545 result.default = mod;
\r
549 function __importDefault(mod) {
\r
550 return (mod && mod.__esModule) ? mod : { default: mod };
\r
556 /***/ (function(module, exports) {
558 module.exports = require("coc.nvim");
562 /***/ (function(module, exports) {
564 module.exports = require("fs");
568 /***/ (function(module, exports) {
570 module.exports = require("path");
574 /***/ (function(module, exports, __webpack_require__) {
577 /* --------------------------------------------------------------------------------------------
\r
578 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
579 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
580 * ------------------------------------------------------------------------------------------ */
\r
582 function __export(m) {
\r
583 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
585 Object.defineProperty(exports, "__esModule", { value: true });
\r
586 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
587 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
\r
588 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
\r
589 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
\r
590 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
\r
591 exports.Disposable = vscode_jsonrpc_1.Disposable;
\r
592 exports.Event = vscode_jsonrpc_1.Event;
\r
593 exports.Emitter = vscode_jsonrpc_1.Emitter;
\r
594 exports.Trace = vscode_jsonrpc_1.Trace;
\r
595 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
\r
596 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
\r
597 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
\r
598 exports.RequestType = vscode_jsonrpc_1.RequestType;
\r
599 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
\r
600 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
\r
601 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
\r
602 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
\r
603 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
\r
604 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
\r
605 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
\r
606 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
\r
607 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
\r
608 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
\r
609 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
\r
610 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
\r
611 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
\r
612 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
\r
613 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
\r
614 __export(__webpack_require__(19));
\r
615 __export(__webpack_require__(20));
\r
616 function createProtocolConnection(reader, writer, logger, strategy) {
\r
617 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
\r
619 exports.createProtocolConnection = createProtocolConnection;
\r
624 /***/ (function(module, exports, __webpack_require__) {
627 /* --------------------------------------------------------------------------------------------
\r
628 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
629 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
630 * ------------------------------------------------------------------------------------------ */
\r
631 /// <reference path="./thenable.ts" />
\r
633 function __export(m) {
\r
634 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
636 Object.defineProperty(exports, "__esModule", { value: true });
\r
637 const Is = __webpack_require__(7);
\r
638 const messages_1 = __webpack_require__(8);
\r
639 exports.RequestType = messages_1.RequestType;
\r
640 exports.RequestType0 = messages_1.RequestType0;
\r
641 exports.RequestType1 = messages_1.RequestType1;
\r
642 exports.RequestType2 = messages_1.RequestType2;
\r
643 exports.RequestType3 = messages_1.RequestType3;
\r
644 exports.RequestType4 = messages_1.RequestType4;
\r
645 exports.RequestType5 = messages_1.RequestType5;
\r
646 exports.RequestType6 = messages_1.RequestType6;
\r
647 exports.RequestType7 = messages_1.RequestType7;
\r
648 exports.RequestType8 = messages_1.RequestType8;
\r
649 exports.RequestType9 = messages_1.RequestType9;
\r
650 exports.ResponseError = messages_1.ResponseError;
\r
651 exports.ErrorCodes = messages_1.ErrorCodes;
\r
652 exports.NotificationType = messages_1.NotificationType;
\r
653 exports.NotificationType0 = messages_1.NotificationType0;
\r
654 exports.NotificationType1 = messages_1.NotificationType1;
\r
655 exports.NotificationType2 = messages_1.NotificationType2;
\r
656 exports.NotificationType3 = messages_1.NotificationType3;
\r
657 exports.NotificationType4 = messages_1.NotificationType4;
\r
658 exports.NotificationType5 = messages_1.NotificationType5;
\r
659 exports.NotificationType6 = messages_1.NotificationType6;
\r
660 exports.NotificationType7 = messages_1.NotificationType7;
\r
661 exports.NotificationType8 = messages_1.NotificationType8;
\r
662 exports.NotificationType9 = messages_1.NotificationType9;
\r
663 const messageReader_1 = __webpack_require__(9);
\r
664 exports.MessageReader = messageReader_1.MessageReader;
\r
665 exports.StreamMessageReader = messageReader_1.StreamMessageReader;
\r
666 exports.IPCMessageReader = messageReader_1.IPCMessageReader;
\r
667 exports.SocketMessageReader = messageReader_1.SocketMessageReader;
\r
668 const messageWriter_1 = __webpack_require__(11);
\r
669 exports.MessageWriter = messageWriter_1.MessageWriter;
\r
670 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
\r
671 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
\r
672 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
\r
673 const events_1 = __webpack_require__(10);
\r
674 exports.Disposable = events_1.Disposable;
\r
675 exports.Event = events_1.Event;
\r
676 exports.Emitter = events_1.Emitter;
\r
677 const cancellation_1 = __webpack_require__(12);
\r
678 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
\r
679 exports.CancellationToken = cancellation_1.CancellationToken;
\r
680 const linkedMap_1 = __webpack_require__(13);
\r
681 __export(__webpack_require__(14));
\r
682 __export(__webpack_require__(18));
\r
683 var CancelNotification;
\r
684 (function (CancelNotification) {
\r
685 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
\r
686 })(CancelNotification || (CancelNotification = {}));
\r
687 exports.NullLogger = Object.freeze({
\r
694 (function (Trace) {
\r
695 Trace[Trace["Off"] = 0] = "Off";
\r
696 Trace[Trace["Messages"] = 1] = "Messages";
\r
697 Trace[Trace["Verbose"] = 2] = "Verbose";
\r
698 })(Trace = exports.Trace || (exports.Trace = {}));
\r
699 (function (Trace) {
\r
700 function fromString(value) {
\r
701 value = value.toLowerCase();
\r
706 return Trace.Messages;
\r
708 return Trace.Verbose;
\r
713 Trace.fromString = fromString;
\r
714 function toString(value) {
\r
718 case Trace.Messages:
\r
720 case Trace.Verbose:
\r
726 Trace.toString = toString;
\r
727 })(Trace = exports.Trace || (exports.Trace = {}));
\r
729 (function (TraceFormat) {
\r
730 TraceFormat["Text"] = "text";
\r
731 TraceFormat["JSON"] = "json";
\r
732 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
733 (function (TraceFormat) {
\r
734 function fromString(value) {
\r
735 value = value.toLowerCase();
\r
736 if (value === 'json') {
\r
737 return TraceFormat.JSON;
\r
740 return TraceFormat.Text;
\r
743 TraceFormat.fromString = fromString;
\r
744 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
745 var SetTraceNotification;
\r
746 (function (SetTraceNotification) {
\r
747 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
\r
748 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
\r
749 var LogTraceNotification;
\r
750 (function (LogTraceNotification) {
\r
751 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
\r
752 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
\r
753 var ConnectionErrors;
\r
754 (function (ConnectionErrors) {
\r
756 * The connection is closed.
\r
758 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
760 * The connection got disposed.
\r
762 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
764 * The connection is already in listening mode.
\r
766 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
\r
767 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
\r
768 class ConnectionError extends Error {
\r
769 constructor(code, message) {
\r
772 Object.setPrototypeOf(this, ConnectionError.prototype);
\r
775 exports.ConnectionError = ConnectionError;
\r
776 var ConnectionStrategy;
\r
777 (function (ConnectionStrategy) {
\r
778 function is(value) {
\r
779 let candidate = value;
\r
780 return candidate && Is.func(candidate.cancelUndispatched);
\r
782 ConnectionStrategy.is = is;
\r
783 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
\r
784 var ConnectionState;
\r
785 (function (ConnectionState) {
\r
786 ConnectionState[ConnectionState["New"] = 1] = "New";
\r
787 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
\r
788 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
\r
789 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
\r
790 })(ConnectionState || (ConnectionState = {}));
\r
791 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
\r
792 let sequenceNumber = 0;
\r
793 let notificationSquenceNumber = 0;
\r
794 let unknownResponseSquenceNumber = 0;
\r
795 const version = '2.0';
\r
796 let starRequestHandler = undefined;
\r
797 let requestHandlers = Object.create(null);
\r
798 let starNotificationHandler = undefined;
\r
799 let notificationHandlers = Object.create(null);
\r
801 let messageQueue = new linkedMap_1.LinkedMap();
\r
802 let responsePromises = Object.create(null);
\r
803 let requestTokens = Object.create(null);
\r
804 let trace = Trace.Off;
\r
805 let traceFormat = TraceFormat.Text;
\r
807 let state = ConnectionState.New;
\r
808 let errorEmitter = new events_1.Emitter();
\r
809 let closeEmitter = new events_1.Emitter();
\r
810 let unhandledNotificationEmitter = new events_1.Emitter();
\r
811 let disposeEmitter = new events_1.Emitter();
\r
812 function createRequestQueueKey(id) {
\r
813 return 'req-' + id.toString();
\r
815 function createResponseQueueKey(id) {
\r
817 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
820 return 'res-' + id.toString();
\r
823 function createNotificationQueueKey() {
\r
824 return 'not-' + (++notificationSquenceNumber).toString();
\r
826 function addMessageToQueue(queue, message) {
\r
827 if (messages_1.isRequestMessage(message)) {
\r
828 queue.set(createRequestQueueKey(message.id), message);
\r
830 else if (messages_1.isResponseMessage(message)) {
\r
831 queue.set(createResponseQueueKey(message.id), message);
\r
834 queue.set(createNotificationQueueKey(), message);
\r
837 function cancelUndispatched(_message) {
\r
840 function isListening() {
\r
841 return state === ConnectionState.Listening;
\r
843 function isClosed() {
\r
844 return state === ConnectionState.Closed;
\r
846 function isDisposed() {
\r
847 return state === ConnectionState.Disposed;
\r
849 function closeHandler() {
\r
850 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
851 state = ConnectionState.Closed;
\r
852 closeEmitter.fire(undefined);
\r
854 // If the connection is disposed don't sent close events.
\r
857 function readErrorHandler(error) {
\r
858 errorEmitter.fire([error, undefined, undefined]);
\r
860 function writeErrorHandler(data) {
\r
861 errorEmitter.fire(data);
\r
863 messageReader.onClose(closeHandler);
\r
864 messageReader.onError(readErrorHandler);
\r
865 messageWriter.onClose(closeHandler);
\r
866 messageWriter.onError(writeErrorHandler);
\r
867 function triggerMessageQueue() {
\r
868 if (timer || messageQueue.size === 0) {
\r
871 timer = setImmediate(() => {
\r
873 processMessageQueue();
\r
876 function processMessageQueue() {
\r
877 if (messageQueue.size === 0) {
\r
880 let message = messageQueue.shift();
\r
882 if (messages_1.isRequestMessage(message)) {
\r
883 handleRequest(message);
\r
885 else if (messages_1.isNotificationMessage(message)) {
\r
886 handleNotification(message);
\r
888 else if (messages_1.isResponseMessage(message)) {
\r
889 handleResponse(message);
\r
892 handleInvalidMessage(message);
\r
896 triggerMessageQueue();
\r
899 let callback = (message) => {
\r
901 // We have received a cancellation message. Check if the message is still in the queue
\r
902 // and cancel it if allowed to do so.
\r
903 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
\r
904 let key = createRequestQueueKey(message.params.id);
\r
905 let toCancel = messageQueue.get(key);
\r
906 if (messages_1.isRequestMessage(toCancel)) {
\r
907 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
\r
908 if (response && (response.error !== void 0 || response.result !== void 0)) {
\r
909 messageQueue.delete(key);
\r
910 response.id = toCancel.id;
\r
911 traceSendingResponse(response, message.method, Date.now());
\r
912 messageWriter.write(response);
\r
917 addMessageToQueue(messageQueue, message);
\r
920 triggerMessageQueue();
\r
923 function handleRequest(requestMessage) {
\r
924 if (isDisposed()) {
\r
925 // we return here silently since we fired an event when the
\r
926 // connection got disposed.
\r
929 function reply(resultOrError, method, startTime) {
\r
932 id: requestMessage.id
\r
934 if (resultOrError instanceof messages_1.ResponseError) {
\r
935 message.error = resultOrError.toJson();
\r
938 message.result = resultOrError === void 0 ? null : resultOrError;
\r
940 traceSendingResponse(message, method, startTime);
\r
941 messageWriter.write(message);
\r
943 function replyError(error, method, startTime) {
\r
946 id: requestMessage.id,
\r
947 error: error.toJson()
\r
949 traceSendingResponse(message, method, startTime);
\r
950 messageWriter.write(message);
\r
952 function replySuccess(result, method, startTime) {
\r
953 // The JSON RPC defines that a response must either have a result or an error
\r
954 // So we can't treat undefined as a valid response result.
\r
955 if (result === void 0) {
\r
960 id: requestMessage.id,
\r
963 traceSendingResponse(message, method, startTime);
\r
964 messageWriter.write(message);
\r
966 traceReceivedRequest(requestMessage);
\r
967 let element = requestHandlers[requestMessage.method];
\r
969 let requestHandler;
\r
971 type = element.type;
\r
972 requestHandler = element.handler;
\r
974 let startTime = Date.now();
\r
975 if (requestHandler || starRequestHandler) {
\r
976 let cancellationSource = new cancellation_1.CancellationTokenSource();
\r
977 let tokenKey = String(requestMessage.id);
\r
978 requestTokens[tokenKey] = cancellationSource;
\r
981 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
982 handlerResult = requestHandler
\r
983 ? requestHandler(cancellationSource.token)
\r
984 : starRequestHandler(requestMessage.method, cancellationSource.token);
\r
986 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
987 handlerResult = requestHandler
\r
988 ? requestHandler(...requestMessage.params, cancellationSource.token)
\r
989 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
\r
992 handlerResult = requestHandler
\r
993 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
994 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
996 let promise = handlerResult;
\r
997 if (!handlerResult) {
\r
998 delete requestTokens[tokenKey];
\r
999 replySuccess(handlerResult, requestMessage.method, startTime);
\r
1001 else if (promise.then) {
\r
1002 promise.then((resultOrError) => {
\r
1003 delete requestTokens[tokenKey];
\r
1004 reply(resultOrError, requestMessage.method, startTime);
\r
1006 delete requestTokens[tokenKey];
\r
1007 if (error instanceof messages_1.ResponseError) {
\r
1008 replyError(error, requestMessage.method, startTime);
\r
1010 else if (error && Is.string(error.message)) {
\r
1011 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
1014 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
1019 delete requestTokens[tokenKey];
\r
1020 reply(handlerResult, requestMessage.method, startTime);
\r
1024 delete requestTokens[tokenKey];
\r
1025 if (error instanceof messages_1.ResponseError) {
\r
1026 reply(error, requestMessage.method, startTime);
\r
1028 else if (error && Is.string(error.message)) {
\r
1029 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
1032 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
1037 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
1040 function handleResponse(responseMessage) {
\r
1041 if (isDisposed()) {
\r
1042 // See handle request.
\r
1045 if (responseMessage.id === null) {
\r
1046 if (responseMessage.error) {
\r
1047 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
\r
1050 logger.error(`Received response message without id. No further error information provided.`);
\r
1054 let key = String(responseMessage.id);
\r
1055 let responsePromise = responsePromises[key];
\r
1056 traceReceivedResponse(responseMessage, responsePromise);
\r
1057 if (responsePromise) {
\r
1058 delete responsePromises[key];
\r
1060 if (responseMessage.error) {
\r
1061 let error = responseMessage.error;
\r
1062 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
\r
1064 else if (responseMessage.result !== void 0) {
\r
1065 responsePromise.resolve(responseMessage.result);
\r
1068 throw new Error('Should never happen.');
\r
1072 if (error.message) {
\r
1073 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
1076 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
1082 function handleNotification(message) {
\r
1083 if (isDisposed()) {
\r
1084 // See handle request.
\r
1087 let type = undefined;
\r
1088 let notificationHandler;
\r
1089 if (message.method === CancelNotification.type.method) {
\r
1090 notificationHandler = (params) => {
\r
1091 let id = params.id;
\r
1092 let source = requestTokens[String(id)];
\r
1099 let element = notificationHandlers[message.method];
\r
1101 notificationHandler = element.handler;
\r
1102 type = element.type;
\r
1105 if (notificationHandler || starNotificationHandler) {
\r
1107 traceReceivedNotification(message);
\r
1108 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
1109 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
\r
1111 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
1112 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
\r
1115 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
1119 if (error.message) {
\r
1120 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
1123 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
1128 unhandledNotificationEmitter.fire(message);
\r
1131 function handleInvalidMessage(message) {
\r
1133 logger.error('Received empty message.');
\r
1136 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
\r
1137 // Test whether we find an id to reject the promise
\r
1138 let responseMessage = message;
\r
1139 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
\r
1140 let key = String(responseMessage.id);
\r
1141 let responseHandler = responsePromises[key];
\r
1142 if (responseHandler) {
\r
1143 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
\r
1147 function traceSendingRequest(message) {
\r
1148 if (trace === Trace.Off || !tracer) {
\r
1151 if (traceFormat === TraceFormat.Text) {
\r
1152 let data = undefined;
\r
1153 if (trace === Trace.Verbose && message.params) {
\r
1154 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1156 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
1159 logLSPMessage('send-request', message);
\r
1162 function traceSendingNotification(message) {
\r
1163 if (trace === Trace.Off || !tracer) {
\r
1166 if (traceFormat === TraceFormat.Text) {
\r
1167 let data = undefined;
\r
1168 if (trace === Trace.Verbose) {
\r
1169 if (message.params) {
\r
1170 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1173 data = 'No parameters provided.\n\n';
\r
1176 tracer.log(`Sending notification '${message.method}'.`, data);
\r
1179 logLSPMessage('send-notification', message);
\r
1182 function traceSendingResponse(message, method, startTime) {
\r
1183 if (trace === Trace.Off || !tracer) {
\r
1186 if (traceFormat === TraceFormat.Text) {
\r
1187 let data = undefined;
\r
1188 if (trace === Trace.Verbose) {
\r
1189 if (message.error && message.error.data) {
\r
1190 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
1193 if (message.result) {
\r
1194 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
1196 else if (message.error === void 0) {
\r
1197 data = 'No result returned.\n\n';
\r
1201 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
1204 logLSPMessage('send-response', message);
\r
1207 function traceReceivedRequest(message) {
\r
1208 if (trace === Trace.Off || !tracer) {
\r
1211 if (traceFormat === TraceFormat.Text) {
\r
1212 let data = undefined;
\r
1213 if (trace === Trace.Verbose && message.params) {
\r
1214 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1216 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
1219 logLSPMessage('receive-request', message);
\r
1222 function traceReceivedNotification(message) {
\r
1223 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\r
1226 if (traceFormat === TraceFormat.Text) {
\r
1227 let data = undefined;
\r
1228 if (trace === Trace.Verbose) {
\r
1229 if (message.params) {
\r
1230 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1233 data = 'No parameters provided.\n\n';
\r
1236 tracer.log(`Received notification '${message.method}'.`, data);
\r
1239 logLSPMessage('receive-notification', message);
\r
1242 function traceReceivedResponse(message, responsePromise) {
\r
1243 if (trace === Trace.Off || !tracer) {
\r
1246 if (traceFormat === TraceFormat.Text) {
\r
1247 let data = undefined;
\r
1248 if (trace === Trace.Verbose) {
\r
1249 if (message.error && message.error.data) {
\r
1250 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
1253 if (message.result) {
\r
1254 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
1256 else if (message.error === void 0) {
\r
1257 data = 'No result returned.\n\n';
\r
1261 if (responsePromise) {
\r
1262 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
\r
1263 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
\r
1266 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
1270 logLSPMessage('receive-response', message);
\r
1273 function logLSPMessage(type, message) {
\r
1274 if (!tracer || trace === Trace.Off) {
\r
1277 const lspMessage = {
\r
1278 isLSPMessage: true,
\r
1281 timestamp: Date.now()
\r
1283 tracer.log(lspMessage);
\r
1285 function throwIfClosedOrDisposed() {
\r
1287 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
1289 if (isDisposed()) {
\r
1290 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
1293 function throwIfListening() {
\r
1294 if (isListening()) {
\r
1295 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
1298 function throwIfNotListening() {
\r
1299 if (!isListening()) {
\r
1300 throw new Error('Call listen() first.');
\r
1303 function undefinedToNull(param) {
\r
1304 if (param === void 0) {
\r
1311 function computeMessageParams(type, params) {
\r
1313 let numberOfParams = type.numberOfParams;
\r
1314 switch (numberOfParams) {
\r
1319 result = undefinedToNull(params[0]);
\r
1323 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
1324 result.push(undefinedToNull(params[i]));
\r
1326 if (params.length < numberOfParams) {
\r
1327 for (let i = params.length; i < numberOfParams; i++) {
\r
1328 result.push(null);
\r
1335 let connection = {
\r
1336 sendNotification: (type, ...params) => {
\r
1337 throwIfClosedOrDisposed();
\r
1339 let messageParams;
\r
1340 if (Is.string(type)) {
\r
1342 switch (params.length) {
\r
1344 messageParams = null;
\r
1347 messageParams = params[0];
\r
1350 messageParams = params;
\r
1355 method = type.method;
\r
1356 messageParams = computeMessageParams(type, params);
\r
1358 let notificationMessage = {
\r
1361 params: messageParams
\r
1363 traceSendingNotification(notificationMessage);
\r
1364 messageWriter.write(notificationMessage);
\r
1366 onNotification: (type, handler) => {
\r
1367 throwIfClosedOrDisposed();
\r
1368 if (Is.func(type)) {
\r
1369 starNotificationHandler = type;
\r
1371 else if (handler) {
\r
1372 if (Is.string(type)) {
\r
1373 notificationHandlers[type] = { type: undefined, handler };
\r
1376 notificationHandlers[type.method] = { type, handler };
\r
1380 sendRequest: (type, ...params) => {
\r
1381 throwIfClosedOrDisposed();
\r
1382 throwIfNotListening();
\r
1384 let messageParams;
\r
1385 let token = undefined;
\r
1386 if (Is.string(type)) {
\r
1388 switch (params.length) {
\r
1390 messageParams = null;
\r
1393 // The cancellation token is optional so it can also be undefined.
\r
1394 if (cancellation_1.CancellationToken.is(params[0])) {
\r
1395 messageParams = null;
\r
1396 token = params[0];
\r
1399 messageParams = undefinedToNull(params[0]);
\r
1403 const last = params.length - 1;
\r
1404 if (cancellation_1.CancellationToken.is(params[last])) {
\r
1405 token = params[last];
\r
1406 if (params.length === 2) {
\r
1407 messageParams = undefinedToNull(params[0]);
\r
1410 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
1414 messageParams = params.map(value => undefinedToNull(value));
\r
1420 method = type.method;
\r
1421 messageParams = computeMessageParams(type, params);
\r
1422 let numberOfParams = type.numberOfParams;
\r
1423 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
\r
1425 let id = sequenceNumber++;
\r
1426 let result = new Promise((resolve, reject) => {
\r
1427 let requestMessage = {
\r
1431 params: messageParams
\r
1433 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
1434 traceSendingRequest(requestMessage);
\r
1436 messageWriter.write(requestMessage);
\r
1439 // Writing the message failed. So we need to reject the promise.
\r
1440 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
\r
1441 responsePromise = null;
\r
1443 if (responsePromise) {
\r
1444 responsePromises[String(id)] = responsePromise;
\r
1448 token.onCancellationRequested(() => {
\r
1449 connection.sendNotification(CancelNotification.type, { id });
\r
1454 onRequest: (type, handler) => {
\r
1455 throwIfClosedOrDisposed();
\r
1456 if (Is.func(type)) {
\r
1457 starRequestHandler = type;
\r
1459 else if (handler) {
\r
1460 if (Is.string(type)) {
\r
1461 requestHandlers[type] = { type: undefined, handler };
\r
1464 requestHandlers[type.method] = { type, handler };
\r
1468 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
\r
1469 let _sendNotification = false;
\r
1470 let _traceFormat = TraceFormat.Text;
\r
1471 if (sendNotificationOrTraceOptions !== void 0) {
\r
1472 if (Is.boolean(sendNotificationOrTraceOptions)) {
\r
1473 _sendNotification = sendNotificationOrTraceOptions;
\r
1476 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
1477 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
1481 traceFormat = _traceFormat;
\r
1482 if (trace === Trace.Off) {
\r
1483 tracer = undefined;
\r
1488 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
1489 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
1492 onError: errorEmitter.event,
\r
1493 onClose: closeEmitter.event,
\r
1494 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
1495 onDispose: disposeEmitter.event,
\r
1497 if (isDisposed()) {
\r
1500 state = ConnectionState.Disposed;
\r
1501 disposeEmitter.fire(undefined);
\r
1502 let error = new Error('Connection got disposed.');
\r
1503 Object.keys(responsePromises).forEach((key) => {
\r
1504 responsePromises[key].reject(error);
\r
1506 responsePromises = Object.create(null);
\r
1507 requestTokens = Object.create(null);
\r
1508 messageQueue = new linkedMap_1.LinkedMap();
\r
1509 // Test for backwards compatibility
\r
1510 if (Is.func(messageWriter.dispose)) {
\r
1511 messageWriter.dispose();
\r
1513 if (Is.func(messageReader.dispose)) {
\r
1514 messageReader.dispose();
\r
1518 throwIfClosedOrDisposed();
\r
1519 throwIfListening();
\r
1520 state = ConnectionState.Listening;
\r
1521 messageReader.listen(callback);
\r
1524 console.log("inspect");
\r
1527 connection.onNotification(LogTraceNotification.type, (params) => {
\r
1528 if (trace === Trace.Off || !tracer) {
\r
1531 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
1533 return connection;
\r
1535 function isMessageReader(value) {
\r
1536 return value.listen !== void 0 && value.read === void 0;
\r
1538 function isMessageWriter(value) {
\r
1539 return value.write !== void 0 && value.end === void 0;
\r
1541 function createMessageConnection(input, output, logger, strategy) {
\r
1543 logger = exports.NullLogger;
\r
1545 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
\r
1546 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
\r
1547 return _createMessageConnection(reader, writer, logger, strategy);
\r
1549 exports.createMessageConnection = createMessageConnection;
\r
1554 /***/ (function(module, exports, __webpack_require__) {
1557 /* --------------------------------------------------------------------------------------------
\r
1558 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1559 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1560 * ------------------------------------------------------------------------------------------ */
\r
1562 Object.defineProperty(exports, "__esModule", { value: true });
\r
1563 function boolean(value) {
\r
1564 return value === true || value === false;
\r
1566 exports.boolean = boolean;
\r
1567 function string(value) {
\r
1568 return typeof value === 'string' || value instanceof String;
\r
1570 exports.string = string;
\r
1571 function number(value) {
\r
1572 return typeof value === 'number' || value instanceof Number;
\r
1574 exports.number = number;
\r
1575 function error(value) {
\r
1576 return value instanceof Error;
\r
1578 exports.error = error;
\r
1579 function func(value) {
\r
1580 return typeof value === 'function';
\r
1582 exports.func = func;
\r
1583 function array(value) {
\r
1584 return Array.isArray(value);
\r
1586 exports.array = array;
\r
1587 function stringArray(value) {
\r
1588 return array(value) && value.every(elem => string(elem));
\r
1590 exports.stringArray = stringArray;
\r
1595 /***/ (function(module, exports, __webpack_require__) {
1598 /* --------------------------------------------------------------------------------------------
\r
1599 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1600 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1601 * ------------------------------------------------------------------------------------------ */
\r
1603 Object.defineProperty(exports, "__esModule", { value: true });
\r
1604 const is = __webpack_require__(7);
\r
1606 * Predefined error codes.
\r
1609 (function (ErrorCodes) {
\r
1610 // Defined by JSON RPC
\r
1611 ErrorCodes.ParseError = -32700;
\r
1612 ErrorCodes.InvalidRequest = -32600;
\r
1613 ErrorCodes.MethodNotFound = -32601;
\r
1614 ErrorCodes.InvalidParams = -32602;
\r
1615 ErrorCodes.InternalError = -32603;
\r
1616 ErrorCodes.serverErrorStart = -32099;
\r
1617 ErrorCodes.serverErrorEnd = -32000;
\r
1618 ErrorCodes.ServerNotInitialized = -32002;
\r
1619 ErrorCodes.UnknownErrorCode = -32001;
\r
1620 // Defined by the protocol.
\r
1621 ErrorCodes.RequestCancelled = -32800;
\r
1622 // Defined by VSCode library.
\r
1623 ErrorCodes.MessageWriteError = 1;
\r
1624 ErrorCodes.MessageReadError = 2;
\r
1625 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
\r
1627 * An error object return in a response in case a request
\r
1630 class ResponseError extends Error {
\r
1631 constructor(code, message, data) {
\r
1633 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
1635 Object.setPrototypeOf(this, ResponseError.prototype);
\r
1640 message: this.message,
\r
1645 exports.ResponseError = ResponseError;
\r
1647 * An abstract implementation of a MessageType.
\r
1649 class AbstractMessageType {
\r
1650 constructor(_method, _numberOfParams) {
\r
1651 this._method = _method;
\r
1652 this._numberOfParams = _numberOfParams;
\r
1655 return this._method;
\r
1657 get numberOfParams() {
\r
1658 return this._numberOfParams;
\r
1661 exports.AbstractMessageType = AbstractMessageType;
\r
1663 * Classes to type request response pairs
\r
1665 class RequestType0 extends AbstractMessageType {
\r
1666 constructor(method) {
\r
1668 this._ = undefined;
\r
1671 exports.RequestType0 = RequestType0;
\r
1672 class RequestType extends AbstractMessageType {
\r
1673 constructor(method) {
\r
1675 this._ = undefined;
\r
1678 exports.RequestType = RequestType;
\r
1679 class RequestType1 extends AbstractMessageType {
\r
1680 constructor(method) {
\r
1682 this._ = undefined;
\r
1685 exports.RequestType1 = RequestType1;
\r
1686 class RequestType2 extends AbstractMessageType {
\r
1687 constructor(method) {
\r
1689 this._ = undefined;
\r
1692 exports.RequestType2 = RequestType2;
\r
1693 class RequestType3 extends AbstractMessageType {
\r
1694 constructor(method) {
\r
1696 this._ = undefined;
\r
1699 exports.RequestType3 = RequestType3;
\r
1700 class RequestType4 extends AbstractMessageType {
\r
1701 constructor(method) {
\r
1703 this._ = undefined;
\r
1706 exports.RequestType4 = RequestType4;
\r
1707 class RequestType5 extends AbstractMessageType {
\r
1708 constructor(method) {
\r
1710 this._ = undefined;
\r
1713 exports.RequestType5 = RequestType5;
\r
1714 class RequestType6 extends AbstractMessageType {
\r
1715 constructor(method) {
\r
1717 this._ = undefined;
\r
1720 exports.RequestType6 = RequestType6;
\r
1721 class RequestType7 extends AbstractMessageType {
\r
1722 constructor(method) {
\r
1724 this._ = undefined;
\r
1727 exports.RequestType7 = RequestType7;
\r
1728 class RequestType8 extends AbstractMessageType {
\r
1729 constructor(method) {
\r
1731 this._ = undefined;
\r
1734 exports.RequestType8 = RequestType8;
\r
1735 class RequestType9 extends AbstractMessageType {
\r
1736 constructor(method) {
\r
1738 this._ = undefined;
\r
1741 exports.RequestType9 = RequestType9;
\r
1742 class NotificationType extends AbstractMessageType {
\r
1743 constructor(method) {
\r
1745 this._ = undefined;
\r
1748 exports.NotificationType = NotificationType;
\r
1749 class NotificationType0 extends AbstractMessageType {
\r
1750 constructor(method) {
\r
1752 this._ = undefined;
\r
1755 exports.NotificationType0 = NotificationType0;
\r
1756 class NotificationType1 extends AbstractMessageType {
\r
1757 constructor(method) {
\r
1759 this._ = undefined;
\r
1762 exports.NotificationType1 = NotificationType1;
\r
1763 class NotificationType2 extends AbstractMessageType {
\r
1764 constructor(method) {
\r
1766 this._ = undefined;
\r
1769 exports.NotificationType2 = NotificationType2;
\r
1770 class NotificationType3 extends AbstractMessageType {
\r
1771 constructor(method) {
\r
1773 this._ = undefined;
\r
1776 exports.NotificationType3 = NotificationType3;
\r
1777 class NotificationType4 extends AbstractMessageType {
\r
1778 constructor(method) {
\r
1780 this._ = undefined;
\r
1783 exports.NotificationType4 = NotificationType4;
\r
1784 class NotificationType5 extends AbstractMessageType {
\r
1785 constructor(method) {
\r
1787 this._ = undefined;
\r
1790 exports.NotificationType5 = NotificationType5;
\r
1791 class NotificationType6 extends AbstractMessageType {
\r
1792 constructor(method) {
\r
1794 this._ = undefined;
\r
1797 exports.NotificationType6 = NotificationType6;
\r
1798 class NotificationType7 extends AbstractMessageType {
\r
1799 constructor(method) {
\r
1801 this._ = undefined;
\r
1804 exports.NotificationType7 = NotificationType7;
\r
1805 class NotificationType8 extends AbstractMessageType {
\r
1806 constructor(method) {
\r
1808 this._ = undefined;
\r
1811 exports.NotificationType8 = NotificationType8;
\r
1812 class NotificationType9 extends AbstractMessageType {
\r
1813 constructor(method) {
\r
1815 this._ = undefined;
\r
1818 exports.NotificationType9 = NotificationType9;
\r
1820 * Tests if the given message is a request message
\r
1822 function isRequestMessage(message) {
\r
1823 let candidate = message;
\r
1824 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
\r
1826 exports.isRequestMessage = isRequestMessage;
\r
1828 * Tests if the given message is a notification message
\r
1830 function isNotificationMessage(message) {
\r
1831 let candidate = message;
\r
1832 return candidate && is.string(candidate.method) && message.id === void 0;
\r
1834 exports.isNotificationMessage = isNotificationMessage;
\r
1836 * Tests if the given message is a response message
\r
1838 function isResponseMessage(message) {
\r
1839 let candidate = message;
\r
1840 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
\r
1842 exports.isResponseMessage = isResponseMessage;
\r
1847 /***/ (function(module, exports, __webpack_require__) {
1850 /* --------------------------------------------------------------------------------------------
\r
1851 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1852 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1853 * ------------------------------------------------------------------------------------------ */
\r
1855 Object.defineProperty(exports, "__esModule", { value: true });
\r
1856 const events_1 = __webpack_require__(10);
\r
1857 const Is = __webpack_require__(7);
\r
1858 let DefaultSize = 8192;
\r
1859 let CR = Buffer.from('\r', 'ascii')[0];
\r
1860 let LF = Buffer.from('\n', 'ascii')[0];
\r
1861 let CRLF = '\r\n';
\r
1862 class MessageBuffer {
\r
1863 constructor(encoding = 'utf8') {
\r
1864 this.encoding = encoding;
\r
1866 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
1869 var toAppend = chunk;
\r
1870 if (typeof (chunk) === 'string') {
\r
1872 var bufferLen = Buffer.byteLength(str, this.encoding);
\r
1873 toAppend = Buffer.allocUnsafe(bufferLen);
\r
1874 toAppend.write(str, 0, bufferLen, this.encoding);
\r
1876 if (this.buffer.length - this.index >= toAppend.length) {
\r
1877 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\r
1880 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
\r
1881 if (this.index === 0) {
\r
1882 this.buffer = Buffer.allocUnsafe(newSize);
\r
1883 toAppend.copy(this.buffer, 0, 0, toAppend.length);
\r
1886 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
1889 this.index += toAppend.length;
\r
1891 tryReadHeaders() {
\r
1892 let result = undefined;
\r
1894 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
1897 // No header / body separator found (e.g CRLFCRLF)
\r
1898 if (current + 3 >= this.index) {
\r
1901 result = Object.create(null);
\r
1902 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
\r
1903 headers.forEach((header) => {
\r
1904 let index = header.indexOf(':');
\r
1905 if (index === -1) {
\r
1906 throw new Error('Message header must separate key and value using :');
\r
1908 let key = header.substr(0, index);
\r
1909 let value = header.substr(index + 1).trim();
\r
1910 result[key] = value;
\r
1912 let nextStart = current + 4;
\r
1913 this.buffer = this.buffer.slice(nextStart);
\r
1914 this.index = this.index - nextStart;
\r
1917 tryReadContent(length) {
\r
1918 if (this.index < length) {
\r
1921 let result = this.buffer.toString(this.encoding, 0, length);
\r
1922 let nextStart = length;
\r
1923 this.buffer.copy(this.buffer, 0, nextStart);
\r
1924 this.index = this.index - nextStart;
\r
1927 get numberOfBytes() {
\r
1928 return this.index;
\r
1931 var MessageReader;
\r
1932 (function (MessageReader) {
\r
1933 function is(value) {
\r
1934 let candidate = value;
\r
1935 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
\r
1936 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
\r
1938 MessageReader.is = is;
\r
1939 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
1940 class AbstractMessageReader {
\r
1942 this.errorEmitter = new events_1.Emitter();
\r
1943 this.closeEmitter = new events_1.Emitter();
\r
1944 this.partialMessageEmitter = new events_1.Emitter();
\r
1947 this.errorEmitter.dispose();
\r
1948 this.closeEmitter.dispose();
\r
1951 return this.errorEmitter.event;
\r
1953 fireError(error) {
\r
1954 this.errorEmitter.fire(this.asError(error));
\r
1957 return this.closeEmitter.event;
\r
1960 this.closeEmitter.fire(undefined);
\r
1962 get onPartialMessage() {
\r
1963 return this.partialMessageEmitter.event;
\r
1965 firePartialMessage(info) {
\r
1966 this.partialMessageEmitter.fire(info);
\r
1969 if (error instanceof Error) {
\r
1973 return new Error(`Reader recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1977 exports.AbstractMessageReader = AbstractMessageReader;
\r
1978 class StreamMessageReader extends AbstractMessageReader {
\r
1979 constructor(readable, encoding = 'utf8') {
\r
1981 this.readable = readable;
\r
1982 this.buffer = new MessageBuffer(encoding);
\r
1983 this._partialMessageTimeout = 10000;
\r
1985 set partialMessageTimeout(timeout) {
\r
1986 this._partialMessageTimeout = timeout;
\r
1988 get partialMessageTimeout() {
\r
1989 return this._partialMessageTimeout;
\r
1991 listen(callback) {
\r
1992 this.nextMessageLength = -1;
\r
1993 this.messageToken = 0;
\r
1994 this.partialMessageTimer = undefined;
\r
1995 this.callback = callback;
\r
1996 this.readable.on('data', (data) => {
\r
1997 this.onData(data);
\r
1999 this.readable.on('error', (error) => this.fireError(error));
\r
2000 this.readable.on('close', () => this.fireClose());
\r
2003 this.buffer.append(data);
\r
2005 if (this.nextMessageLength === -1) {
\r
2006 let headers = this.buffer.tryReadHeaders();
\r
2010 let contentLength = headers['Content-Length'];
\r
2011 if (!contentLength) {
\r
2012 throw new Error('Header must provide a Content-Length property.');
\r
2014 let length = parseInt(contentLength);
\r
2015 if (isNaN(length)) {
\r
2016 throw new Error('Content-Length value must be a number.');
\r
2018 this.nextMessageLength = length;
\r
2019 // Take the encoding form the header. For compatibility
\r
2020 // treat both utf-8 and utf8 as node utf8
\r
2022 var msg = this.buffer.tryReadContent(this.nextMessageLength);
\r
2023 if (msg === null) {
\r
2024 /** We haven't recevied the full message yet. */
\r
2025 this.setPartialMessageTimer();
\r
2028 this.clearPartialMessageTimer();
\r
2029 this.nextMessageLength = -1;
\r
2030 this.messageToken++;
\r
2031 var json = JSON.parse(msg);
\r
2032 this.callback(json);
\r
2035 clearPartialMessageTimer() {
\r
2036 if (this.partialMessageTimer) {
\r
2037 clearTimeout(this.partialMessageTimer);
\r
2038 this.partialMessageTimer = undefined;
\r
2041 setPartialMessageTimer() {
\r
2042 this.clearPartialMessageTimer();
\r
2043 if (this._partialMessageTimeout <= 0) {
\r
2046 this.partialMessageTimer = setTimeout((token, timeout) => {
\r
2047 this.partialMessageTimer = undefined;
\r
2048 if (token === this.messageToken) {
\r
2049 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
\r
2050 this.setPartialMessageTimer();
\r
2052 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
2055 exports.StreamMessageReader = StreamMessageReader;
\r
2056 class IPCMessageReader extends AbstractMessageReader {
\r
2057 constructor(process) {
\r
2059 this.process = process;
\r
2060 let eventEmitter = this.process;
\r
2061 eventEmitter.on('error', (error) => this.fireError(error));
\r
2062 eventEmitter.on('close', () => this.fireClose());
\r
2064 listen(callback) {
\r
2065 this.process.on('message', callback);
\r
2068 exports.IPCMessageReader = IPCMessageReader;
\r
2069 class SocketMessageReader extends StreamMessageReader {
\r
2070 constructor(socket, encoding = 'utf-8') {
\r
2071 super(socket, encoding);
\r
2074 exports.SocketMessageReader = SocketMessageReader;
\r
2079 /***/ (function(module, exports, __webpack_require__) {
2082 /* --------------------------------------------------------------------------------------------
\r
2083 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2084 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2085 * ------------------------------------------------------------------------------------------ */
\r
2087 Object.defineProperty(exports, "__esModule", { value: true });
\r
2089 (function (Disposable) {
\r
2090 function create(func) {
\r
2095 Disposable.create = create;
\r
2096 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\r
2098 (function (Event) {
\r
2099 const _disposable = { dispose() { } };
\r
2100 Event.None = function () { return _disposable; };
\r
2101 })(Event = exports.Event || (exports.Event = {}));
\r
2102 class CallbackList {
\r
2103 add(callback, context = null, bucket) {
\r
2104 if (!this._callbacks) {
\r
2105 this._callbacks = [];
\r
2106 this._contexts = [];
\r
2108 this._callbacks.push(callback);
\r
2109 this._contexts.push(context);
\r
2110 if (Array.isArray(bucket)) {
\r
2111 bucket.push({ dispose: () => this.remove(callback, context) });
\r
2114 remove(callback, context = null) {
\r
2115 if (!this._callbacks) {
\r
2118 var foundCallbackWithDifferentContext = false;
\r
2119 for (var i = 0, len = this._callbacks.length; i < len; i++) {
\r
2120 if (this._callbacks[i] === callback) {
\r
2121 if (this._contexts[i] === context) {
\r
2122 // callback & context match => remove it
\r
2123 this._callbacks.splice(i, 1);
\r
2124 this._contexts.splice(i, 1);
\r
2128 foundCallbackWithDifferentContext = true;
\r
2132 if (foundCallbackWithDifferentContext) {
\r
2133 throw new Error('When adding a listener with a context, you should remove it with the same context');
\r
2137 if (!this._callbacks) {
\r
2140 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
\r
2141 for (var i = 0, len = callbacks.length; i < len; i++) {
\r
2143 ret.push(callbacks[i].apply(contexts[i], args));
\r
2152 return !this._callbacks || this._callbacks.length === 0;
\r
2155 this._callbacks = undefined;
\r
2156 this._contexts = undefined;
\r
2160 constructor(_options) {
\r
2161 this._options = _options;
\r
2164 * For the public to allow to subscribe
\r
2165 * to events from this Emitter
\r
2168 if (!this._event) {
\r
2169 this._event = (listener, thisArgs, disposables) => {
\r
2170 if (!this._callbacks) {
\r
2171 this._callbacks = new CallbackList();
\r
2173 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
2174 this._options.onFirstListenerAdd(this);
\r
2176 this._callbacks.add(listener, thisArgs);
\r
2180 this._callbacks.remove(listener, thisArgs);
\r
2181 result.dispose = Emitter._noop;
\r
2182 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
\r
2183 this._options.onLastListenerRemove(this);
\r
2187 if (Array.isArray(disposables)) {
\r
2188 disposables.push(result);
\r
2193 return this._event;
\r
2196 * To be kept private to fire an event to
\r
2200 if (this._callbacks) {
\r
2201 this._callbacks.invoke.call(this._callbacks, event);
\r
2205 if (this._callbacks) {
\r
2206 this._callbacks.dispose();
\r
2207 this._callbacks = undefined;
\r
2211 Emitter._noop = function () { };
\r
2212 exports.Emitter = Emitter;
\r
2217 /***/ (function(module, exports, __webpack_require__) {
2220 /* --------------------------------------------------------------------------------------------
\r
2221 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2222 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2223 * ------------------------------------------------------------------------------------------ */
\r
2225 Object.defineProperty(exports, "__esModule", { value: true });
\r
2226 const events_1 = __webpack_require__(10);
\r
2227 const Is = __webpack_require__(7);
\r
2228 let ContentLength = 'Content-Length: ';
\r
2229 let CRLF = '\r\n';
\r
2230 var MessageWriter;
\r
2231 (function (MessageWriter) {
\r
2232 function is(value) {
\r
2233 let candidate = value;
\r
2234 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
\r
2235 Is.func(candidate.onError) && Is.func(candidate.write);
\r
2237 MessageWriter.is = is;
\r
2238 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
2239 class AbstractMessageWriter {
\r
2241 this.errorEmitter = new events_1.Emitter();
\r
2242 this.closeEmitter = new events_1.Emitter();
\r
2245 this.errorEmitter.dispose();
\r
2246 this.closeEmitter.dispose();
\r
2249 return this.errorEmitter.event;
\r
2251 fireError(error, message, count) {
\r
2252 this.errorEmitter.fire([this.asError(error), message, count]);
\r
2255 return this.closeEmitter.event;
\r
2258 this.closeEmitter.fire(undefined);
\r
2261 if (error instanceof Error) {
\r
2265 return new Error(`Writer recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
2269 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
2270 class StreamMessageWriter extends AbstractMessageWriter {
\r
2271 constructor(writable, encoding = 'utf8') {
\r
2273 this.writable = writable;
\r
2274 this.encoding = encoding;
\r
2275 this.errorCount = 0;
\r
2276 this.writable.on('error', (error) => this.fireError(error));
\r
2277 this.writable.on('close', () => this.fireClose());
\r
2280 let json = JSON.stringify(msg);
\r
2281 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2283 ContentLength, contentLength.toString(), CRLF,
\r
2287 // Header must be written in ASCII encoding
\r
2288 this.writable.write(headers.join(''), 'ascii');
\r
2289 // Now write the content. This can be written in any encoding
\r
2290 this.writable.write(json, this.encoding);
\r
2291 this.errorCount = 0;
\r
2294 this.errorCount++;
\r
2295 this.fireError(error, msg, this.errorCount);
\r
2299 exports.StreamMessageWriter = StreamMessageWriter;
\r
2300 class IPCMessageWriter extends AbstractMessageWriter {
\r
2301 constructor(process) {
\r
2303 this.process = process;
\r
2304 this.errorCount = 0;
\r
2306 this.sending = false;
\r
2307 let eventEmitter = this.process;
\r
2308 eventEmitter.on('error', (error) => this.fireError(error));
\r
2309 eventEmitter.on('close', () => this.fireClose);
\r
2312 if (!this.sending && this.queue.length === 0) {
\r
2313 // See https://github.com/nodejs/node/issues/7657
\r
2314 this.doWriteMessage(msg);
\r
2317 this.queue.push(msg);
\r
2320 doWriteMessage(msg) {
\r
2322 if (this.process.send) {
\r
2323 this.sending = true;
\r
2324 this.process.send(msg, undefined, undefined, (error) => {
\r
2325 this.sending = false;
\r
2327 this.errorCount++;
\r
2328 this.fireError(error, msg, this.errorCount);
\r
2331 this.errorCount = 0;
\r
2333 if (this.queue.length > 0) {
\r
2334 this.doWriteMessage(this.queue.shift());
\r
2340 this.errorCount++;
\r
2341 this.fireError(error, msg, this.errorCount);
\r
2345 exports.IPCMessageWriter = IPCMessageWriter;
\r
2346 class SocketMessageWriter extends AbstractMessageWriter {
\r
2347 constructor(socket, encoding = 'utf8') {
\r
2349 this.socket = socket;
\r
2351 this.sending = false;
\r
2352 this.encoding = encoding;
\r
2353 this.errorCount = 0;
\r
2354 this.socket.on('error', (error) => this.fireError(error));
\r
2355 this.socket.on('close', () => this.fireClose());
\r
2358 if (!this.sending && this.queue.length === 0) {
\r
2359 // See https://github.com/nodejs/node/issues/7657
\r
2360 this.doWriteMessage(msg);
\r
2363 this.queue.push(msg);
\r
2366 doWriteMessage(msg) {
\r
2367 let json = JSON.stringify(msg);
\r
2368 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2370 ContentLength, contentLength.toString(), CRLF,
\r
2374 // Header must be written in ASCII encoding
\r
2375 this.sending = true;
\r
2376 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
2378 this.handleError(error, msg);
\r
2381 // Now write the content. This can be written in any encoding
\r
2382 this.socket.write(json, this.encoding, (error) => {
\r
2383 this.sending = false;
\r
2385 this.handleError(error, msg);
\r
2388 this.errorCount = 0;
\r
2390 if (this.queue.length > 0) {
\r
2391 this.doWriteMessage(this.queue.shift());
\r
2396 this.handleError(error, msg);
\r
2401 this.handleError(error, msg);
\r
2404 handleError(error, msg) {
\r
2405 this.errorCount++;
\r
2406 this.fireError(error, msg, this.errorCount);
\r
2409 exports.SocketMessageWriter = SocketMessageWriter;
\r
2414 /***/ (function(module, exports, __webpack_require__) {
2417 /*---------------------------------------------------------------------------------------------
\r
2418 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2419 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2420 *--------------------------------------------------------------------------------------------*/
\r
2422 Object.defineProperty(exports, "__esModule", { value: true });
\r
2423 const events_1 = __webpack_require__(10);
\r
2424 const Is = __webpack_require__(7);
\r
2425 var CancellationToken;
\r
2426 (function (CancellationToken) {
\r
2427 CancellationToken.None = Object.freeze({
\r
2428 isCancellationRequested: false,
\r
2429 onCancellationRequested: events_1.Event.None
\r
2431 CancellationToken.Cancelled = Object.freeze({
\r
2432 isCancellationRequested: true,
\r
2433 onCancellationRequested: events_1.Event.None
\r
2435 function is(value) {
\r
2436 let candidate = value;
\r
2437 return candidate && (candidate === CancellationToken.None
\r
2438 || candidate === CancellationToken.Cancelled
\r
2439 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
\r
2441 CancellationToken.is = is;
\r
2442 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
\r
2443 const shortcutEvent = Object.freeze(function (callback, context) {
\r
2444 let handle = setTimeout(callback.bind(context), 0);
\r
2445 return { dispose() { clearTimeout(handle); } };
\r
2447 class MutableToken {
\r
2449 this._isCancelled = false;
\r
2452 if (!this._isCancelled) {
\r
2453 this._isCancelled = true;
\r
2454 if (this._emitter) {
\r
2455 this._emitter.fire(undefined);
\r
2456 this._emitter = undefined;
\r
2460 get isCancellationRequested() {
\r
2461 return this._isCancelled;
\r
2463 get onCancellationRequested() {
\r
2464 if (this._isCancelled) {
\r
2465 return shortcutEvent;
\r
2467 if (!this._emitter) {
\r
2468 this._emitter = new events_1.Emitter();
\r
2470 return this._emitter.event;
\r
2473 class CancellationTokenSource {
\r
2475 if (!this._token) {
\r
2476 // be lazy and create the token only when
\r
2477 // actually needed
\r
2478 this._token = new MutableToken();
\r
2480 return this._token;
\r
2483 if (!this._token) {
\r
2484 // save an object by returning the default
\r
2485 // cancelled token when cancellation happens
\r
2486 // before someone asks for the token
\r
2487 this._token = CancellationToken.Cancelled;
\r
2490 this._token.cancel();
\r
2497 exports.CancellationTokenSource = CancellationTokenSource;
\r
2502 /***/ (function(module, exports, __webpack_require__) {
2506 /*---------------------------------------------------------------------------------------------
\r
2507 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2508 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2509 *--------------------------------------------------------------------------------------------*/
\r
2510 Object.defineProperty(exports, "__esModule", { value: true });
\r
2512 (function (Touch) {
\r
2516 })(Touch = exports.Touch || (exports.Touch = {}));
\r
2519 this._map = new Map();
\r
2520 this._head = undefined;
\r
2521 this._tail = undefined;
\r
2525 this._map.clear();
\r
2526 this._head = undefined;
\r
2527 this._tail = undefined;
\r
2531 return !this._head && !this._tail;
\r
2534 return this._size;
\r
2537 return this._map.has(key);
\r
2540 const item = this._map.get(key);
\r
2544 return item.value;
\r
2546 set(key, value, touch = Touch.None) {
\r
2547 let item = this._map.get(key);
\r
2549 item.value = value;
\r
2550 if (touch !== Touch.None) {
\r
2551 this.touch(item, touch);
\r
2555 item = { key, value, next: undefined, previous: undefined };
\r
2558 this.addItemLast(item);
\r
2561 this.addItemFirst(item);
\r
2564 this.addItemLast(item);
\r
2567 this.addItemLast(item);
\r
2570 this._map.set(key, item);
\r
2575 const item = this._map.get(key);
\r
2579 this._map.delete(key);
\r
2580 this.removeItem(item);
\r
2585 if (!this._head && !this._tail) {
\r
2588 if (!this._head || !this._tail) {
\r
2589 throw new Error('Invalid list');
\r
2591 const item = this._head;
\r
2592 this._map.delete(item.key);
\r
2593 this.removeItem(item);
\r
2595 return item.value;
\r
2597 forEach(callbackfn, thisArg) {
\r
2598 let current = this._head;
\r
2601 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2604 callbackfn(current.value, current.key, this);
\r
2606 current = current.next;
\r
2609 forEachReverse(callbackfn, thisArg) {
\r
2610 let current = this._tail;
\r
2613 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2616 callbackfn(current.value, current.key, this);
\r
2618 current = current.previous;
\r
2623 let current = this._head;
\r
2625 result.push(current.value);
\r
2626 current = current.next;
\r
2632 let current = this._head;
\r
2634 result.push(current.key);
\r
2635 current = current.next;
\r
2639 /* JSON RPC run on es5 which has no Symbol.iterator
\r
2640 public keys(): IterableIterator<K> {
\r
2641 let current = this._head;
\r
2642 let iterator: IterableIterator<K> = {
\r
2643 [Symbol.iterator]() {
\r
2646 next():IteratorResult<K> {
\r
2648 let result = { value: current.key, done: false };
\r
2649 current = current.next;
\r
2652 return { value: undefined, done: true };
\r
2659 public values(): IterableIterator<V> {
\r
2660 let current = this._head;
\r
2661 let iterator: IterableIterator<V> = {
\r
2662 [Symbol.iterator]() {
\r
2665 next():IteratorResult<V> {
\r
2667 let result = { value: current.value, done: false };
\r
2668 current = current.next;
\r
2671 return { value: undefined, done: true };
\r
2678 addItemFirst(item) {
\r
2679 // First time Insert
\r
2680 if (!this._head && !this._tail) {
\r
2681 this._tail = item;
\r
2683 else if (!this._head) {
\r
2684 throw new Error('Invalid list');
\r
2687 item.next = this._head;
\r
2688 this._head.previous = item;
\r
2690 this._head = item;
\r
2692 addItemLast(item) {
\r
2693 // First time Insert
\r
2694 if (!this._head && !this._tail) {
\r
2695 this._head = item;
\r
2697 else if (!this._tail) {
\r
2698 throw new Error('Invalid list');
\r
2701 item.previous = this._tail;
\r
2702 this._tail.next = item;
\r
2704 this._tail = item;
\r
2706 removeItem(item) {
\r
2707 if (item === this._head && item === this._tail) {
\r
2708 this._head = undefined;
\r
2709 this._tail = undefined;
\r
2711 else if (item === this._head) {
\r
2712 this._head = item.next;
\r
2714 else if (item === this._tail) {
\r
2715 this._tail = item.previous;
\r
2718 const next = item.next;
\r
2719 const previous = item.previous;
\r
2720 if (!next || !previous) {
\r
2721 throw new Error('Invalid list');
\r
2723 next.previous = previous;
\r
2724 previous.next = next;
\r
2727 touch(item, touch) {
\r
2728 if (!this._head || !this._tail) {
\r
2729 throw new Error('Invalid list');
\r
2731 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
2734 if (touch === Touch.First) {
\r
2735 if (item === this._head) {
\r
2738 const next = item.next;
\r
2739 const previous = item.previous;
\r
2740 // Unlink the item
\r
2741 if (item === this._tail) {
\r
2742 // previous must be defined since item was not head but is tail
\r
2743 // So there are more than on item in the map
\r
2744 previous.next = undefined;
\r
2745 this._tail = previous;
\r
2748 // Both next and previous are not undefined since item was neither head nor tail.
\r
2749 next.previous = previous;
\r
2750 previous.next = next;
\r
2752 // Insert the node at head
\r
2753 item.previous = undefined;
\r
2754 item.next = this._head;
\r
2755 this._head.previous = item;
\r
2756 this._head = item;
\r
2758 else if (touch === Touch.Last) {
\r
2759 if (item === this._tail) {
\r
2762 const next = item.next;
\r
2763 const previous = item.previous;
\r
2764 // Unlink the item.
\r
2765 if (item === this._head) {
\r
2766 // next must be defined since item was not tail but is head
\r
2767 // So there are more than on item in the map
\r
2768 next.previous = undefined;
\r
2769 this._head = next;
\r
2772 // Both next and previous are not undefined since item was neither head nor tail.
\r
2773 next.previous = previous;
\r
2774 previous.next = next;
\r
2776 item.next = undefined;
\r
2777 item.previous = this._tail;
\r
2778 this._tail.next = item;
\r
2779 this._tail = item;
\r
2783 exports.LinkedMap = LinkedMap;
\r
2788 /***/ (function(module, exports, __webpack_require__) {
2791 /* --------------------------------------------------------------------------------------------
\r
2792 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2793 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2794 * ------------------------------------------------------------------------------------------ */
\r
2796 Object.defineProperty(exports, "__esModule", { value: true });
\r
2797 const path_1 = __webpack_require__(4);
\r
2798 const os_1 = __webpack_require__(15);
\r
2799 const crypto_1 = __webpack_require__(16);
\r
2800 const net_1 = __webpack_require__(17);
\r
2801 const messageReader_1 = __webpack_require__(9);
\r
2802 const messageWriter_1 = __webpack_require__(11);
\r
2803 function generateRandomPipeName() {
\r
2804 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
\r
2805 if (process.platform === 'win32') {
\r
2806 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
\r
2809 // Mac/Unix: use socket file
\r
2810 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\r
2813 exports.generateRandomPipeName = generateRandomPipeName;
\r
2814 function createClientPipeTransport(pipeName, encoding = 'utf-8') {
\r
2815 let connectResolve;
\r
2816 let connected = new Promise((resolve, _reject) => {
\r
2817 connectResolve = resolve;
\r
2819 return new Promise((resolve, reject) => {
\r
2820 let server = net_1.createServer((socket) => {
\r
2823 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2824 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2827 server.on('error', reject);
\r
2828 server.listen(pipeName, () => {
\r
2829 server.removeListener('error', reject);
\r
2831 onConnected: () => { return connected; }
\r
2836 exports.createClientPipeTransport = createClientPipeTransport;
\r
2837 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
2838 const socket = net_1.createConnection(pipeName);
\r
2840 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2841 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2844 exports.createServerPipeTransport = createServerPipeTransport;
\r
2849 /***/ (function(module, exports) {
2851 module.exports = require("os");
2855 /***/ (function(module, exports) {
2857 module.exports = require("crypto");
2861 /***/ (function(module, exports) {
2863 module.exports = require("net");
2867 /***/ (function(module, exports, __webpack_require__) {
2870 /* --------------------------------------------------------------------------------------------
\r
2871 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2872 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2873 * ------------------------------------------------------------------------------------------ */
\r
2875 Object.defineProperty(exports, "__esModule", { value: true });
\r
2876 const net_1 = __webpack_require__(17);
\r
2877 const messageReader_1 = __webpack_require__(9);
\r
2878 const messageWriter_1 = __webpack_require__(11);
\r
2879 function createClientSocketTransport(port, encoding = 'utf-8') {
\r
2880 let connectResolve;
\r
2881 let connected = new Promise((resolve, _reject) => {
\r
2882 connectResolve = resolve;
\r
2884 return new Promise((resolve, reject) => {
\r
2885 let server = net_1.createServer((socket) => {
\r
2888 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2889 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2892 server.on('error', reject);
\r
2893 server.listen(port, '127.0.0.1', () => {
\r
2894 server.removeListener('error', reject);
\r
2896 onConnected: () => { return connected; }
\r
2901 exports.createClientSocketTransport = createClientSocketTransport;
\r
2902 function createServerSocketTransport(port, encoding = 'utf-8') {
\r
2903 const socket = net_1.createConnection(port, '127.0.0.1');
\r
2905 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2906 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2909 exports.createServerSocketTransport = createServerSocketTransport;
\r
2914 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2917 __webpack_require__.r(__webpack_exports__);
2918 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2919 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2920 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2921 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2922 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2923 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2924 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2925 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2926 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2927 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2928 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2929 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2930 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2931 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2932 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2933 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2934 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2935 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2936 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2937 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2938 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2939 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2940 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2941 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2942 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2943 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2944 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2945 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2946 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2947 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2948 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2949 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2950 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2951 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2952 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2953 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2954 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2955 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2956 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2957 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2958 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2959 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2960 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2961 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2962 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2963 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2964 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
2965 /* --------------------------------------------------------------------------------------------
\r
2966 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2967 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2968 * ------------------------------------------------------------------------------------------ */
\r
2971 * The Position namespace provides helper functions to work with
\r
2972 * [Position](#Position) literals.
\r
2975 (function (Position) {
\r
2977 * Creates a new Position literal from the given line and character.
\r
2978 * @param line The position's line.
\r
2979 * @param character The position's character.
\r
2981 function create(line, character) {
\r
2982 return { line: line, character: character };
\r
2984 Position.create = create;
\r
2986 * Checks whether the given liternal conforms to the [Position](#Position) interface.
\r
2988 function is(value) {
\r
2989 var candidate = value;
\r
2990 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
\r
2993 })(Position || (Position = {}));
\r
2995 * The Range namespace provides helper functions to work with
\r
2996 * [Range](#Range) literals.
\r
2999 (function (Range) {
\r
3000 function create(one, two, three, four) {
\r
3001 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
\r
3002 return { start: Position.create(one, two), end: Position.create(three, four) };
\r
3004 else if (Position.is(one) && Position.is(two)) {
\r
3005 return { start: one, end: two };
\r
3008 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
\r
3011 Range.create = create;
\r
3013 * Checks whether the given literal conforms to the [Range](#Range) interface.
\r
3015 function is(value) {
\r
3016 var candidate = value;
\r
3017 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
\r
3020 })(Range || (Range = {}));
\r
3022 * The Location namespace provides helper functions to work with
\r
3023 * [Location](#Location) literals.
\r
3026 (function (Location) {
\r
3028 * Creates a Location literal.
\r
3029 * @param uri The location's uri.
\r
3030 * @param range The location's range.
\r
3032 function create(uri, range) {
\r
3033 return { uri: uri, range: range };
\r
3035 Location.create = create;
\r
3037 * Checks whether the given literal conforms to the [Location](#Location) interface.
\r
3039 function is(value) {
\r
3040 var candidate = value;
\r
3041 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
\r
3044 })(Location || (Location = {}));
\r
3046 * The LocationLink namespace provides helper functions to work with
\r
3047 * [LocationLink](#LocationLink) literals.
\r
3050 (function (LocationLink) {
\r
3052 * Creates a LocationLink literal.
\r
3053 * @param targetUri The definition's uri.
\r
3054 * @param targetRange The full range of the definition.
\r
3055 * @param targetSelectionRange The span of the symbol definition at the target.
\r
3056 * @param originSelectionRange The span of the symbol being defined in the originating source file.
\r
3058 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
\r
3059 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
\r
3061 LocationLink.create = create;
\r
3063 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
\r
3065 function is(value) {
\r
3066 var candidate = value;
\r
3067 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
\r
3068 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
\r
3069 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
\r
3071 LocationLink.is = is;
\r
3072 })(LocationLink || (LocationLink = {}));
\r
3074 * The Color namespace provides helper functions to work with
\r
3075 * [Color](#Color) literals.
\r
3078 (function (Color) {
\r
3080 * Creates a new Color literal.
\r
3082 function create(red, green, blue, alpha) {
\r
3090 Color.create = create;
\r
3092 * Checks whether the given literal conforms to the [Color](#Color) interface.
\r
3094 function is(value) {
\r
3095 var candidate = value;
\r
3096 return Is.number(candidate.red)
\r
3097 && Is.number(candidate.green)
\r
3098 && Is.number(candidate.blue)
\r
3099 && Is.number(candidate.alpha);
\r
3102 })(Color || (Color = {}));
\r
3104 * The ColorInformation namespace provides helper functions to work with
\r
3105 * [ColorInformation](#ColorInformation) literals.
\r
3107 var ColorInformation;
\r
3108 (function (ColorInformation) {
\r
3110 * Creates a new ColorInformation literal.
\r
3112 function create(range, color) {
\r
3118 ColorInformation.create = create;
\r
3120 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
3122 function is(value) {
\r
3123 var candidate = value;
\r
3124 return Range.is(candidate.range) && Color.is(candidate.color);
\r
3126 ColorInformation.is = is;
\r
3127 })(ColorInformation || (ColorInformation = {}));
\r
3129 * The Color namespace provides helper functions to work with
\r
3130 * [ColorPresentation](#ColorPresentation) literals.
\r
3132 var ColorPresentation;
\r
3133 (function (ColorPresentation) {
\r
3135 * Creates a new ColorInformation literal.
\r
3137 function create(label, textEdit, additionalTextEdits) {
\r
3140 textEdit: textEdit,
\r
3141 additionalTextEdits: additionalTextEdits,
\r
3144 ColorPresentation.create = create;
\r
3146 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
3148 function is(value) {
\r
3149 var candidate = value;
\r
3150 return Is.string(candidate.label)
\r
3151 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
\r
3152 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
\r
3154 ColorPresentation.is = is;
\r
3155 })(ColorPresentation || (ColorPresentation = {}));
\r
3157 * Enum of known range kinds
\r
3159 var FoldingRangeKind;
\r
3160 (function (FoldingRangeKind) {
\r
3162 * Folding range for a comment
\r
3164 FoldingRangeKind["Comment"] = "comment";
\r
3166 * Folding range for a imports or includes
\r
3168 FoldingRangeKind["Imports"] = "imports";
\r
3170 * Folding range for a region (e.g. `#region`)
\r
3172 FoldingRangeKind["Region"] = "region";
\r
3173 })(FoldingRangeKind || (FoldingRangeKind = {}));
\r
3175 * The folding range namespace provides helper functions to work with
\r
3176 * [FoldingRange](#FoldingRange) literals.
\r
3179 (function (FoldingRange) {
\r
3181 * Creates a new FoldingRange literal.
\r
3183 function create(startLine, endLine, startCharacter, endCharacter, kind) {
\r
3185 startLine: startLine,
\r
3188 if (Is.defined(startCharacter)) {
\r
3189 result.startCharacter = startCharacter;
\r
3191 if (Is.defined(endCharacter)) {
\r
3192 result.endCharacter = endCharacter;
\r
3194 if (Is.defined(kind)) {
\r
3195 result.kind = kind;
\r
3199 FoldingRange.create = create;
\r
3201 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
\r
3203 function is(value) {
\r
3204 var candidate = value;
\r
3205 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
\r
3206 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
\r
3207 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
\r
3208 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
\r
3210 FoldingRange.is = is;
\r
3211 })(FoldingRange || (FoldingRange = {}));
\r
3213 * The DiagnosticRelatedInformation namespace provides helper functions to work with
\r
3214 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
\r
3216 var DiagnosticRelatedInformation;
\r
3217 (function (DiagnosticRelatedInformation) {
\r
3219 * Creates a new DiagnosticRelatedInformation literal.
\r
3221 function create(location, message) {
\r
3223 location: location,
\r
3227 DiagnosticRelatedInformation.create = create;
\r
3229 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
\r
3231 function is(value) {
\r
3232 var candidate = value;
\r
3233 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
\r
3235 DiagnosticRelatedInformation.is = is;
\r
3236 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
\r
3238 * The diagnostic's severity.
\r
3240 var DiagnosticSeverity;
\r
3241 (function (DiagnosticSeverity) {
\r
3243 * Reports an error.
\r
3245 DiagnosticSeverity.Error = 1;
\r
3247 * Reports a warning.
\r
3249 DiagnosticSeverity.Warning = 2;
\r
3251 * Reports an information.
\r
3253 DiagnosticSeverity.Information = 3;
\r
3257 DiagnosticSeverity.Hint = 4;
\r
3258 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
\r
3260 * The Diagnostic namespace provides helper functions to work with
\r
3261 * [Diagnostic](#Diagnostic) literals.
\r
3264 (function (Diagnostic) {
\r
3266 * Creates a new Diagnostic literal.
\r
3268 function create(range, message, severity, code, source, relatedInformation) {
\r
3269 var result = { range: range, message: message };
\r
3270 if (Is.defined(severity)) {
\r
3271 result.severity = severity;
\r
3273 if (Is.defined(code)) {
\r
3274 result.code = code;
\r
3276 if (Is.defined(source)) {
\r
3277 result.source = source;
\r
3279 if (Is.defined(relatedInformation)) {
\r
3280 result.relatedInformation = relatedInformation;
\r
3284 Diagnostic.create = create;
\r
3286 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
\r
3288 function is(value) {
\r
3289 var candidate = value;
\r
3290 return Is.defined(candidate)
\r
3291 && Range.is(candidate.range)
\r
3292 && Is.string(candidate.message)
\r
3293 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
\r
3294 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
\r
3295 && (Is.string(candidate.source) || Is.undefined(candidate.source))
\r
3296 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
\r
3298 Diagnostic.is = is;
\r
3299 })(Diagnostic || (Diagnostic = {}));
\r
3301 * The Command namespace provides helper functions to work with
\r
3302 * [Command](#Command) literals.
\r
3305 (function (Command) {
\r
3307 * Creates a new Command literal.
\r
3309 function create(title, command) {
\r
3311 for (var _i = 2; _i < arguments.length; _i++) {
\r
3312 args[_i - 2] = arguments[_i];
\r
3314 var result = { title: title, command: command };
\r
3315 if (Is.defined(args) && args.length > 0) {
\r
3316 result.arguments = args;
\r
3320 Command.create = create;
\r
3322 * Checks whether the given literal conforms to the [Command](#Command) interface.
\r
3324 function is(value) {
\r
3325 var candidate = value;
\r
3326 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
\r
3329 })(Command || (Command = {}));
\r
3331 * The TextEdit namespace provides helper function to create replace,
\r
3332 * insert and delete edits more easily.
\r
3335 (function (TextEdit) {
\r
3337 * Creates a replace text edit.
\r
3338 * @param range The range of text to be replaced.
\r
3339 * @param newText The new text.
\r
3341 function replace(range, newText) {
\r
3342 return { range: range, newText: newText };
\r
3344 TextEdit.replace = replace;
\r
3346 * Creates a insert text edit.
\r
3347 * @param position The position to insert the text at.
\r
3348 * @param newText The text to be inserted.
\r
3350 function insert(position, newText) {
\r
3351 return { range: { start: position, end: position }, newText: newText };
\r
3353 TextEdit.insert = insert;
\r
3355 * Creates a delete text edit.
\r
3356 * @param range The range of text to be deleted.
\r
3358 function del(range) {
\r
3359 return { range: range, newText: '' };
\r
3361 TextEdit.del = del;
\r
3362 function is(value) {
\r
3363 var candidate = value;
\r
3364 return Is.objectLiteral(candidate)
\r
3365 && Is.string(candidate.newText)
\r
3366 && Range.is(candidate.range);
\r
3369 })(TextEdit || (TextEdit = {}));
\r
3371 * The TextDocumentEdit namespace provides helper function to create
\r
3372 * an edit that manipulates a text document.
\r
3374 var TextDocumentEdit;
\r
3375 (function (TextDocumentEdit) {
\r
3377 * Creates a new `TextDocumentEdit`
\r
3379 function create(textDocument, edits) {
\r
3380 return { textDocument: textDocument, edits: edits };
\r
3382 TextDocumentEdit.create = create;
\r
3383 function is(value) {
\r
3384 var candidate = value;
\r
3385 return Is.defined(candidate)
\r
3386 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
\r
3387 && Array.isArray(candidate.edits);
\r
3389 TextDocumentEdit.is = is;
\r
3390 })(TextDocumentEdit || (TextDocumentEdit = {}));
\r
3392 (function (CreateFile) {
\r
3393 function create(uri, options) {
\r
3398 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3399 result.options = options;
\r
3403 CreateFile.create = create;
\r
3404 function is(value) {
\r
3405 var candidate = value;
\r
3406 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
\r
3407 (candidate.options === void 0 ||
\r
3408 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3410 CreateFile.is = is;
\r
3411 })(CreateFile || (CreateFile = {}));
\r
3413 (function (RenameFile) {
\r
3414 function create(oldUri, newUri, options) {
\r
3420 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3421 result.options = options;
\r
3425 RenameFile.create = create;
\r
3426 function is(value) {
\r
3427 var candidate = value;
\r
3428 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
\r
3429 (candidate.options === void 0 ||
\r
3430 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3432 RenameFile.is = is;
\r
3433 })(RenameFile || (RenameFile = {}));
\r
3435 (function (DeleteFile) {
\r
3436 function create(uri, options) {
\r
3441 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
\r
3442 result.options = options;
\r
3446 DeleteFile.create = create;
\r
3447 function is(value) {
\r
3448 var candidate = value;
\r
3449 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
\r
3450 (candidate.options === void 0 ||
\r
3451 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
\r
3453 DeleteFile.is = is;
\r
3454 })(DeleteFile || (DeleteFile = {}));
\r
3455 var WorkspaceEdit;
\r
3456 (function (WorkspaceEdit) {
\r
3457 function is(value) {
\r
3458 var candidate = value;
\r
3459 return candidate &&
\r
3460 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
\r
3461 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
\r
3462 if (Is.string(change.kind)) {
\r
3463 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
\r
3466 return TextDocumentEdit.is(change);
\r
3470 WorkspaceEdit.is = is;
\r
3471 })(WorkspaceEdit || (WorkspaceEdit = {}));
\r
3472 var TextEditChangeImpl = /** @class */ (function () {
\r
3473 function TextEditChangeImpl(edits) {
\r
3474 this.edits = edits;
\r
3476 TextEditChangeImpl.prototype.insert = function (position, newText) {
\r
3477 this.edits.push(TextEdit.insert(position, newText));
\r
3479 TextEditChangeImpl.prototype.replace = function (range, newText) {
\r
3480 this.edits.push(TextEdit.replace(range, newText));
\r
3482 TextEditChangeImpl.prototype.delete = function (range) {
\r
3483 this.edits.push(TextEdit.del(range));
\r
3485 TextEditChangeImpl.prototype.add = function (edit) {
\r
3486 this.edits.push(edit);
\r
3488 TextEditChangeImpl.prototype.all = function () {
\r
3489 return this.edits;
\r
3491 TextEditChangeImpl.prototype.clear = function () {
\r
3492 this.edits.splice(0, this.edits.length);
\r
3494 return TextEditChangeImpl;
\r
3497 * A workspace change helps constructing changes to a workspace.
\r
3499 var WorkspaceChange = /** @class */ (function () {
\r
3500 function WorkspaceChange(workspaceEdit) {
\r
3502 this._textEditChanges = Object.create(null);
\r
3503 if (workspaceEdit) {
\r
3504 this._workspaceEdit = workspaceEdit;
\r
3505 if (workspaceEdit.documentChanges) {
\r
3506 workspaceEdit.documentChanges.forEach(function (change) {
\r
3507 if (TextDocumentEdit.is(change)) {
\r
3508 var textEditChange = new TextEditChangeImpl(change.edits);
\r
3509 _this._textEditChanges[change.textDocument.uri] = textEditChange;
\r
3513 else if (workspaceEdit.changes) {
\r
3514 Object.keys(workspaceEdit.changes).forEach(function (key) {
\r
3515 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
\r
3516 _this._textEditChanges[key] = textEditChange;
\r
3521 Object.defineProperty(WorkspaceChange.prototype, "edit", {
\r
3523 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
\r
3524 * use to be returned from a workspace edit operation like rename.
\r
3526 get: function () {
\r
3527 return this._workspaceEdit;
\r
3530 configurable: true
\r
3532 WorkspaceChange.prototype.getTextEditChange = function (key) {
\r
3533 if (VersionedTextDocumentIdentifier.is(key)) {
\r
3534 if (!this._workspaceEdit) {
\r
3535 this._workspaceEdit = {
\r
3536 documentChanges: []
\r
3539 if (!this._workspaceEdit.documentChanges) {
\r
3540 throw new Error('Workspace edit is not configured for document changes.');
\r
3542 var textDocument = key;
\r
3543 var result = this._textEditChanges[textDocument.uri];
\r
3546 var textDocumentEdit = {
\r
3547 textDocument: textDocument,
\r
3550 this._workspaceEdit.documentChanges.push(textDocumentEdit);
\r
3551 result = new TextEditChangeImpl(edits);
\r
3552 this._textEditChanges[textDocument.uri] = result;
\r
3557 if (!this._workspaceEdit) {
\r
3558 this._workspaceEdit = {
\r
3559 changes: Object.create(null)
\r
3562 if (!this._workspaceEdit.changes) {
\r
3563 throw new Error('Workspace edit is not configured for normal text edit changes.');
\r
3565 var result = this._textEditChanges[key];
\r
3568 this._workspaceEdit.changes[key] = edits;
\r
3569 result = new TextEditChangeImpl(edits);
\r
3570 this._textEditChanges[key] = result;
\r
3575 WorkspaceChange.prototype.createFile = function (uri, options) {
\r
3576 this.checkDocumentChanges();
\r
3577 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
\r
3579 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
\r
3580 this.checkDocumentChanges();
\r
3581 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
\r
3583 WorkspaceChange.prototype.deleteFile = function (uri, options) {
\r
3584 this.checkDocumentChanges();
\r
3585 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
\r
3587 WorkspaceChange.prototype.checkDocumentChanges = function () {
\r
3588 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
\r
3589 throw new Error('Workspace edit is not configured for document changes.');
\r
3592 return WorkspaceChange;
\r
3596 * The TextDocumentIdentifier namespace provides helper functions to work with
\r
3597 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
\r
3599 var TextDocumentIdentifier;
\r
3600 (function (TextDocumentIdentifier) {
\r
3602 * Creates a new TextDocumentIdentifier literal.
\r
3603 * @param uri The document's uri.
\r
3605 function create(uri) {
\r
3606 return { uri: uri };
\r
3608 TextDocumentIdentifier.create = create;
\r
3610 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
\r
3612 function is(value) {
\r
3613 var candidate = value;
\r
3614 return Is.defined(candidate) && Is.string(candidate.uri);
\r
3616 TextDocumentIdentifier.is = is;
\r
3617 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
\r
3619 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
\r
3620 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
\r
3622 var VersionedTextDocumentIdentifier;
\r
3623 (function (VersionedTextDocumentIdentifier) {
\r
3625 * Creates a new VersionedTextDocumentIdentifier literal.
\r
3626 * @param uri The document's uri.
\r
3627 * @param uri The document's text.
\r
3629 function create(uri, version) {
\r
3630 return { uri: uri, version: version };
\r
3632 VersionedTextDocumentIdentifier.create = create;
\r
3634 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
\r
3636 function is(value) {
\r
3637 var candidate = value;
\r
3638 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
\r
3640 VersionedTextDocumentIdentifier.is = is;
\r
3641 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
\r
3643 * The TextDocumentItem namespace provides helper functions to work with
\r
3644 * [TextDocumentItem](#TextDocumentItem) literals.
\r
3646 var TextDocumentItem;
\r
3647 (function (TextDocumentItem) {
\r
3649 * Creates a new TextDocumentItem literal.
\r
3650 * @param uri The document's uri.
\r
3651 * @param languageId The document's language identifier.
\r
3652 * @param version The document's version number.
\r
3653 * @param text The document's text.
\r
3655 function create(uri, languageId, version, text) {
\r
3656 return { uri: uri, languageId: languageId, version: version, text: text };
\r
3658 TextDocumentItem.create = create;
\r
3660 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
\r
3662 function is(value) {
\r
3663 var candidate = value;
\r
3664 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
\r
3666 TextDocumentItem.is = is;
\r
3667 })(TextDocumentItem || (TextDocumentItem = {}));
\r
3669 * Describes the content type that a client supports in various
\r
3670 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
\r
3672 * Please note that `MarkupKinds` must not start with a `$`. This kinds
\r
3673 * are reserved for internal usage.
\r
3676 (function (MarkupKind) {
\r
3678 * Plain text is supported as a content format
\r
3680 MarkupKind.PlainText = 'plaintext';
\r
3682 * Markdown is supported as a content format
\r
3684 MarkupKind.Markdown = 'markdown';
\r
3685 })(MarkupKind || (MarkupKind = {}));
\r
3686 (function (MarkupKind) {
\r
3688 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
\r
3690 function is(value) {
\r
3691 var candidate = value;
\r
3692 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
\r
3694 MarkupKind.is = is;
\r
3695 })(MarkupKind || (MarkupKind = {}));
\r
3696 var MarkupContent;
\r
3697 (function (MarkupContent) {
\r
3699 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
\r
3701 function is(value) {
\r
3702 var candidate = value;
\r
3703 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
\r
3705 MarkupContent.is = is;
\r
3706 })(MarkupContent || (MarkupContent = {}));
\r
3708 * The kind of a completion entry.
\r
3710 var CompletionItemKind;
\r
3711 (function (CompletionItemKind) {
\r
3712 CompletionItemKind.Text = 1;
\r
3713 CompletionItemKind.Method = 2;
\r
3714 CompletionItemKind.Function = 3;
\r
3715 CompletionItemKind.Constructor = 4;
\r
3716 CompletionItemKind.Field = 5;
\r
3717 CompletionItemKind.Variable = 6;
\r
3718 CompletionItemKind.Class = 7;
\r
3719 CompletionItemKind.Interface = 8;
\r
3720 CompletionItemKind.Module = 9;
\r
3721 CompletionItemKind.Property = 10;
\r
3722 CompletionItemKind.Unit = 11;
\r
3723 CompletionItemKind.Value = 12;
\r
3724 CompletionItemKind.Enum = 13;
\r
3725 CompletionItemKind.Keyword = 14;
\r
3726 CompletionItemKind.Snippet = 15;
\r
3727 CompletionItemKind.Color = 16;
\r
3728 CompletionItemKind.File = 17;
\r
3729 CompletionItemKind.Reference = 18;
\r
3730 CompletionItemKind.Folder = 19;
\r
3731 CompletionItemKind.EnumMember = 20;
\r
3732 CompletionItemKind.Constant = 21;
\r
3733 CompletionItemKind.Struct = 22;
\r
3734 CompletionItemKind.Event = 23;
\r
3735 CompletionItemKind.Operator = 24;
\r
3736 CompletionItemKind.TypeParameter = 25;
\r
3737 })(CompletionItemKind || (CompletionItemKind = {}));
\r
3739 * Defines whether the insert text in a completion item should be interpreted as
\r
3740 * plain text or a snippet.
\r
3742 var InsertTextFormat;
\r
3743 (function (InsertTextFormat) {
\r
3745 * The primary text to be inserted is treated as a plain string.
\r
3747 InsertTextFormat.PlainText = 1;
\r
3749 * The primary text to be inserted is treated as a snippet.
\r
3751 * A snippet can define tab stops and placeholders with `$1`, `$2`
\r
3752 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
\r
3753 * the end of the snippet. Placeholders with equal identifiers are linked,
\r
3754 * that is typing in one will update others too.
\r
3756 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
\r
3758 InsertTextFormat.Snippet = 2;
\r
3759 })(InsertTextFormat || (InsertTextFormat = {}));
\r
3761 * The CompletionItem namespace provides functions to deal with
\r
3762 * completion items.
\r
3764 var CompletionItem;
\r
3765 (function (CompletionItem) {
\r
3767 * Create a completion item and seed it with a label.
\r
3768 * @param label The completion item's label
\r
3770 function create(label) {
\r
3771 return { label: label };
\r
3773 CompletionItem.create = create;
\r
3774 })(CompletionItem || (CompletionItem = {}));
\r
3776 * The CompletionList namespace provides functions to deal with
\r
3777 * completion lists.
\r
3779 var CompletionList;
\r
3780 (function (CompletionList) {
\r
3782 * Creates a new completion list.
\r
3784 * @param items The completion items.
\r
3785 * @param isIncomplete The list is not complete.
\r
3787 function create(items, isIncomplete) {
\r
3788 return { items: items ? items : [], isIncomplete: !!isIncomplete };
\r
3790 CompletionList.create = create;
\r
3791 })(CompletionList || (CompletionList = {}));
\r
3793 (function (MarkedString) {
\r
3795 * Creates a marked string from plain text.
\r
3797 * @param plainText The plain text.
\r
3799 function fromPlainText(plainText) {
\r
3800 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
\r
3802 MarkedString.fromPlainText = fromPlainText;
\r
3804 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
\r
3806 function is(value) {
\r
3807 var candidate = value;
\r
3808 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
\r
3810 MarkedString.is = is;
\r
3811 })(MarkedString || (MarkedString = {}));
\r
3813 (function (Hover) {
\r
3815 * Checks whether the given value conforms to the [Hover](#Hover) interface.
\r
3817 function is(value) {
\r
3818 var candidate = value;
\r
3819 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
\r
3820 MarkedString.is(candidate.contents) ||
\r
3821 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
\r
3824 })(Hover || (Hover = {}));
\r
3826 * The ParameterInformation namespace provides helper functions to work with
\r
3827 * [ParameterInformation](#ParameterInformation) literals.
\r
3829 var ParameterInformation;
\r
3830 (function (ParameterInformation) {
\r
3832 * Creates a new parameter information literal.
\r
3834 * @param label A label string.
\r
3835 * @param documentation A doc string.
\r
3837 function create(label, documentation) {
\r
3838 return documentation ? { label: label, documentation: documentation } : { label: label };
\r
3840 ParameterInformation.create = create;
\r
3842 })(ParameterInformation || (ParameterInformation = {}));
\r
3844 * The SignatureInformation namespace provides helper functions to work with
\r
3845 * [SignatureInformation](#SignatureInformation) literals.
\r
3847 var SignatureInformation;
\r
3848 (function (SignatureInformation) {
\r
3849 function create(label, documentation) {
\r
3850 var parameters = [];
\r
3851 for (var _i = 2; _i < arguments.length; _i++) {
\r
3852 parameters[_i - 2] = arguments[_i];
\r
3854 var result = { label: label };
\r
3855 if (Is.defined(documentation)) {
\r
3856 result.documentation = documentation;
\r
3858 if (Is.defined(parameters)) {
\r
3859 result.parameters = parameters;
\r
3862 result.parameters = [];
\r
3866 SignatureInformation.create = create;
\r
3867 })(SignatureInformation || (SignatureInformation = {}));
\r
3869 * A document highlight kind.
\r
3871 var DocumentHighlightKind;
\r
3872 (function (DocumentHighlightKind) {
\r
3874 * A textual occurrence.
\r
3876 DocumentHighlightKind.Text = 1;
\r
3878 * Read-access of a symbol, like reading a variable.
\r
3880 DocumentHighlightKind.Read = 2;
\r
3882 * Write-access of a symbol, like writing to a variable.
\r
3884 DocumentHighlightKind.Write = 3;
\r
3885 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
\r
3887 * DocumentHighlight namespace to provide helper functions to work with
\r
3888 * [DocumentHighlight](#DocumentHighlight) literals.
\r
3890 var DocumentHighlight;
\r
3891 (function (DocumentHighlight) {
\r
3893 * Create a DocumentHighlight object.
\r
3894 * @param range The range the highlight applies to.
\r
3896 function create(range, kind) {
\r
3897 var result = { range: range };
\r
3898 if (Is.number(kind)) {
\r
3899 result.kind = kind;
\r
3903 DocumentHighlight.create = create;
\r
3904 })(DocumentHighlight || (DocumentHighlight = {}));
\r
3909 (function (SymbolKind) {
\r
3910 SymbolKind.File = 1;
\r
3911 SymbolKind.Module = 2;
\r
3912 SymbolKind.Namespace = 3;
\r
3913 SymbolKind.Package = 4;
\r
3914 SymbolKind.Class = 5;
\r
3915 SymbolKind.Method = 6;
\r
3916 SymbolKind.Property = 7;
\r
3917 SymbolKind.Field = 8;
\r
3918 SymbolKind.Constructor = 9;
\r
3919 SymbolKind.Enum = 10;
\r
3920 SymbolKind.Interface = 11;
\r
3921 SymbolKind.Function = 12;
\r
3922 SymbolKind.Variable = 13;
\r
3923 SymbolKind.Constant = 14;
\r
3924 SymbolKind.String = 15;
\r
3925 SymbolKind.Number = 16;
\r
3926 SymbolKind.Boolean = 17;
\r
3927 SymbolKind.Array = 18;
\r
3928 SymbolKind.Object = 19;
\r
3929 SymbolKind.Key = 20;
\r
3930 SymbolKind.Null = 21;
\r
3931 SymbolKind.EnumMember = 22;
\r
3932 SymbolKind.Struct = 23;
\r
3933 SymbolKind.Event = 24;
\r
3934 SymbolKind.Operator = 25;
\r
3935 SymbolKind.TypeParameter = 26;
\r
3936 })(SymbolKind || (SymbolKind = {}));
\r
3937 var SymbolInformation;
\r
3938 (function (SymbolInformation) {
\r
3940 * Creates a new symbol information literal.
\r
3942 * @param name The name of the symbol.
\r
3943 * @param kind The kind of the symbol.
\r
3944 * @param range The range of the location of the symbol.
\r
3945 * @param uri The resource of the location of symbol, defaults to the current document.
\r
3946 * @param containerName The name of the symbol containing the symbol.
\r
3948 function create(name, kind, range, uri, containerName) {
\r
3952 location: { uri: uri, range: range }
\r
3954 if (containerName) {
\r
3955 result.containerName = containerName;
\r
3959 SymbolInformation.create = create;
\r
3960 })(SymbolInformation || (SymbolInformation = {}));
\r
3962 * Represents programming constructs like variables, classes, interfaces etc.
\r
3963 * that appear in a document. Document symbols can be hierarchical and they
\r
3964 * have two ranges: one that encloses its definition and one that points to
\r
3965 * its most interesting range, e.g. the range of an identifier.
\r
3967 var DocumentSymbol = /** @class */ (function () {
\r
3968 function DocumentSymbol() {
\r
3970 return DocumentSymbol;
\r
3973 (function (DocumentSymbol) {
\r
3975 * Creates a new symbol information literal.
\r
3977 * @param name The name of the symbol.
\r
3978 * @param detail The detail of the symbol.
\r
3979 * @param kind The kind of the symbol.
\r
3980 * @param range The range of the symbol.
\r
3981 * @param selectionRange The selectionRange of the symbol.
\r
3982 * @param children Children of the symbol.
\r
3984 function create(name, detail, kind, range, selectionRange, children) {
\r
3990 selectionRange: selectionRange
\r
3992 if (children !== void 0) {
\r
3993 result.children = children;
\r
3997 DocumentSymbol.create = create;
\r
3999 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
\r
4001 function is(value) {
\r
4002 var candidate = value;
\r
4003 return candidate &&
\r
4004 Is.string(candidate.name) && Is.number(candidate.kind) &&
\r
4005 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
\r
4006 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
\r
4007 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
\r
4008 (candidate.children === void 0 || Array.isArray(candidate.children));
\r
4010 DocumentSymbol.is = is;
\r
4011 })(DocumentSymbol || (DocumentSymbol = {}));
\r
4013 * A set of predefined code action kinds
\r
4015 var CodeActionKind;
\r
4016 (function (CodeActionKind) {
\r
4018 * Base kind for quickfix actions: 'quickfix'
\r
4020 CodeActionKind.QuickFix = 'quickfix';
\r
4022 * Base kind for refactoring actions: 'refactor'
\r
4024 CodeActionKind.Refactor = 'refactor';
\r
4026 * Base kind for refactoring extraction actions: 'refactor.extract'
\r
4028 * Example extract actions:
\r
4030 * - Extract method
\r
4031 * - Extract function
\r
4032 * - Extract variable
\r
4033 * - Extract interface from class
\r
4036 CodeActionKind.RefactorExtract = 'refactor.extract';
\r
4038 * Base kind for refactoring inline actions: 'refactor.inline'
\r
4040 * Example inline actions:
\r
4042 * - Inline function
\r
4043 * - Inline variable
\r
4044 * - Inline constant
\r
4047 CodeActionKind.RefactorInline = 'refactor.inline';
\r
4049 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
\r
4051 * Example rewrite actions:
\r
4053 * - Convert JavaScript function to class
\r
4054 * - Add or remove parameter
\r
4055 * - Encapsulate field
\r
4056 * - Make method static
\r
4057 * - Move method to base class
\r
4060 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
\r
4062 * Base kind for source actions: `source`
\r
4064 * Source code actions apply to the entire file.
\r
4066 CodeActionKind.Source = 'source';
\r
4068 * Base kind for an organize imports source action: `source.organizeImports`
\r
4070 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
\r
4071 })(CodeActionKind || (CodeActionKind = {}));
\r
4073 * The CodeActionContext namespace provides helper functions to work with
\r
4074 * [CodeActionContext](#CodeActionContext) literals.
\r
4076 var CodeActionContext;
\r
4077 (function (CodeActionContext) {
\r
4079 * Creates a new CodeActionContext literal.
\r
4081 function create(diagnostics, only) {
\r
4082 var result = { diagnostics: diagnostics };
\r
4083 if (only !== void 0 && only !== null) {
\r
4084 result.only = only;
\r
4088 CodeActionContext.create = create;
\r
4090 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
\r
4092 function is(value) {
\r
4093 var candidate = value;
\r
4094 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
\r
4096 CodeActionContext.is = is;
\r
4097 })(CodeActionContext || (CodeActionContext = {}));
\r
4099 (function (CodeAction) {
\r
4100 function create(title, commandOrEdit, kind) {
\r
4101 var result = { title: title };
\r
4102 if (Command.is(commandOrEdit)) {
\r
4103 result.command = commandOrEdit;
\r
4106 result.edit = commandOrEdit;
\r
4108 if (kind !== void null) {
\r
4109 result.kind = kind;
\r
4113 CodeAction.create = create;
\r
4114 function is(value) {
\r
4115 var candidate = value;
\r
4116 return candidate && Is.string(candidate.title) &&
\r
4117 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
\r
4118 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
\r
4119 (candidate.edit !== void 0 || candidate.command !== void 0) &&
\r
4120 (candidate.command === void 0 || Command.is(candidate.command)) &&
\r
4121 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
\r
4123 CodeAction.is = is;
\r
4124 })(CodeAction || (CodeAction = {}));
\r
4126 * The CodeLens namespace provides helper functions to work with
\r
4127 * [CodeLens](#CodeLens) literals.
\r
4130 (function (CodeLens) {
\r
4132 * Creates a new CodeLens literal.
\r
4134 function create(range, data) {
\r
4135 var result = { range: range };
\r
4136 if (Is.defined(data))
\r
4137 result.data = data;
\r
4140 CodeLens.create = create;
\r
4142 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
\r
4144 function is(value) {
\r
4145 var candidate = value;
\r
4146 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
\r
4149 })(CodeLens || (CodeLens = {}));
\r
4151 * The FormattingOptions namespace provides helper functions to work with
\r
4152 * [FormattingOptions](#FormattingOptions) literals.
\r
4154 var FormattingOptions;
\r
4155 (function (FormattingOptions) {
\r
4157 * Creates a new FormattingOptions literal.
\r
4159 function create(tabSize, insertSpaces) {
\r
4160 return { tabSize: tabSize, insertSpaces: insertSpaces };
\r
4162 FormattingOptions.create = create;
\r
4164 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
\r
4166 function is(value) {
\r
4167 var candidate = value;
\r
4168 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
\r
4170 FormattingOptions.is = is;
\r
4171 })(FormattingOptions || (FormattingOptions = {}));
\r
4173 * A document link is a range in a text document that links to an internal or external resource, like another
\r
4174 * text document or a web site.
\r
4176 var DocumentLink = /** @class */ (function () {
\r
4177 function DocumentLink() {
\r
4179 return DocumentLink;
\r
4183 * The DocumentLink namespace provides helper functions to work with
\r
4184 * [DocumentLink](#DocumentLink) literals.
\r
4186 (function (DocumentLink) {
\r
4188 * Creates a new DocumentLink literal.
\r
4190 function create(range, target, data) {
\r
4191 return { range: range, target: target, data: data };
\r
4193 DocumentLink.create = create;
\r
4195 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
\r
4197 function is(value) {
\r
4198 var candidate = value;
\r
4199 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
\r
4201 DocumentLink.is = is;
\r
4202 })(DocumentLink || (DocumentLink = {}));
\r
4203 var EOL = ['\n', '\r\n', '\r'];
\r
4205 (function (TextDocument) {
\r
4207 * Creates a new ITextDocument literal from the given uri and content.
\r
4208 * @param uri The document's uri.
\r
4209 * @param languageId The document's language Id.
\r
4210 * @param content The document's content.
\r
4212 function create(uri, languageId, version, content) {
\r
4213 return new FullTextDocument(uri, languageId, version, content);
\r
4215 TextDocument.create = create;
\r
4217 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
\r
4219 function is(value) {
\r
4220 var candidate = value;
\r
4221 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
\r
4222 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
\r
4224 TextDocument.is = is;
\r
4225 function applyEdits(document, edits) {
\r
4226 var text = document.getText();
\r
4227 var sortedEdits = mergeSort(edits, function (a, b) {
\r
4228 var diff = a.range.start.line - b.range.start.line;
\r
4230 return a.range.start.character - b.range.start.character;
\r
4234 var lastModifiedOffset = text.length;
\r
4235 for (var i = sortedEdits.length - 1; i >= 0; i--) {
\r
4236 var e = sortedEdits[i];
\r
4237 var startOffset = document.offsetAt(e.range.start);
\r
4238 var endOffset = document.offsetAt(e.range.end);
\r
4239 if (endOffset <= lastModifiedOffset) {
\r
4240 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
\r
4243 throw new Error('Overlapping edit');
\r
4245 lastModifiedOffset = startOffset;
\r
4249 TextDocument.applyEdits = applyEdits;
\r
4250 function mergeSort(data, compare) {
\r
4251 if (data.length <= 1) {
\r
4255 var p = (data.length / 2) | 0;
\r
4256 var left = data.slice(0, p);
\r
4257 var right = data.slice(p);
\r
4258 mergeSort(left, compare);
\r
4259 mergeSort(right, compare);
\r
4263 while (leftIdx < left.length && rightIdx < right.length) {
\r
4264 var ret = compare(left[leftIdx], right[rightIdx]);
\r
4266 // smaller_equal -> take left to preserve order
\r
4267 data[i++] = left[leftIdx++];
\r
4270 // greater -> take right
\r
4271 data[i++] = right[rightIdx++];
\r
4274 while (leftIdx < left.length) {
\r
4275 data[i++] = left[leftIdx++];
\r
4277 while (rightIdx < right.length) {
\r
4278 data[i++] = right[rightIdx++];
\r
4282 })(TextDocument || (TextDocument = {}));
\r
4284 * Represents reasons why a text document is saved.
\r
4286 var TextDocumentSaveReason;
\r
4287 (function (TextDocumentSaveReason) {
\r
4289 * Manually triggered, e.g. by the user pressing save, by starting debugging,
\r
4290 * or by an API call.
\r
4292 TextDocumentSaveReason.Manual = 1;
\r
4294 * Automatic after a delay.
\r
4296 TextDocumentSaveReason.AfterDelay = 2;
\r
4298 * When the editor lost focus.
\r
4300 TextDocumentSaveReason.FocusOut = 3;
\r
4301 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));
\r
4302 var FullTextDocument = /** @class */ (function () {
\r
4303 function FullTextDocument(uri, languageId, version, content) {
\r
4305 this._languageId = languageId;
\r
4306 this._version = version;
\r
4307 this._content = content;
\r
4308 this._lineOffsets = null;
\r
4310 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
4311 get: function () {
\r
4315 configurable: true
\r
4317 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
4318 get: function () {
\r
4319 return this._languageId;
\r
4322 configurable: true
\r
4324 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
4325 get: function () {
\r
4326 return this._version;
\r
4329 configurable: true
\r
4331 FullTextDocument.prototype.getText = function (range) {
\r
4333 var start = this.offsetAt(range.start);
\r
4334 var end = this.offsetAt(range.end);
\r
4335 return this._content.substring(start, end);
\r
4337 return this._content;
\r
4339 FullTextDocument.prototype.update = function (event, version) {
\r
4340 this._content = event.text;
\r
4341 this._version = version;
\r
4342 this._lineOffsets = null;
\r
4344 FullTextDocument.prototype.getLineOffsets = function () {
\r
4345 if (this._lineOffsets === null) {
\r
4346 var lineOffsets = [];
\r
4347 var text = this._content;
\r
4348 var isLineStart = true;
\r
4349 for (var i = 0; i < text.length; i++) {
\r
4350 if (isLineStart) {
\r
4351 lineOffsets.push(i);
\r
4352 isLineStart = false;
\r
4354 var ch = text.charAt(i);
\r
4355 isLineStart = (ch === '\r' || ch === '\n');
\r
4356 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
\r
4360 if (isLineStart && text.length > 0) {
\r
4361 lineOffsets.push(text.length);
\r
4363 this._lineOffsets = lineOffsets;
\r
4365 return this._lineOffsets;
\r
4367 FullTextDocument.prototype.positionAt = function (offset) {
\r
4368 offset = Math.max(Math.min(offset, this._content.length), 0);
\r
4369 var lineOffsets = this.getLineOffsets();
\r
4370 var low = 0, high = lineOffsets.length;
\r
4372 return Position.create(0, offset);
\r
4374 while (low < high) {
\r
4375 var mid = Math.floor((low + high) / 2);
\r
4376 if (lineOffsets[mid] > offset) {
\r
4383 // low is the least x for which the line offset is larger than the current offset
\r
4384 // or array.length if no line offset is larger than the current offset
\r
4385 var line = low - 1;
\r
4386 return Position.create(line, offset - lineOffsets[line]);
\r
4388 FullTextDocument.prototype.offsetAt = function (position) {
\r
4389 var lineOffsets = this.getLineOffsets();
\r
4390 if (position.line >= lineOffsets.length) {
\r
4391 return this._content.length;
\r
4393 else if (position.line < 0) {
\r
4396 var lineOffset = lineOffsets[position.line];
\r
4397 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
\r
4398 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
\r
4400 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
4401 get: function () {
\r
4402 return this.getLineOffsets().length;
\r
4405 configurable: true
\r
4407 return FullTextDocument;
\r
4411 var toString = Object.prototype.toString;
\r
4412 function defined(value) {
\r
4413 return typeof value !== 'undefined';
\r
4415 Is.defined = defined;
\r
4416 function undefined(value) {
\r
4417 return typeof value === 'undefined';
\r
4419 Is.undefined = undefined;
\r
4420 function boolean(value) {
\r
4421 return value === true || value === false;
\r
4423 Is.boolean = boolean;
\r
4424 function string(value) {
\r
4425 return toString.call(value) === '[object String]';
\r
4427 Is.string = string;
\r
4428 function number(value) {
\r
4429 return toString.call(value) === '[object Number]';
\r
4431 Is.number = number;
\r
4432 function func(value) {
\r
4433 return toString.call(value) === '[object Function]';
\r
4436 function objectLiteral(value) {
\r
4437 // Strictly speaking class instances pass this check as well. Since the LSP
\r
4438 // doesn't use classes we ignore this for now. If we do we need to add something
\r
4439 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
4440 return value !== null && typeof value === 'object';
\r
4442 Is.objectLiteral = objectLiteral;
\r
4443 function typedArray(value, check) {
\r
4444 return Array.isArray(value) && value.every(check);
\r
4446 Is.typedArray = typedArray;
\r
4447 })(Is || (Is = {}));
\r
4452 /***/ (function(module, exports, __webpack_require__) {
4455 /* --------------------------------------------------------------------------------------------
\r
4456 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4457 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4458 * ------------------------------------------------------------------------------------------ */
\r
4460 Object.defineProperty(exports, "__esModule", { value: true });
\r
4461 const Is = __webpack_require__(21);
\r
4462 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
4463 const protocol_implementation_1 = __webpack_require__(22);
\r
4464 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
\r
4465 const protocol_typeDefinition_1 = __webpack_require__(23);
\r
4466 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
\r
4467 const protocol_workspaceFolders_1 = __webpack_require__(24);
\r
4468 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
\r
4469 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
\r
4470 const protocol_configuration_1 = __webpack_require__(25);
\r
4471 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
\r
4472 const protocol_colorProvider_1 = __webpack_require__(26);
\r
4473 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
\r
4474 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
\r
4475 const protocol_foldingRange_1 = __webpack_require__(27);
\r
4476 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
\r
4477 const protocol_declaration_1 = __webpack_require__(28);
\r
4478 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
\r
4479 const protocol_selectionRange_1 = __webpack_require__(29);
\r
4480 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
\r
4481 exports.SelectionRangeKind = protocol_selectionRange_1.SelectionRangeKind;
\r
4482 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
4483 let __noDynamicImport;
\r
4484 var DocumentFilter;
\r
4485 (function (DocumentFilter) {
\r
4486 function is(value) {
\r
4487 let candidate = value;
\r
4488 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
\r
4490 DocumentFilter.is = is;
\r
4491 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
\r
4493 * The `client/registerCapability` request is sent from the server to the client to register a new capability
\r
4494 * handler on the client side.
\r
4496 var RegistrationRequest;
\r
4497 (function (RegistrationRequest) {
\r
4498 RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');
\r
4499 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
\r
4501 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
\r
4502 * handler on the client side.
\r
4504 var UnregistrationRequest;
\r
4505 (function (UnregistrationRequest) {
\r
4506 UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');
\r
4507 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
\r
4508 var ResourceOperationKind;
\r
4509 (function (ResourceOperationKind) {
\r
4511 * Supports creating new files and folders.
\r
4513 ResourceOperationKind.Create = 'create';
\r
4515 * Supports renaming existing files and folders.
\r
4517 ResourceOperationKind.Rename = 'rename';
\r
4519 * Supports deleting existing files and folders.
\r
4521 ResourceOperationKind.Delete = 'delete';
\r
4522 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
\r
4523 var FailureHandlingKind;
\r
4524 (function (FailureHandlingKind) {
\r
4526 * Applying the workspace change is simply aborted if one of the changes provided
\r
4527 * fails. All operations executed before the failing operation stay executed.
\r
4529 FailureHandlingKind.Abort = 'abort';
\r
4531 * All operations are executed transactional. That means they either all
\r
4532 * succeed or no changes at all are applied to the workspace.
\r
4534 FailureHandlingKind.Transactional = 'transactional';
\r
4536 * If the workspace edit contains only textual file changes they are executed transactional.
\r
4537 * If resource changes (create, rename or delete file) are part of the change the failure
\r
4538 * handling startegy is abort.
\r
4540 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
\r
4542 * The client tries to undo the operations already executed. But there is no
\r
4543 * guaruntee that this is succeeding.
\r
4545 FailureHandlingKind.Undo = 'undo';
\r
4546 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
\r
4548 * Defines how the host (editor) should sync
\r
4549 * document changes to the language server.
\r
4551 var TextDocumentSyncKind;
\r
4552 (function (TextDocumentSyncKind) {
\r
4554 * Documents should not be synced at all.
\r
4556 TextDocumentSyncKind.None = 0;
\r
4558 * Documents are synced by always sending the full content
\r
4559 * of the document.
\r
4561 TextDocumentSyncKind.Full = 1;
\r
4563 * Documents are synced by sending the full content on open.
\r
4564 * After that only incremental updates to the document are
\r
4567 TextDocumentSyncKind.Incremental = 2;
\r
4568 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
\r
4570 * The initialize request is sent from the client to the server.
\r
4571 * It is sent once as the request after starting up the server.
\r
4572 * The requests parameter is of type [InitializeParams](#InitializeParams)
\r
4573 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
\r
4574 * resolves to such.
\r
4576 var InitializeRequest;
\r
4577 (function (InitializeRequest) {
\r
4578 InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');
\r
4579 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
\r
4581 * Known error codes for an `InitializeError`;
\r
4583 var InitializeError;
\r
4584 (function (InitializeError) {
\r
4586 * If the protocol version provided by the client can't be handled by the server.
\r
4587 * @deprecated This initialize error got replaced by client capabilities. There is
\r
4588 * no version handshake in version 3.0x
\r
4590 InitializeError.unknownProtocolVersion = 1;
\r
4591 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
\r
4593 * The intialized notification is sent from the client to the
\r
4594 * server after the client is fully initialized and the server
\r
4595 * is allowed to send requests from the server to the client.
\r
4597 var InitializedNotification;
\r
4598 (function (InitializedNotification) {
\r
4599 InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');
\r
4600 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
\r
4601 //---- Shutdown Method ----
\r
4603 * A shutdown request is sent from the client to the server.
\r
4604 * It is sent once when the client decides to shutdown the
\r
4605 * server. The only notification that is sent after a shutdown request
\r
4606 * is the exit event.
\r
4608 var ShutdownRequest;
\r
4609 (function (ShutdownRequest) {
\r
4610 ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');
\r
4611 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
\r
4612 //---- Exit Notification ----
\r
4614 * The exit event is sent from the client to the server to
\r
4615 * ask the server to exit its process.
\r
4617 var ExitNotification;
\r
4618 (function (ExitNotification) {
\r
4619 ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');
\r
4620 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
\r
4621 //---- Configuration notification ----
\r
4623 * The configuration change notification is sent from the client to the server
\r
4624 * when the client's configuration has changed. The notification contains
\r
4625 * the changed configuration as defined by the language client.
\r
4627 var DidChangeConfigurationNotification;
\r
4628 (function (DidChangeConfigurationNotification) {
\r
4629 DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');
\r
4630 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
\r
4631 //---- Message show and log notifications ----
\r
4633 * The message type
\r
4636 (function (MessageType) {
\r
4638 * An error message.
\r
4640 MessageType.Error = 1;
\r
4642 * A warning message.
\r
4644 MessageType.Warning = 2;
\r
4646 * An information message.
\r
4648 MessageType.Info = 3;
\r
4652 MessageType.Log = 4;
\r
4653 })(MessageType = exports.MessageType || (exports.MessageType = {}));
\r
4655 * The show message notification is sent from a server to a client to ask
\r
4656 * the client to display a particular message in the user interface.
\r
4658 var ShowMessageNotification;
\r
4659 (function (ShowMessageNotification) {
\r
4660 ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');
\r
4661 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
\r
4663 * The show message request is sent from the server to the client to show a message
\r
4664 * and a set of options actions to the user.
\r
4666 var ShowMessageRequest;
\r
4667 (function (ShowMessageRequest) {
\r
4668 ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');
\r
4669 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
\r
4671 * The log message notification is sent from the server to the client to ask
\r
4672 * the client to log a particular message.
\r
4674 var LogMessageNotification;
\r
4675 (function (LogMessageNotification) {
\r
4676 LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');
\r
4677 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
\r
4678 //---- Telemetry notification
\r
4680 * The telemetry event notification is sent from the server to the client to ask
\r
4681 * the client to log telemetry data.
\r
4683 var TelemetryEventNotification;
\r
4684 (function (TelemetryEventNotification) {
\r
4685 TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');
\r
4686 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
\r
4688 * The document open notification is sent from the client to the server to signal
\r
4689 * newly opened text documents. The document's truth is now managed by the client
\r
4690 * and the server must not try to read the document's truth using the document's
\r
4691 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
\r
4692 * mean that its content is presented in an editor. An open notification must not
\r
4693 * be sent more than once without a corresponding close notification send before.
\r
4694 * This means open and close notification must be balanced and the max open count
\r
4697 var DidOpenTextDocumentNotification;
\r
4698 (function (DidOpenTextDocumentNotification) {
\r
4699 DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');
\r
4700 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
\r
4702 * The document change notification is sent from the client to the server to signal
\r
4703 * changes to a text document.
\r
4705 var DidChangeTextDocumentNotification;
\r
4706 (function (DidChangeTextDocumentNotification) {
\r
4707 DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');
\r
4708 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
\r
4710 * The document close notification is sent from the client to the server when
\r
4711 * the document got closed in the client. The document's truth now exists where
\r
4712 * the document's uri points to (e.g. if the document's uri is a file uri the
\r
4713 * truth now exists on disk). As with the open notification the close notification
\r
4714 * is about managing the document's content. Receiving a close notification
\r
4715 * doesn't mean that the document was open in an editor before. A close
\r
4716 * notification requires a previous open notification to be sent.
\r
4718 var DidCloseTextDocumentNotification;
\r
4719 (function (DidCloseTextDocumentNotification) {
\r
4720 DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');
\r
4721 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
\r
4723 * The document save notification is sent from the client to the server when
\r
4724 * the document got saved in the client.
\r
4726 var DidSaveTextDocumentNotification;
\r
4727 (function (DidSaveTextDocumentNotification) {
\r
4728 DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');
\r
4729 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
\r
4731 * A document will save notification is sent from the client to the server before
\r
4732 * the document is actually saved.
\r
4734 var WillSaveTextDocumentNotification;
\r
4735 (function (WillSaveTextDocumentNotification) {
\r
4736 WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');
\r
4737 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
\r
4739 * A document will save request is sent from the client to the server before
\r
4740 * the document is actually saved. The request can return an array of TextEdits
\r
4741 * which will be applied to the text document before it is saved. Please note that
\r
4742 * clients might drop results if computing the text edits took too long or if a
\r
4743 * server constantly fails on this request. This is done to keep the save fast and
\r
4746 var WillSaveTextDocumentWaitUntilRequest;
\r
4747 (function (WillSaveTextDocumentWaitUntilRequest) {
\r
4748 WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');
\r
4749 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
\r
4750 //---- File eventing ----
\r
4752 * The watched files notification is sent from the client to the server when
\r
4753 * the client detects changes to file watched by the language client.
\r
4755 var DidChangeWatchedFilesNotification;
\r
4756 (function (DidChangeWatchedFilesNotification) {
\r
4757 DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');
\r
4758 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
\r
4760 * The file event type
\r
4762 var FileChangeType;
\r
4763 (function (FileChangeType) {
\r
4765 * The file got created.
\r
4767 FileChangeType.Created = 1;
\r
4769 * The file got changed.
\r
4771 FileChangeType.Changed = 2;
\r
4773 * The file got deleted.
\r
4775 FileChangeType.Deleted = 3;
\r
4776 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
\r
4778 (function (WatchKind) {
\r
4780 * Interested in create events.
\r
4782 WatchKind.Create = 1;
\r
4784 * Interested in change events
\r
4786 WatchKind.Change = 2;
\r
4788 * Interested in delete events
\r
4790 WatchKind.Delete = 4;
\r
4791 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
\r
4792 //---- Diagnostic notification ----
\r
4794 * Diagnostics notification are sent from the server to the client to signal
\r
4795 * results of validation runs.
\r
4797 var PublishDiagnosticsNotification;
\r
4798 (function (PublishDiagnosticsNotification) {
\r
4799 PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');
\r
4800 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
\r
4802 * How a completion was triggered
\r
4804 var CompletionTriggerKind;
\r
4805 (function (CompletionTriggerKind) {
\r
4807 * Completion was triggered by typing an identifier (24x7 code
\r
4808 * complete), manual invocation (e.g Ctrl+Space) or via API.
\r
4810 CompletionTriggerKind.Invoked = 1;
\r
4812 * Completion was triggered by a trigger character specified by
\r
4813 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
\r
4815 CompletionTriggerKind.TriggerCharacter = 2;
\r
4817 * Completion was re-triggered as current completion list is incomplete
\r
4819 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
\r
4820 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
\r
4822 * Request to request completion at a given text document position. The request's
\r
4823 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
\r
4824 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
\r
4825 * or a Thenable that resolves to such.
\r
4827 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
\r
4828 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
\r
4829 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
\r
4830 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
\r
4832 var CompletionRequest;
\r
4833 (function (CompletionRequest) {
\r
4834 CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');
\r
4835 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
\r
4837 * Request to resolve additional information for a given completion item.The request's
\r
4838 * parameter is of type [CompletionItem](#CompletionItem) the response
\r
4839 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
\r
4841 var CompletionResolveRequest;
\r
4842 (function (CompletionResolveRequest) {
\r
4843 CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');
\r
4844 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
\r
4845 //---- Hover Support -------------------------------
\r
4847 * Request to request hover information at a given text document position. The request's
\r
4848 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
\r
4849 * type [Hover](#Hover) or a Thenable that resolves to such.
\r
4852 (function (HoverRequest) {
\r
4853 HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');
\r
4854 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
\r
4855 var SignatureHelpRequest;
\r
4856 (function (SignatureHelpRequest) {
\r
4857 SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');
\r
4858 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
\r
4859 //---- Goto Definition -------------------------------------
\r
4861 * A request to resolve the definition location of a symbol at a given text
\r
4862 * document position. The request's parameter is of type [TextDocumentPosition]
\r
4863 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
\r
4864 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
\r
4867 var DefinitionRequest;
\r
4868 (function (DefinitionRequest) {
\r
4869 DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');
\r
4870 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
\r
4872 * A request to resolve project-wide references for the symbol denoted
\r
4873 * by the given text document position. The request's parameter is of
\r
4874 * type [ReferenceParams](#ReferenceParams) the response is of type
\r
4875 * [Location[]](#Location) or a Thenable that resolves to such.
\r
4877 var ReferencesRequest;
\r
4878 (function (ReferencesRequest) {
\r
4879 ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');
\r
4880 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
\r
4881 //---- Document Highlight ----------------------------------
\r
4883 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
\r
4884 * text document position. The request's parameter is of type [TextDocumentPosition]
\r
4885 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
\r
4886 * (#DocumentHighlight) or a Thenable that resolves to such.
\r
4888 var DocumentHighlightRequest;
\r
4889 (function (DocumentHighlightRequest) {
\r
4890 DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');
\r
4891 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
\r
4892 //---- Document Symbol Provider ---------------------------
\r
4894 * A request to list all symbols found in a given text document. The request's
\r
4895 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
\r
4896 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
\r
4897 * that resolves to such.
\r
4899 var DocumentSymbolRequest;
\r
4900 (function (DocumentSymbolRequest) {
\r
4901 DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');
\r
4902 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
\r
4903 //---- Workspace Symbol Provider ---------------------------
\r
4905 * A request to list project-wide symbols matching the query string given
\r
4906 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
\r
4907 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
\r
4908 * resolves to such.
\r
4910 var WorkspaceSymbolRequest;
\r
4911 (function (WorkspaceSymbolRequest) {
\r
4912 WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');
\r
4913 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
\r
4915 * A request to provide commands for the given text document and range.
\r
4917 var CodeActionRequest;
\r
4918 (function (CodeActionRequest) {
\r
4919 CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');
\r
4920 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
\r
4922 * A request to provide code lens for the given text document.
\r
4924 var CodeLensRequest;
\r
4925 (function (CodeLensRequest) {
\r
4926 CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');
\r
4927 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
\r
4929 * A request to resolve a command for a given code lens.
\r
4931 var CodeLensResolveRequest;
\r
4932 (function (CodeLensResolveRequest) {
\r
4933 CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');
\r
4934 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
\r
4936 * A request to to format a whole document.
\r
4938 var DocumentFormattingRequest;
\r
4939 (function (DocumentFormattingRequest) {
\r
4940 DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');
\r
4941 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
\r
4943 * A request to to format a range in a document.
\r
4945 var DocumentRangeFormattingRequest;
\r
4946 (function (DocumentRangeFormattingRequest) {
\r
4947 DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');
\r
4948 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
\r
4950 * A request to format a document on type.
\r
4952 var DocumentOnTypeFormattingRequest;
\r
4953 (function (DocumentOnTypeFormattingRequest) {
\r
4954 DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');
\r
4955 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
\r
4957 * A request to rename a symbol.
\r
4959 var RenameRequest;
\r
4960 (function (RenameRequest) {
\r
4961 RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');
\r
4962 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
\r
4964 * A request to test and perform the setup necessary for a rename.
\r
4966 var PrepareRenameRequest;
\r
4967 (function (PrepareRenameRequest) {
\r
4968 PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');
\r
4969 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
\r
4971 * A request to provide document links
\r
4973 var DocumentLinkRequest;
\r
4974 (function (DocumentLinkRequest) {
\r
4975 DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');
\r
4976 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
\r
4978 * Request to resolve additional information for a given document link. The request's
\r
4979 * parameter is of type [DocumentLink](#DocumentLink) the response
\r
4980 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
\r
4982 var DocumentLinkResolveRequest;
\r
4983 (function (DocumentLinkResolveRequest) {
\r
4984 DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');
\r
4985 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
\r
4987 * A request send from the client to the server to execute a command. The request might return
\r
4988 * a workspace edit which the client will apply to the workspace.
\r
4990 var ExecuteCommandRequest;
\r
4991 (function (ExecuteCommandRequest) {
\r
4992 ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');
\r
4993 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
\r
4995 * A request sent from the server to the client to modified certain resources.
\r
4997 var ApplyWorkspaceEditRequest;
\r
4998 (function (ApplyWorkspaceEditRequest) {
\r
4999 ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');
\r
5000 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
\r
5005 /***/ (function(module, exports, __webpack_require__) {
5008 /* --------------------------------------------------------------------------------------------
\r
5009 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5010 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5011 * ------------------------------------------------------------------------------------------ */
\r
5013 Object.defineProperty(exports, "__esModule", { value: true });
\r
5014 function boolean(value) {
\r
5015 return value === true || value === false;
\r
5017 exports.boolean = boolean;
\r
5018 function string(value) {
\r
5019 return typeof value === 'string' || value instanceof String;
\r
5021 exports.string = string;
\r
5022 function number(value) {
\r
5023 return typeof value === 'number' || value instanceof Number;
\r
5025 exports.number = number;
\r
5026 function error(value) {
\r
5027 return value instanceof Error;
\r
5029 exports.error = error;
\r
5030 function func(value) {
\r
5031 return typeof value === 'function';
\r
5033 exports.func = func;
\r
5034 function array(value) {
\r
5035 return Array.isArray(value);
\r
5037 exports.array = array;
\r
5038 function stringArray(value) {
\r
5039 return array(value) && value.every(elem => string(elem));
\r
5041 exports.stringArray = stringArray;
\r
5042 function typedArray(value, check) {
\r
5043 return Array.isArray(value) && value.every(check);
\r
5045 exports.typedArray = typedArray;
\r
5046 function thenable(value) {
\r
5047 return value && func(value.then);
\r
5049 exports.thenable = thenable;
\r
5054 /***/ (function(module, exports, __webpack_require__) {
5057 /* --------------------------------------------------------------------------------------------
\r
5058 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5059 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5060 * ------------------------------------------------------------------------------------------ */
\r
5062 Object.defineProperty(exports, "__esModule", { value: true });
\r
5063 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5064 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5065 let __noDynamicImport;
\r
5067 * A request to resolve the implementation locations of a symbol at a given text
\r
5068 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5069 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
5070 * Thenable that resolves to such.
\r
5072 var ImplementationRequest;
\r
5073 (function (ImplementationRequest) {
\r
5074 ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');
\r
5075 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
\r
5080 /***/ (function(module, exports, __webpack_require__) {
5083 /* --------------------------------------------------------------------------------------------
\r
5084 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5085 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5086 * ------------------------------------------------------------------------------------------ */
\r
5088 Object.defineProperty(exports, "__esModule", { value: true });
\r
5089 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5090 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5091 let __noDynamicImport;
\r
5093 * A request to resolve the type definition locations of a symbol at a given text
\r
5094 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5095 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
5096 * Thenable that resolves to such.
\r
5098 var TypeDefinitionRequest;
\r
5099 (function (TypeDefinitionRequest) {
\r
5100 TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');
\r
5101 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
\r
5106 /***/ (function(module, exports, __webpack_require__) {
5109 /* --------------------------------------------------------------------------------------------
\r
5110 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5111 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5112 * ------------------------------------------------------------------------------------------ */
\r
5114 Object.defineProperty(exports, "__esModule", { value: true });
\r
5115 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5117 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
\r
5119 var WorkspaceFoldersRequest;
\r
5120 (function (WorkspaceFoldersRequest) {
\r
5121 WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');
\r
5122 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
\r
5124 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
\r
5125 * folder configuration changes.
\r
5127 var DidChangeWorkspaceFoldersNotification;
\r
5128 (function (DidChangeWorkspaceFoldersNotification) {
\r
5129 DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');
\r
5130 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
\r
5135 /***/ (function(module, exports, __webpack_require__) {
5138 /* --------------------------------------------------------------------------------------------
\r
5139 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5140 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5141 * ------------------------------------------------------------------------------------------ */
\r
5143 Object.defineProperty(exports, "__esModule", { value: true });
\r
5144 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5146 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
\r
5147 * configuration setting.
\r
5149 * This pull model replaces the old push model were the client signaled configuration change via an
\r
5150 * event. If the server still needs to react to configuration changes (since the server caches the
\r
5151 * result of `workspace/configuration` requests) the server should register for an empty configuration
\r
5152 * change event and empty the cache if such an event is received.
\r
5154 var ConfigurationRequest;
\r
5155 (function (ConfigurationRequest) {
\r
5156 ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');
\r
5157 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
\r
5162 /***/ (function(module, exports, __webpack_require__) {
5165 /* --------------------------------------------------------------------------------------------
\r
5166 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5167 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5168 * ------------------------------------------------------------------------------------------ */
\r
5170 Object.defineProperty(exports, "__esModule", { value: true });
\r
5171 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5173 * A request to list all color symbols found in a given text document. The request's
\r
5174 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
\r
5175 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
5176 * that resolves to such.
\r
5178 var DocumentColorRequest;
\r
5179 (function (DocumentColorRequest) {
\r
5180 DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');
\r
5181 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
\r
5183 * A request to list all presentation for a color. The request's
\r
5184 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
\r
5185 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
5186 * that resolves to such.
\r
5188 var ColorPresentationRequest;
\r
5189 (function (ColorPresentationRequest) {
\r
5190 ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');
\r
5191 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
\r
5196 /***/ (function(module, exports, __webpack_require__) {
5200 /*---------------------------------------------------------------------------------------------
\r
5201 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5202 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5203 *--------------------------------------------------------------------------------------------*/
\r
5204 Object.defineProperty(exports, "__esModule", { value: true });
\r
5205 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5207 * Enum of known range kinds
\r
5209 var FoldingRangeKind;
\r
5210 (function (FoldingRangeKind) {
\r
5212 * Folding range for a comment
\r
5214 FoldingRangeKind["Comment"] = "comment";
\r
5216 * Folding range for a imports or includes
\r
5218 FoldingRangeKind["Imports"] = "imports";
\r
5220 * Folding range for a region (e.g. `#region`)
\r
5222 FoldingRangeKind["Region"] = "region";
\r
5223 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
\r
5225 * A request to provide folding ranges in a document. The request's
\r
5226 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
\r
5227 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
\r
5228 * that resolves to such.
\r
5230 var FoldingRangeRequest;
\r
5231 (function (FoldingRangeRequest) {
\r
5232 FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');
\r
5233 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
\r
5238 /***/ (function(module, exports, __webpack_require__) {
5241 /* --------------------------------------------------------------------------------------------
\r
5242 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5243 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5244 * ------------------------------------------------------------------------------------------ */
\r
5246 Object.defineProperty(exports, "__esModule", { value: true });
\r
5247 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5248 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5249 let __noDynamicImport;
\r
5251 * A request to resolve the type definition locations of a symbol at a given text
\r
5252 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5253 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
\r
5254 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
\r
5257 var DeclarationRequest;
\r
5258 (function (DeclarationRequest) {
\r
5259 DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');
\r
5260 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
\r
5265 /***/ (function(module, exports, __webpack_require__) {
5269 /*---------------------------------------------------------------------------------------------
\r
5270 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5271 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5272 *--------------------------------------------------------------------------------------------*/
\r
5273 Object.defineProperty(exports, "__esModule", { value: true });
\r
5274 const vscode_jsonrpc_1 = __webpack_require__(6);
\r
5276 * Enum of known selection range kinds
\r
5278 var SelectionRangeKind;
\r
5279 (function (SelectionRangeKind) {
\r
5283 SelectionRangeKind["Empty"] = "";
\r
5285 * The statment kind, its value is `statement`, possible extensions can be
\r
5286 * `statement.if` etc
\r
5288 SelectionRangeKind["Statement"] = "statement";
\r
5290 * The declaration kind, its value is `declaration`, possible extensions can be
\r
5291 * `declaration.function`, `declaration.class` etc.
\r
5293 SelectionRangeKind["Declaration"] = "declaration";
\r
5294 })(SelectionRangeKind = exports.SelectionRangeKind || (exports.SelectionRangeKind = {}));
\r
5296 * A request to provide selection ranges in a document. The request's
\r
5297 * parameter is of type [TextDocumentPositionParams](#TextDocumentPositionParams), the
\r
5298 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
\r
5299 * that resolves to such.
\r
5301 var SelectionRangeRequest;
\r
5302 (function (SelectionRangeRequest) {
\r
5303 SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/selectionRange');
\r
5304 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
\r
5309 /***/ (function(module, exports, __webpack_require__) {
5313 Object.defineProperty(exports, "__esModule", { value: true });
5314 const tslib_1 = __webpack_require__(1);
5315 const path_1 = tslib_1.__importDefault(__webpack_require__(4));
5316 const fs_1 = tslib_1.__importDefault(__webpack_require__(3));
5317 const which_1 = tslib_1.__importDefault(__webpack_require__(31));
5318 function exists(file) {
5319 return fs_1.default.existsSync(file);
5321 function findEslint(rootPath) {
5322 return tslib_1.__awaiter(this, void 0, void 0, function* () {
5323 const platform = process.platform;
5324 if (platform === 'win32' &&
5325 (exists(path_1.default.join(rootPath, 'node_modules', '.bin', 'eslint.cmd')))) {
5326 return path_1.default.join('.', 'node_modules', '.bin', 'eslint.cmd');
5328 else if ((platform === 'linux' || platform === 'darwin') &&
5329 (exists(path_1.default.join(rootPath, 'node_modules', '.bin', 'eslint')))) {
5330 return path_1.default.join('.', 'node_modules', '.bin', 'eslint');
5334 return which_1.default.sync('eslint');
5342 exports.findEslint = findEslint;
5343 //# sourceMappingURL=utils.js.map
5347 /***/ (function(module, exports, __webpack_require__) {
5349 module.exports = which
5350 which.sync = whichSync
5352 var isWindows = process.platform === 'win32' ||
5353 process.env.OSTYPE === 'cygwin' ||
5354 process.env.OSTYPE === 'msys'
5356 var path = __webpack_require__(4)
5357 var COLON = isWindows ? ';' : ':'
5358 var isexe = __webpack_require__(32)
5360 function getNotFoundError (cmd) {
5361 var er = new Error('not found: ' + cmd)
5367 function getPathInfo (cmd, opt) {
5368 var colon = opt.colon || COLON
5369 var pathEnv = opt.path || process.env.PATH || ''
5372 pathEnv = pathEnv.split(colon)
5376 pathEnv.unshift(process.cwd())
5377 pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
5378 pathExt = pathExtExe.split(colon)
5381 // Always test the cmd itself first. isexe will check to make sure
5382 // it's found in the pathExt set.
5383 if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
5387 // If it has a slash, then we don't bother searching the pathenv.
5388 // just check the file itself, and that's it.
5389 if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
5399 function which (cmd, opt, cb) {
5400 if (typeof opt === 'function') {
5405 var info = getPathInfo(cmd, opt)
5406 var pathEnv = info.env
5407 var pathExt = info.ext
5408 var pathExtExe = info.extExe
5411 ;(function F (i, l) {
5413 if (opt.all && found.length)
5414 return cb(null, found)
5416 return cb(getNotFoundError(cmd))
5419 var pathPart = pathEnv[i]
5420 if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
5421 pathPart = pathPart.slice(1, -1)
5423 var p = path.join(pathPart, cmd)
5424 if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
5425 p = cmd.slice(0, 2) + p
5427 ;(function E (ii, ll) {
5428 if (ii === ll) return F(i + 1, l)
5429 var ext = pathExt[ii]
5430 isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
5435 return cb(null, p + ext)
5437 return E(ii + 1, ll)
5439 })(0, pathExt.length)
5440 })(0, pathEnv.length)
5443 function whichSync (cmd, opt) {
5446 var info = getPathInfo(cmd, opt)
5447 var pathEnv = info.env
5448 var pathExt = info.ext
5449 var pathExtExe = info.extExe
5452 for (var i = 0, l = pathEnv.length; i < l; i ++) {
5453 var pathPart = pathEnv[i]
5454 if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
5455 pathPart = pathPart.slice(1, -1)
5457 var p = path.join(pathPart, cmd)
5458 if (!pathPart && /^\.[\\\/]/.test(cmd)) {
5459 p = cmd.slice(0, 2) + p
5461 for (var j = 0, ll = pathExt.length; j < ll; j ++) {
5462 var cur = p + pathExt[j]
5465 is = isexe.sync(cur, { pathExt: pathExtExe })
5476 if (opt.all && found.length)
5482 throw getNotFoundError(cmd)
5488 /***/ (function(module, exports, __webpack_require__) {
5490 var fs = __webpack_require__(3)
5492 if (process.platform === 'win32' || global.TESTING_WINDOWS) {
5493 core = __webpack_require__(33)
5495 core = __webpack_require__(34)
5498 module.exports = isexe
5501 function isexe (path, options, cb) {
5502 if (typeof options === 'function') {
5508 if (typeof Promise !== 'function') {
5509 throw new TypeError('callback not provided')
5512 return new Promise(function (resolve, reject) {
5513 isexe(path, options || {}, function (er, is) {
5523 core(path, options || {}, function (er, is) {
5524 // ignore EACCES because that just means we aren't allowed to run it
5526 if (er.code === 'EACCES' || options && options.ignoreErrors) {
5535 function sync (path, options) {
5536 // my kingdom for a filtered catch
5538 return core.sync(path, options || {})
5540 if (options && options.ignoreErrors || er.code === 'EACCES') {
5551 /***/ (function(module, exports, __webpack_require__) {
5553 module.exports = isexe
5556 var fs = __webpack_require__(3)
5558 function checkPathExt (path, options) {
5559 var pathext = options.pathExt !== undefined ?
5560 options.pathExt : process.env.PATHEXT
5566 pathext = pathext.split(';')
5567 if (pathext.indexOf('') !== -1) {
5570 for (var i = 0; i < pathext.length; i++) {
5571 var p = pathext[i].toLowerCase()
5572 if (p && path.substr(-p.length).toLowerCase() === p) {
5579 function checkStat (stat, path, options) {
5580 if (!stat.isSymbolicLink() && !stat.isFile()) {
5583 return checkPathExt(path, options)
5586 function isexe (path, options, cb) {
5587 fs.stat(path, function (er, stat) {
5588 cb(er, er ? false : checkStat(stat, path, options))
5592 function sync (path, options) {
5593 return checkStat(fs.statSync(path), path, options)
5599 /***/ (function(module, exports, __webpack_require__) {
5601 module.exports = isexe
5604 var fs = __webpack_require__(3)
5606 function isexe (path, options, cb) {
5607 fs.stat(path, function (er, stat) {
5608 cb(er, er ? false : checkStat(stat, options))
5612 function sync (path, options) {
5613 return checkStat(fs.statSync(path), options)
5616 function checkStat (stat, options) {
5617 return stat.isFile() && checkMode(stat, options)
5620 function checkMode (stat, options) {
5625 var myUid = options.uid !== undefined ?
5626 options.uid : process.getuid && process.getuid()
5627 var myGid = options.gid !== undefined ?
5628 options.gid : process.getgid && process.getgid()
5630 var u = parseInt('100', 8)
5631 var g = parseInt('010', 8)
5632 var o = parseInt('001', 8)
5635 var ret = (mod & o) ||
5636 (mod & g) && gid === myGid ||
5637 (mod & u) && uid === myUid ||
5638 (mod & ug) && myUid === 0