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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
94 if (k2 === undefined) k2 = k;
95 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
96 }) : (function(o, m, k, k2) {
97 if (k2 === undefined) k2 = k;
100 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
101 Object.defineProperty(o, "default", { enumerable: true, value: v });
102 }) : function(o, v) {
105 var __importStar = (this && this.__importStar) || function (mod) {
106 if (mod && mod.__esModule) return mod;
108 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
109 __setModuleDefault(result, mod);
112 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
113 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
114 return new (P || (P = Promise))(function (resolve, reject) {
115 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
116 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
117 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
118 step((generator = generator.apply(thisArg, _arguments || [])).next());
121 var __importDefault = (this && this.__importDefault) || function (mod) {
122 return (mod && mod.__esModule) ? mod : { "default": mod };
124 Object.defineProperty(exports, "__esModule", { value: true });
125 exports.activate = void 0;
126 const coc_nvim_1 = __webpack_require__(1);
127 const vscode_languageserver_protocol_1 = __webpack_require__(2);
128 const configCacheHandler_1 = __importDefault(__webpack_require__(32));
129 const errorHandler_1 = __webpack_require__(34);
130 const ignoreFileHandler_1 = __importDefault(__webpack_require__(35));
131 const PrettierEditProvider_1 = __importStar(__webpack_require__(42));
132 const utils_1 = __webpack_require__(37);
133 let formatterHandler;
134 let rangeFormatterHandler;
138 function disposeHandlers() {
139 if (formatterHandler) {
140 formatterHandler.dispose();
142 if (rangeFormatterHandler) {
143 rangeFormatterHandler.dispose();
145 formatterHandler = undefined;
146 rangeFormatterHandler = undefined;
149 * Build formatter selectors
151 function selectors(prettierInstance) {
152 let languageSelector = utils_1.enabledLanguages(prettierInstance).reduce((curr, language) => {
154 { language, scheme: 'file' },
155 { language, scheme: 'untitled' },
158 let rangeLanguageSelector = utils_1.rangeLanguages().reduce((curr, language) => {
160 { language, scheme: 'file' },
161 { language, scheme: 'untitled' },
166 rangeLanguageSelector,
170 return new Promise(resolve => {
176 function activate(context) {
177 return __awaiter(this, void 0, void 0, function* () {
178 context.subscriptions.push(errorHandler_1.setupErrorHandler());
179 const { fileIsIgnored } = ignoreFileHandler_1.default(context.subscriptions);
180 const editProvider = new PrettierEditProvider_1.default(fileIsIgnored);
181 const statusItem = coc_nvim_1.workspace.createStatusBarItem(0);
182 const config = coc_nvim_1.workspace.getConfiguration('prettier');
183 statusItem.text = config.get('statusItemText', 'Prettier');
184 let priority = config.get('formatterPriority', 1);
185 const prettierInstance = yield utils_1.getPrettierInstance();
186 if (!prettierInstance)
188 function checkDocument() {
189 return __awaiter(this, void 0, void 0, function* () {
191 let doc = coc_nvim_1.workspace.getDocument(coc_nvim_1.workspace.bufnr);
192 let languageIds = utils_1.enabledLanguages(prettierInstance);
193 if (doc && languageIds.indexOf(doc.filetype) !== -1) {
201 function registerFormatter() {
203 const { languageSelector, rangeLanguageSelector } = selectors(prettierInstance);
204 rangeFormatterHandler = coc_nvim_1.languages.registerDocumentRangeFormatProvider(rangeLanguageSelector, editProvider, priority);
205 formatterHandler = coc_nvim_1.languages.registerDocumentFormatProvider(languageSelector, editProvider, priority);
208 checkDocument().catch(_e => {
211 coc_nvim_1.events.on('BufEnter', () => __awaiter(this, void 0, void 0, function* () {
212 yield checkDocument();
213 }), null, context.subscriptions);
214 context.subscriptions.push(configCacheHandler_1.default());
215 context.subscriptions.push(coc_nvim_1.commands.registerCommand('prettier.formatFile', () => __awaiter(this, void 0, void 0, function* () {
216 let document = yield coc_nvim_1.workspace.document;
217 let prettierConfig = coc_nvim_1.workspace.getConfiguration('prettier', document.uri);
218 let onlyUseLocalVersion = prettierConfig.get('onlyUseLocalVersion', false);
219 if (onlyUseLocalVersion &&
220 (!utils_1.hasLocalPrettierInstalled(coc_nvim_1.Uri.parse(document.uri).fsPath) ||
221 document.schema != 'file')) {
222 coc_nvim_1.workspace.showMessage(`Flag prettier.onlyUseLocalVersion is set, but prettier is not installed locally. No operation will be made.`, 'warning');
225 let edits = yield PrettierEditProvider_1.format(document.content, document.textDocument, {}).then(code => [
226 vscode_languageserver_protocol_1.TextEdit.replace(PrettierEditProvider_1.fullDocumentRange(document.textDocument), code),
228 if (edits && edits.length) {
229 yield document.applyEdits(coc_nvim_1.workspace.nvim, edits);
234 exports.activate = activate;
239 /***/ (function(module, exports) {
241 module.exports = require("coc.nvim");
245 /***/ (function(module, exports, __webpack_require__) {
248 /* --------------------------------------------------------------------------------------------
\r
249 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
250 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
251 * ------------------------------------------------------------------------------------------ */
\r
253 function __export(m) {
\r
254 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
256 Object.defineProperty(exports, "__esModule", { value: true });
\r
257 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
258 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
\r
259 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
\r
260 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
\r
261 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
\r
262 exports.Disposable = vscode_jsonrpc_1.Disposable;
\r
263 exports.Event = vscode_jsonrpc_1.Event;
\r
264 exports.Emitter = vscode_jsonrpc_1.Emitter;
\r
265 exports.Trace = vscode_jsonrpc_1.Trace;
\r
266 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
\r
267 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
\r
268 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
\r
269 exports.RequestType = vscode_jsonrpc_1.RequestType;
\r
270 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
\r
271 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
\r
272 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
\r
273 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
\r
274 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
\r
275 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
\r
276 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
\r
277 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
\r
278 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
\r
279 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
\r
280 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
\r
281 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
\r
282 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
\r
283 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
\r
284 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
\r
285 exports.ProgressType = vscode_jsonrpc_1.ProgressType;
\r
286 __export(__webpack_require__(17));
\r
287 __export(__webpack_require__(18));
\r
288 const callHierarchy = __webpack_require__(30);
\r
289 const st = __webpack_require__(31);
\r
291 (function (Proposed) {
\r
292 let CallHierarchyPrepareRequest;
\r
293 (function (CallHierarchyPrepareRequest) {
\r
294 CallHierarchyPrepareRequest.method = callHierarchy.CallHierarchyPrepareRequest.method;
\r
295 CallHierarchyPrepareRequest.type = callHierarchy.CallHierarchyPrepareRequest.type;
\r
296 })(CallHierarchyPrepareRequest = Proposed.CallHierarchyPrepareRequest || (Proposed.CallHierarchyPrepareRequest = {}));
\r
297 let CallHierarchyIncomingCallsRequest;
\r
298 (function (CallHierarchyIncomingCallsRequest) {
\r
299 CallHierarchyIncomingCallsRequest.method = callHierarchy.CallHierarchyIncomingCallsRequest.method;
\r
300 CallHierarchyIncomingCallsRequest.type = callHierarchy.CallHierarchyIncomingCallsRequest.type;
\r
301 })(CallHierarchyIncomingCallsRequest = Proposed.CallHierarchyIncomingCallsRequest || (Proposed.CallHierarchyIncomingCallsRequest = {}));
\r
302 let CallHierarchyOutgoingCallsRequest;
\r
303 (function (CallHierarchyOutgoingCallsRequest) {
\r
304 CallHierarchyOutgoingCallsRequest.method = callHierarchy.CallHierarchyOutgoingCallsRequest.method;
\r
305 CallHierarchyOutgoingCallsRequest.type = callHierarchy.CallHierarchyOutgoingCallsRequest.type;
\r
306 })(CallHierarchyOutgoingCallsRequest = Proposed.CallHierarchyOutgoingCallsRequest || (Proposed.CallHierarchyOutgoingCallsRequest = {}));
\r
307 Proposed.SemanticTokenTypes = st.SemanticTokenTypes;
\r
308 Proposed.SemanticTokenModifiers = st.SemanticTokenModifiers;
\r
309 Proposed.SemanticTokens = st.SemanticTokens;
\r
310 let SemanticTokensRequest;
\r
311 (function (SemanticTokensRequest) {
\r
312 SemanticTokensRequest.method = st.SemanticTokensRequest.method;
\r
313 SemanticTokensRequest.type = st.SemanticTokensRequest.type;
\r
314 })(SemanticTokensRequest = Proposed.SemanticTokensRequest || (Proposed.SemanticTokensRequest = {}));
\r
315 let SemanticTokensEditsRequest;
\r
316 (function (SemanticTokensEditsRequest) {
\r
317 SemanticTokensEditsRequest.method = st.SemanticTokensEditsRequest.method;
\r
318 SemanticTokensEditsRequest.type = st.SemanticTokensEditsRequest.type;
\r
319 })(SemanticTokensEditsRequest = Proposed.SemanticTokensEditsRequest || (Proposed.SemanticTokensEditsRequest = {}));
\r
320 let SemanticTokensRangeRequest;
\r
321 (function (SemanticTokensRangeRequest) {
\r
322 SemanticTokensRangeRequest.method = st.SemanticTokensRangeRequest.method;
\r
323 SemanticTokensRangeRequest.type = st.SemanticTokensRangeRequest.type;
\r
324 })(SemanticTokensRangeRequest = Proposed.SemanticTokensRangeRequest || (Proposed.SemanticTokensRangeRequest = {}));
\r
325 })(Proposed = exports.Proposed || (exports.Proposed = {}));
\r
326 function createProtocolConnection(reader, writer, logger, strategy) {
\r
327 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
\r
329 exports.createProtocolConnection = createProtocolConnection;
\r
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="../typings/thenable.d.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__(4);
\r
348 const messages_1 = __webpack_require__(5);
\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__(6);
\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__(8);
\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__(7);
\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__(9);
\r
388 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
\r
389 exports.CancellationToken = cancellation_1.CancellationToken;
\r
390 const linkedMap_1 = __webpack_require__(10);
\r
391 __export(__webpack_require__(11));
\r
392 __export(__webpack_require__(16));
\r
393 var CancelNotification;
\r
394 (function (CancelNotification) {
\r
395 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
\r
396 })(CancelNotification || (CancelNotification = {}));
\r
397 var ProgressNotification;
\r
398 (function (ProgressNotification) {
\r
399 ProgressNotification.type = new messages_1.NotificationType('$/progress');
\r
400 })(ProgressNotification || (ProgressNotification = {}));
\r
401 class ProgressType {
\r
405 exports.ProgressType = ProgressType;
\r
406 exports.NullLogger = Object.freeze({
\r
413 (function (Trace) {
\r
414 Trace[Trace["Off"] = 0] = "Off";
\r
415 Trace[Trace["Messages"] = 1] = "Messages";
\r
416 Trace[Trace["Verbose"] = 2] = "Verbose";
\r
417 })(Trace = exports.Trace || (exports.Trace = {}));
\r
418 (function (Trace) {
\r
419 function fromString(value) {
\r
420 if (!Is.string(value)) {
\r
423 value = value.toLowerCase();
\r
428 return Trace.Messages;
\r
430 return Trace.Verbose;
\r
435 Trace.fromString = fromString;
\r
436 function toString(value) {
\r
440 case Trace.Messages:
\r
442 case Trace.Verbose:
\r
448 Trace.toString = toString;
\r
449 })(Trace = exports.Trace || (exports.Trace = {}));
\r
451 (function (TraceFormat) {
\r
452 TraceFormat["Text"] = "text";
\r
453 TraceFormat["JSON"] = "json";
\r
454 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
455 (function (TraceFormat) {
\r
456 function fromString(value) {
\r
457 value = value.toLowerCase();
\r
458 if (value === 'json') {
\r
459 return TraceFormat.JSON;
\r
462 return TraceFormat.Text;
\r
465 TraceFormat.fromString = fromString;
\r
466 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
467 var SetTraceNotification;
\r
468 (function (SetTraceNotification) {
\r
469 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
\r
470 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
\r
471 var LogTraceNotification;
\r
472 (function (LogTraceNotification) {
\r
473 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
\r
474 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
\r
475 var ConnectionErrors;
\r
476 (function (ConnectionErrors) {
\r
478 * The connection is closed.
\r
480 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
482 * The connection got disposed.
\r
484 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
486 * The connection is already in listening mode.
\r
488 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
\r
489 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
\r
490 class ConnectionError extends Error {
\r
491 constructor(code, message) {
\r
494 Object.setPrototypeOf(this, ConnectionError.prototype);
\r
497 exports.ConnectionError = ConnectionError;
\r
498 var ConnectionStrategy;
\r
499 (function (ConnectionStrategy) {
\r
500 function is(value) {
\r
501 let candidate = value;
\r
502 return candidate && Is.func(candidate.cancelUndispatched);
\r
504 ConnectionStrategy.is = is;
\r
505 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
\r
506 var ConnectionState;
\r
507 (function (ConnectionState) {
\r
508 ConnectionState[ConnectionState["New"] = 1] = "New";
\r
509 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
\r
510 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
\r
511 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
\r
512 })(ConnectionState || (ConnectionState = {}));
\r
513 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
\r
514 let sequenceNumber = 0;
\r
515 let notificationSquenceNumber = 0;
\r
516 let unknownResponseSquenceNumber = 0;
\r
517 const version = '2.0';
\r
518 let starRequestHandler = undefined;
\r
519 let requestHandlers = Object.create(null);
\r
520 let starNotificationHandler = undefined;
\r
521 let notificationHandlers = Object.create(null);
\r
522 let progressHandlers = new Map();
\r
524 let messageQueue = new linkedMap_1.LinkedMap();
\r
525 let responsePromises = Object.create(null);
\r
526 let requestTokens = Object.create(null);
\r
527 let trace = Trace.Off;
\r
528 let traceFormat = TraceFormat.Text;
\r
530 let state = ConnectionState.New;
\r
531 let errorEmitter = new events_1.Emitter();
\r
532 let closeEmitter = new events_1.Emitter();
\r
533 let unhandledNotificationEmitter = new events_1.Emitter();
\r
534 let unhandledProgressEmitter = new events_1.Emitter();
\r
535 let disposeEmitter = new events_1.Emitter();
\r
536 function createRequestQueueKey(id) {
\r
537 return 'req-' + id.toString();
\r
539 function createResponseQueueKey(id) {
\r
541 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
544 return 'res-' + id.toString();
\r
547 function createNotificationQueueKey() {
\r
548 return 'not-' + (++notificationSquenceNumber).toString();
\r
550 function addMessageToQueue(queue, message) {
\r
551 if (messages_1.isRequestMessage(message)) {
\r
552 queue.set(createRequestQueueKey(message.id), message);
\r
554 else if (messages_1.isResponseMessage(message)) {
\r
555 queue.set(createResponseQueueKey(message.id), message);
\r
558 queue.set(createNotificationQueueKey(), message);
\r
561 function cancelUndispatched(_message) {
\r
564 function isListening() {
\r
565 return state === ConnectionState.Listening;
\r
567 function isClosed() {
\r
568 return state === ConnectionState.Closed;
\r
570 function isDisposed() {
\r
571 return state === ConnectionState.Disposed;
\r
573 function closeHandler() {
\r
574 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
575 state = ConnectionState.Closed;
\r
576 closeEmitter.fire(undefined);
\r
578 // If the connection is disposed don't sent close events.
\r
580 function readErrorHandler(error) {
\r
581 errorEmitter.fire([error, undefined, undefined]);
\r
583 function writeErrorHandler(data) {
\r
584 errorEmitter.fire(data);
\r
586 messageReader.onClose(closeHandler);
\r
587 messageReader.onError(readErrorHandler);
\r
588 messageWriter.onClose(closeHandler);
\r
589 messageWriter.onError(writeErrorHandler);
\r
590 function triggerMessageQueue() {
\r
591 if (timer || messageQueue.size === 0) {
\r
594 timer = setImmediate(() => {
\r
596 processMessageQueue();
\r
599 function processMessageQueue() {
\r
600 if (messageQueue.size === 0) {
\r
603 let message = messageQueue.shift();
\r
605 if (messages_1.isRequestMessage(message)) {
\r
606 handleRequest(message);
\r
608 else if (messages_1.isNotificationMessage(message)) {
\r
609 handleNotification(message);
\r
611 else if (messages_1.isResponseMessage(message)) {
\r
612 handleResponse(message);
\r
615 handleInvalidMessage(message);
\r
619 triggerMessageQueue();
\r
622 let callback = (message) => {
\r
624 // We have received a cancellation message. Check if the message is still in the queue
\r
625 // and cancel it if allowed to do so.
\r
626 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
\r
627 let key = createRequestQueueKey(message.params.id);
\r
628 let toCancel = messageQueue.get(key);
\r
629 if (messages_1.isRequestMessage(toCancel)) {
\r
630 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
\r
631 if (response && (response.error !== void 0 || response.result !== void 0)) {
\r
632 messageQueue.delete(key);
\r
633 response.id = toCancel.id;
\r
634 traceSendingResponse(response, message.method, Date.now());
\r
635 messageWriter.write(response);
\r
640 addMessageToQueue(messageQueue, message);
\r
643 triggerMessageQueue();
\r
646 function handleRequest(requestMessage) {
\r
647 if (isDisposed()) {
\r
648 // we return here silently since we fired an event when the
\r
649 // connection got disposed.
\r
652 function reply(resultOrError, method, startTime) {
\r
655 id: requestMessage.id
\r
657 if (resultOrError instanceof messages_1.ResponseError) {
\r
658 message.error = resultOrError.toJson();
\r
661 message.result = resultOrError === void 0 ? null : resultOrError;
\r
663 traceSendingResponse(message, method, startTime);
\r
664 messageWriter.write(message);
\r
666 function replyError(error, method, startTime) {
\r
669 id: requestMessage.id,
\r
670 error: error.toJson()
\r
672 traceSendingResponse(message, method, startTime);
\r
673 messageWriter.write(message);
\r
675 function replySuccess(result, method, startTime) {
\r
676 // The JSON RPC defines that a response must either have a result or an error
\r
677 // So we can't treat undefined as a valid response result.
\r
678 if (result === void 0) {
\r
683 id: requestMessage.id,
\r
686 traceSendingResponse(message, method, startTime);
\r
687 messageWriter.write(message);
\r
689 traceReceivedRequest(requestMessage);
\r
690 let element = requestHandlers[requestMessage.method];
\r
692 let requestHandler;
\r
694 type = element.type;
\r
695 requestHandler = element.handler;
\r
697 let startTime = Date.now();
\r
698 if (requestHandler || starRequestHandler) {
\r
699 let cancellationSource = new cancellation_1.CancellationTokenSource();
\r
700 let tokenKey = String(requestMessage.id);
\r
701 requestTokens[tokenKey] = cancellationSource;
\r
704 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
705 handlerResult = requestHandler
\r
706 ? requestHandler(cancellationSource.token)
\r
707 : starRequestHandler(requestMessage.method, cancellationSource.token);
\r
709 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
710 handlerResult = requestHandler
\r
711 ? requestHandler(...requestMessage.params, cancellationSource.token)
\r
712 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
\r
715 handlerResult = requestHandler
\r
716 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
717 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
719 let promise = handlerResult;
\r
720 if (!handlerResult) {
\r
721 delete requestTokens[tokenKey];
\r
722 replySuccess(handlerResult, requestMessage.method, startTime);
\r
724 else if (promise.then) {
\r
725 promise.then((resultOrError) => {
\r
726 delete requestTokens[tokenKey];
\r
727 reply(resultOrError, requestMessage.method, startTime);
\r
729 delete requestTokens[tokenKey];
\r
730 if (error instanceof messages_1.ResponseError) {
\r
731 replyError(error, requestMessage.method, startTime);
\r
733 else if (error && Is.string(error.message)) {
\r
734 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
737 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
742 delete requestTokens[tokenKey];
\r
743 reply(handlerResult, requestMessage.method, startTime);
\r
747 delete requestTokens[tokenKey];
\r
748 if (error instanceof messages_1.ResponseError) {
\r
749 reply(error, requestMessage.method, startTime);
\r
751 else if (error && Is.string(error.message)) {
\r
752 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
755 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
760 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
763 function handleResponse(responseMessage) {
\r
764 if (isDisposed()) {
\r
765 // See handle request.
\r
768 if (responseMessage.id === null) {
\r
769 if (responseMessage.error) {
\r
770 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
\r
773 logger.error(`Received response message without id. No further error information provided.`);
\r
777 let key = String(responseMessage.id);
\r
778 let responsePromise = responsePromises[key];
\r
779 traceReceivedResponse(responseMessage, responsePromise);
\r
780 if (responsePromise) {
\r
781 delete responsePromises[key];
\r
783 if (responseMessage.error) {
\r
784 let error = responseMessage.error;
\r
785 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
\r
787 else if (responseMessage.result !== void 0) {
\r
788 responsePromise.resolve(responseMessage.result);
\r
791 throw new Error('Should never happen.');
\r
795 if (error.message) {
\r
796 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
799 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
805 function handleNotification(message) {
\r
806 if (isDisposed()) {
\r
807 // See handle request.
\r
810 let type = undefined;
\r
811 let notificationHandler;
\r
812 if (message.method === CancelNotification.type.method) {
\r
813 notificationHandler = (params) => {
\r
814 let id = params.id;
\r
815 let source = requestTokens[String(id)];
\r
822 let element = notificationHandlers[message.method];
\r
824 notificationHandler = element.handler;
\r
825 type = element.type;
\r
828 if (notificationHandler || starNotificationHandler) {
\r
830 traceReceivedNotification(message);
\r
831 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
832 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
\r
834 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
835 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
\r
838 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
842 if (error.message) {
\r
843 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
846 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
851 unhandledNotificationEmitter.fire(message);
\r
854 function handleInvalidMessage(message) {
\r
856 logger.error('Received empty message.');
\r
859 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
\r
860 // Test whether we find an id to reject the promise
\r
861 let responseMessage = message;
\r
862 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
\r
863 let key = String(responseMessage.id);
\r
864 let responseHandler = responsePromises[key];
\r
865 if (responseHandler) {
\r
866 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
\r
870 function traceSendingRequest(message) {
\r
871 if (trace === Trace.Off || !tracer) {
\r
874 if (traceFormat === TraceFormat.Text) {
\r
875 let data = undefined;
\r
876 if (trace === Trace.Verbose && message.params) {
\r
877 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
879 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
882 logLSPMessage('send-request', message);
\r
885 function traceSendingNotification(message) {
\r
886 if (trace === Trace.Off || !tracer) {
\r
889 if (traceFormat === TraceFormat.Text) {
\r
890 let data = undefined;
\r
891 if (trace === Trace.Verbose) {
\r
892 if (message.params) {
\r
893 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
896 data = 'No parameters provided.\n\n';
\r
899 tracer.log(`Sending notification '${message.method}'.`, data);
\r
902 logLSPMessage('send-notification', message);
\r
905 function traceSendingResponse(message, method, startTime) {
\r
906 if (trace === Trace.Off || !tracer) {
\r
909 if (traceFormat === TraceFormat.Text) {
\r
910 let data = undefined;
\r
911 if (trace === Trace.Verbose) {
\r
912 if (message.error && message.error.data) {
\r
913 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
916 if (message.result) {
\r
917 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
919 else if (message.error === void 0) {
\r
920 data = 'No result returned.\n\n';
\r
924 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
927 logLSPMessage('send-response', message);
\r
930 function traceReceivedRequest(message) {
\r
931 if (trace === Trace.Off || !tracer) {
\r
934 if (traceFormat === TraceFormat.Text) {
\r
935 let data = undefined;
\r
936 if (trace === Trace.Verbose && message.params) {
\r
937 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
939 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
942 logLSPMessage('receive-request', message);
\r
945 function traceReceivedNotification(message) {
\r
946 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\r
949 if (traceFormat === TraceFormat.Text) {
\r
950 let data = undefined;
\r
951 if (trace === Trace.Verbose) {
\r
952 if (message.params) {
\r
953 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
956 data = 'No parameters provided.\n\n';
\r
959 tracer.log(`Received notification '${message.method}'.`, data);
\r
962 logLSPMessage('receive-notification', message);
\r
965 function traceReceivedResponse(message, responsePromise) {
\r
966 if (trace === Trace.Off || !tracer) {
\r
969 if (traceFormat === TraceFormat.Text) {
\r
970 let data = undefined;
\r
971 if (trace === Trace.Verbose) {
\r
972 if (message.error && message.error.data) {
\r
973 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
976 if (message.result) {
\r
977 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
979 else if (message.error === void 0) {
\r
980 data = 'No result returned.\n\n';
\r
984 if (responsePromise) {
\r
985 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
\r
986 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
\r
989 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
993 logLSPMessage('receive-response', message);
\r
996 function logLSPMessage(type, message) {
\r
997 if (!tracer || trace === Trace.Off) {
\r
1000 const lspMessage = {
\r
1001 isLSPMessage: true,
\r
1004 timestamp: Date.now()
\r
1006 tracer.log(lspMessage);
\r
1008 function throwIfClosedOrDisposed() {
\r
1010 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
1012 if (isDisposed()) {
\r
1013 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
1016 function throwIfListening() {
\r
1017 if (isListening()) {
\r
1018 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
1021 function throwIfNotListening() {
\r
1022 if (!isListening()) {
\r
1023 throw new Error('Call listen() first.');
\r
1026 function undefinedToNull(param) {
\r
1027 if (param === void 0) {
\r
1034 function computeMessageParams(type, params) {
\r
1036 let numberOfParams = type.numberOfParams;
\r
1037 switch (numberOfParams) {
\r
1042 result = undefinedToNull(params[0]);
\r
1046 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
1047 result.push(undefinedToNull(params[i]));
\r
1049 if (params.length < numberOfParams) {
\r
1050 for (let i = params.length; i < numberOfParams; i++) {
\r
1051 result.push(null);
\r
1058 let connection = {
\r
1059 sendNotification: (type, ...params) => {
\r
1060 throwIfClosedOrDisposed();
\r
1062 let messageParams;
\r
1063 if (Is.string(type)) {
\r
1065 switch (params.length) {
\r
1067 messageParams = null;
\r
1070 messageParams = params[0];
\r
1073 messageParams = params;
\r
1078 method = type.method;
\r
1079 messageParams = computeMessageParams(type, params);
\r
1081 let notificationMessage = {
\r
1084 params: messageParams
\r
1086 traceSendingNotification(notificationMessage);
\r
1087 messageWriter.write(notificationMessage);
\r
1089 onNotification: (type, handler) => {
\r
1090 throwIfClosedOrDisposed();
\r
1091 if (Is.func(type)) {
\r
1092 starNotificationHandler = type;
\r
1094 else if (handler) {
\r
1095 if (Is.string(type)) {
\r
1096 notificationHandlers[type] = { type: undefined, handler };
\r
1099 notificationHandlers[type.method] = { type, handler };
\r
1103 onProgress: (_type, token, handler) => {
\r
1104 if (progressHandlers.has(token)) {
\r
1105 throw new Error(`Progress handler for token ${token} already registered`);
\r
1107 progressHandlers.set(token, handler);
\r
1110 progressHandlers.delete(token);
\r
1114 sendProgress: (_type, token, value) => {
\r
1115 connection.sendNotification(ProgressNotification.type, { token, value });
\r
1117 onUnhandledProgress: unhandledProgressEmitter.event,
\r
1118 sendRequest: (type, ...params) => {
\r
1119 throwIfClosedOrDisposed();
\r
1120 throwIfNotListening();
\r
1122 let messageParams;
\r
1123 let token = undefined;
\r
1124 if (Is.string(type)) {
\r
1126 switch (params.length) {
\r
1128 messageParams = null;
\r
1131 // The cancellation token is optional so it can also be undefined.
\r
1132 if (cancellation_1.CancellationToken.is(params[0])) {
\r
1133 messageParams = null;
\r
1134 token = params[0];
\r
1137 messageParams = undefinedToNull(params[0]);
\r
1141 const last = params.length - 1;
\r
1142 if (cancellation_1.CancellationToken.is(params[last])) {
\r
1143 token = params[last];
\r
1144 if (params.length === 2) {
\r
1145 messageParams = undefinedToNull(params[0]);
\r
1148 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
1152 messageParams = params.map(value => undefinedToNull(value));
\r
1158 method = type.method;
\r
1159 messageParams = computeMessageParams(type, params);
\r
1160 let numberOfParams = type.numberOfParams;
\r
1161 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
\r
1163 let id = sequenceNumber++;
\r
1164 let result = new Promise((resolve, reject) => {
\r
1165 let requestMessage = {
\r
1169 params: messageParams
\r
1171 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
1172 traceSendingRequest(requestMessage);
\r
1174 messageWriter.write(requestMessage);
\r
1177 // Writing the message failed. So we need to reject the promise.
\r
1178 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
\r
1179 responsePromise = null;
\r
1181 if (responsePromise) {
\r
1182 responsePromises[String(id)] = responsePromise;
\r
1186 token.onCancellationRequested(() => {
\r
1187 connection.sendNotification(CancelNotification.type, { id });
\r
1192 onRequest: (type, handler) => {
\r
1193 throwIfClosedOrDisposed();
\r
1194 if (Is.func(type)) {
\r
1195 starRequestHandler = type;
\r
1197 else if (handler) {
\r
1198 if (Is.string(type)) {
\r
1199 requestHandlers[type] = { type: undefined, handler };
\r
1202 requestHandlers[type.method] = { type, handler };
\r
1206 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
\r
1207 let _sendNotification = false;
\r
1208 let _traceFormat = TraceFormat.Text;
\r
1209 if (sendNotificationOrTraceOptions !== void 0) {
\r
1210 if (Is.boolean(sendNotificationOrTraceOptions)) {
\r
1211 _sendNotification = sendNotificationOrTraceOptions;
\r
1214 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
1215 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
1219 traceFormat = _traceFormat;
\r
1220 if (trace === Trace.Off) {
\r
1221 tracer = undefined;
\r
1226 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
1227 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
1230 onError: errorEmitter.event,
\r
1231 onClose: closeEmitter.event,
\r
1232 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
1233 onDispose: disposeEmitter.event,
\r
1235 if (isDisposed()) {
\r
1238 state = ConnectionState.Disposed;
\r
1239 disposeEmitter.fire(undefined);
\r
1240 let error = new Error('Connection got disposed.');
\r
1241 Object.keys(responsePromises).forEach((key) => {
\r
1242 responsePromises[key].reject(error);
\r
1244 responsePromises = Object.create(null);
\r
1245 requestTokens = Object.create(null);
\r
1246 messageQueue = new linkedMap_1.LinkedMap();
\r
1247 // Test for backwards compatibility
\r
1248 if (Is.func(messageWriter.dispose)) {
\r
1249 messageWriter.dispose();
\r
1251 if (Is.func(messageReader.dispose)) {
\r
1252 messageReader.dispose();
\r
1256 throwIfClosedOrDisposed();
\r
1257 throwIfListening();
\r
1258 state = ConnectionState.Listening;
\r
1259 messageReader.listen(callback);
\r
1262 // eslint-disable-next-line no-console
\r
1263 console.log('inspect');
\r
1266 connection.onNotification(LogTraceNotification.type, (params) => {
\r
1267 if (trace === Trace.Off || !tracer) {
\r
1270 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
1272 connection.onNotification(ProgressNotification.type, (params) => {
\r
1273 const handler = progressHandlers.get(params.token);
\r
1275 handler(params.value);
\r
1278 unhandledProgressEmitter.fire(params);
\r
1281 return connection;
\r
1283 function isMessageReader(value) {
\r
1284 return value.listen !== void 0 && value.read === void 0;
\r
1286 function isMessageWriter(value) {
\r
1287 return value.write !== void 0 && value.end === void 0;
\r
1289 function createMessageConnection(input, output, logger, strategy) {
\r
1291 logger = exports.NullLogger;
\r
1293 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
\r
1294 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
\r
1295 return _createMessageConnection(reader, writer, logger, strategy);
\r
1297 exports.createMessageConnection = createMessageConnection;
\r
1302 /***/ (function(module, exports, __webpack_require__) {
1305 /* --------------------------------------------------------------------------------------------
\r
1306 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1307 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1308 * ------------------------------------------------------------------------------------------ */
\r
1310 Object.defineProperty(exports, "__esModule", { value: true });
\r
1311 function boolean(value) {
\r
1312 return value === true || value === false;
\r
1314 exports.boolean = boolean;
\r
1315 function string(value) {
\r
1316 return typeof value === 'string' || value instanceof String;
\r
1318 exports.string = string;
\r
1319 function number(value) {
\r
1320 return typeof value === 'number' || value instanceof Number;
\r
1322 exports.number = number;
\r
1323 function error(value) {
\r
1324 return value instanceof Error;
\r
1326 exports.error = error;
\r
1327 function func(value) {
\r
1328 return typeof value === 'function';
\r
1330 exports.func = func;
\r
1331 function array(value) {
\r
1332 return Array.isArray(value);
\r
1334 exports.array = array;
\r
1335 function stringArray(value) {
\r
1336 return array(value) && value.every(elem => string(elem));
\r
1338 exports.stringArray = stringArray;
\r
1343 /***/ (function(module, exports, __webpack_require__) {
1346 /* --------------------------------------------------------------------------------------------
\r
1347 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1348 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1349 * ------------------------------------------------------------------------------------------ */
\r
1351 Object.defineProperty(exports, "__esModule", { value: true });
\r
1352 const is = __webpack_require__(4);
\r
1354 * Predefined error codes.
\r
1357 (function (ErrorCodes) {
\r
1358 // Defined by JSON RPC
\r
1359 ErrorCodes.ParseError = -32700;
\r
1360 ErrorCodes.InvalidRequest = -32600;
\r
1361 ErrorCodes.MethodNotFound = -32601;
\r
1362 ErrorCodes.InvalidParams = -32602;
\r
1363 ErrorCodes.InternalError = -32603;
\r
1364 ErrorCodes.serverErrorStart = -32099;
\r
1365 ErrorCodes.serverErrorEnd = -32000;
\r
1366 ErrorCodes.ServerNotInitialized = -32002;
\r
1367 ErrorCodes.UnknownErrorCode = -32001;
\r
1368 // Defined by the protocol.
\r
1369 ErrorCodes.RequestCancelled = -32800;
\r
1370 ErrorCodes.ContentModified = -32801;
\r
1371 // Defined by VSCode library.
\r
1372 ErrorCodes.MessageWriteError = 1;
\r
1373 ErrorCodes.MessageReadError = 2;
\r
1374 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
\r
1376 * An error object return in a response in case a request
\r
1379 class ResponseError extends Error {
\r
1380 constructor(code, message, data) {
\r
1382 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
1384 Object.setPrototypeOf(this, ResponseError.prototype);
\r
1389 message: this.message,
\r
1394 exports.ResponseError = ResponseError;
\r
1396 * An abstract implementation of a MessageType.
\r
1398 class AbstractMessageType {
\r
1399 constructor(_method, _numberOfParams) {
\r
1400 this._method = _method;
\r
1401 this._numberOfParams = _numberOfParams;
\r
1404 return this._method;
\r
1406 get numberOfParams() {
\r
1407 return this._numberOfParams;
\r
1410 exports.AbstractMessageType = AbstractMessageType;
\r
1412 * Classes to type request response pairs
\r
1414 * The type parameter RO will be removed in the next major version
\r
1415 * of the JSON RPC library since it is a LSP concept and doesn't
\r
1416 * belong here. For now it is tagged as default never.
\r
1418 class RequestType0 extends AbstractMessageType {
\r
1419 constructor(method) {
\r
1423 exports.RequestType0 = RequestType0;
\r
1424 class RequestType extends AbstractMessageType {
\r
1425 constructor(method) {
\r
1429 exports.RequestType = RequestType;
\r
1430 class RequestType1 extends AbstractMessageType {
\r
1431 constructor(method) {
\r
1435 exports.RequestType1 = RequestType1;
\r
1436 class RequestType2 extends AbstractMessageType {
\r
1437 constructor(method) {
\r
1441 exports.RequestType2 = RequestType2;
\r
1442 class RequestType3 extends AbstractMessageType {
\r
1443 constructor(method) {
\r
1447 exports.RequestType3 = RequestType3;
\r
1448 class RequestType4 extends AbstractMessageType {
\r
1449 constructor(method) {
\r
1453 exports.RequestType4 = RequestType4;
\r
1454 class RequestType5 extends AbstractMessageType {
\r
1455 constructor(method) {
\r
1459 exports.RequestType5 = RequestType5;
\r
1460 class RequestType6 extends AbstractMessageType {
\r
1461 constructor(method) {
\r
1465 exports.RequestType6 = RequestType6;
\r
1466 class RequestType7 extends AbstractMessageType {
\r
1467 constructor(method) {
\r
1471 exports.RequestType7 = RequestType7;
\r
1472 class RequestType8 extends AbstractMessageType {
\r
1473 constructor(method) {
\r
1477 exports.RequestType8 = RequestType8;
\r
1478 class RequestType9 extends AbstractMessageType {
\r
1479 constructor(method) {
\r
1483 exports.RequestType9 = RequestType9;
\r
1485 * The type parameter RO will be removed in the next major version
\r
1486 * of the JSON RPC library since it is a LSP concept and doesn't
\r
1487 * belong here. For now it is tagged as default never.
\r
1489 class NotificationType extends AbstractMessageType {
\r
1490 constructor(method) {
\r
1492 this._ = undefined;
\r
1495 exports.NotificationType = NotificationType;
\r
1496 class NotificationType0 extends AbstractMessageType {
\r
1497 constructor(method) {
\r
1501 exports.NotificationType0 = NotificationType0;
\r
1502 class NotificationType1 extends AbstractMessageType {
\r
1503 constructor(method) {
\r
1507 exports.NotificationType1 = NotificationType1;
\r
1508 class NotificationType2 extends AbstractMessageType {
\r
1509 constructor(method) {
\r
1513 exports.NotificationType2 = NotificationType2;
\r
1514 class NotificationType3 extends AbstractMessageType {
\r
1515 constructor(method) {
\r
1519 exports.NotificationType3 = NotificationType3;
\r
1520 class NotificationType4 extends AbstractMessageType {
\r
1521 constructor(method) {
\r
1525 exports.NotificationType4 = NotificationType4;
\r
1526 class NotificationType5 extends AbstractMessageType {
\r
1527 constructor(method) {
\r
1531 exports.NotificationType5 = NotificationType5;
\r
1532 class NotificationType6 extends AbstractMessageType {
\r
1533 constructor(method) {
\r
1537 exports.NotificationType6 = NotificationType6;
\r
1538 class NotificationType7 extends AbstractMessageType {
\r
1539 constructor(method) {
\r
1543 exports.NotificationType7 = NotificationType7;
\r
1544 class NotificationType8 extends AbstractMessageType {
\r
1545 constructor(method) {
\r
1549 exports.NotificationType8 = NotificationType8;
\r
1550 class NotificationType9 extends AbstractMessageType {
\r
1551 constructor(method) {
\r
1555 exports.NotificationType9 = NotificationType9;
\r
1557 * Tests if the given message is a request message
\r
1559 function isRequestMessage(message) {
\r
1560 let candidate = message;
\r
1561 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
\r
1563 exports.isRequestMessage = isRequestMessage;
\r
1565 * Tests if the given message is a notification message
\r
1567 function isNotificationMessage(message) {
\r
1568 let candidate = message;
\r
1569 return candidate && is.string(candidate.method) && message.id === void 0;
\r
1571 exports.isNotificationMessage = isNotificationMessage;
\r
1573 * Tests if the given message is a response message
\r
1575 function isResponseMessage(message) {
\r
1576 let candidate = message;
\r
1577 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
\r
1579 exports.isResponseMessage = isResponseMessage;
\r
1584 /***/ (function(module, exports, __webpack_require__) {
1587 /* --------------------------------------------------------------------------------------------
\r
1588 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1589 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1590 * ------------------------------------------------------------------------------------------ */
\r
1592 Object.defineProperty(exports, "__esModule", { value: true });
\r
1593 const events_1 = __webpack_require__(7);
\r
1594 const Is = __webpack_require__(4);
\r
1595 let DefaultSize = 8192;
\r
1596 let CR = Buffer.from('\r', 'ascii')[0];
\r
1597 let LF = Buffer.from('\n', 'ascii')[0];
\r
1598 let CRLF = '\r\n';
\r
1599 class MessageBuffer {
\r
1600 constructor(encoding = 'utf8') {
\r
1601 this.encoding = encoding;
\r
1603 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
1606 var toAppend = chunk;
\r
1607 if (typeof (chunk) === 'string') {
\r
1609 var bufferLen = Buffer.byteLength(str, this.encoding);
\r
1610 toAppend = Buffer.allocUnsafe(bufferLen);
\r
1611 toAppend.write(str, 0, bufferLen, this.encoding);
\r
1613 if (this.buffer.length - this.index >= toAppend.length) {
\r
1614 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\r
1617 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
\r
1618 if (this.index === 0) {
\r
1619 this.buffer = Buffer.allocUnsafe(newSize);
\r
1620 toAppend.copy(this.buffer, 0, 0, toAppend.length);
\r
1623 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
1626 this.index += toAppend.length;
\r
1628 tryReadHeaders() {
\r
1629 let result = undefined;
\r
1631 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
1634 // No header / body separator found (e.g CRLFCRLF)
\r
1635 if (current + 3 >= this.index) {
\r
1638 result = Object.create(null);
\r
1639 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
\r
1640 headers.forEach((header) => {
\r
1641 let index = header.indexOf(':');
\r
1642 if (index === -1) {
\r
1643 throw new Error('Message header must separate key and value using :');
\r
1645 let key = header.substr(0, index);
\r
1646 let value = header.substr(index + 1).trim();
\r
1647 result[key] = value;
\r
1649 let nextStart = current + 4;
\r
1650 this.buffer = this.buffer.slice(nextStart);
\r
1651 this.index = this.index - nextStart;
\r
1654 tryReadContent(length) {
\r
1655 if (this.index < length) {
\r
1658 let result = this.buffer.toString(this.encoding, 0, length);
\r
1659 let nextStart = length;
\r
1660 this.buffer.copy(this.buffer, 0, nextStart);
\r
1661 this.index = this.index - nextStart;
\r
1664 get numberOfBytes() {
\r
1665 return this.index;
\r
1668 var MessageReader;
\r
1669 (function (MessageReader) {
\r
1670 function is(value) {
\r
1671 let candidate = value;
\r
1672 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
\r
1673 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
\r
1675 MessageReader.is = is;
\r
1676 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
1677 class AbstractMessageReader {
\r
1679 this.errorEmitter = new events_1.Emitter();
\r
1680 this.closeEmitter = new events_1.Emitter();
\r
1681 this.partialMessageEmitter = new events_1.Emitter();
\r
1684 this.errorEmitter.dispose();
\r
1685 this.closeEmitter.dispose();
\r
1688 return this.errorEmitter.event;
\r
1690 fireError(error) {
\r
1691 this.errorEmitter.fire(this.asError(error));
\r
1694 return this.closeEmitter.event;
\r
1697 this.closeEmitter.fire(undefined);
\r
1699 get onPartialMessage() {
\r
1700 return this.partialMessageEmitter.event;
\r
1702 firePartialMessage(info) {
\r
1703 this.partialMessageEmitter.fire(info);
\r
1706 if (error instanceof Error) {
\r
1710 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1714 exports.AbstractMessageReader = AbstractMessageReader;
\r
1715 class StreamMessageReader extends AbstractMessageReader {
\r
1716 constructor(readable, encoding = 'utf8') {
\r
1718 this.readable = readable;
\r
1719 this.buffer = new MessageBuffer(encoding);
\r
1720 this._partialMessageTimeout = 10000;
\r
1722 set partialMessageTimeout(timeout) {
\r
1723 this._partialMessageTimeout = timeout;
\r
1725 get partialMessageTimeout() {
\r
1726 return this._partialMessageTimeout;
\r
1728 listen(callback) {
\r
1729 this.nextMessageLength = -1;
\r
1730 this.messageToken = 0;
\r
1731 this.partialMessageTimer = undefined;
\r
1732 this.callback = callback;
\r
1733 this.readable.on('data', (data) => {
\r
1734 this.onData(data);
\r
1736 this.readable.on('error', (error) => this.fireError(error));
\r
1737 this.readable.on('close', () => this.fireClose());
\r
1740 this.buffer.append(data);
\r
1742 if (this.nextMessageLength === -1) {
\r
1743 let headers = this.buffer.tryReadHeaders();
\r
1747 let contentLength = headers['Content-Length'];
\r
1748 if (!contentLength) {
\r
1749 throw new Error('Header must provide a Content-Length property.');
\r
1751 let length = parseInt(contentLength);
\r
1752 if (isNaN(length)) {
\r
1753 throw new Error('Content-Length value must be a number.');
\r
1755 this.nextMessageLength = length;
\r
1756 // Take the encoding form the header. For compatibility
\r
1757 // treat both utf-8 and utf8 as node utf8
\r
1759 var msg = this.buffer.tryReadContent(this.nextMessageLength);
\r
1760 if (msg === null) {
\r
1761 /** We haven't received the full message yet. */
\r
1762 this.setPartialMessageTimer();
\r
1765 this.clearPartialMessageTimer();
\r
1766 this.nextMessageLength = -1;
\r
1767 this.messageToken++;
\r
1768 var json = JSON.parse(msg);
\r
1769 this.callback(json);
\r
1772 clearPartialMessageTimer() {
\r
1773 if (this.partialMessageTimer) {
\r
1774 clearTimeout(this.partialMessageTimer);
\r
1775 this.partialMessageTimer = undefined;
\r
1778 setPartialMessageTimer() {
\r
1779 this.clearPartialMessageTimer();
\r
1780 if (this._partialMessageTimeout <= 0) {
\r
1783 this.partialMessageTimer = setTimeout((token, timeout) => {
\r
1784 this.partialMessageTimer = undefined;
\r
1785 if (token === this.messageToken) {
\r
1786 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
\r
1787 this.setPartialMessageTimer();
\r
1789 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
1792 exports.StreamMessageReader = StreamMessageReader;
\r
1793 class IPCMessageReader extends AbstractMessageReader {
\r
1794 constructor(process) {
\r
1796 this.process = process;
\r
1797 let eventEmitter = this.process;
\r
1798 eventEmitter.on('error', (error) => this.fireError(error));
\r
1799 eventEmitter.on('close', () => this.fireClose());
\r
1801 listen(callback) {
\r
1802 this.process.on('message', callback);
\r
1805 exports.IPCMessageReader = IPCMessageReader;
\r
1806 class SocketMessageReader extends StreamMessageReader {
\r
1807 constructor(socket, encoding = 'utf-8') {
\r
1808 super(socket, encoding);
\r
1811 exports.SocketMessageReader = SocketMessageReader;
\r
1816 /***/ (function(module, exports, __webpack_require__) {
1819 /* --------------------------------------------------------------------------------------------
\r
1820 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1821 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1822 * ------------------------------------------------------------------------------------------ */
\r
1824 Object.defineProperty(exports, "__esModule", { value: true });
\r
1826 (function (Disposable) {
\r
1827 function create(func) {
\r
1832 Disposable.create = create;
\r
1833 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\r
1835 (function (Event) {
\r
1836 const _disposable = { dispose() { } };
\r
1837 Event.None = function () { return _disposable; };
\r
1838 })(Event = exports.Event || (exports.Event = {}));
\r
1839 class CallbackList {
\r
1840 add(callback, context = null, bucket) {
\r
1841 if (!this._callbacks) {
\r
1842 this._callbacks = [];
\r
1843 this._contexts = [];
\r
1845 this._callbacks.push(callback);
\r
1846 this._contexts.push(context);
\r
1847 if (Array.isArray(bucket)) {
\r
1848 bucket.push({ dispose: () => this.remove(callback, context) });
\r
1851 remove(callback, context = null) {
\r
1852 if (!this._callbacks) {
\r
1855 var foundCallbackWithDifferentContext = false;
\r
1856 for (var i = 0, len = this._callbacks.length; i < len; i++) {
\r
1857 if (this._callbacks[i] === callback) {
\r
1858 if (this._contexts[i] === context) {
\r
1859 // callback & context match => remove it
\r
1860 this._callbacks.splice(i, 1);
\r
1861 this._contexts.splice(i, 1);
\r
1865 foundCallbackWithDifferentContext = true;
\r
1869 if (foundCallbackWithDifferentContext) {
\r
1870 throw new Error('When adding a listener with a context, you should remove it with the same context');
\r
1874 if (!this._callbacks) {
\r
1877 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
\r
1878 for (var i = 0, len = callbacks.length; i < len; i++) {
\r
1880 ret.push(callbacks[i].apply(contexts[i], args));
\r
1883 // eslint-disable-next-line no-console
\r
1890 return !this._callbacks || this._callbacks.length === 0;
\r
1893 this._callbacks = undefined;
\r
1894 this._contexts = undefined;
\r
1898 constructor(_options) {
\r
1899 this._options = _options;
\r
1902 * For the public to allow to subscribe
\r
1903 * to events from this Emitter
\r
1906 if (!this._event) {
\r
1907 this._event = (listener, thisArgs, disposables) => {
\r
1908 if (!this._callbacks) {
\r
1909 this._callbacks = new CallbackList();
\r
1911 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
1912 this._options.onFirstListenerAdd(this);
\r
1914 this._callbacks.add(listener, thisArgs);
\r
1918 this._callbacks.remove(listener, thisArgs);
\r
1919 result.dispose = Emitter._noop;
\r
1920 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
\r
1921 this._options.onLastListenerRemove(this);
\r
1925 if (Array.isArray(disposables)) {
\r
1926 disposables.push(result);
\r
1931 return this._event;
\r
1934 * To be kept private to fire an event to
\r
1938 if (this._callbacks) {
\r
1939 this._callbacks.invoke.call(this._callbacks, event);
\r
1943 if (this._callbacks) {
\r
1944 this._callbacks.dispose();
\r
1945 this._callbacks = undefined;
\r
1949 exports.Emitter = Emitter;
\r
1950 Emitter._noop = function () { };
\r
1955 /***/ (function(module, exports, __webpack_require__) {
1958 /* --------------------------------------------------------------------------------------------
\r
1959 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1960 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1961 * ------------------------------------------------------------------------------------------ */
\r
1963 Object.defineProperty(exports, "__esModule", { value: true });
\r
1964 const events_1 = __webpack_require__(7);
\r
1965 const Is = __webpack_require__(4);
\r
1966 let ContentLength = 'Content-Length: ';
\r
1967 let CRLF = '\r\n';
\r
1968 var MessageWriter;
\r
1969 (function (MessageWriter) {
\r
1970 function is(value) {
\r
1971 let candidate = value;
\r
1972 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
\r
1973 Is.func(candidate.onError) && Is.func(candidate.write);
\r
1975 MessageWriter.is = is;
\r
1976 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
1977 class AbstractMessageWriter {
\r
1979 this.errorEmitter = new events_1.Emitter();
\r
1980 this.closeEmitter = new events_1.Emitter();
\r
1983 this.errorEmitter.dispose();
\r
1984 this.closeEmitter.dispose();
\r
1987 return this.errorEmitter.event;
\r
1989 fireError(error, message, count) {
\r
1990 this.errorEmitter.fire([this.asError(error), message, count]);
\r
1993 return this.closeEmitter.event;
\r
1996 this.closeEmitter.fire(undefined);
\r
1999 if (error instanceof Error) {
\r
2003 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
2007 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
2008 class StreamMessageWriter extends AbstractMessageWriter {
\r
2009 constructor(writable, encoding = 'utf8') {
\r
2011 this.writable = writable;
\r
2012 this.encoding = encoding;
\r
2013 this.errorCount = 0;
\r
2014 this.writable.on('error', (error) => this.fireError(error));
\r
2015 this.writable.on('close', () => this.fireClose());
\r
2018 let json = JSON.stringify(msg);
\r
2019 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2021 ContentLength, contentLength.toString(), CRLF,
\r
2025 // Header must be written in ASCII encoding
\r
2026 this.writable.write(headers.join(''), 'ascii');
\r
2027 // Now write the content. This can be written in any encoding
\r
2028 this.writable.write(json, this.encoding);
\r
2029 this.errorCount = 0;
\r
2032 this.errorCount++;
\r
2033 this.fireError(error, msg, this.errorCount);
\r
2037 exports.StreamMessageWriter = StreamMessageWriter;
\r
2038 class IPCMessageWriter extends AbstractMessageWriter {
\r
2039 constructor(process) {
\r
2041 this.process = process;
\r
2042 this.errorCount = 0;
\r
2044 this.sending = false;
\r
2045 let eventEmitter = this.process;
\r
2046 eventEmitter.on('error', (error) => this.fireError(error));
\r
2047 eventEmitter.on('close', () => this.fireClose);
\r
2050 if (!this.sending && this.queue.length === 0) {
\r
2051 // See https://github.com/nodejs/node/issues/7657
\r
2052 this.doWriteMessage(msg);
\r
2055 this.queue.push(msg);
\r
2058 doWriteMessage(msg) {
\r
2060 if (this.process.send) {
\r
2061 this.sending = true;
\r
2062 this.process.send(msg, undefined, undefined, (error) => {
\r
2063 this.sending = false;
\r
2065 this.errorCount++;
\r
2066 this.fireError(error, msg, this.errorCount);
\r
2069 this.errorCount = 0;
\r
2071 if (this.queue.length > 0) {
\r
2072 this.doWriteMessage(this.queue.shift());
\r
2078 this.errorCount++;
\r
2079 this.fireError(error, msg, this.errorCount);
\r
2083 exports.IPCMessageWriter = IPCMessageWriter;
\r
2084 class SocketMessageWriter extends AbstractMessageWriter {
\r
2085 constructor(socket, encoding = 'utf8') {
\r
2087 this.socket = socket;
\r
2089 this.sending = false;
\r
2090 this.encoding = encoding;
\r
2091 this.errorCount = 0;
\r
2092 this.socket.on('error', (error) => this.fireError(error));
\r
2093 this.socket.on('close', () => this.fireClose());
\r
2097 this.socket.destroy();
\r
2100 if (!this.sending && this.queue.length === 0) {
\r
2101 // See https://github.com/nodejs/node/issues/7657
\r
2102 this.doWriteMessage(msg);
\r
2105 this.queue.push(msg);
\r
2108 doWriteMessage(msg) {
\r
2109 let json = JSON.stringify(msg);
\r
2110 let contentLength = Buffer.byteLength(json, this.encoding);
\r
2112 ContentLength, contentLength.toString(), CRLF,
\r
2116 // Header must be written in ASCII encoding
\r
2117 this.sending = true;
\r
2118 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
2120 this.handleError(error, msg);
\r
2123 // Now write the content. This can be written in any encoding
\r
2124 this.socket.write(json, this.encoding, (error) => {
\r
2125 this.sending = false;
\r
2127 this.handleError(error, msg);
\r
2130 this.errorCount = 0;
\r
2132 if (this.queue.length > 0) {
\r
2133 this.doWriteMessage(this.queue.shift());
\r
2138 this.handleError(error, msg);
\r
2143 this.handleError(error, msg);
\r
2146 handleError(error, msg) {
\r
2147 this.errorCount++;
\r
2148 this.fireError(error, msg, this.errorCount);
\r
2151 exports.SocketMessageWriter = SocketMessageWriter;
\r
2156 /***/ (function(module, exports, __webpack_require__) {
2159 /*---------------------------------------------------------------------------------------------
\r
2160 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2161 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2162 *--------------------------------------------------------------------------------------------*/
\r
2164 Object.defineProperty(exports, "__esModule", { value: true });
\r
2165 const events_1 = __webpack_require__(7);
\r
2166 const Is = __webpack_require__(4);
\r
2167 var CancellationToken;
\r
2168 (function (CancellationToken) {
\r
2169 CancellationToken.None = Object.freeze({
\r
2170 isCancellationRequested: false,
\r
2171 onCancellationRequested: events_1.Event.None
\r
2173 CancellationToken.Cancelled = Object.freeze({
\r
2174 isCancellationRequested: true,
\r
2175 onCancellationRequested: events_1.Event.None
\r
2177 function is(value) {
\r
2178 let candidate = value;
\r
2179 return candidate && (candidate === CancellationToken.None
\r
2180 || candidate === CancellationToken.Cancelled
\r
2181 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
\r
2183 CancellationToken.is = is;
\r
2184 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
\r
2185 const shortcutEvent = Object.freeze(function (callback, context) {
\r
2186 let handle = setTimeout(callback.bind(context), 0);
\r
2187 return { dispose() { clearTimeout(handle); } };
\r
2189 class MutableToken {
\r
2191 this._isCancelled = false;
\r
2194 if (!this._isCancelled) {
\r
2195 this._isCancelled = true;
\r
2196 if (this._emitter) {
\r
2197 this._emitter.fire(undefined);
\r
2202 get isCancellationRequested() {
\r
2203 return this._isCancelled;
\r
2205 get onCancellationRequested() {
\r
2206 if (this._isCancelled) {
\r
2207 return shortcutEvent;
\r
2209 if (!this._emitter) {
\r
2210 this._emitter = new events_1.Emitter();
\r
2212 return this._emitter.event;
\r
2215 if (this._emitter) {
\r
2216 this._emitter.dispose();
\r
2217 this._emitter = undefined;
\r
2221 class CancellationTokenSource {
\r
2223 if (!this._token) {
\r
2224 // be lazy and create the token only when
\r
2225 // actually needed
\r
2226 this._token = new MutableToken();
\r
2228 return this._token;
\r
2231 if (!this._token) {
\r
2232 // save an object by returning the default
\r
2233 // cancelled token when cancellation happens
\r
2234 // before someone asks for the token
\r
2235 this._token = CancellationToken.Cancelled;
\r
2238 this._token.cancel();
\r
2242 if (!this._token) {
\r
2243 // ensure to initialize with an empty token if we had none
\r
2244 this._token = CancellationToken.None;
\r
2246 else if (this._token instanceof MutableToken) {
\r
2247 // actually dispose
\r
2248 this._token.dispose();
\r
2252 exports.CancellationTokenSource = CancellationTokenSource;
\r
2257 /***/ (function(module, exports, __webpack_require__) {
2261 /*---------------------------------------------------------------------------------------------
\r
2262 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2263 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2264 *--------------------------------------------------------------------------------------------*/
\r
2265 Object.defineProperty(exports, "__esModule", { value: true });
\r
2267 (function (Touch) {
\r
2271 })(Touch = exports.Touch || (exports.Touch = {}));
\r
2274 this._map = new Map();
\r
2275 this._head = undefined;
\r
2276 this._tail = undefined;
\r
2280 this._map.clear();
\r
2281 this._head = undefined;
\r
2282 this._tail = undefined;
\r
2286 return !this._head && !this._tail;
\r
2289 return this._size;
\r
2292 return this._map.has(key);
\r
2295 const item = this._map.get(key);
\r
2299 return item.value;
\r
2301 set(key, value, touch = Touch.None) {
\r
2302 let item = this._map.get(key);
\r
2304 item.value = value;
\r
2305 if (touch !== Touch.None) {
\r
2306 this.touch(item, touch);
\r
2310 item = { key, value, next: undefined, previous: undefined };
\r
2313 this.addItemLast(item);
\r
2316 this.addItemFirst(item);
\r
2319 this.addItemLast(item);
\r
2322 this.addItemLast(item);
\r
2325 this._map.set(key, item);
\r
2330 const item = this._map.get(key);
\r
2334 this._map.delete(key);
\r
2335 this.removeItem(item);
\r
2340 if (!this._head && !this._tail) {
\r
2343 if (!this._head || !this._tail) {
\r
2344 throw new Error('Invalid list');
\r
2346 const item = this._head;
\r
2347 this._map.delete(item.key);
\r
2348 this.removeItem(item);
\r
2350 return item.value;
\r
2352 forEach(callbackfn, thisArg) {
\r
2353 let current = this._head;
\r
2356 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2359 callbackfn(current.value, current.key, this);
\r
2361 current = current.next;
\r
2364 forEachReverse(callbackfn, thisArg) {
\r
2365 let current = this._tail;
\r
2368 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2371 callbackfn(current.value, current.key, this);
\r
2373 current = current.previous;
\r
2378 let current = this._head;
\r
2380 result.push(current.value);
\r
2381 current = current.next;
\r
2387 let current = this._head;
\r
2389 result.push(current.key);
\r
2390 current = current.next;
\r
2394 /* JSON RPC run on es5 which has no Symbol.iterator
\r
2395 public keys(): IterableIterator<K> {
\r
2396 let current = this._head;
\r
2397 let iterator: IterableIterator<K> = {
\r
2398 [Symbol.iterator]() {
\r
2401 next():IteratorResult<K> {
\r
2403 let result = { value: current.key, done: false };
\r
2404 current = current.next;
\r
2407 return { value: undefined, done: true };
\r
2414 public values(): IterableIterator<V> {
\r
2415 let current = this._head;
\r
2416 let iterator: IterableIterator<V> = {
\r
2417 [Symbol.iterator]() {
\r
2420 next():IteratorResult<V> {
\r
2422 let result = { value: current.value, done: false };
\r
2423 current = current.next;
\r
2426 return { value: undefined, done: true };
\r
2433 addItemFirst(item) {
\r
2434 // First time Insert
\r
2435 if (!this._head && !this._tail) {
\r
2436 this._tail = item;
\r
2438 else if (!this._head) {
\r
2439 throw new Error('Invalid list');
\r
2442 item.next = this._head;
\r
2443 this._head.previous = item;
\r
2445 this._head = item;
\r
2447 addItemLast(item) {
\r
2448 // First time Insert
\r
2449 if (!this._head && !this._tail) {
\r
2450 this._head = item;
\r
2452 else if (!this._tail) {
\r
2453 throw new Error('Invalid list');
\r
2456 item.previous = this._tail;
\r
2457 this._tail.next = item;
\r
2459 this._tail = item;
\r
2461 removeItem(item) {
\r
2462 if (item === this._head && item === this._tail) {
\r
2463 this._head = undefined;
\r
2464 this._tail = undefined;
\r
2466 else if (item === this._head) {
\r
2467 this._head = item.next;
\r
2469 else if (item === this._tail) {
\r
2470 this._tail = item.previous;
\r
2473 const next = item.next;
\r
2474 const previous = item.previous;
\r
2475 if (!next || !previous) {
\r
2476 throw new Error('Invalid list');
\r
2478 next.previous = previous;
\r
2479 previous.next = next;
\r
2482 touch(item, touch) {
\r
2483 if (!this._head || !this._tail) {
\r
2484 throw new Error('Invalid list');
\r
2486 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
2489 if (touch === Touch.First) {
\r
2490 if (item === this._head) {
\r
2493 const next = item.next;
\r
2494 const previous = item.previous;
\r
2495 // Unlink the item
\r
2496 if (item === this._tail) {
\r
2497 // previous must be defined since item was not head but is tail
\r
2498 // So there are more than on item in the map
\r
2499 previous.next = undefined;
\r
2500 this._tail = previous;
\r
2503 // Both next and previous are not undefined since item was neither head nor tail.
\r
2504 next.previous = previous;
\r
2505 previous.next = next;
\r
2507 // Insert the node at head
\r
2508 item.previous = undefined;
\r
2509 item.next = this._head;
\r
2510 this._head.previous = item;
\r
2511 this._head = item;
\r
2513 else if (touch === Touch.Last) {
\r
2514 if (item === this._tail) {
\r
2517 const next = item.next;
\r
2518 const previous = item.previous;
\r
2519 // Unlink the item.
\r
2520 if (item === this._head) {
\r
2521 // next must be defined since item was not tail but is head
\r
2522 // So there are more than on item in the map
\r
2523 next.previous = undefined;
\r
2524 this._head = next;
\r
2527 // Both next and previous are not undefined since item was neither head nor tail.
\r
2528 next.previous = previous;
\r
2529 previous.next = next;
\r
2531 item.next = undefined;
\r
2532 item.previous = this._tail;
\r
2533 this._tail.next = item;
\r
2534 this._tail = item;
\r
2538 exports.LinkedMap = LinkedMap;
\r
2543 /***/ (function(module, exports, __webpack_require__) {
2546 /* --------------------------------------------------------------------------------------------
\r
2547 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2548 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2549 * ------------------------------------------------------------------------------------------ */
\r
2551 Object.defineProperty(exports, "__esModule", { value: true });
\r
2552 const path_1 = __webpack_require__(12);
\r
2553 const os_1 = __webpack_require__(13);
\r
2554 const crypto_1 = __webpack_require__(14);
\r
2555 const net_1 = __webpack_require__(15);
\r
2556 const messageReader_1 = __webpack_require__(6);
\r
2557 const messageWriter_1 = __webpack_require__(8);
\r
2558 function generateRandomPipeName() {
\r
2559 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
\r
2560 if (process.platform === 'win32') {
\r
2561 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
\r
2564 // Mac/Unix: use socket file
\r
2565 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\r
2568 exports.generateRandomPipeName = generateRandomPipeName;
\r
2569 function createClientPipeTransport(pipeName, encoding = 'utf-8') {
\r
2570 let connectResolve;
\r
2571 let connected = new Promise((resolve, _reject) => {
\r
2572 connectResolve = resolve;
\r
2574 return new Promise((resolve, reject) => {
\r
2575 let server = net_1.createServer((socket) => {
\r
2578 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2579 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2582 server.on('error', reject);
\r
2583 server.listen(pipeName, () => {
\r
2584 server.removeListener('error', reject);
\r
2586 onConnected: () => { return connected; }
\r
2591 exports.createClientPipeTransport = createClientPipeTransport;
\r
2592 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
2593 const socket = net_1.createConnection(pipeName);
\r
2595 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2596 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2599 exports.createServerPipeTransport = createServerPipeTransport;
\r
2604 /***/ (function(module, exports) {
2606 module.exports = require("path");
2610 /***/ (function(module, exports) {
2612 module.exports = require("os");
2616 /***/ (function(module, exports) {
2618 module.exports = require("crypto");
2622 /***/ (function(module, exports) {
2624 module.exports = require("net");
2628 /***/ (function(module, exports, __webpack_require__) {
2631 /* --------------------------------------------------------------------------------------------
\r
2632 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2633 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2634 * ------------------------------------------------------------------------------------------ */
\r
2636 Object.defineProperty(exports, "__esModule", { value: true });
\r
2637 const net_1 = __webpack_require__(15);
\r
2638 const messageReader_1 = __webpack_require__(6);
\r
2639 const messageWriter_1 = __webpack_require__(8);
\r
2640 function createClientSocketTransport(port, encoding = 'utf-8') {
\r
2641 let connectResolve;
\r
2642 let connected = new Promise((resolve, _reject) => {
\r
2643 connectResolve = resolve;
\r
2645 return new Promise((resolve, reject) => {
\r
2646 let server = net_1.createServer((socket) => {
\r
2649 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2650 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2653 server.on('error', reject);
\r
2654 server.listen(port, '127.0.0.1', () => {
\r
2655 server.removeListener('error', reject);
\r
2657 onConnected: () => { return connected; }
\r
2662 exports.createClientSocketTransport = createClientSocketTransport;
\r
2663 function createServerSocketTransport(port, encoding = 'utf-8') {
\r
2664 const socket = net_1.createConnection(port, '127.0.0.1');
\r
2666 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2667 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2670 exports.createServerSocketTransport = createServerSocketTransport;
\r
2675 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2678 __webpack_require__.r(__webpack_exports__);
2679 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2680 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2681 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2682 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2683 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2684 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2685 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2686 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2687 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2688 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2689 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2690 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
2691 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2692 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2693 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2694 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2695 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2696 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2697 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2698 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2699 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2700 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2701 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2702 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2703 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2704 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2705 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2706 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2707 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemTag", function() { return CompletionItemTag; });
2708 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2709 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2710 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2711 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2712 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2713 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2714 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2715 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2716 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2717 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolTag", function() { return SymbolTag; });
2718 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2719 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2720 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2721 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2722 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2723 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2724 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2725 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2726 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
2727 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2728 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2729 /* --------------------------------------------------------------------------------------------
\r
2730 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2731 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2732 * ------------------------------------------------------------------------------------------ */
\r
2735 * The Position namespace provides helper functions to work with
\r
2736 * [Position](#Position) literals.
\r
2739 (function (Position) {
\r
2741 * Creates a new Position literal from the given line and character.
\r
2742 * @param line The position's line.
\r
2743 * @param character The position's character.
\r
2745 function create(line, character) {
\r
2746 return { line: line, character: character };
\r
2748 Position.create = create;
\r
2750 * Checks whether the given liternal conforms to the [Position](#Position) interface.
\r
2752 function is(value) {
\r
2753 var candidate = value;
\r
2754 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
\r
2757 })(Position || (Position = {}));
\r
2759 * The Range namespace provides helper functions to work with
\r
2760 * [Range](#Range) literals.
\r
2763 (function (Range) {
\r
2764 function create(one, two, three, four) {
\r
2765 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
\r
2766 return { start: Position.create(one, two), end: Position.create(three, four) };
\r
2768 else if (Position.is(one) && Position.is(two)) {
\r
2769 return { start: one, end: two };
\r
2772 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
\r
2775 Range.create = create;
\r
2777 * Checks whether the given literal conforms to the [Range](#Range) interface.
\r
2779 function is(value) {
\r
2780 var candidate = value;
\r
2781 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
\r
2784 })(Range || (Range = {}));
\r
2786 * The Location namespace provides helper functions to work with
\r
2787 * [Location](#Location) literals.
\r
2790 (function (Location) {
\r
2792 * Creates a Location literal.
\r
2793 * @param uri The location's uri.
\r
2794 * @param range The location's range.
\r
2796 function create(uri, range) {
\r
2797 return { uri: uri, range: range };
\r
2799 Location.create = create;
\r
2801 * Checks whether the given literal conforms to the [Location](#Location) interface.
\r
2803 function is(value) {
\r
2804 var candidate = value;
\r
2805 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
\r
2808 })(Location || (Location = {}));
\r
2810 * The LocationLink namespace provides helper functions to work with
\r
2811 * [LocationLink](#LocationLink) literals.
\r
2814 (function (LocationLink) {
\r
2816 * Creates a LocationLink literal.
\r
2817 * @param targetUri The definition's uri.
\r
2818 * @param targetRange The full range of the definition.
\r
2819 * @param targetSelectionRange The span of the symbol definition at the target.
\r
2820 * @param originSelectionRange The span of the symbol being defined in the originating source file.
\r
2822 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
\r
2823 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
\r
2825 LocationLink.create = create;
\r
2827 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
\r
2829 function is(value) {
\r
2830 var candidate = value;
\r
2831 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
\r
2832 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
\r
2833 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
\r
2835 LocationLink.is = is;
\r
2836 })(LocationLink || (LocationLink = {}));
\r
2838 * The Color namespace provides helper functions to work with
\r
2839 * [Color](#Color) literals.
\r
2842 (function (Color) {
\r
2844 * Creates a new Color literal.
\r
2846 function create(red, green, blue, alpha) {
\r
2854 Color.create = create;
\r
2856 * Checks whether the given literal conforms to the [Color](#Color) interface.
\r
2858 function is(value) {
\r
2859 var candidate = value;
\r
2860 return Is.number(candidate.red)
\r
2861 && Is.number(candidate.green)
\r
2862 && Is.number(candidate.blue)
\r
2863 && Is.number(candidate.alpha);
\r
2866 })(Color || (Color = {}));
\r
2868 * The ColorInformation namespace provides helper functions to work with
\r
2869 * [ColorInformation](#ColorInformation) literals.
\r
2871 var ColorInformation;
\r
2872 (function (ColorInformation) {
\r
2874 * Creates a new ColorInformation literal.
\r
2876 function create(range, color) {
\r
2882 ColorInformation.create = create;
\r
2884 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
2886 function is(value) {
\r
2887 var candidate = value;
\r
2888 return Range.is(candidate.range) && Color.is(candidate.color);
\r
2890 ColorInformation.is = is;
\r
2891 })(ColorInformation || (ColorInformation = {}));
\r
2893 * The Color namespace provides helper functions to work with
\r
2894 * [ColorPresentation](#ColorPresentation) literals.
\r
2896 var ColorPresentation;
\r
2897 (function (ColorPresentation) {
\r
2899 * Creates a new ColorInformation literal.
\r
2901 function create(label, textEdit, additionalTextEdits) {
\r
2904 textEdit: textEdit,
\r
2905 additionalTextEdits: additionalTextEdits,
\r
2908 ColorPresentation.create = create;
\r
2910 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
2912 function is(value) {
\r
2913 var candidate = value;
\r
2914 return Is.string(candidate.label)
\r
2915 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
\r
2916 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
\r
2918 ColorPresentation.is = is;
\r
2919 })(ColorPresentation || (ColorPresentation = {}));
\r
2921 * Enum of known range kinds
\r
2923 var FoldingRangeKind;
\r
2924 (function (FoldingRangeKind) {
\r
2926 * Folding range for a comment
\r
2928 FoldingRangeKind["Comment"] = "comment";
\r
2930 * Folding range for a imports or includes
\r
2932 FoldingRangeKind["Imports"] = "imports";
\r
2934 * Folding range for a region (e.g. `#region`)
\r
2936 FoldingRangeKind["Region"] = "region";
\r
2937 })(FoldingRangeKind || (FoldingRangeKind = {}));
\r
2939 * The folding range namespace provides helper functions to work with
\r
2940 * [FoldingRange](#FoldingRange) literals.
\r
2943 (function (FoldingRange) {
\r
2945 * Creates a new FoldingRange literal.
\r
2947 function create(startLine, endLine, startCharacter, endCharacter, kind) {
\r
2949 startLine: startLine,
\r
2952 if (Is.defined(startCharacter)) {
\r
2953 result.startCharacter = startCharacter;
\r
2955 if (Is.defined(endCharacter)) {
\r
2956 result.endCharacter = endCharacter;
\r
2958 if (Is.defined(kind)) {
\r
2959 result.kind = kind;
\r
2963 FoldingRange.create = create;
\r
2965 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
\r
2967 function is(value) {
\r
2968 var candidate = value;
\r
2969 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
\r
2970 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
\r
2971 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
\r
2972 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
\r
2974 FoldingRange.is = is;
\r
2975 })(FoldingRange || (FoldingRange = {}));
\r
2977 * The DiagnosticRelatedInformation namespace provides helper functions to work with
\r
2978 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
\r
2980 var DiagnosticRelatedInformation;
\r
2981 (function (DiagnosticRelatedInformation) {
\r
2983 * Creates a new DiagnosticRelatedInformation literal.
\r
2985 function create(location, message) {
\r
2987 location: location,
\r
2991 DiagnosticRelatedInformation.create = create;
\r
2993 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
\r
2995 function is(value) {
\r
2996 var candidate = value;
\r
2997 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
\r
2999 DiagnosticRelatedInformation.is = is;
\r
3000 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
\r
3002 * The diagnostic's severity.
\r
3004 var DiagnosticSeverity;
\r
3005 (function (DiagnosticSeverity) {
\r
3007 * Reports an error.
\r
3009 DiagnosticSeverity.Error = 1;
\r
3011 * Reports a warning.
\r
3013 DiagnosticSeverity.Warning = 2;
\r
3015 * Reports an information.
\r
3017 DiagnosticSeverity.Information = 3;
\r
3021 DiagnosticSeverity.Hint = 4;
\r
3022 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
\r
3024 * The diagnostic tags.
\r
3028 var DiagnosticTag;
\r
3029 (function (DiagnosticTag) {
\r
3031 * Unused or unnecessary code.
\r
3033 * Clients are allowed to render diagnostics with this tag faded out instead of having
\r
3034 * an error squiggle.
\r
3036 DiagnosticTag.Unnecessary = 1;
\r
3038 * Deprecated or obsolete code.
\r
3040 * Clients are allowed to rendered diagnostics with this tag strike through.
\r
3042 DiagnosticTag.Deprecated = 2;
\r
3043 })(DiagnosticTag || (DiagnosticTag = {}));
\r
3045 * The Diagnostic namespace provides helper functions to work with
\r
3046 * [Diagnostic](#Diagnostic) literals.
\r
3049 (function (Diagnostic) {
\r
3051 * Creates a new Diagnostic literal.
\r
3053 function create(range, message, severity, code, source, relatedInformation) {
\r
3054 var result = { range: range, message: message };
\r
3055 if (Is.defined(severity)) {
\r
3056 result.severity = severity;
\r
3058 if (Is.defined(code)) {
\r
3059 result.code = code;
\r
3061 if (Is.defined(source)) {
\r
3062 result.source = source;
\r
3064 if (Is.defined(relatedInformation)) {
\r
3065 result.relatedInformation = relatedInformation;
\r
3069 Diagnostic.create = create;
\r
3071 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
\r
3073 function is(value) {
\r
3074 var candidate = value;
\r
3075 return Is.defined(candidate)
\r
3076 && Range.is(candidate.range)
\r
3077 && Is.string(candidate.message)
\r
3078 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
\r
3079 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
\r
3080 && (Is.string(candidate.source) || Is.undefined(candidate.source))
\r
3081 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
\r
3083 Diagnostic.is = is;
\r
3084 })(Diagnostic || (Diagnostic = {}));
\r
3086 * The Command namespace provides helper functions to work with
\r
3087 * [Command](#Command) literals.
\r
3090 (function (Command) {
\r
3092 * Creates a new Command literal.
\r
3094 function create(title, command) {
\r
3096 for (var _i = 2; _i < arguments.length; _i++) {
\r
3097 args[_i - 2] = arguments[_i];
\r
3099 var result = { title: title, command: command };
\r
3100 if (Is.defined(args) && args.length > 0) {
\r
3101 result.arguments = args;
\r
3105 Command.create = create;
\r
3107 * Checks whether the given literal conforms to the [Command](#Command) interface.
\r
3109 function is(value) {
\r
3110 var candidate = value;
\r
3111 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
\r
3114 })(Command || (Command = {}));
\r
3116 * The TextEdit namespace provides helper function to create replace,
\r
3117 * insert and delete edits more easily.
\r
3120 (function (TextEdit) {
\r
3122 * Creates a replace text edit.
\r
3123 * @param range The range of text to be replaced.
\r
3124 * @param newText The new text.
\r
3126 function replace(range, newText) {
\r
3127 return { range: range, newText: newText };
\r
3129 TextEdit.replace = replace;
\r
3131 * Creates a insert text edit.
\r
3132 * @param position The position to insert the text at.
\r
3133 * @param newText The text to be inserted.
\r
3135 function insert(position, newText) {
\r
3136 return { range: { start: position, end: position }, newText: newText };
\r
3138 TextEdit.insert = insert;
\r
3140 * Creates a delete text edit.
\r
3141 * @param range The range of text to be deleted.
\r
3143 function del(range) {
\r
3144 return { range: range, newText: '' };
\r
3146 TextEdit.del = del;
\r
3147 function is(value) {
\r
3148 var candidate = value;
\r
3149 return Is.objectLiteral(candidate)
\r
3150 && Is.string(candidate.newText)
\r
3151 && Range.is(candidate.range);
\r
3154 })(TextEdit || (TextEdit = {}));
\r
3156 * The TextDocumentEdit namespace provides helper function to create
\r
3157 * an edit that manipulates a text document.
\r
3159 var TextDocumentEdit;
\r
3160 (function (TextDocumentEdit) {
\r
3162 * Creates a new `TextDocumentEdit`
\r
3164 function create(textDocument, edits) {
\r
3165 return { textDocument: textDocument, edits: edits };
\r
3167 TextDocumentEdit.create = create;
\r
3168 function is(value) {
\r
3169 var candidate = value;
\r
3170 return Is.defined(candidate)
\r
3171 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
\r
3172 && Array.isArray(candidate.edits);
\r
3174 TextDocumentEdit.is = is;
\r
3175 })(TextDocumentEdit || (TextDocumentEdit = {}));
\r
3177 (function (CreateFile) {
\r
3178 function create(uri, options) {
\r
3183 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3184 result.options = options;
\r
3188 CreateFile.create = create;
\r
3189 function is(value) {
\r
3190 var candidate = value;
\r
3191 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
\r
3192 (candidate.options === void 0 ||
\r
3193 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3195 CreateFile.is = is;
\r
3196 })(CreateFile || (CreateFile = {}));
\r
3198 (function (RenameFile) {
\r
3199 function create(oldUri, newUri, options) {
\r
3205 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3206 result.options = options;
\r
3210 RenameFile.create = create;
\r
3211 function is(value) {
\r
3212 var candidate = value;
\r
3213 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
\r
3214 (candidate.options === void 0 ||
\r
3215 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3217 RenameFile.is = is;
\r
3218 })(RenameFile || (RenameFile = {}));
\r
3220 (function (DeleteFile) {
\r
3221 function create(uri, options) {
\r
3226 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
\r
3227 result.options = options;
\r
3231 DeleteFile.create = create;
\r
3232 function is(value) {
\r
3233 var candidate = value;
\r
3234 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
\r
3235 (candidate.options === void 0 ||
\r
3236 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
\r
3238 DeleteFile.is = is;
\r
3239 })(DeleteFile || (DeleteFile = {}));
\r
3240 var WorkspaceEdit;
\r
3241 (function (WorkspaceEdit) {
\r
3242 function is(value) {
\r
3243 var candidate = value;
\r
3244 return candidate &&
\r
3245 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
\r
3246 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
\r
3247 if (Is.string(change.kind)) {
\r
3248 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
\r
3251 return TextDocumentEdit.is(change);
\r
3255 WorkspaceEdit.is = is;
\r
3256 })(WorkspaceEdit || (WorkspaceEdit = {}));
\r
3257 var TextEditChangeImpl = /** @class */ (function () {
\r
3258 function TextEditChangeImpl(edits) {
\r
3259 this.edits = edits;
\r
3261 TextEditChangeImpl.prototype.insert = function (position, newText) {
\r
3262 this.edits.push(TextEdit.insert(position, newText));
\r
3264 TextEditChangeImpl.prototype.replace = function (range, newText) {
\r
3265 this.edits.push(TextEdit.replace(range, newText));
\r
3267 TextEditChangeImpl.prototype.delete = function (range) {
\r
3268 this.edits.push(TextEdit.del(range));
\r
3270 TextEditChangeImpl.prototype.add = function (edit) {
\r
3271 this.edits.push(edit);
\r
3273 TextEditChangeImpl.prototype.all = function () {
\r
3274 return this.edits;
\r
3276 TextEditChangeImpl.prototype.clear = function () {
\r
3277 this.edits.splice(0, this.edits.length);
\r
3279 return TextEditChangeImpl;
\r
3282 * A workspace change helps constructing changes to a workspace.
\r
3284 var WorkspaceChange = /** @class */ (function () {
\r
3285 function WorkspaceChange(workspaceEdit) {
\r
3287 this._textEditChanges = Object.create(null);
\r
3288 if (workspaceEdit) {
\r
3289 this._workspaceEdit = workspaceEdit;
\r
3290 if (workspaceEdit.documentChanges) {
\r
3291 workspaceEdit.documentChanges.forEach(function (change) {
\r
3292 if (TextDocumentEdit.is(change)) {
\r
3293 var textEditChange = new TextEditChangeImpl(change.edits);
\r
3294 _this._textEditChanges[change.textDocument.uri] = textEditChange;
\r
3298 else if (workspaceEdit.changes) {
\r
3299 Object.keys(workspaceEdit.changes).forEach(function (key) {
\r
3300 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
\r
3301 _this._textEditChanges[key] = textEditChange;
\r
3306 Object.defineProperty(WorkspaceChange.prototype, "edit", {
\r
3308 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
\r
3309 * use to be returned from a workspace edit operation like rename.
\r
3311 get: function () {
\r
3312 return this._workspaceEdit;
\r
3315 configurable: true
\r
3317 WorkspaceChange.prototype.getTextEditChange = function (key) {
\r
3318 if (VersionedTextDocumentIdentifier.is(key)) {
\r
3319 if (!this._workspaceEdit) {
\r
3320 this._workspaceEdit = {
\r
3321 documentChanges: []
\r
3324 if (!this._workspaceEdit.documentChanges) {
\r
3325 throw new Error('Workspace edit is not configured for document changes.');
\r
3327 var textDocument = key;
\r
3328 var result = this._textEditChanges[textDocument.uri];
\r
3331 var textDocumentEdit = {
\r
3332 textDocument: textDocument,
\r
3335 this._workspaceEdit.documentChanges.push(textDocumentEdit);
\r
3336 result = new TextEditChangeImpl(edits);
\r
3337 this._textEditChanges[textDocument.uri] = result;
\r
3342 if (!this._workspaceEdit) {
\r
3343 this._workspaceEdit = {
\r
3344 changes: Object.create(null)
\r
3347 if (!this._workspaceEdit.changes) {
\r
3348 throw new Error('Workspace edit is not configured for normal text edit changes.');
\r
3350 var result = this._textEditChanges[key];
\r
3353 this._workspaceEdit.changes[key] = edits;
\r
3354 result = new TextEditChangeImpl(edits);
\r
3355 this._textEditChanges[key] = result;
\r
3360 WorkspaceChange.prototype.createFile = function (uri, options) {
\r
3361 this.checkDocumentChanges();
\r
3362 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
\r
3364 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
\r
3365 this.checkDocumentChanges();
\r
3366 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
\r
3368 WorkspaceChange.prototype.deleteFile = function (uri, options) {
\r
3369 this.checkDocumentChanges();
\r
3370 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
\r
3372 WorkspaceChange.prototype.checkDocumentChanges = function () {
\r
3373 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
\r
3374 throw new Error('Workspace edit is not configured for document changes.');
\r
3377 return WorkspaceChange;
\r
3381 * The TextDocumentIdentifier namespace provides helper functions to work with
\r
3382 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
\r
3384 var TextDocumentIdentifier;
\r
3385 (function (TextDocumentIdentifier) {
\r
3387 * Creates a new TextDocumentIdentifier literal.
\r
3388 * @param uri The document's uri.
\r
3390 function create(uri) {
\r
3391 return { uri: uri };
\r
3393 TextDocumentIdentifier.create = create;
\r
3395 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
\r
3397 function is(value) {
\r
3398 var candidate = value;
\r
3399 return Is.defined(candidate) && Is.string(candidate.uri);
\r
3401 TextDocumentIdentifier.is = is;
\r
3402 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
\r
3404 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
\r
3405 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
\r
3407 var VersionedTextDocumentIdentifier;
\r
3408 (function (VersionedTextDocumentIdentifier) {
\r
3410 * Creates a new VersionedTextDocumentIdentifier literal.
\r
3411 * @param uri The document's uri.
\r
3412 * @param uri The document's text.
\r
3414 function create(uri, version) {
\r
3415 return { uri: uri, version: version };
\r
3417 VersionedTextDocumentIdentifier.create = create;
\r
3419 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
\r
3421 function is(value) {
\r
3422 var candidate = value;
\r
3423 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
\r
3425 VersionedTextDocumentIdentifier.is = is;
\r
3426 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
\r
3428 * The TextDocumentItem namespace provides helper functions to work with
\r
3429 * [TextDocumentItem](#TextDocumentItem) literals.
\r
3431 var TextDocumentItem;
\r
3432 (function (TextDocumentItem) {
\r
3434 * Creates a new TextDocumentItem literal.
\r
3435 * @param uri The document's uri.
\r
3436 * @param languageId The document's language identifier.
\r
3437 * @param version The document's version number.
\r
3438 * @param text The document's text.
\r
3440 function create(uri, languageId, version, text) {
\r
3441 return { uri: uri, languageId: languageId, version: version, text: text };
\r
3443 TextDocumentItem.create = create;
\r
3445 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
\r
3447 function is(value) {
\r
3448 var candidate = value;
\r
3449 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
\r
3451 TextDocumentItem.is = is;
\r
3452 })(TextDocumentItem || (TextDocumentItem = {}));
\r
3454 * Describes the content type that a client supports in various
\r
3455 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
\r
3457 * Please note that `MarkupKinds` must not start with a `$`. This kinds
\r
3458 * are reserved for internal usage.
\r
3461 (function (MarkupKind) {
\r
3463 * Plain text is supported as a content format
\r
3465 MarkupKind.PlainText = 'plaintext';
\r
3467 * Markdown is supported as a content format
\r
3469 MarkupKind.Markdown = 'markdown';
\r
3470 })(MarkupKind || (MarkupKind = {}));
\r
3471 (function (MarkupKind) {
\r
3473 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
\r
3475 function is(value) {
\r
3476 var candidate = value;
\r
3477 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
\r
3479 MarkupKind.is = is;
\r
3480 })(MarkupKind || (MarkupKind = {}));
\r
3481 var MarkupContent;
\r
3482 (function (MarkupContent) {
\r
3484 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
\r
3486 function is(value) {
\r
3487 var candidate = value;
\r
3488 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
\r
3490 MarkupContent.is = is;
\r
3491 })(MarkupContent || (MarkupContent = {}));
\r
3493 * The kind of a completion entry.
\r
3495 var CompletionItemKind;
\r
3496 (function (CompletionItemKind) {
\r
3497 CompletionItemKind.Text = 1;
\r
3498 CompletionItemKind.Method = 2;
\r
3499 CompletionItemKind.Function = 3;
\r
3500 CompletionItemKind.Constructor = 4;
\r
3501 CompletionItemKind.Field = 5;
\r
3502 CompletionItemKind.Variable = 6;
\r
3503 CompletionItemKind.Class = 7;
\r
3504 CompletionItemKind.Interface = 8;
\r
3505 CompletionItemKind.Module = 9;
\r
3506 CompletionItemKind.Property = 10;
\r
3507 CompletionItemKind.Unit = 11;
\r
3508 CompletionItemKind.Value = 12;
\r
3509 CompletionItemKind.Enum = 13;
\r
3510 CompletionItemKind.Keyword = 14;
\r
3511 CompletionItemKind.Snippet = 15;
\r
3512 CompletionItemKind.Color = 16;
\r
3513 CompletionItemKind.File = 17;
\r
3514 CompletionItemKind.Reference = 18;
\r
3515 CompletionItemKind.Folder = 19;
\r
3516 CompletionItemKind.EnumMember = 20;
\r
3517 CompletionItemKind.Constant = 21;
\r
3518 CompletionItemKind.Struct = 22;
\r
3519 CompletionItemKind.Event = 23;
\r
3520 CompletionItemKind.Operator = 24;
\r
3521 CompletionItemKind.TypeParameter = 25;
\r
3522 })(CompletionItemKind || (CompletionItemKind = {}));
\r
3524 * Defines whether the insert text in a completion item should be interpreted as
\r
3525 * plain text or a snippet.
\r
3527 var InsertTextFormat;
\r
3528 (function (InsertTextFormat) {
\r
3530 * The primary text to be inserted is treated as a plain string.
\r
3532 InsertTextFormat.PlainText = 1;
\r
3534 * The primary text to be inserted is treated as a snippet.
\r
3536 * A snippet can define tab stops and placeholders with `$1`, `$2`
\r
3537 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
\r
3538 * the end of the snippet. Placeholders with equal identifiers are linked,
\r
3539 * that is typing in one will update others too.
\r
3541 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
\r
3543 InsertTextFormat.Snippet = 2;
\r
3544 })(InsertTextFormat || (InsertTextFormat = {}));
\r
3546 * Completion item tags are extra annotations that tweak the rendering of a completion
\r
3551 var CompletionItemTag;
\r
3552 (function (CompletionItemTag) {
\r
3554 * Render a completion as obsolete, usually using a strike-out.
\r
3556 CompletionItemTag.Deprecated = 1;
\r
3557 })(CompletionItemTag || (CompletionItemTag = {}));
\r
3559 * The CompletionItem namespace provides functions to deal with
\r
3560 * completion items.
\r
3562 var CompletionItem;
\r
3563 (function (CompletionItem) {
\r
3565 * Create a completion item and seed it with a label.
\r
3566 * @param label The completion item's label
\r
3568 function create(label) {
\r
3569 return { label: label };
\r
3571 CompletionItem.create = create;
\r
3572 })(CompletionItem || (CompletionItem = {}));
\r
3574 * The CompletionList namespace provides functions to deal with
\r
3575 * completion lists.
\r
3577 var CompletionList;
\r
3578 (function (CompletionList) {
\r
3580 * Creates a new completion list.
\r
3582 * @param items The completion items.
\r
3583 * @param isIncomplete The list is not complete.
\r
3585 function create(items, isIncomplete) {
\r
3586 return { items: items ? items : [], isIncomplete: !!isIncomplete };
\r
3588 CompletionList.create = create;
\r
3589 })(CompletionList || (CompletionList = {}));
\r
3591 (function (MarkedString) {
\r
3593 * Creates a marked string from plain text.
\r
3595 * @param plainText The plain text.
\r
3597 function fromPlainText(plainText) {
\r
3598 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
\r
3600 MarkedString.fromPlainText = fromPlainText;
\r
3602 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
\r
3604 function is(value) {
\r
3605 var candidate = value;
\r
3606 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
\r
3608 MarkedString.is = is;
\r
3609 })(MarkedString || (MarkedString = {}));
\r
3611 (function (Hover) {
\r
3613 * Checks whether the given value conforms to the [Hover](#Hover) interface.
\r
3615 function is(value) {
\r
3616 var candidate = value;
\r
3617 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
\r
3618 MarkedString.is(candidate.contents) ||
\r
3619 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
\r
3622 })(Hover || (Hover = {}));
\r
3624 * The ParameterInformation namespace provides helper functions to work with
\r
3625 * [ParameterInformation](#ParameterInformation) literals.
\r
3627 var ParameterInformation;
\r
3628 (function (ParameterInformation) {
\r
3630 * Creates a new parameter information literal.
\r
3632 * @param label A label string.
\r
3633 * @param documentation A doc string.
\r
3635 function create(label, documentation) {
\r
3636 return documentation ? { label: label, documentation: documentation } : { label: label };
\r
3638 ParameterInformation.create = create;
\r
3639 })(ParameterInformation || (ParameterInformation = {}));
\r
3641 * The SignatureInformation namespace provides helper functions to work with
\r
3642 * [SignatureInformation](#SignatureInformation) literals.
\r
3644 var SignatureInformation;
\r
3645 (function (SignatureInformation) {
\r
3646 function create(label, documentation) {
\r
3647 var parameters = [];
\r
3648 for (var _i = 2; _i < arguments.length; _i++) {
\r
3649 parameters[_i - 2] = arguments[_i];
\r
3651 var result = { label: label };
\r
3652 if (Is.defined(documentation)) {
\r
3653 result.documentation = documentation;
\r
3655 if (Is.defined(parameters)) {
\r
3656 result.parameters = parameters;
\r
3659 result.parameters = [];
\r
3663 SignatureInformation.create = create;
\r
3664 })(SignatureInformation || (SignatureInformation = {}));
\r
3666 * A document highlight kind.
\r
3668 var DocumentHighlightKind;
\r
3669 (function (DocumentHighlightKind) {
\r
3671 * A textual occurrence.
\r
3673 DocumentHighlightKind.Text = 1;
\r
3675 * Read-access of a symbol, like reading a variable.
\r
3677 DocumentHighlightKind.Read = 2;
\r
3679 * Write-access of a symbol, like writing to a variable.
\r
3681 DocumentHighlightKind.Write = 3;
\r
3682 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
\r
3684 * DocumentHighlight namespace to provide helper functions to work with
\r
3685 * [DocumentHighlight](#DocumentHighlight) literals.
\r
3687 var DocumentHighlight;
\r
3688 (function (DocumentHighlight) {
\r
3690 * Create a DocumentHighlight object.
\r
3691 * @param range The range the highlight applies to.
\r
3693 function create(range, kind) {
\r
3694 var result = { range: range };
\r
3695 if (Is.number(kind)) {
\r
3696 result.kind = kind;
\r
3700 DocumentHighlight.create = create;
\r
3701 })(DocumentHighlight || (DocumentHighlight = {}));
\r
3706 (function (SymbolKind) {
\r
3707 SymbolKind.File = 1;
\r
3708 SymbolKind.Module = 2;
\r
3709 SymbolKind.Namespace = 3;
\r
3710 SymbolKind.Package = 4;
\r
3711 SymbolKind.Class = 5;
\r
3712 SymbolKind.Method = 6;
\r
3713 SymbolKind.Property = 7;
\r
3714 SymbolKind.Field = 8;
\r
3715 SymbolKind.Constructor = 9;
\r
3716 SymbolKind.Enum = 10;
\r
3717 SymbolKind.Interface = 11;
\r
3718 SymbolKind.Function = 12;
\r
3719 SymbolKind.Variable = 13;
\r
3720 SymbolKind.Constant = 14;
\r
3721 SymbolKind.String = 15;
\r
3722 SymbolKind.Number = 16;
\r
3723 SymbolKind.Boolean = 17;
\r
3724 SymbolKind.Array = 18;
\r
3725 SymbolKind.Object = 19;
\r
3726 SymbolKind.Key = 20;
\r
3727 SymbolKind.Null = 21;
\r
3728 SymbolKind.EnumMember = 22;
\r
3729 SymbolKind.Struct = 23;
\r
3730 SymbolKind.Event = 24;
\r
3731 SymbolKind.Operator = 25;
\r
3732 SymbolKind.TypeParameter = 26;
\r
3733 })(SymbolKind || (SymbolKind = {}));
\r
3735 * Symbol tags are extra annotations that tweak the rendering of a symbol.
\r
3739 (function (SymbolTag) {
\r
3741 * Render a symbol as obsolete, usually using a strike-out.
\r
3743 SymbolTag.Deprecated = 1;
\r
3744 })(SymbolTag || (SymbolTag = {}));
\r
3745 var SymbolInformation;
\r
3746 (function (SymbolInformation) {
\r
3748 * Creates a new symbol information literal.
\r
3750 * @param name The name of the symbol.
\r
3751 * @param kind The kind of the symbol.
\r
3752 * @param range The range of the location of the symbol.
\r
3753 * @param uri The resource of the location of symbol, defaults to the current document.
\r
3754 * @param containerName The name of the symbol containing the symbol.
\r
3756 function create(name, kind, range, uri, containerName) {
\r
3760 location: { uri: uri, range: range }
\r
3762 if (containerName) {
\r
3763 result.containerName = containerName;
\r
3767 SymbolInformation.create = create;
\r
3768 })(SymbolInformation || (SymbolInformation = {}));
\r
3769 var DocumentSymbol;
\r
3770 (function (DocumentSymbol) {
\r
3772 * Creates a new symbol information literal.
\r
3774 * @param name The name of the symbol.
\r
3775 * @param detail The detail of the symbol.
\r
3776 * @param kind The kind of the symbol.
\r
3777 * @param range The range of the symbol.
\r
3778 * @param selectionRange The selectionRange of the symbol.
\r
3779 * @param children Children of the symbol.
\r
3781 function create(name, detail, kind, range, selectionRange, children) {
\r
3787 selectionRange: selectionRange
\r
3789 if (children !== void 0) {
\r
3790 result.children = children;
\r
3794 DocumentSymbol.create = create;
\r
3796 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
\r
3798 function is(value) {
\r
3799 var candidate = value;
\r
3800 return candidate &&
\r
3801 Is.string(candidate.name) && Is.number(candidate.kind) &&
\r
3802 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
\r
3803 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
\r
3804 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
\r
3805 (candidate.children === void 0 || Array.isArray(candidate.children));
\r
3807 DocumentSymbol.is = is;
\r
3808 })(DocumentSymbol || (DocumentSymbol = {}));
\r
3810 * A set of predefined code action kinds
\r
3812 var CodeActionKind;
\r
3813 (function (CodeActionKind) {
\r
3817 CodeActionKind.Empty = '';
\r
3819 * Base kind for quickfix actions: 'quickfix'
\r
3821 CodeActionKind.QuickFix = 'quickfix';
\r
3823 * Base kind for refactoring actions: 'refactor'
\r
3825 CodeActionKind.Refactor = 'refactor';
\r
3827 * Base kind for refactoring extraction actions: 'refactor.extract'
\r
3829 * Example extract actions:
\r
3831 * - Extract method
\r
3832 * - Extract function
\r
3833 * - Extract variable
\r
3834 * - Extract interface from class
\r
3837 CodeActionKind.RefactorExtract = 'refactor.extract';
\r
3839 * Base kind for refactoring inline actions: 'refactor.inline'
\r
3841 * Example inline actions:
\r
3843 * - Inline function
\r
3844 * - Inline variable
\r
3845 * - Inline constant
\r
3848 CodeActionKind.RefactorInline = 'refactor.inline';
\r
3850 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
\r
3852 * Example rewrite actions:
\r
3854 * - Convert JavaScript function to class
\r
3855 * - Add or remove parameter
\r
3856 * - Encapsulate field
\r
3857 * - Make method static
\r
3858 * - Move method to base class
\r
3861 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
\r
3863 * Base kind for source actions: `source`
\r
3865 * Source code actions apply to the entire file.
\r
3867 CodeActionKind.Source = 'source';
\r
3869 * Base kind for an organize imports source action: `source.organizeImports`
\r
3871 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
\r
3873 * Base kind for auto-fix source actions: `source.fixAll`.
\r
3875 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
\r
3876 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
\r
3880 CodeActionKind.SourceFixAll = 'source.fixAll';
\r
3881 })(CodeActionKind || (CodeActionKind = {}));
\r
3883 * The CodeActionContext namespace provides helper functions to work with
\r
3884 * [CodeActionContext](#CodeActionContext) literals.
\r
3886 var CodeActionContext;
\r
3887 (function (CodeActionContext) {
\r
3889 * Creates a new CodeActionContext literal.
\r
3891 function create(diagnostics, only) {
\r
3892 var result = { diagnostics: diagnostics };
\r
3893 if (only !== void 0 && only !== null) {
\r
3894 result.only = only;
\r
3898 CodeActionContext.create = create;
\r
3900 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
\r
3902 function is(value) {
\r
3903 var candidate = value;
\r
3904 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
\r
3906 CodeActionContext.is = is;
\r
3907 })(CodeActionContext || (CodeActionContext = {}));
\r
3909 (function (CodeAction) {
\r
3910 function create(title, commandOrEdit, kind) {
\r
3911 var result = { title: title };
\r
3912 if (Command.is(commandOrEdit)) {
\r
3913 result.command = commandOrEdit;
\r
3916 result.edit = commandOrEdit;
\r
3918 if (kind !== void 0) {
\r
3919 result.kind = kind;
\r
3923 CodeAction.create = create;
\r
3924 function is(value) {
\r
3925 var candidate = value;
\r
3926 return candidate && Is.string(candidate.title) &&
\r
3927 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
\r
3928 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
\r
3929 (candidate.edit !== void 0 || candidate.command !== void 0) &&
\r
3930 (candidate.command === void 0 || Command.is(candidate.command)) &&
\r
3931 (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) &&
\r
3932 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
\r
3934 CodeAction.is = is;
\r
3935 })(CodeAction || (CodeAction = {}));
\r
3937 * The CodeLens namespace provides helper functions to work with
\r
3938 * [CodeLens](#CodeLens) literals.
\r
3941 (function (CodeLens) {
\r
3943 * Creates a new CodeLens literal.
\r
3945 function create(range, data) {
\r
3946 var result = { range: range };
\r
3947 if (Is.defined(data)) {
\r
3948 result.data = data;
\r
3952 CodeLens.create = create;
\r
3954 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
\r
3956 function is(value) {
\r
3957 var candidate = value;
\r
3958 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
\r
3961 })(CodeLens || (CodeLens = {}));
\r
3963 * The FormattingOptions namespace provides helper functions to work with
\r
3964 * [FormattingOptions](#FormattingOptions) literals.
\r
3966 var FormattingOptions;
\r
3967 (function (FormattingOptions) {
\r
3969 * Creates a new FormattingOptions literal.
\r
3971 function create(tabSize, insertSpaces) {
\r
3972 return { tabSize: tabSize, insertSpaces: insertSpaces };
\r
3974 FormattingOptions.create = create;
\r
3976 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
\r
3978 function is(value) {
\r
3979 var candidate = value;
\r
3980 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
\r
3982 FormattingOptions.is = is;
\r
3983 })(FormattingOptions || (FormattingOptions = {}));
\r
3985 * The DocumentLink namespace provides helper functions to work with
\r
3986 * [DocumentLink](#DocumentLink) literals.
\r
3989 (function (DocumentLink) {
\r
3991 * Creates a new DocumentLink literal.
\r
3993 function create(range, target, data) {
\r
3994 return { range: range, target: target, data: data };
\r
3996 DocumentLink.create = create;
\r
3998 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
\r
4000 function is(value) {
\r
4001 var candidate = value;
\r
4002 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
\r
4004 DocumentLink.is = is;
\r
4005 })(DocumentLink || (DocumentLink = {}));
\r
4007 * The SelectionRange namespace provides helper function to work with
\r
4008 * SelectionRange literals.
\r
4010 var SelectionRange;
\r
4011 (function (SelectionRange) {
\r
4013 * Creates a new SelectionRange
\r
4014 * @param range the range.
\r
4015 * @param parent an optional parent.
\r
4017 function create(range, parent) {
\r
4018 return { range: range, parent: parent };
\r
4020 SelectionRange.create = create;
\r
4021 function is(value) {
\r
4022 var candidate = value;
\r
4023 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
\r
4025 SelectionRange.is = is;
\r
4026 })(SelectionRange || (SelectionRange = {}));
\r
4027 var EOL = ['\n', '\r\n', '\r'];
\r
4029 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
\r
4032 (function (TextDocument) {
\r
4034 * Creates a new ITextDocument literal from the given uri and content.
\r
4035 * @param uri The document's uri.
\r
4036 * @param languageId The document's language Id.
\r
4037 * @param content The document's content.
\r
4039 function create(uri, languageId, version, content) {
\r
4040 return new FullTextDocument(uri, languageId, version, content);
\r
4042 TextDocument.create = create;
\r
4044 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
\r
4046 function is(value) {
\r
4047 var candidate = value;
\r
4048 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
\r
4049 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
\r
4051 TextDocument.is = is;
\r
4052 function applyEdits(document, edits) {
\r
4053 var text = document.getText();
\r
4054 var sortedEdits = mergeSort(edits, function (a, b) {
\r
4055 var diff = a.range.start.line - b.range.start.line;
\r
4057 return a.range.start.character - b.range.start.character;
\r
4061 var lastModifiedOffset = text.length;
\r
4062 for (var i = sortedEdits.length - 1; i >= 0; i--) {
\r
4063 var e = sortedEdits[i];
\r
4064 var startOffset = document.offsetAt(e.range.start);
\r
4065 var endOffset = document.offsetAt(e.range.end);
\r
4066 if (endOffset <= lastModifiedOffset) {
\r
4067 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
\r
4070 throw new Error('Overlapping edit');
\r
4072 lastModifiedOffset = startOffset;
\r
4076 TextDocument.applyEdits = applyEdits;
\r
4077 function mergeSort(data, compare) {
\r
4078 if (data.length <= 1) {
\r
4082 var p = (data.length / 2) | 0;
\r
4083 var left = data.slice(0, p);
\r
4084 var right = data.slice(p);
\r
4085 mergeSort(left, compare);
\r
4086 mergeSort(right, compare);
\r
4090 while (leftIdx < left.length && rightIdx < right.length) {
\r
4091 var ret = compare(left[leftIdx], right[rightIdx]);
\r
4093 // smaller_equal -> take left to preserve order
\r
4094 data[i++] = left[leftIdx++];
\r
4097 // greater -> take right
\r
4098 data[i++] = right[rightIdx++];
\r
4101 while (leftIdx < left.length) {
\r
4102 data[i++] = left[leftIdx++];
\r
4104 while (rightIdx < right.length) {
\r
4105 data[i++] = right[rightIdx++];
\r
4109 })(TextDocument || (TextDocument = {}));
\r
4110 var FullTextDocument = /** @class */ (function () {
\r
4111 function FullTextDocument(uri, languageId, version, content) {
\r
4113 this._languageId = languageId;
\r
4114 this._version = version;
\r
4115 this._content = content;
\r
4116 this._lineOffsets = undefined;
\r
4118 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
4119 get: function () {
\r
4123 configurable: true
\r
4125 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
4126 get: function () {
\r
4127 return this._languageId;
\r
4130 configurable: true
\r
4132 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
4133 get: function () {
\r
4134 return this._version;
\r
4137 configurable: true
\r
4139 FullTextDocument.prototype.getText = function (range) {
\r
4141 var start = this.offsetAt(range.start);
\r
4142 var end = this.offsetAt(range.end);
\r
4143 return this._content.substring(start, end);
\r
4145 return this._content;
\r
4147 FullTextDocument.prototype.update = function (event, version) {
\r
4148 this._content = event.text;
\r
4149 this._version = version;
\r
4150 this._lineOffsets = undefined;
\r
4152 FullTextDocument.prototype.getLineOffsets = function () {
\r
4153 if (this._lineOffsets === undefined) {
\r
4154 var lineOffsets = [];
\r
4155 var text = this._content;
\r
4156 var isLineStart = true;
\r
4157 for (var i = 0; i < text.length; i++) {
\r
4158 if (isLineStart) {
\r
4159 lineOffsets.push(i);
\r
4160 isLineStart = false;
\r
4162 var ch = text.charAt(i);
\r
4163 isLineStart = (ch === '\r' || ch === '\n');
\r
4164 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
\r
4168 if (isLineStart && text.length > 0) {
\r
4169 lineOffsets.push(text.length);
\r
4171 this._lineOffsets = lineOffsets;
\r
4173 return this._lineOffsets;
\r
4175 FullTextDocument.prototype.positionAt = function (offset) {
\r
4176 offset = Math.max(Math.min(offset, this._content.length), 0);
\r
4177 var lineOffsets = this.getLineOffsets();
\r
4178 var low = 0, high = lineOffsets.length;
\r
4180 return Position.create(0, offset);
\r
4182 while (low < high) {
\r
4183 var mid = Math.floor((low + high) / 2);
\r
4184 if (lineOffsets[mid] > offset) {
\r
4191 // low is the least x for which the line offset is larger than the current offset
\r
4192 // or array.length if no line offset is larger than the current offset
\r
4193 var line = low - 1;
\r
4194 return Position.create(line, offset - lineOffsets[line]);
\r
4196 FullTextDocument.prototype.offsetAt = function (position) {
\r
4197 var lineOffsets = this.getLineOffsets();
\r
4198 if (position.line >= lineOffsets.length) {
\r
4199 return this._content.length;
\r
4201 else if (position.line < 0) {
\r
4204 var lineOffset = lineOffsets[position.line];
\r
4205 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
\r
4206 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
\r
4208 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
4209 get: function () {
\r
4210 return this.getLineOffsets().length;
\r
4213 configurable: true
\r
4215 return FullTextDocument;
\r
4219 var toString = Object.prototype.toString;
\r
4220 function defined(value) {
\r
4221 return typeof value !== 'undefined';
\r
4223 Is.defined = defined;
\r
4224 function undefined(value) {
\r
4225 return typeof value === 'undefined';
\r
4227 Is.undefined = undefined;
\r
4228 function boolean(value) {
\r
4229 return value === true || value === false;
\r
4231 Is.boolean = boolean;
\r
4232 function string(value) {
\r
4233 return toString.call(value) === '[object String]';
\r
4235 Is.string = string;
\r
4236 function number(value) {
\r
4237 return toString.call(value) === '[object Number]';
\r
4239 Is.number = number;
\r
4240 function func(value) {
\r
4241 return toString.call(value) === '[object Function]';
\r
4244 function objectLiteral(value) {
\r
4245 // Strictly speaking class instances pass this check as well. Since the LSP
\r
4246 // doesn't use classes we ignore this for now. If we do we need to add something
\r
4247 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
4248 return value !== null && typeof value === 'object';
\r
4250 Is.objectLiteral = objectLiteral;
\r
4251 function typedArray(value, check) {
\r
4252 return Array.isArray(value) && value.every(check);
\r
4254 Is.typedArray = typedArray;
\r
4255 })(Is || (Is = {}));
\r
4260 /***/ (function(module, exports, __webpack_require__) {
4263 /* --------------------------------------------------------------------------------------------
\r
4264 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4265 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4266 * ------------------------------------------------------------------------------------------ */
\r
4268 Object.defineProperty(exports, "__esModule", { value: true });
\r
4269 const Is = __webpack_require__(19);
\r
4270 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
4271 const messages_1 = __webpack_require__(20);
\r
4272 const protocol_implementation_1 = __webpack_require__(21);
\r
4273 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
\r
4274 const protocol_typeDefinition_1 = __webpack_require__(22);
\r
4275 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
\r
4276 const protocol_workspaceFolders_1 = __webpack_require__(23);
\r
4277 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
\r
4278 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
\r
4279 const protocol_configuration_1 = __webpack_require__(24);
\r
4280 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
\r
4281 const protocol_colorProvider_1 = __webpack_require__(25);
\r
4282 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
\r
4283 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
\r
4284 const protocol_foldingRange_1 = __webpack_require__(26);
\r
4285 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
\r
4286 const protocol_declaration_1 = __webpack_require__(27);
\r
4287 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
\r
4288 const protocol_selectionRange_1 = __webpack_require__(28);
\r
4289 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
\r
4290 const protocol_progress_1 = __webpack_require__(29);
\r
4291 exports.WorkDoneProgress = protocol_progress_1.WorkDoneProgress;
\r
4292 exports.WorkDoneProgressCreateRequest = protocol_progress_1.WorkDoneProgressCreateRequest;
\r
4293 exports.WorkDoneProgressCancelNotification = protocol_progress_1.WorkDoneProgressCancelNotification;
\r
4294 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
4295 let __noDynamicImport;
\r
4297 * The DocumentFilter namespace provides helper functions to work with
\r
4298 * [DocumentFilter](#DocumentFilter) literals.
\r
4300 var DocumentFilter;
\r
4301 (function (DocumentFilter) {
\r
4302 function is(value) {
\r
4303 const candidate = value;
\r
4304 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
\r
4306 DocumentFilter.is = is;
\r
4307 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
\r
4309 * The DocumentSelector namespace provides helper functions to work with
\r
4310 * [DocumentSelector](#DocumentSelector)s.
\r
4312 var DocumentSelector;
\r
4313 (function (DocumentSelector) {
\r
4314 function is(value) {
\r
4315 if (!Array.isArray(value)) {
\r
4318 for (let elem of value) {
\r
4319 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
\r
4325 DocumentSelector.is = is;
\r
4326 })(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
\r
4328 * The `client/registerCapability` request is sent from the server to the client to register a new capability
\r
4329 * handler on the client side.
\r
4331 var RegistrationRequest;
\r
4332 (function (RegistrationRequest) {
\r
4333 RegistrationRequest.type = new messages_1.ProtocolRequestType('client/registerCapability');
\r
4334 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
\r
4336 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
\r
4337 * handler on the client side.
\r
4339 var UnregistrationRequest;
\r
4340 (function (UnregistrationRequest) {
\r
4341 UnregistrationRequest.type = new messages_1.ProtocolRequestType('client/unregisterCapability');
\r
4342 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
\r
4343 var ResourceOperationKind;
\r
4344 (function (ResourceOperationKind) {
\r
4346 * Supports creating new files and folders.
\r
4348 ResourceOperationKind.Create = 'create';
\r
4350 * Supports renaming existing files and folders.
\r
4352 ResourceOperationKind.Rename = 'rename';
\r
4354 * Supports deleting existing files and folders.
\r
4356 ResourceOperationKind.Delete = 'delete';
\r
4357 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
\r
4358 var FailureHandlingKind;
\r
4359 (function (FailureHandlingKind) {
\r
4361 * Applying the workspace change is simply aborted if one of the changes provided
\r
4362 * fails. All operations executed before the failing operation stay executed.
\r
4364 FailureHandlingKind.Abort = 'abort';
\r
4366 * All operations are executed transactional. That means they either all
\r
4367 * succeed or no changes at all are applied to the workspace.
\r
4369 FailureHandlingKind.Transactional = 'transactional';
\r
4371 * If the workspace edit contains only textual file changes they are executed transactional.
\r
4372 * If resource changes (create, rename or delete file) are part of the change the failure
\r
4373 * handling startegy is abort.
\r
4375 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
\r
4377 * The client tries to undo the operations already executed. But there is no
\r
4378 * guarantee that this is succeeding.
\r
4380 FailureHandlingKind.Undo = 'undo';
\r
4381 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
\r
4383 * The StaticRegistrationOptions namespace provides helper functions to work with
\r
4384 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
\r
4386 var StaticRegistrationOptions;
\r
4387 (function (StaticRegistrationOptions) {
\r
4388 function hasId(value) {
\r
4389 const candidate = value;
\r
4390 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
\r
4392 StaticRegistrationOptions.hasId = hasId;
\r
4393 })(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
\r
4395 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
\r
4396 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
\r
4398 var TextDocumentRegistrationOptions;
\r
4399 (function (TextDocumentRegistrationOptions) {
\r
4400 function is(value) {
\r
4401 const candidate = value;
\r
4402 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
\r
4404 TextDocumentRegistrationOptions.is = is;
\r
4405 })(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
\r
4407 * The WorkDoneProgressOptions namespace provides helper functions to work with
\r
4408 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
\r
4410 var WorkDoneProgressOptions;
\r
4411 (function (WorkDoneProgressOptions) {
\r
4412 function is(value) {
\r
4413 const candidate = value;
\r
4414 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
\r
4416 WorkDoneProgressOptions.is = is;
\r
4417 function hasWorkDoneProgress(value) {
\r
4418 const candidate = value;
\r
4419 return candidate && Is.boolean(candidate.workDoneProgress);
\r
4421 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
\r
4422 })(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
\r
4424 * The initialize request is sent from the client to the server.
\r
4425 * It is sent once as the request after starting up the server.
\r
4426 * The requests parameter is of type [InitializeParams](#InitializeParams)
\r
4427 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
\r
4428 * resolves to such.
\r
4430 var InitializeRequest;
\r
4431 (function (InitializeRequest) {
\r
4432 InitializeRequest.type = new messages_1.ProtocolRequestType('initialize');
\r
4433 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
\r
4435 * Known error codes for an `InitializeError`;
\r
4437 var InitializeError;
\r
4438 (function (InitializeError) {
\r
4440 * If the protocol version provided by the client can't be handled by the server.
\r
4441 * @deprecated This initialize error got replaced by client capabilities. There is
\r
4442 * no version handshake in version 3.0x
\r
4444 InitializeError.unknownProtocolVersion = 1;
\r
4445 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
\r
4447 * The intialized notification is sent from the client to the
\r
4448 * server after the client is fully initialized and the server
\r
4449 * is allowed to send requests from the server to the client.
\r
4451 var InitializedNotification;
\r
4452 (function (InitializedNotification) {
\r
4453 InitializedNotification.type = new messages_1.ProtocolNotificationType('initialized');
\r
4454 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
\r
4455 //---- Shutdown Method ----
\r
4457 * A shutdown request is sent from the client to the server.
\r
4458 * It is sent once when the client decides to shutdown the
\r
4459 * server. The only notification that is sent after a shutdown request
\r
4460 * is the exit event.
\r
4462 var ShutdownRequest;
\r
4463 (function (ShutdownRequest) {
\r
4464 ShutdownRequest.type = new messages_1.ProtocolRequestType0('shutdown');
\r
4465 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
\r
4466 //---- Exit Notification ----
\r
4468 * The exit event is sent from the client to the server to
\r
4469 * ask the server to exit its process.
\r
4471 var ExitNotification;
\r
4472 (function (ExitNotification) {
\r
4473 ExitNotification.type = new messages_1.ProtocolNotificationType0('exit');
\r
4474 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
\r
4476 * The configuration change notification is sent from the client to the server
\r
4477 * when the client's configuration has changed. The notification contains
\r
4478 * the changed configuration as defined by the language client.
\r
4480 var DidChangeConfigurationNotification;
\r
4481 (function (DidChangeConfigurationNotification) {
\r
4482 DidChangeConfigurationNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeConfiguration');
\r
4483 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
\r
4484 //---- Message show and log notifications ----
\r
4486 * The message type
\r
4489 (function (MessageType) {
\r
4491 * An error message.
\r
4493 MessageType.Error = 1;
\r
4495 * A warning message.
\r
4497 MessageType.Warning = 2;
\r
4499 * An information message.
\r
4501 MessageType.Info = 3;
\r
4505 MessageType.Log = 4;
\r
4506 })(MessageType = exports.MessageType || (exports.MessageType = {}));
\r
4508 * The show message notification is sent from a server to a client to ask
\r
4509 * the client to display a particular message in the user interface.
\r
4511 var ShowMessageNotification;
\r
4512 (function (ShowMessageNotification) {
\r
4513 ShowMessageNotification.type = new messages_1.ProtocolNotificationType('window/showMessage');
\r
4514 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
\r
4516 * The show message request is sent from the server to the client to show a message
\r
4517 * and a set of options actions to the user.
\r
4519 var ShowMessageRequest;
\r
4520 (function (ShowMessageRequest) {
\r
4521 ShowMessageRequest.type = new messages_1.ProtocolRequestType('window/showMessageRequest');
\r
4522 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
\r
4524 * The log message notification is sent from the server to the client to ask
\r
4525 * the client to log a particular message.
\r
4527 var LogMessageNotification;
\r
4528 (function (LogMessageNotification) {
\r
4529 LogMessageNotification.type = new messages_1.ProtocolNotificationType('window/logMessage');
\r
4530 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
\r
4531 //---- Telemetry notification
\r
4533 * The telemetry event notification is sent from the server to the client to ask
\r
4534 * the client to log telemetry data.
\r
4536 var TelemetryEventNotification;
\r
4537 (function (TelemetryEventNotification) {
\r
4538 TelemetryEventNotification.type = new messages_1.ProtocolNotificationType('telemetry/event');
\r
4539 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
\r
4541 * Defines how the host (editor) should sync
\r
4542 * document changes to the language server.
\r
4544 var TextDocumentSyncKind;
\r
4545 (function (TextDocumentSyncKind) {
\r
4547 * Documents should not be synced at all.
\r
4549 TextDocumentSyncKind.None = 0;
\r
4551 * Documents are synced by always sending the full content
\r
4552 * of the document.
\r
4554 TextDocumentSyncKind.Full = 1;
\r
4556 * Documents are synced by sending the full content on open.
\r
4557 * After that only incremental updates to the document are
\r
4560 TextDocumentSyncKind.Incremental = 2;
\r
4561 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
\r
4563 * The document open notification is sent from the client to the server to signal
\r
4564 * newly opened text documents. The document's truth is now managed by the client
\r
4565 * and the server must not try to read the document's truth using the document's
\r
4566 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
\r
4567 * mean that its content is presented in an editor. An open notification must not
\r
4568 * be sent more than once without a corresponding close notification send before.
\r
4569 * This means open and close notification must be balanced and the max open count
\r
4572 var DidOpenTextDocumentNotification;
\r
4573 (function (DidOpenTextDocumentNotification) {
\r
4574 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
\r
4575 DidOpenTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification.method);
\r
4576 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
\r
4578 * The document change notification is sent from the client to the server to signal
\r
4579 * changes to a text document.
\r
4581 var DidChangeTextDocumentNotification;
\r
4582 (function (DidChangeTextDocumentNotification) {
\r
4583 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
\r
4584 DidChangeTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification.method);
\r
4585 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
\r
4587 * The document close notification is sent from the client to the server when
\r
4588 * the document got closed in the client. The document's truth now exists where
\r
4589 * the document's uri points to (e.g. if the document's uri is a file uri the
\r
4590 * truth now exists on disk). As with the open notification the close notification
\r
4591 * is about managing the document's content. Receiving a close notification
\r
4592 * doesn't mean that the document was open in an editor before. A close
\r
4593 * notification requires a previous open notification to be sent.
\r
4595 var DidCloseTextDocumentNotification;
\r
4596 (function (DidCloseTextDocumentNotification) {
\r
4597 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
\r
4598 DidCloseTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification.method);
\r
4599 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
\r
4601 * The document save notification is sent from the client to the server when
\r
4602 * the document got saved in the client.
\r
4604 var DidSaveTextDocumentNotification;
\r
4605 (function (DidSaveTextDocumentNotification) {
\r
4606 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
\r
4607 DidSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification.method);
\r
4608 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
\r
4610 * Represents reasons why a text document is saved.
\r
4612 var TextDocumentSaveReason;
\r
4613 (function (TextDocumentSaveReason) {
\r
4615 * Manually triggered, e.g. by the user pressing save, by starting debugging,
\r
4616 * or by an API call.
\r
4618 TextDocumentSaveReason.Manual = 1;
\r
4620 * Automatic after a delay.
\r
4622 TextDocumentSaveReason.AfterDelay = 2;
\r
4624 * When the editor lost focus.
\r
4626 TextDocumentSaveReason.FocusOut = 3;
\r
4627 })(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
\r
4629 * A document will save notification is sent from the client to the server before
\r
4630 * the document is actually saved.
\r
4632 var WillSaveTextDocumentNotification;
\r
4633 (function (WillSaveTextDocumentNotification) {
\r
4634 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
\r
4635 WillSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification.method);
\r
4636 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
\r
4638 * A document will save request is sent from the client to the server before
\r
4639 * the document is actually saved. The request can return an array of TextEdits
\r
4640 * which will be applied to the text document before it is saved. Please note that
\r
4641 * clients might drop results if computing the text edits took too long or if a
\r
4642 * server constantly fails on this request. This is done to keep the save fast and
\r
4645 var WillSaveTextDocumentWaitUntilRequest;
\r
4646 (function (WillSaveTextDocumentWaitUntilRequest) {
\r
4647 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
\r
4648 WillSaveTextDocumentWaitUntilRequest.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest.method);
\r
4649 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
\r
4651 * The watched files notification is sent from the client to the server when
\r
4652 * the client detects changes to file watched by the language client.
\r
4654 var DidChangeWatchedFilesNotification;
\r
4655 (function (DidChangeWatchedFilesNotification) {
\r
4656 DidChangeWatchedFilesNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWatchedFiles');
\r
4657 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
\r
4659 * The file event type
\r
4661 var FileChangeType;
\r
4662 (function (FileChangeType) {
\r
4664 * The file got created.
\r
4666 FileChangeType.Created = 1;
\r
4668 * The file got changed.
\r
4670 FileChangeType.Changed = 2;
\r
4672 * The file got deleted.
\r
4674 FileChangeType.Deleted = 3;
\r
4675 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
\r
4677 (function (WatchKind) {
\r
4679 * Interested in create events.
\r
4681 WatchKind.Create = 1;
\r
4683 * Interested in change events
\r
4685 WatchKind.Change = 2;
\r
4687 * Interested in delete events
\r
4689 WatchKind.Delete = 4;
\r
4690 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
\r
4692 * Diagnostics notification are sent from the server to the client to signal
\r
4693 * results of validation runs.
\r
4695 var PublishDiagnosticsNotification;
\r
4696 (function (PublishDiagnosticsNotification) {
\r
4697 PublishDiagnosticsNotification.type = new messages_1.ProtocolNotificationType('textDocument/publishDiagnostics');
\r
4698 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
\r
4700 * How a completion was triggered
\r
4702 var CompletionTriggerKind;
\r
4703 (function (CompletionTriggerKind) {
\r
4705 * Completion was triggered by typing an identifier (24x7 code
\r
4706 * complete), manual invocation (e.g Ctrl+Space) or via API.
\r
4708 CompletionTriggerKind.Invoked = 1;
\r
4710 * Completion was triggered by a trigger character specified by
\r
4711 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
\r
4713 CompletionTriggerKind.TriggerCharacter = 2;
\r
4715 * Completion was re-triggered as current completion list is incomplete
\r
4717 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
\r
4718 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
\r
4720 * Request to request completion at a given text document position. The request's
\r
4721 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
\r
4722 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
\r
4723 * or a Thenable that resolves to such.
\r
4725 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
\r
4726 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
\r
4727 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
\r
4728 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
\r
4730 var CompletionRequest;
\r
4731 (function (CompletionRequest) {
\r
4732 CompletionRequest.method = 'textDocument/completion';
\r
4733 CompletionRequest.type = new messages_1.ProtocolRequestType(CompletionRequest.method);
\r
4734 /** @deprecated Use CompletionRequest.type */
\r
4735 CompletionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4736 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
\r
4738 * Request to resolve additional information for a given completion item.The request's
\r
4739 * parameter is of type [CompletionItem](#CompletionItem) the response
\r
4740 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
\r
4742 var CompletionResolveRequest;
\r
4743 (function (CompletionResolveRequest) {
\r
4744 CompletionResolveRequest.method = 'completionItem/resolve';
\r
4745 CompletionResolveRequest.type = new messages_1.ProtocolRequestType(CompletionResolveRequest.method);
\r
4746 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
\r
4748 * Request to request hover information at a given text document position. The request's
\r
4749 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
\r
4750 * type [Hover](#Hover) or a Thenable that resolves to such.
\r
4753 (function (HoverRequest) {
\r
4754 HoverRequest.method = 'textDocument/hover';
\r
4755 HoverRequest.type = new messages_1.ProtocolRequestType(HoverRequest.method);
\r
4756 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
\r
4758 * How a signature help was triggered.
\r
4762 var SignatureHelpTriggerKind;
\r
4763 (function (SignatureHelpTriggerKind) {
\r
4765 * Signature help was invoked manually by the user or by a command.
\r
4767 SignatureHelpTriggerKind.Invoked = 1;
\r
4769 * Signature help was triggered by a trigger character.
\r
4771 SignatureHelpTriggerKind.TriggerCharacter = 2;
\r
4773 * Signature help was triggered by the cursor moving or by the document content changing.
\r
4775 SignatureHelpTriggerKind.ContentChange = 3;
\r
4776 })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
\r
4777 var SignatureHelpRequest;
\r
4778 (function (SignatureHelpRequest) {
\r
4779 SignatureHelpRequest.method = 'textDocument/signatureHelp';
\r
4780 SignatureHelpRequest.type = new messages_1.ProtocolRequestType(SignatureHelpRequest.method);
\r
4781 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
\r
4783 * A request to resolve the definition location of a symbol at a given text
\r
4784 * document position. The request's parameter is of type [TextDocumentPosition]
\r
4785 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
\r
4786 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
\r
4789 var DefinitionRequest;
\r
4790 (function (DefinitionRequest) {
\r
4791 DefinitionRequest.method = 'textDocument/definition';
\r
4792 DefinitionRequest.type = new messages_1.ProtocolRequestType(DefinitionRequest.method);
\r
4793 /** @deprecated Use DefinitionRequest.type */
\r
4794 DefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4795 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
\r
4797 * A request to resolve project-wide references for the symbol denoted
\r
4798 * by the given text document position. The request's parameter is of
\r
4799 * type [ReferenceParams](#ReferenceParams) the response is of type
\r
4800 * [Location[]](#Location) or a Thenable that resolves to such.
\r
4802 var ReferencesRequest;
\r
4803 (function (ReferencesRequest) {
\r
4804 ReferencesRequest.method = 'textDocument/references';
\r
4805 ReferencesRequest.type = new messages_1.ProtocolRequestType(ReferencesRequest.method);
\r
4806 /** @deprecated Use ReferencesRequest.type */
\r
4807 ReferencesRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4808 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
\r
4810 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
\r
4811 * text document position. The request's parameter is of type [TextDocumentPosition]
\r
4812 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
\r
4813 * (#DocumentHighlight) or a Thenable that resolves to such.
\r
4815 var DocumentHighlightRequest;
\r
4816 (function (DocumentHighlightRequest) {
\r
4817 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
\r
4818 DocumentHighlightRequest.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest.method);
\r
4819 /** @deprecated Use DocumentHighlightRequest.type */
\r
4820 DocumentHighlightRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4821 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
\r
4823 * A request to list all symbols found in a given text document. The request's
\r
4824 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
\r
4825 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
\r
4826 * that resolves to such.
\r
4828 var DocumentSymbolRequest;
\r
4829 (function (DocumentSymbolRequest) {
\r
4830 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
\r
4831 DocumentSymbolRequest.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest.method);
\r
4832 /** @deprecated Use DocumentSymbolRequest.type */
\r
4833 DocumentSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4834 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
\r
4836 * A request to provide commands for the given text document and range.
\r
4838 var CodeActionRequest;
\r
4839 (function (CodeActionRequest) {
\r
4840 CodeActionRequest.method = 'textDocument/codeAction';
\r
4841 CodeActionRequest.type = new messages_1.ProtocolRequestType(CodeActionRequest.method);
\r
4842 /** @deprecated Use CodeActionRequest.type */
\r
4843 CodeActionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4844 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
\r
4846 * A request to list project-wide symbols matching the query string given
\r
4847 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
\r
4848 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
\r
4849 * resolves to such.
\r
4851 var WorkspaceSymbolRequest;
\r
4852 (function (WorkspaceSymbolRequest) {
\r
4853 WorkspaceSymbolRequest.method = 'workspace/symbol';
\r
4854 WorkspaceSymbolRequest.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest.method);
\r
4855 /** @deprecated Use WorkspaceSymbolRequest.type */
\r
4856 WorkspaceSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4857 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
\r
4859 * A request to provide code lens for the given text document.
\r
4861 var CodeLensRequest;
\r
4862 (function (CodeLensRequest) {
\r
4863 CodeLensRequest.type = new messages_1.ProtocolRequestType('textDocument/codeLens');
\r
4864 /** @deprecated Use CodeLensRequest.type */
\r
4865 CodeLensRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4866 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
\r
4868 * A request to resolve a command for a given code lens.
\r
4870 var CodeLensResolveRequest;
\r
4871 (function (CodeLensResolveRequest) {
\r
4872 CodeLensResolveRequest.type = new messages_1.ProtocolRequestType('codeLens/resolve');
\r
4873 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
\r
4875 * A request to provide document links
\r
4877 var DocumentLinkRequest;
\r
4878 (function (DocumentLinkRequest) {
\r
4879 DocumentLinkRequest.method = 'textDocument/documentLink';
\r
4880 DocumentLinkRequest.type = new messages_1.ProtocolRequestType(DocumentLinkRequest.method);
\r
4881 /** @deprecated Use DocumentLinkRequest.type */
\r
4882 DocumentLinkRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4883 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
\r
4885 * Request to resolve additional information for a given document link. The request's
\r
4886 * parameter is of type [DocumentLink](#DocumentLink) the response
\r
4887 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
\r
4889 var DocumentLinkResolveRequest;
\r
4890 (function (DocumentLinkResolveRequest) {
\r
4891 DocumentLinkResolveRequest.type = new messages_1.ProtocolRequestType('documentLink/resolve');
\r
4892 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
\r
4894 * A request to to format a whole document.
\r
4896 var DocumentFormattingRequest;
\r
4897 (function (DocumentFormattingRequest) {
\r
4898 DocumentFormattingRequest.method = 'textDocument/formatting';
\r
4899 DocumentFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest.method);
\r
4900 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
\r
4902 * A request to to format a range in a document.
\r
4904 var DocumentRangeFormattingRequest;
\r
4905 (function (DocumentRangeFormattingRequest) {
\r
4906 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
\r
4907 DocumentRangeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest.method);
\r
4908 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
\r
4910 * A request to format a document on type.
\r
4912 var DocumentOnTypeFormattingRequest;
\r
4913 (function (DocumentOnTypeFormattingRequest) {
\r
4914 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
\r
4915 DocumentOnTypeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest.method);
\r
4916 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
\r
4918 * A request to rename a symbol.
\r
4920 var RenameRequest;
\r
4921 (function (RenameRequest) {
\r
4922 RenameRequest.method = 'textDocument/rename';
\r
4923 RenameRequest.type = new messages_1.ProtocolRequestType(RenameRequest.method);
\r
4924 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
\r
4926 * A request to test and perform the setup necessary for a rename.
\r
4928 var PrepareRenameRequest;
\r
4929 (function (PrepareRenameRequest) {
\r
4930 PrepareRenameRequest.method = 'textDocument/prepareRename';
\r
4931 PrepareRenameRequest.type = new messages_1.ProtocolRequestType(PrepareRenameRequest.method);
\r
4932 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
\r
4934 * A request send from the client to the server to execute a command. The request might return
\r
4935 * a workspace edit which the client will apply to the workspace.
\r
4937 var ExecuteCommandRequest;
\r
4938 (function (ExecuteCommandRequest) {
\r
4939 ExecuteCommandRequest.type = new messages_1.ProtocolRequestType('workspace/executeCommand');
\r
4940 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
\r
4942 * A request sent from the server to the client to modified certain resources.
\r
4944 var ApplyWorkspaceEditRequest;
\r
4945 (function (ApplyWorkspaceEditRequest) {
\r
4946 ApplyWorkspaceEditRequest.type = new messages_1.ProtocolRequestType('workspace/applyEdit');
\r
4947 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
\r
4952 /***/ (function(module, exports, __webpack_require__) {
4955 /* --------------------------------------------------------------------------------------------
\r
4956 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4957 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4958 * ------------------------------------------------------------------------------------------ */
\r
4960 Object.defineProperty(exports, "__esModule", { value: true });
\r
4961 function boolean(value) {
\r
4962 return value === true || value === false;
\r
4964 exports.boolean = boolean;
\r
4965 function string(value) {
\r
4966 return typeof value === 'string' || value instanceof String;
\r
4968 exports.string = string;
\r
4969 function number(value) {
\r
4970 return typeof value === 'number' || value instanceof Number;
\r
4972 exports.number = number;
\r
4973 function error(value) {
\r
4974 return value instanceof Error;
\r
4976 exports.error = error;
\r
4977 function func(value) {
\r
4978 return typeof value === 'function';
\r
4980 exports.func = func;
\r
4981 function array(value) {
\r
4982 return Array.isArray(value);
\r
4984 exports.array = array;
\r
4985 function stringArray(value) {
\r
4986 return array(value) && value.every(elem => string(elem));
\r
4988 exports.stringArray = stringArray;
\r
4989 function typedArray(value, check) {
\r
4990 return Array.isArray(value) && value.every(check);
\r
4992 exports.typedArray = typedArray;
\r
4993 function objectLiteral(value) {
\r
4994 // Strictly speaking class instances pass this check as well. Since the LSP
\r
4995 // doesn't use classes we ignore this for now. If we do we need to add something
\r
4996 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
4997 return value !== null && typeof value === 'object';
\r
4999 exports.objectLiteral = objectLiteral;
\r
5004 /***/ (function(module, exports, __webpack_require__) {
5007 /* --------------------------------------------------------------------------------------------
\r
5008 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5009 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5010 * ------------------------------------------------------------------------------------------ */
\r
5012 Object.defineProperty(exports, "__esModule", { value: true });
\r
5013 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5014 class ProtocolRequestType0 extends vscode_jsonrpc_1.RequestType0 {
\r
5015 constructor(method) {
\r
5019 exports.ProtocolRequestType0 = ProtocolRequestType0;
\r
5020 class ProtocolRequestType extends vscode_jsonrpc_1.RequestType {
\r
5021 constructor(method) {
\r
5025 exports.ProtocolRequestType = ProtocolRequestType;
\r
5026 class ProtocolNotificationType extends vscode_jsonrpc_1.NotificationType {
\r
5027 constructor(method) {
\r
5031 exports.ProtocolNotificationType = ProtocolNotificationType;
\r
5032 class ProtocolNotificationType0 extends vscode_jsonrpc_1.NotificationType0 {
\r
5033 constructor(method) {
\r
5037 exports.ProtocolNotificationType0 = ProtocolNotificationType0;
\r
5042 /***/ (function(module, exports, __webpack_require__) {
5045 /* --------------------------------------------------------------------------------------------
\r
5046 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5047 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5048 * ------------------------------------------------------------------------------------------ */
\r
5050 Object.defineProperty(exports, "__esModule", { value: true });
\r
5051 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5052 const messages_1 = __webpack_require__(20);
\r
5053 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5054 let __noDynamicImport;
\r
5056 * A request to resolve the implementation locations of a symbol at a given text
\r
5057 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5058 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
5059 * Thenable that resolves to such.
\r
5061 var ImplementationRequest;
\r
5062 (function (ImplementationRequest) {
\r
5063 ImplementationRequest.method = 'textDocument/implementation';
\r
5064 ImplementationRequest.type = new messages_1.ProtocolRequestType(ImplementationRequest.method);
\r
5065 /** @deprecated Use ImplementationRequest.type */
\r
5066 ImplementationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5067 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
\r
5072 /***/ (function(module, exports, __webpack_require__) {
5075 /* --------------------------------------------------------------------------------------------
\r
5076 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5077 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5078 * ------------------------------------------------------------------------------------------ */
\r
5080 Object.defineProperty(exports, "__esModule", { value: true });
\r
5081 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5082 const messages_1 = __webpack_require__(20);
\r
5083 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5084 let __noDynamicImport;
\r
5086 * A request to resolve the type definition locations of a symbol at a given text
\r
5087 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5088 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
5089 * Thenable that resolves to such.
\r
5091 var TypeDefinitionRequest;
\r
5092 (function (TypeDefinitionRequest) {
\r
5093 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
\r
5094 TypeDefinitionRequest.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest.method);
\r
5095 /** @deprecated Use TypeDefinitionRequest.type */
\r
5096 TypeDefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5097 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
\r
5102 /***/ (function(module, exports, __webpack_require__) {
5105 /* --------------------------------------------------------------------------------------------
\r
5106 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5107 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5108 * ------------------------------------------------------------------------------------------ */
\r
5110 Object.defineProperty(exports, "__esModule", { value: true });
\r
5111 const messages_1 = __webpack_require__(20);
\r
5113 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
\r
5115 var WorkspaceFoldersRequest;
\r
5116 (function (WorkspaceFoldersRequest) {
\r
5117 WorkspaceFoldersRequest.type = new messages_1.ProtocolRequestType0('workspace/workspaceFolders');
\r
5118 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
\r
5120 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
\r
5121 * folder configuration changes.
\r
5123 var DidChangeWorkspaceFoldersNotification;
\r
5124 (function (DidChangeWorkspaceFoldersNotification) {
\r
5125 DidChangeWorkspaceFoldersNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWorkspaceFolders');
\r
5126 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
\r
5131 /***/ (function(module, exports, __webpack_require__) {
5134 /* --------------------------------------------------------------------------------------------
\r
5135 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5136 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5137 * ------------------------------------------------------------------------------------------ */
\r
5139 Object.defineProperty(exports, "__esModule", { value: true });
\r
5140 const messages_1 = __webpack_require__(20);
\r
5142 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
\r
5143 * configuration setting.
\r
5145 * This pull model replaces the old push model were the client signaled configuration change via an
\r
5146 * event. If the server still needs to react to configuration changes (since the server caches the
\r
5147 * result of `workspace/configuration` requests) the server should register for an empty configuration
\r
5148 * change event and empty the cache if such an event is received.
\r
5150 var ConfigurationRequest;
\r
5151 (function (ConfigurationRequest) {
\r
5152 ConfigurationRequest.type = new messages_1.ProtocolRequestType('workspace/configuration');
\r
5153 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
\r
5158 /***/ (function(module, exports, __webpack_require__) {
5161 /* --------------------------------------------------------------------------------------------
\r
5162 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5163 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5164 * ------------------------------------------------------------------------------------------ */
\r
5166 Object.defineProperty(exports, "__esModule", { value: true });
\r
5167 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5168 const messages_1 = __webpack_require__(20);
\r
5170 * A request to list all color symbols found in a given text document. The request's
\r
5171 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
\r
5172 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
5173 * that resolves to such.
\r
5175 var DocumentColorRequest;
\r
5176 (function (DocumentColorRequest) {
\r
5177 DocumentColorRequest.method = 'textDocument/documentColor';
\r
5178 DocumentColorRequest.type = new messages_1.ProtocolRequestType(DocumentColorRequest.method);
\r
5179 /** @deprecated Use DocumentColorRequest.type */
\r
5180 DocumentColorRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5181 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
\r
5183 * A request to list all presentation for a color. The request's
\r
5184 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
\r
5185 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
5186 * that resolves to such.
\r
5188 var ColorPresentationRequest;
\r
5189 (function (ColorPresentationRequest) {
\r
5190 ColorPresentationRequest.type = new messages_1.ProtocolRequestType('textDocument/colorPresentation');
\r
5191 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
\r
5196 /***/ (function(module, exports, __webpack_require__) {
5200 /*---------------------------------------------------------------------------------------------
\r
5201 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5202 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5203 *--------------------------------------------------------------------------------------------*/
\r
5204 Object.defineProperty(exports, "__esModule", { value: true });
\r
5205 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5206 const messages_1 = __webpack_require__(20);
\r
5208 * Enum of known range kinds
\r
5210 var FoldingRangeKind;
\r
5211 (function (FoldingRangeKind) {
\r
5213 * Folding range for a comment
\r
5215 FoldingRangeKind["Comment"] = "comment";
\r
5217 * Folding range for a imports or includes
\r
5219 FoldingRangeKind["Imports"] = "imports";
\r
5221 * Folding range for a region (e.g. `#region`)
\r
5223 FoldingRangeKind["Region"] = "region";
\r
5224 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
\r
5226 * A request to provide folding ranges in a document. The request's
\r
5227 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
\r
5228 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
\r
5229 * that resolves to such.
\r
5231 var FoldingRangeRequest;
\r
5232 (function (FoldingRangeRequest) {
\r
5233 FoldingRangeRequest.method = 'textDocument/foldingRange';
\r
5234 FoldingRangeRequest.type = new messages_1.ProtocolRequestType(FoldingRangeRequest.method);
\r
5235 /** @deprecated Use FoldingRangeRequest.type */
\r
5236 FoldingRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5237 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
\r
5242 /***/ (function(module, exports, __webpack_require__) {
5245 /* --------------------------------------------------------------------------------------------
\r
5246 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5247 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5248 * ------------------------------------------------------------------------------------------ */
\r
5250 Object.defineProperty(exports, "__esModule", { value: true });
\r
5251 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5252 const messages_1 = __webpack_require__(20);
\r
5253 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5254 let __noDynamicImport;
\r
5256 * A request to resolve the type definition locations of a symbol at a given text
\r
5257 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5258 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
\r
5259 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
\r
5262 var DeclarationRequest;
\r
5263 (function (DeclarationRequest) {
\r
5264 DeclarationRequest.method = 'textDocument/declaration';
\r
5265 DeclarationRequest.type = new messages_1.ProtocolRequestType(DeclarationRequest.method);
\r
5266 /** @deprecated Use DeclarationRequest.type */
\r
5267 DeclarationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5268 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
\r
5273 /***/ (function(module, exports, __webpack_require__) {
5277 /*---------------------------------------------------------------------------------------------
\r
5278 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5279 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5280 *--------------------------------------------------------------------------------------------*/
\r
5281 Object.defineProperty(exports, "__esModule", { value: true });
\r
5282 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5283 const messages_1 = __webpack_require__(20);
\r
5285 * A request to provide selection ranges in a document. The request's
\r
5286 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
\r
5287 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
\r
5288 * that resolves to such.
\r
5290 var SelectionRangeRequest;
\r
5291 (function (SelectionRangeRequest) {
\r
5292 SelectionRangeRequest.method = 'textDocument/selectionRange';
\r
5293 SelectionRangeRequest.type = new messages_1.ProtocolRequestType(SelectionRangeRequest.method);
\r
5294 /** @deprecated Use SelectionRangeRequest.type */
\r
5295 SelectionRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5296 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
\r
5301 /***/ (function(module, exports, __webpack_require__) {
5304 /* --------------------------------------------------------------------------------------------
\r
5305 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5306 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5307 * ------------------------------------------------------------------------------------------ */
\r
5309 Object.defineProperty(exports, "__esModule", { value: true });
\r
5310 const vscode_jsonrpc_1 = __webpack_require__(3);
\r
5311 const messages_1 = __webpack_require__(20);
\r
5312 var WorkDoneProgress;
\r
5313 (function (WorkDoneProgress) {
\r
5314 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
\r
5315 })(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
\r
5317 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
\r
5318 * reporting from the server.
\r
5320 var WorkDoneProgressCreateRequest;
\r
5321 (function (WorkDoneProgressCreateRequest) {
\r
5322 WorkDoneProgressCreateRequest.type = new messages_1.ProtocolRequestType('window/workDoneProgress/create');
\r
5323 })(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
\r
5325 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
\r
5326 * initiated on the server side.
\r
5328 var WorkDoneProgressCancelNotification;
\r
5329 (function (WorkDoneProgressCancelNotification) {
\r
5330 WorkDoneProgressCancelNotification.type = new messages_1.ProtocolNotificationType('window/workDoneProgress/cancel');
\r
5331 })(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
\r
5336 /***/ (function(module, exports, __webpack_require__) {
5339 /* --------------------------------------------------------------------------------------------
\r
5340 * Copyright (c) TypeFox and others. All rights reserved.
\r
5341 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5342 * ------------------------------------------------------------------------------------------ */
\r
5344 Object.defineProperty(exports, "__esModule", { value: true });
\r
5345 const messages_1 = __webpack_require__(20);
\r
5347 * A request to result a `CallHierarchyItem` in a document at a given position.
\r
5348 * Can be used as an input to a incoming or outgoing call hierarchy.
\r
5350 * @since 3.16.0 - Proposed state
\r
5352 var CallHierarchyPrepareRequest;
\r
5353 (function (CallHierarchyPrepareRequest) {
\r
5354 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
\r
5355 CallHierarchyPrepareRequest.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest.method);
\r
5356 })(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
\r
5358 * A request to resolve the incoming calls for a given `CallHierarchyItem`.
\r
5360 * @since 3.16.0 - Proposed state
\r
5362 var CallHierarchyIncomingCallsRequest;
\r
5363 (function (CallHierarchyIncomingCallsRequest) {
\r
5364 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
\r
5365 CallHierarchyIncomingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest.method);
\r
5366 })(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
\r
5368 * A request to resolve the outgoing calls for a given `CallHierarchyItem`.
\r
5370 * @since 3.16.0 - Proposed state
\r
5372 var CallHierarchyOutgoingCallsRequest;
\r
5373 (function (CallHierarchyOutgoingCallsRequest) {
\r
5374 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
\r
5375 CallHierarchyOutgoingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest.method);
\r
5376 })(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
\r
5381 /***/ (function(module, exports, __webpack_require__) {
5384 /* --------------------------------------------------------------------------------------------
\r
5385 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5386 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5387 * ------------------------------------------------------------------------------------------ */
\r
5389 Object.defineProperty(exports, "__esModule", { value: true });
\r
5390 const messages_1 = __webpack_require__(20);
\r
5392 * A set of predefined token types. This set is not fixed
\r
5393 * an clients can specify additional token types via the
\r
5394 * corresponding client capabilities.
\r
5396 * @since 3.16.0 - Proposed state
\r
5398 var SemanticTokenTypes;
\r
5399 (function (SemanticTokenTypes) {
\r
5400 SemanticTokenTypes["comment"] = "comment";
\r
5401 SemanticTokenTypes["keyword"] = "keyword";
\r
5402 SemanticTokenTypes["string"] = "string";
\r
5403 SemanticTokenTypes["number"] = "number";
\r
5404 SemanticTokenTypes["regexp"] = "regexp";
\r
5405 SemanticTokenTypes["operator"] = "operator";
\r
5406 SemanticTokenTypes["namespace"] = "namespace";
\r
5407 SemanticTokenTypes["type"] = "type";
\r
5408 SemanticTokenTypes["struct"] = "struct";
\r
5409 SemanticTokenTypes["class"] = "class";
\r
5410 SemanticTokenTypes["interface"] = "interface";
\r
5411 SemanticTokenTypes["enum"] = "enum";
\r
5412 SemanticTokenTypes["typeParameter"] = "typeParameter";
\r
5413 SemanticTokenTypes["function"] = "function";
\r
5414 SemanticTokenTypes["member"] = "member";
\r
5415 SemanticTokenTypes["property"] = "property";
\r
5416 SemanticTokenTypes["macro"] = "macro";
\r
5417 SemanticTokenTypes["variable"] = "variable";
\r
5418 SemanticTokenTypes["parameter"] = "parameter";
\r
5419 SemanticTokenTypes["label"] = "label";
\r
5420 })(SemanticTokenTypes = exports.SemanticTokenTypes || (exports.SemanticTokenTypes = {}));
\r
5422 * A set of predefined token modifiers. This set is not fixed
\r
5423 * an clients can specify additional token types via the
\r
5424 * corresponding client capabilities.
\r
5426 * @since 3.16.0 - Proposed state
\r
5428 var SemanticTokenModifiers;
\r
5429 (function (SemanticTokenModifiers) {
\r
5430 SemanticTokenModifiers["documentation"] = "documentation";
\r
5431 SemanticTokenModifiers["declaration"] = "declaration";
\r
5432 SemanticTokenModifiers["definition"] = "definition";
\r
5433 SemanticTokenModifiers["reference"] = "reference";
\r
5434 SemanticTokenModifiers["static"] = "static";
\r
5435 SemanticTokenModifiers["abstract"] = "abstract";
\r
5436 SemanticTokenModifiers["deprecated"] = "deprecated";
\r
5437 SemanticTokenModifiers["async"] = "async";
\r
5438 SemanticTokenModifiers["volatile"] = "volatile";
\r
5439 SemanticTokenModifiers["readonly"] = "readonly";
\r
5440 })(SemanticTokenModifiers = exports.SemanticTokenModifiers || (exports.SemanticTokenModifiers = {}));
\r
5442 * @since 3.16.0 - Proposed state
\r
5444 var SemanticTokens;
\r
5445 (function (SemanticTokens) {
\r
5446 function is(value) {
\r
5447 const candidate = value;
\r
5448 return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
\r
5449 Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
\r
5451 SemanticTokens.is = is;
\r
5452 })(SemanticTokens = exports.SemanticTokens || (exports.SemanticTokens = {}));
\r
5454 * @since 3.16.0 - Proposed state
\r
5456 var SemanticTokensRequest;
\r
5457 (function (SemanticTokensRequest) {
\r
5458 SemanticTokensRequest.method = 'textDocument/semanticTokens';
\r
5459 SemanticTokensRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRequest.method);
\r
5460 })(SemanticTokensRequest = exports.SemanticTokensRequest || (exports.SemanticTokensRequest = {}));
\r
5462 * @since 3.16.0 - Proposed state
\r
5464 var SemanticTokensEditsRequest;
\r
5465 (function (SemanticTokensEditsRequest) {
\r
5466 SemanticTokensEditsRequest.method = 'textDocument/semanticTokens/edits';
\r
5467 SemanticTokensEditsRequest.type = new messages_1.ProtocolRequestType(SemanticTokensEditsRequest.method);
\r
5468 })(SemanticTokensEditsRequest = exports.SemanticTokensEditsRequest || (exports.SemanticTokensEditsRequest = {}));
\r
5470 * @since 3.16.0 - Proposed state
\r
5472 var SemanticTokensRangeRequest;
\r
5473 (function (SemanticTokensRangeRequest) {
\r
5474 SemanticTokensRangeRequest.method = 'textDocument/semanticTokens/range';
\r
5475 SemanticTokensRangeRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest.method);
\r
5476 })(SemanticTokensRangeRequest = exports.SemanticTokensRangeRequest || (exports.SemanticTokensRangeRequest = {}));
\r
5481 /***/ (function(module, exports, __webpack_require__) {
5485 Object.defineProperty(exports, "__esModule", { value: true });
5486 const coc_nvim_1 = __webpack_require__(1);
5487 const prettier = __webpack_require__(33);
5489 * Prettier reads configuration from files
5491 const PRETTIER_CONFIG_FILES = [
5498 'prettier.config.js',
5501 * Create a file watcher. Clears prettier's configuration cache on
5502 * file change, create, delete.
5503 * @returns disposable file system watcher.
5505 function fileListener() {
5506 const fileWatcher = coc_nvim_1.workspace.createFileSystemWatcher(`**/{${PRETTIER_CONFIG_FILES.join(',')}}`);
5507 fileWatcher.onDidChange(prettier.clearConfigCache);
5508 fileWatcher.onDidCreate(prettier.clearConfigCache);
5509 fileWatcher.onDidDelete(prettier.clearConfigCache);
5512 exports.default = fileListener;
5517 /***/ (function(module, exports) {
5519 module.exports = require("prettier");
5523 /***/ (function(module, exports, __webpack_require__) {
5527 Object.defineProperty(exports, "__esModule", { value: true });
5528 exports.setupErrorHandler = exports.safeExecution = exports.addToOutput = void 0;
5529 const coc_nvim_1 = __webpack_require__(1);
5532 * Adds the filepath to the error message
5534 * @param msg The original error message
5535 * @param fileName The path to the file
5536 * @returns {string} enhanced message with the filename
5538 function addFilePath(msg, fileName) {
5539 const lines = msg.split('\n');
5540 if (lines.length > 0) {
5541 lines[0] = lines[0].replace(/(\d*):(\d*)/g, `${fileName}:$1:$2`);
5542 return lines.join('\n');
5547 * Append messages to the output channel and format it with a title
5549 * @param message The message to append to the output channel
5551 function addToOutput(message, type = 'Trace') {
5554 const title = `${type} - ${new Date().toLocaleString()}:`;
5555 // Create a sort of title, to differentiate between messages
5556 outputChannel.appendLine('');
5557 // Append actual output
5558 outputChannel.appendLine(`[${title}] ${message}\n`);
5560 exports.addToOutput = addToOutput;
5562 * Execute a callback safely, if it doesn't work, return default and log messages.
5564 * @param cb The function to be executed,
5565 * @param defaultText The default value if execution of the cb failed
5566 * @param fileName The filename of the current document
5567 * @returns {string} formatted text or defaultText
5569 function safeExecution(cb, defaultText, fileName) {
5570 if (cb instanceof Promise) {
5572 .then(returnValue => {
5573 // updateStatusBar('Prettier: $(check)')
5577 addToOutput(addFilePath(err.message, fileName), 'Error');
5578 // updateStatusBar('Prettier: $(x)')
5583 const returnValue = cb();
5584 // updateStatusBar('Prettier: $(check)')
5588 addToOutput(addFilePath(err.message, fileName), 'Error');
5589 // updateStatusBar('Prettier: $(x)')
5593 exports.safeExecution = safeExecution;
5595 * Setup the output channel and the statusBarItem.
5596 * Create a command to show the output channel
5598 * @returns {Disposable} The command to open the output channel
5600 function setupErrorHandler() {
5601 // Setup the outputChannel
5602 outputChannel = coc_nvim_1.workspace.createOutputChannel('prettier');
5603 return coc_nvim_1.commands.registerCommand('prettier.open-output', () => {
5604 outputChannel.show();
5607 exports.setupErrorHandler = setupErrorHandler;
5612 /***/ (function(module, exports, __webpack_require__) {
5616 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5617 if (k2 === undefined) k2 = k;
5618 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5619 }) : (function(o, m, k, k2) {
5620 if (k2 === undefined) k2 = k;
5623 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5624 Object.defineProperty(o, "default", { enumerable: true, value: v });
5625 }) : function(o, v) {
5628 var __importStar = (this && this.__importStar) || function (mod) {
5629 if (mod && mod.__esModule) return mod;
5631 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5632 __setModuleDefault(result, mod);
5635 Object.defineProperty(exports, "__esModule", { value: true });
5636 const coc_nvim_1 = __webpack_require__(1);
5637 const fs_1 = __webpack_require__(36);
5638 const path = __importStar(__webpack_require__(12));
5639 const errorHandler_1 = __webpack_require__(34);
5640 const utils_1 = __webpack_require__(37);
5641 const ignore = __webpack_require__(41);
5642 const nullIgnorer = { ignores: () => false };
5644 * Create an ignore file handler. Will lazily read ignore files on a per-resource
5645 * basis, and cache the contents until it changes.
5647 function ignoreFileHandler(disposables) {
5648 const ignorers = new Map();
5649 disposables.push({ dispose: () => ignorers.clear() });
5651 fileIsIgnored(filePath) {
5652 const { ignorer, ignoreFilePath } = getIgnorerForFile(filePath);
5653 return ignorer.ignores(path.relative(path.dirname(ignoreFilePath), filePath));
5656 function getIgnorerForFile(fsPath) {
5657 const absolutePath = getIgnorePathForFile(fsPath, utils_1.getConfig(coc_nvim_1.Uri.file(fsPath)).ignorePath);
5658 if (!absolutePath) {
5659 return { ignoreFilePath: '', ignorer: nullIgnorer };
5661 if (!ignorers.has(absolutePath)) {
5662 loadIgnorer(coc_nvim_1.Uri.file(absolutePath));
5664 if (!fs_1.existsSync(absolutePath)) {
5665 // Don't log default value.
5666 const ignorePath = utils_1.getConfig(coc_nvim_1.Uri.file(fsPath)).ignorePath;
5667 if (ignorePath !== '.prettierignore') {
5668 errorHandler_1.addToOutput(`Wrong prettier.ignorePath provided in your settings. The path (${ignorePath}) does not exist.`, 'Warning');
5670 return { ignoreFilePath: '', ignorer: nullIgnorer };
5673 ignoreFilePath: absolutePath,
5674 ignorer: ignorers.get(absolutePath),
5677 function loadIgnorer(ignoreUri) {
5678 let ignorer = nullIgnorer;
5679 if (!ignorers.has(ignoreUri.fsPath)) {
5680 const fileWatcher = coc_nvim_1.workspace.createFileSystemWatcher(ignoreUri.fsPath);
5681 disposables.push(fileWatcher);
5682 fileWatcher.onDidCreate(loadIgnorer, null, disposables);
5683 fileWatcher.onDidChange(loadIgnorer, null, disposables);
5684 fileWatcher.onDidDelete(unloadIgnorer, null, disposables);
5686 if (fs_1.existsSync(ignoreUri.fsPath)) {
5687 const ignoreFileContents = fs_1.readFileSync(ignoreUri.fsPath, 'utf8');
5688 ignorer = ignore().add(ignoreFileContents);
5690 ignorers.set(ignoreUri.fsPath, ignorer);
5692 function unloadIgnorer(ignoreUri) {
5693 ignorers.set(ignoreUri.fsPath, nullIgnorer);
5696 function getIgnorePathForFile(_filePath, ignorePath) {
5697 // Configuration `prettier.ignorePath` is set to `null`
5701 if (coc_nvim_1.workspace.workspaceFolder) {
5702 const folder = coc_nvim_1.workspace.workspaceFolder;
5703 return folder ? getPath(ignorePath, coc_nvim_1.Uri.parse(folder.uri).fsPath) : null;
5707 function getPath(fsPath, relativeTo) {
5708 return path.isAbsolute(fsPath) ? fsPath : path.join(relativeTo, fsPath);
5710 exports.default = ignoreFileHandler;
5715 /***/ (function(module, exports) {
5717 module.exports = require("fs");
5721 /***/ (function(module, exports, __webpack_require__) {
5725 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5726 if (k2 === undefined) k2 = k;
5727 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5728 }) : (function(o, m, k, k2) {
5729 if (k2 === undefined) k2 = k;
5732 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5733 Object.defineProperty(o, "default", { enumerable: true, value: v });
5734 }) : function(o, v) {
5737 var __importStar = (this && this.__importStar) || function (mod) {
5738 if (mod && mod.__esModule) return mod;
5740 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5741 __setModuleDefault(result, mod);
5744 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5745 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5746 return new (P || (P = Promise))(function (resolve, reject) {
5747 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5748 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5749 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5750 step((generator = generator.apply(thisArg, _arguments || [])).next());
5753 Object.defineProperty(exports, "__esModule", { value: true });
5754 exports.hasLocalPrettierInstalled = exports.getGroup = exports.rangeLanguages = exports.enabledLanguages = exports.allLanguages = exports.getParsersFromLanguageId = exports.getPrettierInstance = exports.getConfig = void 0;
5755 const coc_nvim_1 = __webpack_require__(1);
5756 const path_1 = __importStar(__webpack_require__(12));
5757 const requirePkg_1 = __webpack_require__(38);
5758 const errorHandler_1 = __webpack_require__(34);
5759 function getConfig(uri) {
5760 return coc_nvim_1.workspace.getConfiguration('prettier', uri ? uri.toString() : undefined);
5762 exports.getConfig = getConfig;
5763 function getPrettierInstance() {
5764 return __awaiter(this, void 0, void 0, function* () {
5765 const document = yield coc_nvim_1.workspace.document;
5766 const uri = coc_nvim_1.Uri.parse(document.uri);
5767 const fileName = uri.fsPath;
5768 const vscodeConfig = getConfig(uri);
5769 const localOnly = vscodeConfig.onlyUseLocalVersion;
5770 const resolvedPrettier = (yield requirePkg_1.requireLocalPkg(path_1.default.dirname(fileName), 'prettier', { silent: true, ignoreBundled: localOnly }));
5771 if (!resolvedPrettier) {
5772 errorHandler_1.addToOutput(`Prettier module not found, prettier.onlyUseLocalVersion: ${vscodeConfig.onlyUseLocalVersion}`, 'Error');
5774 return resolvedPrettier;
5777 exports.getPrettierInstance = getPrettierInstance;
5778 function getParsersFromLanguageId(languageId, prettierInstance, path) {
5779 const supportedLanguages = getSupportLanguages(prettierInstance);
5780 const language = supportedLanguages.find(lang => Array.isArray(lang.vscodeLanguageIds) &&
5781 lang.vscodeLanguageIds.includes(languageId) &&
5782 // Only for some specific filenames
5783 (lang.extensions.length > 0 ||
5785 lang.filenames != null &&
5786 lang.filenames.includes(path_1.basename(path)))));
5790 return language.parsers;
5792 exports.getParsersFromLanguageId = getParsersFromLanguageId;
5793 function allLanguages(prettierInstance) {
5794 const supportedLanguages = getSupportLanguages(prettierInstance);
5795 return supportedLanguages.reduce((ids, language) => [...ids, ...(language.vscodeLanguageIds || [])], []);
5797 exports.allLanguages = allLanguages;
5798 function enabledLanguages(prettierInstance) {
5799 const { disableLanguages } = getConfig();
5800 const languages = allLanguages(prettierInstance);
5801 return languages.filter(x => disableLanguages.indexOf(x) == -1);
5803 exports.enabledLanguages = enabledLanguages;
5804 function rangeLanguages() {
5805 const { disableLanguages } = getConfig();
5813 ].filter(x => disableLanguages.indexOf(x) == -1);
5815 exports.rangeLanguages = rangeLanguages;
5816 function getGroup(group, prettierInstance) {
5817 const supportedLanguages = getSupportLanguages(prettierInstance);
5818 return supportedLanguages.filter(language => language.group === group);
5820 exports.getGroup = getGroup;
5821 function getSupportLanguages(prettierInstance) {
5822 return prettierInstance.getSupportInfo(prettierInstance.version).languages;
5824 function hasLocalPrettierInstalled(filePath) {
5825 const localPrettier = requirePkg_1.requireLocalPkg(filePath, 'prettier', {
5827 ignoreBundled: true,
5829 return localPrettier != null;
5831 exports.hasLocalPrettierInstalled = hasLocalPrettierInstalled;
5836 /***/ (function(module, exports, __webpack_require__) {
5840 var __importDefault = (this && this.__importDefault) || function (mod) {
5841 return (mod && mod.__esModule) ? mod : { "default": mod };
5843 Object.defineProperty(exports, "__esModule", { value: true });
5844 exports.requireLocalPkg = void 0;
5845 const errorHandler_1 = __webpack_require__(34);
5846 const resolve_from_1 = __importDefault(__webpack_require__(39));
5847 const requireFunc = true ? require : undefined;
5849 * Require package explicitly installed relative to given path.
5850 * Fallback to bundled one if no package was found bottom up.
5851 * @param {string} fspath file system path starting point to resolve package
5852 * @param {string} pkgName package's name to require
5855 function requireLocalPkg(fspath, pkgName, options = { silent: true, ignoreBundled: false }) {
5856 let modulePath = resolve_from_1.default.silent(fspath, pkgName);
5857 if (modulePath !== void 0) {
5859 return requireFunc(modulePath);
5862 if (!options.silent) {
5863 errorHandler_1.addToOutput(`Failed to load require ${pkgName} from ${modulePath}.${options.ignoreBundled ? `` : ` Using bundled`}`, 'Error');
5867 return options.ignoreBundled ? null : requireFunc(pkgName);
5869 exports.requireLocalPkg = requireLocalPkg;
5874 /***/ (function(module, exports, __webpack_require__) {
5878 const path = __webpack_require__(12);
5879 const Module = __webpack_require__(40);
5880 const fs = __webpack_require__(36);
5882 const resolveFrom = (fromDirectory, moduleId, silent) => {
5883 if (typeof fromDirectory !== 'string') {
5884 throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDirectory}\``);
5887 if (typeof moduleId !== 'string') {
5888 throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
5892 fromDirectory = fs.realpathSync(fromDirectory);
5894 if (error.code === 'ENOENT') {
5895 fromDirectory = path.resolve(fromDirectory);
5896 } else if (silent) {
5903 const fromFile = path.join(fromDirectory, 'noop.js');
5905 const resolveFileName = () => Module._resolveFilename(moduleId, {
5908 paths: Module._nodeModulePaths(fromDirectory)
5913 return resolveFileName();
5919 return resolveFileName();
5922 module.exports = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId);
5923 module.exports.silent = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId, true);
5928 /***/ (function(module, exports) {
5930 module.exports = require("module");
5934 /***/ (function(module, exports) {
5936 // A simple implementation of make-array
5937 function makeArray (subject) {
5938 return Array.isArray(subject)
5946 const REGEX_TEST_BLANK_LINE = /^\s+$/
5947 const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/
5948 const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/
5949 const REGEX_SPLITALL_CRLF = /\r?\n/g
5955 const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/
5958 const KEY_IGNORE = typeof Symbol !== 'undefined'
5959 ? Symbol.for('node-ignore')
5960 /* istanbul ignore next */
5963 const define = (object, key, value) =>
5964 Object.defineProperty(object, key, {value})
5966 const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g
5968 // Sanitize the range of a regular expression
5969 // The cases are complicated, see test cases for details
5970 const sanitizeRange = range => range.replace(
5972 (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)
5974 // Invalid range (out of order) which is ok for gitignore rules but
5975 // fatal for JavaScript regular expression, so eliminate it.
5980 const cleanRangeBackSlash = slashes => {
5981 const {length} = slashes
5982 return slashes.slice(0, length - length % 2)
5985 // > If the pattern ends with a slash,
5986 // > it is removed for the purpose of the following description,
5987 // > but it would only find a match with a directory.
5988 // > In other words, foo/ will match a directory foo and paths underneath it,
5989 // > but will not match a regular file or a symbolic link foo
5990 // > (this is consistent with the way how pathspec works in general in Git).
5991 // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
5992 // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
5993 // you could use option `mark: true` with `glob`
5995 // '`foo/`' should not continue with the '`..`'
5998 // > Trailing spaces are ignored unless they are quoted with backslash ("\")
6004 match => match.indexOf('\\') === 0
6009 // replace (\ ) with ' '
6015 // Escape metacharacters
6016 // which is written down by users but means special for regular expressions.
6018 // > There are 12 characters with special meanings:
6019 // > - the backslash \,
6021 // > - the dollar sign $,
6022 // > - the period or dot .,
6023 // > - the vertical bar or pipe symbol |,
6024 // > - the question mark ?,
6025 // > - the asterisk or star *,
6026 // > - the plus sign +,
6027 // > - the opening parenthesis (,
6028 // > - the closing parenthesis ),
6029 // > - and the opening square bracket [,
6030 // > - the opening curly brace {,
6031 // > These special characters are often called "metacharacters".
6034 match => `\\${match}`
6038 // > a question mark (?) matches a single character
6046 // > A leading slash matches the beginning of the pathname.
6047 // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
6048 // A leading slash matches the beginning of the pathname
6053 // replace special metacharacter slash after the leading slash
6060 // > A leading "**" followed by a slash means match in all directories.
6061 // > For example, "**/foo" matches file or directory "foo" anywhere,
6062 // > the same as pattern "foo".
6063 // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
6064 // > under directory "foo".
6065 // Notice that the '*'s have been replaced as '\\*'
6068 // '**/foo' <-> 'foo'
6074 // there will be no leading '/'
6075 // (which has been replaced by section "leading slash")
6076 // If starts with '**', adding a '^' to the regular expression also works
6078 function startingReplacer () {
6079 // If has a slash `/` at the beginning or middle
6080 return !/\/(?!$)/.test(this)
6081 // > Prior to 2.22.1
6082 // > If the pattern does not contain a slash /,
6083 // > Git treats it as a shell glob pattern
6084 // Actually, if there is only a trailing slash,
6085 // git also treats it as a shell glob pattern
6087 // After 2.22.1 (compatible but clearer)
6088 // > If there is a separator at the beginning or middle (or both)
6089 // > of the pattern, then the pattern is relative to the directory
6090 // > level of the particular .gitignore file itself.
6091 // > Otherwise the pattern may also match at any level below
6092 // > the .gitignore level.
6095 // > Otherwise, Git treats the pattern as a shell glob suitable for
6096 // > consumption by fnmatch(3)
6103 // Use lookahead assertions so that we could match more than one `'/**'`
6104 /\\\/\\\*\\\*(?=\\\/|$)/g,
6106 // Zero, one or several directories
6107 // should not use '*', or it will be replaced by the next replacer
6109 // Check if it is not the last `'/**'`
6110 (_, index, str) => index + 6 < str.length
6113 // > A slash followed by two consecutive asterisks then a slash matches
6114 // > zero or more directories.
6115 // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
6120 // > A trailing `"/**"` matches everything inside.
6122 // #21: everything inside but it should not include the current folder
6126 // intermediate wildcards
6128 // Never replace escaped '*'
6129 // ignore rule '\*' will match the path '*'
6132 // 'abc.*' -> skip this rule
6133 /(^|[^\\]+)\\\*(?=.+)/g,
6135 // '*.js' matches '.js'
6136 // '*.js' doesn't match 'abc'
6137 (_, p1) => `${p1}[^\\/]*`
6141 // unescape, revert step 3 except for back slash
6142 // For example, if a user escape a '\\*',
6143 // after step 3, the result will be '\\\\\\*'
6144 /\\\\\\(?=[$.|*+(){^])/g,
6155 // > The range notation, e.g. [a-zA-Z],
6156 // > can be used to match one of the characters in a range.
6158 // `\` is escaped by step 3
6159 /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
6160 (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE
6161 // '\\[bar]' -> '\\\\[bar\\]'
6162 ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`
6164 ? endEscape.length % 2 === 0
6165 // A normal case, and it is a range notation
6168 ? `[${sanitizeRange(range)}${endEscape}]`
6169 // Invalid range notaton
6170 // '[bar\\]' -> '[bar\\\\]'
6177 // 'js' will not match 'js.'
6178 // 'ab' will not match 'abc'
6182 // https://git-scm.com/docs/gitignore
6183 // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
6184 // which re-fixes #24, #38
6186 // > If there is a separator at the end of the pattern then the pattern
6187 // > will only match directories, otherwise the pattern can match both
6188 // > files and directories.
6190 // 'js*' will not match 'a.js'
6191 // 'js/' will not match 'a.js'
6192 // 'js' will match 'a.js' and 'a.js/'
6193 match => /\/$/.test(match)
6194 // foo/ will not match 'foo'
6196 // foo matches 'foo' and 'foo/'
6197 : `${match}(?=$|\\/$)`
6200 // trailing wildcard
6206 // '/*' does not match EMPTY
6207 // '/*' does not match everything
6210 // 'abc/*' does not match 'abc/'
6214 // 'a*' matches 'aa'
6217 return `${prefix}(?=$|\\/$)`
6222 // A simple cache, because an ignore rule only has only one certain meaning
6223 const regexCache = Object.create(null)
6226 const makeRegex = (pattern, negative, ignorecase) => {
6227 const r = regexCache[pattern]
6232 // const replacers = negative
6233 // ? NEGATIVE_REPLACERS
6234 // : POSITIVE_REPLACERS
6236 const source = REPLACERS.reduce(
6237 (prev, current) => prev.replace(current[0], current[1].bind(pattern)),
6241 return regexCache[pattern] = ignorecase
6242 ? new RegExp(source, 'i')
6243 : new RegExp(source)
6246 const isString = subject => typeof subject === 'string'
6248 // > A blank line matches no files, so it can serve as a separator for readability.
6249 const checkPattern = pattern => pattern
6250 && isString(pattern)
6251 && !REGEX_TEST_BLANK_LINE.test(pattern)
6253 // > A line starting with # serves as a comment.
6254 && pattern.indexOf('#') !== 0
6256 const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF)
6265 this.origin = origin
6266 this.pattern = pattern
6267 this.negative = negative
6272 const createRule = (pattern, ignorecase) => {
6273 const origin = pattern
6274 let negative = false
6276 // > An optional prefix "!" which negates the pattern;
6277 if (pattern.indexOf('!') === 0) {
6279 pattern = pattern.substr(1)
6283 // > Put a backslash ("\") in front of the first "!" for patterns that
6284 // > begin with a literal "!", for example, `"\!important!.txt"`.
6285 .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
6286 // > Put a backslash ("\") in front of the first hash for patterns that
6287 // > begin with a hash.
6288 .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')
6290 const regex = makeRegex(pattern, negative, ignorecase)
6292 return new IgnoreRule(
6300 const throwError = (message, Ctor) => {
6301 throw new Ctor(message)
6304 const checkPath = (path, originalPath, doThrow) => {
6305 if (!isString(path)) {
6307 `path must be a string, but got \`${originalPath}\``,
6312 // We don't know if we should ignore EMPTY, so throw
6314 return doThrow(`path must not be empty`, TypeError)
6317 // Check if it is a relative path
6318 if (checkPath.isNotRelative(path)) {
6319 const r = '`path.relative()`d'
6321 `path should be a ${r} string, but got "${originalPath}"`,
6329 const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)
6331 checkPath.isNotRelative = isNotRelative
6332 checkPath.convert = p => p
6339 this._ignorecase = ignorecase
6340 define(this, KEY_IGNORE, true)
6345 this._ignoreCache = Object.create(null)
6346 this._testCache = Object.create(null)
6349 _addPattern (pattern) {
6351 if (pattern && pattern[KEY_IGNORE]) {
6352 this._rules = this._rules.concat(pattern._rules)
6357 if (checkPattern(pattern)) {
6358 const rule = createRule(pattern, this._ignorecase)
6360 this._rules.push(rule)
6364 // @param {Array<string> | string | Ignore} pattern
6370 ? splitPattern(pattern)
6372 ).forEach(this._addPattern, this)
6374 // Some rules have just added to the ignore,
6375 // making the behavior changed.
6384 addPattern (pattern) {
6385 return this.add(pattern)
6388 // | ignored : unignored
6389 // negative | 0:0 | 0:1 | 1:0 | 1:1
6390 // -------- | ------- | ------- | ------- | --------
6391 // 0 | TEST | TEST | SKIP | X
6392 // 1 | TESTIF | SKIP | TEST | X
6394 // - SKIP: always skip
6395 // - TEST: always test
6396 // - TESTIF: only test if checkUnignored
6397 // - X: that never happen
6399 // @param {boolean} whether should check if the path is unignored,
6400 // setting `checkUnignored` to `false` could reduce additional
6403 // @returns {TestResult} true if a file is ignored
6404 _testOne (path, checkUnignored) {
6406 let unignored = false
6408 this._rules.forEach(rule => {
6409 const {negative} = rule
6411 unignored === negative && ignored !== unignored
6412 || negative && !ignored && !unignored && !checkUnignored
6417 const matched = rule.regex.test(path)
6421 unignored = negative
6431 // @returns {TestResult}
6432 _test (originalPath, cache, checkUnignored, slices) {
6433 const path = originalPath
6434 // Supports nullable path
6435 && checkPath.convert(originalPath)
6437 checkPath(path, originalPath, throwError)
6439 return this._t(path, cache, checkUnignored, slices)
6442 _t (path, cache, checkUnignored, slices) {
6443 if (path in cache) {
6449 // ['path', 'to', 'a.js']
6450 slices = path.split(SLASH)
6455 // If the path has no parent directory, just test it
6456 if (!slices.length) {
6457 return cache[path] = this._testOne(path, checkUnignored)
6460 const parent = this._t(
6461 slices.join(SLASH) + SLASH,
6467 // If the path contains a parent directory, check the parent first
6468 return cache[path] = parent.ignored
6469 // > It is not possible to re-include a file if a parent directory of
6470 // > that file is excluded.
6472 : this._testOne(path, checkUnignored)
6476 return this._test(path, this._ignoreCache, false).ignored
6480 return path => !this.ignores(path)
6484 return makeArray(paths).filter(this.createFilter())
6487 // @returns {TestResult}
6489 return this._test(path, this._testCache, true)
6493 const factory = options => new Ignore(options)
6495 const returnFalse = () => false
6497 const isPathValid = path =>
6498 checkPath(path && checkPath.convert(path), path, returnFalse)
6500 factory.isPathValid = isPathValid
6503 factory.default = factory
6505 module.exports = factory
6508 // --------------------------------------------------------------
6509 /* istanbul ignore if */
6511 // Detect `process` so that it can run in browsers.
6512 typeof process !== 'undefined'
6514 process.env && process.env.IGNORE_TEST_WIN32
6515 || process.platform === 'win32'
6518 /* eslint no-control-regex: "off" */
6519 const makePosix = str => /^\\\\\?\\/.test(str)
6520 || /["<>|\u0000-\u001F]+/u.test(str)
6522 : str.replace(/\\/g, '/')
6524 checkPath.convert = makePosix
6526 // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
6528 const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i
6529 checkPath.isNotRelative = path =>
6530 REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
6531 || isNotRelative(path)
6537 /***/ (function(module, exports, __webpack_require__) {
6541 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6542 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6543 return new (P || (P = Promise))(function (resolve, reject) {
6544 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6545 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6546 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6547 step((generator = generator.apply(thisArg, _arguments || [])).next());
6550 var __importDefault = (this && this.__importDefault) || function (mod) {
6551 return (mod && mod.__esModule) ? mod : { "default": mod };
6553 Object.defineProperty(exports, "__esModule", { value: true });
6554 exports.fullDocumentRange = exports.format = void 0;
6555 const coc_nvim_1 = __webpack_require__(1);
6556 const path_1 = __importDefault(__webpack_require__(12));
6557 const vscode_languageserver_protocol_1 = __webpack_require__(2);
6558 const errorHandler_1 = __webpack_require__(34);
6559 const requirePkg_1 = __webpack_require__(38);
6560 const utils_1 = __webpack_require__(37);
6562 * HOLD style parsers (for stylelint integration)
6564 const STYLE_PARSERS = ['postcss', 'css', 'less', 'scss'];
6566 * Resolves the prettierconfig for the given file.
6568 * @param filePath file's path
6570 function resolveConfig(filePath, options) {
6571 return __awaiter(this, void 0, void 0, function* () {
6573 const localPrettier = (yield requirePkg_1.requireLocalPkg(path_1.default.dirname(filePath), 'prettier', { silent: true, ignoreBundled: true }));
6574 let prettierInstance = localPrettier;
6575 if (!prettierInstance && !options.onlyUseLocalVersion) {
6576 prettierInstance = __webpack_require__(33);
6578 const config = yield prettierInstance.resolveConfig(filePath, options);
6582 return { config: null, error };
6587 * Define which config should be used.
6588 * If a prettierconfig exists, it returns itself.
6589 * It merges prettierconfig into vscode's config (editorconfig).
6591 * - additionalConfig
6594 * @param hasPrettierConfig a prettierconfig exists
6595 * @param additionalConfig config we really want to see in. (range)
6596 * @param prettierConfig prettier's file config
6597 * @param vscodeConfig our config
6599 function mergeConfig(hasPrettierConfig, additionalConfig, prettierConfig, vscodeConfig) {
6600 return hasPrettierConfig
6601 ? Object.assign({ parser: vscodeConfig.parser }, // always merge our inferred parser in
6602 prettierConfig, additionalConfig)
6603 : Object.assign(vscodeConfig, prettierConfig, additionalConfig);
6606 * Format the given text with user's configuration.
6607 * @param text Text to format
6608 * @param path formatting file's path
6609 * @returns {string} formatted text
6611 function format(text, { languageId, uri }, customOptions) {
6612 return __awaiter(this, void 0, void 0, function* () {
6613 let u = coc_nvim_1.Uri.parse(uri);
6614 const isUntitled = u.scheme == 'untitled';
6615 const fileName = u.fsPath;
6616 const vscodeConfig = utils_1.getConfig(u);
6617 const localOnly = vscodeConfig.onlyUseLocalVersion;
6618 const resolvedPrettier = yield utils_1.getPrettierInstance();
6619 if (!resolvedPrettier) {
6620 errorHandler_1.addToOutput(`Prettier module not found, prettier.onlyUseLocalVersion: ${vscodeConfig.onlyUseLocalVersion}`, 'Error');
6622 let supportedLanguages = utils_1.allLanguages(resolvedPrettier);
6623 if (supportedLanguages.indexOf(languageId) == -1) {
6624 coc_nvim_1.workspace.showMessage(`${languageId} not supported by prettier`, 'error');
6627 const dynamicParsers = utils_1.getParsersFromLanguageId(languageId, resolvedPrettier, isUntitled ? undefined : fileName);
6628 let useBundled = false;
6630 if (!dynamicParsers.length) {
6631 const bundledParsers = utils_1.getParsersFromLanguageId(languageId, __webpack_require__(33), isUntitled ? undefined : fileName);
6632 parser = bundledParsers[0] || 'babylon';
6635 else if (dynamicParsers.includes(vscodeConfig.parser)) {
6636 // handle deprecated parser option (parser: "flow")
6637 parser = vscodeConfig.parser;
6640 parser = dynamicParsers[0];
6642 const doesParserSupportEslint = [
6648 ].includes(languageId);
6649 const { config: fileOptions, error } = yield resolveConfig(fileName, {
6651 onlyUseLocalVersion: localOnly,
6652 requireConfig: vscodeConfig.requireConfig,
6654 const hasConfig = fileOptions != null;
6655 if (!hasConfig && vscodeConfig.requireConfig) {
6659 errorHandler_1.addToOutput(`Failed to resolve config for ${fileName}. Falling back to the default config settings.`, 'Error');
6661 const prettierOptions = mergeConfig(hasConfig, customOptions, fileOptions || {}, {
6662 printWidth: vscodeConfig.printWidth,
6663 tabWidth: vscodeConfig.tabWidth,
6664 singleQuote: vscodeConfig.singleQuote,
6665 jsxSingleQuote: vscodeConfig.jsxSingleQuote,
6666 trailingComma: vscodeConfig.trailingComma,
6667 bracketSpacing: vscodeConfig.bracketSpacing,
6668 jsxBracketSameLine: vscodeConfig.jsxBracketSameLine,
6670 semi: vscodeConfig.semi,
6671 useTabs: vscodeConfig.useTabs,
6672 proseWrap: vscodeConfig.proseWrap,
6673 arrowParens: vscodeConfig.arrowParens,
6675 if (vscodeConfig.tslintIntegration && parser === 'typescript') {
6676 return errorHandler_1.safeExecution(() => {
6677 const prettierTslint = requirePkg_1.requireLocalPkg(u.fsPath, 'prettier-tslint')
6679 // setUsedModule('prettier-tslint', 'Unknown', true)
6680 return prettierTslint({
6683 fallbackPrettierOptions: prettierOptions,
6687 if (vscodeConfig.eslintIntegration && doesParserSupportEslint) {
6688 return errorHandler_1.safeExecution(() => {
6689 const prettierEslint = requirePkg_1.requireLocalPkg(u.fsPath, 'prettier-eslint');
6690 // setUsedModule('prettier-eslint', 'Unknown', true)
6691 return prettierEslint({
6694 fallbackPrettierOptions: prettierOptions,
6698 if (vscodeConfig.stylelintIntegration && STYLE_PARSERS.includes(parser)) {
6699 const prettierStylelint = requirePkg_1.requireLocalPkg(u.fsPath, 'prettier-stylelint');
6700 return errorHandler_1.safeExecution(prettierStylelint.format({
6704 }), text, fileName);
6706 if (!doesParserSupportEslint && useBundled) {
6707 let bundledPrettier = __webpack_require__(33);
6708 return errorHandler_1.safeExecution(() => {
6709 const warningMessage = `prettier@${bundledPrettier.version} doesn't support ${languageId}. ` +
6710 `Falling back to bundled prettier@${bundledPrettier.version}.`;
6711 errorHandler_1.addToOutput(warningMessage, 'Warning');
6712 // setUsedModule('prettier', bundledPrettier.version, true)
6713 return bundledPrettier.format(text, prettierOptions);
6716 // setUsedModule('prettier', localPrettier.version, false)
6717 return errorHandler_1.safeExecution(() => resolvedPrettier.format(text, prettierOptions), text, fileName);
6720 exports.format = format;
6721 function fullDocumentRange(document) {
6722 const lastLineId = document.lineCount - 1;
6723 let doc = coc_nvim_1.workspace.getDocument(document.uri);
6724 return vscode_languageserver_protocol_1.Range.create({ character: 0, line: 0 }, { character: doc.getline(lastLineId).length, line: lastLineId });
6726 exports.fullDocumentRange = fullDocumentRange;
6727 class PrettierEditProvider {
6728 constructor(_fileIsIgnored) {
6729 this._fileIsIgnored = _fileIsIgnored;
6731 provideDocumentRangeFormattingEdits(document, range, _options, _token) {
6732 return this._provideEdits(document, {
6733 rangeStart: document.offsetAt(range.start),
6734 rangeEnd: document.offsetAt(range.end),
6737 provideDocumentFormattingEdits(document, _options, _token) {
6738 return this._provideEdits(document, {});
6740 _provideEdits(document, options) {
6741 return __awaiter(this, void 0, void 0, function* () {
6742 let fileName = coc_nvim_1.Uri.parse(document.uri).fsPath;
6743 if (!document.uri.startsWith('untitled') && this._fileIsIgnored(fileName)) {
6744 return Promise.resolve([]);
6746 const code = yield format(document.getText(), document, options);
6747 const edits = [yield vscode_languageserver_protocol_1.TextEdit.replace(fullDocumentRange(document), code)];
6748 const { disableSuccessMessage } = utils_1.getConfig();
6749 if (edits && edits.length && !disableSuccessMessage) {
6750 coc_nvim_1.workspace.showMessage('Formatted by prettier');
6752 errorHandler_1.addToOutput(`Formatted file: ${document.uri}`);
6753 errorHandler_1.addToOutput(`Prettier format edits: ${JSON.stringify(edits, null, 2)}`);
6758 exports.default = PrettierEditProvider;