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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
94 return new (P || (P = Promise))(function (resolve, reject) {
95 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
96 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
97 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
98 step((generator = generator.apply(thisArg, _arguments || [])).next());
101 Object.defineProperty(exports, "__esModule", { value: true });
102 const coc_nvim_1 = __webpack_require__(1);
103 const customData_1 = __webpack_require__(2);
104 const vscode_languageserver_protocol_1 = __webpack_require__(4);
105 const tagClosing_1 = __webpack_require__(31);
107 (function (TagCloseRequest) {
108 TagCloseRequest.type = new vscode_languageserver_protocol_1.RequestType('html/tag');
109 })(TagCloseRequest || (TagCloseRequest = {}));
110 function activate(context) {
111 return __awaiter(this, void 0, void 0, function* () {
112 let { subscriptions } = context;
113 const config = coc_nvim_1.workspace.getConfiguration().get('html', {});
114 const enable = config.enable;
115 if (enable === false)
117 const file = context.asAbsolutePath('lib/server.js');
118 const selector = config.filetypes || ['html', 'handlebars', 'htmldjango'];
119 const embeddedLanguages = { css: true, javascript: true };
120 let serverOptions = {
122 args: ['--node-ipc'],
123 transport: coc_nvim_1.TransportKind.ipc,
125 cwd: coc_nvim_1.workspace.root,
126 execArgv: config.execArgv || []
130 ...customData_1.getCustomDataPathsInAllWorkspaces(),
131 ...customData_1.getCustomDataPathsFromAllExtensions()
133 let clientOptions = {
134 documentSelector: selector,
136 configurationSection: ['html', 'css', 'javascript']
138 outputChannelName: 'html',
139 initializationOptions: {
144 let client = new coc_nvim_1.LanguageClient('html', 'HTML language server', serverOptions, clientOptions);
145 client.onReady().then(() => {
146 selector.forEach(selector => {
147 context.subscriptions.push(coc_nvim_1.languages.registerSelectionRangeProvider(selector, {
148 provideSelectionRanges(document, positions) {
149 return __awaiter(this, void 0, void 0, function* () {
150 const textDocument = { uri: document.uri };
151 return yield Promise.resolve(client.sendRequest('$/textDocument/selectionRanges', { textDocument, positions }));
156 const tagRequestor = (document, position) => {
163 return client.sendRequest(TagCloseRequest.type, param);
165 context.subscriptions.push(tagClosing_1.activateTagClosing(tagRequestor, selector, 'html.autoClosingTags'));
169 subscriptions.push(coc_nvim_1.services.registLanguageClient(client));
172 exports.activate = activate;
177 /***/ (function(module, exports) {
179 module.exports = require("coc.nvim");
183 /***/ (function(module, exports, __webpack_require__) {
187 /*---------------------------------------------------------------------------------------------
188 * Copyright (c) Microsoft Corporation. All rights reserved.
189 * Licensed under the MIT License. See License.txt in the project root for license information.
190 *--------------------------------------------------------------------------------------------*/
191 var __importStar = (this && this.__importStar) || function (mod) {
192 if (mod && mod.__esModule) return mod;
194 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
195 result["default"] = mod;
198 Object.defineProperty(exports, "__esModule", { value: true });
199 const path = __importStar(__webpack_require__(3));
200 const coc_nvim_1 = __webpack_require__(1);
201 function getCustomDataPathsInAllWorkspaces() {
202 const dataPaths = [];
203 const workspaceFolders = coc_nvim_1.workspace.workspaceFolders;
204 if (!workspaceFolders) {
207 workspaceFolders.forEach(wf => {
208 const allHtmlConfig = coc_nvim_1.workspace.getConfiguration(undefined, wf.uri);
209 const wfHtmlConfig = allHtmlConfig.inspect('html');
211 wfHtmlConfig.workspaceFolderValue &&
212 wfHtmlConfig.workspaceFolderValue.experimental &&
213 wfHtmlConfig.workspaceFolderValue.experimental.customData) {
214 const customData = wfHtmlConfig.workspaceFolderValue.experimental.customData;
215 if (Array.isArray(customData)) {
216 customData.forEach(t => {
217 if (typeof t === 'string') {
218 dataPaths.push(path.resolve(coc_nvim_1.Uri.parse(wf.uri).fsPath, t));
226 exports.getCustomDataPathsInAllWorkspaces = getCustomDataPathsInAllWorkspaces;
227 function getCustomDataPathsFromAllExtensions() {
228 const dataPaths = [];
229 for (const extension of coc_nvim_1.extensions.all) {
230 const contributes = extension.packageJSON && extension.packageJSON.contributes;
233 contributes.html.experimental.customData &&
234 Array.isArray(contributes.html.experimental.customData)) {
235 const relativePaths = contributes.html.experimental.customData;
236 relativePaths.forEach(rp => {
237 dataPaths.push(path.resolve(extension.extensionPath, rp));
243 exports.getCustomDataPathsFromAllExtensions = getCustomDataPathsFromAllExtensions;
248 /***/ (function(module, exports) {
250 module.exports = require("path");
254 /***/ (function(module, exports, __webpack_require__) {
257 /* --------------------------------------------------------------------------------------------
258 * Copyright (c) Microsoft Corporation. All rights reserved.
259 * Licensed under the MIT License. See License.txt in the project root for license information.
260 * ------------------------------------------------------------------------------------------ */
262 function __export(m) {
263 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
265 Object.defineProperty(exports, "__esModule", { value: true });
266 const vscode_jsonrpc_1 = __webpack_require__(5);
267 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
268 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
269 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
270 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
271 exports.Disposable = vscode_jsonrpc_1.Disposable;
272 exports.Event = vscode_jsonrpc_1.Event;
273 exports.Emitter = vscode_jsonrpc_1.Emitter;
274 exports.Trace = vscode_jsonrpc_1.Trace;
275 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
276 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
277 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
278 exports.RequestType = vscode_jsonrpc_1.RequestType;
279 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
280 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
281 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
282 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
283 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
284 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
285 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
286 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
287 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
288 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
289 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
290 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
291 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
292 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
293 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
294 __export(__webpack_require__(18));
295 __export(__webpack_require__(19));
296 const callHierarchy = __webpack_require__(29);
297 const progress = __webpack_require__(30);
299 (function (Proposed) {
300 let CallHierarchyRequest;
301 (function (CallHierarchyRequest) {
302 CallHierarchyRequest.type = callHierarchy.CallHierarchyRequest.type;
303 })(CallHierarchyRequest = Proposed.CallHierarchyRequest || (Proposed.CallHierarchyRequest = {}));
304 let CallHierarchyDirection;
305 (function (CallHierarchyDirection) {
306 CallHierarchyDirection.CallsFrom = callHierarchy.CallHierarchyDirection.CallsFrom;
307 CallHierarchyDirection.CallsTo = callHierarchy.CallHierarchyDirection.CallsTo;
308 })(CallHierarchyDirection = Proposed.CallHierarchyDirection || (Proposed.CallHierarchyDirection = {}));
309 let ProgressStartNotification;
310 (function (ProgressStartNotification) {
311 ProgressStartNotification.type = progress.ProgressStartNotification.type;
312 })(ProgressStartNotification = Proposed.ProgressStartNotification || (Proposed.ProgressStartNotification = {}));
313 let ProgressReportNotification;
314 (function (ProgressReportNotification) {
315 ProgressReportNotification.type = progress.ProgressReportNotification.type;
316 })(ProgressReportNotification = Proposed.ProgressReportNotification || (Proposed.ProgressReportNotification = {}));
317 let ProgressDoneNotification;
318 (function (ProgressDoneNotification) {
319 ProgressDoneNotification.type = progress.ProgressDoneNotification.type;
320 })(ProgressDoneNotification = Proposed.ProgressDoneNotification || (Proposed.ProgressDoneNotification = {}));
321 let ProgressCancelNotification;
322 (function (ProgressCancelNotification) {
323 ProgressCancelNotification.type = progress.ProgressCancelNotification.type;
324 })(ProgressCancelNotification = Proposed.ProgressCancelNotification || (Proposed.ProgressCancelNotification = {}));
325 })(Proposed = exports.Proposed || (exports.Proposed = {}));
326 function createProtocolConnection(reader, writer, logger, strategy) {
327 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
329 exports.createProtocolConnection = createProtocolConnection;
334 /***/ (function(module, exports, __webpack_require__) {
337 /* --------------------------------------------------------------------------------------------
\r
338 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
339 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
340 * ------------------------------------------------------------------------------------------ */
\r
341 /// <reference path="./thenable.ts" />
\r
343 function __export(m) {
\r
344 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
346 Object.defineProperty(exports, "__esModule", { value: true });
\r
347 const Is = __webpack_require__(6);
\r
348 const messages_1 = __webpack_require__(7);
\r
349 exports.RequestType = messages_1.RequestType;
\r
350 exports.RequestType0 = messages_1.RequestType0;
\r
351 exports.RequestType1 = messages_1.RequestType1;
\r
352 exports.RequestType2 = messages_1.RequestType2;
\r
353 exports.RequestType3 = messages_1.RequestType3;
\r
354 exports.RequestType4 = messages_1.RequestType4;
\r
355 exports.RequestType5 = messages_1.RequestType5;
\r
356 exports.RequestType6 = messages_1.RequestType6;
\r
357 exports.RequestType7 = messages_1.RequestType7;
\r
358 exports.RequestType8 = messages_1.RequestType8;
\r
359 exports.RequestType9 = messages_1.RequestType9;
\r
360 exports.ResponseError = messages_1.ResponseError;
\r
361 exports.ErrorCodes = messages_1.ErrorCodes;
\r
362 exports.NotificationType = messages_1.NotificationType;
\r
363 exports.NotificationType0 = messages_1.NotificationType0;
\r
364 exports.NotificationType1 = messages_1.NotificationType1;
\r
365 exports.NotificationType2 = messages_1.NotificationType2;
\r
366 exports.NotificationType3 = messages_1.NotificationType3;
\r
367 exports.NotificationType4 = messages_1.NotificationType4;
\r
368 exports.NotificationType5 = messages_1.NotificationType5;
\r
369 exports.NotificationType6 = messages_1.NotificationType6;
\r
370 exports.NotificationType7 = messages_1.NotificationType7;
\r
371 exports.NotificationType8 = messages_1.NotificationType8;
\r
372 exports.NotificationType9 = messages_1.NotificationType9;
\r
373 const messageReader_1 = __webpack_require__(8);
\r
374 exports.MessageReader = messageReader_1.MessageReader;
\r
375 exports.StreamMessageReader = messageReader_1.StreamMessageReader;
\r
376 exports.IPCMessageReader = messageReader_1.IPCMessageReader;
\r
377 exports.SocketMessageReader = messageReader_1.SocketMessageReader;
\r
378 const messageWriter_1 = __webpack_require__(10);
\r
379 exports.MessageWriter = messageWriter_1.MessageWriter;
\r
380 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
\r
381 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
\r
382 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
\r
383 const events_1 = __webpack_require__(9);
\r
384 exports.Disposable = events_1.Disposable;
\r
385 exports.Event = events_1.Event;
\r
386 exports.Emitter = events_1.Emitter;
\r
387 const cancellation_1 = __webpack_require__(11);
\r
388 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
\r
389 exports.CancellationToken = cancellation_1.CancellationToken;
\r
390 const linkedMap_1 = __webpack_require__(12);
\r
391 __export(__webpack_require__(13));
\r
392 __export(__webpack_require__(17));
\r
393 var CancelNotification;
\r
394 (function (CancelNotification) {
\r
395 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
\r
396 })(CancelNotification || (CancelNotification = {}));
\r
397 exports.NullLogger = Object.freeze({
\r
404 (function (Trace) {
\r
405 Trace[Trace["Off"] = 0] = "Off";
\r
406 Trace[Trace["Messages"] = 1] = "Messages";
\r
407 Trace[Trace["Verbose"] = 2] = "Verbose";
\r
408 })(Trace = exports.Trace || (exports.Trace = {}));
\r
409 (function (Trace) {
\r
410 function fromString(value) {
\r
411 value = value.toLowerCase();
\r
416 return Trace.Messages;
\r
418 return Trace.Verbose;
\r
423 Trace.fromString = fromString;
\r
424 function toString(value) {
\r
428 case Trace.Messages:
\r
430 case Trace.Verbose:
\r
436 Trace.toString = toString;
\r
437 })(Trace = exports.Trace || (exports.Trace = {}));
\r
439 (function (TraceFormat) {
\r
440 TraceFormat["Text"] = "text";
\r
441 TraceFormat["JSON"] = "json";
\r
442 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
443 (function (TraceFormat) {
\r
444 function fromString(value) {
\r
445 value = value.toLowerCase();
\r
446 if (value === 'json') {
\r
447 return TraceFormat.JSON;
\r
450 return TraceFormat.Text;
\r
453 TraceFormat.fromString = fromString;
\r
454 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
455 var SetTraceNotification;
\r
456 (function (SetTraceNotification) {
\r
457 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
\r
458 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
\r
459 var LogTraceNotification;
\r
460 (function (LogTraceNotification) {
\r
461 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
\r
462 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
\r
463 var ConnectionErrors;
\r
464 (function (ConnectionErrors) {
\r
466 * The connection is closed.
\r
468 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
470 * The connection got disposed.
\r
472 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
474 * The connection is already in listening mode.
\r
476 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
\r
477 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
\r
478 class ConnectionError extends Error {
\r
479 constructor(code, message) {
\r
482 Object.setPrototypeOf(this, ConnectionError.prototype);
\r
485 exports.ConnectionError = ConnectionError;
\r
486 var ConnectionStrategy;
\r
487 (function (ConnectionStrategy) {
\r
488 function is(value) {
\r
489 let candidate = value;
\r
490 return candidate && Is.func(candidate.cancelUndispatched);
\r
492 ConnectionStrategy.is = is;
\r
493 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
\r
494 var ConnectionState;
\r
495 (function (ConnectionState) {
\r
496 ConnectionState[ConnectionState["New"] = 1] = "New";
\r
497 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
\r
498 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
\r
499 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
\r
500 })(ConnectionState || (ConnectionState = {}));
\r
501 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
\r
502 let sequenceNumber = 0;
\r
503 let notificationSquenceNumber = 0;
\r
504 let unknownResponseSquenceNumber = 0;
\r
505 const version = '2.0';
\r
506 let starRequestHandler = undefined;
\r
507 let requestHandlers = Object.create(null);
\r
508 let starNotificationHandler = undefined;
\r
509 let notificationHandlers = Object.create(null);
\r
511 let messageQueue = new linkedMap_1.LinkedMap();
\r
512 let responsePromises = Object.create(null);
\r
513 let requestTokens = Object.create(null);
\r
514 let trace = Trace.Off;
\r
515 let traceFormat = TraceFormat.Text;
\r
517 let state = ConnectionState.New;
\r
518 let errorEmitter = new events_1.Emitter();
\r
519 let closeEmitter = new events_1.Emitter();
\r
520 let unhandledNotificationEmitter = new events_1.Emitter();
\r
521 let disposeEmitter = new events_1.Emitter();
\r
522 function createRequestQueueKey(id) {
\r
523 return 'req-' + id.toString();
\r
525 function createResponseQueueKey(id) {
\r
527 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
530 return 'res-' + id.toString();
\r
533 function createNotificationQueueKey() {
\r
534 return 'not-' + (++notificationSquenceNumber).toString();
\r
536 function addMessageToQueue(queue, message) {
\r
537 if (messages_1.isRequestMessage(message)) {
\r
538 queue.set(createRequestQueueKey(message.id), message);
\r
540 else if (messages_1.isResponseMessage(message)) {
\r
541 queue.set(createResponseQueueKey(message.id), message);
\r
544 queue.set(createNotificationQueueKey(), message);
\r
547 function cancelUndispatched(_message) {
\r
550 function isListening() {
\r
551 return state === ConnectionState.Listening;
\r
553 function isClosed() {
\r
554 return state === ConnectionState.Closed;
\r
556 function isDisposed() {
\r
557 return state === ConnectionState.Disposed;
\r
559 function closeHandler() {
\r
560 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
561 state = ConnectionState.Closed;
\r
562 closeEmitter.fire(undefined);
\r
564 // If the connection is disposed don't sent close events.
\r
567 function readErrorHandler(error) {
\r
568 errorEmitter.fire([error, undefined, undefined]);
\r
570 function writeErrorHandler(data) {
\r
571 errorEmitter.fire(data);
\r
573 messageReader.onClose(closeHandler);
\r
574 messageReader.onError(readErrorHandler);
\r
575 messageWriter.onClose(closeHandler);
\r
576 messageWriter.onError(writeErrorHandler);
\r
577 function triggerMessageQueue() {
\r
578 if (timer || messageQueue.size === 0) {
\r
581 timer = setImmediate(() => {
\r
583 processMessageQueue();
\r
586 function processMessageQueue() {
\r
587 if (messageQueue.size === 0) {
\r
590 let message = messageQueue.shift();
\r
592 if (messages_1.isRequestMessage(message)) {
\r
593 handleRequest(message);
\r
595 else if (messages_1.isNotificationMessage(message)) {
\r
596 handleNotification(message);
\r
598 else if (messages_1.isResponseMessage(message)) {
\r
599 handleResponse(message);
\r
602 handleInvalidMessage(message);
\r
606 triggerMessageQueue();
\r
609 let callback = (message) => {
\r
611 // We have received a cancellation message. Check if the message is still in the queue
\r
612 // and cancel it if allowed to do so.
\r
613 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
\r
614 let key = createRequestQueueKey(message.params.id);
\r
615 let toCancel = messageQueue.get(key);
\r
616 if (messages_1.isRequestMessage(toCancel)) {
\r
617 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
\r
618 if (response && (response.error !== void 0 || response.result !== void 0)) {
\r
619 messageQueue.delete(key);
\r
620 response.id = toCancel.id;
\r
621 traceSendingResponse(response, message.method, Date.now());
\r
622 messageWriter.write(response);
\r
627 addMessageToQueue(messageQueue, message);
\r
630 triggerMessageQueue();
\r
633 function handleRequest(requestMessage) {
\r
634 if (isDisposed()) {
\r
635 // we return here silently since we fired an event when the
\r
636 // connection got disposed.
\r
639 function reply(resultOrError, method, startTime) {
\r
642 id: requestMessage.id
\r
644 if (resultOrError instanceof messages_1.ResponseError) {
\r
645 message.error = resultOrError.toJson();
\r
648 message.result = resultOrError === void 0 ? null : resultOrError;
\r
650 traceSendingResponse(message, method, startTime);
\r
651 messageWriter.write(message);
\r
653 function replyError(error, method, startTime) {
\r
656 id: requestMessage.id,
\r
657 error: error.toJson()
\r
659 traceSendingResponse(message, method, startTime);
\r
660 messageWriter.write(message);
\r
662 function replySuccess(result, method, startTime) {
\r
663 // The JSON RPC defines that a response must either have a result or an error
\r
664 // So we can't treat undefined as a valid response result.
\r
665 if (result === void 0) {
\r
670 id: requestMessage.id,
\r
673 traceSendingResponse(message, method, startTime);
\r
674 messageWriter.write(message);
\r
676 traceReceivedRequest(requestMessage);
\r
677 let element = requestHandlers[requestMessage.method];
\r
679 let requestHandler;
\r
681 type = element.type;
\r
682 requestHandler = element.handler;
\r
684 let startTime = Date.now();
\r
685 if (requestHandler || starRequestHandler) {
\r
686 let cancellationSource = new cancellation_1.CancellationTokenSource();
\r
687 let tokenKey = String(requestMessage.id);
\r
688 requestTokens[tokenKey] = cancellationSource;
\r
691 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
692 handlerResult = requestHandler
\r
693 ? requestHandler(cancellationSource.token)
\r
694 : starRequestHandler(requestMessage.method, cancellationSource.token);
\r
696 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
697 handlerResult = requestHandler
\r
698 ? requestHandler(...requestMessage.params, cancellationSource.token)
\r
699 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
\r
702 handlerResult = requestHandler
\r
703 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
704 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
706 let promise = handlerResult;
\r
707 if (!handlerResult) {
\r
708 delete requestTokens[tokenKey];
\r
709 replySuccess(handlerResult, requestMessage.method, startTime);
\r
711 else if (promise.then) {
\r
712 promise.then((resultOrError) => {
\r
713 delete requestTokens[tokenKey];
\r
714 reply(resultOrError, requestMessage.method, startTime);
\r
716 delete requestTokens[tokenKey];
\r
717 if (error instanceof messages_1.ResponseError) {
\r
718 replyError(error, requestMessage.method, startTime);
\r
720 else if (error && Is.string(error.message)) {
\r
721 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
724 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
729 delete requestTokens[tokenKey];
\r
730 reply(handlerResult, requestMessage.method, startTime);
\r
734 delete requestTokens[tokenKey];
\r
735 if (error instanceof messages_1.ResponseError) {
\r
736 reply(error, requestMessage.method, startTime);
\r
738 else if (error && Is.string(error.message)) {
\r
739 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
742 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
747 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
750 function handleResponse(responseMessage) {
\r
751 if (isDisposed()) {
\r
752 // See handle request.
\r
755 if (responseMessage.id === null) {
\r
756 if (responseMessage.error) {
\r
757 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
\r
760 logger.error(`Received response message without id. No further error information provided.`);
\r
764 let key = String(responseMessage.id);
\r
765 let responsePromise = responsePromises[key];
\r
766 traceReceivedResponse(responseMessage, responsePromise);
\r
767 if (responsePromise) {
\r
768 delete responsePromises[key];
\r
770 if (responseMessage.error) {
\r
771 let error = responseMessage.error;
\r
772 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
\r
774 else if (responseMessage.result !== void 0) {
\r
775 responsePromise.resolve(responseMessage.result);
\r
778 throw new Error('Should never happen.');
\r
782 if (error.message) {
\r
783 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
786 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
792 function handleNotification(message) {
\r
793 if (isDisposed()) {
\r
794 // See handle request.
\r
797 let type = undefined;
\r
798 let notificationHandler;
\r
799 if (message.method === CancelNotification.type.method) {
\r
800 notificationHandler = (params) => {
\r
801 let id = params.id;
\r
802 let source = requestTokens[String(id)];
\r
809 let element = notificationHandlers[message.method];
\r
811 notificationHandler = element.handler;
\r
812 type = element.type;
\r
815 if (notificationHandler || starNotificationHandler) {
\r
817 traceReceivedNotification(message);
\r
818 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
819 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
\r
821 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
822 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
\r
825 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
829 if (error.message) {
\r
830 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
833 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
838 unhandledNotificationEmitter.fire(message);
\r
841 function handleInvalidMessage(message) {
\r
843 logger.error('Received empty message.');
\r
846 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
\r
847 // Test whether we find an id to reject the promise
\r
848 let responseMessage = message;
\r
849 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
\r
850 let key = String(responseMessage.id);
\r
851 let responseHandler = responsePromises[key];
\r
852 if (responseHandler) {
\r
853 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
\r
857 function traceSendingRequest(message) {
\r
858 if (trace === Trace.Off || !tracer) {
\r
861 if (traceFormat === TraceFormat.Text) {
\r
862 let data = undefined;
\r
863 if (trace === Trace.Verbose && message.params) {
\r
864 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
866 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
869 logLSPMessage('send-request', message);
\r
872 function traceSendingNotification(message) {
\r
873 if (trace === Trace.Off || !tracer) {
\r
876 if (traceFormat === TraceFormat.Text) {
\r
877 let data = undefined;
\r
878 if (trace === Trace.Verbose) {
\r
879 if (message.params) {
\r
880 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
883 data = 'No parameters provided.\n\n';
\r
886 tracer.log(`Sending notification '${message.method}'.`, data);
\r
889 logLSPMessage('send-notification', message);
\r
892 function traceSendingResponse(message, method, startTime) {
\r
893 if (trace === Trace.Off || !tracer) {
\r
896 if (traceFormat === TraceFormat.Text) {
\r
897 let data = undefined;
\r
898 if (trace === Trace.Verbose) {
\r
899 if (message.error && message.error.data) {
\r
900 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
903 if (message.result) {
\r
904 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
906 else if (message.error === void 0) {
\r
907 data = 'No result returned.\n\n';
\r
911 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
914 logLSPMessage('send-response', message);
\r
917 function traceReceivedRequest(message) {
\r
918 if (trace === Trace.Off || !tracer) {
\r
921 if (traceFormat === TraceFormat.Text) {
\r
922 let data = undefined;
\r
923 if (trace === Trace.Verbose && message.params) {
\r
924 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
926 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
929 logLSPMessage('receive-request', message);
\r
932 function traceReceivedNotification(message) {
\r
933 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\r
936 if (traceFormat === TraceFormat.Text) {
\r
937 let data = undefined;
\r
938 if (trace === Trace.Verbose) {
\r
939 if (message.params) {
\r
940 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
943 data = 'No parameters provided.\n\n';
\r
946 tracer.log(`Received notification '${message.method}'.`, data);
\r
949 logLSPMessage('receive-notification', message);
\r
952 function traceReceivedResponse(message, responsePromise) {
\r
953 if (trace === Trace.Off || !tracer) {
\r
956 if (traceFormat === TraceFormat.Text) {
\r
957 let data = undefined;
\r
958 if (trace === Trace.Verbose) {
\r
959 if (message.error && message.error.data) {
\r
960 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
963 if (message.result) {
\r
964 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
966 else if (message.error === void 0) {
\r
967 data = 'No result returned.\n\n';
\r
971 if (responsePromise) {
\r
972 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
\r
973 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
\r
976 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
980 logLSPMessage('receive-response', message);
\r
983 function logLSPMessage(type, message) {
\r
984 if (!tracer || trace === Trace.Off) {
\r
987 const lspMessage = {
\r
988 isLSPMessage: true,
\r
991 timestamp: Date.now()
\r
993 tracer.log(lspMessage);
\r
995 function throwIfClosedOrDisposed() {
\r
997 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
999 if (isDisposed()) {
\r
1000 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
1003 function throwIfListening() {
\r
1004 if (isListening()) {
\r
1005 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
1008 function throwIfNotListening() {
\r
1009 if (!isListening()) {
\r
1010 throw new Error('Call listen() first.');
\r
1013 function undefinedToNull(param) {
\r
1014 if (param === void 0) {
\r
1021 function computeMessageParams(type, params) {
\r
1023 let numberOfParams = type.numberOfParams;
\r
1024 switch (numberOfParams) {
\r
1029 result = undefinedToNull(params[0]);
\r
1033 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
1034 result.push(undefinedToNull(params[i]));
\r
1036 if (params.length < numberOfParams) {
\r
1037 for (let i = params.length; i < numberOfParams; i++) {
\r
1038 result.push(null);
\r
1045 let connection = {
\r
1046 sendNotification: (type, ...params) => {
\r
1047 throwIfClosedOrDisposed();
\r
1049 let messageParams;
\r
1050 if (Is.string(type)) {
\r
1052 switch (params.length) {
\r
1054 messageParams = null;
\r
1057 messageParams = params[0];
\r
1060 messageParams = params;
\r
1065 method = type.method;
\r
1066 messageParams = computeMessageParams(type, params);
\r
1068 let notificationMessage = {
\r
1071 params: messageParams
\r
1073 traceSendingNotification(notificationMessage);
\r
1074 messageWriter.write(notificationMessage);
\r
1076 onNotification: (type, handler) => {
\r
1077 throwIfClosedOrDisposed();
\r
1078 if (Is.func(type)) {
\r
1079 starNotificationHandler = type;
\r
1081 else if (handler) {
\r
1082 if (Is.string(type)) {
\r
1083 notificationHandlers[type] = { type: undefined, handler };
\r
1086 notificationHandlers[type.method] = { type, handler };
\r
1090 sendRequest: (type, ...params) => {
\r
1091 throwIfClosedOrDisposed();
\r
1092 throwIfNotListening();
\r
1094 let messageParams;
\r
1095 let token = undefined;
\r
1096 if (Is.string(type)) {
\r
1098 switch (params.length) {
\r
1100 messageParams = null;
\r
1103 // The cancellation token is optional so it can also be undefined.
\r
1104 if (cancellation_1.CancellationToken.is(params[0])) {
\r
1105 messageParams = null;
\r
1106 token = params[0];
\r
1109 messageParams = undefinedToNull(params[0]);
\r
1113 const last = params.length - 1;
\r
1114 if (cancellation_1.CancellationToken.is(params[last])) {
\r
1115 token = params[last];
\r
1116 if (params.length === 2) {
\r
1117 messageParams = undefinedToNull(params[0]);
\r
1120 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
1124 messageParams = params.map(value => undefinedToNull(value));
\r
1130 method = type.method;
\r
1131 messageParams = computeMessageParams(type, params);
\r
1132 let numberOfParams = type.numberOfParams;
\r
1133 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
\r
1135 let id = sequenceNumber++;
\r
1136 let result = new Promise((resolve, reject) => {
\r
1137 let requestMessage = {
\r
1141 params: messageParams
\r
1143 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
1144 traceSendingRequest(requestMessage);
\r
1146 messageWriter.write(requestMessage);
\r
1149 // Writing the message failed. So we need to reject the promise.
\r
1150 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
\r
1151 responsePromise = null;
\r
1153 if (responsePromise) {
\r
1154 responsePromises[String(id)] = responsePromise;
\r
1158 token.onCancellationRequested(() => {
\r
1159 connection.sendNotification(CancelNotification.type, { id });
\r
1164 onRequest: (type, handler) => {
\r
1165 throwIfClosedOrDisposed();
\r
1166 if (Is.func(type)) {
\r
1167 starRequestHandler = type;
\r
1169 else if (handler) {
\r
1170 if (Is.string(type)) {
\r
1171 requestHandlers[type] = { type: undefined, handler };
\r
1174 requestHandlers[type.method] = { type, handler };
\r
1178 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
\r
1179 let _sendNotification = false;
\r
1180 let _traceFormat = TraceFormat.Text;
\r
1181 if (sendNotificationOrTraceOptions !== void 0) {
\r
1182 if (Is.boolean(sendNotificationOrTraceOptions)) {
\r
1183 _sendNotification = sendNotificationOrTraceOptions;
\r
1186 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
1187 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
1191 traceFormat = _traceFormat;
\r
1192 if (trace === Trace.Off) {
\r
1193 tracer = undefined;
\r
1198 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
1199 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
1202 onError: errorEmitter.event,
\r
1203 onClose: closeEmitter.event,
\r
1204 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
1205 onDispose: disposeEmitter.event,
\r
1207 if (isDisposed()) {
\r
1210 state = ConnectionState.Disposed;
\r
1211 disposeEmitter.fire(undefined);
\r
1212 let error = new Error('Connection got disposed.');
\r
1213 Object.keys(responsePromises).forEach((key) => {
\r
1214 responsePromises[key].reject(error);
\r
1216 responsePromises = Object.create(null);
\r
1217 requestTokens = Object.create(null);
\r
1218 messageQueue = new linkedMap_1.LinkedMap();
\r
1219 // Test for backwards compatibility
\r
1220 if (Is.func(messageWriter.dispose)) {
\r
1221 messageWriter.dispose();
\r
1223 if (Is.func(messageReader.dispose)) {
\r
1224 messageReader.dispose();
\r
1228 throwIfClosedOrDisposed();
\r
1229 throwIfListening();
\r
1230 state = ConnectionState.Listening;
\r
1231 messageReader.listen(callback);
\r
1234 console.log("inspect");
\r
1237 connection.onNotification(LogTraceNotification.type, (params) => {
\r
1238 if (trace === Trace.Off || !tracer) {
\r
1241 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
1243 return connection;
\r
1245 function isMessageReader(value) {
\r
1246 return value.listen !== void 0 && value.read === void 0;
\r
1248 function isMessageWriter(value) {
\r
1249 return value.write !== void 0 && value.end === void 0;
\r
1251 function createMessageConnection(input, output, logger, strategy) {
\r
1253 logger = exports.NullLogger;
\r
1255 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
\r
1256 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
\r
1257 return _createMessageConnection(reader, writer, logger, strategy);
\r
1259 exports.createMessageConnection = createMessageConnection;
\r
1264 /***/ (function(module, exports, __webpack_require__) {
1267 /* --------------------------------------------------------------------------------------------
\r
1268 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1269 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1270 * ------------------------------------------------------------------------------------------ */
\r
1272 Object.defineProperty(exports, "__esModule", { value: true });
\r
1273 function boolean(value) {
\r
1274 return value === true || value === false;
\r
1276 exports.boolean = boolean;
\r
1277 function string(value) {
\r
1278 return typeof value === 'string' || value instanceof String;
\r
1280 exports.string = string;
\r
1281 function number(value) {
\r
1282 return typeof value === 'number' || value instanceof Number;
\r
1284 exports.number = number;
\r
1285 function error(value) {
\r
1286 return value instanceof Error;
\r
1288 exports.error = error;
\r
1289 function func(value) {
\r
1290 return typeof value === 'function';
\r
1292 exports.func = func;
\r
1293 function array(value) {
\r
1294 return Array.isArray(value);
\r
1296 exports.array = array;
\r
1297 function stringArray(value) {
\r
1298 return array(value) && value.every(elem => string(elem));
\r
1300 exports.stringArray = stringArray;
\r
1305 /***/ (function(module, exports, __webpack_require__) {
1308 /* --------------------------------------------------------------------------------------------
\r
1309 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1310 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1311 * ------------------------------------------------------------------------------------------ */
\r
1313 Object.defineProperty(exports, "__esModule", { value: true });
\r
1314 const is = __webpack_require__(6);
\r
1316 * Predefined error codes.
\r
1319 (function (ErrorCodes) {
\r
1320 // Defined by JSON RPC
\r
1321 ErrorCodes.ParseError = -32700;
\r
1322 ErrorCodes.InvalidRequest = -32600;
\r
1323 ErrorCodes.MethodNotFound = -32601;
\r
1324 ErrorCodes.InvalidParams = -32602;
\r
1325 ErrorCodes.InternalError = -32603;
\r
1326 ErrorCodes.serverErrorStart = -32099;
\r
1327 ErrorCodes.serverErrorEnd = -32000;
\r
1328 ErrorCodes.ServerNotInitialized = -32002;
\r
1329 ErrorCodes.UnknownErrorCode = -32001;
\r
1330 // Defined by the protocol.
\r
1331 ErrorCodes.RequestCancelled = -32800;
\r
1332 ErrorCodes.ContentModified = -32801;
\r
1333 // Defined by VSCode library.
\r
1334 ErrorCodes.MessageWriteError = 1;
\r
1335 ErrorCodes.MessageReadError = 2;
\r
1336 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
\r
1338 * An error object return in a response in case a request
\r
1341 class ResponseError extends Error {
\r
1342 constructor(code, message, data) {
\r
1344 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
1346 Object.setPrototypeOf(this, ResponseError.prototype);
\r
1351 message: this.message,
\r
1356 exports.ResponseError = ResponseError;
\r
1358 * An abstract implementation of a MessageType.
\r
1360 class AbstractMessageType {
\r
1361 constructor(_method, _numberOfParams) {
\r
1362 this._method = _method;
\r
1363 this._numberOfParams = _numberOfParams;
\r
1366 return this._method;
\r
1368 get numberOfParams() {
\r
1369 return this._numberOfParams;
\r
1372 exports.AbstractMessageType = AbstractMessageType;
\r
1374 * Classes to type request response pairs
\r
1376 class RequestType0 extends AbstractMessageType {
\r
1377 constructor(method) {
\r
1379 this._ = undefined;
\r
1382 exports.RequestType0 = RequestType0;
\r
1383 class RequestType extends AbstractMessageType {
\r
1384 constructor(method) {
\r
1386 this._ = undefined;
\r
1389 exports.RequestType = RequestType;
\r
1390 class RequestType1 extends AbstractMessageType {
\r
1391 constructor(method) {
\r
1393 this._ = undefined;
\r
1396 exports.RequestType1 = RequestType1;
\r
1397 class RequestType2 extends AbstractMessageType {
\r
1398 constructor(method) {
\r
1400 this._ = undefined;
\r
1403 exports.RequestType2 = RequestType2;
\r
1404 class RequestType3 extends AbstractMessageType {
\r
1405 constructor(method) {
\r
1407 this._ = undefined;
\r
1410 exports.RequestType3 = RequestType3;
\r
1411 class RequestType4 extends AbstractMessageType {
\r
1412 constructor(method) {
\r
1414 this._ = undefined;
\r
1417 exports.RequestType4 = RequestType4;
\r
1418 class RequestType5 extends AbstractMessageType {
\r
1419 constructor(method) {
\r
1421 this._ = undefined;
\r
1424 exports.RequestType5 = RequestType5;
\r
1425 class RequestType6 extends AbstractMessageType {
\r
1426 constructor(method) {
\r
1428 this._ = undefined;
\r
1431 exports.RequestType6 = RequestType6;
\r
1432 class RequestType7 extends AbstractMessageType {
\r
1433 constructor(method) {
\r
1435 this._ = undefined;
\r
1438 exports.RequestType7 = RequestType7;
\r
1439 class RequestType8 extends AbstractMessageType {
\r
1440 constructor(method) {
\r
1442 this._ = undefined;
\r
1445 exports.RequestType8 = RequestType8;
\r
1446 class RequestType9 extends AbstractMessageType {
\r
1447 constructor(method) {
\r
1449 this._ = undefined;
\r
1452 exports.RequestType9 = RequestType9;
\r
1453 class NotificationType extends AbstractMessageType {
\r
1454 constructor(method) {
\r
1456 this._ = undefined;
\r
1459 exports.NotificationType = NotificationType;
\r
1460 class NotificationType0 extends AbstractMessageType {
\r
1461 constructor(method) {
\r
1463 this._ = undefined;
\r
1466 exports.NotificationType0 = NotificationType0;
\r
1467 class NotificationType1 extends AbstractMessageType {
\r
1468 constructor(method) {
\r
1470 this._ = undefined;
\r
1473 exports.NotificationType1 = NotificationType1;
\r
1474 class NotificationType2 extends AbstractMessageType {
\r
1475 constructor(method) {
\r
1477 this._ = undefined;
\r
1480 exports.NotificationType2 = NotificationType2;
\r
1481 class NotificationType3 extends AbstractMessageType {
\r
1482 constructor(method) {
\r
1484 this._ = undefined;
\r
1487 exports.NotificationType3 = NotificationType3;
\r
1488 class NotificationType4 extends AbstractMessageType {
\r
1489 constructor(method) {
\r
1491 this._ = undefined;
\r
1494 exports.NotificationType4 = NotificationType4;
\r
1495 class NotificationType5 extends AbstractMessageType {
\r
1496 constructor(method) {
\r
1498 this._ = undefined;
\r
1501 exports.NotificationType5 = NotificationType5;
\r
1502 class NotificationType6 extends AbstractMessageType {
\r
1503 constructor(method) {
\r
1505 this._ = undefined;
\r
1508 exports.NotificationType6 = NotificationType6;
\r
1509 class NotificationType7 extends AbstractMessageType {
\r
1510 constructor(method) {
\r
1512 this._ = undefined;
\r
1515 exports.NotificationType7 = NotificationType7;
\r
1516 class NotificationType8 extends AbstractMessageType {
\r
1517 constructor(method) {
\r
1519 this._ = undefined;
\r
1522 exports.NotificationType8 = NotificationType8;
\r
1523 class NotificationType9 extends AbstractMessageType {
\r
1524 constructor(method) {
\r
1526 this._ = undefined;
\r
1529 exports.NotificationType9 = NotificationType9;
\r
1531 * Tests if the given message is a request message
\r
1533 function isRequestMessage(message) {
\r
1534 let candidate = message;
\r
1535 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
\r
1537 exports.isRequestMessage = isRequestMessage;
\r
1539 * Tests if the given message is a notification message
\r
1541 function isNotificationMessage(message) {
\r
1542 let candidate = message;
\r
1543 return candidate && is.string(candidate.method) && message.id === void 0;
\r
1545 exports.isNotificationMessage = isNotificationMessage;
\r
1547 * Tests if the given message is a response message
\r
1549 function isResponseMessage(message) {
\r
1550 let candidate = message;
\r
1551 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
\r
1553 exports.isResponseMessage = isResponseMessage;
\r
1558 /***/ (function(module, exports, __webpack_require__) {
1561 /* --------------------------------------------------------------------------------------------
\r
1562 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1563 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1564 * ------------------------------------------------------------------------------------------ */
\r
1566 Object.defineProperty(exports, "__esModule", { value: true });
\r
1567 const events_1 = __webpack_require__(9);
\r
1568 const Is = __webpack_require__(6);
\r
1569 let DefaultSize = 8192;
\r
1570 let CR = Buffer.from('\r', 'ascii')[0];
\r
1571 let LF = Buffer.from('\n', 'ascii')[0];
\r
1572 let CRLF = '\r\n';
\r
1573 class MessageBuffer {
\r
1574 constructor(encoding = 'utf8') {
\r
1575 this.encoding = encoding;
\r
1577 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
1580 var toAppend = chunk;
\r
1581 if (typeof (chunk) === 'string') {
\r
1583 var bufferLen = Buffer.byteLength(str, this.encoding);
\r
1584 toAppend = Buffer.allocUnsafe(bufferLen);
\r
1585 toAppend.write(str, 0, bufferLen, this.encoding);
\r
1587 if (this.buffer.length - this.index >= toAppend.length) {
\r
1588 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\r
1591 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
\r
1592 if (this.index === 0) {
\r
1593 this.buffer = Buffer.allocUnsafe(newSize);
\r
1594 toAppend.copy(this.buffer, 0, 0, toAppend.length);
\r
1597 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
1600 this.index += toAppend.length;
\r
1602 tryReadHeaders() {
\r
1603 let result = undefined;
\r
1605 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
1608 // No header / body separator found (e.g CRLFCRLF)
\r
1609 if (current + 3 >= this.index) {
\r
1612 result = Object.create(null);
\r
1613 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
\r
1614 headers.forEach((header) => {
\r
1615 let index = header.indexOf(':');
\r
1616 if (index === -1) {
\r
1617 throw new Error('Message header must separate key and value using :');
\r
1619 let key = header.substr(0, index);
\r
1620 let value = header.substr(index + 1).trim();
\r
1621 result[key] = value;
\r
1623 let nextStart = current + 4;
\r
1624 this.buffer = this.buffer.slice(nextStart);
\r
1625 this.index = this.index - nextStart;
\r
1628 tryReadContent(length) {
\r
1629 if (this.index < length) {
\r
1632 let result = this.buffer.toString(this.encoding, 0, length);
\r
1633 let nextStart = length;
\r
1634 this.buffer.copy(this.buffer, 0, nextStart);
\r
1635 this.index = this.index - nextStart;
\r
1638 get numberOfBytes() {
\r
1639 return this.index;
\r
1642 var MessageReader;
\r
1643 (function (MessageReader) {
\r
1644 function is(value) {
\r
1645 let candidate = value;
\r
1646 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
\r
1647 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
\r
1649 MessageReader.is = is;
\r
1650 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
1651 class AbstractMessageReader {
\r
1653 this.errorEmitter = new events_1.Emitter();
\r
1654 this.closeEmitter = new events_1.Emitter();
\r
1655 this.partialMessageEmitter = new events_1.Emitter();
\r
1658 this.errorEmitter.dispose();
\r
1659 this.closeEmitter.dispose();
\r
1662 return this.errorEmitter.event;
\r
1664 fireError(error) {
\r
1665 this.errorEmitter.fire(this.asError(error));
\r
1668 return this.closeEmitter.event;
\r
1671 this.closeEmitter.fire(undefined);
\r
1673 get onPartialMessage() {
\r
1674 return this.partialMessageEmitter.event;
\r
1676 firePartialMessage(info) {
\r
1677 this.partialMessageEmitter.fire(info);
\r
1680 if (error instanceof Error) {
\r
1684 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1688 exports.AbstractMessageReader = AbstractMessageReader;
\r
1689 class StreamMessageReader extends AbstractMessageReader {
\r
1690 constructor(readable, encoding = 'utf8') {
\r
1692 this.readable = readable;
\r
1693 this.buffer = new MessageBuffer(encoding);
\r
1694 this._partialMessageTimeout = 10000;
\r
1696 set partialMessageTimeout(timeout) {
\r
1697 this._partialMessageTimeout = timeout;
\r
1699 get partialMessageTimeout() {
\r
1700 return this._partialMessageTimeout;
\r
1702 listen(callback) {
\r
1703 this.nextMessageLength = -1;
\r
1704 this.messageToken = 0;
\r
1705 this.partialMessageTimer = undefined;
\r
1706 this.callback = callback;
\r
1707 this.readable.on('data', (data) => {
\r
1708 this.onData(data);
\r
1710 this.readable.on('error', (error) => this.fireError(error));
\r
1711 this.readable.on('close', () => this.fireClose());
\r
1714 this.buffer.append(data);
\r
1716 if (this.nextMessageLength === -1) {
\r
1717 let headers = this.buffer.tryReadHeaders();
\r
1721 let contentLength = headers['Content-Length'];
\r
1722 if (!contentLength) {
\r
1723 throw new Error('Header must provide a Content-Length property.');
\r
1725 let length = parseInt(contentLength);
\r
1726 if (isNaN(length)) {
\r
1727 throw new Error('Content-Length value must be a number.');
\r
1729 this.nextMessageLength = length;
\r
1730 // Take the encoding form the header. For compatibility
\r
1731 // treat both utf-8 and utf8 as node utf8
\r
1733 var msg = this.buffer.tryReadContent(this.nextMessageLength);
\r
1734 if (msg === null) {
\r
1735 /** We haven't received the full message yet. */
\r
1736 this.setPartialMessageTimer();
\r
1739 this.clearPartialMessageTimer();
\r
1740 this.nextMessageLength = -1;
\r
1741 this.messageToken++;
\r
1742 var json = JSON.parse(msg);
\r
1743 this.callback(json);
\r
1746 clearPartialMessageTimer() {
\r
1747 if (this.partialMessageTimer) {
\r
1748 clearTimeout(this.partialMessageTimer);
\r
1749 this.partialMessageTimer = undefined;
\r
1752 setPartialMessageTimer() {
\r
1753 this.clearPartialMessageTimer();
\r
1754 if (this._partialMessageTimeout <= 0) {
\r
1757 this.partialMessageTimer = setTimeout((token, timeout) => {
\r
1758 this.partialMessageTimer = undefined;
\r
1759 if (token === this.messageToken) {
\r
1760 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
\r
1761 this.setPartialMessageTimer();
\r
1763 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
1766 exports.StreamMessageReader = StreamMessageReader;
\r
1767 class IPCMessageReader extends AbstractMessageReader {
\r
1768 constructor(process) {
\r
1770 this.process = process;
\r
1771 let eventEmitter = this.process;
\r
1772 eventEmitter.on('error', (error) => this.fireError(error));
\r
1773 eventEmitter.on('close', () => this.fireClose());
\r
1775 listen(callback) {
\r
1776 this.process.on('message', callback);
\r
1779 exports.IPCMessageReader = IPCMessageReader;
\r
1780 class SocketMessageReader extends StreamMessageReader {
\r
1781 constructor(socket, encoding = 'utf-8') {
\r
1782 super(socket, encoding);
\r
1785 exports.SocketMessageReader = SocketMessageReader;
\r
1790 /***/ (function(module, exports, __webpack_require__) {
1793 /* --------------------------------------------------------------------------------------------
\r
1794 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1795 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1796 * ------------------------------------------------------------------------------------------ */
\r
1798 Object.defineProperty(exports, "__esModule", { value: true });
\r
1800 (function (Disposable) {
\r
1801 function create(func) {
\r
1806 Disposable.create = create;
\r
1807 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\r
1809 (function (Event) {
\r
1810 const _disposable = { dispose() { } };
\r
1811 Event.None = function () { return _disposable; };
\r
1812 })(Event = exports.Event || (exports.Event = {}));
\r
1813 class CallbackList {
\r
1814 add(callback, context = null, bucket) {
\r
1815 if (!this._callbacks) {
\r
1816 this._callbacks = [];
\r
1817 this._contexts = [];
\r
1819 this._callbacks.push(callback);
\r
1820 this._contexts.push(context);
\r
1821 if (Array.isArray(bucket)) {
\r
1822 bucket.push({ dispose: () => this.remove(callback, context) });
\r
1825 remove(callback, context = null) {
\r
1826 if (!this._callbacks) {
\r
1829 var foundCallbackWithDifferentContext = false;
\r
1830 for (var i = 0, len = this._callbacks.length; i < len; i++) {
\r
1831 if (this._callbacks[i] === callback) {
\r
1832 if (this._contexts[i] === context) {
\r
1833 // callback & context match => remove it
\r
1834 this._callbacks.splice(i, 1);
\r
1835 this._contexts.splice(i, 1);
\r
1839 foundCallbackWithDifferentContext = true;
\r
1843 if (foundCallbackWithDifferentContext) {
\r
1844 throw new Error('When adding a listener with a context, you should remove it with the same context');
\r
1848 if (!this._callbacks) {
\r
1851 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
\r
1852 for (var i = 0, len = callbacks.length; i < len; i++) {
\r
1854 ret.push(callbacks[i].apply(contexts[i], args));
\r
1863 return !this._callbacks || this._callbacks.length === 0;
\r
1866 this._callbacks = undefined;
\r
1867 this._contexts = undefined;
\r
1871 constructor(_options) {
\r
1872 this._options = _options;
\r
1875 * For the public to allow to subscribe
\r
1876 * to events from this Emitter
\r
1879 if (!this._event) {
\r
1880 this._event = (listener, thisArgs, disposables) => {
\r
1881 if (!this._callbacks) {
\r
1882 this._callbacks = new CallbackList();
\r
1884 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
1885 this._options.onFirstListenerAdd(this);
\r
1887 this._callbacks.add(listener, thisArgs);
\r
1891 this._callbacks.remove(listener, thisArgs);
\r
1892 result.dispose = Emitter._noop;
\r
1893 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
\r
1894 this._options.onLastListenerRemove(this);
\r
1898 if (Array.isArray(disposables)) {
\r
1899 disposables.push(result);
\r
1904 return this._event;
\r
1907 * To be kept private to fire an event to
\r
1911 if (this._callbacks) {
\r
1912 this._callbacks.invoke.call(this._callbacks, event);
\r
1916 if (this._callbacks) {
\r
1917 this._callbacks.dispose();
\r
1918 this._callbacks = undefined;
\r
1922 Emitter._noop = function () { };
\r
1923 exports.Emitter = Emitter;
\r
1928 /***/ (function(module, exports, __webpack_require__) {
1931 /* --------------------------------------------------------------------------------------------
\r
1932 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1933 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1934 * ------------------------------------------------------------------------------------------ */
\r
1936 Object.defineProperty(exports, "__esModule", { value: true });
\r
1937 const events_1 = __webpack_require__(9);
\r
1938 const Is = __webpack_require__(6);
\r
1939 let ContentLength = 'Content-Length: ';
\r
1940 let CRLF = '\r\n';
\r
1941 var MessageWriter;
\r
1942 (function (MessageWriter) {
\r
1943 function is(value) {
\r
1944 let candidate = value;
\r
1945 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
\r
1946 Is.func(candidate.onError) && Is.func(candidate.write);
\r
1948 MessageWriter.is = is;
\r
1949 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
1950 class AbstractMessageWriter {
\r
1952 this.errorEmitter = new events_1.Emitter();
\r
1953 this.closeEmitter = new events_1.Emitter();
\r
1956 this.errorEmitter.dispose();
\r
1957 this.closeEmitter.dispose();
\r
1960 return this.errorEmitter.event;
\r
1962 fireError(error, message, count) {
\r
1963 this.errorEmitter.fire([this.asError(error), message, count]);
\r
1966 return this.closeEmitter.event;
\r
1969 this.closeEmitter.fire(undefined);
\r
1972 if (error instanceof Error) {
\r
1976 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1980 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
1981 class StreamMessageWriter extends AbstractMessageWriter {
\r
1982 constructor(writable, encoding = 'utf8') {
\r
1984 this.writable = writable;
\r
1985 this.encoding = encoding;
\r
1986 this.errorCount = 0;
\r
1987 this.writable.on('error', (error) => this.fireError(error));
\r
1988 this.writable.on('close', () => this.fireClose());
\r
1991 let json = JSON.stringify(msg);
\r
1992 let contentLength = Buffer.byteLength(json, this.encoding);
\r
1994 ContentLength, contentLength.toString(), CRLF,
\r
1998 // Header must be written in ASCII encoding
\r
1999 this.writable.write(headers.join(''), 'ascii');
\r
2000 // Now write the content. This can be written in any encoding
\r
2001 this.writable.write(json, this.encoding);
\r
2002 this.errorCount = 0;
\r
2005 this.errorCount++;
\r
2006 this.fireError(error, msg, this.errorCount);
\r
2010 exports.StreamMessageWriter = StreamMessageWriter;
\r
2011 class IPCMessageWriter extends AbstractMessageWriter {
\r
2012 constructor(process) {
\r
2014 this.process = process;
\r
2015 this.errorCount = 0;
\r
2017 this.sending = false;
\r
2018 let eventEmitter = this.process;
\r
2019 eventEmitter.on('error', (error) => this.fireError(error));
\r
2020 eventEmitter.on('close', () => this.fireClose);
\r
2023 if (!this.sending && this.queue.length === 0) {
\r
2024 // See https://github.com/nodejs/node/issues/7657
\r
2025 this.doWriteMessage(msg);
\r
2028 this.queue.push(msg);
\r
2031 doWriteMessage(msg) {
\r
2033 if (this.process.send) {
\r
2034 this.sending = true;
\r
2035 this.process.send(msg, undefined, undefined, (error) => {
\r
2036 this.sending = false;
\r
2038 this.errorCount++;
\r
2039 this.fireError(error, msg, this.errorCount);
\r
2042 this.errorCount = 0;
\r
2044 if (this.queue.length > 0) {
\r
2045 this.doWriteMessage(this.queue.shift());
\r
2051 this.errorCount++;
\r
2052 this.fireError(error, msg, this.errorCount);
\r
2056 exports.IPCMessageWriter = IPCMessageWriter;
\r
2057 class SocketMessageWriter extends AbstractMessageWriter {
\r
2058 constructor(socket, encoding = 'utf8') {
\r
2060 this.socket = socket;
\r
2062 this.sending = false;
\r
2063 this.encoding = encoding;
\r
2064 this.errorCount = 0;
\r
2065 this.socket.on('error', (error) => this.fireError(error));
\r
2066 this.socket.on('close', () => this.fireClose());
\r
2070 this.socket.destroy();
\r
2073 if (!this.sending && this.queue.length === 0) {
\r
2074 // See https://github.com/nodejs/node/issues/7657
\r
2075 this.doWriteMessage(msg);
\r
2078 this.queue.push(msg);
\r
2081 doWriteMessage(msg) {
\r
2082 let json = JSON.stringify(msg);
\r
2083 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2085 ContentLength, contentLength.toString(), CRLF,
\r
2089 // Header must be written in ASCII encoding
\r
2090 this.sending = true;
\r
2091 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
2093 this.handleError(error, msg);
\r
2096 // Now write the content. This can be written in any encoding
\r
2097 this.socket.write(json, this.encoding, (error) => {
\r
2098 this.sending = false;
\r
2100 this.handleError(error, msg);
\r
2103 this.errorCount = 0;
\r
2105 if (this.queue.length > 0) {
\r
2106 this.doWriteMessage(this.queue.shift());
\r
2111 this.handleError(error, msg);
\r
2116 this.handleError(error, msg);
\r
2119 handleError(error, msg) {
\r
2120 this.errorCount++;
\r
2121 this.fireError(error, msg, this.errorCount);
\r
2124 exports.SocketMessageWriter = SocketMessageWriter;
\r
2129 /***/ (function(module, exports, __webpack_require__) {
2132 /*---------------------------------------------------------------------------------------------
\r
2133 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2134 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2135 *--------------------------------------------------------------------------------------------*/
\r
2137 Object.defineProperty(exports, "__esModule", { value: true });
\r
2138 const events_1 = __webpack_require__(9);
\r
2139 const Is = __webpack_require__(6);
\r
2140 var CancellationToken;
\r
2141 (function (CancellationToken) {
\r
2142 CancellationToken.None = Object.freeze({
\r
2143 isCancellationRequested: false,
\r
2144 onCancellationRequested: events_1.Event.None
\r
2146 CancellationToken.Cancelled = Object.freeze({
\r
2147 isCancellationRequested: true,
\r
2148 onCancellationRequested: events_1.Event.None
\r
2150 function is(value) {
\r
2151 let candidate = value;
\r
2152 return candidate && (candidate === CancellationToken.None
\r
2153 || candidate === CancellationToken.Cancelled
\r
2154 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
\r
2156 CancellationToken.is = is;
\r
2157 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
\r
2158 const shortcutEvent = Object.freeze(function (callback, context) {
\r
2159 let handle = setTimeout(callback.bind(context), 0);
\r
2160 return { dispose() { clearTimeout(handle); } };
\r
2162 class MutableToken {
\r
2164 this._isCancelled = false;
\r
2167 if (!this._isCancelled) {
\r
2168 this._isCancelled = true;
\r
2169 if (this._emitter) {
\r
2170 this._emitter.fire(undefined);
\r
2175 get isCancellationRequested() {
\r
2176 return this._isCancelled;
\r
2178 get onCancellationRequested() {
\r
2179 if (this._isCancelled) {
\r
2180 return shortcutEvent;
\r
2182 if (!this._emitter) {
\r
2183 this._emitter = new events_1.Emitter();
\r
2185 return this._emitter.event;
\r
2188 if (this._emitter) {
\r
2189 this._emitter.dispose();
\r
2190 this._emitter = undefined;
\r
2194 class CancellationTokenSource {
\r
2196 if (!this._token) {
\r
2197 // be lazy and create the token only when
\r
2198 // actually needed
\r
2199 this._token = new MutableToken();
\r
2201 return this._token;
\r
2204 if (!this._token) {
\r
2205 // save an object by returning the default
\r
2206 // cancelled token when cancellation happens
\r
2207 // before someone asks for the token
\r
2208 this._token = CancellationToken.Cancelled;
\r
2211 this._token.cancel();
\r
2215 if (!this._token) {
\r
2216 // ensure to initialize with an empty token if we had none
\r
2217 this._token = CancellationToken.None;
\r
2219 else if (this._token instanceof MutableToken) {
\r
2220 // actually dispose
\r
2221 this._token.dispose();
\r
2225 exports.CancellationTokenSource = CancellationTokenSource;
\r
2230 /***/ (function(module, exports, __webpack_require__) {
2234 /*---------------------------------------------------------------------------------------------
\r
2235 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2236 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2237 *--------------------------------------------------------------------------------------------*/
\r
2238 Object.defineProperty(exports, "__esModule", { value: true });
\r
2240 (function (Touch) {
\r
2244 })(Touch = exports.Touch || (exports.Touch = {}));
\r
2247 this._map = new Map();
\r
2248 this._head = undefined;
\r
2249 this._tail = undefined;
\r
2253 this._map.clear();
\r
2254 this._head = undefined;
\r
2255 this._tail = undefined;
\r
2259 return !this._head && !this._tail;
\r
2262 return this._size;
\r
2265 return this._map.has(key);
\r
2268 const item = this._map.get(key);
\r
2272 return item.value;
\r
2274 set(key, value, touch = Touch.None) {
\r
2275 let item = this._map.get(key);
\r
2277 item.value = value;
\r
2278 if (touch !== Touch.None) {
\r
2279 this.touch(item, touch);
\r
2283 item = { key, value, next: undefined, previous: undefined };
\r
2286 this.addItemLast(item);
\r
2289 this.addItemFirst(item);
\r
2292 this.addItemLast(item);
\r
2295 this.addItemLast(item);
\r
2298 this._map.set(key, item);
\r
2303 const item = this._map.get(key);
\r
2307 this._map.delete(key);
\r
2308 this.removeItem(item);
\r
2313 if (!this._head && !this._tail) {
\r
2316 if (!this._head || !this._tail) {
\r
2317 throw new Error('Invalid list');
\r
2319 const item = this._head;
\r
2320 this._map.delete(item.key);
\r
2321 this.removeItem(item);
\r
2323 return item.value;
\r
2325 forEach(callbackfn, thisArg) {
\r
2326 let current = this._head;
\r
2329 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2332 callbackfn(current.value, current.key, this);
\r
2334 current = current.next;
\r
2337 forEachReverse(callbackfn, thisArg) {
\r
2338 let current = this._tail;
\r
2341 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2344 callbackfn(current.value, current.key, this);
\r
2346 current = current.previous;
\r
2351 let current = this._head;
\r
2353 result.push(current.value);
\r
2354 current = current.next;
\r
2360 let current = this._head;
\r
2362 result.push(current.key);
\r
2363 current = current.next;
\r
2367 /* JSON RPC run on es5 which has no Symbol.iterator
\r
2368 public keys(): IterableIterator<K> {
\r
2369 let current = this._head;
\r
2370 let iterator: IterableIterator<K> = {
\r
2371 [Symbol.iterator]() {
\r
2374 next():IteratorResult<K> {
\r
2376 let result = { value: current.key, done: false };
\r
2377 current = current.next;
\r
2380 return { value: undefined, done: true };
\r
2387 public values(): IterableIterator<V> {
\r
2388 let current = this._head;
\r
2389 let iterator: IterableIterator<V> = {
\r
2390 [Symbol.iterator]() {
\r
2393 next():IteratorResult<V> {
\r
2395 let result = { value: current.value, done: false };
\r
2396 current = current.next;
\r
2399 return { value: undefined, done: true };
\r
2406 addItemFirst(item) {
\r
2407 // First time Insert
\r
2408 if (!this._head && !this._tail) {
\r
2409 this._tail = item;
\r
2411 else if (!this._head) {
\r
2412 throw new Error('Invalid list');
\r
2415 item.next = this._head;
\r
2416 this._head.previous = item;
\r
2418 this._head = item;
\r
2420 addItemLast(item) {
\r
2421 // First time Insert
\r
2422 if (!this._head && !this._tail) {
\r
2423 this._head = item;
\r
2425 else if (!this._tail) {
\r
2426 throw new Error('Invalid list');
\r
2429 item.previous = this._tail;
\r
2430 this._tail.next = item;
\r
2432 this._tail = item;
\r
2434 removeItem(item) {
\r
2435 if (item === this._head && item === this._tail) {
\r
2436 this._head = undefined;
\r
2437 this._tail = undefined;
\r
2439 else if (item === this._head) {
\r
2440 this._head = item.next;
\r
2442 else if (item === this._tail) {
\r
2443 this._tail = item.previous;
\r
2446 const next = item.next;
\r
2447 const previous = item.previous;
\r
2448 if (!next || !previous) {
\r
2449 throw new Error('Invalid list');
\r
2451 next.previous = previous;
\r
2452 previous.next = next;
\r
2455 touch(item, touch) {
\r
2456 if (!this._head || !this._tail) {
\r
2457 throw new Error('Invalid list');
\r
2459 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
2462 if (touch === Touch.First) {
\r
2463 if (item === this._head) {
\r
2466 const next = item.next;
\r
2467 const previous = item.previous;
\r
2468 // Unlink the item
\r
2469 if (item === this._tail) {
\r
2470 // previous must be defined since item was not head but is tail
\r
2471 // So there are more than on item in the map
\r
2472 previous.next = undefined;
\r
2473 this._tail = previous;
\r
2476 // Both next and previous are not undefined since item was neither head nor tail.
\r
2477 next.previous = previous;
\r
2478 previous.next = next;
\r
2480 // Insert the node at head
\r
2481 item.previous = undefined;
\r
2482 item.next = this._head;
\r
2483 this._head.previous = item;
\r
2484 this._head = item;
\r
2486 else if (touch === Touch.Last) {
\r
2487 if (item === this._tail) {
\r
2490 const next = item.next;
\r
2491 const previous = item.previous;
\r
2492 // Unlink the item.
\r
2493 if (item === this._head) {
\r
2494 // next must be defined since item was not tail but is head
\r
2495 // So there are more than on item in the map
\r
2496 next.previous = undefined;
\r
2497 this._head = next;
\r
2500 // Both next and previous are not undefined since item was neither head nor tail.
\r
2501 next.previous = previous;
\r
2502 previous.next = next;
\r
2504 item.next = undefined;
\r
2505 item.previous = this._tail;
\r
2506 this._tail.next = item;
\r
2507 this._tail = item;
\r
2511 exports.LinkedMap = LinkedMap;
\r
2516 /***/ (function(module, exports, __webpack_require__) {
2519 /* --------------------------------------------------------------------------------------------
\r
2520 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2521 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2522 * ------------------------------------------------------------------------------------------ */
\r
2524 Object.defineProperty(exports, "__esModule", { value: true });
\r
2525 const path_1 = __webpack_require__(3);
\r
2526 const os_1 = __webpack_require__(14);
\r
2527 const crypto_1 = __webpack_require__(15);
\r
2528 const net_1 = __webpack_require__(16);
\r
2529 const messageReader_1 = __webpack_require__(8);
\r
2530 const messageWriter_1 = __webpack_require__(10);
\r
2531 function generateRandomPipeName() {
\r
2532 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
\r
2533 if (process.platform === 'win32') {
\r
2534 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
\r
2537 // Mac/Unix: use socket file
\r
2538 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\r
2541 exports.generateRandomPipeName = generateRandomPipeName;
\r
2542 function createClientPipeTransport(pipeName, encoding = 'utf-8') {
\r
2543 let connectResolve;
\r
2544 let connected = new Promise((resolve, _reject) => {
\r
2545 connectResolve = resolve;
\r
2547 return new Promise((resolve, reject) => {
\r
2548 let server = net_1.createServer((socket) => {
\r
2551 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2552 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2555 server.on('error', reject);
\r
2556 server.listen(pipeName, () => {
\r
2557 server.removeListener('error', reject);
\r
2559 onConnected: () => { return connected; }
\r
2564 exports.createClientPipeTransport = createClientPipeTransport;
\r
2565 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
2566 const socket = net_1.createConnection(pipeName);
\r
2568 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2569 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2572 exports.createServerPipeTransport = createServerPipeTransport;
\r
2577 /***/ (function(module, exports) {
2579 module.exports = require("os");
2583 /***/ (function(module, exports) {
2585 module.exports = require("crypto");
2589 /***/ (function(module, exports) {
2591 module.exports = require("net");
2595 /***/ (function(module, exports, __webpack_require__) {
2598 /* --------------------------------------------------------------------------------------------
\r
2599 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2600 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2601 * ------------------------------------------------------------------------------------------ */
\r
2603 Object.defineProperty(exports, "__esModule", { value: true });
\r
2604 const net_1 = __webpack_require__(16);
\r
2605 const messageReader_1 = __webpack_require__(8);
\r
2606 const messageWriter_1 = __webpack_require__(10);
\r
2607 function createClientSocketTransport(port, encoding = 'utf-8') {
\r
2608 let connectResolve;
\r
2609 let connected = new Promise((resolve, _reject) => {
\r
2610 connectResolve = resolve;
\r
2612 return new Promise((resolve, reject) => {
\r
2613 let server = net_1.createServer((socket) => {
\r
2616 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2617 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2620 server.on('error', reject);
\r
2621 server.listen(port, '127.0.0.1', () => {
\r
2622 server.removeListener('error', reject);
\r
2624 onConnected: () => { return connected; }
\r
2629 exports.createClientSocketTransport = createClientSocketTransport;
\r
2630 function createServerSocketTransport(port, encoding = 'utf-8') {
\r
2631 const socket = net_1.createConnection(port, '127.0.0.1');
\r
2633 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2634 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2637 exports.createServerSocketTransport = createServerSocketTransport;
\r
2642 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2645 __webpack_require__.r(__webpack_exports__);
2646 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2647 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2648 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2649 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2650 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2651 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2652 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2653 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2654 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2655 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2656 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2657 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
2658 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2659 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2660 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2661 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2662 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2663 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2664 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2665 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2666 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2667 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2668 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2669 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2670 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2671 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2672 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2673 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2674 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2675 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2676 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2677 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2678 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2679 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2680 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2681 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2682 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2683 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2684 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2685 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2686 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2687 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2688 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2689 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2690 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2691 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
2692 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2693 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2694 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
2695 /* --------------------------------------------------------------------------------------------
2696 * Copyright (c) Microsoft Corporation. All rights reserved.
2697 * Licensed under the MIT License. See License.txt in the project root for license information.
2698 * ------------------------------------------------------------------------------------------ */
2701 * The Position namespace provides helper functions to work with
2702 * [Position](#Position) literals.
2705 (function (Position) {
2707 * Creates a new Position literal from the given line and character.
2708 * @param line The position's line.
2709 * @param character The position's character.
2711 function create(line, character) {
2712 return { line: line, character: character };
2714 Position.create = create;
2716 * Checks whether the given liternal conforms to the [Position](#Position) interface.
2718 function is(value) {
2719 var candidate = value;
2720 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
2723 })(Position || (Position = {}));
2725 * The Range namespace provides helper functions to work with
2726 * [Range](#Range) literals.
2730 function create(one, two, three, four) {
2731 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
2732 return { start: Position.create(one, two), end: Position.create(three, four) };
2734 else if (Position.is(one) && Position.is(two)) {
2735 return { start: one, end: two };
2738 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
2741 Range.create = create;
2743 * Checks whether the given literal conforms to the [Range](#Range) interface.
2745 function is(value) {
2746 var candidate = value;
2747 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
2750 })(Range || (Range = {}));
2752 * The Location namespace provides helper functions to work with
2753 * [Location](#Location) literals.
2756 (function (Location) {
2758 * Creates a Location literal.
2759 * @param uri The location's uri.
2760 * @param range The location's range.
2762 function create(uri, range) {
2763 return { uri: uri, range: range };
2765 Location.create = create;
2767 * Checks whether the given literal conforms to the [Location](#Location) interface.
2769 function is(value) {
2770 var candidate = value;
2771 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
2774 })(Location || (Location = {}));
2776 * The LocationLink namespace provides helper functions to work with
2777 * [LocationLink](#LocationLink) literals.
2780 (function (LocationLink) {
2782 * Creates a LocationLink literal.
2783 * @param targetUri The definition's uri.
2784 * @param targetRange The full range of the definition.
2785 * @param targetSelectionRange The span of the symbol definition at the target.
2786 * @param originSelectionRange The span of the symbol being defined in the originating source file.
2788 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
2789 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
2791 LocationLink.create = create;
2793 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
2795 function is(value) {
2796 var candidate = value;
2797 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
2798 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
2799 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
2801 LocationLink.is = is;
2802 })(LocationLink || (LocationLink = {}));
2804 * The Color namespace provides helper functions to work with
2805 * [Color](#Color) literals.
2810 * Creates a new Color literal.
2812 function create(red, green, blue, alpha) {
2820 Color.create = create;
2822 * Checks whether the given literal conforms to the [Color](#Color) interface.
2824 function is(value) {
2825 var candidate = value;
2826 return Is.number(candidate.red)
2827 && Is.number(candidate.green)
2828 && Is.number(candidate.blue)
2829 && Is.number(candidate.alpha);
2832 })(Color || (Color = {}));
2834 * The ColorInformation namespace provides helper functions to work with
2835 * [ColorInformation](#ColorInformation) literals.
2837 var ColorInformation;
2838 (function (ColorInformation) {
2840 * Creates a new ColorInformation literal.
2842 function create(range, color) {
2848 ColorInformation.create = create;
2850 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
2852 function is(value) {
2853 var candidate = value;
2854 return Range.is(candidate.range) && Color.is(candidate.color);
2856 ColorInformation.is = is;
2857 })(ColorInformation || (ColorInformation = {}));
2859 * The Color namespace provides helper functions to work with
2860 * [ColorPresentation](#ColorPresentation) literals.
2862 var ColorPresentation;
2863 (function (ColorPresentation) {
2865 * Creates a new ColorInformation literal.
2867 function create(label, textEdit, additionalTextEdits) {
2871 additionalTextEdits: additionalTextEdits,
2874 ColorPresentation.create = create;
2876 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
2878 function is(value) {
2879 var candidate = value;
2880 return Is.string(candidate.label)
2881 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
2882 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
2884 ColorPresentation.is = is;
2885 })(ColorPresentation || (ColorPresentation = {}));
2887 * Enum of known range kinds
2889 var FoldingRangeKind;
2890 (function (FoldingRangeKind) {
2892 * Folding range for a comment
2894 FoldingRangeKind["Comment"] = "comment";
2896 * Folding range for a imports or includes
2898 FoldingRangeKind["Imports"] = "imports";
2900 * Folding range for a region (e.g. `#region`)
2902 FoldingRangeKind["Region"] = "region";
2903 })(FoldingRangeKind || (FoldingRangeKind = {}));
2905 * The folding range namespace provides helper functions to work with
2906 * [FoldingRange](#FoldingRange) literals.
2909 (function (FoldingRange) {
2911 * Creates a new FoldingRange literal.
2913 function create(startLine, endLine, startCharacter, endCharacter, kind) {
2915 startLine: startLine,
2918 if (Is.defined(startCharacter)) {
2919 result.startCharacter = startCharacter;
2921 if (Is.defined(endCharacter)) {
2922 result.endCharacter = endCharacter;
2924 if (Is.defined(kind)) {
2929 FoldingRange.create = create;
2931 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
2933 function is(value) {
2934 var candidate = value;
2935 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
2936 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
2937 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
2938 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
2940 FoldingRange.is = is;
2941 })(FoldingRange || (FoldingRange = {}));
2943 * The DiagnosticRelatedInformation namespace provides helper functions to work with
2944 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
2946 var DiagnosticRelatedInformation;
2947 (function (DiagnosticRelatedInformation) {
2949 * Creates a new DiagnosticRelatedInformation literal.
2951 function create(location, message) {
2957 DiagnosticRelatedInformation.create = create;
2959 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
2961 function is(value) {
2962 var candidate = value;
2963 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
2965 DiagnosticRelatedInformation.is = is;
2966 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
2968 * The diagnostic's severity.
2970 var DiagnosticSeverity;
2971 (function (DiagnosticSeverity) {
2975 DiagnosticSeverity.Error = 1;
2977 * Reports a warning.
2979 DiagnosticSeverity.Warning = 2;
2981 * Reports an information.
2983 DiagnosticSeverity.Information = 3;
2987 DiagnosticSeverity.Hint = 4;
2988 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
2990 (function (DiagnosticTag) {
2992 * Unused or unnecessary code.
2994 * Clients are allowed to render diagnostics with this tag faded out instead of having
2995 * an error squiggle.
2997 DiagnosticTag.Unnecessary = 1;
2998 })(DiagnosticTag || (DiagnosticTag = {}));
3000 * The Diagnostic namespace provides helper functions to work with
3001 * [Diagnostic](#Diagnostic) literals.
3004 (function (Diagnostic) {
3006 * Creates a new Diagnostic literal.
3008 function create(range, message, severity, code, source, relatedInformation) {
3009 var result = { range: range, message: message };
3010 if (Is.defined(severity)) {
3011 result.severity = severity;
3013 if (Is.defined(code)) {
3016 if (Is.defined(source)) {
3017 result.source = source;
3019 if (Is.defined(relatedInformation)) {
3020 result.relatedInformation = relatedInformation;
3024 Diagnostic.create = create;
3026 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
3028 function is(value) {
3029 var candidate = value;
3030 return Is.defined(candidate)
3031 && Range.is(candidate.range)
3032 && Is.string(candidate.message)
3033 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
3034 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
3035 && (Is.string(candidate.source) || Is.undefined(candidate.source))
3036 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
3039 })(Diagnostic || (Diagnostic = {}));
3041 * The Command namespace provides helper functions to work with
3042 * [Command](#Command) literals.
3045 (function (Command) {
3047 * Creates a new Command literal.
3049 function create(title, command) {
3051 for (var _i = 2; _i < arguments.length; _i++) {
3052 args[_i - 2] = arguments[_i];
3054 var result = { title: title, command: command };
3055 if (Is.defined(args) && args.length > 0) {
3056 result.arguments = args;
3060 Command.create = create;
3062 * Checks whether the given literal conforms to the [Command](#Command) interface.
3064 function is(value) {
3065 var candidate = value;
3066 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
3069 })(Command || (Command = {}));
3071 * The TextEdit namespace provides helper function to create replace,
3072 * insert and delete edits more easily.
3075 (function (TextEdit) {
3077 * Creates a replace text edit.
3078 * @param range The range of text to be replaced.
3079 * @param newText The new text.
3081 function replace(range, newText) {
3082 return { range: range, newText: newText };
3084 TextEdit.replace = replace;
3086 * Creates a insert text edit.
3087 * @param position The position to insert the text at.
3088 * @param newText The text to be inserted.
3090 function insert(position, newText) {
3091 return { range: { start: position, end: position }, newText: newText };
3093 TextEdit.insert = insert;
3095 * Creates a delete text edit.
3096 * @param range The range of text to be deleted.
3098 function del(range) {
3099 return { range: range, newText: '' };
3102 function is(value) {
3103 var candidate = value;
3104 return Is.objectLiteral(candidate)
3105 && Is.string(candidate.newText)
3106 && Range.is(candidate.range);
3109 })(TextEdit || (TextEdit = {}));
3111 * The TextDocumentEdit namespace provides helper function to create
3112 * an edit that manipulates a text document.
3114 var TextDocumentEdit;
3115 (function (TextDocumentEdit) {
3117 * Creates a new `TextDocumentEdit`
3119 function create(textDocument, edits) {
3120 return { textDocument: textDocument, edits: edits };
3122 TextDocumentEdit.create = create;
3123 function is(value) {
3124 var candidate = value;
3125 return Is.defined(candidate)
3126 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
3127 && Array.isArray(candidate.edits);
3129 TextDocumentEdit.is = is;
3130 })(TextDocumentEdit || (TextDocumentEdit = {}));
3132 (function (CreateFile) {
3133 function create(uri, options) {
3138 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
3139 result.options = options;
3143 CreateFile.create = create;
3144 function is(value) {
3145 var candidate = value;
3146 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
3147 (candidate.options === void 0 ||
3148 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
3151 })(CreateFile || (CreateFile = {}));
3153 (function (RenameFile) {
3154 function create(oldUri, newUri, options) {
3160 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
3161 result.options = options;
3165 RenameFile.create = create;
3166 function is(value) {
3167 var candidate = value;
3168 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
3169 (candidate.options === void 0 ||
3170 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
3173 })(RenameFile || (RenameFile = {}));
3175 (function (DeleteFile) {
3176 function create(uri, options) {
3181 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
3182 result.options = options;
3186 DeleteFile.create = create;
3187 function is(value) {
3188 var candidate = value;
3189 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
3190 (candidate.options === void 0 ||
3191 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
3194 })(DeleteFile || (DeleteFile = {}));
3196 (function (WorkspaceEdit) {
3197 function is(value) {
3198 var candidate = value;
3200 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
3201 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
3202 if (Is.string(change.kind)) {
3203 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
3206 return TextDocumentEdit.is(change);
3210 WorkspaceEdit.is = is;
3211 })(WorkspaceEdit || (WorkspaceEdit = {}));
3212 var TextEditChangeImpl = /** @class */ (function () {
3213 function TextEditChangeImpl(edits) {
3216 TextEditChangeImpl.prototype.insert = function (position, newText) {
3217 this.edits.push(TextEdit.insert(position, newText));
3219 TextEditChangeImpl.prototype.replace = function (range, newText) {
3220 this.edits.push(TextEdit.replace(range, newText));
3222 TextEditChangeImpl.prototype.delete = function (range) {
3223 this.edits.push(TextEdit.del(range));
3225 TextEditChangeImpl.prototype.add = function (edit) {
3226 this.edits.push(edit);
3228 TextEditChangeImpl.prototype.all = function () {
3231 TextEditChangeImpl.prototype.clear = function () {
3232 this.edits.splice(0, this.edits.length);
3234 return TextEditChangeImpl;
3237 * A workspace change helps constructing changes to a workspace.
3239 var WorkspaceChange = /** @class */ (function () {
3240 function WorkspaceChange(workspaceEdit) {
3242 this._textEditChanges = Object.create(null);
3243 if (workspaceEdit) {
3244 this._workspaceEdit = workspaceEdit;
3245 if (workspaceEdit.documentChanges) {
3246 workspaceEdit.documentChanges.forEach(function (change) {
3247 if (TextDocumentEdit.is(change)) {
3248 var textEditChange = new TextEditChangeImpl(change.edits);
3249 _this._textEditChanges[change.textDocument.uri] = textEditChange;
3253 else if (workspaceEdit.changes) {
3254 Object.keys(workspaceEdit.changes).forEach(function (key) {
3255 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
3256 _this._textEditChanges[key] = textEditChange;
3261 Object.defineProperty(WorkspaceChange.prototype, "edit", {
3263 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
3264 * use to be returned from a workspace edit operation like rename.
3267 return this._workspaceEdit;
3272 WorkspaceChange.prototype.getTextEditChange = function (key) {
3273 if (VersionedTextDocumentIdentifier.is(key)) {
3274 if (!this._workspaceEdit) {
3275 this._workspaceEdit = {
3279 if (!this._workspaceEdit.documentChanges) {
3280 throw new Error('Workspace edit is not configured for document changes.');
3282 var textDocument = key;
3283 var result = this._textEditChanges[textDocument.uri];
3286 var textDocumentEdit = {
3287 textDocument: textDocument,
3290 this._workspaceEdit.documentChanges.push(textDocumentEdit);
3291 result = new TextEditChangeImpl(edits);
3292 this._textEditChanges[textDocument.uri] = result;
3297 if (!this._workspaceEdit) {
3298 this._workspaceEdit = {
3299 changes: Object.create(null)
3302 if (!this._workspaceEdit.changes) {
3303 throw new Error('Workspace edit is not configured for normal text edit changes.');
3305 var result = this._textEditChanges[key];
3308 this._workspaceEdit.changes[key] = edits;
3309 result = new TextEditChangeImpl(edits);
3310 this._textEditChanges[key] = result;
3315 WorkspaceChange.prototype.createFile = function (uri, options) {
3316 this.checkDocumentChanges();
3317 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
3319 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
3320 this.checkDocumentChanges();
3321 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
3323 WorkspaceChange.prototype.deleteFile = function (uri, options) {
3324 this.checkDocumentChanges();
3325 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
3327 WorkspaceChange.prototype.checkDocumentChanges = function () {
3328 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
3329 throw new Error('Workspace edit is not configured for document changes.');
3332 return WorkspaceChange;
3336 * The TextDocumentIdentifier namespace provides helper functions to work with
3337 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
3339 var TextDocumentIdentifier;
3340 (function (TextDocumentIdentifier) {
3342 * Creates a new TextDocumentIdentifier literal.
3343 * @param uri The document's uri.
3345 function create(uri) {
3346 return { uri: uri };
3348 TextDocumentIdentifier.create = create;
3350 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
3352 function is(value) {
3353 var candidate = value;
3354 return Is.defined(candidate) && Is.string(candidate.uri);
3356 TextDocumentIdentifier.is = is;
3357 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
3359 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
3360 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
3362 var VersionedTextDocumentIdentifier;
3363 (function (VersionedTextDocumentIdentifier) {
3365 * Creates a new VersionedTextDocumentIdentifier literal.
3366 * @param uri The document's uri.
3367 * @param uri The document's text.
3369 function create(uri, version) {
3370 return { uri: uri, version: version };
3372 VersionedTextDocumentIdentifier.create = create;
3374 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
3376 function is(value) {
3377 var candidate = value;
3378 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
3380 VersionedTextDocumentIdentifier.is = is;
3381 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
3383 * The TextDocumentItem namespace provides helper functions to work with
3384 * [TextDocumentItem](#TextDocumentItem) literals.
3386 var TextDocumentItem;
3387 (function (TextDocumentItem) {
3389 * Creates a new TextDocumentItem literal.
3390 * @param uri The document's uri.
3391 * @param languageId The document's language identifier.
3392 * @param version The document's version number.
3393 * @param text The document's text.
3395 function create(uri, languageId, version, text) {
3396 return { uri: uri, languageId: languageId, version: version, text: text };
3398 TextDocumentItem.create = create;
3400 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
3402 function is(value) {
3403 var candidate = value;
3404 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
3406 TextDocumentItem.is = is;
3407 })(TextDocumentItem || (TextDocumentItem = {}));
3409 * Describes the content type that a client supports in various
3410 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
3412 * Please note that `MarkupKinds` must not start with a `$`. This kinds
3413 * are reserved for internal usage.
3416 (function (MarkupKind) {
3418 * Plain text is supported as a content format
3420 MarkupKind.PlainText = 'plaintext';
3422 * Markdown is supported as a content format
3424 MarkupKind.Markdown = 'markdown';
3425 })(MarkupKind || (MarkupKind = {}));
3426 (function (MarkupKind) {
3428 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
3430 function is(value) {
3431 var candidate = value;
3432 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
3435 })(MarkupKind || (MarkupKind = {}));
3437 (function (MarkupContent) {
3439 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
3441 function is(value) {
3442 var candidate = value;
3443 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
3445 MarkupContent.is = is;
3446 })(MarkupContent || (MarkupContent = {}));
3448 * The kind of a completion entry.
3450 var CompletionItemKind;
3451 (function (CompletionItemKind) {
3452 CompletionItemKind.Text = 1;
3453 CompletionItemKind.Method = 2;
3454 CompletionItemKind.Function = 3;
3455 CompletionItemKind.Constructor = 4;
3456 CompletionItemKind.Field = 5;
3457 CompletionItemKind.Variable = 6;
3458 CompletionItemKind.Class = 7;
3459 CompletionItemKind.Interface = 8;
3460 CompletionItemKind.Module = 9;
3461 CompletionItemKind.Property = 10;
3462 CompletionItemKind.Unit = 11;
3463 CompletionItemKind.Value = 12;
3464 CompletionItemKind.Enum = 13;
3465 CompletionItemKind.Keyword = 14;
3466 CompletionItemKind.Snippet = 15;
3467 CompletionItemKind.Color = 16;
3468 CompletionItemKind.File = 17;
3469 CompletionItemKind.Reference = 18;
3470 CompletionItemKind.Folder = 19;
3471 CompletionItemKind.EnumMember = 20;
3472 CompletionItemKind.Constant = 21;
3473 CompletionItemKind.Struct = 22;
3474 CompletionItemKind.Event = 23;
3475 CompletionItemKind.Operator = 24;
3476 CompletionItemKind.TypeParameter = 25;
3477 })(CompletionItemKind || (CompletionItemKind = {}));
3479 * Defines whether the insert text in a completion item should be interpreted as
3480 * plain text or a snippet.
3482 var InsertTextFormat;
3483 (function (InsertTextFormat) {
3485 * The primary text to be inserted is treated as a plain string.
3487 InsertTextFormat.PlainText = 1;
3489 * The primary text to be inserted is treated as a snippet.
3491 * A snippet can define tab stops and placeholders with `$1`, `$2`
3492 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
3493 * the end of the snippet. Placeholders with equal identifiers are linked,
3494 * that is typing in one will update others too.
3496 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
3498 InsertTextFormat.Snippet = 2;
3499 })(InsertTextFormat || (InsertTextFormat = {}));
3501 * The CompletionItem namespace provides functions to deal with
3505 (function (CompletionItem) {
3507 * Create a completion item and seed it with a label.
3508 * @param label The completion item's label
3510 function create(label) {
3511 return { label: label };
3513 CompletionItem.create = create;
3514 })(CompletionItem || (CompletionItem = {}));
3516 * The CompletionList namespace provides functions to deal with
3520 (function (CompletionList) {
3522 * Creates a new completion list.
3524 * @param items The completion items.
3525 * @param isIncomplete The list is not complete.
3527 function create(items, isIncomplete) {
3528 return { items: items ? items : [], isIncomplete: !!isIncomplete };
3530 CompletionList.create = create;
3531 })(CompletionList || (CompletionList = {}));
3533 (function (MarkedString) {
3535 * Creates a marked string from plain text.
3537 * @param plainText The plain text.
3539 function fromPlainText(plainText) {
3540 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
3542 MarkedString.fromPlainText = fromPlainText;
3544 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
3546 function is(value) {
3547 var candidate = value;
3548 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
3550 MarkedString.is = is;
3551 })(MarkedString || (MarkedString = {}));
3555 * Checks whether the given value conforms to the [Hover](#Hover) interface.
3557 function is(value) {
3558 var candidate = value;
3559 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
3560 MarkedString.is(candidate.contents) ||
3561 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
3564 })(Hover || (Hover = {}));
3566 * The ParameterInformation namespace provides helper functions to work with
3567 * [ParameterInformation](#ParameterInformation) literals.
3569 var ParameterInformation;
3570 (function (ParameterInformation) {
3572 * Creates a new parameter information literal.
3574 * @param label A label string.
3575 * @param documentation A doc string.
3577 function create(label, documentation) {
3578 return documentation ? { label: label, documentation: documentation } : { label: label };
3580 ParameterInformation.create = create;
3582 })(ParameterInformation || (ParameterInformation = {}));
3584 * The SignatureInformation namespace provides helper functions to work with
3585 * [SignatureInformation](#SignatureInformation) literals.
3587 var SignatureInformation;
3588 (function (SignatureInformation) {
3589 function create(label, documentation) {
3590 var parameters = [];
3591 for (var _i = 2; _i < arguments.length; _i++) {
3592 parameters[_i - 2] = arguments[_i];
3594 var result = { label: label };
3595 if (Is.defined(documentation)) {
3596 result.documentation = documentation;
3598 if (Is.defined(parameters)) {
3599 result.parameters = parameters;
3602 result.parameters = [];
3606 SignatureInformation.create = create;
3607 })(SignatureInformation || (SignatureInformation = {}));
3609 * A document highlight kind.
3611 var DocumentHighlightKind;
3612 (function (DocumentHighlightKind) {
3614 * A textual occurrence.
3616 DocumentHighlightKind.Text = 1;
3618 * Read-access of a symbol, like reading a variable.
3620 DocumentHighlightKind.Read = 2;
3622 * Write-access of a symbol, like writing to a variable.
3624 DocumentHighlightKind.Write = 3;
3625 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
3627 * DocumentHighlight namespace to provide helper functions to work with
3628 * [DocumentHighlight](#DocumentHighlight) literals.
3630 var DocumentHighlight;
3631 (function (DocumentHighlight) {
3633 * Create a DocumentHighlight object.
3634 * @param range The range the highlight applies to.
3636 function create(range, kind) {
3637 var result = { range: range };
3638 if (Is.number(kind)) {
3643 DocumentHighlight.create = create;
3644 })(DocumentHighlight || (DocumentHighlight = {}));
3649 (function (SymbolKind) {
3650 SymbolKind.File = 1;
3651 SymbolKind.Module = 2;
3652 SymbolKind.Namespace = 3;
3653 SymbolKind.Package = 4;
3654 SymbolKind.Class = 5;
3655 SymbolKind.Method = 6;
3656 SymbolKind.Property = 7;
3657 SymbolKind.Field = 8;
3658 SymbolKind.Constructor = 9;
3659 SymbolKind.Enum = 10;
3660 SymbolKind.Interface = 11;
3661 SymbolKind.Function = 12;
3662 SymbolKind.Variable = 13;
3663 SymbolKind.Constant = 14;
3664 SymbolKind.String = 15;
3665 SymbolKind.Number = 16;
3666 SymbolKind.Boolean = 17;
3667 SymbolKind.Array = 18;
3668 SymbolKind.Object = 19;
3669 SymbolKind.Key = 20;
3670 SymbolKind.Null = 21;
3671 SymbolKind.EnumMember = 22;
3672 SymbolKind.Struct = 23;
3673 SymbolKind.Event = 24;
3674 SymbolKind.Operator = 25;
3675 SymbolKind.TypeParameter = 26;
3676 })(SymbolKind || (SymbolKind = {}));
3677 var SymbolInformation;
3678 (function (SymbolInformation) {
3680 * Creates a new symbol information literal.
3682 * @param name The name of the symbol.
3683 * @param kind The kind of the symbol.
3684 * @param range The range of the location of the symbol.
3685 * @param uri The resource of the location of symbol, defaults to the current document.
3686 * @param containerName The name of the symbol containing the symbol.
3688 function create(name, kind, range, uri, containerName) {
3692 location: { uri: uri, range: range }
3694 if (containerName) {
3695 result.containerName = containerName;
3699 SymbolInformation.create = create;
3700 })(SymbolInformation || (SymbolInformation = {}));
3702 * Represents programming constructs like variables, classes, interfaces etc.
3703 * that appear in a document. Document symbols can be hierarchical and they
3704 * have two ranges: one that encloses its definition and one that points to
3705 * its most interesting range, e.g. the range of an identifier.
3707 var DocumentSymbol = /** @class */ (function () {
3708 function DocumentSymbol() {
3710 return DocumentSymbol;
3713 (function (DocumentSymbol) {
3715 * Creates a new symbol information literal.
3717 * @param name The name of the symbol.
3718 * @param detail The detail of the symbol.
3719 * @param kind The kind of the symbol.
3720 * @param range The range of the symbol.
3721 * @param selectionRange The selectionRange of the symbol.
3722 * @param children Children of the symbol.
3724 function create(name, detail, kind, range, selectionRange, children) {
3730 selectionRange: selectionRange
3732 if (children !== void 0) {
3733 result.children = children;
3737 DocumentSymbol.create = create;
3739 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
3741 function is(value) {
3742 var candidate = value;
3744 Is.string(candidate.name) && Is.number(candidate.kind) &&
3745 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
3746 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
3747 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
3748 (candidate.children === void 0 || Array.isArray(candidate.children));
3750 DocumentSymbol.is = is;
3751 })(DocumentSymbol || (DocumentSymbol = {}));
3753 * A set of predefined code action kinds
3756 (function (CodeActionKind) {
3758 * Base kind for quickfix actions: 'quickfix'
3760 CodeActionKind.QuickFix = 'quickfix';
3762 * Base kind for refactoring actions: 'refactor'
3764 CodeActionKind.Refactor = 'refactor';
3766 * Base kind for refactoring extraction actions: 'refactor.extract'
3768 * Example extract actions:
3771 * - Extract function
3772 * - Extract variable
3773 * - Extract interface from class
3776 CodeActionKind.RefactorExtract = 'refactor.extract';
3778 * Base kind for refactoring inline actions: 'refactor.inline'
3780 * Example inline actions:
3787 CodeActionKind.RefactorInline = 'refactor.inline';
3789 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
3791 * Example rewrite actions:
3793 * - Convert JavaScript function to class
3794 * - Add or remove parameter
3795 * - Encapsulate field
3796 * - Make method static
3797 * - Move method to base class
3800 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
3802 * Base kind for source actions: `source`
3804 * Source code actions apply to the entire file.
3806 CodeActionKind.Source = 'source';
3808 * Base kind for an organize imports source action: `source.organizeImports`
3810 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
3811 })(CodeActionKind || (CodeActionKind = {}));
3813 * The CodeActionContext namespace provides helper functions to work with
3814 * [CodeActionContext](#CodeActionContext) literals.
3816 var CodeActionContext;
3817 (function (CodeActionContext) {
3819 * Creates a new CodeActionContext literal.
3821 function create(diagnostics, only) {
3822 var result = { diagnostics: diagnostics };
3823 if (only !== void 0 && only !== null) {
3828 CodeActionContext.create = create;
3830 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
3832 function is(value) {
3833 var candidate = value;
3834 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
3836 CodeActionContext.is = is;
3837 })(CodeActionContext || (CodeActionContext = {}));
3839 (function (CodeAction) {
3840 function create(title, commandOrEdit, kind) {
3841 var result = { title: title };
3842 if (Command.is(commandOrEdit)) {
3843 result.command = commandOrEdit;
3846 result.edit = commandOrEdit;
3848 if (kind !== void null) {
3853 CodeAction.create = create;
3854 function is(value) {
3855 var candidate = value;
3856 return candidate && Is.string(candidate.title) &&
3857 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
3858 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
3859 (candidate.edit !== void 0 || candidate.command !== void 0) &&
3860 (candidate.command === void 0 || Command.is(candidate.command)) &&
3861 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
3864 })(CodeAction || (CodeAction = {}));
3866 * The CodeLens namespace provides helper functions to work with
3867 * [CodeLens](#CodeLens) literals.
3870 (function (CodeLens) {
3872 * Creates a new CodeLens literal.
3874 function create(range, data) {
3875 var result = { range: range };
3876 if (Is.defined(data))
3880 CodeLens.create = create;
3882 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
3884 function is(value) {
3885 var candidate = value;
3886 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
3889 })(CodeLens || (CodeLens = {}));
3891 * The FormattingOptions namespace provides helper functions to work with
3892 * [FormattingOptions](#FormattingOptions) literals.
3894 var FormattingOptions;
3895 (function (FormattingOptions) {
3897 * Creates a new FormattingOptions literal.
3899 function create(tabSize, insertSpaces) {
3900 return { tabSize: tabSize, insertSpaces: insertSpaces };
3902 FormattingOptions.create = create;
3904 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
3906 function is(value) {
3907 var candidate = value;
3908 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
3910 FormattingOptions.is = is;
3911 })(FormattingOptions || (FormattingOptions = {}));
3913 * A document link is a range in a text document that links to an internal or external resource, like another
3914 * text document or a web site.
3916 var DocumentLink = /** @class */ (function () {
3917 function DocumentLink() {
3919 return DocumentLink;
3923 * The DocumentLink namespace provides helper functions to work with
3924 * [DocumentLink](#DocumentLink) literals.
3926 (function (DocumentLink) {
3928 * Creates a new DocumentLink literal.
3930 function create(range, target, data) {
3931 return { range: range, target: target, data: data };
3933 DocumentLink.create = create;
3935 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
3937 function is(value) {
3938 var candidate = value;
3939 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
3941 DocumentLink.is = is;
3942 })(DocumentLink || (DocumentLink = {}));
3944 * The SelectionRange namespace provides helper function to work with
3945 * SelectionRange literals.
3948 (function (SelectionRange) {
3950 * Creates a new SelectionRange
3951 * @param range the range.
3952 * @param parent an optional parent.
3954 function create(range, parent) {
3955 return { range: range, parent: parent };
3957 SelectionRange.create = create;
3958 function is(value) {
3959 var candidate = value;
3960 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
3962 SelectionRange.is = is;
3963 })(SelectionRange || (SelectionRange = {}));
3964 var EOL = ['\n', '\r\n', '\r'];
3966 (function (TextDocument) {
3968 * Creates a new ITextDocument literal from the given uri and content.
3969 * @param uri The document's uri.
3970 * @param languageId The document's language Id.
3971 * @param content The document's content.
3973 function create(uri, languageId, version, content) {
3974 return new FullTextDocument(uri, languageId, version, content);
3976 TextDocument.create = create;
3978 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
3980 function is(value) {
3981 var candidate = value;
3982 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
3983 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
3985 TextDocument.is = is;
3986 function applyEdits(document, edits) {
3987 var text = document.getText();
3988 var sortedEdits = mergeSort(edits, function (a, b) {
3989 var diff = a.range.start.line - b.range.start.line;
3991 return a.range.start.character - b.range.start.character;
3995 var lastModifiedOffset = text.length;
3996 for (var i = sortedEdits.length - 1; i >= 0; i--) {
3997 var e = sortedEdits[i];
3998 var startOffset = document.offsetAt(e.range.start);
3999 var endOffset = document.offsetAt(e.range.end);
4000 if (endOffset <= lastModifiedOffset) {
4001 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
4004 throw new Error('Overlapping edit');
4006 lastModifiedOffset = startOffset;
4010 TextDocument.applyEdits = applyEdits;
4011 function mergeSort(data, compare) {
4012 if (data.length <= 1) {
4016 var p = (data.length / 2) | 0;
4017 var left = data.slice(0, p);
4018 var right = data.slice(p);
4019 mergeSort(left, compare);
4020 mergeSort(right, compare);
4024 while (leftIdx < left.length && rightIdx < right.length) {
4025 var ret = compare(left[leftIdx], right[rightIdx]);
4027 // smaller_equal -> take left to preserve order
4028 data[i++] = left[leftIdx++];
4031 // greater -> take right
4032 data[i++] = right[rightIdx++];
4035 while (leftIdx < left.length) {
4036 data[i++] = left[leftIdx++];
4038 while (rightIdx < right.length) {
4039 data[i++] = right[rightIdx++];
4043 })(TextDocument || (TextDocument = {}));
4045 * Represents reasons why a text document is saved.
4047 var TextDocumentSaveReason;
4048 (function (TextDocumentSaveReason) {
4050 * Manually triggered, e.g. by the user pressing save, by starting debugging,
4051 * or by an API call.
4053 TextDocumentSaveReason.Manual = 1;
4055 * Automatic after a delay.
4057 TextDocumentSaveReason.AfterDelay = 2;
4059 * When the editor lost focus.
4061 TextDocumentSaveReason.FocusOut = 3;
4062 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));
4063 var FullTextDocument = /** @class */ (function () {
4064 function FullTextDocument(uri, languageId, version, content) {
4066 this._languageId = languageId;
4067 this._version = version;
4068 this._content = content;
4069 this._lineOffsets = null;
4071 Object.defineProperty(FullTextDocument.prototype, "uri", {
4078 Object.defineProperty(FullTextDocument.prototype, "languageId", {
4080 return this._languageId;
4085 Object.defineProperty(FullTextDocument.prototype, "version", {
4087 return this._version;
4092 FullTextDocument.prototype.getText = function (range) {
4094 var start = this.offsetAt(range.start);
4095 var end = this.offsetAt(range.end);
4096 return this._content.substring(start, end);
4098 return this._content;
4100 FullTextDocument.prototype.update = function (event, version) {
4101 this._content = event.text;
4102 this._version = version;
4103 this._lineOffsets = null;
4105 FullTextDocument.prototype.getLineOffsets = function () {
4106 if (this._lineOffsets === null) {
4107 var lineOffsets = [];
4108 var text = this._content;
4109 var isLineStart = true;
4110 for (var i = 0; i < text.length; i++) {
4112 lineOffsets.push(i);
4113 isLineStart = false;
4115 var ch = text.charAt(i);
4116 isLineStart = (ch === '\r' || ch === '\n');
4117 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
4121 if (isLineStart && text.length > 0) {
4122 lineOffsets.push(text.length);
4124 this._lineOffsets = lineOffsets;
4126 return this._lineOffsets;
4128 FullTextDocument.prototype.positionAt = function (offset) {
4129 offset = Math.max(Math.min(offset, this._content.length), 0);
4130 var lineOffsets = this.getLineOffsets();
4131 var low = 0, high = lineOffsets.length;
4133 return Position.create(0, offset);
4135 while (low < high) {
4136 var mid = Math.floor((low + high) / 2);
4137 if (lineOffsets[mid] > offset) {
4144 // low is the least x for which the line offset is larger than the current offset
4145 // or array.length if no line offset is larger than the current offset
4147 return Position.create(line, offset - lineOffsets[line]);
4149 FullTextDocument.prototype.offsetAt = function (position) {
4150 var lineOffsets = this.getLineOffsets();
4151 if (position.line >= lineOffsets.length) {
4152 return this._content.length;
4154 else if (position.line < 0) {
4157 var lineOffset = lineOffsets[position.line];
4158 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
4159 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
4161 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
4163 return this.getLineOffsets().length;
4168 return FullTextDocument;
4172 var toString = Object.prototype.toString;
4173 function defined(value) {
4174 return typeof value !== 'undefined';
4176 Is.defined = defined;
4177 function undefined(value) {
4178 return typeof value === 'undefined';
4180 Is.undefined = undefined;
4181 function boolean(value) {
4182 return value === true || value === false;
4184 Is.boolean = boolean;
4185 function string(value) {
4186 return toString.call(value) === '[object String]';
4189 function number(value) {
4190 return toString.call(value) === '[object Number]';
4193 function func(value) {
4194 return toString.call(value) === '[object Function]';
4197 function objectLiteral(value) {
4198 // Strictly speaking class instances pass this check as well. Since the LSP
4199 // doesn't use classes we ignore this for now. If we do we need to add something
4200 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
4201 return value !== null && typeof value === 'object';
4203 Is.objectLiteral = objectLiteral;
4204 function typedArray(value, check) {
4205 return Array.isArray(value) && value.every(check);
4207 Is.typedArray = typedArray;
4208 })(Is || (Is = {}));
4213 /***/ (function(module, exports, __webpack_require__) {
4216 /* --------------------------------------------------------------------------------------------
4217 * Copyright (c) Microsoft Corporation. All rights reserved.
4218 * Licensed under the MIT License. See License.txt in the project root for license information.
4219 * ------------------------------------------------------------------------------------------ */
4221 Object.defineProperty(exports, "__esModule", { value: true });
4222 const Is = __webpack_require__(20);
4223 const vscode_jsonrpc_1 = __webpack_require__(5);
4224 const protocol_implementation_1 = __webpack_require__(21);
4225 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
4226 const protocol_typeDefinition_1 = __webpack_require__(22);
4227 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
4228 const protocol_workspaceFolders_1 = __webpack_require__(23);
4229 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
4230 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
4231 const protocol_configuration_1 = __webpack_require__(24);
4232 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
4233 const protocol_colorProvider_1 = __webpack_require__(25);
4234 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
4235 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
4236 const protocol_foldingRange_1 = __webpack_require__(26);
4237 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
4238 const protocol_declaration_1 = __webpack_require__(27);
4239 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
4240 const protocol_selectionRange_1 = __webpack_require__(28);
4241 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
4242 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
4243 let __noDynamicImport;
4245 (function (DocumentFilter) {
4246 function is(value) {
4247 let candidate = value;
4248 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
4250 DocumentFilter.is = is;
4251 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
4253 * The `client/registerCapability` request is sent from the server to the client to register a new capability
4254 * handler on the client side.
4256 var RegistrationRequest;
4257 (function (RegistrationRequest) {
4258 RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');
4259 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
4261 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
4262 * handler on the client side.
4264 var UnregistrationRequest;
4265 (function (UnregistrationRequest) {
4266 UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');
4267 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
4268 var ResourceOperationKind;
4269 (function (ResourceOperationKind) {
4271 * Supports creating new files and folders.
4273 ResourceOperationKind.Create = 'create';
4275 * Supports renaming existing files and folders.
4277 ResourceOperationKind.Rename = 'rename';
4279 * Supports deleting existing files and folders.
4281 ResourceOperationKind.Delete = 'delete';
4282 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
4283 var FailureHandlingKind;
4284 (function (FailureHandlingKind) {
4286 * Applying the workspace change is simply aborted if one of the changes provided
4287 * fails. All operations executed before the failing operation stay executed.
4289 FailureHandlingKind.Abort = 'abort';
4291 * All operations are executed transactional. That means they either all
4292 * succeed or no changes at all are applied to the workspace.
4294 FailureHandlingKind.Transactional = 'transactional';
4296 * If the workspace edit contains only textual file changes they are executed transactional.
4297 * If resource changes (create, rename or delete file) are part of the change the failure
4298 * handling startegy is abort.
4300 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
4302 * The client tries to undo the operations already executed. But there is no
4303 * guaruntee that this is succeeding.
4305 FailureHandlingKind.Undo = 'undo';
4306 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
4308 * Defines how the host (editor) should sync
4309 * document changes to the language server.
4311 var TextDocumentSyncKind;
4312 (function (TextDocumentSyncKind) {
4314 * Documents should not be synced at all.
4316 TextDocumentSyncKind.None = 0;
4318 * Documents are synced by always sending the full content
4321 TextDocumentSyncKind.Full = 1;
4323 * Documents are synced by sending the full content on open.
4324 * After that only incremental updates to the document are
4327 TextDocumentSyncKind.Incremental = 2;
4328 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
4330 * The initialize request is sent from the client to the server.
4331 * It is sent once as the request after starting up the server.
4332 * The requests parameter is of type [InitializeParams](#InitializeParams)
4333 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
4336 var InitializeRequest;
4337 (function (InitializeRequest) {
4338 InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');
4339 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
4341 * Known error codes for an `InitializeError`;
4343 var InitializeError;
4344 (function (InitializeError) {
4346 * If the protocol version provided by the client can't be handled by the server.
4347 * @deprecated This initialize error got replaced by client capabilities. There is
4348 * no version handshake in version 3.0x
4350 InitializeError.unknownProtocolVersion = 1;
4351 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
4353 * The intialized notification is sent from the client to the
4354 * server after the client is fully initialized and the server
4355 * is allowed to send requests from the server to the client.
4357 var InitializedNotification;
4358 (function (InitializedNotification) {
4359 InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');
4360 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
4361 //---- Shutdown Method ----
4363 * A shutdown request is sent from the client to the server.
4364 * It is sent once when the client decides to shutdown the
4365 * server. The only notification that is sent after a shutdown request
4366 * is the exit event.
4368 var ShutdownRequest;
4369 (function (ShutdownRequest) {
4370 ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');
4371 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
4372 //---- Exit Notification ----
4374 * The exit event is sent from the client to the server to
4375 * ask the server to exit its process.
4377 var ExitNotification;
4378 (function (ExitNotification) {
4379 ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');
4380 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
4381 //---- Configuration notification ----
4383 * The configuration change notification is sent from the client to the server
4384 * when the client's configuration has changed. The notification contains
4385 * the changed configuration as defined by the language client.
4387 var DidChangeConfigurationNotification;
4388 (function (DidChangeConfigurationNotification) {
4389 DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');
4390 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
4391 //---- Message show and log notifications ----
4396 (function (MessageType) {
4400 MessageType.Error = 1;
4402 * A warning message.
4404 MessageType.Warning = 2;
4406 * An information message.
4408 MessageType.Info = 3;
4412 MessageType.Log = 4;
4413 })(MessageType = exports.MessageType || (exports.MessageType = {}));
4415 * The show message notification is sent from a server to a client to ask
4416 * the client to display a particular message in the user interface.
4418 var ShowMessageNotification;
4419 (function (ShowMessageNotification) {
4420 ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');
4421 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
4423 * The show message request is sent from the server to the client to show a message
4424 * and a set of options actions to the user.
4426 var ShowMessageRequest;
4427 (function (ShowMessageRequest) {
4428 ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');
4429 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
4431 * The log message notification is sent from the server to the client to ask
4432 * the client to log a particular message.
4434 var LogMessageNotification;
4435 (function (LogMessageNotification) {
4436 LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');
4437 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
4438 //---- Telemetry notification
4440 * The telemetry event notification is sent from the server to the client to ask
4441 * the client to log telemetry data.
4443 var TelemetryEventNotification;
4444 (function (TelemetryEventNotification) {
4445 TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');
4446 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
4448 * The document open notification is sent from the client to the server to signal
4449 * newly opened text documents. The document's truth is now managed by the client
4450 * and the server must not try to read the document's truth using the document's
4451 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
4452 * mean that its content is presented in an editor. An open notification must not
4453 * be sent more than once without a corresponding close notification send before.
4454 * This means open and close notification must be balanced and the max open count
4457 var DidOpenTextDocumentNotification;
4458 (function (DidOpenTextDocumentNotification) {
4459 DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');
4460 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
4462 * The document change notification is sent from the client to the server to signal
4463 * changes to a text document.
4465 var DidChangeTextDocumentNotification;
4466 (function (DidChangeTextDocumentNotification) {
4467 DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');
4468 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
4470 * The document close notification is sent from the client to the server when
4471 * the document got closed in the client. The document's truth now exists where
4472 * the document's uri points to (e.g. if the document's uri is a file uri the
4473 * truth now exists on disk). As with the open notification the close notification
4474 * is about managing the document's content. Receiving a close notification
4475 * doesn't mean that the document was open in an editor before. A close
4476 * notification requires a previous open notification to be sent.
4478 var DidCloseTextDocumentNotification;
4479 (function (DidCloseTextDocumentNotification) {
4480 DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');
4481 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
4483 * The document save notification is sent from the client to the server when
4484 * the document got saved in the client.
4486 var DidSaveTextDocumentNotification;
4487 (function (DidSaveTextDocumentNotification) {
4488 DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');
4489 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
4491 * A document will save notification is sent from the client to the server before
4492 * the document is actually saved.
4494 var WillSaveTextDocumentNotification;
4495 (function (WillSaveTextDocumentNotification) {
4496 WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');
4497 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
4499 * A document will save request is sent from the client to the server before
4500 * the document is actually saved. The request can return an array of TextEdits
4501 * which will be applied to the text document before it is saved. Please note that
4502 * clients might drop results if computing the text edits took too long or if a
4503 * server constantly fails on this request. This is done to keep the save fast and
4506 var WillSaveTextDocumentWaitUntilRequest;
4507 (function (WillSaveTextDocumentWaitUntilRequest) {
4508 WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');
4509 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
4510 //---- File eventing ----
4512 * The watched files notification is sent from the client to the server when
4513 * the client detects changes to file watched by the language client.
4515 var DidChangeWatchedFilesNotification;
4516 (function (DidChangeWatchedFilesNotification) {
4517 DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');
4518 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
4520 * The file event type
4523 (function (FileChangeType) {
4525 * The file got created.
4527 FileChangeType.Created = 1;
4529 * The file got changed.
4531 FileChangeType.Changed = 2;
4533 * The file got deleted.
4535 FileChangeType.Deleted = 3;
4536 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
4538 (function (WatchKind) {
4540 * Interested in create events.
4542 WatchKind.Create = 1;
4544 * Interested in change events
4546 WatchKind.Change = 2;
4548 * Interested in delete events
4550 WatchKind.Delete = 4;
4551 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
4552 //---- Diagnostic notification ----
4554 * Diagnostics notification are sent from the server to the client to signal
4555 * results of validation runs.
4557 var PublishDiagnosticsNotification;
4558 (function (PublishDiagnosticsNotification) {
4559 PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');
4560 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
4562 * How a completion was triggered
4564 var CompletionTriggerKind;
4565 (function (CompletionTriggerKind) {
4567 * Completion was triggered by typing an identifier (24x7 code
4568 * complete), manual invocation (e.g Ctrl+Space) or via API.
4570 CompletionTriggerKind.Invoked = 1;
4572 * Completion was triggered by a trigger character specified by
4573 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
4575 CompletionTriggerKind.TriggerCharacter = 2;
4577 * Completion was re-triggered as current completion list is incomplete
4579 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
4580 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
4582 * Request to request completion at a given text document position. The request's
4583 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
4584 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
4585 * or a Thenable that resolves to such.
4587 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
4588 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
4589 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
4590 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
4592 var CompletionRequest;
4593 (function (CompletionRequest) {
4594 CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');
4595 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
4597 * Request to resolve additional information for a given completion item.The request's
4598 * parameter is of type [CompletionItem](#CompletionItem) the response
4599 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
4601 var CompletionResolveRequest;
4602 (function (CompletionResolveRequest) {
4603 CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');
4604 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
4605 //---- Hover Support -------------------------------
4607 * Request to request hover information at a given text document position. The request's
4608 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
4609 * type [Hover](#Hover) or a Thenable that resolves to such.
4612 (function (HoverRequest) {
4613 HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');
4614 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
4615 var SignatureHelpRequest;
4616 (function (SignatureHelpRequest) {
4617 SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');
4618 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
4619 //---- Goto Definition -------------------------------------
4621 * A request to resolve the definition location of a symbol at a given text
4622 * document position. The request's parameter is of type [TextDocumentPosition]
4623 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
4624 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
4627 var DefinitionRequest;
4628 (function (DefinitionRequest) {
4629 DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');
4630 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
4632 * A request to resolve project-wide references for the symbol denoted
4633 * by the given text document position. The request's parameter is of
4634 * type [ReferenceParams](#ReferenceParams) the response is of type
4635 * [Location[]](#Location) or a Thenable that resolves to such.
4637 var ReferencesRequest;
4638 (function (ReferencesRequest) {
4639 ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');
4640 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
4641 //---- Document Highlight ----------------------------------
4643 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
4644 * text document position. The request's parameter is of type [TextDocumentPosition]
4645 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
4646 * (#DocumentHighlight) or a Thenable that resolves to such.
4648 var DocumentHighlightRequest;
4649 (function (DocumentHighlightRequest) {
4650 DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');
4651 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
4652 //---- Document Symbol Provider ---------------------------
4654 * A request to list all symbols found in a given text document. The request's
4655 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
4656 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
4657 * that resolves to such.
4659 var DocumentSymbolRequest;
4660 (function (DocumentSymbolRequest) {
4661 DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');
4662 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
4663 //---- Workspace Symbol Provider ---------------------------
4665 * A request to list project-wide symbols matching the query string given
4666 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
4667 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
4670 var WorkspaceSymbolRequest;
4671 (function (WorkspaceSymbolRequest) {
4672 WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');
4673 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
4675 * A request to provide commands for the given text document and range.
4677 var CodeActionRequest;
4678 (function (CodeActionRequest) {
4679 CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');
4680 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
4682 * A request to provide code lens for the given text document.
4684 var CodeLensRequest;
4685 (function (CodeLensRequest) {
4686 CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');
4687 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
4689 * A request to resolve a command for a given code lens.
4691 var CodeLensResolveRequest;
4692 (function (CodeLensResolveRequest) {
4693 CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');
4694 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
4696 * A request to to format a whole document.
4698 var DocumentFormattingRequest;
4699 (function (DocumentFormattingRequest) {
4700 DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');
4701 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
4703 * A request to to format a range in a document.
4705 var DocumentRangeFormattingRequest;
4706 (function (DocumentRangeFormattingRequest) {
4707 DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');
4708 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
4710 * A request to format a document on type.
4712 var DocumentOnTypeFormattingRequest;
4713 (function (DocumentOnTypeFormattingRequest) {
4714 DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');
4715 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
4717 * A request to rename a symbol.
4720 (function (RenameRequest) {
4721 RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');
4722 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
4724 * A request to test and perform the setup necessary for a rename.
4726 var PrepareRenameRequest;
4727 (function (PrepareRenameRequest) {
4728 PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');
4729 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
4731 * A request to provide document links
4733 var DocumentLinkRequest;
4734 (function (DocumentLinkRequest) {
4735 DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');
4736 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
4738 * Request to resolve additional information for a given document link. The request's
4739 * parameter is of type [DocumentLink](#DocumentLink) the response
4740 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
4742 var DocumentLinkResolveRequest;
4743 (function (DocumentLinkResolveRequest) {
4744 DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');
4745 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
4747 * A request send from the client to the server to execute a command. The request might return
4748 * a workspace edit which the client will apply to the workspace.
4750 var ExecuteCommandRequest;
4751 (function (ExecuteCommandRequest) {
4752 ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');
4753 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
4755 * A request sent from the server to the client to modified certain resources.
4757 var ApplyWorkspaceEditRequest;
4758 (function (ApplyWorkspaceEditRequest) {
4759 ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');
4760 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
4765 /***/ (function(module, exports, __webpack_require__) {
4768 /* --------------------------------------------------------------------------------------------
4769 * Copyright (c) Microsoft Corporation. All rights reserved.
4770 * Licensed under the MIT License. See License.txt in the project root for license information.
4771 * ------------------------------------------------------------------------------------------ */
4773 Object.defineProperty(exports, "__esModule", { value: true });
4774 function boolean(value) {
4775 return value === true || value === false;
4777 exports.boolean = boolean;
4778 function string(value) {
4779 return typeof value === 'string' || value instanceof String;
4781 exports.string = string;
4782 function number(value) {
4783 return typeof value === 'number' || value instanceof Number;
4785 exports.number = number;
4786 function error(value) {
4787 return value instanceof Error;
4789 exports.error = error;
4790 function func(value) {
4791 return typeof value === 'function';
4793 exports.func = func;
4794 function array(value) {
4795 return Array.isArray(value);
4797 exports.array = array;
4798 function stringArray(value) {
4799 return array(value) && value.every(elem => string(elem));
4801 exports.stringArray = stringArray;
4802 function typedArray(value, check) {
4803 return Array.isArray(value) && value.every(check);
4805 exports.typedArray = typedArray;
4806 function thenable(value) {
4807 return value && func(value.then);
4809 exports.thenable = thenable;
4814 /***/ (function(module, exports, __webpack_require__) {
4817 /* --------------------------------------------------------------------------------------------
4818 * Copyright (c) Microsoft Corporation. All rights reserved.
4819 * Licensed under the MIT License. See License.txt in the project root for license information.
4820 * ------------------------------------------------------------------------------------------ */
4822 Object.defineProperty(exports, "__esModule", { value: true });
4823 const vscode_jsonrpc_1 = __webpack_require__(5);
4824 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
4825 let __noDynamicImport;
4827 * A request to resolve the implementation locations of a symbol at a given text
4828 * document position. The request's parameter is of type [TextDocumentPositioParams]
4829 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
4830 * Thenable that resolves to such.
4832 var ImplementationRequest;
4833 (function (ImplementationRequest) {
4834 ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');
4835 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
4840 /***/ (function(module, exports, __webpack_require__) {
4843 /* --------------------------------------------------------------------------------------------
4844 * Copyright (c) Microsoft Corporation. All rights reserved.
4845 * Licensed under the MIT License. See License.txt in the project root for license information.
4846 * ------------------------------------------------------------------------------------------ */
4848 Object.defineProperty(exports, "__esModule", { value: true });
4849 const vscode_jsonrpc_1 = __webpack_require__(5);
4850 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
4851 let __noDynamicImport;
4853 * A request to resolve the type definition locations of a symbol at a given text
4854 * document position. The request's parameter is of type [TextDocumentPositioParams]
4855 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
4856 * Thenable that resolves to such.
4858 var TypeDefinitionRequest;
4859 (function (TypeDefinitionRequest) {
4860 TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');
4861 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
4866 /***/ (function(module, exports, __webpack_require__) {
4869 /* --------------------------------------------------------------------------------------------
4870 * Copyright (c) Microsoft Corporation. All rights reserved.
4871 * Licensed under the MIT License. See License.txt in the project root for license information.
4872 * ------------------------------------------------------------------------------------------ */
4874 Object.defineProperty(exports, "__esModule", { value: true });
4875 const vscode_jsonrpc_1 = __webpack_require__(5);
4877 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
4879 var WorkspaceFoldersRequest;
4880 (function (WorkspaceFoldersRequest) {
4881 WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');
4882 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
4884 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
4885 * folder configuration changes.
4887 var DidChangeWorkspaceFoldersNotification;
4888 (function (DidChangeWorkspaceFoldersNotification) {
4889 DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');
4890 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
4895 /***/ (function(module, exports, __webpack_require__) {
4898 /* --------------------------------------------------------------------------------------------
4899 * Copyright (c) Microsoft Corporation. All rights reserved.
4900 * Licensed under the MIT License. See License.txt in the project root for license information.
4901 * ------------------------------------------------------------------------------------------ */
4903 Object.defineProperty(exports, "__esModule", { value: true });
4904 const vscode_jsonrpc_1 = __webpack_require__(5);
4906 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
4907 * configuration setting.
4909 * This pull model replaces the old push model were the client signaled configuration change via an
4910 * event. If the server still needs to react to configuration changes (since the server caches the
4911 * result of `workspace/configuration` requests) the server should register for an empty configuration
4912 * change event and empty the cache if such an event is received.
4914 var ConfigurationRequest;
4915 (function (ConfigurationRequest) {
4916 ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');
4917 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
4922 /***/ (function(module, exports, __webpack_require__) {
4925 /* --------------------------------------------------------------------------------------------
4926 * Copyright (c) Microsoft Corporation. All rights reserved.
4927 * Licensed under the MIT License. See License.txt in the project root for license information.
4928 * ------------------------------------------------------------------------------------------ */
4930 Object.defineProperty(exports, "__esModule", { value: true });
4931 const vscode_jsonrpc_1 = __webpack_require__(5);
4933 * A request to list all color symbols found in a given text document. The request's
4934 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
4935 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4936 * that resolves to such.
4938 var DocumentColorRequest;
4939 (function (DocumentColorRequest) {
4940 DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');
4941 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
4943 * A request to list all presentation for a color. The request's
4944 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
4945 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4946 * that resolves to such.
4948 var ColorPresentationRequest;
4949 (function (ColorPresentationRequest) {
4950 ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');
4951 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
4956 /***/ (function(module, exports, __webpack_require__) {
4960 /*---------------------------------------------------------------------------------------------
4961 * Copyright (c) Microsoft Corporation. All rights reserved.
4962 * Licensed under the MIT License. See License.txt in the project root for license information.
4963 *--------------------------------------------------------------------------------------------*/
4964 Object.defineProperty(exports, "__esModule", { value: true });
4965 const vscode_jsonrpc_1 = __webpack_require__(5);
4967 * Enum of known range kinds
4969 var FoldingRangeKind;
4970 (function (FoldingRangeKind) {
4972 * Folding range for a comment
4974 FoldingRangeKind["Comment"] = "comment";
4976 * Folding range for a imports or includes
4978 FoldingRangeKind["Imports"] = "imports";
4980 * Folding range for a region (e.g. `#region`)
4982 FoldingRangeKind["Region"] = "region";
4983 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
4985 * A request to provide folding ranges in a document. The request's
4986 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
4987 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
4988 * that resolves to such.
4990 var FoldingRangeRequest;
4991 (function (FoldingRangeRequest) {
4992 FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');
4993 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
4998 /***/ (function(module, exports, __webpack_require__) {
5001 /* --------------------------------------------------------------------------------------------
5002 * Copyright (c) Microsoft Corporation. All rights reserved.
5003 * Licensed under the MIT License. See License.txt in the project root for license information.
5004 * ------------------------------------------------------------------------------------------ */
5006 Object.defineProperty(exports, "__esModule", { value: true });
5007 const vscode_jsonrpc_1 = __webpack_require__(5);
5008 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
5009 let __noDynamicImport;
5011 * A request to resolve the type definition locations of a symbol at a given text
5012 * document position. The request's parameter is of type [TextDocumentPositioParams]
5013 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
5014 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
5017 var DeclarationRequest;
5018 (function (DeclarationRequest) {
5019 DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');
5020 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
5025 /***/ (function(module, exports, __webpack_require__) {
5029 /*---------------------------------------------------------------------------------------------
5030 * Copyright (c) Microsoft Corporation. All rights reserved.
5031 * Licensed under the MIT License. See License.txt in the project root for license information.
5032 *--------------------------------------------------------------------------------------------*/
5033 Object.defineProperty(exports, "__esModule", { value: true });
5034 const vscode_jsonrpc_1 = __webpack_require__(5);
5036 * A request to provide selection ranges in a document. The request's
5037 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
5038 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
5039 * that resolves to such.
5041 var SelectionRangeRequest;
5042 (function (SelectionRangeRequest) {
5043 SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/selectionRange');
5044 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
5049 /***/ (function(module, exports, __webpack_require__) {
5052 /* --------------------------------------------------------------------------------------------
5053 * Copyright (c) TypeFox and others. All rights reserved.
5054 * Licensed under the MIT License. See License.txt in the project root for license information.
5055 * ------------------------------------------------------------------------------------------ */
5057 Object.defineProperty(exports, "__esModule", { value: true });
5058 const vscode_jsonrpc_1 = __webpack_require__(5);
5060 * The direction of a call hierarchy request.
5062 var CallHierarchyDirection;
5063 (function (CallHierarchyDirection) {
5067 CallHierarchyDirection.CallsFrom = 1;
5071 CallHierarchyDirection.CallsTo = 2;
5072 })(CallHierarchyDirection = exports.CallHierarchyDirection || (exports.CallHierarchyDirection = {}));
5074 * Request to provide the call hierarchy at a given text document position.
5076 * The request's parameter is of type [CallHierarchyParams](#CallHierarchyParams). The response
5077 * is of type [CallHierarchyCall[]](#CallHierarchyCall) or a Thenable that resolves to such.
5079 * Evaluates the symbol defined (or referenced) at the given position, and returns all incoming or outgoing calls to the symbol(s).
5081 var CallHierarchyRequest;
5082 (function (CallHierarchyRequest) {
5083 CallHierarchyRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/callHierarchy');
5084 })(CallHierarchyRequest = exports.CallHierarchyRequest || (exports.CallHierarchyRequest = {}));
5089 /***/ (function(module, exports, __webpack_require__) {
5092 /* --------------------------------------------------------------------------------------------
5093 * Copyright (c) Microsoft Corporation. All rights reserved.
5094 * Licensed under the MIT License. See License.txt in the project root for license information.
5095 * ------------------------------------------------------------------------------------------ */
5097 Object.defineProperty(exports, "__esModule", { value: true });
5098 const vscode_jsonrpc_1 = __webpack_require__(5);
5100 * The `window/progress/start` notification is sent from the server to the client
5101 * to initiate a progress.
5103 var ProgressStartNotification;
5104 (function (ProgressStartNotification) {
5105 ProgressStartNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/start');
5106 })(ProgressStartNotification = exports.ProgressStartNotification || (exports.ProgressStartNotification = {}));
5108 * The `window/progress/report` notification is sent from the server to the client
5109 * to initiate a progress.
5111 var ProgressReportNotification;
5112 (function (ProgressReportNotification) {
5113 ProgressReportNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/report');
5114 })(ProgressReportNotification = exports.ProgressReportNotification || (exports.ProgressReportNotification = {}));
5116 * The `window/progress/done` notification is sent from the server to the client
5117 * to initiate a progress.
5119 var ProgressDoneNotification;
5120 (function (ProgressDoneNotification) {
5121 ProgressDoneNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/done');
5122 })(ProgressDoneNotification = exports.ProgressDoneNotification || (exports.ProgressDoneNotification = {}));
5124 * The `window/progress/cancel` notification is sent client to the server to cancel a progress
5125 * initiated on the server side.
5127 var ProgressCancelNotification;
5128 (function (ProgressCancelNotification) {
5129 ProgressCancelNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/cancel');
5130 })(ProgressCancelNotification = exports.ProgressCancelNotification || (exports.ProgressCancelNotification = {}));
5135 /***/ (function(module, exports, __webpack_require__) {
5139 /*---------------------------------------------------------------------------------------------
5140 * Copyright (c) Microsoft Corporation. All rights reserved.
5141 * Licensed under the MIT License. See License.txt in the project root for license information.
5142 *--------------------------------------------------------------------------------------------*/
5143 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5144 return new (P || (P = Promise))(function (resolve, reject) {
5145 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5146 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5147 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
5148 step((generator = generator.apply(thisArg, _arguments || [])).next());
5151 Object.defineProperty(exports, "__esModule", { value: true });
5152 const coc_nvim_1 = __webpack_require__(1);
5153 const vscode_languageserver_protocol_1 = __webpack_require__(4);
5154 function activateTagClosing(tagProvider, supportedLanguages, configName) {
5155 let disposables = [];
5156 coc_nvim_1.workspace.onDidChangeTextDocument(event => {
5157 const document = coc_nvim_1.workspace.getDocument(event.textDocument.uri);
5161 onDidChangeTextDocument(document.textDocument, event.contentChanges)
5165 }, null, disposables);
5166 let isEnabled = false;
5167 updateEnabledState().catch(() => {
5170 disposables.push(coc_nvim_1.workspace.registerAutocmd({
5171 event: ['BufEnter'],
5173 callback: updateEnabledState,
5176 function updateEnabledState() {
5177 return __awaiter(this, void 0, void 0, function* () {
5179 const doc = yield coc_nvim_1.workspace.document;
5183 const document = doc.textDocument;
5184 if (supportedLanguages.indexOf(document.languageId) === -1) {
5187 if (!coc_nvim_1.workspace.getConfiguration(undefined, document.uri).get(configName)) {
5193 function onDidChangeTextDocument(document, changes) {
5194 return __awaiter(this, void 0, void 0, function* () {
5198 const doc = yield coc_nvim_1.workspace.document;
5202 let activeDocument = doc.textDocument;
5203 if (document !== activeDocument || changes.length === 0) {
5206 if (typeof timeout !== 'undefined') {
5207 clearTimeout(timeout);
5209 let lastChange = changes[changes.length - 1];
5210 let lastCharacter = lastChange.text[lastChange.text.length - 1];
5211 if (lastChange.rangeLength > 0 || lastCharacter !== '>' && lastCharacter !== '/') {
5214 let rangeStart = lastChange.range.start;
5215 let version = document.version;
5216 timeout = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
5217 let position = vscode_languageserver_protocol_1.Position.create(rangeStart.line, rangeStart.character + lastChange.text.length);
5218 tagProvider(document, position).then((text) => __awaiter(this, void 0, void 0, function* () {
5219 if (text && isEnabled) {
5220 const doc = yield coc_nvim_1.workspace.document;
5224 let activeDocument = doc.textDocument;
5225 if (document === activeDocument && activeDocument.version === version) {
5226 coc_nvim_1.snippetManager.insertSnippet(text, false, vscode_languageserver_protocol_1.Range.create(position, position))
5233 timeout = undefined;
5237 return coc_nvim_1.Disposable.create(() => {
5238 disposables.forEach(disposable => {
5239 disposable.dispose();
5244 exports.activateTagClosing = activateTagClosing;