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 var __importDefault = (this && this.__importDefault) || function (mod) {
94 return (mod && mod.__esModule) ? mod : { "default": mod };
96 Object.defineProperty(exports, "__esModule", { value: true });
97 const coc_nvim_1 = __webpack_require__(1);
98 const fs_1 = __importDefault(__webpack_require__(2));
99 const path_1 = __importDefault(__webpack_require__(3));
100 const vscode_languageserver_protocol_1 = __webpack_require__(4);
101 const utils_1 = __webpack_require__(33);
102 const defaultLanguages = ['javascript', 'javascriptreact', 'typescript', 'typescriptreact'];
105 const toString = Object.prototype.toString;
106 function boolean(value) {
107 return value === true || value === false;
109 Is.boolean = boolean;
110 function string(value) {
111 return toString.call(value) === '[object String]';
115 var OpenESLintDocRequest;
116 (function (OpenESLintDocRequest) {
117 OpenESLintDocRequest.type = new vscode_languageserver_protocol_1.RequestType('eslint/openDoc');
118 })(OpenESLintDocRequest || (OpenESLintDocRequest = {}));
120 (function (DirectoryItem) {
122 let candidate = item;
124 Is.string(candidate.directory) &&
125 (Is.boolean(candidate.changeProcessCWD) ||
126 candidate.changeProcessCWD === void 0));
128 DirectoryItem.is = is;
129 })(DirectoryItem || (DirectoryItem = {}));
131 (function (NoConfigRequest) {
132 NoConfigRequest.type = new vscode_languageserver_protocol_1.RequestType('eslint/noConfig');
133 })(NoConfigRequest || (NoConfigRequest = {}));
134 var NoESLintLibraryRequest;
135 (function (NoESLintLibraryRequest) {
136 NoESLintLibraryRequest.type = new vscode_languageserver_protocol_1.RequestType('eslint/noLibrary');
137 })(NoESLintLibraryRequest || (NoESLintLibraryRequest = {}));
138 const exitCalled = new vscode_languageserver_protocol_1.NotificationType('eslint/exitCalled');
139 async function createDefaultConfiguration() {
140 let { root } = coc_nvim_1.workspace;
148 for (let configFile of configFiles) {
149 if (fs_1.default.existsSync(path_1.default.join(root, configFile))) {
150 coc_nvim_1.workspace.openResource(coc_nvim_1.Uri.file(root).toString()).catch(_e => {
156 const eslintCommand = await utils_1.findEslint(root);
157 await coc_nvim_1.workspace.nvim.call('coc#util#open_terminal', [{
158 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 async function activate(context) {
170 let { subscriptions } = context;
171 const config = coc_nvim_1.workspace.getConfiguration().get('eslint', {});
172 const filetypes = config.filetypes || defaultLanguages;
173 const selector = filetypes.reduce((res, filetype) => {
174 return res.concat([{ language: filetype, scheme: 'file' }, { language: filetype, scheme: 'untitled' }]);
176 const nodeEnv = config.nodeEnv;
180 let serverOptions = {
181 runtime: config.runtime,
182 module: context.asAbsolutePath('./lib/server.js'),
183 args: ['--node-ipc'],
184 transport: coc_nvim_1.TransportKind.ipc,
186 cwd: coc_nvim_1.workspace.root,
187 execArgv: config.execArgv,
191 const syncedDocuments = new Map();
192 let clientOptions = {
193 documentSelector: selector,
195 configurationSection: 'eslint',
197 coc_nvim_1.workspace.createFileSystemWatcher('**/.eslintr{c.js,c.yaml,c.yml,c,c.json}'),
198 coc_nvim_1.workspace.createFileSystemWatcher('**/.eslintignore'),
199 coc_nvim_1.workspace.createFileSystemWatcher('**/package.json')
202 outputChannelName: 'eslint',
203 initializationOptions: config.initializationOptions,
204 diagnosticCollectionName: 'eslint',
205 initializationFailedHandler: error => {
206 coc_nvim_1.workspace.showMessage(`Eslint server initialization failed: ${error.message}.`, 'error');
210 didOpen: (document, next) => {
211 if (shouldBeValidated(document)) {
213 syncedDocuments.set(document.uri.toString(), document);
217 didChange: (event, next) => {
218 if (syncedDocuments.has(event.textDocument.uri)) {
222 didClose: (document, next) => {
223 let uri = document.uri.toString();
224 if (syncedDocuments.has(uri)) {
225 syncedDocuments.delete(uri);
229 provideCodeActions: (document, range, context, token, next) => {
230 if (!syncedDocuments.has(document.uri.toString()) || !context.diagnostics || context.diagnostics.length === 0) {
233 let eslintDiagnostics = [];
234 for (let diagnostic of context.diagnostics) {
235 if (diagnostic.source === 'eslint') {
236 eslintDiagnostics.push(diagnostic);
239 if (eslintDiagnostics.length === 0) {
242 let newContext = Object.assign({}, context, {
243 diagnostics: eslintDiagnostics
245 return next(document, range, newContext, token);
248 configuration: (params, _token, _next) => {
249 return params.items.map(item => {
250 let uri = item.scopeUri;
251 let config = coc_nvim_1.workspace.getConfiguration('eslint', uri);
252 let pm = config.get('packageManager', 'npm');
254 packageManager: pm === 'yarn' ? 'yarn' : 'npm',
255 quiet: config.get('quiet', false),
256 validate: config.get('validate', true),
257 autoFix: config.get('autoFix', false),
258 autoFixOnSave: config.get('autoFixOnSave', false),
259 autoFixSkipRules: config.get('autoFixSkipRules', []),
260 nodePath: config.get('nodePath', undefined),
261 options: config.get('options', {}),
262 run: config.get('run', 'onType'),
263 workspaceFolder: getWorkspaceFolder(uri),
264 workingDirectory: undefined,
266 disableRuleComment: config.get('codeAction.disableRuleComment', { enable: true, location: 'separateLine' }),
267 showDocumentation: config.get('codeAction.showDocumentation', { enable: true })
276 let client = new coc_nvim_1.LanguageClient('eslint', 'eslint langserver', serverOptions, clientOptions);
277 subscriptions.push(coc_nvim_1.services.registLanguageClient(client));
278 function onDidChangeConfiguration(e) {
279 if (!e.affectsConfiguration('eslint') || client.serviceState != coc_nvim_1.ServiceStat.Running)
281 for (let textDocument of syncedDocuments.values()) {
282 if (!shouldBeValidated(textDocument)) {
283 syncedDocuments.delete(textDocument.uri);
284 client.sendNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, { textDocument: { uri: textDocument.uri } });
287 for (let textDocument of coc_nvim_1.workspace.textDocuments) {
288 if (!syncedDocuments.has(textDocument.uri.toString()) && shouldBeValidated(textDocument)) {
289 client.sendNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, {
291 uri: textDocument.uri,
292 languageId: textDocument.languageId,
293 version: textDocument.version,
294 text: textDocument.getText()
297 syncedDocuments.set(textDocument.uri.toString(), textDocument);
301 subscriptions.push(coc_nvim_1.commands.registerCommand('eslint.createConfig', createDefaultConfiguration));
302 subscriptions.push(coc_nvim_1.commands.registerCommand('eslint.executeAutofix', async () => {
303 let document = await coc_nvim_1.workspace.document;
304 if (!shouldBeValidated(document.textDocument)) {
305 coc_nvim_1.workspace.showMessage(`Current filetype ${document.textDocument.languageId} is not handled by coc-eslint.`, 'warning');
308 await client.onReady();
311 version: document.version
314 command: 'eslint.applyAutoFix',
315 arguments: [textDocument]
317 client.sendRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, params)
318 .then(undefined, () => {
319 coc_nvim_1.workspace.showMessage('Failed to apply ESLint fixes to the document.', 'error');
322 client.onReady().then(() => {
323 client.onNotification(exitCalled, params => {
324 coc_nvim_1.workspace.showMessage(`Server process exited with code ${params[0]}. This usually indicates a misconfigured ESLint setup.`, 'error');
326 client.onRequest(NoConfigRequest.type, params => {
327 let uri = coc_nvim_1.Uri.parse(params.document.uri);
328 let config = coc_nvim_1.workspace.getConfiguration('eslint', uri.toString());
329 if (config.get('quiet', false))
331 let fileLocation = uri.fsPath;
332 coc_nvim_1.workspace.showMessage(`No ESLint configuration (e.g .eslintrc) found for file: ${fileLocation}`, 'warning');
335 client.onRequest(NoESLintLibraryRequest.type, params => {
336 let uri = coc_nvim_1.Uri.parse(params.source.uri);
337 let config = coc_nvim_1.workspace.getConfiguration('eslint', uri.toString());
338 if (config.get('quiet', false))
340 coc_nvim_1.workspace.showMessage(`Failed to load the ESLint library for the document ${uri.fsPath}`, 'warning');
343 client.onRequest(OpenESLintDocRequest.type, async (params) => {
344 await coc_nvim_1.commands.executeCommand('vscode.open', coc_nvim_1.Uri.parse(params.url));
347 coc_nvim_1.workspace.onDidChangeConfiguration(onDidChangeConfiguration, null, subscriptions);
352 exports.activate = activate;
353 function getWorkspaceFolder(uri) {
354 let fsPath = coc_nvim_1.Uri.parse(uri).fsPath;
355 let folder = coc_nvim_1.workspace.workspaceFolders.find(o => fsPath.startsWith(coc_nvim_1.Uri.parse(o.uri).fsPath));
362 /***/ (function(module, exports) {
364 module.exports = require("coc.nvim");
368 /***/ (function(module, exports) {
370 module.exports = require("fs");
374 /***/ (function(module, exports) {
376 module.exports = require("path");
380 /***/ (function(module, exports, __webpack_require__) {
383 /* --------------------------------------------------------------------------------------------
\r
384 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
385 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
386 * ------------------------------------------------------------------------------------------ */
\r
388 function __export(m) {
\r
389 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
391 Object.defineProperty(exports, "__esModule", { value: true });
\r
392 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
393 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
\r
394 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
\r
395 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
\r
396 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
\r
397 exports.Disposable = vscode_jsonrpc_1.Disposable;
\r
398 exports.Event = vscode_jsonrpc_1.Event;
\r
399 exports.Emitter = vscode_jsonrpc_1.Emitter;
\r
400 exports.Trace = vscode_jsonrpc_1.Trace;
\r
401 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
\r
402 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
\r
403 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
\r
404 exports.RequestType = vscode_jsonrpc_1.RequestType;
\r
405 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
\r
406 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
\r
407 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
\r
408 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
\r
409 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
\r
410 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
\r
411 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
\r
412 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
\r
413 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
\r
414 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
\r
415 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
\r
416 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
\r
417 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
\r
418 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
\r
419 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
\r
420 exports.ProgressType = vscode_jsonrpc_1.ProgressType;
\r
421 __export(__webpack_require__(18));
\r
422 __export(__webpack_require__(19));
\r
423 const callHierarchy = __webpack_require__(31);
\r
424 const st = __webpack_require__(32);
\r
426 (function (Proposed) {
\r
427 let CallHierarchyPrepareRequest;
\r
428 (function (CallHierarchyPrepareRequest) {
\r
429 CallHierarchyPrepareRequest.method = callHierarchy.CallHierarchyPrepareRequest.method;
\r
430 CallHierarchyPrepareRequest.type = callHierarchy.CallHierarchyPrepareRequest.type;
\r
431 })(CallHierarchyPrepareRequest = Proposed.CallHierarchyPrepareRequest || (Proposed.CallHierarchyPrepareRequest = {}));
\r
432 let CallHierarchyIncomingCallsRequest;
\r
433 (function (CallHierarchyIncomingCallsRequest) {
\r
434 CallHierarchyIncomingCallsRequest.method = callHierarchy.CallHierarchyIncomingCallsRequest.method;
\r
435 CallHierarchyIncomingCallsRequest.type = callHierarchy.CallHierarchyIncomingCallsRequest.type;
\r
436 })(CallHierarchyIncomingCallsRequest = Proposed.CallHierarchyIncomingCallsRequest || (Proposed.CallHierarchyIncomingCallsRequest = {}));
\r
437 let CallHierarchyOutgoingCallsRequest;
\r
438 (function (CallHierarchyOutgoingCallsRequest) {
\r
439 CallHierarchyOutgoingCallsRequest.method = callHierarchy.CallHierarchyOutgoingCallsRequest.method;
\r
440 CallHierarchyOutgoingCallsRequest.type = callHierarchy.CallHierarchyOutgoingCallsRequest.type;
\r
441 })(CallHierarchyOutgoingCallsRequest = Proposed.CallHierarchyOutgoingCallsRequest || (Proposed.CallHierarchyOutgoingCallsRequest = {}));
\r
442 Proposed.SemanticTokenTypes = st.SemanticTokenTypes;
\r
443 Proposed.SemanticTokenModifiers = st.SemanticTokenModifiers;
\r
444 Proposed.SemanticTokens = st.SemanticTokens;
\r
445 let SemanticTokensRequest;
\r
446 (function (SemanticTokensRequest) {
\r
447 SemanticTokensRequest.method = st.SemanticTokensRequest.method;
\r
448 SemanticTokensRequest.type = st.SemanticTokensRequest.type;
\r
449 })(SemanticTokensRequest = Proposed.SemanticTokensRequest || (Proposed.SemanticTokensRequest = {}));
\r
450 let SemanticTokensEditsRequest;
\r
451 (function (SemanticTokensEditsRequest) {
\r
452 SemanticTokensEditsRequest.method = st.SemanticTokensEditsRequest.method;
\r
453 SemanticTokensEditsRequest.type = st.SemanticTokensEditsRequest.type;
\r
454 })(SemanticTokensEditsRequest = Proposed.SemanticTokensEditsRequest || (Proposed.SemanticTokensEditsRequest = {}));
\r
455 let SemanticTokensRangeRequest;
\r
456 (function (SemanticTokensRangeRequest) {
\r
457 SemanticTokensRangeRequest.method = st.SemanticTokensRangeRequest.method;
\r
458 SemanticTokensRangeRequest.type = st.SemanticTokensRangeRequest.type;
\r
459 })(SemanticTokensRangeRequest = Proposed.SemanticTokensRangeRequest || (Proposed.SemanticTokensRangeRequest = {}));
\r
460 })(Proposed = exports.Proposed || (exports.Proposed = {}));
\r
461 function createProtocolConnection(reader, writer, logger, strategy) {
\r
462 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
\r
464 exports.createProtocolConnection = createProtocolConnection;
\r
469 /***/ (function(module, exports, __webpack_require__) {
472 /* --------------------------------------------------------------------------------------------
\r
473 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
474 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
475 * ------------------------------------------------------------------------------------------ */
\r
476 /// <reference path="../typings/thenable.d.ts" />
\r
478 function __export(m) {
\r
479 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
481 Object.defineProperty(exports, "__esModule", { value: true });
\r
482 const Is = __webpack_require__(6);
\r
483 const messages_1 = __webpack_require__(7);
\r
484 exports.RequestType = messages_1.RequestType;
\r
485 exports.RequestType0 = messages_1.RequestType0;
\r
486 exports.RequestType1 = messages_1.RequestType1;
\r
487 exports.RequestType2 = messages_1.RequestType2;
\r
488 exports.RequestType3 = messages_1.RequestType3;
\r
489 exports.RequestType4 = messages_1.RequestType4;
\r
490 exports.RequestType5 = messages_1.RequestType5;
\r
491 exports.RequestType6 = messages_1.RequestType6;
\r
492 exports.RequestType7 = messages_1.RequestType7;
\r
493 exports.RequestType8 = messages_1.RequestType8;
\r
494 exports.RequestType9 = messages_1.RequestType9;
\r
495 exports.ResponseError = messages_1.ResponseError;
\r
496 exports.ErrorCodes = messages_1.ErrorCodes;
\r
497 exports.NotificationType = messages_1.NotificationType;
\r
498 exports.NotificationType0 = messages_1.NotificationType0;
\r
499 exports.NotificationType1 = messages_1.NotificationType1;
\r
500 exports.NotificationType2 = messages_1.NotificationType2;
\r
501 exports.NotificationType3 = messages_1.NotificationType3;
\r
502 exports.NotificationType4 = messages_1.NotificationType4;
\r
503 exports.NotificationType5 = messages_1.NotificationType5;
\r
504 exports.NotificationType6 = messages_1.NotificationType6;
\r
505 exports.NotificationType7 = messages_1.NotificationType7;
\r
506 exports.NotificationType8 = messages_1.NotificationType8;
\r
507 exports.NotificationType9 = messages_1.NotificationType9;
\r
508 const messageReader_1 = __webpack_require__(8);
\r
509 exports.MessageReader = messageReader_1.MessageReader;
\r
510 exports.StreamMessageReader = messageReader_1.StreamMessageReader;
\r
511 exports.IPCMessageReader = messageReader_1.IPCMessageReader;
\r
512 exports.SocketMessageReader = messageReader_1.SocketMessageReader;
\r
513 const messageWriter_1 = __webpack_require__(10);
\r
514 exports.MessageWriter = messageWriter_1.MessageWriter;
\r
515 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
\r
516 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
\r
517 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
\r
518 const events_1 = __webpack_require__(9);
\r
519 exports.Disposable = events_1.Disposable;
\r
520 exports.Event = events_1.Event;
\r
521 exports.Emitter = events_1.Emitter;
\r
522 const cancellation_1 = __webpack_require__(11);
\r
523 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
\r
524 exports.CancellationToken = cancellation_1.CancellationToken;
\r
525 const linkedMap_1 = __webpack_require__(12);
\r
526 __export(__webpack_require__(13));
\r
527 __export(__webpack_require__(17));
\r
528 var CancelNotification;
\r
529 (function (CancelNotification) {
\r
530 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
\r
531 })(CancelNotification || (CancelNotification = {}));
\r
532 var ProgressNotification;
\r
533 (function (ProgressNotification) {
\r
534 ProgressNotification.type = new messages_1.NotificationType('$/progress');
\r
535 })(ProgressNotification || (ProgressNotification = {}));
\r
536 class ProgressType {
\r
540 exports.ProgressType = ProgressType;
\r
541 exports.NullLogger = Object.freeze({
\r
548 (function (Trace) {
\r
549 Trace[Trace["Off"] = 0] = "Off";
\r
550 Trace[Trace["Messages"] = 1] = "Messages";
\r
551 Trace[Trace["Verbose"] = 2] = "Verbose";
\r
552 })(Trace = exports.Trace || (exports.Trace = {}));
\r
553 (function (Trace) {
\r
554 function fromString(value) {
\r
555 if (!Is.string(value)) {
\r
558 value = value.toLowerCase();
\r
563 return Trace.Messages;
\r
565 return Trace.Verbose;
\r
570 Trace.fromString = fromString;
\r
571 function toString(value) {
\r
575 case Trace.Messages:
\r
577 case Trace.Verbose:
\r
583 Trace.toString = toString;
\r
584 })(Trace = exports.Trace || (exports.Trace = {}));
\r
586 (function (TraceFormat) {
\r
587 TraceFormat["Text"] = "text";
\r
588 TraceFormat["JSON"] = "json";
\r
589 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
590 (function (TraceFormat) {
\r
591 function fromString(value) {
\r
592 value = value.toLowerCase();
\r
593 if (value === 'json') {
\r
594 return TraceFormat.JSON;
\r
597 return TraceFormat.Text;
\r
600 TraceFormat.fromString = fromString;
\r
601 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
602 var SetTraceNotification;
\r
603 (function (SetTraceNotification) {
\r
604 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
\r
605 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
\r
606 var LogTraceNotification;
\r
607 (function (LogTraceNotification) {
\r
608 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
\r
609 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
\r
610 var ConnectionErrors;
\r
611 (function (ConnectionErrors) {
\r
613 * The connection is closed.
\r
615 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
617 * The connection got disposed.
\r
619 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
621 * The connection is already in listening mode.
\r
623 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
\r
624 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
\r
625 class ConnectionError extends Error {
\r
626 constructor(code, message) {
\r
629 Object.setPrototypeOf(this, ConnectionError.prototype);
\r
632 exports.ConnectionError = ConnectionError;
\r
633 var ConnectionStrategy;
\r
634 (function (ConnectionStrategy) {
\r
635 function is(value) {
\r
636 let candidate = value;
\r
637 return candidate && Is.func(candidate.cancelUndispatched);
\r
639 ConnectionStrategy.is = is;
\r
640 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
\r
641 var ConnectionState;
\r
642 (function (ConnectionState) {
\r
643 ConnectionState[ConnectionState["New"] = 1] = "New";
\r
644 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
\r
645 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
\r
646 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
\r
647 })(ConnectionState || (ConnectionState = {}));
\r
648 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
\r
649 let sequenceNumber = 0;
\r
650 let notificationSquenceNumber = 0;
\r
651 let unknownResponseSquenceNumber = 0;
\r
652 const version = '2.0';
\r
653 let starRequestHandler = undefined;
\r
654 let requestHandlers = Object.create(null);
\r
655 let starNotificationHandler = undefined;
\r
656 let notificationHandlers = Object.create(null);
\r
657 let progressHandlers = new Map();
\r
659 let messageQueue = new linkedMap_1.LinkedMap();
\r
660 let responsePromises = Object.create(null);
\r
661 let requestTokens = Object.create(null);
\r
662 let trace = Trace.Off;
\r
663 let traceFormat = TraceFormat.Text;
\r
665 let state = ConnectionState.New;
\r
666 let errorEmitter = new events_1.Emitter();
\r
667 let closeEmitter = new events_1.Emitter();
\r
668 let unhandledNotificationEmitter = new events_1.Emitter();
\r
669 let unhandledProgressEmitter = new events_1.Emitter();
\r
670 let disposeEmitter = new events_1.Emitter();
\r
671 function createRequestQueueKey(id) {
\r
672 return 'req-' + id.toString();
\r
674 function createResponseQueueKey(id) {
\r
676 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
679 return 'res-' + id.toString();
\r
682 function createNotificationQueueKey() {
\r
683 return 'not-' + (++notificationSquenceNumber).toString();
\r
685 function addMessageToQueue(queue, message) {
\r
686 if (messages_1.isRequestMessage(message)) {
\r
687 queue.set(createRequestQueueKey(message.id), message);
\r
689 else if (messages_1.isResponseMessage(message)) {
\r
690 queue.set(createResponseQueueKey(message.id), message);
\r
693 queue.set(createNotificationQueueKey(), message);
\r
696 function cancelUndispatched(_message) {
\r
699 function isListening() {
\r
700 return state === ConnectionState.Listening;
\r
702 function isClosed() {
\r
703 return state === ConnectionState.Closed;
\r
705 function isDisposed() {
\r
706 return state === ConnectionState.Disposed;
\r
708 function closeHandler() {
\r
709 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
710 state = ConnectionState.Closed;
\r
711 closeEmitter.fire(undefined);
\r
713 // If the connection is disposed don't sent close events.
\r
715 function readErrorHandler(error) {
\r
716 errorEmitter.fire([error, undefined, undefined]);
\r
718 function writeErrorHandler(data) {
\r
719 errorEmitter.fire(data);
\r
721 messageReader.onClose(closeHandler);
\r
722 messageReader.onError(readErrorHandler);
\r
723 messageWriter.onClose(closeHandler);
\r
724 messageWriter.onError(writeErrorHandler);
\r
725 function triggerMessageQueue() {
\r
726 if (timer || messageQueue.size === 0) {
\r
729 timer = setImmediate(() => {
\r
731 processMessageQueue();
\r
734 function processMessageQueue() {
\r
735 if (messageQueue.size === 0) {
\r
738 let message = messageQueue.shift();
\r
740 if (messages_1.isRequestMessage(message)) {
\r
741 handleRequest(message);
\r
743 else if (messages_1.isNotificationMessage(message)) {
\r
744 handleNotification(message);
\r
746 else if (messages_1.isResponseMessage(message)) {
\r
747 handleResponse(message);
\r
750 handleInvalidMessage(message);
\r
754 triggerMessageQueue();
\r
757 let callback = (message) => {
\r
759 // We have received a cancellation message. Check if the message is still in the queue
\r
760 // and cancel it if allowed to do so.
\r
761 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
\r
762 let key = createRequestQueueKey(message.params.id);
\r
763 let toCancel = messageQueue.get(key);
\r
764 if (messages_1.isRequestMessage(toCancel)) {
\r
765 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
\r
766 if (response && (response.error !== void 0 || response.result !== void 0)) {
\r
767 messageQueue.delete(key);
\r
768 response.id = toCancel.id;
\r
769 traceSendingResponse(response, message.method, Date.now());
\r
770 messageWriter.write(response);
\r
775 addMessageToQueue(messageQueue, message);
\r
778 triggerMessageQueue();
\r
781 function handleRequest(requestMessage) {
\r
782 if (isDisposed()) {
\r
783 // we return here silently since we fired an event when the
\r
784 // connection got disposed.
\r
787 function reply(resultOrError, method, startTime) {
\r
790 id: requestMessage.id
\r
792 if (resultOrError instanceof messages_1.ResponseError) {
\r
793 message.error = resultOrError.toJson();
\r
796 message.result = resultOrError === void 0 ? null : resultOrError;
\r
798 traceSendingResponse(message, method, startTime);
\r
799 messageWriter.write(message);
\r
801 function replyError(error, method, startTime) {
\r
804 id: requestMessage.id,
\r
805 error: error.toJson()
\r
807 traceSendingResponse(message, method, startTime);
\r
808 messageWriter.write(message);
\r
810 function replySuccess(result, method, startTime) {
\r
811 // The JSON RPC defines that a response must either have a result or an error
\r
812 // So we can't treat undefined as a valid response result.
\r
813 if (result === void 0) {
\r
818 id: requestMessage.id,
\r
821 traceSendingResponse(message, method, startTime);
\r
822 messageWriter.write(message);
\r
824 traceReceivedRequest(requestMessage);
\r
825 let element = requestHandlers[requestMessage.method];
\r
827 let requestHandler;
\r
829 type = element.type;
\r
830 requestHandler = element.handler;
\r
832 let startTime = Date.now();
\r
833 if (requestHandler || starRequestHandler) {
\r
834 let cancellationSource = new cancellation_1.CancellationTokenSource();
\r
835 let tokenKey = String(requestMessage.id);
\r
836 requestTokens[tokenKey] = cancellationSource;
\r
839 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
840 handlerResult = requestHandler
\r
841 ? requestHandler(cancellationSource.token)
\r
842 : starRequestHandler(requestMessage.method, cancellationSource.token);
\r
844 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
845 handlerResult = requestHandler
\r
846 ? requestHandler(...requestMessage.params, cancellationSource.token)
\r
847 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
\r
850 handlerResult = requestHandler
\r
851 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
852 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
854 let promise = handlerResult;
\r
855 if (!handlerResult) {
\r
856 delete requestTokens[tokenKey];
\r
857 replySuccess(handlerResult, requestMessage.method, startTime);
\r
859 else if (promise.then) {
\r
860 promise.then((resultOrError) => {
\r
861 delete requestTokens[tokenKey];
\r
862 reply(resultOrError, requestMessage.method, startTime);
\r
864 delete requestTokens[tokenKey];
\r
865 if (error instanceof messages_1.ResponseError) {
\r
866 replyError(error, requestMessage.method, startTime);
\r
868 else if (error && Is.string(error.message)) {
\r
869 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
872 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
877 delete requestTokens[tokenKey];
\r
878 reply(handlerResult, requestMessage.method, startTime);
\r
882 delete requestTokens[tokenKey];
\r
883 if (error instanceof messages_1.ResponseError) {
\r
884 reply(error, requestMessage.method, startTime);
\r
886 else if (error && Is.string(error.message)) {
\r
887 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
890 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
895 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
898 function handleResponse(responseMessage) {
\r
899 if (isDisposed()) {
\r
900 // See handle request.
\r
903 if (responseMessage.id === null) {
\r
904 if (responseMessage.error) {
\r
905 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
\r
908 logger.error(`Received response message without id. No further error information provided.`);
\r
912 let key = String(responseMessage.id);
\r
913 let responsePromise = responsePromises[key];
\r
914 traceReceivedResponse(responseMessage, responsePromise);
\r
915 if (responsePromise) {
\r
916 delete responsePromises[key];
\r
918 if (responseMessage.error) {
\r
919 let error = responseMessage.error;
\r
920 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
\r
922 else if (responseMessage.result !== void 0) {
\r
923 responsePromise.resolve(responseMessage.result);
\r
926 throw new Error('Should never happen.');
\r
930 if (error.message) {
\r
931 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
934 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
940 function handleNotification(message) {
\r
941 if (isDisposed()) {
\r
942 // See handle request.
\r
945 let type = undefined;
\r
946 let notificationHandler;
\r
947 if (message.method === CancelNotification.type.method) {
\r
948 notificationHandler = (params) => {
\r
949 let id = params.id;
\r
950 let source = requestTokens[String(id)];
\r
957 let element = notificationHandlers[message.method];
\r
959 notificationHandler = element.handler;
\r
960 type = element.type;
\r
963 if (notificationHandler || starNotificationHandler) {
\r
965 traceReceivedNotification(message);
\r
966 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
967 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
\r
969 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
970 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
\r
973 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
977 if (error.message) {
\r
978 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
981 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
986 unhandledNotificationEmitter.fire(message);
\r
989 function handleInvalidMessage(message) {
\r
991 logger.error('Received empty message.');
\r
994 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
\r
995 // Test whether we find an id to reject the promise
\r
996 let responseMessage = message;
\r
997 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
\r
998 let key = String(responseMessage.id);
\r
999 let responseHandler = responsePromises[key];
\r
1000 if (responseHandler) {
\r
1001 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
\r
1005 function traceSendingRequest(message) {
\r
1006 if (trace === Trace.Off || !tracer) {
\r
1009 if (traceFormat === TraceFormat.Text) {
\r
1010 let data = undefined;
\r
1011 if (trace === Trace.Verbose && message.params) {
\r
1012 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1014 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
1017 logLSPMessage('send-request', message);
\r
1020 function traceSendingNotification(message) {
\r
1021 if (trace === Trace.Off || !tracer) {
\r
1024 if (traceFormat === TraceFormat.Text) {
\r
1025 let data = undefined;
\r
1026 if (trace === Trace.Verbose) {
\r
1027 if (message.params) {
\r
1028 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1031 data = 'No parameters provided.\n\n';
\r
1034 tracer.log(`Sending notification '${message.method}'.`, data);
\r
1037 logLSPMessage('send-notification', message);
\r
1040 function traceSendingResponse(message, method, startTime) {
\r
1041 if (trace === Trace.Off || !tracer) {
\r
1044 if (traceFormat === TraceFormat.Text) {
\r
1045 let data = undefined;
\r
1046 if (trace === Trace.Verbose) {
\r
1047 if (message.error && message.error.data) {
\r
1048 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
1051 if (message.result) {
\r
1052 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
1054 else if (message.error === void 0) {
\r
1055 data = 'No result returned.\n\n';
\r
1059 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
1062 logLSPMessage('send-response', message);
\r
1065 function traceReceivedRequest(message) {
\r
1066 if (trace === Trace.Off || !tracer) {
\r
1069 if (traceFormat === TraceFormat.Text) {
\r
1070 let data = undefined;
\r
1071 if (trace === Trace.Verbose && message.params) {
\r
1072 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1074 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
1077 logLSPMessage('receive-request', message);
\r
1080 function traceReceivedNotification(message) {
\r
1081 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\r
1084 if (traceFormat === TraceFormat.Text) {
\r
1085 let data = undefined;
\r
1086 if (trace === Trace.Verbose) {
\r
1087 if (message.params) {
\r
1088 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
1091 data = 'No parameters provided.\n\n';
\r
1094 tracer.log(`Received notification '${message.method}'.`, data);
\r
1097 logLSPMessage('receive-notification', message);
\r
1100 function traceReceivedResponse(message, responsePromise) {
\r
1101 if (trace === Trace.Off || !tracer) {
\r
1104 if (traceFormat === TraceFormat.Text) {
\r
1105 let data = undefined;
\r
1106 if (trace === Trace.Verbose) {
\r
1107 if (message.error && message.error.data) {
\r
1108 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
1111 if (message.result) {
\r
1112 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
1114 else if (message.error === void 0) {
\r
1115 data = 'No result returned.\n\n';
\r
1119 if (responsePromise) {
\r
1120 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
\r
1121 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
\r
1124 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
1128 logLSPMessage('receive-response', message);
\r
1131 function logLSPMessage(type, message) {
\r
1132 if (!tracer || trace === Trace.Off) {
\r
1135 const lspMessage = {
\r
1136 isLSPMessage: true,
\r
1139 timestamp: Date.now()
\r
1141 tracer.log(lspMessage);
\r
1143 function throwIfClosedOrDisposed() {
\r
1145 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
1147 if (isDisposed()) {
\r
1148 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
1151 function throwIfListening() {
\r
1152 if (isListening()) {
\r
1153 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
1156 function throwIfNotListening() {
\r
1157 if (!isListening()) {
\r
1158 throw new Error('Call listen() first.');
\r
1161 function undefinedToNull(param) {
\r
1162 if (param === void 0) {
\r
1169 function computeMessageParams(type, params) {
\r
1171 let numberOfParams = type.numberOfParams;
\r
1172 switch (numberOfParams) {
\r
1177 result = undefinedToNull(params[0]);
\r
1181 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
1182 result.push(undefinedToNull(params[i]));
\r
1184 if (params.length < numberOfParams) {
\r
1185 for (let i = params.length; i < numberOfParams; i++) {
\r
1186 result.push(null);
\r
1193 let connection = {
\r
1194 sendNotification: (type, ...params) => {
\r
1195 throwIfClosedOrDisposed();
\r
1197 let messageParams;
\r
1198 if (Is.string(type)) {
\r
1200 switch (params.length) {
\r
1202 messageParams = null;
\r
1205 messageParams = params[0];
\r
1208 messageParams = params;
\r
1213 method = type.method;
\r
1214 messageParams = computeMessageParams(type, params);
\r
1216 let notificationMessage = {
\r
1219 params: messageParams
\r
1221 traceSendingNotification(notificationMessage);
\r
1222 messageWriter.write(notificationMessage);
\r
1224 onNotification: (type, handler) => {
\r
1225 throwIfClosedOrDisposed();
\r
1226 if (Is.func(type)) {
\r
1227 starNotificationHandler = type;
\r
1229 else if (handler) {
\r
1230 if (Is.string(type)) {
\r
1231 notificationHandlers[type] = { type: undefined, handler };
\r
1234 notificationHandlers[type.method] = { type, handler };
\r
1238 onProgress: (_type, token, handler) => {
\r
1239 if (progressHandlers.has(token)) {
\r
1240 throw new Error(`Progress handler for token ${token} already registered`);
\r
1242 progressHandlers.set(token, handler);
\r
1245 progressHandlers.delete(token);
\r
1249 sendProgress: (_type, token, value) => {
\r
1250 connection.sendNotification(ProgressNotification.type, { token, value });
\r
1252 onUnhandledProgress: unhandledProgressEmitter.event,
\r
1253 sendRequest: (type, ...params) => {
\r
1254 throwIfClosedOrDisposed();
\r
1255 throwIfNotListening();
\r
1257 let messageParams;
\r
1258 let token = undefined;
\r
1259 if (Is.string(type)) {
\r
1261 switch (params.length) {
\r
1263 messageParams = null;
\r
1266 // The cancellation token is optional so it can also be undefined.
\r
1267 if (cancellation_1.CancellationToken.is(params[0])) {
\r
1268 messageParams = null;
\r
1269 token = params[0];
\r
1272 messageParams = undefinedToNull(params[0]);
\r
1276 const last = params.length - 1;
\r
1277 if (cancellation_1.CancellationToken.is(params[last])) {
\r
1278 token = params[last];
\r
1279 if (params.length === 2) {
\r
1280 messageParams = undefinedToNull(params[0]);
\r
1283 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
1287 messageParams = params.map(value => undefinedToNull(value));
\r
1293 method = type.method;
\r
1294 messageParams = computeMessageParams(type, params);
\r
1295 let numberOfParams = type.numberOfParams;
\r
1296 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
\r
1298 let id = sequenceNumber++;
\r
1299 let result = new Promise((resolve, reject) => {
\r
1300 let requestMessage = {
\r
1304 params: messageParams
\r
1306 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
1307 traceSendingRequest(requestMessage);
\r
1309 messageWriter.write(requestMessage);
\r
1312 // Writing the message failed. So we need to reject the promise.
\r
1313 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
\r
1314 responsePromise = null;
\r
1316 if (responsePromise) {
\r
1317 responsePromises[String(id)] = responsePromise;
\r
1321 token.onCancellationRequested(() => {
\r
1322 connection.sendNotification(CancelNotification.type, { id });
\r
1327 onRequest: (type, handler) => {
\r
1328 throwIfClosedOrDisposed();
\r
1329 if (Is.func(type)) {
\r
1330 starRequestHandler = type;
\r
1332 else if (handler) {
\r
1333 if (Is.string(type)) {
\r
1334 requestHandlers[type] = { type: undefined, handler };
\r
1337 requestHandlers[type.method] = { type, handler };
\r
1341 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
\r
1342 let _sendNotification = false;
\r
1343 let _traceFormat = TraceFormat.Text;
\r
1344 if (sendNotificationOrTraceOptions !== void 0) {
\r
1345 if (Is.boolean(sendNotificationOrTraceOptions)) {
\r
1346 _sendNotification = sendNotificationOrTraceOptions;
\r
1349 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
1350 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
1354 traceFormat = _traceFormat;
\r
1355 if (trace === Trace.Off) {
\r
1356 tracer = undefined;
\r
1361 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
1362 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
1365 onError: errorEmitter.event,
\r
1366 onClose: closeEmitter.event,
\r
1367 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
1368 onDispose: disposeEmitter.event,
\r
1370 if (isDisposed()) {
\r
1373 state = ConnectionState.Disposed;
\r
1374 disposeEmitter.fire(undefined);
\r
1375 let error = new Error('Connection got disposed.');
\r
1376 Object.keys(responsePromises).forEach((key) => {
\r
1377 responsePromises[key].reject(error);
\r
1379 responsePromises = Object.create(null);
\r
1380 requestTokens = Object.create(null);
\r
1381 messageQueue = new linkedMap_1.LinkedMap();
\r
1382 // Test for backwards compatibility
\r
1383 if (Is.func(messageWriter.dispose)) {
\r
1384 messageWriter.dispose();
\r
1386 if (Is.func(messageReader.dispose)) {
\r
1387 messageReader.dispose();
\r
1391 throwIfClosedOrDisposed();
\r
1392 throwIfListening();
\r
1393 state = ConnectionState.Listening;
\r
1394 messageReader.listen(callback);
\r
1397 // eslint-disable-next-line no-console
\r
1398 console.log('inspect');
\r
1401 connection.onNotification(LogTraceNotification.type, (params) => {
\r
1402 if (trace === Trace.Off || !tracer) {
\r
1405 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
1407 connection.onNotification(ProgressNotification.type, (params) => {
\r
1408 const handler = progressHandlers.get(params.token);
\r
1410 handler(params.value);
\r
1413 unhandledProgressEmitter.fire(params);
\r
1416 return connection;
\r
1418 function isMessageReader(value) {
\r
1419 return value.listen !== void 0 && value.read === void 0;
\r
1421 function isMessageWriter(value) {
\r
1422 return value.write !== void 0 && value.end === void 0;
\r
1424 function createMessageConnection(input, output, logger, strategy) {
\r
1426 logger = exports.NullLogger;
\r
1428 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
\r
1429 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
\r
1430 return _createMessageConnection(reader, writer, logger, strategy);
\r
1432 exports.createMessageConnection = createMessageConnection;
\r
1437 /***/ (function(module, exports, __webpack_require__) {
1440 /* --------------------------------------------------------------------------------------------
\r
1441 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1442 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1443 * ------------------------------------------------------------------------------------------ */
\r
1445 Object.defineProperty(exports, "__esModule", { value: true });
\r
1446 function boolean(value) {
\r
1447 return value === true || value === false;
\r
1449 exports.boolean = boolean;
\r
1450 function string(value) {
\r
1451 return typeof value === 'string' || value instanceof String;
\r
1453 exports.string = string;
\r
1454 function number(value) {
\r
1455 return typeof value === 'number' || value instanceof Number;
\r
1457 exports.number = number;
\r
1458 function error(value) {
\r
1459 return value instanceof Error;
\r
1461 exports.error = error;
\r
1462 function func(value) {
\r
1463 return typeof value === 'function';
\r
1465 exports.func = func;
\r
1466 function array(value) {
\r
1467 return Array.isArray(value);
\r
1469 exports.array = array;
\r
1470 function stringArray(value) {
\r
1471 return array(value) && value.every(elem => string(elem));
\r
1473 exports.stringArray = stringArray;
\r
1478 /***/ (function(module, exports, __webpack_require__) {
1481 /* --------------------------------------------------------------------------------------------
\r
1482 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1483 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1484 * ------------------------------------------------------------------------------------------ */
\r
1486 Object.defineProperty(exports, "__esModule", { value: true });
\r
1487 const is = __webpack_require__(6);
\r
1489 * Predefined error codes.
\r
1492 (function (ErrorCodes) {
\r
1493 // Defined by JSON RPC
\r
1494 ErrorCodes.ParseError = -32700;
\r
1495 ErrorCodes.InvalidRequest = -32600;
\r
1496 ErrorCodes.MethodNotFound = -32601;
\r
1497 ErrorCodes.InvalidParams = -32602;
\r
1498 ErrorCodes.InternalError = -32603;
\r
1499 ErrorCodes.serverErrorStart = -32099;
\r
1500 ErrorCodes.serverErrorEnd = -32000;
\r
1501 ErrorCodes.ServerNotInitialized = -32002;
\r
1502 ErrorCodes.UnknownErrorCode = -32001;
\r
1503 // Defined by the protocol.
\r
1504 ErrorCodes.RequestCancelled = -32800;
\r
1505 ErrorCodes.ContentModified = -32801;
\r
1506 // Defined by VSCode library.
\r
1507 ErrorCodes.MessageWriteError = 1;
\r
1508 ErrorCodes.MessageReadError = 2;
\r
1509 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
\r
1511 * An error object return in a response in case a request
\r
1514 class ResponseError extends Error {
\r
1515 constructor(code, message, data) {
\r
1517 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
1519 Object.setPrototypeOf(this, ResponseError.prototype);
\r
1524 message: this.message,
\r
1529 exports.ResponseError = ResponseError;
\r
1531 * An abstract implementation of a MessageType.
\r
1533 class AbstractMessageType {
\r
1534 constructor(_method, _numberOfParams) {
\r
1535 this._method = _method;
\r
1536 this._numberOfParams = _numberOfParams;
\r
1539 return this._method;
\r
1541 get numberOfParams() {
\r
1542 return this._numberOfParams;
\r
1545 exports.AbstractMessageType = AbstractMessageType;
\r
1547 * Classes to type request response pairs
\r
1549 * The type parameter RO will be removed in the next major version
\r
1550 * of the JSON RPC library since it is a LSP concept and doesn't
\r
1551 * belong here. For now it is tagged as default never.
\r
1553 class RequestType0 extends AbstractMessageType {
\r
1554 constructor(method) {
\r
1558 exports.RequestType0 = RequestType0;
\r
1559 class RequestType extends AbstractMessageType {
\r
1560 constructor(method) {
\r
1564 exports.RequestType = RequestType;
\r
1565 class RequestType1 extends AbstractMessageType {
\r
1566 constructor(method) {
\r
1570 exports.RequestType1 = RequestType1;
\r
1571 class RequestType2 extends AbstractMessageType {
\r
1572 constructor(method) {
\r
1576 exports.RequestType2 = RequestType2;
\r
1577 class RequestType3 extends AbstractMessageType {
\r
1578 constructor(method) {
\r
1582 exports.RequestType3 = RequestType3;
\r
1583 class RequestType4 extends AbstractMessageType {
\r
1584 constructor(method) {
\r
1588 exports.RequestType4 = RequestType4;
\r
1589 class RequestType5 extends AbstractMessageType {
\r
1590 constructor(method) {
\r
1594 exports.RequestType5 = RequestType5;
\r
1595 class RequestType6 extends AbstractMessageType {
\r
1596 constructor(method) {
\r
1600 exports.RequestType6 = RequestType6;
\r
1601 class RequestType7 extends AbstractMessageType {
\r
1602 constructor(method) {
\r
1606 exports.RequestType7 = RequestType7;
\r
1607 class RequestType8 extends AbstractMessageType {
\r
1608 constructor(method) {
\r
1612 exports.RequestType8 = RequestType8;
\r
1613 class RequestType9 extends AbstractMessageType {
\r
1614 constructor(method) {
\r
1618 exports.RequestType9 = RequestType9;
\r
1620 * The type parameter RO will be removed in the next major version
\r
1621 * of the JSON RPC library since it is a LSP concept and doesn't
\r
1622 * belong here. For now it is tagged as default never.
\r
1624 class NotificationType extends AbstractMessageType {
\r
1625 constructor(method) {
\r
1627 this._ = undefined;
\r
1630 exports.NotificationType = NotificationType;
\r
1631 class NotificationType0 extends AbstractMessageType {
\r
1632 constructor(method) {
\r
1636 exports.NotificationType0 = NotificationType0;
\r
1637 class NotificationType1 extends AbstractMessageType {
\r
1638 constructor(method) {
\r
1642 exports.NotificationType1 = NotificationType1;
\r
1643 class NotificationType2 extends AbstractMessageType {
\r
1644 constructor(method) {
\r
1648 exports.NotificationType2 = NotificationType2;
\r
1649 class NotificationType3 extends AbstractMessageType {
\r
1650 constructor(method) {
\r
1654 exports.NotificationType3 = NotificationType3;
\r
1655 class NotificationType4 extends AbstractMessageType {
\r
1656 constructor(method) {
\r
1660 exports.NotificationType4 = NotificationType4;
\r
1661 class NotificationType5 extends AbstractMessageType {
\r
1662 constructor(method) {
\r
1666 exports.NotificationType5 = NotificationType5;
\r
1667 class NotificationType6 extends AbstractMessageType {
\r
1668 constructor(method) {
\r
1672 exports.NotificationType6 = NotificationType6;
\r
1673 class NotificationType7 extends AbstractMessageType {
\r
1674 constructor(method) {
\r
1678 exports.NotificationType7 = NotificationType7;
\r
1679 class NotificationType8 extends AbstractMessageType {
\r
1680 constructor(method) {
\r
1684 exports.NotificationType8 = NotificationType8;
\r
1685 class NotificationType9 extends AbstractMessageType {
\r
1686 constructor(method) {
\r
1690 exports.NotificationType9 = NotificationType9;
\r
1692 * Tests if the given message is a request message
\r
1694 function isRequestMessage(message) {
\r
1695 let candidate = message;
\r
1696 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
\r
1698 exports.isRequestMessage = isRequestMessage;
\r
1700 * Tests if the given message is a notification message
\r
1702 function isNotificationMessage(message) {
\r
1703 let candidate = message;
\r
1704 return candidate && is.string(candidate.method) && message.id === void 0;
\r
1706 exports.isNotificationMessage = isNotificationMessage;
\r
1708 * Tests if the given message is a response message
\r
1710 function isResponseMessage(message) {
\r
1711 let candidate = message;
\r
1712 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
\r
1714 exports.isResponseMessage = isResponseMessage;
\r
1719 /***/ (function(module, exports, __webpack_require__) {
1722 /* --------------------------------------------------------------------------------------------
\r
1723 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1724 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1725 * ------------------------------------------------------------------------------------------ */
\r
1727 Object.defineProperty(exports, "__esModule", { value: true });
\r
1728 const events_1 = __webpack_require__(9);
\r
1729 const Is = __webpack_require__(6);
\r
1730 let DefaultSize = 8192;
\r
1731 let CR = Buffer.from('\r', 'ascii')[0];
\r
1732 let LF = Buffer.from('\n', 'ascii')[0];
\r
1733 let CRLF = '\r\n';
\r
1734 class MessageBuffer {
\r
1735 constructor(encoding = 'utf8') {
\r
1736 this.encoding = encoding;
\r
1738 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
1741 var toAppend = chunk;
\r
1742 if (typeof (chunk) === 'string') {
\r
1744 var bufferLen = Buffer.byteLength(str, this.encoding);
\r
1745 toAppend = Buffer.allocUnsafe(bufferLen);
\r
1746 toAppend.write(str, 0, bufferLen, this.encoding);
\r
1748 if (this.buffer.length - this.index >= toAppend.length) {
\r
1749 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\r
1752 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
\r
1753 if (this.index === 0) {
\r
1754 this.buffer = Buffer.allocUnsafe(newSize);
\r
1755 toAppend.copy(this.buffer, 0, 0, toAppend.length);
\r
1758 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
1761 this.index += toAppend.length;
\r
1763 tryReadHeaders() {
\r
1764 let result = undefined;
\r
1766 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
1769 // No header / body separator found (e.g CRLFCRLF)
\r
1770 if (current + 3 >= this.index) {
\r
1773 result = Object.create(null);
\r
1774 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
\r
1775 headers.forEach((header) => {
\r
1776 let index = header.indexOf(':');
\r
1777 if (index === -1) {
\r
1778 throw new Error('Message header must separate key and value using :');
\r
1780 let key = header.substr(0, index);
\r
1781 let value = header.substr(index + 1).trim();
\r
1782 result[key] = value;
\r
1784 let nextStart = current + 4;
\r
1785 this.buffer = this.buffer.slice(nextStart);
\r
1786 this.index = this.index - nextStart;
\r
1789 tryReadContent(length) {
\r
1790 if (this.index < length) {
\r
1793 let result = this.buffer.toString(this.encoding, 0, length);
\r
1794 let nextStart = length;
\r
1795 this.buffer.copy(this.buffer, 0, nextStart);
\r
1796 this.index = this.index - nextStart;
\r
1799 get numberOfBytes() {
\r
1800 return this.index;
\r
1803 var MessageReader;
\r
1804 (function (MessageReader) {
\r
1805 function is(value) {
\r
1806 let candidate = value;
\r
1807 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
\r
1808 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
\r
1810 MessageReader.is = is;
\r
1811 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
1812 class AbstractMessageReader {
\r
1814 this.errorEmitter = new events_1.Emitter();
\r
1815 this.closeEmitter = new events_1.Emitter();
\r
1816 this.partialMessageEmitter = new events_1.Emitter();
\r
1819 this.errorEmitter.dispose();
\r
1820 this.closeEmitter.dispose();
\r
1823 return this.errorEmitter.event;
\r
1825 fireError(error) {
\r
1826 this.errorEmitter.fire(this.asError(error));
\r
1829 return this.closeEmitter.event;
\r
1832 this.closeEmitter.fire(undefined);
\r
1834 get onPartialMessage() {
\r
1835 return this.partialMessageEmitter.event;
\r
1837 firePartialMessage(info) {
\r
1838 this.partialMessageEmitter.fire(info);
\r
1841 if (error instanceof Error) {
\r
1845 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1849 exports.AbstractMessageReader = AbstractMessageReader;
\r
1850 class StreamMessageReader extends AbstractMessageReader {
\r
1851 constructor(readable, encoding = 'utf8') {
\r
1853 this.readable = readable;
\r
1854 this.buffer = new MessageBuffer(encoding);
\r
1855 this._partialMessageTimeout = 10000;
\r
1857 set partialMessageTimeout(timeout) {
\r
1858 this._partialMessageTimeout = timeout;
\r
1860 get partialMessageTimeout() {
\r
1861 return this._partialMessageTimeout;
\r
1863 listen(callback) {
\r
1864 this.nextMessageLength = -1;
\r
1865 this.messageToken = 0;
\r
1866 this.partialMessageTimer = undefined;
\r
1867 this.callback = callback;
\r
1868 this.readable.on('data', (data) => {
\r
1869 this.onData(data);
\r
1871 this.readable.on('error', (error) => this.fireError(error));
\r
1872 this.readable.on('close', () => this.fireClose());
\r
1875 this.buffer.append(data);
\r
1877 if (this.nextMessageLength === -1) {
\r
1878 let headers = this.buffer.tryReadHeaders();
\r
1882 let contentLength = headers['Content-Length'];
\r
1883 if (!contentLength) {
\r
1884 throw new Error('Header must provide a Content-Length property.');
\r
1886 let length = parseInt(contentLength);
\r
1887 if (isNaN(length)) {
\r
1888 throw new Error('Content-Length value must be a number.');
\r
1890 this.nextMessageLength = length;
\r
1891 // Take the encoding form the header. For compatibility
\r
1892 // treat both utf-8 and utf8 as node utf8
\r
1894 var msg = this.buffer.tryReadContent(this.nextMessageLength);
\r
1895 if (msg === null) {
\r
1896 /** We haven't received the full message yet. */
\r
1897 this.setPartialMessageTimer();
\r
1900 this.clearPartialMessageTimer();
\r
1901 this.nextMessageLength = -1;
\r
1902 this.messageToken++;
\r
1903 var json = JSON.parse(msg);
\r
1904 this.callback(json);
\r
1907 clearPartialMessageTimer() {
\r
1908 if (this.partialMessageTimer) {
\r
1909 clearTimeout(this.partialMessageTimer);
\r
1910 this.partialMessageTimer = undefined;
\r
1913 setPartialMessageTimer() {
\r
1914 this.clearPartialMessageTimer();
\r
1915 if (this._partialMessageTimeout <= 0) {
\r
1918 this.partialMessageTimer = setTimeout((token, timeout) => {
\r
1919 this.partialMessageTimer = undefined;
\r
1920 if (token === this.messageToken) {
\r
1921 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
\r
1922 this.setPartialMessageTimer();
\r
1924 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
1927 exports.StreamMessageReader = StreamMessageReader;
\r
1928 class IPCMessageReader extends AbstractMessageReader {
\r
1929 constructor(process) {
\r
1931 this.process = process;
\r
1932 let eventEmitter = this.process;
\r
1933 eventEmitter.on('error', (error) => this.fireError(error));
\r
1934 eventEmitter.on('close', () => this.fireClose());
\r
1936 listen(callback) {
\r
1937 this.process.on('message', callback);
\r
1940 exports.IPCMessageReader = IPCMessageReader;
\r
1941 class SocketMessageReader extends StreamMessageReader {
\r
1942 constructor(socket, encoding = 'utf-8') {
\r
1943 super(socket, encoding);
\r
1946 exports.SocketMessageReader = SocketMessageReader;
\r
1951 /***/ (function(module, exports, __webpack_require__) {
1954 /* --------------------------------------------------------------------------------------------
\r
1955 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1956 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1957 * ------------------------------------------------------------------------------------------ */
\r
1959 Object.defineProperty(exports, "__esModule", { value: true });
\r
1961 (function (Disposable) {
\r
1962 function create(func) {
\r
1967 Disposable.create = create;
\r
1968 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\r
1970 (function (Event) {
\r
1971 const _disposable = { dispose() { } };
\r
1972 Event.None = function () { return _disposable; };
\r
1973 })(Event = exports.Event || (exports.Event = {}));
\r
1974 class CallbackList {
\r
1975 add(callback, context = null, bucket) {
\r
1976 if (!this._callbacks) {
\r
1977 this._callbacks = [];
\r
1978 this._contexts = [];
\r
1980 this._callbacks.push(callback);
\r
1981 this._contexts.push(context);
\r
1982 if (Array.isArray(bucket)) {
\r
1983 bucket.push({ dispose: () => this.remove(callback, context) });
\r
1986 remove(callback, context = null) {
\r
1987 if (!this._callbacks) {
\r
1990 var foundCallbackWithDifferentContext = false;
\r
1991 for (var i = 0, len = this._callbacks.length; i < len; i++) {
\r
1992 if (this._callbacks[i] === callback) {
\r
1993 if (this._contexts[i] === context) {
\r
1994 // callback & context match => remove it
\r
1995 this._callbacks.splice(i, 1);
\r
1996 this._contexts.splice(i, 1);
\r
2000 foundCallbackWithDifferentContext = true;
\r
2004 if (foundCallbackWithDifferentContext) {
\r
2005 throw new Error('When adding a listener with a context, you should remove it with the same context');
\r
2009 if (!this._callbacks) {
\r
2012 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
\r
2013 for (var i = 0, len = callbacks.length; i < len; i++) {
\r
2015 ret.push(callbacks[i].apply(contexts[i], args));
\r
2018 // eslint-disable-next-line no-console
\r
2025 return !this._callbacks || this._callbacks.length === 0;
\r
2028 this._callbacks = undefined;
\r
2029 this._contexts = undefined;
\r
2033 constructor(_options) {
\r
2034 this._options = _options;
\r
2037 * For the public to allow to subscribe
\r
2038 * to events from this Emitter
\r
2041 if (!this._event) {
\r
2042 this._event = (listener, thisArgs, disposables) => {
\r
2043 if (!this._callbacks) {
\r
2044 this._callbacks = new CallbackList();
\r
2046 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
2047 this._options.onFirstListenerAdd(this);
\r
2049 this._callbacks.add(listener, thisArgs);
\r
2053 this._callbacks.remove(listener, thisArgs);
\r
2054 result.dispose = Emitter._noop;
\r
2055 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
\r
2056 this._options.onLastListenerRemove(this);
\r
2060 if (Array.isArray(disposables)) {
\r
2061 disposables.push(result);
\r
2066 return this._event;
\r
2069 * To be kept private to fire an event to
\r
2073 if (this._callbacks) {
\r
2074 this._callbacks.invoke.call(this._callbacks, event);
\r
2078 if (this._callbacks) {
\r
2079 this._callbacks.dispose();
\r
2080 this._callbacks = undefined;
\r
2084 exports.Emitter = Emitter;
\r
2085 Emitter._noop = function () { };
\r
2090 /***/ (function(module, exports, __webpack_require__) {
2093 /* --------------------------------------------------------------------------------------------
\r
2094 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2095 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2096 * ------------------------------------------------------------------------------------------ */
\r
2098 Object.defineProperty(exports, "__esModule", { value: true });
\r
2099 const events_1 = __webpack_require__(9);
\r
2100 const Is = __webpack_require__(6);
\r
2101 let ContentLength = 'Content-Length: ';
\r
2102 let CRLF = '\r\n';
\r
2103 var MessageWriter;
\r
2104 (function (MessageWriter) {
\r
2105 function is(value) {
\r
2106 let candidate = value;
\r
2107 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
\r
2108 Is.func(candidate.onError) && Is.func(candidate.write);
\r
2110 MessageWriter.is = is;
\r
2111 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
2112 class AbstractMessageWriter {
\r
2114 this.errorEmitter = new events_1.Emitter();
\r
2115 this.closeEmitter = new events_1.Emitter();
\r
2118 this.errorEmitter.dispose();
\r
2119 this.closeEmitter.dispose();
\r
2122 return this.errorEmitter.event;
\r
2124 fireError(error, message, count) {
\r
2125 this.errorEmitter.fire([this.asError(error), message, count]);
\r
2128 return this.closeEmitter.event;
\r
2131 this.closeEmitter.fire(undefined);
\r
2134 if (error instanceof Error) {
\r
2138 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
2142 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
2143 class StreamMessageWriter extends AbstractMessageWriter {
\r
2144 constructor(writable, encoding = 'utf8') {
\r
2146 this.writable = writable;
\r
2147 this.encoding = encoding;
\r
2148 this.errorCount = 0;
\r
2149 this.writable.on('error', (error) => this.fireError(error));
\r
2150 this.writable.on('close', () => this.fireClose());
\r
2153 let json = JSON.stringify(msg);
\r
2154 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2156 ContentLength, contentLength.toString(), CRLF,
\r
2160 // Header must be written in ASCII encoding
\r
2161 this.writable.write(headers.join(''), 'ascii');
\r
2162 // Now write the content. This can be written in any encoding
\r
2163 this.writable.write(json, this.encoding);
\r
2164 this.errorCount = 0;
\r
2167 this.errorCount++;
\r
2168 this.fireError(error, msg, this.errorCount);
\r
2172 exports.StreamMessageWriter = StreamMessageWriter;
\r
2173 class IPCMessageWriter extends AbstractMessageWriter {
\r
2174 constructor(process) {
\r
2176 this.process = process;
\r
2177 this.errorCount = 0;
\r
2179 this.sending = false;
\r
2180 let eventEmitter = this.process;
\r
2181 eventEmitter.on('error', (error) => this.fireError(error));
\r
2182 eventEmitter.on('close', () => this.fireClose);
\r
2185 if (!this.sending && this.queue.length === 0) {
\r
2186 // See https://github.com/nodejs/node/issues/7657
\r
2187 this.doWriteMessage(msg);
\r
2190 this.queue.push(msg);
\r
2193 doWriteMessage(msg) {
\r
2195 if (this.process.send) {
\r
2196 this.sending = true;
\r
2197 this.process.send(msg, undefined, undefined, (error) => {
\r
2198 this.sending = false;
\r
2200 this.errorCount++;
\r
2201 this.fireError(error, msg, this.errorCount);
\r
2204 this.errorCount = 0;
\r
2206 if (this.queue.length > 0) {
\r
2207 this.doWriteMessage(this.queue.shift());
\r
2213 this.errorCount++;
\r
2214 this.fireError(error, msg, this.errorCount);
\r
2218 exports.IPCMessageWriter = IPCMessageWriter;
\r
2219 class SocketMessageWriter extends AbstractMessageWriter {
\r
2220 constructor(socket, encoding = 'utf8') {
\r
2222 this.socket = socket;
\r
2224 this.sending = false;
\r
2225 this.encoding = encoding;
\r
2226 this.errorCount = 0;
\r
2227 this.socket.on('error', (error) => this.fireError(error));
\r
2228 this.socket.on('close', () => this.fireClose());
\r
2232 this.socket.destroy();
\r
2235 if (!this.sending && this.queue.length === 0) {
\r
2236 // See https://github.com/nodejs/node/issues/7657
\r
2237 this.doWriteMessage(msg);
\r
2240 this.queue.push(msg);
\r
2243 doWriteMessage(msg) {
\r
2244 let json = JSON.stringify(msg);
\r
2245 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2247 ContentLength, contentLength.toString(), CRLF,
\r
2251 // Header must be written in ASCII encoding
\r
2252 this.sending = true;
\r
2253 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
2255 this.handleError(error, msg);
\r
2258 // Now write the content. This can be written in any encoding
\r
2259 this.socket.write(json, this.encoding, (error) => {
\r
2260 this.sending = false;
\r
2262 this.handleError(error, msg);
\r
2265 this.errorCount = 0;
\r
2267 if (this.queue.length > 0) {
\r
2268 this.doWriteMessage(this.queue.shift());
\r
2273 this.handleError(error, msg);
\r
2278 this.handleError(error, msg);
\r
2281 handleError(error, msg) {
\r
2282 this.errorCount++;
\r
2283 this.fireError(error, msg, this.errorCount);
\r
2286 exports.SocketMessageWriter = SocketMessageWriter;
\r
2291 /***/ (function(module, exports, __webpack_require__) {
2294 /*---------------------------------------------------------------------------------------------
\r
2295 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2296 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2297 *--------------------------------------------------------------------------------------------*/
\r
2299 Object.defineProperty(exports, "__esModule", { value: true });
\r
2300 const events_1 = __webpack_require__(9);
\r
2301 const Is = __webpack_require__(6);
\r
2302 var CancellationToken;
\r
2303 (function (CancellationToken) {
\r
2304 CancellationToken.None = Object.freeze({
\r
2305 isCancellationRequested: false,
\r
2306 onCancellationRequested: events_1.Event.None
\r
2308 CancellationToken.Cancelled = Object.freeze({
\r
2309 isCancellationRequested: true,
\r
2310 onCancellationRequested: events_1.Event.None
\r
2312 function is(value) {
\r
2313 let candidate = value;
\r
2314 return candidate && (candidate === CancellationToken.None
\r
2315 || candidate === CancellationToken.Cancelled
\r
2316 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
\r
2318 CancellationToken.is = is;
\r
2319 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
\r
2320 const shortcutEvent = Object.freeze(function (callback, context) {
\r
2321 let handle = setTimeout(callback.bind(context), 0);
\r
2322 return { dispose() { clearTimeout(handle); } };
\r
2324 class MutableToken {
\r
2326 this._isCancelled = false;
\r
2329 if (!this._isCancelled) {
\r
2330 this._isCancelled = true;
\r
2331 if (this._emitter) {
\r
2332 this._emitter.fire(undefined);
\r
2337 get isCancellationRequested() {
\r
2338 return this._isCancelled;
\r
2340 get onCancellationRequested() {
\r
2341 if (this._isCancelled) {
\r
2342 return shortcutEvent;
\r
2344 if (!this._emitter) {
\r
2345 this._emitter = new events_1.Emitter();
\r
2347 return this._emitter.event;
\r
2350 if (this._emitter) {
\r
2351 this._emitter.dispose();
\r
2352 this._emitter = undefined;
\r
2356 class CancellationTokenSource {
\r
2358 if (!this._token) {
\r
2359 // be lazy and create the token only when
\r
2360 // actually needed
\r
2361 this._token = new MutableToken();
\r
2363 return this._token;
\r
2366 if (!this._token) {
\r
2367 // save an object by returning the default
\r
2368 // cancelled token when cancellation happens
\r
2369 // before someone asks for the token
\r
2370 this._token = CancellationToken.Cancelled;
\r
2373 this._token.cancel();
\r
2377 if (!this._token) {
\r
2378 // ensure to initialize with an empty token if we had none
\r
2379 this._token = CancellationToken.None;
\r
2381 else if (this._token instanceof MutableToken) {
\r
2382 // actually dispose
\r
2383 this._token.dispose();
\r
2387 exports.CancellationTokenSource = CancellationTokenSource;
\r
2392 /***/ (function(module, exports, __webpack_require__) {
2396 /*---------------------------------------------------------------------------------------------
\r
2397 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2398 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2399 *--------------------------------------------------------------------------------------------*/
\r
2400 Object.defineProperty(exports, "__esModule", { value: true });
\r
2402 (function (Touch) {
\r
2406 })(Touch = exports.Touch || (exports.Touch = {}));
\r
2409 this._map = new Map();
\r
2410 this._head = undefined;
\r
2411 this._tail = undefined;
\r
2415 this._map.clear();
\r
2416 this._head = undefined;
\r
2417 this._tail = undefined;
\r
2421 return !this._head && !this._tail;
\r
2424 return this._size;
\r
2427 return this._map.has(key);
\r
2430 const item = this._map.get(key);
\r
2434 return item.value;
\r
2436 set(key, value, touch = Touch.None) {
\r
2437 let item = this._map.get(key);
\r
2439 item.value = value;
\r
2440 if (touch !== Touch.None) {
\r
2441 this.touch(item, touch);
\r
2445 item = { key, value, next: undefined, previous: undefined };
\r
2448 this.addItemLast(item);
\r
2451 this.addItemFirst(item);
\r
2454 this.addItemLast(item);
\r
2457 this.addItemLast(item);
\r
2460 this._map.set(key, item);
\r
2465 const item = this._map.get(key);
\r
2469 this._map.delete(key);
\r
2470 this.removeItem(item);
\r
2475 if (!this._head && !this._tail) {
\r
2478 if (!this._head || !this._tail) {
\r
2479 throw new Error('Invalid list');
\r
2481 const item = this._head;
\r
2482 this._map.delete(item.key);
\r
2483 this.removeItem(item);
\r
2485 return item.value;
\r
2487 forEach(callbackfn, thisArg) {
\r
2488 let current = this._head;
\r
2491 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2494 callbackfn(current.value, current.key, this);
\r
2496 current = current.next;
\r
2499 forEachReverse(callbackfn, thisArg) {
\r
2500 let current = this._tail;
\r
2503 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2506 callbackfn(current.value, current.key, this);
\r
2508 current = current.previous;
\r
2513 let current = this._head;
\r
2515 result.push(current.value);
\r
2516 current = current.next;
\r
2522 let current = this._head;
\r
2524 result.push(current.key);
\r
2525 current = current.next;
\r
2529 /* JSON RPC run on es5 which has no Symbol.iterator
\r
2530 public keys(): IterableIterator<K> {
\r
2531 let current = this._head;
\r
2532 let iterator: IterableIterator<K> = {
\r
2533 [Symbol.iterator]() {
\r
2536 next():IteratorResult<K> {
\r
2538 let result = { value: current.key, done: false };
\r
2539 current = current.next;
\r
2542 return { value: undefined, done: true };
\r
2549 public values(): IterableIterator<V> {
\r
2550 let current = this._head;
\r
2551 let iterator: IterableIterator<V> = {
\r
2552 [Symbol.iterator]() {
\r
2555 next():IteratorResult<V> {
\r
2557 let result = { value: current.value, done: false };
\r
2558 current = current.next;
\r
2561 return { value: undefined, done: true };
\r
2568 addItemFirst(item) {
\r
2569 // First time Insert
\r
2570 if (!this._head && !this._tail) {
\r
2571 this._tail = item;
\r
2573 else if (!this._head) {
\r
2574 throw new Error('Invalid list');
\r
2577 item.next = this._head;
\r
2578 this._head.previous = item;
\r
2580 this._head = item;
\r
2582 addItemLast(item) {
\r
2583 // First time Insert
\r
2584 if (!this._head && !this._tail) {
\r
2585 this._head = item;
\r
2587 else if (!this._tail) {
\r
2588 throw new Error('Invalid list');
\r
2591 item.previous = this._tail;
\r
2592 this._tail.next = item;
\r
2594 this._tail = item;
\r
2596 removeItem(item) {
\r
2597 if (item === this._head && item === this._tail) {
\r
2598 this._head = undefined;
\r
2599 this._tail = undefined;
\r
2601 else if (item === this._head) {
\r
2602 this._head = item.next;
\r
2604 else if (item === this._tail) {
\r
2605 this._tail = item.previous;
\r
2608 const next = item.next;
\r
2609 const previous = item.previous;
\r
2610 if (!next || !previous) {
\r
2611 throw new Error('Invalid list');
\r
2613 next.previous = previous;
\r
2614 previous.next = next;
\r
2617 touch(item, touch) {
\r
2618 if (!this._head || !this._tail) {
\r
2619 throw new Error('Invalid list');
\r
2621 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
2624 if (touch === Touch.First) {
\r
2625 if (item === this._head) {
\r
2628 const next = item.next;
\r
2629 const previous = item.previous;
\r
2630 // Unlink the item
\r
2631 if (item === this._tail) {
\r
2632 // previous must be defined since item was not head but is tail
\r
2633 // So there are more than on item in the map
\r
2634 previous.next = undefined;
\r
2635 this._tail = previous;
\r
2638 // Both next and previous are not undefined since item was neither head nor tail.
\r
2639 next.previous = previous;
\r
2640 previous.next = next;
\r
2642 // Insert the node at head
\r
2643 item.previous = undefined;
\r
2644 item.next = this._head;
\r
2645 this._head.previous = item;
\r
2646 this._head = item;
\r
2648 else if (touch === Touch.Last) {
\r
2649 if (item === this._tail) {
\r
2652 const next = item.next;
\r
2653 const previous = item.previous;
\r
2654 // Unlink the item.
\r
2655 if (item === this._head) {
\r
2656 // next must be defined since item was not tail but is head
\r
2657 // So there are more than on item in the map
\r
2658 next.previous = undefined;
\r
2659 this._head = next;
\r
2662 // Both next and previous are not undefined since item was neither head nor tail.
\r
2663 next.previous = previous;
\r
2664 previous.next = next;
\r
2666 item.next = undefined;
\r
2667 item.previous = this._tail;
\r
2668 this._tail.next = item;
\r
2669 this._tail = item;
\r
2673 exports.LinkedMap = LinkedMap;
\r
2678 /***/ (function(module, exports, __webpack_require__) {
2681 /* --------------------------------------------------------------------------------------------
\r
2682 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2683 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2684 * ------------------------------------------------------------------------------------------ */
\r
2686 Object.defineProperty(exports, "__esModule", { value: true });
\r
2687 const path_1 = __webpack_require__(3);
\r
2688 const os_1 = __webpack_require__(14);
\r
2689 const crypto_1 = __webpack_require__(15);
\r
2690 const net_1 = __webpack_require__(16);
\r
2691 const messageReader_1 = __webpack_require__(8);
\r
2692 const messageWriter_1 = __webpack_require__(10);
\r
2693 function generateRandomPipeName() {
\r
2694 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
\r
2695 if (process.platform === 'win32') {
\r
2696 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
\r
2699 // Mac/Unix: use socket file
\r
2700 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\r
2703 exports.generateRandomPipeName = generateRandomPipeName;
\r
2704 function createClientPipeTransport(pipeName, encoding = 'utf-8') {
\r
2705 let connectResolve;
\r
2706 let connected = new Promise((resolve, _reject) => {
\r
2707 connectResolve = resolve;
\r
2709 return new Promise((resolve, reject) => {
\r
2710 let server = net_1.createServer((socket) => {
\r
2713 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2714 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2717 server.on('error', reject);
\r
2718 server.listen(pipeName, () => {
\r
2719 server.removeListener('error', reject);
\r
2721 onConnected: () => { return connected; }
\r
2726 exports.createClientPipeTransport = createClientPipeTransport;
\r
2727 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
2728 const socket = net_1.createConnection(pipeName);
\r
2730 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2731 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2734 exports.createServerPipeTransport = createServerPipeTransport;
\r
2739 /***/ (function(module, exports) {
2741 module.exports = require("os");
2745 /***/ (function(module, exports) {
2747 module.exports = require("crypto");
2751 /***/ (function(module, exports) {
2753 module.exports = require("net");
2757 /***/ (function(module, exports, __webpack_require__) {
2760 /* --------------------------------------------------------------------------------------------
\r
2761 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2762 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2763 * ------------------------------------------------------------------------------------------ */
\r
2765 Object.defineProperty(exports, "__esModule", { value: true });
\r
2766 const net_1 = __webpack_require__(16);
\r
2767 const messageReader_1 = __webpack_require__(8);
\r
2768 const messageWriter_1 = __webpack_require__(10);
\r
2769 function createClientSocketTransport(port, encoding = 'utf-8') {
\r
2770 let connectResolve;
\r
2771 let connected = new Promise((resolve, _reject) => {
\r
2772 connectResolve = resolve;
\r
2774 return new Promise((resolve, reject) => {
\r
2775 let server = net_1.createServer((socket) => {
\r
2778 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2779 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2782 server.on('error', reject);
\r
2783 server.listen(port, '127.0.0.1', () => {
\r
2784 server.removeListener('error', reject);
\r
2786 onConnected: () => { return connected; }
\r
2791 exports.createClientSocketTransport = createClientSocketTransport;
\r
2792 function createServerSocketTransport(port, encoding = 'utf-8') {
\r
2793 const socket = net_1.createConnection(port, '127.0.0.1');
\r
2795 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2796 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2799 exports.createServerSocketTransport = createServerSocketTransport;
\r
2804 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2807 __webpack_require__.r(__webpack_exports__);
2808 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2809 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2810 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2811 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2812 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2813 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2814 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2815 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2816 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2817 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2818 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2819 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
2820 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2821 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2822 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2823 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2824 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2825 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2826 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2827 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2828 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2829 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2830 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2831 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2832 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2833 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2834 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2835 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2836 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemTag", function() { return CompletionItemTag; });
2837 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2838 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2839 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2840 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2841 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2842 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2843 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2844 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2845 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2846 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolTag", function() { return SymbolTag; });
2847 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2848 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2849 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2850 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2851 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2852 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2853 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2854 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2855 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
2856 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2857 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2858 /* --------------------------------------------------------------------------------------------
\r
2859 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2860 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2861 * ------------------------------------------------------------------------------------------ */
\r
2864 * The Position namespace provides helper functions to work with
\r
2865 * [Position](#Position) literals.
\r
2868 (function (Position) {
\r
2870 * Creates a new Position literal from the given line and character.
\r
2871 * @param line The position's line.
\r
2872 * @param character The position's character.
\r
2874 function create(line, character) {
\r
2875 return { line: line, character: character };
\r
2877 Position.create = create;
\r
2879 * Checks whether the given liternal conforms to the [Position](#Position) interface.
\r
2881 function is(value) {
\r
2882 var candidate = value;
\r
2883 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
\r
2886 })(Position || (Position = {}));
\r
2888 * The Range namespace provides helper functions to work with
\r
2889 * [Range](#Range) literals.
\r
2892 (function (Range) {
\r
2893 function create(one, two, three, four) {
\r
2894 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
\r
2895 return { start: Position.create(one, two), end: Position.create(three, four) };
\r
2897 else if (Position.is(one) && Position.is(two)) {
\r
2898 return { start: one, end: two };
\r
2901 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
\r
2904 Range.create = create;
\r
2906 * Checks whether the given literal conforms to the [Range](#Range) interface.
\r
2908 function is(value) {
\r
2909 var candidate = value;
\r
2910 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
\r
2913 })(Range || (Range = {}));
\r
2915 * The Location namespace provides helper functions to work with
\r
2916 * [Location](#Location) literals.
\r
2919 (function (Location) {
\r
2921 * Creates a Location literal.
\r
2922 * @param uri The location's uri.
\r
2923 * @param range The location's range.
\r
2925 function create(uri, range) {
\r
2926 return { uri: uri, range: range };
\r
2928 Location.create = create;
\r
2930 * Checks whether the given literal conforms to the [Location](#Location) interface.
\r
2932 function is(value) {
\r
2933 var candidate = value;
\r
2934 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
\r
2937 })(Location || (Location = {}));
\r
2939 * The LocationLink namespace provides helper functions to work with
\r
2940 * [LocationLink](#LocationLink) literals.
\r
2943 (function (LocationLink) {
\r
2945 * Creates a LocationLink literal.
\r
2946 * @param targetUri The definition's uri.
\r
2947 * @param targetRange The full range of the definition.
\r
2948 * @param targetSelectionRange The span of the symbol definition at the target.
\r
2949 * @param originSelectionRange The span of the symbol being defined in the originating source file.
\r
2951 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
\r
2952 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
\r
2954 LocationLink.create = create;
\r
2956 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
\r
2958 function is(value) {
\r
2959 var candidate = value;
\r
2960 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
\r
2961 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
\r
2962 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
\r
2964 LocationLink.is = is;
\r
2965 })(LocationLink || (LocationLink = {}));
\r
2967 * The Color namespace provides helper functions to work with
\r
2968 * [Color](#Color) literals.
\r
2971 (function (Color) {
\r
2973 * Creates a new Color literal.
\r
2975 function create(red, green, blue, alpha) {
\r
2983 Color.create = create;
\r
2985 * Checks whether the given literal conforms to the [Color](#Color) interface.
\r
2987 function is(value) {
\r
2988 var candidate = value;
\r
2989 return Is.number(candidate.red)
\r
2990 && Is.number(candidate.green)
\r
2991 && Is.number(candidate.blue)
\r
2992 && Is.number(candidate.alpha);
\r
2995 })(Color || (Color = {}));
\r
2997 * The ColorInformation namespace provides helper functions to work with
\r
2998 * [ColorInformation](#ColorInformation) literals.
\r
3000 var ColorInformation;
\r
3001 (function (ColorInformation) {
\r
3003 * Creates a new ColorInformation literal.
\r
3005 function create(range, color) {
\r
3011 ColorInformation.create = create;
\r
3013 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
3015 function is(value) {
\r
3016 var candidate = value;
\r
3017 return Range.is(candidate.range) && Color.is(candidate.color);
\r
3019 ColorInformation.is = is;
\r
3020 })(ColorInformation || (ColorInformation = {}));
\r
3022 * The Color namespace provides helper functions to work with
\r
3023 * [ColorPresentation](#ColorPresentation) literals.
\r
3025 var ColorPresentation;
\r
3026 (function (ColorPresentation) {
\r
3028 * Creates a new ColorInformation literal.
\r
3030 function create(label, textEdit, additionalTextEdits) {
\r
3033 textEdit: textEdit,
\r
3034 additionalTextEdits: additionalTextEdits,
\r
3037 ColorPresentation.create = create;
\r
3039 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
3041 function is(value) {
\r
3042 var candidate = value;
\r
3043 return Is.string(candidate.label)
\r
3044 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
\r
3045 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
\r
3047 ColorPresentation.is = is;
\r
3048 })(ColorPresentation || (ColorPresentation = {}));
\r
3050 * Enum of known range kinds
\r
3052 var FoldingRangeKind;
\r
3053 (function (FoldingRangeKind) {
\r
3055 * Folding range for a comment
\r
3057 FoldingRangeKind["Comment"] = "comment";
\r
3059 * Folding range for a imports or includes
\r
3061 FoldingRangeKind["Imports"] = "imports";
\r
3063 * Folding range for a region (e.g. `#region`)
\r
3065 FoldingRangeKind["Region"] = "region";
\r
3066 })(FoldingRangeKind || (FoldingRangeKind = {}));
\r
3068 * The folding range namespace provides helper functions to work with
\r
3069 * [FoldingRange](#FoldingRange) literals.
\r
3072 (function (FoldingRange) {
\r
3074 * Creates a new FoldingRange literal.
\r
3076 function create(startLine, endLine, startCharacter, endCharacter, kind) {
\r
3078 startLine: startLine,
\r
3081 if (Is.defined(startCharacter)) {
\r
3082 result.startCharacter = startCharacter;
\r
3084 if (Is.defined(endCharacter)) {
\r
3085 result.endCharacter = endCharacter;
\r
3087 if (Is.defined(kind)) {
\r
3088 result.kind = kind;
\r
3092 FoldingRange.create = create;
\r
3094 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
\r
3096 function is(value) {
\r
3097 var candidate = value;
\r
3098 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
\r
3099 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
\r
3100 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
\r
3101 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
\r
3103 FoldingRange.is = is;
\r
3104 })(FoldingRange || (FoldingRange = {}));
\r
3106 * The DiagnosticRelatedInformation namespace provides helper functions to work with
\r
3107 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
\r
3109 var DiagnosticRelatedInformation;
\r
3110 (function (DiagnosticRelatedInformation) {
\r
3112 * Creates a new DiagnosticRelatedInformation literal.
\r
3114 function create(location, message) {
\r
3116 location: location,
\r
3120 DiagnosticRelatedInformation.create = create;
\r
3122 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
\r
3124 function is(value) {
\r
3125 var candidate = value;
\r
3126 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
\r
3128 DiagnosticRelatedInformation.is = is;
\r
3129 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
\r
3131 * The diagnostic's severity.
\r
3133 var DiagnosticSeverity;
\r
3134 (function (DiagnosticSeverity) {
\r
3136 * Reports an error.
\r
3138 DiagnosticSeverity.Error = 1;
\r
3140 * Reports a warning.
\r
3142 DiagnosticSeverity.Warning = 2;
\r
3144 * Reports an information.
\r
3146 DiagnosticSeverity.Information = 3;
\r
3150 DiagnosticSeverity.Hint = 4;
\r
3151 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
\r
3153 * The diagnostic tags.
\r
3157 var DiagnosticTag;
\r
3158 (function (DiagnosticTag) {
\r
3160 * Unused or unnecessary code.
\r
3162 * Clients are allowed to render diagnostics with this tag faded out instead of having
\r
3163 * an error squiggle.
\r
3165 DiagnosticTag.Unnecessary = 1;
\r
3167 * Deprecated or obsolete code.
\r
3169 * Clients are allowed to rendered diagnostics with this tag strike through.
\r
3171 DiagnosticTag.Deprecated = 2;
\r
3172 })(DiagnosticTag || (DiagnosticTag = {}));
\r
3174 * The Diagnostic namespace provides helper functions to work with
\r
3175 * [Diagnostic](#Diagnostic) literals.
\r
3178 (function (Diagnostic) {
\r
3180 * Creates a new Diagnostic literal.
\r
3182 function create(range, message, severity, code, source, relatedInformation) {
\r
3183 var result = { range: range, message: message };
\r
3184 if (Is.defined(severity)) {
\r
3185 result.severity = severity;
\r
3187 if (Is.defined(code)) {
\r
3188 result.code = code;
\r
3190 if (Is.defined(source)) {
\r
3191 result.source = source;
\r
3193 if (Is.defined(relatedInformation)) {
\r
3194 result.relatedInformation = relatedInformation;
\r
3198 Diagnostic.create = create;
\r
3200 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
\r
3202 function is(value) {
\r
3203 var candidate = value;
\r
3204 return Is.defined(candidate)
\r
3205 && Range.is(candidate.range)
\r
3206 && Is.string(candidate.message)
\r
3207 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
\r
3208 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
\r
3209 && (Is.string(candidate.source) || Is.undefined(candidate.source))
\r
3210 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
\r
3212 Diagnostic.is = is;
\r
3213 })(Diagnostic || (Diagnostic = {}));
\r
3215 * The Command namespace provides helper functions to work with
\r
3216 * [Command](#Command) literals.
\r
3219 (function (Command) {
\r
3221 * Creates a new Command literal.
\r
3223 function create(title, command) {
\r
3225 for (var _i = 2; _i < arguments.length; _i++) {
\r
3226 args[_i - 2] = arguments[_i];
\r
3228 var result = { title: title, command: command };
\r
3229 if (Is.defined(args) && args.length > 0) {
\r
3230 result.arguments = args;
\r
3234 Command.create = create;
\r
3236 * Checks whether the given literal conforms to the [Command](#Command) interface.
\r
3238 function is(value) {
\r
3239 var candidate = value;
\r
3240 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
\r
3243 })(Command || (Command = {}));
\r
3245 * The TextEdit namespace provides helper function to create replace,
\r
3246 * insert and delete edits more easily.
\r
3249 (function (TextEdit) {
\r
3251 * Creates a replace text edit.
\r
3252 * @param range The range of text to be replaced.
\r
3253 * @param newText The new text.
\r
3255 function replace(range, newText) {
\r
3256 return { range: range, newText: newText };
\r
3258 TextEdit.replace = replace;
\r
3260 * Creates a insert text edit.
\r
3261 * @param position The position to insert the text at.
\r
3262 * @param newText The text to be inserted.
\r
3264 function insert(position, newText) {
\r
3265 return { range: { start: position, end: position }, newText: newText };
\r
3267 TextEdit.insert = insert;
\r
3269 * Creates a delete text edit.
\r
3270 * @param range The range of text to be deleted.
\r
3272 function del(range) {
\r
3273 return { range: range, newText: '' };
\r
3275 TextEdit.del = del;
\r
3276 function is(value) {
\r
3277 var candidate = value;
\r
3278 return Is.objectLiteral(candidate)
\r
3279 && Is.string(candidate.newText)
\r
3280 && Range.is(candidate.range);
\r
3283 })(TextEdit || (TextEdit = {}));
\r
3285 * The TextDocumentEdit namespace provides helper function to create
\r
3286 * an edit that manipulates a text document.
\r
3288 var TextDocumentEdit;
\r
3289 (function (TextDocumentEdit) {
\r
3291 * Creates a new `TextDocumentEdit`
\r
3293 function create(textDocument, edits) {
\r
3294 return { textDocument: textDocument, edits: edits };
\r
3296 TextDocumentEdit.create = create;
\r
3297 function is(value) {
\r
3298 var candidate = value;
\r
3299 return Is.defined(candidate)
\r
3300 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
\r
3301 && Array.isArray(candidate.edits);
\r
3303 TextDocumentEdit.is = is;
\r
3304 })(TextDocumentEdit || (TextDocumentEdit = {}));
\r
3306 (function (CreateFile) {
\r
3307 function create(uri, options) {
\r
3312 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3313 result.options = options;
\r
3317 CreateFile.create = create;
\r
3318 function is(value) {
\r
3319 var candidate = value;
\r
3320 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
\r
3321 (candidate.options === void 0 ||
\r
3322 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3324 CreateFile.is = is;
\r
3325 })(CreateFile || (CreateFile = {}));
\r
3327 (function (RenameFile) {
\r
3328 function create(oldUri, newUri, options) {
\r
3334 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3335 result.options = options;
\r
3339 RenameFile.create = create;
\r
3340 function is(value) {
\r
3341 var candidate = value;
\r
3342 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
\r
3343 (candidate.options === void 0 ||
\r
3344 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3346 RenameFile.is = is;
\r
3347 })(RenameFile || (RenameFile = {}));
\r
3349 (function (DeleteFile) {
\r
3350 function create(uri, options) {
\r
3355 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
\r
3356 result.options = options;
\r
3360 DeleteFile.create = create;
\r
3361 function is(value) {
\r
3362 var candidate = value;
\r
3363 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
\r
3364 (candidate.options === void 0 ||
\r
3365 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
\r
3367 DeleteFile.is = is;
\r
3368 })(DeleteFile || (DeleteFile = {}));
\r
3369 var WorkspaceEdit;
\r
3370 (function (WorkspaceEdit) {
\r
3371 function is(value) {
\r
3372 var candidate = value;
\r
3373 return candidate &&
\r
3374 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
\r
3375 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
\r
3376 if (Is.string(change.kind)) {
\r
3377 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
\r
3380 return TextDocumentEdit.is(change);
\r
3384 WorkspaceEdit.is = is;
\r
3385 })(WorkspaceEdit || (WorkspaceEdit = {}));
\r
3386 var TextEditChangeImpl = /** @class */ (function () {
\r
3387 function TextEditChangeImpl(edits) {
\r
3388 this.edits = edits;
\r
3390 TextEditChangeImpl.prototype.insert = function (position, newText) {
\r
3391 this.edits.push(TextEdit.insert(position, newText));
\r
3393 TextEditChangeImpl.prototype.replace = function (range, newText) {
\r
3394 this.edits.push(TextEdit.replace(range, newText));
\r
3396 TextEditChangeImpl.prototype.delete = function (range) {
\r
3397 this.edits.push(TextEdit.del(range));
\r
3399 TextEditChangeImpl.prototype.add = function (edit) {
\r
3400 this.edits.push(edit);
\r
3402 TextEditChangeImpl.prototype.all = function () {
\r
3403 return this.edits;
\r
3405 TextEditChangeImpl.prototype.clear = function () {
\r
3406 this.edits.splice(0, this.edits.length);
\r
3408 return TextEditChangeImpl;
\r
3411 * A workspace change helps constructing changes to a workspace.
\r
3413 var WorkspaceChange = /** @class */ (function () {
\r
3414 function WorkspaceChange(workspaceEdit) {
\r
3416 this._textEditChanges = Object.create(null);
\r
3417 if (workspaceEdit) {
\r
3418 this._workspaceEdit = workspaceEdit;
\r
3419 if (workspaceEdit.documentChanges) {
\r
3420 workspaceEdit.documentChanges.forEach(function (change) {
\r
3421 if (TextDocumentEdit.is(change)) {
\r
3422 var textEditChange = new TextEditChangeImpl(change.edits);
\r
3423 _this._textEditChanges[change.textDocument.uri] = textEditChange;
\r
3427 else if (workspaceEdit.changes) {
\r
3428 Object.keys(workspaceEdit.changes).forEach(function (key) {
\r
3429 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
\r
3430 _this._textEditChanges[key] = textEditChange;
\r
3435 Object.defineProperty(WorkspaceChange.prototype, "edit", {
\r
3437 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
\r
3438 * use to be returned from a workspace edit operation like rename.
\r
3440 get: function () {
\r
3441 return this._workspaceEdit;
\r
3444 configurable: true
\r
3446 WorkspaceChange.prototype.getTextEditChange = function (key) {
\r
3447 if (VersionedTextDocumentIdentifier.is(key)) {
\r
3448 if (!this._workspaceEdit) {
\r
3449 this._workspaceEdit = {
\r
3450 documentChanges: []
\r
3453 if (!this._workspaceEdit.documentChanges) {
\r
3454 throw new Error('Workspace edit is not configured for document changes.');
\r
3456 var textDocument = key;
\r
3457 var result = this._textEditChanges[textDocument.uri];
\r
3460 var textDocumentEdit = {
\r
3461 textDocument: textDocument,
\r
3464 this._workspaceEdit.documentChanges.push(textDocumentEdit);
\r
3465 result = new TextEditChangeImpl(edits);
\r
3466 this._textEditChanges[textDocument.uri] = result;
\r
3471 if (!this._workspaceEdit) {
\r
3472 this._workspaceEdit = {
\r
3473 changes: Object.create(null)
\r
3476 if (!this._workspaceEdit.changes) {
\r
3477 throw new Error('Workspace edit is not configured for normal text edit changes.');
\r
3479 var result = this._textEditChanges[key];
\r
3482 this._workspaceEdit.changes[key] = edits;
\r
3483 result = new TextEditChangeImpl(edits);
\r
3484 this._textEditChanges[key] = result;
\r
3489 WorkspaceChange.prototype.createFile = function (uri, options) {
\r
3490 this.checkDocumentChanges();
\r
3491 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
\r
3493 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
\r
3494 this.checkDocumentChanges();
\r
3495 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
\r
3497 WorkspaceChange.prototype.deleteFile = function (uri, options) {
\r
3498 this.checkDocumentChanges();
\r
3499 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
\r
3501 WorkspaceChange.prototype.checkDocumentChanges = function () {
\r
3502 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
\r
3503 throw new Error('Workspace edit is not configured for document changes.');
\r
3506 return WorkspaceChange;
\r
3510 * The TextDocumentIdentifier namespace provides helper functions to work with
\r
3511 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
\r
3513 var TextDocumentIdentifier;
\r
3514 (function (TextDocumentIdentifier) {
\r
3516 * Creates a new TextDocumentIdentifier literal.
\r
3517 * @param uri The document's uri.
\r
3519 function create(uri) {
\r
3520 return { uri: uri };
\r
3522 TextDocumentIdentifier.create = create;
\r
3524 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
\r
3526 function is(value) {
\r
3527 var candidate = value;
\r
3528 return Is.defined(candidate) && Is.string(candidate.uri);
\r
3530 TextDocumentIdentifier.is = is;
\r
3531 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
\r
3533 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
\r
3534 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
\r
3536 var VersionedTextDocumentIdentifier;
\r
3537 (function (VersionedTextDocumentIdentifier) {
\r
3539 * Creates a new VersionedTextDocumentIdentifier literal.
\r
3540 * @param uri The document's uri.
\r
3541 * @param uri The document's text.
\r
3543 function create(uri, version) {
\r
3544 return { uri: uri, version: version };
\r
3546 VersionedTextDocumentIdentifier.create = create;
\r
3548 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
\r
3550 function is(value) {
\r
3551 var candidate = value;
\r
3552 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
\r
3554 VersionedTextDocumentIdentifier.is = is;
\r
3555 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
\r
3557 * The TextDocumentItem namespace provides helper functions to work with
\r
3558 * [TextDocumentItem](#TextDocumentItem) literals.
\r
3560 var TextDocumentItem;
\r
3561 (function (TextDocumentItem) {
\r
3563 * Creates a new TextDocumentItem literal.
\r
3564 * @param uri The document's uri.
\r
3565 * @param languageId The document's language identifier.
\r
3566 * @param version The document's version number.
\r
3567 * @param text The document's text.
\r
3569 function create(uri, languageId, version, text) {
\r
3570 return { uri: uri, languageId: languageId, version: version, text: text };
\r
3572 TextDocumentItem.create = create;
\r
3574 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
\r
3576 function is(value) {
\r
3577 var candidate = value;
\r
3578 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
\r
3580 TextDocumentItem.is = is;
\r
3581 })(TextDocumentItem || (TextDocumentItem = {}));
\r
3583 * Describes the content type that a client supports in various
\r
3584 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
\r
3586 * Please note that `MarkupKinds` must not start with a `$`. This kinds
\r
3587 * are reserved for internal usage.
\r
3590 (function (MarkupKind) {
\r
3592 * Plain text is supported as a content format
\r
3594 MarkupKind.PlainText = 'plaintext';
\r
3596 * Markdown is supported as a content format
\r
3598 MarkupKind.Markdown = 'markdown';
\r
3599 })(MarkupKind || (MarkupKind = {}));
\r
3600 (function (MarkupKind) {
\r
3602 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
\r
3604 function is(value) {
\r
3605 var candidate = value;
\r
3606 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
\r
3608 MarkupKind.is = is;
\r
3609 })(MarkupKind || (MarkupKind = {}));
\r
3610 var MarkupContent;
\r
3611 (function (MarkupContent) {
\r
3613 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
\r
3615 function is(value) {
\r
3616 var candidate = value;
\r
3617 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
\r
3619 MarkupContent.is = is;
\r
3620 })(MarkupContent || (MarkupContent = {}));
\r
3622 * The kind of a completion entry.
\r
3624 var CompletionItemKind;
\r
3625 (function (CompletionItemKind) {
\r
3626 CompletionItemKind.Text = 1;
\r
3627 CompletionItemKind.Method = 2;
\r
3628 CompletionItemKind.Function = 3;
\r
3629 CompletionItemKind.Constructor = 4;
\r
3630 CompletionItemKind.Field = 5;
\r
3631 CompletionItemKind.Variable = 6;
\r
3632 CompletionItemKind.Class = 7;
\r
3633 CompletionItemKind.Interface = 8;
\r
3634 CompletionItemKind.Module = 9;
\r
3635 CompletionItemKind.Property = 10;
\r
3636 CompletionItemKind.Unit = 11;
\r
3637 CompletionItemKind.Value = 12;
\r
3638 CompletionItemKind.Enum = 13;
\r
3639 CompletionItemKind.Keyword = 14;
\r
3640 CompletionItemKind.Snippet = 15;
\r
3641 CompletionItemKind.Color = 16;
\r
3642 CompletionItemKind.File = 17;
\r
3643 CompletionItemKind.Reference = 18;
\r
3644 CompletionItemKind.Folder = 19;
\r
3645 CompletionItemKind.EnumMember = 20;
\r
3646 CompletionItemKind.Constant = 21;
\r
3647 CompletionItemKind.Struct = 22;
\r
3648 CompletionItemKind.Event = 23;
\r
3649 CompletionItemKind.Operator = 24;
\r
3650 CompletionItemKind.TypeParameter = 25;
\r
3651 })(CompletionItemKind || (CompletionItemKind = {}));
\r
3653 * Defines whether the insert text in a completion item should be interpreted as
\r
3654 * plain text or a snippet.
\r
3656 var InsertTextFormat;
\r
3657 (function (InsertTextFormat) {
\r
3659 * The primary text to be inserted is treated as a plain string.
\r
3661 InsertTextFormat.PlainText = 1;
\r
3663 * The primary text to be inserted is treated as a snippet.
\r
3665 * A snippet can define tab stops and placeholders with `$1`, `$2`
\r
3666 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
\r
3667 * the end of the snippet. Placeholders with equal identifiers are linked,
\r
3668 * that is typing in one will update others too.
\r
3670 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
\r
3672 InsertTextFormat.Snippet = 2;
\r
3673 })(InsertTextFormat || (InsertTextFormat = {}));
\r
3675 * Completion item tags are extra annotations that tweak the rendering of a completion
\r
3680 var CompletionItemTag;
\r
3681 (function (CompletionItemTag) {
\r
3683 * Render a completion as obsolete, usually using a strike-out.
\r
3685 CompletionItemTag.Deprecated = 1;
\r
3686 })(CompletionItemTag || (CompletionItemTag = {}));
\r
3688 * The CompletionItem namespace provides functions to deal with
\r
3689 * completion items.
\r
3691 var CompletionItem;
\r
3692 (function (CompletionItem) {
\r
3694 * Create a completion item and seed it with a label.
\r
3695 * @param label The completion item's label
\r
3697 function create(label) {
\r
3698 return { label: label };
\r
3700 CompletionItem.create = create;
\r
3701 })(CompletionItem || (CompletionItem = {}));
\r
3703 * The CompletionList namespace provides functions to deal with
\r
3704 * completion lists.
\r
3706 var CompletionList;
\r
3707 (function (CompletionList) {
\r
3709 * Creates a new completion list.
\r
3711 * @param items The completion items.
\r
3712 * @param isIncomplete The list is not complete.
\r
3714 function create(items, isIncomplete) {
\r
3715 return { items: items ? items : [], isIncomplete: !!isIncomplete };
\r
3717 CompletionList.create = create;
\r
3718 })(CompletionList || (CompletionList = {}));
\r
3720 (function (MarkedString) {
\r
3722 * Creates a marked string from plain text.
\r
3724 * @param plainText The plain text.
\r
3726 function fromPlainText(plainText) {
\r
3727 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
\r
3729 MarkedString.fromPlainText = fromPlainText;
\r
3731 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
\r
3733 function is(value) {
\r
3734 var candidate = value;
\r
3735 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
\r
3737 MarkedString.is = is;
\r
3738 })(MarkedString || (MarkedString = {}));
\r
3740 (function (Hover) {
\r
3742 * Checks whether the given value conforms to the [Hover](#Hover) interface.
\r
3744 function is(value) {
\r
3745 var candidate = value;
\r
3746 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
\r
3747 MarkedString.is(candidate.contents) ||
\r
3748 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
\r
3751 })(Hover || (Hover = {}));
\r
3753 * The ParameterInformation namespace provides helper functions to work with
\r
3754 * [ParameterInformation](#ParameterInformation) literals.
\r
3756 var ParameterInformation;
\r
3757 (function (ParameterInformation) {
\r
3759 * Creates a new parameter information literal.
\r
3761 * @param label A label string.
\r
3762 * @param documentation A doc string.
\r
3764 function create(label, documentation) {
\r
3765 return documentation ? { label: label, documentation: documentation } : { label: label };
\r
3767 ParameterInformation.create = create;
\r
3768 })(ParameterInformation || (ParameterInformation = {}));
\r
3770 * The SignatureInformation namespace provides helper functions to work with
\r
3771 * [SignatureInformation](#SignatureInformation) literals.
\r
3773 var SignatureInformation;
\r
3774 (function (SignatureInformation) {
\r
3775 function create(label, documentation) {
\r
3776 var parameters = [];
\r
3777 for (var _i = 2; _i < arguments.length; _i++) {
\r
3778 parameters[_i - 2] = arguments[_i];
\r
3780 var result = { label: label };
\r
3781 if (Is.defined(documentation)) {
\r
3782 result.documentation = documentation;
\r
3784 if (Is.defined(parameters)) {
\r
3785 result.parameters = parameters;
\r
3788 result.parameters = [];
\r
3792 SignatureInformation.create = create;
\r
3793 })(SignatureInformation || (SignatureInformation = {}));
\r
3795 * A document highlight kind.
\r
3797 var DocumentHighlightKind;
\r
3798 (function (DocumentHighlightKind) {
\r
3800 * A textual occurrence.
\r
3802 DocumentHighlightKind.Text = 1;
\r
3804 * Read-access of a symbol, like reading a variable.
\r
3806 DocumentHighlightKind.Read = 2;
\r
3808 * Write-access of a symbol, like writing to a variable.
\r
3810 DocumentHighlightKind.Write = 3;
\r
3811 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
\r
3813 * DocumentHighlight namespace to provide helper functions to work with
\r
3814 * [DocumentHighlight](#DocumentHighlight) literals.
\r
3816 var DocumentHighlight;
\r
3817 (function (DocumentHighlight) {
\r
3819 * Create a DocumentHighlight object.
\r
3820 * @param range The range the highlight applies to.
\r
3822 function create(range, kind) {
\r
3823 var result = { range: range };
\r
3824 if (Is.number(kind)) {
\r
3825 result.kind = kind;
\r
3829 DocumentHighlight.create = create;
\r
3830 })(DocumentHighlight || (DocumentHighlight = {}));
\r
3835 (function (SymbolKind) {
\r
3836 SymbolKind.File = 1;
\r
3837 SymbolKind.Module = 2;
\r
3838 SymbolKind.Namespace = 3;
\r
3839 SymbolKind.Package = 4;
\r
3840 SymbolKind.Class = 5;
\r
3841 SymbolKind.Method = 6;
\r
3842 SymbolKind.Property = 7;
\r
3843 SymbolKind.Field = 8;
\r
3844 SymbolKind.Constructor = 9;
\r
3845 SymbolKind.Enum = 10;
\r
3846 SymbolKind.Interface = 11;
\r
3847 SymbolKind.Function = 12;
\r
3848 SymbolKind.Variable = 13;
\r
3849 SymbolKind.Constant = 14;
\r
3850 SymbolKind.String = 15;
\r
3851 SymbolKind.Number = 16;
\r
3852 SymbolKind.Boolean = 17;
\r
3853 SymbolKind.Array = 18;
\r
3854 SymbolKind.Object = 19;
\r
3855 SymbolKind.Key = 20;
\r
3856 SymbolKind.Null = 21;
\r
3857 SymbolKind.EnumMember = 22;
\r
3858 SymbolKind.Struct = 23;
\r
3859 SymbolKind.Event = 24;
\r
3860 SymbolKind.Operator = 25;
\r
3861 SymbolKind.TypeParameter = 26;
\r
3862 })(SymbolKind || (SymbolKind = {}));
\r
3864 * Symbol tags are extra annotations that tweak the rendering of a symbol.
\r
3868 (function (SymbolTag) {
\r
3870 * Render a symbol as obsolete, usually using a strike-out.
\r
3872 SymbolTag.Deprecated = 1;
\r
3873 })(SymbolTag || (SymbolTag = {}));
\r
3874 var SymbolInformation;
\r
3875 (function (SymbolInformation) {
\r
3877 * Creates a new symbol information literal.
\r
3879 * @param name The name of the symbol.
\r
3880 * @param kind The kind of the symbol.
\r
3881 * @param range The range of the location of the symbol.
\r
3882 * @param uri The resource of the location of symbol, defaults to the current document.
\r
3883 * @param containerName The name of the symbol containing the symbol.
\r
3885 function create(name, kind, range, uri, containerName) {
\r
3889 location: { uri: uri, range: range }
\r
3891 if (containerName) {
\r
3892 result.containerName = containerName;
\r
3896 SymbolInformation.create = create;
\r
3897 })(SymbolInformation || (SymbolInformation = {}));
\r
3898 var DocumentSymbol;
\r
3899 (function (DocumentSymbol) {
\r
3901 * Creates a new symbol information literal.
\r
3903 * @param name The name of the symbol.
\r
3904 * @param detail The detail of the symbol.
\r
3905 * @param kind The kind of the symbol.
\r
3906 * @param range The range of the symbol.
\r
3907 * @param selectionRange The selectionRange of the symbol.
\r
3908 * @param children Children of the symbol.
\r
3910 function create(name, detail, kind, range, selectionRange, children) {
\r
3916 selectionRange: selectionRange
\r
3918 if (children !== void 0) {
\r
3919 result.children = children;
\r
3923 DocumentSymbol.create = create;
\r
3925 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
\r
3927 function is(value) {
\r
3928 var candidate = value;
\r
3929 return candidate &&
\r
3930 Is.string(candidate.name) && Is.number(candidate.kind) &&
\r
3931 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
\r
3932 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
\r
3933 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
\r
3934 (candidate.children === void 0 || Array.isArray(candidate.children));
\r
3936 DocumentSymbol.is = is;
\r
3937 })(DocumentSymbol || (DocumentSymbol = {}));
\r
3939 * A set of predefined code action kinds
\r
3941 var CodeActionKind;
\r
3942 (function (CodeActionKind) {
\r
3946 CodeActionKind.Empty = '';
\r
3948 * Base kind for quickfix actions: 'quickfix'
\r
3950 CodeActionKind.QuickFix = 'quickfix';
\r
3952 * Base kind for refactoring actions: 'refactor'
\r
3954 CodeActionKind.Refactor = 'refactor';
\r
3956 * Base kind for refactoring extraction actions: 'refactor.extract'
\r
3958 * Example extract actions:
\r
3960 * - Extract method
\r
3961 * - Extract function
\r
3962 * - Extract variable
\r
3963 * - Extract interface from class
\r
3966 CodeActionKind.RefactorExtract = 'refactor.extract';
\r
3968 * Base kind for refactoring inline actions: 'refactor.inline'
\r
3970 * Example inline actions:
\r
3972 * - Inline function
\r
3973 * - Inline variable
\r
3974 * - Inline constant
\r
3977 CodeActionKind.RefactorInline = 'refactor.inline';
\r
3979 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
\r
3981 * Example rewrite actions:
\r
3983 * - Convert JavaScript function to class
\r
3984 * - Add or remove parameter
\r
3985 * - Encapsulate field
\r
3986 * - Make method static
\r
3987 * - Move method to base class
\r
3990 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
\r
3992 * Base kind for source actions: `source`
\r
3994 * Source code actions apply to the entire file.
\r
3996 CodeActionKind.Source = 'source';
\r
3998 * Base kind for an organize imports source action: `source.organizeImports`
\r
4000 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
\r
4002 * Base kind for auto-fix source actions: `source.fixAll`.
\r
4004 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
\r
4005 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
\r
4009 CodeActionKind.SourceFixAll = 'source.fixAll';
\r
4010 })(CodeActionKind || (CodeActionKind = {}));
\r
4012 * The CodeActionContext namespace provides helper functions to work with
\r
4013 * [CodeActionContext](#CodeActionContext) literals.
\r
4015 var CodeActionContext;
\r
4016 (function (CodeActionContext) {
\r
4018 * Creates a new CodeActionContext literal.
\r
4020 function create(diagnostics, only) {
\r
4021 var result = { diagnostics: diagnostics };
\r
4022 if (only !== void 0 && only !== null) {
\r
4023 result.only = only;
\r
4027 CodeActionContext.create = create;
\r
4029 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
\r
4031 function is(value) {
\r
4032 var candidate = value;
\r
4033 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
\r
4035 CodeActionContext.is = is;
\r
4036 })(CodeActionContext || (CodeActionContext = {}));
\r
4038 (function (CodeAction) {
\r
4039 function create(title, commandOrEdit, kind) {
\r
4040 var result = { title: title };
\r
4041 if (Command.is(commandOrEdit)) {
\r
4042 result.command = commandOrEdit;
\r
4045 result.edit = commandOrEdit;
\r
4047 if (kind !== void 0) {
\r
4048 result.kind = kind;
\r
4052 CodeAction.create = create;
\r
4053 function is(value) {
\r
4054 var candidate = value;
\r
4055 return candidate && Is.string(candidate.title) &&
\r
4056 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
\r
4057 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
\r
4058 (candidate.edit !== void 0 || candidate.command !== void 0) &&
\r
4059 (candidate.command === void 0 || Command.is(candidate.command)) &&
\r
4060 (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) &&
\r
4061 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
\r
4063 CodeAction.is = is;
\r
4064 })(CodeAction || (CodeAction = {}));
\r
4066 * The CodeLens namespace provides helper functions to work with
\r
4067 * [CodeLens](#CodeLens) literals.
\r
4070 (function (CodeLens) {
\r
4072 * Creates a new CodeLens literal.
\r
4074 function create(range, data) {
\r
4075 var result = { range: range };
\r
4076 if (Is.defined(data)) {
\r
4077 result.data = data;
\r
4081 CodeLens.create = create;
\r
4083 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
\r
4085 function is(value) {
\r
4086 var candidate = value;
\r
4087 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
\r
4090 })(CodeLens || (CodeLens = {}));
\r
4092 * The FormattingOptions namespace provides helper functions to work with
\r
4093 * [FormattingOptions](#FormattingOptions) literals.
\r
4095 var FormattingOptions;
\r
4096 (function (FormattingOptions) {
\r
4098 * Creates a new FormattingOptions literal.
\r
4100 function create(tabSize, insertSpaces) {
\r
4101 return { tabSize: tabSize, insertSpaces: insertSpaces };
\r
4103 FormattingOptions.create = create;
\r
4105 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
\r
4107 function is(value) {
\r
4108 var candidate = value;
\r
4109 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
\r
4111 FormattingOptions.is = is;
\r
4112 })(FormattingOptions || (FormattingOptions = {}));
\r
4114 * The DocumentLink namespace provides helper functions to work with
\r
4115 * [DocumentLink](#DocumentLink) literals.
\r
4118 (function (DocumentLink) {
\r
4120 * Creates a new DocumentLink literal.
\r
4122 function create(range, target, data) {
\r
4123 return { range: range, target: target, data: data };
\r
4125 DocumentLink.create = create;
\r
4127 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
\r
4129 function is(value) {
\r
4130 var candidate = value;
\r
4131 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
\r
4133 DocumentLink.is = is;
\r
4134 })(DocumentLink || (DocumentLink = {}));
\r
4136 * The SelectionRange namespace provides helper function to work with
\r
4137 * SelectionRange literals.
\r
4139 var SelectionRange;
\r
4140 (function (SelectionRange) {
\r
4142 * Creates a new SelectionRange
\r
4143 * @param range the range.
\r
4144 * @param parent an optional parent.
\r
4146 function create(range, parent) {
\r
4147 return { range: range, parent: parent };
\r
4149 SelectionRange.create = create;
\r
4150 function is(value) {
\r
4151 var candidate = value;
\r
4152 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
\r
4154 SelectionRange.is = is;
\r
4155 })(SelectionRange || (SelectionRange = {}));
\r
4156 var EOL = ['\n', '\r\n', '\r'];
\r
4158 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
\r
4161 (function (TextDocument) {
\r
4163 * Creates a new ITextDocument literal from the given uri and content.
\r
4164 * @param uri The document's uri.
\r
4165 * @param languageId The document's language Id.
\r
4166 * @param content The document's content.
\r
4168 function create(uri, languageId, version, content) {
\r
4169 return new FullTextDocument(uri, languageId, version, content);
\r
4171 TextDocument.create = create;
\r
4173 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
\r
4175 function is(value) {
\r
4176 var candidate = value;
\r
4177 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
\r
4178 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
\r
4180 TextDocument.is = is;
\r
4181 function applyEdits(document, edits) {
\r
4182 var text = document.getText();
\r
4183 var sortedEdits = mergeSort(edits, function (a, b) {
\r
4184 var diff = a.range.start.line - b.range.start.line;
\r
4186 return a.range.start.character - b.range.start.character;
\r
4190 var lastModifiedOffset = text.length;
\r
4191 for (var i = sortedEdits.length - 1; i >= 0; i--) {
\r
4192 var e = sortedEdits[i];
\r
4193 var startOffset = document.offsetAt(e.range.start);
\r
4194 var endOffset = document.offsetAt(e.range.end);
\r
4195 if (endOffset <= lastModifiedOffset) {
\r
4196 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
\r
4199 throw new Error('Overlapping edit');
\r
4201 lastModifiedOffset = startOffset;
\r
4205 TextDocument.applyEdits = applyEdits;
\r
4206 function mergeSort(data, compare) {
\r
4207 if (data.length <= 1) {
\r
4211 var p = (data.length / 2) | 0;
\r
4212 var left = data.slice(0, p);
\r
4213 var right = data.slice(p);
\r
4214 mergeSort(left, compare);
\r
4215 mergeSort(right, compare);
\r
4219 while (leftIdx < left.length && rightIdx < right.length) {
\r
4220 var ret = compare(left[leftIdx], right[rightIdx]);
\r
4222 // smaller_equal -> take left to preserve order
\r
4223 data[i++] = left[leftIdx++];
\r
4226 // greater -> take right
\r
4227 data[i++] = right[rightIdx++];
\r
4230 while (leftIdx < left.length) {
\r
4231 data[i++] = left[leftIdx++];
\r
4233 while (rightIdx < right.length) {
\r
4234 data[i++] = right[rightIdx++];
\r
4238 })(TextDocument || (TextDocument = {}));
\r
4239 var FullTextDocument = /** @class */ (function () {
\r
4240 function FullTextDocument(uri, languageId, version, content) {
\r
4242 this._languageId = languageId;
\r
4243 this._version = version;
\r
4244 this._content = content;
\r
4245 this._lineOffsets = undefined;
\r
4247 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
4248 get: function () {
\r
4252 configurable: true
\r
4254 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
4255 get: function () {
\r
4256 return this._languageId;
\r
4259 configurable: true
\r
4261 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
4262 get: function () {
\r
4263 return this._version;
\r
4266 configurable: true
\r
4268 FullTextDocument.prototype.getText = function (range) {
\r
4270 var start = this.offsetAt(range.start);
\r
4271 var end = this.offsetAt(range.end);
\r
4272 return this._content.substring(start, end);
\r
4274 return this._content;
\r
4276 FullTextDocument.prototype.update = function (event, version) {
\r
4277 this._content = event.text;
\r
4278 this._version = version;
\r
4279 this._lineOffsets = undefined;
\r
4281 FullTextDocument.prototype.getLineOffsets = function () {
\r
4282 if (this._lineOffsets === undefined) {
\r
4283 var lineOffsets = [];
\r
4284 var text = this._content;
\r
4285 var isLineStart = true;
\r
4286 for (var i = 0; i < text.length; i++) {
\r
4287 if (isLineStart) {
\r
4288 lineOffsets.push(i);
\r
4289 isLineStart = false;
\r
4291 var ch = text.charAt(i);
\r
4292 isLineStart = (ch === '\r' || ch === '\n');
\r
4293 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
\r
4297 if (isLineStart && text.length > 0) {
\r
4298 lineOffsets.push(text.length);
\r
4300 this._lineOffsets = lineOffsets;
\r
4302 return this._lineOffsets;
\r
4304 FullTextDocument.prototype.positionAt = function (offset) {
\r
4305 offset = Math.max(Math.min(offset, this._content.length), 0);
\r
4306 var lineOffsets = this.getLineOffsets();
\r
4307 var low = 0, high = lineOffsets.length;
\r
4309 return Position.create(0, offset);
\r
4311 while (low < high) {
\r
4312 var mid = Math.floor((low + high) / 2);
\r
4313 if (lineOffsets[mid] > offset) {
\r
4320 // low is the least x for which the line offset is larger than the current offset
\r
4321 // or array.length if no line offset is larger than the current offset
\r
4322 var line = low - 1;
\r
4323 return Position.create(line, offset - lineOffsets[line]);
\r
4325 FullTextDocument.prototype.offsetAt = function (position) {
\r
4326 var lineOffsets = this.getLineOffsets();
\r
4327 if (position.line >= lineOffsets.length) {
\r
4328 return this._content.length;
\r
4330 else if (position.line < 0) {
\r
4333 var lineOffset = lineOffsets[position.line];
\r
4334 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
\r
4335 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
\r
4337 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
4338 get: function () {
\r
4339 return this.getLineOffsets().length;
\r
4342 configurable: true
\r
4344 return FullTextDocument;
\r
4348 var toString = Object.prototype.toString;
\r
4349 function defined(value) {
\r
4350 return typeof value !== 'undefined';
\r
4352 Is.defined = defined;
\r
4353 function undefined(value) {
\r
4354 return typeof value === 'undefined';
\r
4356 Is.undefined = undefined;
\r
4357 function boolean(value) {
\r
4358 return value === true || value === false;
\r
4360 Is.boolean = boolean;
\r
4361 function string(value) {
\r
4362 return toString.call(value) === '[object String]';
\r
4364 Is.string = string;
\r
4365 function number(value) {
\r
4366 return toString.call(value) === '[object Number]';
\r
4368 Is.number = number;
\r
4369 function func(value) {
\r
4370 return toString.call(value) === '[object Function]';
\r
4373 function objectLiteral(value) {
\r
4374 // Strictly speaking class instances pass this check as well. Since the LSP
\r
4375 // doesn't use classes we ignore this for now. If we do we need to add something
\r
4376 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
4377 return value !== null && typeof value === 'object';
\r
4379 Is.objectLiteral = objectLiteral;
\r
4380 function typedArray(value, check) {
\r
4381 return Array.isArray(value) && value.every(check);
\r
4383 Is.typedArray = typedArray;
\r
4384 })(Is || (Is = {}));
\r
4389 /***/ (function(module, exports, __webpack_require__) {
4392 /* --------------------------------------------------------------------------------------------
\r
4393 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4394 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4395 * ------------------------------------------------------------------------------------------ */
\r
4397 Object.defineProperty(exports, "__esModule", { value: true });
\r
4398 const Is = __webpack_require__(20);
\r
4399 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4400 const messages_1 = __webpack_require__(21);
\r
4401 const protocol_implementation_1 = __webpack_require__(22);
\r
4402 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
\r
4403 const protocol_typeDefinition_1 = __webpack_require__(23);
\r
4404 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
\r
4405 const protocol_workspaceFolders_1 = __webpack_require__(24);
\r
4406 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
\r
4407 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
\r
4408 const protocol_configuration_1 = __webpack_require__(25);
\r
4409 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
\r
4410 const protocol_colorProvider_1 = __webpack_require__(26);
\r
4411 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
\r
4412 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
\r
4413 const protocol_foldingRange_1 = __webpack_require__(27);
\r
4414 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
\r
4415 const protocol_declaration_1 = __webpack_require__(28);
\r
4416 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
\r
4417 const protocol_selectionRange_1 = __webpack_require__(29);
\r
4418 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
\r
4419 const protocol_progress_1 = __webpack_require__(30);
\r
4420 exports.WorkDoneProgress = protocol_progress_1.WorkDoneProgress;
\r
4421 exports.WorkDoneProgressCreateRequest = protocol_progress_1.WorkDoneProgressCreateRequest;
\r
4422 exports.WorkDoneProgressCancelNotification = protocol_progress_1.WorkDoneProgressCancelNotification;
\r
4423 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
4424 let __noDynamicImport;
\r
4426 * The DocumentFilter namespace provides helper functions to work with
\r
4427 * [DocumentFilter](#DocumentFilter) literals.
\r
4429 var DocumentFilter;
\r
4430 (function (DocumentFilter) {
\r
4431 function is(value) {
\r
4432 const candidate = value;
\r
4433 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
\r
4435 DocumentFilter.is = is;
\r
4436 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
\r
4438 * The DocumentSelector namespace provides helper functions to work with
\r
4439 * [DocumentSelector](#DocumentSelector)s.
\r
4441 var DocumentSelector;
\r
4442 (function (DocumentSelector) {
\r
4443 function is(value) {
\r
4444 if (!Array.isArray(value)) {
\r
4447 for (let elem of value) {
\r
4448 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
\r
4454 DocumentSelector.is = is;
\r
4455 })(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
\r
4457 * The `client/registerCapability` request is sent from the server to the client to register a new capability
\r
4458 * handler on the client side.
\r
4460 var RegistrationRequest;
\r
4461 (function (RegistrationRequest) {
\r
4462 RegistrationRequest.type = new messages_1.ProtocolRequestType('client/registerCapability');
\r
4463 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
\r
4465 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
\r
4466 * handler on the client side.
\r
4468 var UnregistrationRequest;
\r
4469 (function (UnregistrationRequest) {
\r
4470 UnregistrationRequest.type = new messages_1.ProtocolRequestType('client/unregisterCapability');
\r
4471 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
\r
4472 var ResourceOperationKind;
\r
4473 (function (ResourceOperationKind) {
\r
4475 * Supports creating new files and folders.
\r
4477 ResourceOperationKind.Create = 'create';
\r
4479 * Supports renaming existing files and folders.
\r
4481 ResourceOperationKind.Rename = 'rename';
\r
4483 * Supports deleting existing files and folders.
\r
4485 ResourceOperationKind.Delete = 'delete';
\r
4486 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
\r
4487 var FailureHandlingKind;
\r
4488 (function (FailureHandlingKind) {
\r
4490 * Applying the workspace change is simply aborted if one of the changes provided
\r
4491 * fails. All operations executed before the failing operation stay executed.
\r
4493 FailureHandlingKind.Abort = 'abort';
\r
4495 * All operations are executed transactional. That means they either all
\r
4496 * succeed or no changes at all are applied to the workspace.
\r
4498 FailureHandlingKind.Transactional = 'transactional';
\r
4500 * If the workspace edit contains only textual file changes they are executed transactional.
\r
4501 * If resource changes (create, rename or delete file) are part of the change the failure
\r
4502 * handling startegy is abort.
\r
4504 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
\r
4506 * The client tries to undo the operations already executed. But there is no
\r
4507 * guarantee that this is succeeding.
\r
4509 FailureHandlingKind.Undo = 'undo';
\r
4510 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
\r
4512 * The StaticRegistrationOptions namespace provides helper functions to work with
\r
4513 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
\r
4515 var StaticRegistrationOptions;
\r
4516 (function (StaticRegistrationOptions) {
\r
4517 function hasId(value) {
\r
4518 const candidate = value;
\r
4519 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
\r
4521 StaticRegistrationOptions.hasId = hasId;
\r
4522 })(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
\r
4524 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
\r
4525 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
\r
4527 var TextDocumentRegistrationOptions;
\r
4528 (function (TextDocumentRegistrationOptions) {
\r
4529 function is(value) {
\r
4530 const candidate = value;
\r
4531 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
\r
4533 TextDocumentRegistrationOptions.is = is;
\r
4534 })(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
\r
4536 * The WorkDoneProgressOptions namespace provides helper functions to work with
\r
4537 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
\r
4539 var WorkDoneProgressOptions;
\r
4540 (function (WorkDoneProgressOptions) {
\r
4541 function is(value) {
\r
4542 const candidate = value;
\r
4543 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
\r
4545 WorkDoneProgressOptions.is = is;
\r
4546 function hasWorkDoneProgress(value) {
\r
4547 const candidate = value;
\r
4548 return candidate && Is.boolean(candidate.workDoneProgress);
\r
4550 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
\r
4551 })(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
\r
4553 * The initialize request is sent from the client to the server.
\r
4554 * It is sent once as the request after starting up the server.
\r
4555 * The requests parameter is of type [InitializeParams](#InitializeParams)
\r
4556 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
\r
4557 * resolves to such.
\r
4559 var InitializeRequest;
\r
4560 (function (InitializeRequest) {
\r
4561 InitializeRequest.type = new messages_1.ProtocolRequestType('initialize');
\r
4562 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
\r
4564 * Known error codes for an `InitializeError`;
\r
4566 var InitializeError;
\r
4567 (function (InitializeError) {
\r
4569 * If the protocol version provided by the client can't be handled by the server.
\r
4570 * @deprecated This initialize error got replaced by client capabilities. There is
\r
4571 * no version handshake in version 3.0x
\r
4573 InitializeError.unknownProtocolVersion = 1;
\r
4574 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
\r
4576 * The intialized notification is sent from the client to the
\r
4577 * server after the client is fully initialized and the server
\r
4578 * is allowed to send requests from the server to the client.
\r
4580 var InitializedNotification;
\r
4581 (function (InitializedNotification) {
\r
4582 InitializedNotification.type = new messages_1.ProtocolNotificationType('initialized');
\r
4583 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
\r
4584 //---- Shutdown Method ----
\r
4586 * A shutdown request is sent from the client to the server.
\r
4587 * It is sent once when the client decides to shutdown the
\r
4588 * server. The only notification that is sent after a shutdown request
\r
4589 * is the exit event.
\r
4591 var ShutdownRequest;
\r
4592 (function (ShutdownRequest) {
\r
4593 ShutdownRequest.type = new messages_1.ProtocolRequestType0('shutdown');
\r
4594 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
\r
4595 //---- Exit Notification ----
\r
4597 * The exit event is sent from the client to the server to
\r
4598 * ask the server to exit its process.
\r
4600 var ExitNotification;
\r
4601 (function (ExitNotification) {
\r
4602 ExitNotification.type = new messages_1.ProtocolNotificationType0('exit');
\r
4603 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
\r
4605 * The configuration change notification is sent from the client to the server
\r
4606 * when the client's configuration has changed. The notification contains
\r
4607 * the changed configuration as defined by the language client.
\r
4609 var DidChangeConfigurationNotification;
\r
4610 (function (DidChangeConfigurationNotification) {
\r
4611 DidChangeConfigurationNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeConfiguration');
\r
4612 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
\r
4613 //---- Message show and log notifications ----
\r
4615 * The message type
\r
4618 (function (MessageType) {
\r
4620 * An error message.
\r
4622 MessageType.Error = 1;
\r
4624 * A warning message.
\r
4626 MessageType.Warning = 2;
\r
4628 * An information message.
\r
4630 MessageType.Info = 3;
\r
4634 MessageType.Log = 4;
\r
4635 })(MessageType = exports.MessageType || (exports.MessageType = {}));
\r
4637 * The show message notification is sent from a server to a client to ask
\r
4638 * the client to display a particular message in the user interface.
\r
4640 var ShowMessageNotification;
\r
4641 (function (ShowMessageNotification) {
\r
4642 ShowMessageNotification.type = new messages_1.ProtocolNotificationType('window/showMessage');
\r
4643 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
\r
4645 * The show message request is sent from the server to the client to show a message
\r
4646 * and a set of options actions to the user.
\r
4648 var ShowMessageRequest;
\r
4649 (function (ShowMessageRequest) {
\r
4650 ShowMessageRequest.type = new messages_1.ProtocolRequestType('window/showMessageRequest');
\r
4651 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
\r
4653 * The log message notification is sent from the server to the client to ask
\r
4654 * the client to log a particular message.
\r
4656 var LogMessageNotification;
\r
4657 (function (LogMessageNotification) {
\r
4658 LogMessageNotification.type = new messages_1.ProtocolNotificationType('window/logMessage');
\r
4659 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
\r
4660 //---- Telemetry notification
\r
4662 * The telemetry event notification is sent from the server to the client to ask
\r
4663 * the client to log telemetry data.
\r
4665 var TelemetryEventNotification;
\r
4666 (function (TelemetryEventNotification) {
\r
4667 TelemetryEventNotification.type = new messages_1.ProtocolNotificationType('telemetry/event');
\r
4668 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
\r
4670 * Defines how the host (editor) should sync
\r
4671 * document changes to the language server.
\r
4673 var TextDocumentSyncKind;
\r
4674 (function (TextDocumentSyncKind) {
\r
4676 * Documents should not be synced at all.
\r
4678 TextDocumentSyncKind.None = 0;
\r
4680 * Documents are synced by always sending the full content
\r
4681 * of the document.
\r
4683 TextDocumentSyncKind.Full = 1;
\r
4685 * Documents are synced by sending the full content on open.
\r
4686 * After that only incremental updates to the document are
\r
4689 TextDocumentSyncKind.Incremental = 2;
\r
4690 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
\r
4692 * The document open notification is sent from the client to the server to signal
\r
4693 * newly opened text documents. The document's truth is now managed by the client
\r
4694 * and the server must not try to read the document's truth using the document's
\r
4695 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
\r
4696 * mean that its content is presented in an editor. An open notification must not
\r
4697 * be sent more than once without a corresponding close notification send before.
\r
4698 * This means open and close notification must be balanced and the max open count
\r
4701 var DidOpenTextDocumentNotification;
\r
4702 (function (DidOpenTextDocumentNotification) {
\r
4703 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
\r
4704 DidOpenTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification.method);
\r
4705 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
\r
4707 * The document change notification is sent from the client to the server to signal
\r
4708 * changes to a text document.
\r
4710 var DidChangeTextDocumentNotification;
\r
4711 (function (DidChangeTextDocumentNotification) {
\r
4712 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
\r
4713 DidChangeTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification.method);
\r
4714 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
\r
4716 * The document close notification is sent from the client to the server when
\r
4717 * the document got closed in the client. The document's truth now exists where
\r
4718 * the document's uri points to (e.g. if the document's uri is a file uri the
\r
4719 * truth now exists on disk). As with the open notification the close notification
\r
4720 * is about managing the document's content. Receiving a close notification
\r
4721 * doesn't mean that the document was open in an editor before. A close
\r
4722 * notification requires a previous open notification to be sent.
\r
4724 var DidCloseTextDocumentNotification;
\r
4725 (function (DidCloseTextDocumentNotification) {
\r
4726 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
\r
4727 DidCloseTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification.method);
\r
4728 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
\r
4730 * The document save notification is sent from the client to the server when
\r
4731 * the document got saved in the client.
\r
4733 var DidSaveTextDocumentNotification;
\r
4734 (function (DidSaveTextDocumentNotification) {
\r
4735 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
\r
4736 DidSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification.method);
\r
4737 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
\r
4739 * Represents reasons why a text document is saved.
\r
4741 var TextDocumentSaveReason;
\r
4742 (function (TextDocumentSaveReason) {
\r
4744 * Manually triggered, e.g. by the user pressing save, by starting debugging,
\r
4745 * or by an API call.
\r
4747 TextDocumentSaveReason.Manual = 1;
\r
4749 * Automatic after a delay.
\r
4751 TextDocumentSaveReason.AfterDelay = 2;
\r
4753 * When the editor lost focus.
\r
4755 TextDocumentSaveReason.FocusOut = 3;
\r
4756 })(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
\r
4758 * A document will save notification is sent from the client to the server before
\r
4759 * the document is actually saved.
\r
4761 var WillSaveTextDocumentNotification;
\r
4762 (function (WillSaveTextDocumentNotification) {
\r
4763 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
\r
4764 WillSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification.method);
\r
4765 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
\r
4767 * A document will save request is sent from the client to the server before
\r
4768 * the document is actually saved. The request can return an array of TextEdits
\r
4769 * which will be applied to the text document before it is saved. Please note that
\r
4770 * clients might drop results if computing the text edits took too long or if a
\r
4771 * server constantly fails on this request. This is done to keep the save fast and
\r
4774 var WillSaveTextDocumentWaitUntilRequest;
\r
4775 (function (WillSaveTextDocumentWaitUntilRequest) {
\r
4776 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
\r
4777 WillSaveTextDocumentWaitUntilRequest.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest.method);
\r
4778 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
\r
4780 * The watched files notification is sent from the client to the server when
\r
4781 * the client detects changes to file watched by the language client.
\r
4783 var DidChangeWatchedFilesNotification;
\r
4784 (function (DidChangeWatchedFilesNotification) {
\r
4785 DidChangeWatchedFilesNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWatchedFiles');
\r
4786 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
\r
4788 * The file event type
\r
4790 var FileChangeType;
\r
4791 (function (FileChangeType) {
\r
4793 * The file got created.
\r
4795 FileChangeType.Created = 1;
\r
4797 * The file got changed.
\r
4799 FileChangeType.Changed = 2;
\r
4801 * The file got deleted.
\r
4803 FileChangeType.Deleted = 3;
\r
4804 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
\r
4806 (function (WatchKind) {
\r
4808 * Interested in create events.
\r
4810 WatchKind.Create = 1;
\r
4812 * Interested in change events
\r
4814 WatchKind.Change = 2;
\r
4816 * Interested in delete events
\r
4818 WatchKind.Delete = 4;
\r
4819 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
\r
4821 * Diagnostics notification are sent from the server to the client to signal
\r
4822 * results of validation runs.
\r
4824 var PublishDiagnosticsNotification;
\r
4825 (function (PublishDiagnosticsNotification) {
\r
4826 PublishDiagnosticsNotification.type = new messages_1.ProtocolNotificationType('textDocument/publishDiagnostics');
\r
4827 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
\r
4829 * How a completion was triggered
\r
4831 var CompletionTriggerKind;
\r
4832 (function (CompletionTriggerKind) {
\r
4834 * Completion was triggered by typing an identifier (24x7 code
\r
4835 * complete), manual invocation (e.g Ctrl+Space) or via API.
\r
4837 CompletionTriggerKind.Invoked = 1;
\r
4839 * Completion was triggered by a trigger character specified by
\r
4840 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
\r
4842 CompletionTriggerKind.TriggerCharacter = 2;
\r
4844 * Completion was re-triggered as current completion list is incomplete
\r
4846 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
\r
4847 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
\r
4849 * Request to request completion at a given text document position. The request's
\r
4850 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
\r
4851 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
\r
4852 * or a Thenable that resolves to such.
\r
4854 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
\r
4855 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
\r
4856 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
\r
4857 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
\r
4859 var CompletionRequest;
\r
4860 (function (CompletionRequest) {
\r
4861 CompletionRequest.method = 'textDocument/completion';
\r
4862 CompletionRequest.type = new messages_1.ProtocolRequestType(CompletionRequest.method);
\r
4863 /** @deprecated Use CompletionRequest.type */
\r
4864 CompletionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4865 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
\r
4867 * Request to resolve additional information for a given completion item.The request's
\r
4868 * parameter is of type [CompletionItem](#CompletionItem) the response
\r
4869 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
\r
4871 var CompletionResolveRequest;
\r
4872 (function (CompletionResolveRequest) {
\r
4873 CompletionResolveRequest.method = 'completionItem/resolve';
\r
4874 CompletionResolveRequest.type = new messages_1.ProtocolRequestType(CompletionResolveRequest.method);
\r
4875 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
\r
4877 * Request to request hover information at a given text document position. The request's
\r
4878 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
\r
4879 * type [Hover](#Hover) or a Thenable that resolves to such.
\r
4882 (function (HoverRequest) {
\r
4883 HoverRequest.method = 'textDocument/hover';
\r
4884 HoverRequest.type = new messages_1.ProtocolRequestType(HoverRequest.method);
\r
4885 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
\r
4887 * How a signature help was triggered.
\r
4891 var SignatureHelpTriggerKind;
\r
4892 (function (SignatureHelpTriggerKind) {
\r
4894 * Signature help was invoked manually by the user or by a command.
\r
4896 SignatureHelpTriggerKind.Invoked = 1;
\r
4898 * Signature help was triggered by a trigger character.
\r
4900 SignatureHelpTriggerKind.TriggerCharacter = 2;
\r
4902 * Signature help was triggered by the cursor moving or by the document content changing.
\r
4904 SignatureHelpTriggerKind.ContentChange = 3;
\r
4905 })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
\r
4906 var SignatureHelpRequest;
\r
4907 (function (SignatureHelpRequest) {
\r
4908 SignatureHelpRequest.method = 'textDocument/signatureHelp';
\r
4909 SignatureHelpRequest.type = new messages_1.ProtocolRequestType(SignatureHelpRequest.method);
\r
4910 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
\r
4912 * A request to resolve the definition location of a symbol at a given text
\r
4913 * document position. The request's parameter is of type [TextDocumentPosition]
\r
4914 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
\r
4915 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
\r
4918 var DefinitionRequest;
\r
4919 (function (DefinitionRequest) {
\r
4920 DefinitionRequest.method = 'textDocument/definition';
\r
4921 DefinitionRequest.type = new messages_1.ProtocolRequestType(DefinitionRequest.method);
\r
4922 /** @deprecated Use DefinitionRequest.type */
\r
4923 DefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4924 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
\r
4926 * A request to resolve project-wide references for the symbol denoted
\r
4927 * by the given text document position. The request's parameter is of
\r
4928 * type [ReferenceParams](#ReferenceParams) the response is of type
\r
4929 * [Location[]](#Location) or a Thenable that resolves to such.
\r
4931 var ReferencesRequest;
\r
4932 (function (ReferencesRequest) {
\r
4933 ReferencesRequest.method = 'textDocument/references';
\r
4934 ReferencesRequest.type = new messages_1.ProtocolRequestType(ReferencesRequest.method);
\r
4935 /** @deprecated Use ReferencesRequest.type */
\r
4936 ReferencesRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4937 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
\r
4939 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
\r
4940 * text document position. The request's parameter is of type [TextDocumentPosition]
\r
4941 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
\r
4942 * (#DocumentHighlight) or a Thenable that resolves to such.
\r
4944 var DocumentHighlightRequest;
\r
4945 (function (DocumentHighlightRequest) {
\r
4946 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
\r
4947 DocumentHighlightRequest.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest.method);
\r
4948 /** @deprecated Use DocumentHighlightRequest.type */
\r
4949 DocumentHighlightRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4950 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
\r
4952 * A request to list all symbols found in a given text document. The request's
\r
4953 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
\r
4954 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
\r
4955 * that resolves to such.
\r
4957 var DocumentSymbolRequest;
\r
4958 (function (DocumentSymbolRequest) {
\r
4959 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
\r
4960 DocumentSymbolRequest.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest.method);
\r
4961 /** @deprecated Use DocumentSymbolRequest.type */
\r
4962 DocumentSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4963 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
\r
4965 * A request to provide commands for the given text document and range.
\r
4967 var CodeActionRequest;
\r
4968 (function (CodeActionRequest) {
\r
4969 CodeActionRequest.method = 'textDocument/codeAction';
\r
4970 CodeActionRequest.type = new messages_1.ProtocolRequestType(CodeActionRequest.method);
\r
4971 /** @deprecated Use CodeActionRequest.type */
\r
4972 CodeActionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4973 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
\r
4975 * A request to list project-wide symbols matching the query string given
\r
4976 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
\r
4977 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
\r
4978 * resolves to such.
\r
4980 var WorkspaceSymbolRequest;
\r
4981 (function (WorkspaceSymbolRequest) {
\r
4982 WorkspaceSymbolRequest.method = 'workspace/symbol';
\r
4983 WorkspaceSymbolRequest.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest.method);
\r
4984 /** @deprecated Use WorkspaceSymbolRequest.type */
\r
4985 WorkspaceSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4986 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
\r
4988 * A request to provide code lens for the given text document.
\r
4990 var CodeLensRequest;
\r
4991 (function (CodeLensRequest) {
\r
4992 CodeLensRequest.type = new messages_1.ProtocolRequestType('textDocument/codeLens');
\r
4993 /** @deprecated Use CodeLensRequest.type */
\r
4994 CodeLensRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4995 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
\r
4997 * A request to resolve a command for a given code lens.
\r
4999 var CodeLensResolveRequest;
\r
5000 (function (CodeLensResolveRequest) {
\r
5001 CodeLensResolveRequest.type = new messages_1.ProtocolRequestType('codeLens/resolve');
\r
5002 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
\r
5004 * A request to provide document links
\r
5006 var DocumentLinkRequest;
\r
5007 (function (DocumentLinkRequest) {
\r
5008 DocumentLinkRequest.method = 'textDocument/documentLink';
\r
5009 DocumentLinkRequest.type = new messages_1.ProtocolRequestType(DocumentLinkRequest.method);
\r
5010 /** @deprecated Use DocumentLinkRequest.type */
\r
5011 DocumentLinkRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5012 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
\r
5014 * Request to resolve additional information for a given document link. The request's
\r
5015 * parameter is of type [DocumentLink](#DocumentLink) the response
\r
5016 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
\r
5018 var DocumentLinkResolveRequest;
\r
5019 (function (DocumentLinkResolveRequest) {
\r
5020 DocumentLinkResolveRequest.type = new messages_1.ProtocolRequestType('documentLink/resolve');
\r
5021 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
\r
5023 * A request to to format a whole document.
\r
5025 var DocumentFormattingRequest;
\r
5026 (function (DocumentFormattingRequest) {
\r
5027 DocumentFormattingRequest.method = 'textDocument/formatting';
\r
5028 DocumentFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest.method);
\r
5029 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
\r
5031 * A request to to format a range in a document.
\r
5033 var DocumentRangeFormattingRequest;
\r
5034 (function (DocumentRangeFormattingRequest) {
\r
5035 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
\r
5036 DocumentRangeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest.method);
\r
5037 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
\r
5039 * A request to format a document on type.
\r
5041 var DocumentOnTypeFormattingRequest;
\r
5042 (function (DocumentOnTypeFormattingRequest) {
\r
5043 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
\r
5044 DocumentOnTypeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest.method);
\r
5045 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
\r
5047 * A request to rename a symbol.
\r
5049 var RenameRequest;
\r
5050 (function (RenameRequest) {
\r
5051 RenameRequest.method = 'textDocument/rename';
\r
5052 RenameRequest.type = new messages_1.ProtocolRequestType(RenameRequest.method);
\r
5053 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
\r
5055 * A request to test and perform the setup necessary for a rename.
\r
5057 var PrepareRenameRequest;
\r
5058 (function (PrepareRenameRequest) {
\r
5059 PrepareRenameRequest.method = 'textDocument/prepareRename';
\r
5060 PrepareRenameRequest.type = new messages_1.ProtocolRequestType(PrepareRenameRequest.method);
\r
5061 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
\r
5063 * A request send from the client to the server to execute a command. The request might return
\r
5064 * a workspace edit which the client will apply to the workspace.
\r
5066 var ExecuteCommandRequest;
\r
5067 (function (ExecuteCommandRequest) {
\r
5068 ExecuteCommandRequest.type = new messages_1.ProtocolRequestType('workspace/executeCommand');
\r
5069 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
\r
5071 * A request sent from the server to the client to modified certain resources.
\r
5073 var ApplyWorkspaceEditRequest;
\r
5074 (function (ApplyWorkspaceEditRequest) {
\r
5075 ApplyWorkspaceEditRequest.type = new messages_1.ProtocolRequestType('workspace/applyEdit');
\r
5076 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
\r
5081 /***/ (function(module, exports, __webpack_require__) {
5084 /* --------------------------------------------------------------------------------------------
\r
5085 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5086 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5087 * ------------------------------------------------------------------------------------------ */
\r
5089 Object.defineProperty(exports, "__esModule", { value: true });
\r
5090 function boolean(value) {
\r
5091 return value === true || value === false;
\r
5093 exports.boolean = boolean;
\r
5094 function string(value) {
\r
5095 return typeof value === 'string' || value instanceof String;
\r
5097 exports.string = string;
\r
5098 function number(value) {
\r
5099 return typeof value === 'number' || value instanceof Number;
\r
5101 exports.number = number;
\r
5102 function error(value) {
\r
5103 return value instanceof Error;
\r
5105 exports.error = error;
\r
5106 function func(value) {
\r
5107 return typeof value === 'function';
\r
5109 exports.func = func;
\r
5110 function array(value) {
\r
5111 return Array.isArray(value);
\r
5113 exports.array = array;
\r
5114 function stringArray(value) {
\r
5115 return array(value) && value.every(elem => string(elem));
\r
5117 exports.stringArray = stringArray;
\r
5118 function typedArray(value, check) {
\r
5119 return Array.isArray(value) && value.every(check);
\r
5121 exports.typedArray = typedArray;
\r
5122 function objectLiteral(value) {
\r
5123 // Strictly speaking class instances pass this check as well. Since the LSP
\r
5124 // doesn't use classes we ignore this for now. If we do we need to add something
\r
5125 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
5126 return value !== null && typeof value === 'object';
\r
5128 exports.objectLiteral = objectLiteral;
\r
5133 /***/ (function(module, exports, __webpack_require__) {
5136 /* --------------------------------------------------------------------------------------------
\r
5137 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5138 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5139 * ------------------------------------------------------------------------------------------ */
\r
5141 Object.defineProperty(exports, "__esModule", { value: true });
\r
5142 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5143 class ProtocolRequestType0 extends vscode_jsonrpc_1.RequestType0 {
\r
5144 constructor(method) {
\r
5148 exports.ProtocolRequestType0 = ProtocolRequestType0;
\r
5149 class ProtocolRequestType extends vscode_jsonrpc_1.RequestType {
\r
5150 constructor(method) {
\r
5154 exports.ProtocolRequestType = ProtocolRequestType;
\r
5155 class ProtocolNotificationType extends vscode_jsonrpc_1.NotificationType {
\r
5156 constructor(method) {
\r
5160 exports.ProtocolNotificationType = ProtocolNotificationType;
\r
5161 class ProtocolNotificationType0 extends vscode_jsonrpc_1.NotificationType0 {
\r
5162 constructor(method) {
\r
5166 exports.ProtocolNotificationType0 = ProtocolNotificationType0;
\r
5171 /***/ (function(module, exports, __webpack_require__) {
5174 /* --------------------------------------------------------------------------------------------
\r
5175 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5176 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5177 * ------------------------------------------------------------------------------------------ */
\r
5179 Object.defineProperty(exports, "__esModule", { value: true });
\r
5180 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5181 const messages_1 = __webpack_require__(21);
\r
5182 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5183 let __noDynamicImport;
\r
5185 * A request to resolve the implementation locations of a symbol at a given text
\r
5186 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5187 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
5188 * Thenable that resolves to such.
\r
5190 var ImplementationRequest;
\r
5191 (function (ImplementationRequest) {
\r
5192 ImplementationRequest.method = 'textDocument/implementation';
\r
5193 ImplementationRequest.type = new messages_1.ProtocolRequestType(ImplementationRequest.method);
\r
5194 /** @deprecated Use ImplementationRequest.type */
\r
5195 ImplementationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5196 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
\r
5201 /***/ (function(module, exports, __webpack_require__) {
5204 /* --------------------------------------------------------------------------------------------
\r
5205 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5206 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5207 * ------------------------------------------------------------------------------------------ */
\r
5209 Object.defineProperty(exports, "__esModule", { value: true });
\r
5210 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5211 const messages_1 = __webpack_require__(21);
\r
5212 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5213 let __noDynamicImport;
\r
5215 * A request to resolve the type definition locations of a symbol at a given text
\r
5216 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5217 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
5218 * Thenable that resolves to such.
\r
5220 var TypeDefinitionRequest;
\r
5221 (function (TypeDefinitionRequest) {
\r
5222 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
\r
5223 TypeDefinitionRequest.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest.method);
\r
5224 /** @deprecated Use TypeDefinitionRequest.type */
\r
5225 TypeDefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5226 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
\r
5231 /***/ (function(module, exports, __webpack_require__) {
5234 /* --------------------------------------------------------------------------------------------
\r
5235 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5236 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5237 * ------------------------------------------------------------------------------------------ */
\r
5239 Object.defineProperty(exports, "__esModule", { value: true });
\r
5240 const messages_1 = __webpack_require__(21);
\r
5242 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
\r
5244 var WorkspaceFoldersRequest;
\r
5245 (function (WorkspaceFoldersRequest) {
\r
5246 WorkspaceFoldersRequest.type = new messages_1.ProtocolRequestType0('workspace/workspaceFolders');
\r
5247 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
\r
5249 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
\r
5250 * folder configuration changes.
\r
5252 var DidChangeWorkspaceFoldersNotification;
\r
5253 (function (DidChangeWorkspaceFoldersNotification) {
\r
5254 DidChangeWorkspaceFoldersNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWorkspaceFolders');
\r
5255 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
\r
5260 /***/ (function(module, exports, __webpack_require__) {
5263 /* --------------------------------------------------------------------------------------------
\r
5264 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5265 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5266 * ------------------------------------------------------------------------------------------ */
\r
5268 Object.defineProperty(exports, "__esModule", { value: true });
\r
5269 const messages_1 = __webpack_require__(21);
\r
5271 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
\r
5272 * configuration setting.
\r
5274 * This pull model replaces the old push model were the client signaled configuration change via an
\r
5275 * event. If the server still needs to react to configuration changes (since the server caches the
\r
5276 * result of `workspace/configuration` requests) the server should register for an empty configuration
\r
5277 * change event and empty the cache if such an event is received.
\r
5279 var ConfigurationRequest;
\r
5280 (function (ConfigurationRequest) {
\r
5281 ConfigurationRequest.type = new messages_1.ProtocolRequestType('workspace/configuration');
\r
5282 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
\r
5287 /***/ (function(module, exports, __webpack_require__) {
5290 /* --------------------------------------------------------------------------------------------
\r
5291 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5292 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5293 * ------------------------------------------------------------------------------------------ */
\r
5295 Object.defineProperty(exports, "__esModule", { value: true });
\r
5296 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5297 const messages_1 = __webpack_require__(21);
\r
5299 * A request to list all color symbols found in a given text document. The request's
\r
5300 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
\r
5301 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
5302 * that resolves to such.
\r
5304 var DocumentColorRequest;
\r
5305 (function (DocumentColorRequest) {
\r
5306 DocumentColorRequest.method = 'textDocument/documentColor';
\r
5307 DocumentColorRequest.type = new messages_1.ProtocolRequestType(DocumentColorRequest.method);
\r
5308 /** @deprecated Use DocumentColorRequest.type */
\r
5309 DocumentColorRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5310 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
\r
5312 * A request to list all presentation for a color. The request's
\r
5313 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
\r
5314 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
5315 * that resolves to such.
\r
5317 var ColorPresentationRequest;
\r
5318 (function (ColorPresentationRequest) {
\r
5319 ColorPresentationRequest.type = new messages_1.ProtocolRequestType('textDocument/colorPresentation');
\r
5320 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
\r
5325 /***/ (function(module, exports, __webpack_require__) {
5329 /*---------------------------------------------------------------------------------------------
\r
5330 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5331 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5332 *--------------------------------------------------------------------------------------------*/
\r
5333 Object.defineProperty(exports, "__esModule", { value: true });
\r
5334 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5335 const messages_1 = __webpack_require__(21);
\r
5337 * Enum of known range kinds
\r
5339 var FoldingRangeKind;
\r
5340 (function (FoldingRangeKind) {
\r
5342 * Folding range for a comment
\r
5344 FoldingRangeKind["Comment"] = "comment";
\r
5346 * Folding range for a imports or includes
\r
5348 FoldingRangeKind["Imports"] = "imports";
\r
5350 * Folding range for a region (e.g. `#region`)
\r
5352 FoldingRangeKind["Region"] = "region";
\r
5353 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
\r
5355 * A request to provide folding ranges in a document. The request's
\r
5356 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
\r
5357 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
\r
5358 * that resolves to such.
\r
5360 var FoldingRangeRequest;
\r
5361 (function (FoldingRangeRequest) {
\r
5362 FoldingRangeRequest.method = 'textDocument/foldingRange';
\r
5363 FoldingRangeRequest.type = new messages_1.ProtocolRequestType(FoldingRangeRequest.method);
\r
5364 /** @deprecated Use FoldingRangeRequest.type */
\r
5365 FoldingRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5366 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
\r
5371 /***/ (function(module, exports, __webpack_require__) {
5374 /* --------------------------------------------------------------------------------------------
\r
5375 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5376 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5377 * ------------------------------------------------------------------------------------------ */
\r
5379 Object.defineProperty(exports, "__esModule", { value: true });
\r
5380 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5381 const messages_1 = __webpack_require__(21);
\r
5382 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5383 let __noDynamicImport;
\r
5385 * A request to resolve the type definition locations of a symbol at a given text
\r
5386 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5387 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
\r
5388 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
\r
5391 var DeclarationRequest;
\r
5392 (function (DeclarationRequest) {
\r
5393 DeclarationRequest.method = 'textDocument/declaration';
\r
5394 DeclarationRequest.type = new messages_1.ProtocolRequestType(DeclarationRequest.method);
\r
5395 /** @deprecated Use DeclarationRequest.type */
\r
5396 DeclarationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5397 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
\r
5402 /***/ (function(module, exports, __webpack_require__) {
5406 /*---------------------------------------------------------------------------------------------
\r
5407 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5408 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5409 *--------------------------------------------------------------------------------------------*/
\r
5410 Object.defineProperty(exports, "__esModule", { value: true });
\r
5411 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5412 const messages_1 = __webpack_require__(21);
\r
5414 * A request to provide selection ranges in a document. The request's
\r
5415 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
\r
5416 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
\r
5417 * that resolves to such.
\r
5419 var SelectionRangeRequest;
\r
5420 (function (SelectionRangeRequest) {
\r
5421 SelectionRangeRequest.method = 'textDocument/selectionRange';
\r
5422 SelectionRangeRequest.type = new messages_1.ProtocolRequestType(SelectionRangeRequest.method);
\r
5423 /** @deprecated Use SelectionRangeRequest.type */
\r
5424 SelectionRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5425 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
\r
5430 /***/ (function(module, exports, __webpack_require__) {
5433 /* --------------------------------------------------------------------------------------------
\r
5434 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5435 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5436 * ------------------------------------------------------------------------------------------ */
\r
5438 Object.defineProperty(exports, "__esModule", { value: true });
\r
5439 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5440 const messages_1 = __webpack_require__(21);
\r
5441 var WorkDoneProgress;
\r
5442 (function (WorkDoneProgress) {
\r
5443 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
\r
5444 })(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
\r
5446 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
\r
5447 * reporting from the server.
\r
5449 var WorkDoneProgressCreateRequest;
\r
5450 (function (WorkDoneProgressCreateRequest) {
\r
5451 WorkDoneProgressCreateRequest.type = new messages_1.ProtocolRequestType('window/workDoneProgress/create');
\r
5452 })(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
\r
5454 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
\r
5455 * initiated on the server side.
\r
5457 var WorkDoneProgressCancelNotification;
\r
5458 (function (WorkDoneProgressCancelNotification) {
\r
5459 WorkDoneProgressCancelNotification.type = new messages_1.ProtocolNotificationType('window/workDoneProgress/cancel');
\r
5460 })(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
\r
5465 /***/ (function(module, exports, __webpack_require__) {
5468 /* --------------------------------------------------------------------------------------------
\r
5469 * Copyright (c) TypeFox and others. All rights reserved.
\r
5470 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5471 * ------------------------------------------------------------------------------------------ */
\r
5473 Object.defineProperty(exports, "__esModule", { value: true });
\r
5474 const messages_1 = __webpack_require__(21);
\r
5476 * A request to result a `CallHierarchyItem` in a document at a given position.
\r
5477 * Can be used as an input to a incoming or outgoing call hierarchy.
\r
5479 * @since 3.16.0 - Proposed state
\r
5481 var CallHierarchyPrepareRequest;
\r
5482 (function (CallHierarchyPrepareRequest) {
\r
5483 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
\r
5484 CallHierarchyPrepareRequest.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest.method);
\r
5485 })(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
\r
5487 * A request to resolve the incoming calls for a given `CallHierarchyItem`.
\r
5489 * @since 3.16.0 - Proposed state
\r
5491 var CallHierarchyIncomingCallsRequest;
\r
5492 (function (CallHierarchyIncomingCallsRequest) {
\r
5493 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
\r
5494 CallHierarchyIncomingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest.method);
\r
5495 })(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
\r
5497 * A request to resolve the outgoing calls for a given `CallHierarchyItem`.
\r
5499 * @since 3.16.0 - Proposed state
\r
5501 var CallHierarchyOutgoingCallsRequest;
\r
5502 (function (CallHierarchyOutgoingCallsRequest) {
\r
5503 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
\r
5504 CallHierarchyOutgoingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest.method);
\r
5505 })(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
\r
5510 /***/ (function(module, exports, __webpack_require__) {
5513 /* --------------------------------------------------------------------------------------------
\r
5514 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5515 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5516 * ------------------------------------------------------------------------------------------ */
\r
5518 Object.defineProperty(exports, "__esModule", { value: true });
\r
5519 const messages_1 = __webpack_require__(21);
\r
5521 * A set of predefined token types. This set is not fixed
\r
5522 * an clients can specify additional token types via the
\r
5523 * corresponding client capabilities.
\r
5525 * @since 3.16.0 - Proposed state
\r
5527 var SemanticTokenTypes;
\r
5528 (function (SemanticTokenTypes) {
\r
5529 SemanticTokenTypes["comment"] = "comment";
\r
5530 SemanticTokenTypes["keyword"] = "keyword";
\r
5531 SemanticTokenTypes["string"] = "string";
\r
5532 SemanticTokenTypes["number"] = "number";
\r
5533 SemanticTokenTypes["regexp"] = "regexp";
\r
5534 SemanticTokenTypes["operator"] = "operator";
\r
5535 SemanticTokenTypes["namespace"] = "namespace";
\r
5536 SemanticTokenTypes["type"] = "type";
\r
5537 SemanticTokenTypes["struct"] = "struct";
\r
5538 SemanticTokenTypes["class"] = "class";
\r
5539 SemanticTokenTypes["interface"] = "interface";
\r
5540 SemanticTokenTypes["enum"] = "enum";
\r
5541 SemanticTokenTypes["typeParameter"] = "typeParameter";
\r
5542 SemanticTokenTypes["function"] = "function";
\r
5543 SemanticTokenTypes["member"] = "member";
\r
5544 SemanticTokenTypes["property"] = "property";
\r
5545 SemanticTokenTypes["macro"] = "macro";
\r
5546 SemanticTokenTypes["variable"] = "variable";
\r
5547 SemanticTokenTypes["parameter"] = "parameter";
\r
5548 SemanticTokenTypes["label"] = "label";
\r
5549 })(SemanticTokenTypes = exports.SemanticTokenTypes || (exports.SemanticTokenTypes = {}));
\r
5551 * A set of predefined token modifiers. This set is not fixed
\r
5552 * an clients can specify additional token types via the
\r
5553 * corresponding client capabilities.
\r
5555 * @since 3.16.0 - Proposed state
\r
5557 var SemanticTokenModifiers;
\r
5558 (function (SemanticTokenModifiers) {
\r
5559 SemanticTokenModifiers["documentation"] = "documentation";
\r
5560 SemanticTokenModifiers["declaration"] = "declaration";
\r
5561 SemanticTokenModifiers["definition"] = "definition";
\r
5562 SemanticTokenModifiers["reference"] = "reference";
\r
5563 SemanticTokenModifiers["static"] = "static";
\r
5564 SemanticTokenModifiers["abstract"] = "abstract";
\r
5565 SemanticTokenModifiers["deprecated"] = "deprecated";
\r
5566 SemanticTokenModifiers["async"] = "async";
\r
5567 SemanticTokenModifiers["volatile"] = "volatile";
\r
5568 SemanticTokenModifiers["readonly"] = "readonly";
\r
5569 })(SemanticTokenModifiers = exports.SemanticTokenModifiers || (exports.SemanticTokenModifiers = {}));
\r
5571 * @since 3.16.0 - Proposed state
\r
5573 var SemanticTokens;
\r
5574 (function (SemanticTokens) {
\r
5575 function is(value) {
\r
5576 const candidate = value;
\r
5577 return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
\r
5578 Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
\r
5580 SemanticTokens.is = is;
\r
5581 })(SemanticTokens = exports.SemanticTokens || (exports.SemanticTokens = {}));
\r
5583 * @since 3.16.0 - Proposed state
\r
5585 var SemanticTokensRequest;
\r
5586 (function (SemanticTokensRequest) {
\r
5587 SemanticTokensRequest.method = 'textDocument/semanticTokens';
\r
5588 SemanticTokensRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRequest.method);
\r
5589 })(SemanticTokensRequest = exports.SemanticTokensRequest || (exports.SemanticTokensRequest = {}));
\r
5591 * @since 3.16.0 - Proposed state
\r
5593 var SemanticTokensEditsRequest;
\r
5594 (function (SemanticTokensEditsRequest) {
\r
5595 SemanticTokensEditsRequest.method = 'textDocument/semanticTokens/edits';
\r
5596 SemanticTokensEditsRequest.type = new messages_1.ProtocolRequestType(SemanticTokensEditsRequest.method);
\r
5597 })(SemanticTokensEditsRequest = exports.SemanticTokensEditsRequest || (exports.SemanticTokensEditsRequest = {}));
\r
5599 * @since 3.16.0 - Proposed state
\r
5601 var SemanticTokensRangeRequest;
\r
5602 (function (SemanticTokensRangeRequest) {
\r
5603 SemanticTokensRangeRequest.method = 'textDocument/semanticTokens/range';
\r
5604 SemanticTokensRangeRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest.method);
\r
5605 })(SemanticTokensRangeRequest = exports.SemanticTokensRangeRequest || (exports.SemanticTokensRangeRequest = {}));
\r
5610 /***/ (function(module, exports, __webpack_require__) {
5614 var __importDefault = (this && this.__importDefault) || function (mod) {
5615 return (mod && mod.__esModule) ? mod : { "default": mod };
5617 Object.defineProperty(exports, "__esModule", { value: true });
5618 const path_1 = __importDefault(__webpack_require__(3));
5619 const fs_1 = __importDefault(__webpack_require__(2));
5620 const which_1 = __importDefault(__webpack_require__(34));
5621 function exists(file) {
5622 return fs_1.default.existsSync(file);
5624 async function findEslint(rootPath) {
5625 const platform = process.platform;
5626 if (platform === 'win32' &&
5627 (exists(path_1.default.join(rootPath, 'node_modules', '.bin', 'eslint.cmd')))) {
5628 return path_1.default.join('.', 'node_modules', '.bin', 'eslint.cmd');
5630 else if ((platform === 'linux' || platform === 'darwin') &&
5631 (exists(path_1.default.join(rootPath, 'node_modules', '.bin', 'eslint')))) {
5632 return path_1.default.join('.', 'node_modules', '.bin', 'eslint');
5634 else if (exists(path_1.default.join(rootPath, '.vscode', 'pnpify', 'eslint', 'bin', 'eslint.js'))) {
5635 return path_1.default.join('.', '.vscode', 'pnpify', 'eslint', 'bin', 'eslint.js');
5639 return which_1.default.sync('eslint');
5646 exports.findEslint = findEslint;
5651 /***/ (function(module, exports, __webpack_require__) {
5653 const isWindows = process.platform === 'win32' ||
5654 process.env.OSTYPE === 'cygwin' ||
5655 process.env.OSTYPE === 'msys'
5657 const path = __webpack_require__(3)
5658 const COLON = isWindows ? ';' : ':'
5659 const isexe = __webpack_require__(35)
5661 const getNotFoundError = (cmd) =>
5662 Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
5664 const getPathInfo = (cmd, opt) => {
5665 const colon = opt.colon || COLON
5667 // If it has a slash, then we don't bother searching the pathenv.
5668 // just check the file itself, and that's it.
5669 const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
5672 // windows always checks the cwd first
5673 ...(isWindows ? [process.cwd()] : []),
5674 ...(opt.path || process.env.PATH ||
5675 /* istanbul ignore next: very unusual */ '').split(colon),
5678 const pathExtExe = isWindows
5679 ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
5681 const pathExt = isWindows ? pathExtExe.split(colon) : ['']
5684 if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
5695 const which = (cmd, opt, cb) => {
5696 if (typeof opt === 'function') {
5703 const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
5706 const step = i => new Promise((resolve, reject) => {
5707 if (i === pathEnv.length)
5708 return opt.all && found.length ? resolve(found)
5709 : reject(getNotFoundError(cmd))
5711 const ppRaw = pathEnv[i]
5712 const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
5714 const pCmd = path.join(pathPart, cmd)
5715 const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
5718 resolve(subStep(p, i, 0))
5721 const subStep = (p, i, ii) => new Promise((resolve, reject) => {
5722 if (ii === pathExt.length)
5723 return resolve(step(i + 1))
5724 const ext = pathExt[ii]
5725 isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
5730 return resolve(p + ext)
5732 return resolve(subStep(p, i, ii + 1))
5736 return cb ? step(0).then(res => cb(null, res), cb) : step(0)
5739 const whichSync = (cmd, opt) => {
5742 const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
5745 for (let i = 0; i < pathEnv.length; i ++) {
5746 const ppRaw = pathEnv[i]
5747 const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
5749 const pCmd = path.join(pathPart, cmd)
5750 const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
5753 for (let j = 0; j < pathExt.length; j ++) {
5754 const cur = p + pathExt[j]
5756 const is = isexe.sync(cur, { pathExt: pathExtExe })
5767 if (opt.all && found.length)
5773 throw getNotFoundError(cmd)
5776 module.exports = which
5777 which.sync = whichSync
5782 /***/ (function(module, exports, __webpack_require__) {
5784 var fs = __webpack_require__(2)
5786 if (process.platform === 'win32' || global.TESTING_WINDOWS) {
5787 core = __webpack_require__(36)
5789 core = __webpack_require__(37)
5792 module.exports = isexe
5795 function isexe (path, options, cb) {
5796 if (typeof options === 'function') {
5802 if (typeof Promise !== 'function') {
5803 throw new TypeError('callback not provided')
5806 return new Promise(function (resolve, reject) {
5807 isexe(path, options || {}, function (er, is) {
5817 core(path, options || {}, function (er, is) {
5818 // ignore EACCES because that just means we aren't allowed to run it
5820 if (er.code === 'EACCES' || options && options.ignoreErrors) {
5829 function sync (path, options) {
5830 // my kingdom for a filtered catch
5832 return core.sync(path, options || {})
5834 if (options && options.ignoreErrors || er.code === 'EACCES') {
5845 /***/ (function(module, exports, __webpack_require__) {
5847 module.exports = isexe
5850 var fs = __webpack_require__(2)
5852 function checkPathExt (path, options) {
5853 var pathext = options.pathExt !== undefined ?
5854 options.pathExt : process.env.PATHEXT
5860 pathext = pathext.split(';')
5861 if (pathext.indexOf('') !== -1) {
5864 for (var i = 0; i < pathext.length; i++) {
5865 var p = pathext[i].toLowerCase()
5866 if (p && path.substr(-p.length).toLowerCase() === p) {
5873 function checkStat (stat, path, options) {
5874 if (!stat.isSymbolicLink() && !stat.isFile()) {
5877 return checkPathExt(path, options)
5880 function isexe (path, options, cb) {
5881 fs.stat(path, function (er, stat) {
5882 cb(er, er ? false : checkStat(stat, path, options))
5886 function sync (path, options) {
5887 return checkStat(fs.statSync(path), path, options)
5893 /***/ (function(module, exports, __webpack_require__) {
5895 module.exports = isexe
5898 var fs = __webpack_require__(2)
5900 function isexe (path, options, cb) {
5901 fs.stat(path, function (er, stat) {
5902 cb(er, er ? false : checkStat(stat, options))
5906 function sync (path, options) {
5907 return checkStat(fs.statSync(path), options)
5910 function checkStat (stat, options) {
5911 return stat.isFile() && checkMode(stat, options)
5914 function checkMode (stat, options) {
5919 var myUid = options.uid !== undefined ?
5920 options.uid : process.getuid && process.getuid()
5921 var myGid = options.gid !== undefined ?
5922 options.gid : process.getgid && process.getgid()
5924 var u = parseInt('100', 8)
5925 var g = parseInt('010', 8)
5926 var o = parseInt('001', 8)
5929 var ret = (mod & o) ||
5930 (mod & g) && gid === myGid ||
5931 (mod & u) && uid === myUid ||
5932 (mod & ug) && myUid === 0