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 = 36);
86 /************************************************************************/
91 /***/ (function(module, exports) {
93 module.exports = require("fs");
97 /***/ (function(module, exports) {
99 module.exports = require("path");
103 /***/ (function(module, exports, __webpack_require__) {
106 /* --------------------------------------------------------------------------------------------
\r
107 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
108 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
109 * ------------------------------------------------------------------------------------------ */
\r
111 function __export(m) {
\r
112 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
114 Object.defineProperty(exports, "__esModule", { value: true });
\r
115 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
116 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
\r
117 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
\r
118 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
\r
119 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
\r
120 exports.Disposable = vscode_jsonrpc_1.Disposable;
\r
121 exports.Event = vscode_jsonrpc_1.Event;
\r
122 exports.Emitter = vscode_jsonrpc_1.Emitter;
\r
123 exports.Trace = vscode_jsonrpc_1.Trace;
\r
124 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
\r
125 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
\r
126 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
\r
127 exports.RequestType = vscode_jsonrpc_1.RequestType;
\r
128 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
\r
129 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
\r
130 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
\r
131 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
\r
132 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
\r
133 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
\r
134 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
\r
135 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
\r
136 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
\r
137 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
\r
138 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
\r
139 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
\r
140 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
\r
141 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
\r
142 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
\r
143 exports.ProgressType = vscode_jsonrpc_1.ProgressType;
\r
144 __export(__webpack_require__(18));
\r
145 __export(__webpack_require__(19));
\r
146 const callHierarchy = __webpack_require__(30);
\r
148 (function (Proposed) {
\r
149 let CallHierarchyPrepareRequest;
\r
150 (function (CallHierarchyPrepareRequest) {
\r
151 CallHierarchyPrepareRequest.method = callHierarchy.CallHierarchyPrepareRequest.method;
\r
152 CallHierarchyPrepareRequest.type = callHierarchy.CallHierarchyPrepareRequest.type;
\r
153 })(CallHierarchyPrepareRequest = Proposed.CallHierarchyPrepareRequest || (Proposed.CallHierarchyPrepareRequest = {}));
\r
154 let CallHierarchyIncomingCallsRequest;
\r
155 (function (CallHierarchyIncomingCallsRequest) {
\r
156 CallHierarchyIncomingCallsRequest.method = callHierarchy.CallHierarchyIncomingCallsRequest.method;
\r
157 CallHierarchyIncomingCallsRequest.type = callHierarchy.CallHierarchyIncomingCallsRequest;
\r
158 CallHierarchyIncomingCallsRequest.resultType = callHierarchy.CallHierarchyIncomingCallsRequest.resultType;
\r
159 })(CallHierarchyIncomingCallsRequest = Proposed.CallHierarchyIncomingCallsRequest || (Proposed.CallHierarchyIncomingCallsRequest = {}));
\r
160 let CallHierarchyOutgoingCallsRequest;
\r
161 (function (CallHierarchyOutgoingCallsRequest) {
\r
162 CallHierarchyOutgoingCallsRequest.method = callHierarchy.CallHierarchyOutgoingCallsRequest.method;
\r
163 CallHierarchyOutgoingCallsRequest.type = callHierarchy.CallHierarchyOutgoingCallsRequest;
\r
164 CallHierarchyOutgoingCallsRequest.resultType = callHierarchy.CallHierarchyOutgoingCallsRequest.resultType;
\r
165 })(CallHierarchyOutgoingCallsRequest = Proposed.CallHierarchyOutgoingCallsRequest || (Proposed.CallHierarchyOutgoingCallsRequest = {}));
\r
166 })(Proposed = exports.Proposed || (exports.Proposed = {}));
\r
167 function createProtocolConnection(reader, writer, logger, strategy) {
\r
168 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
\r
170 exports.createProtocolConnection = createProtocolConnection;
\r
175 /***/ (function(module, exports, __webpack_require__) {
178 /* --------------------------------------------------------------------------------------------
\r
179 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
180 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
181 * ------------------------------------------------------------------------------------------ */
\r
182 /// <reference path="../typings/thenable.d.ts" />
\r
184 function __export(m) {
\r
185 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
187 Object.defineProperty(exports, "__esModule", { value: true });
\r
188 const Is = __webpack_require__(6);
\r
189 const messages_1 = __webpack_require__(7);
\r
190 exports.RequestType = messages_1.RequestType;
\r
191 exports.RequestType0 = messages_1.RequestType0;
\r
192 exports.RequestType1 = messages_1.RequestType1;
\r
193 exports.RequestType2 = messages_1.RequestType2;
\r
194 exports.RequestType3 = messages_1.RequestType3;
\r
195 exports.RequestType4 = messages_1.RequestType4;
\r
196 exports.RequestType5 = messages_1.RequestType5;
\r
197 exports.RequestType6 = messages_1.RequestType6;
\r
198 exports.RequestType7 = messages_1.RequestType7;
\r
199 exports.RequestType8 = messages_1.RequestType8;
\r
200 exports.RequestType9 = messages_1.RequestType9;
\r
201 exports.ResponseError = messages_1.ResponseError;
\r
202 exports.ErrorCodes = messages_1.ErrorCodes;
\r
203 exports.NotificationType = messages_1.NotificationType;
\r
204 exports.NotificationType0 = messages_1.NotificationType0;
\r
205 exports.NotificationType1 = messages_1.NotificationType1;
\r
206 exports.NotificationType2 = messages_1.NotificationType2;
\r
207 exports.NotificationType3 = messages_1.NotificationType3;
\r
208 exports.NotificationType4 = messages_1.NotificationType4;
\r
209 exports.NotificationType5 = messages_1.NotificationType5;
\r
210 exports.NotificationType6 = messages_1.NotificationType6;
\r
211 exports.NotificationType7 = messages_1.NotificationType7;
\r
212 exports.NotificationType8 = messages_1.NotificationType8;
\r
213 exports.NotificationType9 = messages_1.NotificationType9;
\r
214 const messageReader_1 = __webpack_require__(8);
\r
215 exports.MessageReader = messageReader_1.MessageReader;
\r
216 exports.StreamMessageReader = messageReader_1.StreamMessageReader;
\r
217 exports.IPCMessageReader = messageReader_1.IPCMessageReader;
\r
218 exports.SocketMessageReader = messageReader_1.SocketMessageReader;
\r
219 const messageWriter_1 = __webpack_require__(10);
\r
220 exports.MessageWriter = messageWriter_1.MessageWriter;
\r
221 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
\r
222 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
\r
223 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
\r
224 const events_1 = __webpack_require__(9);
\r
225 exports.Disposable = events_1.Disposable;
\r
226 exports.Event = events_1.Event;
\r
227 exports.Emitter = events_1.Emitter;
\r
228 const cancellation_1 = __webpack_require__(11);
\r
229 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
\r
230 exports.CancellationToken = cancellation_1.CancellationToken;
\r
231 const linkedMap_1 = __webpack_require__(12);
\r
232 __export(__webpack_require__(13));
\r
233 __export(__webpack_require__(17));
\r
234 var CancelNotification;
\r
235 (function (CancelNotification) {
\r
236 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
\r
237 })(CancelNotification || (CancelNotification = {}));
\r
238 var ProgressNotification;
\r
239 (function (ProgressNotification) {
\r
240 ProgressNotification.type = new messages_1.NotificationType('$/progress');
\r
241 })(ProgressNotification || (ProgressNotification = {}));
\r
242 class ProgressType {
\r
244 this._ = undefined;
\r
247 exports.ProgressType = ProgressType;
\r
248 exports.NullLogger = Object.freeze({
\r
255 (function (Trace) {
\r
256 Trace[Trace["Off"] = 0] = "Off";
\r
257 Trace[Trace["Messages"] = 1] = "Messages";
\r
258 Trace[Trace["Verbose"] = 2] = "Verbose";
\r
259 })(Trace = exports.Trace || (exports.Trace = {}));
\r
260 (function (Trace) {
\r
261 function fromString(value) {
\r
262 if (!Is.string(value)) {
\r
265 value = value.toLowerCase();
\r
270 return Trace.Messages;
\r
272 return Trace.Verbose;
\r
277 Trace.fromString = fromString;
\r
278 function toString(value) {
\r
282 case Trace.Messages:
\r
284 case Trace.Verbose:
\r
290 Trace.toString = toString;
\r
291 })(Trace = exports.Trace || (exports.Trace = {}));
\r
293 (function (TraceFormat) {
\r
294 TraceFormat["Text"] = "text";
\r
295 TraceFormat["JSON"] = "json";
\r
296 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
297 (function (TraceFormat) {
\r
298 function fromString(value) {
\r
299 value = value.toLowerCase();
\r
300 if (value === 'json') {
\r
301 return TraceFormat.JSON;
\r
304 return TraceFormat.Text;
\r
307 TraceFormat.fromString = fromString;
\r
308 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
309 var SetTraceNotification;
\r
310 (function (SetTraceNotification) {
\r
311 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
\r
312 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
\r
313 var LogTraceNotification;
\r
314 (function (LogTraceNotification) {
\r
315 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
\r
316 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
\r
317 var ConnectionErrors;
\r
318 (function (ConnectionErrors) {
\r
320 * The connection is closed.
\r
322 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
324 * The connection got disposed.
\r
326 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
328 * The connection is already in listening mode.
\r
330 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
\r
331 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
\r
332 class ConnectionError extends Error {
\r
333 constructor(code, message) {
\r
336 Object.setPrototypeOf(this, ConnectionError.prototype);
\r
339 exports.ConnectionError = ConnectionError;
\r
340 var ConnectionStrategy;
\r
341 (function (ConnectionStrategy) {
\r
342 function is(value) {
\r
343 let candidate = value;
\r
344 return candidate && Is.func(candidate.cancelUndispatched);
\r
346 ConnectionStrategy.is = is;
\r
347 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
\r
348 var ConnectionState;
\r
349 (function (ConnectionState) {
\r
350 ConnectionState[ConnectionState["New"] = 1] = "New";
\r
351 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
\r
352 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
\r
353 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
\r
354 })(ConnectionState || (ConnectionState = {}));
\r
355 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
\r
356 let sequenceNumber = 0;
\r
357 let notificationSquenceNumber = 0;
\r
358 let unknownResponseSquenceNumber = 0;
\r
359 const version = '2.0';
\r
360 let starRequestHandler = undefined;
\r
361 let requestHandlers = Object.create(null);
\r
362 let starNotificationHandler = undefined;
\r
363 let notificationHandlers = Object.create(null);
\r
364 let progressHandlers = new Map();
\r
366 let messageQueue = new linkedMap_1.LinkedMap();
\r
367 let responsePromises = Object.create(null);
\r
368 let requestTokens = Object.create(null);
\r
369 let trace = Trace.Off;
\r
370 let traceFormat = TraceFormat.Text;
\r
372 let state = ConnectionState.New;
\r
373 let errorEmitter = new events_1.Emitter();
\r
374 let closeEmitter = new events_1.Emitter();
\r
375 let unhandledNotificationEmitter = new events_1.Emitter();
\r
376 let unhandledProgressEmitter = new events_1.Emitter();
\r
377 let disposeEmitter = new events_1.Emitter();
\r
378 function createRequestQueueKey(id) {
\r
379 return 'req-' + id.toString();
\r
381 function createResponseQueueKey(id) {
\r
383 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
386 return 'res-' + id.toString();
\r
389 function createNotificationQueueKey() {
\r
390 return 'not-' + (++notificationSquenceNumber).toString();
\r
392 function addMessageToQueue(queue, message) {
\r
393 if (messages_1.isRequestMessage(message)) {
\r
394 queue.set(createRequestQueueKey(message.id), message);
\r
396 else if (messages_1.isResponseMessage(message)) {
\r
397 queue.set(createResponseQueueKey(message.id), message);
\r
400 queue.set(createNotificationQueueKey(), message);
\r
403 function cancelUndispatched(_message) {
\r
406 function isListening() {
\r
407 return state === ConnectionState.Listening;
\r
409 function isClosed() {
\r
410 return state === ConnectionState.Closed;
\r
412 function isDisposed() {
\r
413 return state === ConnectionState.Disposed;
\r
415 function closeHandler() {
\r
416 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
417 state = ConnectionState.Closed;
\r
418 closeEmitter.fire(undefined);
\r
420 // If the connection is disposed don't sent close events.
\r
422 function readErrorHandler(error) {
\r
423 errorEmitter.fire([error, undefined, undefined]);
\r
425 function writeErrorHandler(data) {
\r
426 errorEmitter.fire(data);
\r
428 messageReader.onClose(closeHandler);
\r
429 messageReader.onError(readErrorHandler);
\r
430 messageWriter.onClose(closeHandler);
\r
431 messageWriter.onError(writeErrorHandler);
\r
432 function triggerMessageQueue() {
\r
433 if (timer || messageQueue.size === 0) {
\r
436 timer = setImmediate(() => {
\r
438 processMessageQueue();
\r
441 function processMessageQueue() {
\r
442 if (messageQueue.size === 0) {
\r
445 let message = messageQueue.shift();
\r
447 if (messages_1.isRequestMessage(message)) {
\r
448 handleRequest(message);
\r
450 else if (messages_1.isNotificationMessage(message)) {
\r
451 handleNotification(message);
\r
453 else if (messages_1.isResponseMessage(message)) {
\r
454 handleResponse(message);
\r
457 handleInvalidMessage(message);
\r
461 triggerMessageQueue();
\r
464 let callback = (message) => {
\r
466 // We have received a cancellation message. Check if the message is still in the queue
\r
467 // and cancel it if allowed to do so.
\r
468 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
\r
469 let key = createRequestQueueKey(message.params.id);
\r
470 let toCancel = messageQueue.get(key);
\r
471 if (messages_1.isRequestMessage(toCancel)) {
\r
472 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
\r
473 if (response && (response.error !== void 0 || response.result !== void 0)) {
\r
474 messageQueue.delete(key);
\r
475 response.id = toCancel.id;
\r
476 traceSendingResponse(response, message.method, Date.now());
\r
477 messageWriter.write(response);
\r
482 addMessageToQueue(messageQueue, message);
\r
485 triggerMessageQueue();
\r
488 function handleRequest(requestMessage) {
\r
489 if (isDisposed()) {
\r
490 // we return here silently since we fired an event when the
\r
491 // connection got disposed.
\r
494 function reply(resultOrError, method, startTime) {
\r
497 id: requestMessage.id
\r
499 if (resultOrError instanceof messages_1.ResponseError) {
\r
500 message.error = resultOrError.toJson();
\r
503 message.result = resultOrError === void 0 ? null : resultOrError;
\r
505 traceSendingResponse(message, method, startTime);
\r
506 messageWriter.write(message);
\r
508 function replyError(error, method, startTime) {
\r
511 id: requestMessage.id,
\r
512 error: error.toJson()
\r
514 traceSendingResponse(message, method, startTime);
\r
515 messageWriter.write(message);
\r
517 function replySuccess(result, method, startTime) {
\r
518 // The JSON RPC defines that a response must either have a result or an error
\r
519 // So we can't treat undefined as a valid response result.
\r
520 if (result === void 0) {
\r
525 id: requestMessage.id,
\r
528 traceSendingResponse(message, method, startTime);
\r
529 messageWriter.write(message);
\r
531 traceReceivedRequest(requestMessage);
\r
532 let element = requestHandlers[requestMessage.method];
\r
534 let requestHandler;
\r
536 type = element.type;
\r
537 requestHandler = element.handler;
\r
539 let startTime = Date.now();
\r
540 if (requestHandler || starRequestHandler) {
\r
541 let cancellationSource = new cancellation_1.CancellationTokenSource();
\r
542 let tokenKey = String(requestMessage.id);
\r
543 requestTokens[tokenKey] = cancellationSource;
\r
546 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
547 handlerResult = requestHandler
\r
548 ? requestHandler(cancellationSource.token)
\r
549 : starRequestHandler(requestMessage.method, cancellationSource.token);
\r
551 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
552 handlerResult = requestHandler
\r
553 ? requestHandler(...requestMessage.params, cancellationSource.token)
\r
554 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
\r
557 handlerResult = requestHandler
\r
558 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
559 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
561 let promise = handlerResult;
\r
562 if (!handlerResult) {
\r
563 delete requestTokens[tokenKey];
\r
564 replySuccess(handlerResult, requestMessage.method, startTime);
\r
566 else if (promise.then) {
\r
567 promise.then((resultOrError) => {
\r
568 delete requestTokens[tokenKey];
\r
569 reply(resultOrError, requestMessage.method, startTime);
\r
571 delete requestTokens[tokenKey];
\r
572 if (error instanceof messages_1.ResponseError) {
\r
573 replyError(error, requestMessage.method, startTime);
\r
575 else if (error && Is.string(error.message)) {
\r
576 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
579 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
584 delete requestTokens[tokenKey];
\r
585 reply(handlerResult, requestMessage.method, startTime);
\r
589 delete requestTokens[tokenKey];
\r
590 if (error instanceof messages_1.ResponseError) {
\r
591 reply(error, requestMessage.method, startTime);
\r
593 else if (error && Is.string(error.message)) {
\r
594 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
597 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
602 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
605 function handleResponse(responseMessage) {
\r
606 if (isDisposed()) {
\r
607 // See handle request.
\r
610 if (responseMessage.id === null) {
\r
611 if (responseMessage.error) {
\r
612 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
\r
615 logger.error(`Received response message without id. No further error information provided.`);
\r
619 let key = String(responseMessage.id);
\r
620 let responsePromise = responsePromises[key];
\r
621 traceReceivedResponse(responseMessage, responsePromise);
\r
622 if (responsePromise) {
\r
623 delete responsePromises[key];
\r
625 if (responseMessage.error) {
\r
626 let error = responseMessage.error;
\r
627 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
\r
629 else if (responseMessage.result !== void 0) {
\r
630 responsePromise.resolve(responseMessage.result);
\r
633 throw new Error('Should never happen.');
\r
637 if (error.message) {
\r
638 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
641 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
647 function handleNotification(message) {
\r
648 if (isDisposed()) {
\r
649 // See handle request.
\r
652 let type = undefined;
\r
653 let notificationHandler;
\r
654 if (message.method === CancelNotification.type.method) {
\r
655 notificationHandler = (params) => {
\r
656 let id = params.id;
\r
657 let source = requestTokens[String(id)];
\r
664 let element = notificationHandlers[message.method];
\r
666 notificationHandler = element.handler;
\r
667 type = element.type;
\r
670 if (notificationHandler || starNotificationHandler) {
\r
672 traceReceivedNotification(message);
\r
673 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
674 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
\r
676 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
677 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
\r
680 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
684 if (error.message) {
\r
685 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
688 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
693 unhandledNotificationEmitter.fire(message);
\r
696 function handleInvalidMessage(message) {
\r
698 logger.error('Received empty message.');
\r
701 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
\r
702 // Test whether we find an id to reject the promise
\r
703 let responseMessage = message;
\r
704 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
\r
705 let key = String(responseMessage.id);
\r
706 let responseHandler = responsePromises[key];
\r
707 if (responseHandler) {
\r
708 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
\r
712 function traceSendingRequest(message) {
\r
713 if (trace === Trace.Off || !tracer) {
\r
716 if (traceFormat === TraceFormat.Text) {
\r
717 let data = undefined;
\r
718 if (trace === Trace.Verbose && message.params) {
\r
719 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
721 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
724 logLSPMessage('send-request', message);
\r
727 function traceSendingNotification(message) {
\r
728 if (trace === Trace.Off || !tracer) {
\r
731 if (traceFormat === TraceFormat.Text) {
\r
732 let data = undefined;
\r
733 if (trace === Trace.Verbose) {
\r
734 if (message.params) {
\r
735 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
738 data = 'No parameters provided.\n\n';
\r
741 tracer.log(`Sending notification '${message.method}'.`, data);
\r
744 logLSPMessage('send-notification', message);
\r
747 function traceSendingResponse(message, method, startTime) {
\r
748 if (trace === Trace.Off || !tracer) {
\r
751 if (traceFormat === TraceFormat.Text) {
\r
752 let data = undefined;
\r
753 if (trace === Trace.Verbose) {
\r
754 if (message.error && message.error.data) {
\r
755 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
758 if (message.result) {
\r
759 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
761 else if (message.error === void 0) {
\r
762 data = 'No result returned.\n\n';
\r
766 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
769 logLSPMessage('send-response', message);
\r
772 function traceReceivedRequest(message) {
\r
773 if (trace === Trace.Off || !tracer) {
\r
776 if (traceFormat === TraceFormat.Text) {
\r
777 let data = undefined;
\r
778 if (trace === Trace.Verbose && message.params) {
\r
779 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
781 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
784 logLSPMessage('receive-request', message);
\r
787 function traceReceivedNotification(message) {
\r
788 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\r
791 if (traceFormat === TraceFormat.Text) {
\r
792 let data = undefined;
\r
793 if (trace === Trace.Verbose) {
\r
794 if (message.params) {
\r
795 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
798 data = 'No parameters provided.\n\n';
\r
801 tracer.log(`Received notification '${message.method}'.`, data);
\r
804 logLSPMessage('receive-notification', message);
\r
807 function traceReceivedResponse(message, responsePromise) {
\r
808 if (trace === Trace.Off || !tracer) {
\r
811 if (traceFormat === TraceFormat.Text) {
\r
812 let data = undefined;
\r
813 if (trace === Trace.Verbose) {
\r
814 if (message.error && message.error.data) {
\r
815 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
818 if (message.result) {
\r
819 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
821 else if (message.error === void 0) {
\r
822 data = 'No result returned.\n\n';
\r
826 if (responsePromise) {
\r
827 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
\r
828 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
\r
831 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
835 logLSPMessage('receive-response', message);
\r
838 function logLSPMessage(type, message) {
\r
839 if (!tracer || trace === Trace.Off) {
\r
842 const lspMessage = {
\r
843 isLSPMessage: true,
\r
846 timestamp: Date.now()
\r
848 tracer.log(lspMessage);
\r
850 function throwIfClosedOrDisposed() {
\r
852 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
854 if (isDisposed()) {
\r
855 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
858 function throwIfListening() {
\r
859 if (isListening()) {
\r
860 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
863 function throwIfNotListening() {
\r
864 if (!isListening()) {
\r
865 throw new Error('Call listen() first.');
\r
868 function undefinedToNull(param) {
\r
869 if (param === void 0) {
\r
876 function computeMessageParams(type, params) {
\r
878 let numberOfParams = type.numberOfParams;
\r
879 switch (numberOfParams) {
\r
884 result = undefinedToNull(params[0]);
\r
888 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
889 result.push(undefinedToNull(params[i]));
\r
891 if (params.length < numberOfParams) {
\r
892 for (let i = params.length; i < numberOfParams; i++) {
\r
901 sendNotification: (type, ...params) => {
\r
902 throwIfClosedOrDisposed();
\r
905 if (Is.string(type)) {
\r
907 switch (params.length) {
\r
909 messageParams = null;
\r
912 messageParams = params[0];
\r
915 messageParams = params;
\r
920 method = type.method;
\r
921 messageParams = computeMessageParams(type, params);
\r
923 let notificationMessage = {
\r
926 params: messageParams
\r
928 traceSendingNotification(notificationMessage);
\r
929 messageWriter.write(notificationMessage);
\r
931 onNotification: (type, handler) => {
\r
932 throwIfClosedOrDisposed();
\r
933 if (Is.func(type)) {
\r
934 starNotificationHandler = type;
\r
936 else if (handler) {
\r
937 if (Is.string(type)) {
\r
938 notificationHandlers[type] = { type: undefined, handler };
\r
941 notificationHandlers[type.method] = { type, handler };
\r
945 onProgress: (_type, token, handler) => {
\r
946 if (progressHandlers.has(token)) {
\r
947 throw new Error(`Progress handler for token ${token} already registered`);
\r
949 progressHandlers.set(token, handler);
\r
952 progressHandlers.delete(token);
\r
956 sendProgress: (_type, token, value) => {
\r
957 connection.sendNotification(ProgressNotification.type, { token, value });
\r
959 onUnhandledProgress: unhandledProgressEmitter.event,
\r
960 sendRequest: (type, ...params) => {
\r
961 throwIfClosedOrDisposed();
\r
962 throwIfNotListening();
\r
965 let token = undefined;
\r
966 if (Is.string(type)) {
\r
968 switch (params.length) {
\r
970 messageParams = null;
\r
973 // The cancellation token is optional so it can also be undefined.
\r
974 if (cancellation_1.CancellationToken.is(params[0])) {
\r
975 messageParams = null;
\r
979 messageParams = undefinedToNull(params[0]);
\r
983 const last = params.length - 1;
\r
984 if (cancellation_1.CancellationToken.is(params[last])) {
\r
985 token = params[last];
\r
986 if (params.length === 2) {
\r
987 messageParams = undefinedToNull(params[0]);
\r
990 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
994 messageParams = params.map(value => undefinedToNull(value));
\r
1000 method = type.method;
\r
1001 messageParams = computeMessageParams(type, params);
\r
1002 let numberOfParams = type.numberOfParams;
\r
1003 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
\r
1005 let id = sequenceNumber++;
\r
1006 let result = new Promise((resolve, reject) => {
\r
1007 let requestMessage = {
\r
1011 params: messageParams
\r
1013 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
1014 traceSendingRequest(requestMessage);
\r
1016 messageWriter.write(requestMessage);
\r
1019 // Writing the message failed. So we need to reject the promise.
\r
1020 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
\r
1021 responsePromise = null;
\r
1023 if (responsePromise) {
\r
1024 responsePromises[String(id)] = responsePromise;
\r
1028 token.onCancellationRequested(() => {
\r
1029 connection.sendNotification(CancelNotification.type, { id });
\r
1034 onRequest: (type, handler) => {
\r
1035 throwIfClosedOrDisposed();
\r
1036 if (Is.func(type)) {
\r
1037 starRequestHandler = type;
\r
1039 else if (handler) {
\r
1040 if (Is.string(type)) {
\r
1041 requestHandlers[type] = { type: undefined, handler };
\r
1044 requestHandlers[type.method] = { type, handler };
\r
1048 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
\r
1049 let _sendNotification = false;
\r
1050 let _traceFormat = TraceFormat.Text;
\r
1051 if (sendNotificationOrTraceOptions !== void 0) {
\r
1052 if (Is.boolean(sendNotificationOrTraceOptions)) {
\r
1053 _sendNotification = sendNotificationOrTraceOptions;
\r
1056 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
1057 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
1061 traceFormat = _traceFormat;
\r
1062 if (trace === Trace.Off) {
\r
1063 tracer = undefined;
\r
1068 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
1069 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
1072 onError: errorEmitter.event,
\r
1073 onClose: closeEmitter.event,
\r
1074 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
1075 onDispose: disposeEmitter.event,
\r
1077 if (isDisposed()) {
\r
1080 state = ConnectionState.Disposed;
\r
1081 disposeEmitter.fire(undefined);
\r
1082 let error = new Error('Connection got disposed.');
\r
1083 Object.keys(responsePromises).forEach((key) => {
\r
1084 responsePromises[key].reject(error);
\r
1086 responsePromises = Object.create(null);
\r
1087 requestTokens = Object.create(null);
\r
1088 messageQueue = new linkedMap_1.LinkedMap();
\r
1089 // Test for backwards compatibility
\r
1090 if (Is.func(messageWriter.dispose)) {
\r
1091 messageWriter.dispose();
\r
1093 if (Is.func(messageReader.dispose)) {
\r
1094 messageReader.dispose();
\r
1098 throwIfClosedOrDisposed();
\r
1099 throwIfListening();
\r
1100 state = ConnectionState.Listening;
\r
1101 messageReader.listen(callback);
\r
1104 // eslint-disable-next-line no-console
\r
1105 console.log('inspect');
\r
1108 connection.onNotification(LogTraceNotification.type, (params) => {
\r
1109 if (trace === Trace.Off || !tracer) {
\r
1112 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
1114 connection.onNotification(ProgressNotification.type, (params) => {
\r
1115 const handler = progressHandlers.get(params.token);
\r
1117 handler(params.value);
\r
1120 unhandledProgressEmitter.fire(params);
\r
1123 return connection;
\r
1125 function isMessageReader(value) {
\r
1126 return value.listen !== void 0 && value.read === void 0;
\r
1128 function isMessageWriter(value) {
\r
1129 return value.write !== void 0 && value.end === void 0;
\r
1131 function createMessageConnection(input, output, logger, strategy) {
\r
1133 logger = exports.NullLogger;
\r
1135 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
\r
1136 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
\r
1137 return _createMessageConnection(reader, writer, logger, strategy);
\r
1139 exports.createMessageConnection = createMessageConnection;
\r
1144 /***/ (function(module, exports, __webpack_require__) {
1147 /* --------------------------------------------------------------------------------------------
\r
1148 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1149 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1150 * ------------------------------------------------------------------------------------------ */
\r
1152 Object.defineProperty(exports, "__esModule", { value: true });
\r
1153 function boolean(value) {
\r
1154 return value === true || value === false;
\r
1156 exports.boolean = boolean;
\r
1157 function string(value) {
\r
1158 return typeof value === 'string' || value instanceof String;
\r
1160 exports.string = string;
\r
1161 function number(value) {
\r
1162 return typeof value === 'number' || value instanceof Number;
\r
1164 exports.number = number;
\r
1165 function error(value) {
\r
1166 return value instanceof Error;
\r
1168 exports.error = error;
\r
1169 function func(value) {
\r
1170 return typeof value === 'function';
\r
1172 exports.func = func;
\r
1173 function array(value) {
\r
1174 return Array.isArray(value);
\r
1176 exports.array = array;
\r
1177 function stringArray(value) {
\r
1178 return array(value) && value.every(elem => string(elem));
\r
1180 exports.stringArray = stringArray;
\r
1185 /***/ (function(module, exports, __webpack_require__) {
1188 /* --------------------------------------------------------------------------------------------
\r
1189 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1190 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1191 * ------------------------------------------------------------------------------------------ */
\r
1193 Object.defineProperty(exports, "__esModule", { value: true });
\r
1194 const is = __webpack_require__(6);
\r
1196 * Predefined error codes.
\r
1199 (function (ErrorCodes) {
\r
1200 // Defined by JSON RPC
\r
1201 ErrorCodes.ParseError = -32700;
\r
1202 ErrorCodes.InvalidRequest = -32600;
\r
1203 ErrorCodes.MethodNotFound = -32601;
\r
1204 ErrorCodes.InvalidParams = -32602;
\r
1205 ErrorCodes.InternalError = -32603;
\r
1206 ErrorCodes.serverErrorStart = -32099;
\r
1207 ErrorCodes.serverErrorEnd = -32000;
\r
1208 ErrorCodes.ServerNotInitialized = -32002;
\r
1209 ErrorCodes.UnknownErrorCode = -32001;
\r
1210 // Defined by the protocol.
\r
1211 ErrorCodes.RequestCancelled = -32800;
\r
1212 ErrorCodes.ContentModified = -32801;
\r
1213 // Defined by VSCode library.
\r
1214 ErrorCodes.MessageWriteError = 1;
\r
1215 ErrorCodes.MessageReadError = 2;
\r
1216 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
\r
1218 * An error object return in a response in case a request
\r
1221 class ResponseError extends Error {
\r
1222 constructor(code, message, data) {
\r
1224 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
1226 Object.setPrototypeOf(this, ResponseError.prototype);
\r
1231 message: this.message,
\r
1236 exports.ResponseError = ResponseError;
\r
1238 * An abstract implementation of a MessageType.
\r
1240 class AbstractMessageType {
\r
1241 constructor(_method, _numberOfParams) {
\r
1242 this._method = _method;
\r
1243 this._numberOfParams = _numberOfParams;
\r
1246 return this._method;
\r
1248 get numberOfParams() {
\r
1249 return this._numberOfParams;
\r
1252 exports.AbstractMessageType = AbstractMessageType;
\r
1254 * Classes to type request response pairs
\r
1256 class RequestType0 extends AbstractMessageType {
\r
1257 constructor(method) {
\r
1259 this._ = undefined;
\r
1262 exports.RequestType0 = RequestType0;
\r
1263 class RequestType extends AbstractMessageType {
\r
1264 constructor(method) {
\r
1266 this._ = undefined;
\r
1269 exports.RequestType = RequestType;
\r
1270 class RequestType1 extends AbstractMessageType {
\r
1271 constructor(method) {
\r
1273 this._ = undefined;
\r
1276 exports.RequestType1 = RequestType1;
\r
1277 class RequestType2 extends AbstractMessageType {
\r
1278 constructor(method) {
\r
1280 this._ = undefined;
\r
1283 exports.RequestType2 = RequestType2;
\r
1284 class RequestType3 extends AbstractMessageType {
\r
1285 constructor(method) {
\r
1287 this._ = undefined;
\r
1290 exports.RequestType3 = RequestType3;
\r
1291 class RequestType4 extends AbstractMessageType {
\r
1292 constructor(method) {
\r
1294 this._ = undefined;
\r
1297 exports.RequestType4 = RequestType4;
\r
1298 class RequestType5 extends AbstractMessageType {
\r
1299 constructor(method) {
\r
1301 this._ = undefined;
\r
1304 exports.RequestType5 = RequestType5;
\r
1305 class RequestType6 extends AbstractMessageType {
\r
1306 constructor(method) {
\r
1308 this._ = undefined;
\r
1311 exports.RequestType6 = RequestType6;
\r
1312 class RequestType7 extends AbstractMessageType {
\r
1313 constructor(method) {
\r
1315 this._ = undefined;
\r
1318 exports.RequestType7 = RequestType7;
\r
1319 class RequestType8 extends AbstractMessageType {
\r
1320 constructor(method) {
\r
1322 this._ = undefined;
\r
1325 exports.RequestType8 = RequestType8;
\r
1326 class RequestType9 extends AbstractMessageType {
\r
1327 constructor(method) {
\r
1329 this._ = undefined;
\r
1332 exports.RequestType9 = RequestType9;
\r
1333 class NotificationType extends AbstractMessageType {
\r
1334 constructor(method) {
\r
1336 this._ = undefined;
\r
1339 exports.NotificationType = NotificationType;
\r
1340 class NotificationType0 extends AbstractMessageType {
\r
1341 constructor(method) {
\r
1343 this._ = undefined;
\r
1346 exports.NotificationType0 = NotificationType0;
\r
1347 class NotificationType1 extends AbstractMessageType {
\r
1348 constructor(method) {
\r
1350 this._ = undefined;
\r
1353 exports.NotificationType1 = NotificationType1;
\r
1354 class NotificationType2 extends AbstractMessageType {
\r
1355 constructor(method) {
\r
1357 this._ = undefined;
\r
1360 exports.NotificationType2 = NotificationType2;
\r
1361 class NotificationType3 extends AbstractMessageType {
\r
1362 constructor(method) {
\r
1364 this._ = undefined;
\r
1367 exports.NotificationType3 = NotificationType3;
\r
1368 class NotificationType4 extends AbstractMessageType {
\r
1369 constructor(method) {
\r
1371 this._ = undefined;
\r
1374 exports.NotificationType4 = NotificationType4;
\r
1375 class NotificationType5 extends AbstractMessageType {
\r
1376 constructor(method) {
\r
1378 this._ = undefined;
\r
1381 exports.NotificationType5 = NotificationType5;
\r
1382 class NotificationType6 extends AbstractMessageType {
\r
1383 constructor(method) {
\r
1385 this._ = undefined;
\r
1388 exports.NotificationType6 = NotificationType6;
\r
1389 class NotificationType7 extends AbstractMessageType {
\r
1390 constructor(method) {
\r
1392 this._ = undefined;
\r
1395 exports.NotificationType7 = NotificationType7;
\r
1396 class NotificationType8 extends AbstractMessageType {
\r
1397 constructor(method) {
\r
1399 this._ = undefined;
\r
1402 exports.NotificationType8 = NotificationType8;
\r
1403 class NotificationType9 extends AbstractMessageType {
\r
1404 constructor(method) {
\r
1406 this._ = undefined;
\r
1409 exports.NotificationType9 = NotificationType9;
\r
1411 * Tests if the given message is a request message
\r
1413 function isRequestMessage(message) {
\r
1414 let candidate = message;
\r
1415 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
\r
1417 exports.isRequestMessage = isRequestMessage;
\r
1419 * Tests if the given message is a notification message
\r
1421 function isNotificationMessage(message) {
\r
1422 let candidate = message;
\r
1423 return candidate && is.string(candidate.method) && message.id === void 0;
\r
1425 exports.isNotificationMessage = isNotificationMessage;
\r
1427 * Tests if the given message is a response message
\r
1429 function isResponseMessage(message) {
\r
1430 let candidate = message;
\r
1431 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
\r
1433 exports.isResponseMessage = isResponseMessage;
\r
1438 /***/ (function(module, exports, __webpack_require__) {
1441 /* --------------------------------------------------------------------------------------------
\r
1442 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1443 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1444 * ------------------------------------------------------------------------------------------ */
\r
1446 Object.defineProperty(exports, "__esModule", { value: true });
\r
1447 const events_1 = __webpack_require__(9);
\r
1448 const Is = __webpack_require__(6);
\r
1449 let DefaultSize = 8192;
\r
1450 let CR = Buffer.from('\r', 'ascii')[0];
\r
1451 let LF = Buffer.from('\n', 'ascii')[0];
\r
1452 let CRLF = '\r\n';
\r
1453 class MessageBuffer {
\r
1454 constructor(encoding = 'utf8') {
\r
1455 this.encoding = encoding;
\r
1457 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
1460 var toAppend = chunk;
\r
1461 if (typeof (chunk) === 'string') {
\r
1463 var bufferLen = Buffer.byteLength(str, this.encoding);
\r
1464 toAppend = Buffer.allocUnsafe(bufferLen);
\r
1465 toAppend.write(str, 0, bufferLen, this.encoding);
\r
1467 if (this.buffer.length - this.index >= toAppend.length) {
\r
1468 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\r
1471 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
\r
1472 if (this.index === 0) {
\r
1473 this.buffer = Buffer.allocUnsafe(newSize);
\r
1474 toAppend.copy(this.buffer, 0, 0, toAppend.length);
\r
1477 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
1480 this.index += toAppend.length;
\r
1482 tryReadHeaders() {
\r
1483 let result = undefined;
\r
1485 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
1488 // No header / body separator found (e.g CRLFCRLF)
\r
1489 if (current + 3 >= this.index) {
\r
1492 result = Object.create(null);
\r
1493 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
\r
1494 headers.forEach((header) => {
\r
1495 let index = header.indexOf(':');
\r
1496 if (index === -1) {
\r
1497 throw new Error('Message header must separate key and value using :');
\r
1499 let key = header.substr(0, index);
\r
1500 let value = header.substr(index + 1).trim();
\r
1501 result[key] = value;
\r
1503 let nextStart = current + 4;
\r
1504 this.buffer = this.buffer.slice(nextStart);
\r
1505 this.index = this.index - nextStart;
\r
1508 tryReadContent(length) {
\r
1509 if (this.index < length) {
\r
1512 let result = this.buffer.toString(this.encoding, 0, length);
\r
1513 let nextStart = length;
\r
1514 this.buffer.copy(this.buffer, 0, nextStart);
\r
1515 this.index = this.index - nextStart;
\r
1518 get numberOfBytes() {
\r
1519 return this.index;
\r
1522 var MessageReader;
\r
1523 (function (MessageReader) {
\r
1524 function is(value) {
\r
1525 let candidate = value;
\r
1526 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
\r
1527 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
\r
1529 MessageReader.is = is;
\r
1530 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
1531 class AbstractMessageReader {
\r
1533 this.errorEmitter = new events_1.Emitter();
\r
1534 this.closeEmitter = new events_1.Emitter();
\r
1535 this.partialMessageEmitter = new events_1.Emitter();
\r
1538 this.errorEmitter.dispose();
\r
1539 this.closeEmitter.dispose();
\r
1542 return this.errorEmitter.event;
\r
1544 fireError(error) {
\r
1545 this.errorEmitter.fire(this.asError(error));
\r
1548 return this.closeEmitter.event;
\r
1551 this.closeEmitter.fire(undefined);
\r
1553 get onPartialMessage() {
\r
1554 return this.partialMessageEmitter.event;
\r
1556 firePartialMessage(info) {
\r
1557 this.partialMessageEmitter.fire(info);
\r
1560 if (error instanceof Error) {
\r
1564 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1568 exports.AbstractMessageReader = AbstractMessageReader;
\r
1569 class StreamMessageReader extends AbstractMessageReader {
\r
1570 constructor(readable, encoding = 'utf8') {
\r
1572 this.readable = readable;
\r
1573 this.buffer = new MessageBuffer(encoding);
\r
1574 this._partialMessageTimeout = 10000;
\r
1576 set partialMessageTimeout(timeout) {
\r
1577 this._partialMessageTimeout = timeout;
\r
1579 get partialMessageTimeout() {
\r
1580 return this._partialMessageTimeout;
\r
1582 listen(callback) {
\r
1583 this.nextMessageLength = -1;
\r
1584 this.messageToken = 0;
\r
1585 this.partialMessageTimer = undefined;
\r
1586 this.callback = callback;
\r
1587 this.readable.on('data', (data) => {
\r
1588 this.onData(data);
\r
1590 this.readable.on('error', (error) => this.fireError(error));
\r
1591 this.readable.on('close', () => this.fireClose());
\r
1594 this.buffer.append(data);
\r
1596 if (this.nextMessageLength === -1) {
\r
1597 let headers = this.buffer.tryReadHeaders();
\r
1601 let contentLength = headers['Content-Length'];
\r
1602 if (!contentLength) {
\r
1603 throw new Error('Header must provide a Content-Length property.');
\r
1605 let length = parseInt(contentLength);
\r
1606 if (isNaN(length)) {
\r
1607 throw new Error('Content-Length value must be a number.');
\r
1609 this.nextMessageLength = length;
\r
1610 // Take the encoding form the header. For compatibility
\r
1611 // treat both utf-8 and utf8 as node utf8
\r
1613 var msg = this.buffer.tryReadContent(this.nextMessageLength);
\r
1614 if (msg === null) {
\r
1615 /** We haven't received the full message yet. */
\r
1616 this.setPartialMessageTimer();
\r
1619 this.clearPartialMessageTimer();
\r
1620 this.nextMessageLength = -1;
\r
1621 this.messageToken++;
\r
1622 var json = JSON.parse(msg);
\r
1623 this.callback(json);
\r
1626 clearPartialMessageTimer() {
\r
1627 if (this.partialMessageTimer) {
\r
1628 clearTimeout(this.partialMessageTimer);
\r
1629 this.partialMessageTimer = undefined;
\r
1632 setPartialMessageTimer() {
\r
1633 this.clearPartialMessageTimer();
\r
1634 if (this._partialMessageTimeout <= 0) {
\r
1637 this.partialMessageTimer = setTimeout((token, timeout) => {
\r
1638 this.partialMessageTimer = undefined;
\r
1639 if (token === this.messageToken) {
\r
1640 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
\r
1641 this.setPartialMessageTimer();
\r
1643 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
1646 exports.StreamMessageReader = StreamMessageReader;
\r
1647 class IPCMessageReader extends AbstractMessageReader {
\r
1648 constructor(process) {
\r
1650 this.process = process;
\r
1651 let eventEmitter = this.process;
\r
1652 eventEmitter.on('error', (error) => this.fireError(error));
\r
1653 eventEmitter.on('close', () => this.fireClose());
\r
1655 listen(callback) {
\r
1656 this.process.on('message', callback);
\r
1659 exports.IPCMessageReader = IPCMessageReader;
\r
1660 class SocketMessageReader extends StreamMessageReader {
\r
1661 constructor(socket, encoding = 'utf-8') {
\r
1662 super(socket, encoding);
\r
1665 exports.SocketMessageReader = SocketMessageReader;
\r
1670 /***/ (function(module, exports, __webpack_require__) {
1673 /* --------------------------------------------------------------------------------------------
\r
1674 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1675 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1676 * ------------------------------------------------------------------------------------------ */
\r
1678 Object.defineProperty(exports, "__esModule", { value: true });
\r
1680 (function (Disposable) {
\r
1681 function create(func) {
\r
1686 Disposable.create = create;
\r
1687 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\r
1689 (function (Event) {
\r
1690 const _disposable = { dispose() { } };
\r
1691 Event.None = function () { return _disposable; };
\r
1692 })(Event = exports.Event || (exports.Event = {}));
\r
1693 class CallbackList {
\r
1694 add(callback, context = null, bucket) {
\r
1695 if (!this._callbacks) {
\r
1696 this._callbacks = [];
\r
1697 this._contexts = [];
\r
1699 this._callbacks.push(callback);
\r
1700 this._contexts.push(context);
\r
1701 if (Array.isArray(bucket)) {
\r
1702 bucket.push({ dispose: () => this.remove(callback, context) });
\r
1705 remove(callback, context = null) {
\r
1706 if (!this._callbacks) {
\r
1709 var foundCallbackWithDifferentContext = false;
\r
1710 for (var i = 0, len = this._callbacks.length; i < len; i++) {
\r
1711 if (this._callbacks[i] === callback) {
\r
1712 if (this._contexts[i] === context) {
\r
1713 // callback & context match => remove it
\r
1714 this._callbacks.splice(i, 1);
\r
1715 this._contexts.splice(i, 1);
\r
1719 foundCallbackWithDifferentContext = true;
\r
1723 if (foundCallbackWithDifferentContext) {
\r
1724 throw new Error('When adding a listener with a context, you should remove it with the same context');
\r
1728 if (!this._callbacks) {
\r
1731 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
\r
1732 for (var i = 0, len = callbacks.length; i < len; i++) {
\r
1734 ret.push(callbacks[i].apply(contexts[i], args));
\r
1737 // eslint-disable-next-line no-console
\r
1744 return !this._callbacks || this._callbacks.length === 0;
\r
1747 this._callbacks = undefined;
\r
1748 this._contexts = undefined;
\r
1752 constructor(_options) {
\r
1753 this._options = _options;
\r
1756 * For the public to allow to subscribe
\r
1757 * to events from this Emitter
\r
1760 if (!this._event) {
\r
1761 this._event = (listener, thisArgs, disposables) => {
\r
1762 if (!this._callbacks) {
\r
1763 this._callbacks = new CallbackList();
\r
1765 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
1766 this._options.onFirstListenerAdd(this);
\r
1768 this._callbacks.add(listener, thisArgs);
\r
1772 this._callbacks.remove(listener, thisArgs);
\r
1773 result.dispose = Emitter._noop;
\r
1774 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
\r
1775 this._options.onLastListenerRemove(this);
\r
1779 if (Array.isArray(disposables)) {
\r
1780 disposables.push(result);
\r
1785 return this._event;
\r
1788 * To be kept private to fire an event to
\r
1792 if (this._callbacks) {
\r
1793 this._callbacks.invoke.call(this._callbacks, event);
\r
1797 if (this._callbacks) {
\r
1798 this._callbacks.dispose();
\r
1799 this._callbacks = undefined;
\r
1803 exports.Emitter = Emitter;
\r
1804 Emitter._noop = function () { };
\r
1809 /***/ (function(module, exports, __webpack_require__) {
1812 /* --------------------------------------------------------------------------------------------
\r
1813 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
1814 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
1815 * ------------------------------------------------------------------------------------------ */
\r
1817 Object.defineProperty(exports, "__esModule", { value: true });
\r
1818 const events_1 = __webpack_require__(9);
\r
1819 const Is = __webpack_require__(6);
\r
1820 let ContentLength = 'Content-Length: ';
\r
1821 let CRLF = '\r\n';
\r
1822 var MessageWriter;
\r
1823 (function (MessageWriter) {
\r
1824 function is(value) {
\r
1825 let candidate = value;
\r
1826 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
\r
1827 Is.func(candidate.onError) && Is.func(candidate.write);
\r
1829 MessageWriter.is = is;
\r
1830 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
1831 class AbstractMessageWriter {
\r
1833 this.errorEmitter = new events_1.Emitter();
\r
1834 this.closeEmitter = new events_1.Emitter();
\r
1837 this.errorEmitter.dispose();
\r
1838 this.closeEmitter.dispose();
\r
1841 return this.errorEmitter.event;
\r
1843 fireError(error, message, count) {
\r
1844 this.errorEmitter.fire([this.asError(error), message, count]);
\r
1847 return this.closeEmitter.event;
\r
1850 this.closeEmitter.fire(undefined);
\r
1853 if (error instanceof Error) {
\r
1857 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
1861 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
1862 class StreamMessageWriter extends AbstractMessageWriter {
\r
1863 constructor(writable, encoding = 'utf8') {
\r
1865 this.writable = writable;
\r
1866 this.encoding = encoding;
\r
1867 this.errorCount = 0;
\r
1868 this.writable.on('error', (error) => this.fireError(error));
\r
1869 this.writable.on('close', () => this.fireClose());
\r
1872 let json = JSON.stringify(msg);
\r
1873 let contentLength = Buffer.byteLength(json, this.encoding);
\r
1875 ContentLength, contentLength.toString(), CRLF,
\r
1879 // Header must be written in ASCII encoding
\r
1880 this.writable.write(headers.join(''), 'ascii');
\r
1881 // Now write the content. This can be written in any encoding
\r
1882 this.writable.write(json, this.encoding);
\r
1883 this.errorCount = 0;
\r
1886 this.errorCount++;
\r
1887 this.fireError(error, msg, this.errorCount);
\r
1891 exports.StreamMessageWriter = StreamMessageWriter;
\r
1892 class IPCMessageWriter extends AbstractMessageWriter {
\r
1893 constructor(process) {
\r
1895 this.process = process;
\r
1896 this.errorCount = 0;
\r
1898 this.sending = false;
\r
1899 let eventEmitter = this.process;
\r
1900 eventEmitter.on('error', (error) => this.fireError(error));
\r
1901 eventEmitter.on('close', () => this.fireClose);
\r
1904 if (!this.sending && this.queue.length === 0) {
\r
1905 // See https://github.com/nodejs/node/issues/7657
\r
1906 this.doWriteMessage(msg);
\r
1909 this.queue.push(msg);
\r
1912 doWriteMessage(msg) {
\r
1914 if (this.process.send) {
\r
1915 this.sending = true;
\r
1916 this.process.send(msg, undefined, undefined, (error) => {
\r
1917 this.sending = false;
\r
1919 this.errorCount++;
\r
1920 this.fireError(error, msg, this.errorCount);
\r
1923 this.errorCount = 0;
\r
1925 if (this.queue.length > 0) {
\r
1926 this.doWriteMessage(this.queue.shift());
\r
1932 this.errorCount++;
\r
1933 this.fireError(error, msg, this.errorCount);
\r
1937 exports.IPCMessageWriter = IPCMessageWriter;
\r
1938 class SocketMessageWriter extends AbstractMessageWriter {
\r
1939 constructor(socket, encoding = 'utf8') {
\r
1941 this.socket = socket;
\r
1943 this.sending = false;
\r
1944 this.encoding = encoding;
\r
1945 this.errorCount = 0;
\r
1946 this.socket.on('error', (error) => this.fireError(error));
\r
1947 this.socket.on('close', () => this.fireClose());
\r
1951 this.socket.destroy();
\r
1954 if (!this.sending && this.queue.length === 0) {
\r
1955 // See https://github.com/nodejs/node/issues/7657
\r
1956 this.doWriteMessage(msg);
\r
1959 this.queue.push(msg);
\r
1962 doWriteMessage(msg) {
\r
1963 let json = JSON.stringify(msg);
\r
1964 let contentLength = Buffer.byteLength(json, this.encoding);
\r
1966 ContentLength, contentLength.toString(), CRLF,
\r
1970 // Header must be written in ASCII encoding
\r
1971 this.sending = true;
\r
1972 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
1974 this.handleError(error, msg);
\r
1977 // Now write the content. This can be written in any encoding
\r
1978 this.socket.write(json, this.encoding, (error) => {
\r
1979 this.sending = false;
\r
1981 this.handleError(error, msg);
\r
1984 this.errorCount = 0;
\r
1986 if (this.queue.length > 0) {
\r
1987 this.doWriteMessage(this.queue.shift());
\r
1992 this.handleError(error, msg);
\r
1997 this.handleError(error, msg);
\r
2000 handleError(error, msg) {
\r
2001 this.errorCount++;
\r
2002 this.fireError(error, msg, this.errorCount);
\r
2005 exports.SocketMessageWriter = SocketMessageWriter;
\r
2010 /***/ (function(module, exports, __webpack_require__) {
2013 /*---------------------------------------------------------------------------------------------
\r
2014 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2015 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2016 *--------------------------------------------------------------------------------------------*/
\r
2018 Object.defineProperty(exports, "__esModule", { value: true });
\r
2019 const events_1 = __webpack_require__(9);
\r
2020 const Is = __webpack_require__(6);
\r
2021 var CancellationToken;
\r
2022 (function (CancellationToken) {
\r
2023 CancellationToken.None = Object.freeze({
\r
2024 isCancellationRequested: false,
\r
2025 onCancellationRequested: events_1.Event.None
\r
2027 CancellationToken.Cancelled = Object.freeze({
\r
2028 isCancellationRequested: true,
\r
2029 onCancellationRequested: events_1.Event.None
\r
2031 function is(value) {
\r
2032 let candidate = value;
\r
2033 return candidate && (candidate === CancellationToken.None
\r
2034 || candidate === CancellationToken.Cancelled
\r
2035 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
\r
2037 CancellationToken.is = is;
\r
2038 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
\r
2039 const shortcutEvent = Object.freeze(function (callback, context) {
\r
2040 let handle = setTimeout(callback.bind(context), 0);
\r
2041 return { dispose() { clearTimeout(handle); } };
\r
2043 class MutableToken {
\r
2045 this._isCancelled = false;
\r
2048 if (!this._isCancelled) {
\r
2049 this._isCancelled = true;
\r
2050 if (this._emitter) {
\r
2051 this._emitter.fire(undefined);
\r
2056 get isCancellationRequested() {
\r
2057 return this._isCancelled;
\r
2059 get onCancellationRequested() {
\r
2060 if (this._isCancelled) {
\r
2061 return shortcutEvent;
\r
2063 if (!this._emitter) {
\r
2064 this._emitter = new events_1.Emitter();
\r
2066 return this._emitter.event;
\r
2069 if (this._emitter) {
\r
2070 this._emitter.dispose();
\r
2071 this._emitter = undefined;
\r
2075 class CancellationTokenSource {
\r
2077 if (!this._token) {
\r
2078 // be lazy and create the token only when
\r
2079 // actually needed
\r
2080 this._token = new MutableToken();
\r
2082 return this._token;
\r
2085 if (!this._token) {
\r
2086 // save an object by returning the default
\r
2087 // cancelled token when cancellation happens
\r
2088 // before someone asks for the token
\r
2089 this._token = CancellationToken.Cancelled;
\r
2092 this._token.cancel();
\r
2096 if (!this._token) {
\r
2097 // ensure to initialize with an empty token if we had none
\r
2098 this._token = CancellationToken.None;
\r
2100 else if (this._token instanceof MutableToken) {
\r
2101 // actually dispose
\r
2102 this._token.dispose();
\r
2106 exports.CancellationTokenSource = CancellationTokenSource;
\r
2111 /***/ (function(module, exports, __webpack_require__) {
2115 /*---------------------------------------------------------------------------------------------
\r
2116 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2117 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2118 *--------------------------------------------------------------------------------------------*/
\r
2119 Object.defineProperty(exports, "__esModule", { value: true });
\r
2121 (function (Touch) {
\r
2125 })(Touch = exports.Touch || (exports.Touch = {}));
\r
2128 this._map = new Map();
\r
2129 this._head = undefined;
\r
2130 this._tail = undefined;
\r
2134 this._map.clear();
\r
2135 this._head = undefined;
\r
2136 this._tail = undefined;
\r
2140 return !this._head && !this._tail;
\r
2143 return this._size;
\r
2146 return this._map.has(key);
\r
2149 const item = this._map.get(key);
\r
2153 return item.value;
\r
2155 set(key, value, touch = Touch.None) {
\r
2156 let item = this._map.get(key);
\r
2158 item.value = value;
\r
2159 if (touch !== Touch.None) {
\r
2160 this.touch(item, touch);
\r
2164 item = { key, value, next: undefined, previous: undefined };
\r
2167 this.addItemLast(item);
\r
2170 this.addItemFirst(item);
\r
2173 this.addItemLast(item);
\r
2176 this.addItemLast(item);
\r
2179 this._map.set(key, item);
\r
2184 const item = this._map.get(key);
\r
2188 this._map.delete(key);
\r
2189 this.removeItem(item);
\r
2194 if (!this._head && !this._tail) {
\r
2197 if (!this._head || !this._tail) {
\r
2198 throw new Error('Invalid list');
\r
2200 const item = this._head;
\r
2201 this._map.delete(item.key);
\r
2202 this.removeItem(item);
\r
2204 return item.value;
\r
2206 forEach(callbackfn, thisArg) {
\r
2207 let current = this._head;
\r
2210 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2213 callbackfn(current.value, current.key, this);
\r
2215 current = current.next;
\r
2218 forEachReverse(callbackfn, thisArg) {
\r
2219 let current = this._tail;
\r
2222 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
2225 callbackfn(current.value, current.key, this);
\r
2227 current = current.previous;
\r
2232 let current = this._head;
\r
2234 result.push(current.value);
\r
2235 current = current.next;
\r
2241 let current = this._head;
\r
2243 result.push(current.key);
\r
2244 current = current.next;
\r
2248 /* JSON RPC run on es5 which has no Symbol.iterator
\r
2249 public keys(): IterableIterator<K> {
\r
2250 let current = this._head;
\r
2251 let iterator: IterableIterator<K> = {
\r
2252 [Symbol.iterator]() {
\r
2255 next():IteratorResult<K> {
\r
2257 let result = { value: current.key, done: false };
\r
2258 current = current.next;
\r
2261 return { value: undefined, done: true };
\r
2268 public values(): IterableIterator<V> {
\r
2269 let current = this._head;
\r
2270 let iterator: IterableIterator<V> = {
\r
2271 [Symbol.iterator]() {
\r
2274 next():IteratorResult<V> {
\r
2276 let result = { value: current.value, done: false };
\r
2277 current = current.next;
\r
2280 return { value: undefined, done: true };
\r
2287 addItemFirst(item) {
\r
2288 // First time Insert
\r
2289 if (!this._head && !this._tail) {
\r
2290 this._tail = item;
\r
2292 else if (!this._head) {
\r
2293 throw new Error('Invalid list');
\r
2296 item.next = this._head;
\r
2297 this._head.previous = item;
\r
2299 this._head = item;
\r
2301 addItemLast(item) {
\r
2302 // First time Insert
\r
2303 if (!this._head && !this._tail) {
\r
2304 this._head = item;
\r
2306 else if (!this._tail) {
\r
2307 throw new Error('Invalid list');
\r
2310 item.previous = this._tail;
\r
2311 this._tail.next = item;
\r
2313 this._tail = item;
\r
2315 removeItem(item) {
\r
2316 if (item === this._head && item === this._tail) {
\r
2317 this._head = undefined;
\r
2318 this._tail = undefined;
\r
2320 else if (item === this._head) {
\r
2321 this._head = item.next;
\r
2323 else if (item === this._tail) {
\r
2324 this._tail = item.previous;
\r
2327 const next = item.next;
\r
2328 const previous = item.previous;
\r
2329 if (!next || !previous) {
\r
2330 throw new Error('Invalid list');
\r
2332 next.previous = previous;
\r
2333 previous.next = next;
\r
2336 touch(item, touch) {
\r
2337 if (!this._head || !this._tail) {
\r
2338 throw new Error('Invalid list');
\r
2340 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
2343 if (touch === Touch.First) {
\r
2344 if (item === this._head) {
\r
2347 const next = item.next;
\r
2348 const previous = item.previous;
\r
2349 // Unlink the item
\r
2350 if (item === this._tail) {
\r
2351 // previous must be defined since item was not head but is tail
\r
2352 // So there are more than on item in the map
\r
2353 previous.next = undefined;
\r
2354 this._tail = previous;
\r
2357 // Both next and previous are not undefined since item was neither head nor tail.
\r
2358 next.previous = previous;
\r
2359 previous.next = next;
\r
2361 // Insert the node at head
\r
2362 item.previous = undefined;
\r
2363 item.next = this._head;
\r
2364 this._head.previous = item;
\r
2365 this._head = item;
\r
2367 else if (touch === Touch.Last) {
\r
2368 if (item === this._tail) {
\r
2371 const next = item.next;
\r
2372 const previous = item.previous;
\r
2373 // Unlink the item.
\r
2374 if (item === this._head) {
\r
2375 // next must be defined since item was not tail but is head
\r
2376 // So there are more than on item in the map
\r
2377 next.previous = undefined;
\r
2378 this._head = next;
\r
2381 // Both next and previous are not undefined since item was neither head nor tail.
\r
2382 next.previous = previous;
\r
2383 previous.next = next;
\r
2385 item.next = undefined;
\r
2386 item.previous = this._tail;
\r
2387 this._tail.next = item;
\r
2388 this._tail = item;
\r
2392 exports.LinkedMap = LinkedMap;
\r
2397 /***/ (function(module, exports, __webpack_require__) {
2400 /* --------------------------------------------------------------------------------------------
\r
2401 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2402 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2403 * ------------------------------------------------------------------------------------------ */
\r
2405 Object.defineProperty(exports, "__esModule", { value: true });
\r
2406 const path_1 = __webpack_require__(3);
\r
2407 const os_1 = __webpack_require__(14);
\r
2408 const crypto_1 = __webpack_require__(15);
\r
2409 const net_1 = __webpack_require__(16);
\r
2410 const messageReader_1 = __webpack_require__(8);
\r
2411 const messageWriter_1 = __webpack_require__(10);
\r
2412 function generateRandomPipeName() {
\r
2413 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
\r
2414 if (process.platform === 'win32') {
\r
2415 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
\r
2418 // Mac/Unix: use socket file
\r
2419 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\r
2422 exports.generateRandomPipeName = generateRandomPipeName;
\r
2423 function createClientPipeTransport(pipeName, encoding = 'utf-8') {
\r
2424 let connectResolve;
\r
2425 let connected = new Promise((resolve, _reject) => {
\r
2426 connectResolve = resolve;
\r
2428 return new Promise((resolve, reject) => {
\r
2429 let server = net_1.createServer((socket) => {
\r
2432 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2433 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2436 server.on('error', reject);
\r
2437 server.listen(pipeName, () => {
\r
2438 server.removeListener('error', reject);
\r
2440 onConnected: () => { return connected; }
\r
2445 exports.createClientPipeTransport = createClientPipeTransport;
\r
2446 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
2447 const socket = net_1.createConnection(pipeName);
\r
2449 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2450 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2453 exports.createServerPipeTransport = createServerPipeTransport;
\r
2458 /***/ (function(module, exports) {
2460 module.exports = require("os");
2464 /***/ (function(module, exports) {
2466 module.exports = require("crypto");
2470 /***/ (function(module, exports) {
2472 module.exports = require("net");
2476 /***/ (function(module, exports, __webpack_require__) {
2479 /* --------------------------------------------------------------------------------------------
\r
2480 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2481 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2482 * ------------------------------------------------------------------------------------------ */
\r
2484 Object.defineProperty(exports, "__esModule", { value: true });
\r
2485 const net_1 = __webpack_require__(16);
\r
2486 const messageReader_1 = __webpack_require__(8);
\r
2487 const messageWriter_1 = __webpack_require__(10);
\r
2488 function createClientSocketTransport(port, encoding = 'utf-8') {
\r
2489 let connectResolve;
\r
2490 let connected = new Promise((resolve, _reject) => {
\r
2491 connectResolve = resolve;
\r
2493 return new Promise((resolve, reject) => {
\r
2494 let server = net_1.createServer((socket) => {
\r
2497 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2498 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2501 server.on('error', reject);
\r
2502 server.listen(port, '127.0.0.1', () => {
\r
2503 server.removeListener('error', reject);
\r
2505 onConnected: () => { return connected; }
\r
2510 exports.createClientSocketTransport = createClientSocketTransport;
\r
2511 function createServerSocketTransport(port, encoding = 'utf-8') {
\r
2512 const socket = net_1.createConnection(port, '127.0.0.1');
\r
2514 new messageReader_1.SocketMessageReader(socket, encoding),
\r
2515 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
2518 exports.createServerSocketTransport = createServerSocketTransport;
\r
2523 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2526 __webpack_require__.r(__webpack_exports__);
2527 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2528 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2529 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2530 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2531 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2532 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2533 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2534 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2535 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2536 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2537 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2538 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
2539 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2540 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2541 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2542 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2543 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2544 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2545 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2546 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2547 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2548 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2549 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2550 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2551 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2552 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2553 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2554 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2555 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemTag", function() { return CompletionItemTag; });
2556 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2557 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2558 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2559 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2560 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2561 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2562 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2563 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2564 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2565 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolTag", function() { return SymbolTag; });
2566 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2567 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2568 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2569 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2570 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2571 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2572 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2573 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2574 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
2575 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2576 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2577 /* --------------------------------------------------------------------------------------------
\r
2578 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
2579 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
2580 * ------------------------------------------------------------------------------------------ */
\r
2583 * The Position namespace provides helper functions to work with
\r
2584 * [Position](#Position) literals.
\r
2587 (function (Position) {
\r
2589 * Creates a new Position literal from the given line and character.
\r
2590 * @param line The position's line.
\r
2591 * @param character The position's character.
\r
2593 function create(line, character) {
\r
2594 return { line: line, character: character };
\r
2596 Position.create = create;
\r
2598 * Checks whether the given liternal conforms to the [Position](#Position) interface.
\r
2600 function is(value) {
\r
2601 var candidate = value;
\r
2602 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
\r
2605 })(Position || (Position = {}));
\r
2607 * The Range namespace provides helper functions to work with
\r
2608 * [Range](#Range) literals.
\r
2611 (function (Range) {
\r
2612 function create(one, two, three, four) {
\r
2613 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
\r
2614 return { start: Position.create(one, two), end: Position.create(three, four) };
\r
2616 else if (Position.is(one) && Position.is(two)) {
\r
2617 return { start: one, end: two };
\r
2620 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
\r
2623 Range.create = create;
\r
2625 * Checks whether the given literal conforms to the [Range](#Range) interface.
\r
2627 function is(value) {
\r
2628 var candidate = value;
\r
2629 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
\r
2632 })(Range || (Range = {}));
\r
2634 * The Location namespace provides helper functions to work with
\r
2635 * [Location](#Location) literals.
\r
2638 (function (Location) {
\r
2640 * Creates a Location literal.
\r
2641 * @param uri The location's uri.
\r
2642 * @param range The location's range.
\r
2644 function create(uri, range) {
\r
2645 return { uri: uri, range: range };
\r
2647 Location.create = create;
\r
2649 * Checks whether the given literal conforms to the [Location](#Location) interface.
\r
2651 function is(value) {
\r
2652 var candidate = value;
\r
2653 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
\r
2656 })(Location || (Location = {}));
\r
2658 * The LocationLink namespace provides helper functions to work with
\r
2659 * [LocationLink](#LocationLink) literals.
\r
2662 (function (LocationLink) {
\r
2664 * Creates a LocationLink literal.
\r
2665 * @param targetUri The definition's uri.
\r
2666 * @param targetRange The full range of the definition.
\r
2667 * @param targetSelectionRange The span of the symbol definition at the target.
\r
2668 * @param originSelectionRange The span of the symbol being defined in the originating source file.
\r
2670 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
\r
2671 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
\r
2673 LocationLink.create = create;
\r
2675 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
\r
2677 function is(value) {
\r
2678 var candidate = value;
\r
2679 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
\r
2680 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
\r
2681 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
\r
2683 LocationLink.is = is;
\r
2684 })(LocationLink || (LocationLink = {}));
\r
2686 * The Color namespace provides helper functions to work with
\r
2687 * [Color](#Color) literals.
\r
2690 (function (Color) {
\r
2692 * Creates a new Color literal.
\r
2694 function create(red, green, blue, alpha) {
\r
2702 Color.create = create;
\r
2704 * Checks whether the given literal conforms to the [Color](#Color) interface.
\r
2706 function is(value) {
\r
2707 var candidate = value;
\r
2708 return Is.number(candidate.red)
\r
2709 && Is.number(candidate.green)
\r
2710 && Is.number(candidate.blue)
\r
2711 && Is.number(candidate.alpha);
\r
2714 })(Color || (Color = {}));
\r
2716 * The ColorInformation namespace provides helper functions to work with
\r
2717 * [ColorInformation](#ColorInformation) literals.
\r
2719 var ColorInformation;
\r
2720 (function (ColorInformation) {
\r
2722 * Creates a new ColorInformation literal.
\r
2724 function create(range, color) {
\r
2730 ColorInformation.create = create;
\r
2732 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
2734 function is(value) {
\r
2735 var candidate = value;
\r
2736 return Range.is(candidate.range) && Color.is(candidate.color);
\r
2738 ColorInformation.is = is;
\r
2739 })(ColorInformation || (ColorInformation = {}));
\r
2741 * The Color namespace provides helper functions to work with
\r
2742 * [ColorPresentation](#ColorPresentation) literals.
\r
2744 var ColorPresentation;
\r
2745 (function (ColorPresentation) {
\r
2747 * Creates a new ColorInformation literal.
\r
2749 function create(label, textEdit, additionalTextEdits) {
\r
2752 textEdit: textEdit,
\r
2753 additionalTextEdits: additionalTextEdits,
\r
2756 ColorPresentation.create = create;
\r
2758 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
2760 function is(value) {
\r
2761 var candidate = value;
\r
2762 return Is.string(candidate.label)
\r
2763 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
\r
2764 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
\r
2766 ColorPresentation.is = is;
\r
2767 })(ColorPresentation || (ColorPresentation = {}));
\r
2769 * Enum of known range kinds
\r
2771 var FoldingRangeKind;
\r
2772 (function (FoldingRangeKind) {
\r
2774 * Folding range for a comment
\r
2776 FoldingRangeKind["Comment"] = "comment";
\r
2778 * Folding range for a imports or includes
\r
2780 FoldingRangeKind["Imports"] = "imports";
\r
2782 * Folding range for a region (e.g. `#region`)
\r
2784 FoldingRangeKind["Region"] = "region";
\r
2785 })(FoldingRangeKind || (FoldingRangeKind = {}));
\r
2787 * The folding range namespace provides helper functions to work with
\r
2788 * [FoldingRange](#FoldingRange) literals.
\r
2791 (function (FoldingRange) {
\r
2793 * Creates a new FoldingRange literal.
\r
2795 function create(startLine, endLine, startCharacter, endCharacter, kind) {
\r
2797 startLine: startLine,
\r
2800 if (Is.defined(startCharacter)) {
\r
2801 result.startCharacter = startCharacter;
\r
2803 if (Is.defined(endCharacter)) {
\r
2804 result.endCharacter = endCharacter;
\r
2806 if (Is.defined(kind)) {
\r
2807 result.kind = kind;
\r
2811 FoldingRange.create = create;
\r
2813 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
\r
2815 function is(value) {
\r
2816 var candidate = value;
\r
2817 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
\r
2818 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
\r
2819 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
\r
2820 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
\r
2822 FoldingRange.is = is;
\r
2823 })(FoldingRange || (FoldingRange = {}));
\r
2825 * The DiagnosticRelatedInformation namespace provides helper functions to work with
\r
2826 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
\r
2828 var DiagnosticRelatedInformation;
\r
2829 (function (DiagnosticRelatedInformation) {
\r
2831 * Creates a new DiagnosticRelatedInformation literal.
\r
2833 function create(location, message) {
\r
2835 location: location,
\r
2839 DiagnosticRelatedInformation.create = create;
\r
2841 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
\r
2843 function is(value) {
\r
2844 var candidate = value;
\r
2845 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
\r
2847 DiagnosticRelatedInformation.is = is;
\r
2848 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
\r
2850 * The diagnostic's severity.
\r
2852 var DiagnosticSeverity;
\r
2853 (function (DiagnosticSeverity) {
\r
2855 * Reports an error.
\r
2857 DiagnosticSeverity.Error = 1;
\r
2859 * Reports a warning.
\r
2861 DiagnosticSeverity.Warning = 2;
\r
2863 * Reports an information.
\r
2865 DiagnosticSeverity.Information = 3;
\r
2869 DiagnosticSeverity.Hint = 4;
\r
2870 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
\r
2872 * The diagnostic tags.
\r
2876 var DiagnosticTag;
\r
2877 (function (DiagnosticTag) {
\r
2879 * Unused or unnecessary code.
\r
2881 * Clients are allowed to render diagnostics with this tag faded out instead of having
\r
2882 * an error squiggle.
\r
2884 DiagnosticTag.Unnecessary = 1;
\r
2886 * Deprecated or obsolete code.
\r
2888 * Clients are allowed to rendered diagnostics with this tag strike through.
\r
2890 DiagnosticTag.Deprecated = 2;
\r
2891 })(DiagnosticTag || (DiagnosticTag = {}));
\r
2893 * The Diagnostic namespace provides helper functions to work with
\r
2894 * [Diagnostic](#Diagnostic) literals.
\r
2897 (function (Diagnostic) {
\r
2899 * Creates a new Diagnostic literal.
\r
2901 function create(range, message, severity, code, source, relatedInformation) {
\r
2902 var result = { range: range, message: message };
\r
2903 if (Is.defined(severity)) {
\r
2904 result.severity = severity;
\r
2906 if (Is.defined(code)) {
\r
2907 result.code = code;
\r
2909 if (Is.defined(source)) {
\r
2910 result.source = source;
\r
2912 if (Is.defined(relatedInformation)) {
\r
2913 result.relatedInformation = relatedInformation;
\r
2917 Diagnostic.create = create;
\r
2919 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
\r
2921 function is(value) {
\r
2922 var candidate = value;
\r
2923 return Is.defined(candidate)
\r
2924 && Range.is(candidate.range)
\r
2925 && Is.string(candidate.message)
\r
2926 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
\r
2927 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
\r
2928 && (Is.string(candidate.source) || Is.undefined(candidate.source))
\r
2929 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
\r
2931 Diagnostic.is = is;
\r
2932 })(Diagnostic || (Diagnostic = {}));
\r
2934 * The Command namespace provides helper functions to work with
\r
2935 * [Command](#Command) literals.
\r
2938 (function (Command) {
\r
2940 * Creates a new Command literal.
\r
2942 function create(title, command) {
\r
2944 for (var _i = 2; _i < arguments.length; _i++) {
\r
2945 args[_i - 2] = arguments[_i];
\r
2947 var result = { title: title, command: command };
\r
2948 if (Is.defined(args) && args.length > 0) {
\r
2949 result.arguments = args;
\r
2953 Command.create = create;
\r
2955 * Checks whether the given literal conforms to the [Command](#Command) interface.
\r
2957 function is(value) {
\r
2958 var candidate = value;
\r
2959 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
\r
2962 })(Command || (Command = {}));
\r
2964 * The TextEdit namespace provides helper function to create replace,
\r
2965 * insert and delete edits more easily.
\r
2968 (function (TextEdit) {
\r
2970 * Creates a replace text edit.
\r
2971 * @param range The range of text to be replaced.
\r
2972 * @param newText The new text.
\r
2974 function replace(range, newText) {
\r
2975 return { range: range, newText: newText };
\r
2977 TextEdit.replace = replace;
\r
2979 * Creates a insert text edit.
\r
2980 * @param position The position to insert the text at.
\r
2981 * @param newText The text to be inserted.
\r
2983 function insert(position, newText) {
\r
2984 return { range: { start: position, end: position }, newText: newText };
\r
2986 TextEdit.insert = insert;
\r
2988 * Creates a delete text edit.
\r
2989 * @param range The range of text to be deleted.
\r
2991 function del(range) {
\r
2992 return { range: range, newText: '' };
\r
2994 TextEdit.del = del;
\r
2995 function is(value) {
\r
2996 var candidate = value;
\r
2997 return Is.objectLiteral(candidate)
\r
2998 && Is.string(candidate.newText)
\r
2999 && Range.is(candidate.range);
\r
3002 })(TextEdit || (TextEdit = {}));
\r
3004 * The TextDocumentEdit namespace provides helper function to create
\r
3005 * an edit that manipulates a text document.
\r
3007 var TextDocumentEdit;
\r
3008 (function (TextDocumentEdit) {
\r
3010 * Creates a new `TextDocumentEdit`
\r
3012 function create(textDocument, edits) {
\r
3013 return { textDocument: textDocument, edits: edits };
\r
3015 TextDocumentEdit.create = create;
\r
3016 function is(value) {
\r
3017 var candidate = value;
\r
3018 return Is.defined(candidate)
\r
3019 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
\r
3020 && Array.isArray(candidate.edits);
\r
3022 TextDocumentEdit.is = is;
\r
3023 })(TextDocumentEdit || (TextDocumentEdit = {}));
\r
3025 (function (CreateFile) {
\r
3026 function create(uri, options) {
\r
3031 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3032 result.options = options;
\r
3036 CreateFile.create = create;
\r
3037 function is(value) {
\r
3038 var candidate = value;
\r
3039 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
\r
3040 (candidate.options === void 0 ||
\r
3041 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3043 CreateFile.is = is;
\r
3044 })(CreateFile || (CreateFile = {}));
\r
3046 (function (RenameFile) {
\r
3047 function create(oldUri, newUri, options) {
\r
3053 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
3054 result.options = options;
\r
3058 RenameFile.create = create;
\r
3059 function is(value) {
\r
3060 var candidate = value;
\r
3061 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
\r
3062 (candidate.options === void 0 ||
\r
3063 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
3065 RenameFile.is = is;
\r
3066 })(RenameFile || (RenameFile = {}));
\r
3068 (function (DeleteFile) {
\r
3069 function create(uri, options) {
\r
3074 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
\r
3075 result.options = options;
\r
3079 DeleteFile.create = create;
\r
3080 function is(value) {
\r
3081 var candidate = value;
\r
3082 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
\r
3083 (candidate.options === void 0 ||
\r
3084 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
\r
3086 DeleteFile.is = is;
\r
3087 })(DeleteFile || (DeleteFile = {}));
\r
3088 var WorkspaceEdit;
\r
3089 (function (WorkspaceEdit) {
\r
3090 function is(value) {
\r
3091 var candidate = value;
\r
3092 return candidate &&
\r
3093 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
\r
3094 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
\r
3095 if (Is.string(change.kind)) {
\r
3096 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
\r
3099 return TextDocumentEdit.is(change);
\r
3103 WorkspaceEdit.is = is;
\r
3104 })(WorkspaceEdit || (WorkspaceEdit = {}));
\r
3105 var TextEditChangeImpl = /** @class */ (function () {
\r
3106 function TextEditChangeImpl(edits) {
\r
3107 this.edits = edits;
\r
3109 TextEditChangeImpl.prototype.insert = function (position, newText) {
\r
3110 this.edits.push(TextEdit.insert(position, newText));
\r
3112 TextEditChangeImpl.prototype.replace = function (range, newText) {
\r
3113 this.edits.push(TextEdit.replace(range, newText));
\r
3115 TextEditChangeImpl.prototype.delete = function (range) {
\r
3116 this.edits.push(TextEdit.del(range));
\r
3118 TextEditChangeImpl.prototype.add = function (edit) {
\r
3119 this.edits.push(edit);
\r
3121 TextEditChangeImpl.prototype.all = function () {
\r
3122 return this.edits;
\r
3124 TextEditChangeImpl.prototype.clear = function () {
\r
3125 this.edits.splice(0, this.edits.length);
\r
3127 return TextEditChangeImpl;
\r
3130 * A workspace change helps constructing changes to a workspace.
\r
3132 var WorkspaceChange = /** @class */ (function () {
\r
3133 function WorkspaceChange(workspaceEdit) {
\r
3135 this._textEditChanges = Object.create(null);
\r
3136 if (workspaceEdit) {
\r
3137 this._workspaceEdit = workspaceEdit;
\r
3138 if (workspaceEdit.documentChanges) {
\r
3139 workspaceEdit.documentChanges.forEach(function (change) {
\r
3140 if (TextDocumentEdit.is(change)) {
\r
3141 var textEditChange = new TextEditChangeImpl(change.edits);
\r
3142 _this._textEditChanges[change.textDocument.uri] = textEditChange;
\r
3146 else if (workspaceEdit.changes) {
\r
3147 Object.keys(workspaceEdit.changes).forEach(function (key) {
\r
3148 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
\r
3149 _this._textEditChanges[key] = textEditChange;
\r
3154 Object.defineProperty(WorkspaceChange.prototype, "edit", {
\r
3156 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
\r
3157 * use to be returned from a workspace edit operation like rename.
\r
3159 get: function () {
\r
3160 return this._workspaceEdit;
\r
3163 configurable: true
\r
3165 WorkspaceChange.prototype.getTextEditChange = function (key) {
\r
3166 if (VersionedTextDocumentIdentifier.is(key)) {
\r
3167 if (!this._workspaceEdit) {
\r
3168 this._workspaceEdit = {
\r
3169 documentChanges: []
\r
3172 if (!this._workspaceEdit.documentChanges) {
\r
3173 throw new Error('Workspace edit is not configured for document changes.');
\r
3175 var textDocument = key;
\r
3176 var result = this._textEditChanges[textDocument.uri];
\r
3179 var textDocumentEdit = {
\r
3180 textDocument: textDocument,
\r
3183 this._workspaceEdit.documentChanges.push(textDocumentEdit);
\r
3184 result = new TextEditChangeImpl(edits);
\r
3185 this._textEditChanges[textDocument.uri] = result;
\r
3190 if (!this._workspaceEdit) {
\r
3191 this._workspaceEdit = {
\r
3192 changes: Object.create(null)
\r
3195 if (!this._workspaceEdit.changes) {
\r
3196 throw new Error('Workspace edit is not configured for normal text edit changes.');
\r
3198 var result = this._textEditChanges[key];
\r
3201 this._workspaceEdit.changes[key] = edits;
\r
3202 result = new TextEditChangeImpl(edits);
\r
3203 this._textEditChanges[key] = result;
\r
3208 WorkspaceChange.prototype.createFile = function (uri, options) {
\r
3209 this.checkDocumentChanges();
\r
3210 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
\r
3212 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
\r
3213 this.checkDocumentChanges();
\r
3214 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
\r
3216 WorkspaceChange.prototype.deleteFile = function (uri, options) {
\r
3217 this.checkDocumentChanges();
\r
3218 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
\r
3220 WorkspaceChange.prototype.checkDocumentChanges = function () {
\r
3221 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
\r
3222 throw new Error('Workspace edit is not configured for document changes.');
\r
3225 return WorkspaceChange;
\r
3229 * The TextDocumentIdentifier namespace provides helper functions to work with
\r
3230 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
\r
3232 var TextDocumentIdentifier;
\r
3233 (function (TextDocumentIdentifier) {
\r
3235 * Creates a new TextDocumentIdentifier literal.
\r
3236 * @param uri The document's uri.
\r
3238 function create(uri) {
\r
3239 return { uri: uri };
\r
3241 TextDocumentIdentifier.create = create;
\r
3243 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
\r
3245 function is(value) {
\r
3246 var candidate = value;
\r
3247 return Is.defined(candidate) && Is.string(candidate.uri);
\r
3249 TextDocumentIdentifier.is = is;
\r
3250 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
\r
3252 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
\r
3253 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
\r
3255 var VersionedTextDocumentIdentifier;
\r
3256 (function (VersionedTextDocumentIdentifier) {
\r
3258 * Creates a new VersionedTextDocumentIdentifier literal.
\r
3259 * @param uri The document's uri.
\r
3260 * @param uri The document's text.
\r
3262 function create(uri, version) {
\r
3263 return { uri: uri, version: version };
\r
3265 VersionedTextDocumentIdentifier.create = create;
\r
3267 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
\r
3269 function is(value) {
\r
3270 var candidate = value;
\r
3271 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
\r
3273 VersionedTextDocumentIdentifier.is = is;
\r
3274 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
\r
3276 * The TextDocumentItem namespace provides helper functions to work with
\r
3277 * [TextDocumentItem](#TextDocumentItem) literals.
\r
3279 var TextDocumentItem;
\r
3280 (function (TextDocumentItem) {
\r
3282 * Creates a new TextDocumentItem literal.
\r
3283 * @param uri The document's uri.
\r
3284 * @param languageId The document's language identifier.
\r
3285 * @param version The document's version number.
\r
3286 * @param text The document's text.
\r
3288 function create(uri, languageId, version, text) {
\r
3289 return { uri: uri, languageId: languageId, version: version, text: text };
\r
3291 TextDocumentItem.create = create;
\r
3293 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
\r
3295 function is(value) {
\r
3296 var candidate = value;
\r
3297 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
\r
3299 TextDocumentItem.is = is;
\r
3300 })(TextDocumentItem || (TextDocumentItem = {}));
\r
3302 * Describes the content type that a client supports in various
\r
3303 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
\r
3305 * Please note that `MarkupKinds` must not start with a `$`. This kinds
\r
3306 * are reserved for internal usage.
\r
3309 (function (MarkupKind) {
\r
3311 * Plain text is supported as a content format
\r
3313 MarkupKind.PlainText = 'plaintext';
\r
3315 * Markdown is supported as a content format
\r
3317 MarkupKind.Markdown = 'markdown';
\r
3318 })(MarkupKind || (MarkupKind = {}));
\r
3319 (function (MarkupKind) {
\r
3321 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
\r
3323 function is(value) {
\r
3324 var candidate = value;
\r
3325 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
\r
3327 MarkupKind.is = is;
\r
3328 })(MarkupKind || (MarkupKind = {}));
\r
3329 var MarkupContent;
\r
3330 (function (MarkupContent) {
\r
3332 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
\r
3334 function is(value) {
\r
3335 var candidate = value;
\r
3336 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
\r
3338 MarkupContent.is = is;
\r
3339 })(MarkupContent || (MarkupContent = {}));
\r
3341 * The kind of a completion entry.
\r
3343 var CompletionItemKind;
\r
3344 (function (CompletionItemKind) {
\r
3345 CompletionItemKind.Text = 1;
\r
3346 CompletionItemKind.Method = 2;
\r
3347 CompletionItemKind.Function = 3;
\r
3348 CompletionItemKind.Constructor = 4;
\r
3349 CompletionItemKind.Field = 5;
\r
3350 CompletionItemKind.Variable = 6;
\r
3351 CompletionItemKind.Class = 7;
\r
3352 CompletionItemKind.Interface = 8;
\r
3353 CompletionItemKind.Module = 9;
\r
3354 CompletionItemKind.Property = 10;
\r
3355 CompletionItemKind.Unit = 11;
\r
3356 CompletionItemKind.Value = 12;
\r
3357 CompletionItemKind.Enum = 13;
\r
3358 CompletionItemKind.Keyword = 14;
\r
3359 CompletionItemKind.Snippet = 15;
\r
3360 CompletionItemKind.Color = 16;
\r
3361 CompletionItemKind.File = 17;
\r
3362 CompletionItemKind.Reference = 18;
\r
3363 CompletionItemKind.Folder = 19;
\r
3364 CompletionItemKind.EnumMember = 20;
\r
3365 CompletionItemKind.Constant = 21;
\r
3366 CompletionItemKind.Struct = 22;
\r
3367 CompletionItemKind.Event = 23;
\r
3368 CompletionItemKind.Operator = 24;
\r
3369 CompletionItemKind.TypeParameter = 25;
\r
3370 })(CompletionItemKind || (CompletionItemKind = {}));
\r
3372 * Defines whether the insert text in a completion item should be interpreted as
\r
3373 * plain text or a snippet.
\r
3375 var InsertTextFormat;
\r
3376 (function (InsertTextFormat) {
\r
3378 * The primary text to be inserted is treated as a plain string.
\r
3380 InsertTextFormat.PlainText = 1;
\r
3382 * The primary text to be inserted is treated as a snippet.
\r
3384 * A snippet can define tab stops and placeholders with `$1`, `$2`
\r
3385 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
\r
3386 * the end of the snippet. Placeholders with equal identifiers are linked,
\r
3387 * that is typing in one will update others too.
\r
3389 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
\r
3391 InsertTextFormat.Snippet = 2;
\r
3392 })(InsertTextFormat || (InsertTextFormat = {}));
\r
3394 * Completion item tags are extra annotations that tweak the rendering of a completion
\r
3399 var CompletionItemTag;
\r
3400 (function (CompletionItemTag) {
\r
3402 * Render a completion as obsolete, usually using a strike-out.
\r
3404 CompletionItemTag.Deprecated = 1;
\r
3405 })(CompletionItemTag || (CompletionItemTag = {}));
\r
3407 * The CompletionItem namespace provides functions to deal with
\r
3408 * completion items.
\r
3410 var CompletionItem;
\r
3411 (function (CompletionItem) {
\r
3413 * Create a completion item and seed it with a label.
\r
3414 * @param label The completion item's label
\r
3416 function create(label) {
\r
3417 return { label: label };
\r
3419 CompletionItem.create = create;
\r
3420 })(CompletionItem || (CompletionItem = {}));
\r
3422 * The CompletionList namespace provides functions to deal with
\r
3423 * completion lists.
\r
3425 var CompletionList;
\r
3426 (function (CompletionList) {
\r
3428 * Creates a new completion list.
\r
3430 * @param items The completion items.
\r
3431 * @param isIncomplete The list is not complete.
\r
3433 function create(items, isIncomplete) {
\r
3434 return { items: items ? items : [], isIncomplete: !!isIncomplete };
\r
3436 CompletionList.create = create;
\r
3437 })(CompletionList || (CompletionList = {}));
\r
3439 (function (MarkedString) {
\r
3441 * Creates a marked string from plain text.
\r
3443 * @param plainText The plain text.
\r
3445 function fromPlainText(plainText) {
\r
3446 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
\r
3448 MarkedString.fromPlainText = fromPlainText;
\r
3450 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
\r
3452 function is(value) {
\r
3453 var candidate = value;
\r
3454 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
\r
3456 MarkedString.is = is;
\r
3457 })(MarkedString || (MarkedString = {}));
\r
3459 (function (Hover) {
\r
3461 * Checks whether the given value conforms to the [Hover](#Hover) interface.
\r
3463 function is(value) {
\r
3464 var candidate = value;
\r
3465 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
\r
3466 MarkedString.is(candidate.contents) ||
\r
3467 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
\r
3470 })(Hover || (Hover = {}));
\r
3472 * The ParameterInformation namespace provides helper functions to work with
\r
3473 * [ParameterInformation](#ParameterInformation) literals.
\r
3475 var ParameterInformation;
\r
3476 (function (ParameterInformation) {
\r
3478 * Creates a new parameter information literal.
\r
3480 * @param label A label string.
\r
3481 * @param documentation A doc string.
\r
3483 function create(label, documentation) {
\r
3484 return documentation ? { label: label, documentation: documentation } : { label: label };
\r
3486 ParameterInformation.create = create;
\r
3487 })(ParameterInformation || (ParameterInformation = {}));
\r
3489 * The SignatureInformation namespace provides helper functions to work with
\r
3490 * [SignatureInformation](#SignatureInformation) literals.
\r
3492 var SignatureInformation;
\r
3493 (function (SignatureInformation) {
\r
3494 function create(label, documentation) {
\r
3495 var parameters = [];
\r
3496 for (var _i = 2; _i < arguments.length; _i++) {
\r
3497 parameters[_i - 2] = arguments[_i];
\r
3499 var result = { label: label };
\r
3500 if (Is.defined(documentation)) {
\r
3501 result.documentation = documentation;
\r
3503 if (Is.defined(parameters)) {
\r
3504 result.parameters = parameters;
\r
3507 result.parameters = [];
\r
3511 SignatureInformation.create = create;
\r
3512 })(SignatureInformation || (SignatureInformation = {}));
\r
3514 * A document highlight kind.
\r
3516 var DocumentHighlightKind;
\r
3517 (function (DocumentHighlightKind) {
\r
3519 * A textual occurrence.
\r
3521 DocumentHighlightKind.Text = 1;
\r
3523 * Read-access of a symbol, like reading a variable.
\r
3525 DocumentHighlightKind.Read = 2;
\r
3527 * Write-access of a symbol, like writing to a variable.
\r
3529 DocumentHighlightKind.Write = 3;
\r
3530 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
\r
3532 * DocumentHighlight namespace to provide helper functions to work with
\r
3533 * [DocumentHighlight](#DocumentHighlight) literals.
\r
3535 var DocumentHighlight;
\r
3536 (function (DocumentHighlight) {
\r
3538 * Create a DocumentHighlight object.
\r
3539 * @param range The range the highlight applies to.
\r
3541 function create(range, kind) {
\r
3542 var result = { range: range };
\r
3543 if (Is.number(kind)) {
\r
3544 result.kind = kind;
\r
3548 DocumentHighlight.create = create;
\r
3549 })(DocumentHighlight || (DocumentHighlight = {}));
\r
3554 (function (SymbolKind) {
\r
3555 SymbolKind.File = 1;
\r
3556 SymbolKind.Module = 2;
\r
3557 SymbolKind.Namespace = 3;
\r
3558 SymbolKind.Package = 4;
\r
3559 SymbolKind.Class = 5;
\r
3560 SymbolKind.Method = 6;
\r
3561 SymbolKind.Property = 7;
\r
3562 SymbolKind.Field = 8;
\r
3563 SymbolKind.Constructor = 9;
\r
3564 SymbolKind.Enum = 10;
\r
3565 SymbolKind.Interface = 11;
\r
3566 SymbolKind.Function = 12;
\r
3567 SymbolKind.Variable = 13;
\r
3568 SymbolKind.Constant = 14;
\r
3569 SymbolKind.String = 15;
\r
3570 SymbolKind.Number = 16;
\r
3571 SymbolKind.Boolean = 17;
\r
3572 SymbolKind.Array = 18;
\r
3573 SymbolKind.Object = 19;
\r
3574 SymbolKind.Key = 20;
\r
3575 SymbolKind.Null = 21;
\r
3576 SymbolKind.EnumMember = 22;
\r
3577 SymbolKind.Struct = 23;
\r
3578 SymbolKind.Event = 24;
\r
3579 SymbolKind.Operator = 25;
\r
3580 SymbolKind.TypeParameter = 26;
\r
3581 })(SymbolKind || (SymbolKind = {}));
\r
3583 * Symbol tags are extra annotations that tweak the rendering of a symbol.
\r
3587 (function (SymbolTag) {
\r
3589 * Render a symbol as obsolete, usually using a strike-out.
\r
3591 SymbolTag.Deprecated = 1;
\r
3592 })(SymbolTag || (SymbolTag = {}));
\r
3593 var SymbolInformation;
\r
3594 (function (SymbolInformation) {
\r
3596 * Creates a new symbol information literal.
\r
3598 * @param name The name of the symbol.
\r
3599 * @param kind The kind of the symbol.
\r
3600 * @param range The range of the location of the symbol.
\r
3601 * @param uri The resource of the location of symbol, defaults to the current document.
\r
3602 * @param containerName The name of the symbol containing the symbol.
\r
3604 function create(name, kind, range, uri, containerName) {
\r
3608 location: { uri: uri, range: range }
\r
3610 if (containerName) {
\r
3611 result.containerName = containerName;
\r
3615 SymbolInformation.create = create;
\r
3616 })(SymbolInformation || (SymbolInformation = {}));
\r
3617 var DocumentSymbol;
\r
3618 (function (DocumentSymbol) {
\r
3620 * Creates a new symbol information literal.
\r
3622 * @param name The name of the symbol.
\r
3623 * @param detail The detail of the symbol.
\r
3624 * @param kind The kind of the symbol.
\r
3625 * @param range The range of the symbol.
\r
3626 * @param selectionRange The selectionRange of the symbol.
\r
3627 * @param children Children of the symbol.
\r
3629 function create(name, detail, kind, range, selectionRange, children) {
\r
3635 selectionRange: selectionRange
\r
3637 if (children !== void 0) {
\r
3638 result.children = children;
\r
3642 DocumentSymbol.create = create;
\r
3644 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
\r
3646 function is(value) {
\r
3647 var candidate = value;
\r
3648 return candidate &&
\r
3649 Is.string(candidate.name) && Is.number(candidate.kind) &&
\r
3650 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
\r
3651 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
\r
3652 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
\r
3653 (candidate.children === void 0 || Array.isArray(candidate.children));
\r
3655 DocumentSymbol.is = is;
\r
3656 })(DocumentSymbol || (DocumentSymbol = {}));
\r
3658 * A set of predefined code action kinds
\r
3660 var CodeActionKind;
\r
3661 (function (CodeActionKind) {
\r
3665 CodeActionKind.Empty = '';
\r
3667 * Base kind for quickfix actions: 'quickfix'
\r
3669 CodeActionKind.QuickFix = 'quickfix';
\r
3671 * Base kind for refactoring actions: 'refactor'
\r
3673 CodeActionKind.Refactor = 'refactor';
\r
3675 * Base kind for refactoring extraction actions: 'refactor.extract'
\r
3677 * Example extract actions:
\r
3679 * - Extract method
\r
3680 * - Extract function
\r
3681 * - Extract variable
\r
3682 * - Extract interface from class
\r
3685 CodeActionKind.RefactorExtract = 'refactor.extract';
\r
3687 * Base kind for refactoring inline actions: 'refactor.inline'
\r
3689 * Example inline actions:
\r
3691 * - Inline function
\r
3692 * - Inline variable
\r
3693 * - Inline constant
\r
3696 CodeActionKind.RefactorInline = 'refactor.inline';
\r
3698 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
\r
3700 * Example rewrite actions:
\r
3702 * - Convert JavaScript function to class
\r
3703 * - Add or remove parameter
\r
3704 * - Encapsulate field
\r
3705 * - Make method static
\r
3706 * - Move method to base class
\r
3709 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
\r
3711 * Base kind for source actions: `source`
\r
3713 * Source code actions apply to the entire file.
\r
3715 CodeActionKind.Source = 'source';
\r
3717 * Base kind for an organize imports source action: `source.organizeImports`
\r
3719 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
\r
3721 * Base kind for auto-fix source actions: `source.fixAll`.
\r
3723 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
\r
3724 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
\r
3728 CodeActionKind.SourceFixAll = 'source.fixAll';
\r
3729 })(CodeActionKind || (CodeActionKind = {}));
\r
3731 * The CodeActionContext namespace provides helper functions to work with
\r
3732 * [CodeActionContext](#CodeActionContext) literals.
\r
3734 var CodeActionContext;
\r
3735 (function (CodeActionContext) {
\r
3737 * Creates a new CodeActionContext literal.
\r
3739 function create(diagnostics, only) {
\r
3740 var result = { diagnostics: diagnostics };
\r
3741 if (only !== void 0 && only !== null) {
\r
3742 result.only = only;
\r
3746 CodeActionContext.create = create;
\r
3748 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
\r
3750 function is(value) {
\r
3751 var candidate = value;
\r
3752 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
\r
3754 CodeActionContext.is = is;
\r
3755 })(CodeActionContext || (CodeActionContext = {}));
\r
3757 (function (CodeAction) {
\r
3758 function create(title, commandOrEdit, kind) {
\r
3759 var result = { title: title };
\r
3760 if (Command.is(commandOrEdit)) {
\r
3761 result.command = commandOrEdit;
\r
3764 result.edit = commandOrEdit;
\r
3766 if (kind !== void 0) {
\r
3767 result.kind = kind;
\r
3771 CodeAction.create = create;
\r
3772 function is(value) {
\r
3773 var candidate = value;
\r
3774 return candidate && Is.string(candidate.title) &&
\r
3775 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
\r
3776 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
\r
3777 (candidate.edit !== void 0 || candidate.command !== void 0) &&
\r
3778 (candidate.command === void 0 || Command.is(candidate.command)) &&
\r
3779 (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) &&
\r
3780 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
\r
3782 CodeAction.is = is;
\r
3783 })(CodeAction || (CodeAction = {}));
\r
3785 * The CodeLens namespace provides helper functions to work with
\r
3786 * [CodeLens](#CodeLens) literals.
\r
3789 (function (CodeLens) {
\r
3791 * Creates a new CodeLens literal.
\r
3793 function create(range, data) {
\r
3794 var result = { range: range };
\r
3795 if (Is.defined(data)) {
\r
3796 result.data = data;
\r
3800 CodeLens.create = create;
\r
3802 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
\r
3804 function is(value) {
\r
3805 var candidate = value;
\r
3806 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
\r
3809 })(CodeLens || (CodeLens = {}));
\r
3811 * The FormattingOptions namespace provides helper functions to work with
\r
3812 * [FormattingOptions](#FormattingOptions) literals.
\r
3814 var FormattingOptions;
\r
3815 (function (FormattingOptions) {
\r
3817 * Creates a new FormattingOptions literal.
\r
3819 function create(tabSize, insertSpaces) {
\r
3820 return { tabSize: tabSize, insertSpaces: insertSpaces };
\r
3822 FormattingOptions.create = create;
\r
3824 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
\r
3826 function is(value) {
\r
3827 var candidate = value;
\r
3828 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
\r
3830 FormattingOptions.is = is;
\r
3831 })(FormattingOptions || (FormattingOptions = {}));
\r
3833 * The DocumentLink namespace provides helper functions to work with
\r
3834 * [DocumentLink](#DocumentLink) literals.
\r
3837 (function (DocumentLink) {
\r
3839 * Creates a new DocumentLink literal.
\r
3841 function create(range, target, data) {
\r
3842 return { range: range, target: target, data: data };
\r
3844 DocumentLink.create = create;
\r
3846 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
\r
3848 function is(value) {
\r
3849 var candidate = value;
\r
3850 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
\r
3852 DocumentLink.is = is;
\r
3853 })(DocumentLink || (DocumentLink = {}));
\r
3855 * The SelectionRange namespace provides helper function to work with
\r
3856 * SelectionRange literals.
\r
3858 var SelectionRange;
\r
3859 (function (SelectionRange) {
\r
3861 * Creates a new SelectionRange
\r
3862 * @param range the range.
\r
3863 * @param parent an optional parent.
\r
3865 function create(range, parent) {
\r
3866 return { range: range, parent: parent };
\r
3868 SelectionRange.create = create;
\r
3869 function is(value) {
\r
3870 var candidate = value;
\r
3871 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
\r
3873 SelectionRange.is = is;
\r
3874 })(SelectionRange || (SelectionRange = {}));
\r
3875 var EOL = ['\n', '\r\n', '\r'];
\r
3877 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
\r
3880 (function (TextDocument) {
\r
3882 * Creates a new ITextDocument literal from the given uri and content.
\r
3883 * @param uri The document's uri.
\r
3884 * @param languageId The document's language Id.
\r
3885 * @param content The document's content.
\r
3887 function create(uri, languageId, version, content) {
\r
3888 return new FullTextDocument(uri, languageId, version, content);
\r
3890 TextDocument.create = create;
\r
3892 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
\r
3894 function is(value) {
\r
3895 var candidate = value;
\r
3896 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
\r
3897 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
\r
3899 TextDocument.is = is;
\r
3900 function applyEdits(document, edits) {
\r
3901 var text = document.getText();
\r
3902 var sortedEdits = mergeSort(edits, function (a, b) {
\r
3903 var diff = a.range.start.line - b.range.start.line;
\r
3905 return a.range.start.character - b.range.start.character;
\r
3909 var lastModifiedOffset = text.length;
\r
3910 for (var i = sortedEdits.length - 1; i >= 0; i--) {
\r
3911 var e = sortedEdits[i];
\r
3912 var startOffset = document.offsetAt(e.range.start);
\r
3913 var endOffset = document.offsetAt(e.range.end);
\r
3914 if (endOffset <= lastModifiedOffset) {
\r
3915 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
\r
3918 throw new Error('Overlapping edit');
\r
3920 lastModifiedOffset = startOffset;
\r
3924 TextDocument.applyEdits = applyEdits;
\r
3925 function mergeSort(data, compare) {
\r
3926 if (data.length <= 1) {
\r
3930 var p = (data.length / 2) | 0;
\r
3931 var left = data.slice(0, p);
\r
3932 var right = data.slice(p);
\r
3933 mergeSort(left, compare);
\r
3934 mergeSort(right, compare);
\r
3938 while (leftIdx < left.length && rightIdx < right.length) {
\r
3939 var ret = compare(left[leftIdx], right[rightIdx]);
\r
3941 // smaller_equal -> take left to preserve order
\r
3942 data[i++] = left[leftIdx++];
\r
3945 // greater -> take right
\r
3946 data[i++] = right[rightIdx++];
\r
3949 while (leftIdx < left.length) {
\r
3950 data[i++] = left[leftIdx++];
\r
3952 while (rightIdx < right.length) {
\r
3953 data[i++] = right[rightIdx++];
\r
3957 })(TextDocument || (TextDocument = {}));
\r
3958 var FullTextDocument = /** @class */ (function () {
\r
3959 function FullTextDocument(uri, languageId, version, content) {
\r
3961 this._languageId = languageId;
\r
3962 this._version = version;
\r
3963 this._content = content;
\r
3964 this._lineOffsets = undefined;
\r
3966 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
3967 get: function () {
\r
3971 configurable: true
\r
3973 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
3974 get: function () {
\r
3975 return this._languageId;
\r
3978 configurable: true
\r
3980 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
3981 get: function () {
\r
3982 return this._version;
\r
3985 configurable: true
\r
3987 FullTextDocument.prototype.getText = function (range) {
\r
3989 var start = this.offsetAt(range.start);
\r
3990 var end = this.offsetAt(range.end);
\r
3991 return this._content.substring(start, end);
\r
3993 return this._content;
\r
3995 FullTextDocument.prototype.update = function (event, version) {
\r
3996 this._content = event.text;
\r
3997 this._version = version;
\r
3998 this._lineOffsets = undefined;
\r
4000 FullTextDocument.prototype.getLineOffsets = function () {
\r
4001 if (this._lineOffsets === undefined) {
\r
4002 var lineOffsets = [];
\r
4003 var text = this._content;
\r
4004 var isLineStart = true;
\r
4005 for (var i = 0; i < text.length; i++) {
\r
4006 if (isLineStart) {
\r
4007 lineOffsets.push(i);
\r
4008 isLineStart = false;
\r
4010 var ch = text.charAt(i);
\r
4011 isLineStart = (ch === '\r' || ch === '\n');
\r
4012 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
\r
4016 if (isLineStart && text.length > 0) {
\r
4017 lineOffsets.push(text.length);
\r
4019 this._lineOffsets = lineOffsets;
\r
4021 return this._lineOffsets;
\r
4023 FullTextDocument.prototype.positionAt = function (offset) {
\r
4024 offset = Math.max(Math.min(offset, this._content.length), 0);
\r
4025 var lineOffsets = this.getLineOffsets();
\r
4026 var low = 0, high = lineOffsets.length;
\r
4028 return Position.create(0, offset);
\r
4030 while (low < high) {
\r
4031 var mid = Math.floor((low + high) / 2);
\r
4032 if (lineOffsets[mid] > offset) {
\r
4039 // low is the least x for which the line offset is larger than the current offset
\r
4040 // or array.length if no line offset is larger than the current offset
\r
4041 var line = low - 1;
\r
4042 return Position.create(line, offset - lineOffsets[line]);
\r
4044 FullTextDocument.prototype.offsetAt = function (position) {
\r
4045 var lineOffsets = this.getLineOffsets();
\r
4046 if (position.line >= lineOffsets.length) {
\r
4047 return this._content.length;
\r
4049 else if (position.line < 0) {
\r
4052 var lineOffset = lineOffsets[position.line];
\r
4053 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
\r
4054 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
\r
4056 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
4057 get: function () {
\r
4058 return this.getLineOffsets().length;
\r
4061 configurable: true
\r
4063 return FullTextDocument;
\r
4067 var toString = Object.prototype.toString;
\r
4068 function defined(value) {
\r
4069 return typeof value !== 'undefined';
\r
4071 Is.defined = defined;
\r
4072 function undefined(value) {
\r
4073 return typeof value === 'undefined';
\r
4075 Is.undefined = undefined;
\r
4076 function boolean(value) {
\r
4077 return value === true || value === false;
\r
4079 Is.boolean = boolean;
\r
4080 function string(value) {
\r
4081 return toString.call(value) === '[object String]';
\r
4083 Is.string = string;
\r
4084 function number(value) {
\r
4085 return toString.call(value) === '[object Number]';
\r
4087 Is.number = number;
\r
4088 function func(value) {
\r
4089 return toString.call(value) === '[object Function]';
\r
4092 function objectLiteral(value) {
\r
4093 // Strictly speaking class instances pass this check as well. Since the LSP
\r
4094 // doesn't use classes we ignore this for now. If we do we need to add something
\r
4095 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
4096 return value !== null && typeof value === 'object';
\r
4098 Is.objectLiteral = objectLiteral;
\r
4099 function typedArray(value, check) {
\r
4100 return Array.isArray(value) && value.every(check);
\r
4102 Is.typedArray = typedArray;
\r
4103 })(Is || (Is = {}));
\r
4108 /***/ (function(module, exports, __webpack_require__) {
4111 /* --------------------------------------------------------------------------------------------
\r
4112 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4113 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4114 * ------------------------------------------------------------------------------------------ */
\r
4116 Object.defineProperty(exports, "__esModule", { value: true });
\r
4117 const Is = __webpack_require__(20);
\r
4118 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4119 const protocol_implementation_1 = __webpack_require__(21);
\r
4120 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
\r
4121 const protocol_typeDefinition_1 = __webpack_require__(22);
\r
4122 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
\r
4123 const protocol_workspaceFolders_1 = __webpack_require__(23);
\r
4124 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
\r
4125 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
\r
4126 const protocol_configuration_1 = __webpack_require__(24);
\r
4127 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
\r
4128 const protocol_colorProvider_1 = __webpack_require__(25);
\r
4129 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
\r
4130 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
\r
4131 const protocol_foldingRange_1 = __webpack_require__(26);
\r
4132 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
\r
4133 const protocol_declaration_1 = __webpack_require__(27);
\r
4134 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
\r
4135 const protocol_selectionRange_1 = __webpack_require__(28);
\r
4136 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
\r
4137 const protocol_progress_1 = __webpack_require__(29);
\r
4138 exports.WorkDoneProgress = protocol_progress_1.WorkDoneProgress;
\r
4139 exports.WorkDoneProgressCreateRequest = protocol_progress_1.WorkDoneProgressCreateRequest;
\r
4140 exports.WorkDoneProgressCancelNotification = protocol_progress_1.WorkDoneProgressCancelNotification;
\r
4141 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
4142 let __noDynamicImport;
\r
4144 * The DocumentFilter namespace provides helper functions to work with
\r
4145 * [DocumentFilter](#DocumentFilter) literals.
\r
4147 var DocumentFilter;
\r
4148 (function (DocumentFilter) {
\r
4149 function is(value) {
\r
4150 const candidate = value;
\r
4151 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
\r
4153 DocumentFilter.is = is;
\r
4154 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
\r
4156 * The DocumentSelector namespace provides helper functions to work with
\r
4157 * [DocumentSelector](#DocumentSelector)s.
\r
4159 var DocumentSelector;
\r
4160 (function (DocumentSelector) {
\r
4161 function is(value) {
\r
4162 if (!Array.isArray(value)) {
\r
4165 for (let elem of value) {
\r
4166 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
\r
4172 DocumentSelector.is = is;
\r
4173 })(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
\r
4175 * The `client/registerCapability` request is sent from the server to the client to register a new capability
\r
4176 * handler on the client side.
\r
4178 var RegistrationRequest;
\r
4179 (function (RegistrationRequest) {
\r
4180 RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');
\r
4181 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
\r
4183 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
\r
4184 * handler on the client side.
\r
4186 var UnregistrationRequest;
\r
4187 (function (UnregistrationRequest) {
\r
4188 UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');
\r
4189 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
\r
4190 var ResourceOperationKind;
\r
4191 (function (ResourceOperationKind) {
\r
4193 * Supports creating new files and folders.
\r
4195 ResourceOperationKind.Create = 'create';
\r
4197 * Supports renaming existing files and folders.
\r
4199 ResourceOperationKind.Rename = 'rename';
\r
4201 * Supports deleting existing files and folders.
\r
4203 ResourceOperationKind.Delete = 'delete';
\r
4204 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
\r
4205 var FailureHandlingKind;
\r
4206 (function (FailureHandlingKind) {
\r
4208 * Applying the workspace change is simply aborted if one of the changes provided
\r
4209 * fails. All operations executed before the failing operation stay executed.
\r
4211 FailureHandlingKind.Abort = 'abort';
\r
4213 * All operations are executed transactional. That means they either all
\r
4214 * succeed or no changes at all are applied to the workspace.
\r
4216 FailureHandlingKind.Transactional = 'transactional';
\r
4218 * If the workspace edit contains only textual file changes they are executed transactional.
\r
4219 * If resource changes (create, rename or delete file) are part of the change the failure
\r
4220 * handling startegy is abort.
\r
4222 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
\r
4224 * The client tries to undo the operations already executed. But there is no
\r
4225 * guaruntee that this is succeeding.
\r
4227 FailureHandlingKind.Undo = 'undo';
\r
4228 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
\r
4230 * The StaticRegistrationOptions namespace provides helper functions to work with
\r
4231 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
\r
4233 var StaticRegistrationOptions;
\r
4234 (function (StaticRegistrationOptions) {
\r
4235 function hasId(value) {
\r
4236 const candidate = value;
\r
4237 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
\r
4239 StaticRegistrationOptions.hasId = hasId;
\r
4240 })(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
\r
4242 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
\r
4243 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
\r
4245 var TextDocumentRegistrationOptions;
\r
4246 (function (TextDocumentRegistrationOptions) {
\r
4247 function is(value) {
\r
4248 const candidate = value;
\r
4249 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
\r
4251 TextDocumentRegistrationOptions.is = is;
\r
4252 })(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
\r
4254 * The WorkDoneProgressOptions namespace provides helper functions to work with
\r
4255 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
\r
4257 var WorkDoneProgressOptions;
\r
4258 (function (WorkDoneProgressOptions) {
\r
4259 function is(value) {
\r
4260 const candidate = value;
\r
4261 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
\r
4263 WorkDoneProgressOptions.is = is;
\r
4264 function hasWorkDoneProgress(value) {
\r
4265 const candidate = value;
\r
4266 return candidate && Is.boolean(candidate.workDoneProgress);
\r
4268 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
\r
4269 })(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
\r
4271 * The initialize request is sent from the client to the server.
\r
4272 * It is sent once as the request after starting up the server.
\r
4273 * The requests parameter is of type [InitializeParams](#InitializeParams)
\r
4274 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
\r
4275 * resolves to such.
\r
4277 var InitializeRequest;
\r
4278 (function (InitializeRequest) {
\r
4279 InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');
\r
4280 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
\r
4282 * Known error codes for an `InitializeError`;
\r
4284 var InitializeError;
\r
4285 (function (InitializeError) {
\r
4287 * If the protocol version provided by the client can't be handled by the server.
\r
4288 * @deprecated This initialize error got replaced by client capabilities. There is
\r
4289 * no version handshake in version 3.0x
\r
4291 InitializeError.unknownProtocolVersion = 1;
\r
4292 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
\r
4294 * The intialized notification is sent from the client to the
\r
4295 * server after the client is fully initialized and the server
\r
4296 * is allowed to send requests from the server to the client.
\r
4298 var InitializedNotification;
\r
4299 (function (InitializedNotification) {
\r
4300 InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');
\r
4301 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
\r
4302 //---- Shutdown Method ----
\r
4304 * A shutdown request is sent from the client to the server.
\r
4305 * It is sent once when the client decides to shutdown the
\r
4306 * server. The only notification that is sent after a shutdown request
\r
4307 * is the exit event.
\r
4309 var ShutdownRequest;
\r
4310 (function (ShutdownRequest) {
\r
4311 ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');
\r
4312 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
\r
4313 //---- Exit Notification ----
\r
4315 * The exit event is sent from the client to the server to
\r
4316 * ask the server to exit its process.
\r
4318 var ExitNotification;
\r
4319 (function (ExitNotification) {
\r
4320 ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');
\r
4321 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
\r
4323 * The configuration change notification is sent from the client to the server
\r
4324 * when the client's configuration has changed. The notification contains
\r
4325 * the changed configuration as defined by the language client.
\r
4327 var DidChangeConfigurationNotification;
\r
4328 (function (DidChangeConfigurationNotification) {
\r
4329 DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');
\r
4330 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
\r
4331 //---- Message show and log notifications ----
\r
4333 * The message type
\r
4336 (function (MessageType) {
\r
4338 * An error message.
\r
4340 MessageType.Error = 1;
\r
4342 * A warning message.
\r
4344 MessageType.Warning = 2;
\r
4346 * An information message.
\r
4348 MessageType.Info = 3;
\r
4352 MessageType.Log = 4;
\r
4353 })(MessageType = exports.MessageType || (exports.MessageType = {}));
\r
4355 * The show message notification is sent from a server to a client to ask
\r
4356 * the client to display a particular message in the user interface.
\r
4358 var ShowMessageNotification;
\r
4359 (function (ShowMessageNotification) {
\r
4360 ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');
\r
4361 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
\r
4363 * The show message request is sent from the server to the client to show a message
\r
4364 * and a set of options actions to the user.
\r
4366 var ShowMessageRequest;
\r
4367 (function (ShowMessageRequest) {
\r
4368 ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');
\r
4369 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
\r
4371 * The log message notification is sent from the server to the client to ask
\r
4372 * the client to log a particular message.
\r
4374 var LogMessageNotification;
\r
4375 (function (LogMessageNotification) {
\r
4376 LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');
\r
4377 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
\r
4378 //---- Telemetry notification
\r
4380 * The telemetry event notification is sent from the server to the client to ask
\r
4381 * the client to log telemetry data.
\r
4383 var TelemetryEventNotification;
\r
4384 (function (TelemetryEventNotification) {
\r
4385 TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');
\r
4386 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
\r
4388 * Defines how the host (editor) should sync
\r
4389 * document changes to the language server.
\r
4391 var TextDocumentSyncKind;
\r
4392 (function (TextDocumentSyncKind) {
\r
4394 * Documents should not be synced at all.
\r
4396 TextDocumentSyncKind.None = 0;
\r
4398 * Documents are synced by always sending the full content
\r
4399 * of the document.
\r
4401 TextDocumentSyncKind.Full = 1;
\r
4403 * Documents are synced by sending the full content on open.
\r
4404 * After that only incremental updates to the document are
\r
4407 TextDocumentSyncKind.Incremental = 2;
\r
4408 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
\r
4410 * The document open notification is sent from the client to the server to signal
\r
4411 * newly opened text documents. The document's truth is now managed by the client
\r
4412 * and the server must not try to read the document's truth using the document's
\r
4413 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
\r
4414 * mean that its content is presented in an editor. An open notification must not
\r
4415 * be sent more than once without a corresponding close notification send before.
\r
4416 * This means open and close notification must be balanced and the max open count
\r
4419 var DidOpenTextDocumentNotification;
\r
4420 (function (DidOpenTextDocumentNotification) {
\r
4421 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
\r
4422 DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType(DidOpenTextDocumentNotification.method);
\r
4423 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
\r
4425 * The document change notification is sent from the client to the server to signal
\r
4426 * changes to a text document.
\r
4428 var DidChangeTextDocumentNotification;
\r
4429 (function (DidChangeTextDocumentNotification) {
\r
4430 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
\r
4431 DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType(DidChangeTextDocumentNotification.method);
\r
4432 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
\r
4434 * The document close notification is sent from the client to the server when
\r
4435 * the document got closed in the client. The document's truth now exists where
\r
4436 * the document's uri points to (e.g. if the document's uri is a file uri the
\r
4437 * truth now exists on disk). As with the open notification the close notification
\r
4438 * is about managing the document's content. Receiving a close notification
\r
4439 * doesn't mean that the document was open in an editor before. A close
\r
4440 * notification requires a previous open notification to be sent.
\r
4442 var DidCloseTextDocumentNotification;
\r
4443 (function (DidCloseTextDocumentNotification) {
\r
4444 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
\r
4445 DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType(DidCloseTextDocumentNotification.method);
\r
4446 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
\r
4448 * The document save notification is sent from the client to the server when
\r
4449 * the document got saved in the client.
\r
4451 var DidSaveTextDocumentNotification;
\r
4452 (function (DidSaveTextDocumentNotification) {
\r
4453 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
\r
4454 DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType(DidSaveTextDocumentNotification.method);
\r
4455 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
\r
4457 * Represents reasons why a text document is saved.
\r
4459 var TextDocumentSaveReason;
\r
4460 (function (TextDocumentSaveReason) {
\r
4462 * Manually triggered, e.g. by the user pressing save, by starting debugging,
\r
4463 * or by an API call.
\r
4465 TextDocumentSaveReason.Manual = 1;
\r
4467 * Automatic after a delay.
\r
4469 TextDocumentSaveReason.AfterDelay = 2;
\r
4471 * When the editor lost focus.
\r
4473 TextDocumentSaveReason.FocusOut = 3;
\r
4474 })(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
\r
4476 * A document will save notification is sent from the client to the server before
\r
4477 * the document is actually saved.
\r
4479 var WillSaveTextDocumentNotification;
\r
4480 (function (WillSaveTextDocumentNotification) {
\r
4481 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
\r
4482 WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType(WillSaveTextDocumentNotification.method);
\r
4483 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
\r
4485 * A document will save request is sent from the client to the server before
\r
4486 * the document is actually saved. The request can return an array of TextEdits
\r
4487 * which will be applied to the text document before it is saved. Please note that
\r
4488 * clients might drop results if computing the text edits took too long or if a
\r
4489 * server constantly fails on this request. This is done to keep the save fast and
\r
4492 var WillSaveTextDocumentWaitUntilRequest;
\r
4493 (function (WillSaveTextDocumentWaitUntilRequest) {
\r
4494 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
\r
4495 WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType(WillSaveTextDocumentWaitUntilRequest.method);
\r
4496 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
\r
4498 * The watched files notification is sent from the client to the server when
\r
4499 * the client detects changes to file watched by the language client.
\r
4501 var DidChangeWatchedFilesNotification;
\r
4502 (function (DidChangeWatchedFilesNotification) {
\r
4503 DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');
\r
4504 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
\r
4506 * The file event type
\r
4508 var FileChangeType;
\r
4509 (function (FileChangeType) {
\r
4511 * The file got created.
\r
4513 FileChangeType.Created = 1;
\r
4515 * The file got changed.
\r
4517 FileChangeType.Changed = 2;
\r
4519 * The file got deleted.
\r
4521 FileChangeType.Deleted = 3;
\r
4522 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
\r
4524 (function (WatchKind) {
\r
4526 * Interested in create events.
\r
4528 WatchKind.Create = 1;
\r
4530 * Interested in change events
\r
4532 WatchKind.Change = 2;
\r
4534 * Interested in delete events
\r
4536 WatchKind.Delete = 4;
\r
4537 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
\r
4539 * Diagnostics notification are sent from the server to the client to signal
\r
4540 * results of validation runs.
\r
4542 var PublishDiagnosticsNotification;
\r
4543 (function (PublishDiagnosticsNotification) {
\r
4544 PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');
\r
4545 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
\r
4547 * How a completion was triggered
\r
4549 var CompletionTriggerKind;
\r
4550 (function (CompletionTriggerKind) {
\r
4552 * Completion was triggered by typing an identifier (24x7 code
\r
4553 * complete), manual invocation (e.g Ctrl+Space) or via API.
\r
4555 CompletionTriggerKind.Invoked = 1;
\r
4557 * Completion was triggered by a trigger character specified by
\r
4558 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
\r
4560 CompletionTriggerKind.TriggerCharacter = 2;
\r
4562 * Completion was re-triggered as current completion list is incomplete
\r
4564 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
\r
4565 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
\r
4567 * Request to request completion at a given text document position. The request's
\r
4568 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
\r
4569 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
\r
4570 * or a Thenable that resolves to such.
\r
4572 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
\r
4573 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
\r
4574 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
\r
4575 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
\r
4577 var CompletionRequest;
\r
4578 (function (CompletionRequest) {
\r
4579 CompletionRequest.method = 'textDocument/completion';
\r
4580 CompletionRequest.type = new vscode_jsonrpc_1.RequestType(CompletionRequest.method);
\r
4581 CompletionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4582 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
\r
4584 * Request to resolve additional information for a given completion item.The request's
\r
4585 * parameter is of type [CompletionItem](#CompletionItem) the response
\r
4586 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
\r
4588 var CompletionResolveRequest;
\r
4589 (function (CompletionResolveRequest) {
\r
4590 CompletionResolveRequest.method = 'completionItem/resolve';
\r
4591 CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType(CompletionResolveRequest.method);
\r
4592 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
\r
4594 * Request to request hover information at a given text document position. The request's
\r
4595 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
\r
4596 * type [Hover](#Hover) or a Thenable that resolves to such.
\r
4599 (function (HoverRequest) {
\r
4600 HoverRequest.method = 'textDocument/hover';
\r
4601 HoverRequest.type = new vscode_jsonrpc_1.RequestType(HoverRequest.method);
\r
4602 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
\r
4604 * How a signature help was triggered.
\r
4608 var SignatureHelpTriggerKind;
\r
4609 (function (SignatureHelpTriggerKind) {
\r
4611 * Signature help was invoked manually by the user or by a command.
\r
4613 SignatureHelpTriggerKind.Invoked = 1;
\r
4615 * Signature help was triggered by a trigger character.
\r
4617 SignatureHelpTriggerKind.TriggerCharacter = 2;
\r
4619 * Signature help was triggered by the cursor moving or by the document content changing.
\r
4621 SignatureHelpTriggerKind.ContentChange = 3;
\r
4622 })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
\r
4623 var SignatureHelpRequest;
\r
4624 (function (SignatureHelpRequest) {
\r
4625 SignatureHelpRequest.method = 'textDocument/signatureHelp';
\r
4626 SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType(SignatureHelpRequest.method);
\r
4627 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
\r
4629 * A request to resolve the definition location of a symbol at a given text
\r
4630 * document position. The request's parameter is of type [TextDocumentPosition]
\r
4631 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
\r
4632 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
\r
4635 var DefinitionRequest;
\r
4636 (function (DefinitionRequest) {
\r
4637 DefinitionRequest.method = 'textDocument/definition';
\r
4638 DefinitionRequest.type = new vscode_jsonrpc_1.RequestType(DefinitionRequest.method);
\r
4639 DefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4640 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
\r
4642 * A request to resolve project-wide references for the symbol denoted
\r
4643 * by the given text document position. The request's parameter is of
\r
4644 * type [ReferenceParams](#ReferenceParams) the response is of type
\r
4645 * [Location[]](#Location) or a Thenable that resolves to such.
\r
4647 var ReferencesRequest;
\r
4648 (function (ReferencesRequest) {
\r
4649 ReferencesRequest.method = 'textDocument/references';
\r
4650 ReferencesRequest.type = new vscode_jsonrpc_1.RequestType(ReferencesRequest.method);
\r
4651 ReferencesRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4652 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
\r
4654 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
\r
4655 * text document position. The request's parameter is of type [TextDocumentPosition]
\r
4656 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
\r
4657 * (#DocumentHighlight) or a Thenable that resolves to such.
\r
4659 var DocumentHighlightRequest;
\r
4660 (function (DocumentHighlightRequest) {
\r
4661 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
\r
4662 DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType(DocumentHighlightRequest.method);
\r
4663 DocumentHighlightRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4664 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
\r
4666 * A request to list all symbols found in a given text document. The request's
\r
4667 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
\r
4668 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
\r
4669 * that resolves to such.
\r
4671 var DocumentSymbolRequest;
\r
4672 (function (DocumentSymbolRequest) {
\r
4673 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
\r
4674 DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType(DocumentSymbolRequest.method);
\r
4675 DocumentSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4676 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
\r
4678 * A request to provide commands for the given text document and range.
\r
4680 var CodeActionRequest;
\r
4681 (function (CodeActionRequest) {
\r
4682 CodeActionRequest.method = 'textDocument/codeAction';
\r
4683 CodeActionRequest.type = new vscode_jsonrpc_1.RequestType(CodeActionRequest.method);
\r
4684 CodeActionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4685 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
\r
4687 * A request to list project-wide symbols matching the query string given
\r
4688 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
\r
4689 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
\r
4690 * resolves to such.
\r
4692 var WorkspaceSymbolRequest;
\r
4693 (function (WorkspaceSymbolRequest) {
\r
4694 WorkspaceSymbolRequest.method = 'workspace/symbol';
\r
4695 WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType(WorkspaceSymbolRequest.method);
\r
4696 WorkspaceSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4697 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
\r
4699 * A request to provide code lens for the given text document.
\r
4701 var CodeLensRequest;
\r
4702 (function (CodeLensRequest) {
\r
4703 CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');
\r
4704 CodeLensRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4705 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
\r
4707 * A request to resolve a command for a given code lens.
\r
4709 var CodeLensResolveRequest;
\r
4710 (function (CodeLensResolveRequest) {
\r
4711 CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');
\r
4712 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
\r
4714 * A request to provide document links
\r
4716 var DocumentLinkRequest;
\r
4717 (function (DocumentLinkRequest) {
\r
4718 DocumentLinkRequest.method = 'textDocument/documentLink';
\r
4719 DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType(DocumentLinkRequest.method);
\r
4720 DocumentLinkRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4721 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
\r
4723 * Request to resolve additional information for a given document link. The request's
\r
4724 * parameter is of type [DocumentLink](#DocumentLink) the response
\r
4725 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
\r
4727 var DocumentLinkResolveRequest;
\r
4728 (function (DocumentLinkResolveRequest) {
\r
4729 DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');
\r
4730 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
\r
4732 * A request to to format a whole document.
\r
4734 var DocumentFormattingRequest;
\r
4735 (function (DocumentFormattingRequest) {
\r
4736 DocumentFormattingRequest.method = 'textDocument/formatting';
\r
4737 DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType(DocumentFormattingRequest.method);
\r
4738 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
\r
4740 * A request to to format a range in a document.
\r
4742 var DocumentRangeFormattingRequest;
\r
4743 (function (DocumentRangeFormattingRequest) {
\r
4744 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
\r
4745 DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType(DocumentRangeFormattingRequest.method);
\r
4746 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
\r
4748 * A request to format a document on type.
\r
4750 var DocumentOnTypeFormattingRequest;
\r
4751 (function (DocumentOnTypeFormattingRequest) {
\r
4752 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
\r
4753 DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType(DocumentOnTypeFormattingRequest.method);
\r
4754 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
\r
4756 * A request to rename a symbol.
\r
4758 var RenameRequest;
\r
4759 (function (RenameRequest) {
\r
4760 RenameRequest.method = 'textDocument/rename';
\r
4761 RenameRequest.type = new vscode_jsonrpc_1.RequestType(RenameRequest.method);
\r
4762 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
\r
4764 * A request to test and perform the setup necessary for a rename.
\r
4766 var PrepareRenameRequest;
\r
4767 (function (PrepareRenameRequest) {
\r
4768 PrepareRenameRequest.method = 'textDocument/prepareRename';
\r
4769 PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType(PrepareRenameRequest.method);
\r
4770 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
\r
4772 * A request send from the client to the server to execute a command. The request might return
\r
4773 * a workspace edit which the client will apply to the workspace.
\r
4775 var ExecuteCommandRequest;
\r
4776 (function (ExecuteCommandRequest) {
\r
4777 ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');
\r
4778 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
\r
4780 * A request sent from the server to the client to modified certain resources.
\r
4782 var ApplyWorkspaceEditRequest;
\r
4783 (function (ApplyWorkspaceEditRequest) {
\r
4784 ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');
\r
4785 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
\r
4790 /***/ (function(module, exports, __webpack_require__) {
4793 /* --------------------------------------------------------------------------------------------
\r
4794 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4795 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4796 * ------------------------------------------------------------------------------------------ */
\r
4798 Object.defineProperty(exports, "__esModule", { value: true });
\r
4799 function boolean(value) {
\r
4800 return value === true || value === false;
\r
4802 exports.boolean = boolean;
\r
4803 function string(value) {
\r
4804 return typeof value === 'string' || value instanceof String;
\r
4806 exports.string = string;
\r
4807 function number(value) {
\r
4808 return typeof value === 'number' || value instanceof Number;
\r
4810 exports.number = number;
\r
4811 function error(value) {
\r
4812 return value instanceof Error;
\r
4814 exports.error = error;
\r
4815 function func(value) {
\r
4816 return typeof value === 'function';
\r
4818 exports.func = func;
\r
4819 function array(value) {
\r
4820 return Array.isArray(value);
\r
4822 exports.array = array;
\r
4823 function stringArray(value) {
\r
4824 return array(value) && value.every(elem => string(elem));
\r
4826 exports.stringArray = stringArray;
\r
4827 function typedArray(value, check) {
\r
4828 return Array.isArray(value) && value.every(check);
\r
4830 exports.typedArray = typedArray;
\r
4831 function objectLiteral(value) {
\r
4832 // Strictly speaking class instances pass this check as well. Since the LSP
\r
4833 // doesn't use classes we ignore this for now. If we do we need to add something
\r
4834 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
4835 return value !== null && typeof value === 'object';
\r
4837 exports.objectLiteral = objectLiteral;
\r
4842 /***/ (function(module, exports, __webpack_require__) {
4845 /* --------------------------------------------------------------------------------------------
\r
4846 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4847 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4848 * ------------------------------------------------------------------------------------------ */
\r
4850 Object.defineProperty(exports, "__esModule", { value: true });
\r
4851 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4852 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
4853 let __noDynamicImport;
\r
4855 * A request to resolve the implementation locations of a symbol at a given text
\r
4856 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
4857 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
4858 * Thenable that resolves to such.
\r
4860 var ImplementationRequest;
\r
4861 (function (ImplementationRequest) {
\r
4862 ImplementationRequest.method = 'textDocument/implementation';
\r
4863 ImplementationRequest.type = new vscode_jsonrpc_1.RequestType(ImplementationRequest.method);
\r
4864 ImplementationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4865 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
\r
4870 /***/ (function(module, exports, __webpack_require__) {
4873 /* --------------------------------------------------------------------------------------------
\r
4874 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4875 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4876 * ------------------------------------------------------------------------------------------ */
\r
4878 Object.defineProperty(exports, "__esModule", { value: true });
\r
4879 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4880 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
4881 let __noDynamicImport;
\r
4883 * A request to resolve the type definition locations of a symbol at a given text
\r
4884 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
4885 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
4886 * Thenable that resolves to such.
\r
4888 var TypeDefinitionRequest;
\r
4889 (function (TypeDefinitionRequest) {
\r
4890 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
\r
4891 TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType(TypeDefinitionRequest.method);
\r
4892 TypeDefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4893 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
\r
4898 /***/ (function(module, exports, __webpack_require__) {
4901 /* --------------------------------------------------------------------------------------------
\r
4902 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4903 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4904 * ------------------------------------------------------------------------------------------ */
\r
4906 Object.defineProperty(exports, "__esModule", { value: true });
\r
4907 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4909 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
\r
4911 var WorkspaceFoldersRequest;
\r
4912 (function (WorkspaceFoldersRequest) {
\r
4913 WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');
\r
4914 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
\r
4916 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
\r
4917 * folder configuration changes.
\r
4919 var DidChangeWorkspaceFoldersNotification;
\r
4920 (function (DidChangeWorkspaceFoldersNotification) {
\r
4921 DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');
\r
4922 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
\r
4927 /***/ (function(module, exports, __webpack_require__) {
4930 /* --------------------------------------------------------------------------------------------
\r
4931 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4932 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4933 * ------------------------------------------------------------------------------------------ */
\r
4935 Object.defineProperty(exports, "__esModule", { value: true });
\r
4936 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4938 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
\r
4939 * configuration setting.
\r
4941 * This pull model replaces the old push model were the client signaled configuration change via an
\r
4942 * event. If the server still needs to react to configuration changes (since the server caches the
\r
4943 * result of `workspace/configuration` requests) the server should register for an empty configuration
\r
4944 * change event and empty the cache if such an event is received.
\r
4946 var ConfigurationRequest;
\r
4947 (function (ConfigurationRequest) {
\r
4948 ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');
\r
4949 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
\r
4954 /***/ (function(module, exports, __webpack_require__) {
4957 /* --------------------------------------------------------------------------------------------
\r
4958 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4959 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4960 * ------------------------------------------------------------------------------------------ */
\r
4962 Object.defineProperty(exports, "__esModule", { value: true });
\r
4963 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
4965 * A request to list all color symbols found in a given text document. The request's
\r
4966 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
\r
4967 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
4968 * that resolves to such.
\r
4970 var DocumentColorRequest;
\r
4971 (function (DocumentColorRequest) {
\r
4972 DocumentColorRequest.method = 'textDocument/documentColor';
\r
4973 DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType(DocumentColorRequest.method);
\r
4974 DocumentColorRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
4975 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
\r
4977 * A request to list all presentation for a color. The request's
\r
4978 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
\r
4979 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
4980 * that resolves to such.
\r
4982 var ColorPresentationRequest;
\r
4983 (function (ColorPresentationRequest) {
\r
4984 ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');
\r
4985 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
\r
4990 /***/ (function(module, exports, __webpack_require__) {
4994 /*---------------------------------------------------------------------------------------------
\r
4995 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
4996 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
4997 *--------------------------------------------------------------------------------------------*/
\r
4998 Object.defineProperty(exports, "__esModule", { value: true });
\r
4999 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5001 * Enum of known range kinds
\r
5003 var FoldingRangeKind;
\r
5004 (function (FoldingRangeKind) {
\r
5006 * Folding range for a comment
\r
5008 FoldingRangeKind["Comment"] = "comment";
\r
5010 * Folding range for a imports or includes
\r
5012 FoldingRangeKind["Imports"] = "imports";
\r
5014 * Folding range for a region (e.g. `#region`)
\r
5016 FoldingRangeKind["Region"] = "region";
\r
5017 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
\r
5019 * A request to provide folding ranges in a document. The request's
\r
5020 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
\r
5021 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
\r
5022 * that resolves to such.
\r
5024 var FoldingRangeRequest;
\r
5025 (function (FoldingRangeRequest) {
\r
5026 FoldingRangeRequest.method = 'textDocument/foldingRange';
\r
5027 FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType(FoldingRangeRequest.method);
\r
5028 FoldingRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5029 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
\r
5034 /***/ (function(module, exports, __webpack_require__) {
5037 /* --------------------------------------------------------------------------------------------
\r
5038 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5039 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5040 * ------------------------------------------------------------------------------------------ */
\r
5042 Object.defineProperty(exports, "__esModule", { value: true });
\r
5043 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5044 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
5045 let __noDynamicImport;
\r
5047 * A request to resolve the type definition locations of a symbol at a given text
\r
5048 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
5049 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
\r
5050 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
\r
5053 var DeclarationRequest;
\r
5054 (function (DeclarationRequest) {
\r
5055 DeclarationRequest.method = 'textDocument/declaration';
\r
5056 DeclarationRequest.type = new vscode_jsonrpc_1.RequestType(DeclarationRequest.method);
\r
5057 DeclarationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5058 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
\r
5063 /***/ (function(module, exports, __webpack_require__) {
5067 /*---------------------------------------------------------------------------------------------
\r
5068 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5069 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5070 *--------------------------------------------------------------------------------------------*/
\r
5071 Object.defineProperty(exports, "__esModule", { value: true });
\r
5072 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5074 * A request to provide selection ranges in a document. The request's
\r
5075 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
\r
5076 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
\r
5077 * that resolves to such.
\r
5079 var SelectionRangeRequest;
\r
5080 (function (SelectionRangeRequest) {
\r
5081 SelectionRangeRequest.method = 'textDocument/selectionRange';
\r
5082 SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType(SelectionRangeRequest.method);
\r
5083 SelectionRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5084 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
\r
5089 /***/ (function(module, exports, __webpack_require__) {
5092 /* --------------------------------------------------------------------------------------------
\r
5093 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
5094 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5095 * ------------------------------------------------------------------------------------------ */
\r
5097 Object.defineProperty(exports, "__esModule", { value: true });
\r
5098 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5099 var WorkDoneProgress;
\r
5100 (function (WorkDoneProgress) {
\r
5101 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
\r
5102 })(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
\r
5104 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
\r
5105 * reporting from the server.
\r
5107 var WorkDoneProgressCreateRequest;
\r
5108 (function (WorkDoneProgressCreateRequest) {
\r
5109 WorkDoneProgressCreateRequest.type = new vscode_jsonrpc_1.RequestType('window/workDoneProgress/create');
\r
5110 })(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
\r
5112 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
\r
5113 * initiated on the server side.
\r
5115 var WorkDoneProgressCancelNotification;
\r
5116 (function (WorkDoneProgressCancelNotification) {
\r
5117 WorkDoneProgressCancelNotification.type = new vscode_jsonrpc_1.NotificationType('window/workDoneProgress/cancel');
\r
5118 })(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
\r
5123 /***/ (function(module, exports, __webpack_require__) {
5126 /* --------------------------------------------------------------------------------------------
\r
5127 * Copyright (c) TypeFox and others. All rights reserved.
\r
5128 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
5129 * ------------------------------------------------------------------------------------------ */
\r
5131 Object.defineProperty(exports, "__esModule", { value: true });
\r
5132 const vscode_jsonrpc_1 = __webpack_require__(5);
\r
5133 var CallHierarchyPrepareRequest;
\r
5134 (function (CallHierarchyPrepareRequest) {
\r
5135 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
\r
5136 CallHierarchyPrepareRequest.type = new vscode_jsonrpc_1.RequestType(CallHierarchyPrepareRequest.method);
\r
5137 })(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
\r
5138 var CallHierarchyIncomingCallsRequest;
\r
5139 (function (CallHierarchyIncomingCallsRequest) {
\r
5140 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
\r
5141 CallHierarchyIncomingCallsRequest.type = new vscode_jsonrpc_1.RequestType(CallHierarchyIncomingCallsRequest.method);
\r
5142 CallHierarchyIncomingCallsRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5143 })(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
\r
5144 var CallHierarchyOutgoingCallsRequest;
\r
5145 (function (CallHierarchyOutgoingCallsRequest) {
\r
5146 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
\r
5147 CallHierarchyOutgoingCallsRequest.type = new vscode_jsonrpc_1.RequestType(CallHierarchyOutgoingCallsRequest.method);
\r
5148 CallHierarchyOutgoingCallsRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
5149 })(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
\r
5159 /***/ (function(module, exports, __webpack_require__) {
5162 /* --------------------------------------------------------------------------------------------
5163 * Copyright (c) Microsoft Corporation. All rights reserved.
5164 * Licensed under the MIT License. See License.txt in the project root for license information.
5165 * ------------------------------------------------------------------------------------------ */
5167 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5168 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5169 return new (P || (P = Promise))(function (resolve, reject) {
5170 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5171 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5172 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5173 step((generator = generator.apply(thisArg, _arguments || [])).next());
5176 var __importStar = (this && this.__importStar) || function (mod) {
5177 if (mod && mod.__esModule) return mod;
5179 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
5180 result["default"] = mod;
5183 Object.defineProperty(exports, "__esModule", { value: true });
5184 const os = __importStar(__webpack_require__(14));
5185 const path = __importStar(__webpack_require__(3));
5186 const vscode_languageserver_1 = __webpack_require__(37);
5187 const vscode_uri_1 = __webpack_require__(46);
5188 const types_1 = __webpack_require__(47);
5189 const util_1 = __webpack_require__(48);
5190 const vscode_languageserver_textdocument_1 = __webpack_require__(52);
5191 const requireFunc = true ? require : undefined;
5193 (function (CommandIds) {
5194 CommandIds.applySingleFix = 'eslint.applySingleFix';
5195 CommandIds.applySameFixes = 'eslint.applySameFixes';
5196 CommandIds.applyAllFixes = 'eslint.applyAllFixes';
5197 CommandIds.applyAutoFix = 'eslint.applyAutoFix';
5198 CommandIds.applyDisableLine = 'eslint.applyDisableLine';
5199 CommandIds.applyDisableFile = 'eslint.applyDisableFile';
5200 CommandIds.openRuleDoc = 'eslint.openRuleDoc';
5201 })(CommandIds || (CommandIds = {}));
5202 var OpenESLintDocRequest;
5203 (function (OpenESLintDocRequest) {
5204 OpenESLintDocRequest.type = new vscode_languageserver_1.RequestType('eslint/openDoc');
5205 })(OpenESLintDocRequest || (OpenESLintDocRequest = {}));
5207 (function (Status) {
5208 Status[Status["ok"] = 1] = "ok";
5209 Status[Status["warn"] = 2] = "warn";
5210 Status[Status["error"] = 3] = "error";
5211 })(Status || (Status = {}));
5212 var StatusNotification;
5213 (function (StatusNotification) {
5214 StatusNotification.type = new vscode_languageserver_1.NotificationType('eslint/status');
5215 })(StatusNotification || (StatusNotification = {}));
5216 var NoConfigRequest;
5217 (function (NoConfigRequest) {
5218 NoConfigRequest.type = new vscode_languageserver_1.RequestType('eslint/noConfig');
5219 })(NoConfigRequest || (NoConfigRequest = {}));
5220 var NoESLintLibraryRequest;
5221 (function (NoESLintLibraryRequest) {
5222 NoESLintLibraryRequest.type = new vscode_languageserver_1.RequestType('eslint/noLibrary');
5223 })(NoESLintLibraryRequest || (NoESLintLibraryRequest = {}));
5224 class CodeActionResult {
5226 this._actions = new Map();
5229 let result = this._actions.get(ruleId);
5230 if (result === undefined) {
5231 result = { fixes: [] };
5232 this._actions.set(ruleId, result);
5236 set fixAll(action) {
5237 this._fixAll = action;
5241 for (let actions of this._actions.values()) {
5242 result.push(...actions.fixes);
5243 if (actions.disable) {
5244 result.push(actions.disable);
5246 if (actions.fixAll) {
5247 result.push(actions.fixAll);
5249 if (actions.disableFile) {
5250 result.push(actions.disableFile);
5252 if (actions.showDocumentation) {
5253 result.push(actions.showDocumentation);
5256 if (this._fixAll !== undefined) {
5257 result.push(this._fixAll);
5263 for (let actions of this._actions.values()) {
5264 result += actions.fixes.length;
5269 function makeDiagnostic(problem) {
5270 let message = problem.ruleId != null
5271 ? `${problem.message} (${problem.ruleId})`
5272 : `${problem.message}`;
5273 let startLine = Math.max(0, problem.line - 1);
5274 let startChar = Math.max(0, problem.column - 1);
5275 let endLine = problem.endLine != null ? Math.max(0, problem.endLine - 1) : startLine;
5276 let endChar = problem.endColumn != null ? Math.max(0, problem.endColumn - 1) : startChar;
5279 severity: convertSeverity(problem.severity),
5282 start: { line: startLine, character: startChar },
5283 end: { line: endLine, character: endChar }
5285 code: problem.ruleId
5288 function computeKey(diagnostic) {
5289 let range = diagnostic.range;
5290 return `[${range.start.line},${range.start.character},${range.end.line},${range.end.character}]-${diagnostic.code}`;
5292 let codeActions = new Map();
5293 function recordCodeAction(document, diagnostic, problem) {
5294 if (!problem.ruleId) {
5297 let uri = document.uri;
5298 let edits = codeActions.get(uri);
5301 codeActions.set(uri, edits);
5303 edits.set(computeKey(diagnostic), { label: `Fix this ${problem.ruleId} problem`, documentVersion: document.version, ruleId: problem.ruleId, edit: problem.fix, line: problem.line });
5305 function convertSeverity(severity) {
5307 // Eslint 1 is warning
5309 return vscode_languageserver_1.DiagnosticSeverity.Warning;
5311 return vscode_languageserver_1.DiagnosticSeverity.Error;
5313 return vscode_languageserver_1.DiagnosticSeverity.Error;
5316 const exitCalled = new vscode_languageserver_1.NotificationType('eslint/exitCalled');
5317 const nodeExit = process.exit;
5318 process.exit = ((code) => {
5319 let stack = new Error('stack');
5320 connection.sendNotification(exitCalled, [code ? code : 0, stack.stack]);
5325 process.on('uncaughtException', (error) => {
5328 if (typeof error.stack === 'string') {
5329 message = error.stack;
5331 else if (typeof error.message === 'string') {
5332 message = error.message;
5334 else if (typeof error === 'string') {
5339 message = JSON.stringify(error, undefined, 4);
5342 // Should not happen.
5346 connection.console.error(`Uncaught exception recevied.
5349 let connection = vscode_languageserver_1.createConnection();
5350 connection.console.info(`ESLint server running in node ${process.version}`);
5351 let documents = new vscode_languageserver_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
5353 function globalNpmPath() {
5354 if (_globalNpmPath === void 0) {
5355 _globalNpmPath = vscode_languageserver_1.Files.resolveGlobalNodePath(trace);
5356 if (_globalNpmPath === void 0) {
5357 _globalNpmPath = null;
5360 if (_globalNpmPath === null) {
5363 return _globalNpmPath;
5365 let _globalYarnPath;
5366 function globalYarnPath() {
5367 if (_globalYarnPath === void 0) {
5368 _globalYarnPath = vscode_languageserver_1.Files.resolveGlobalYarnPath(trace);
5369 if (_globalYarnPath === void 0) {
5370 _globalYarnPath = null;
5373 if (_globalYarnPath === null) {
5376 return _globalYarnPath;
5378 let path2Library = new Map();
5379 let document2Settings = new Map();
5384 function resolveSettings(document) {
5385 let uri = document.uri;
5386 let resultPromise = document2Settings.get(uri);
5387 if (resultPromise) {
5388 return resultPromise;
5390 resultPromise = connection.workspace
5391 .getConfiguration({ scopeUri: uri, section: '' })
5392 .then((settings) => {
5394 if (settings.nodePath) {
5395 nodePath = settings.nodePath;
5396 if (nodePath.startsWith('~')) {
5397 nodePath = nodePath.replace(/^~/, os.homedir());
5399 if (!path.isAbsolute(nodePath)) {
5400 nodePath = path.join(vscode_uri_1.URI.parse(settings.workspaceFolder.uri).fsPath, nodePath);
5403 else if (settings.packageManager === 'npm') {
5404 nodePath = globalNpmPath();
5406 else if (settings.packageManager === 'yarn') {
5407 nodePath = globalYarnPath();
5409 let uri = vscode_uri_1.URI.parse(document.uri);
5412 if (uri.scheme === 'file') {
5413 directory = path.dirname(uri.fsPath);
5416 directory = settings.workspaceFolder ? vscode_uri_1.URI.parse(settings.workspaceFolder.uri).fsPath : undefined;
5418 promise = util_1.resolveModule('./eslint', directory, nodePath).catch(() => {
5419 return util_1.resolveModule('eslint', directory, nodePath);
5421 return promise.then(path => {
5422 let library = path2Library.get(path);
5424 library = requireFunc(path);
5425 if (!library.CLIEngine) {
5426 settings.validate = false;
5427 connection.console.error(`The eslint library loaded from ${path} doesn\'t export a CLIEngine. You need at least eslint@1.0.0`);
5430 connection.console.info(`ESLint library loaded from: ${path}`);
5431 settings.library = library;
5433 path2Library.set(path, library);
5436 settings.library = library;
5440 settings.validate = false;
5441 connection.sendRequest(NoESLintLibraryRequest.type, {
5442 source: { uri: document.uri }
5447 document2Settings.set(uri, resultPromise);
5448 return resultPromise;
5451 (function (Request) {
5452 function is(value) {
5453 let candidate = value;
5454 return (candidate &&
5455 !!candidate.token &&
5456 !!candidate.resolve &&
5457 !!candidate.reject);
5460 })(Request || (Request = {}));
5462 (function (Thenable) {
5463 function is(value) {
5464 let candidate = value;
5465 return candidate && typeof candidate.then === 'function';
5468 })(Thenable || (Thenable = {}));
5469 class BufferedMessageQueue {
5470 constructor(connection) {
5471 this.connection = connection;
5473 this.requestHandlers = new Map();
5474 this.notificationHandlers = new Map();
5476 registerRequest(type, handler, versionProvider) {
5477 this.connection.onRequest(type, (params, token) => {
5478 return new Promise((resolve, reject) => {
5480 method: type.method,
5482 documentVersion: versionProvider
5483 ? versionProvider(params)
5492 this.requestHandlers.set(type.method, { handler, versionProvider });
5494 registerNotification(type, handler, versionProvider) {
5495 connection.onNotification(type, params => {
5497 method: type.method,
5499 documentVersion: versionProvider ? versionProvider(params) : undefined
5503 this.notificationHandlers.set(type.method, { handler, versionProvider });
5505 addNotificationMessage(type, params, version) {
5507 method: type.method,
5509 documentVersion: version
5513 onNotification(type, handler, versionProvider) {
5514 this.notificationHandlers.set(type.method, { handler, versionProvider });
5517 if (this.timer || this.queue.length === 0) {
5520 this.timer = setImmediate(() => {
5521 this.timer = undefined;
5522 this.processQueue();
5526 let message = this.queue.shift();
5530 if (Request.is(message)) {
5531 let requestMessage = message;
5532 if (requestMessage.token.isCancellationRequested) {
5533 requestMessage.reject(
5534 // tslint:disable-next-line: no-inferred-empty-object-type
5535 new vscode_languageserver_1.ResponseError(vscode_languageserver_1.ErrorCodes.RequestCancelled, 'Request got cancelled'));
5538 let elem = this.requestHandlers.get(requestMessage.method);
5539 if (elem.versionProvider &&
5540 requestMessage.documentVersion !== void 0 &&
5541 requestMessage.documentVersion !==
5542 elem.versionProvider(requestMessage.params)) {
5543 requestMessage.reject(
5544 // tslint:disable-next-line: no-inferred-empty-object-type
5545 new vscode_languageserver_1.ResponseError(vscode_languageserver_1.ErrorCodes.RequestCancelled, 'Request got cancelled'));
5548 let result = elem.handler(requestMessage.params, requestMessage.token);
5549 if (Thenable.is(result)) {
5550 result.then(value => {
5551 requestMessage.resolve(value);
5553 requestMessage.reject(error);
5557 requestMessage.resolve(result);
5561 let notificationMessage = message;
5562 let elem = this.notificationHandlers.get(notificationMessage.method);
5563 if (elem.versionProvider &&
5564 notificationMessage.documentVersion !== void 0 &&
5565 notificationMessage.documentVersion !==
5566 elem.versionProvider(notificationMessage.params)) {
5569 elem.handler(notificationMessage.params);
5574 let messageQueue = new BufferedMessageQueue(connection);
5575 var ValidateNotification;
5576 (function (ValidateNotification) {
5577 ValidateNotification.type = new vscode_languageserver_1.NotificationType('eslint/validate');
5578 })(ValidateNotification || (ValidateNotification = {}));
5579 messageQueue.onNotification(ValidateNotification.type, document => {
5580 validateSingle(document, true);
5582 return document.version;
5584 // The documents manager listen for text document create, change
5585 // and close on the connection
5586 documents.listen(connection);
5587 documents.onDidOpen(event => {
5588 resolveSettings(event.document).then(settings => {
5589 if (!settings.validate) {
5592 if (settings.run === 'onSave') {
5593 messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
5597 // A text document has changed. Validate the document according the run setting.
5598 documents.onDidChangeContent(event => {
5599 resolveSettings(event.document).then(settings => {
5600 if (!settings.validate || settings.run !== 'onType') {
5603 messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
5606 documents.onWillSaveWaitUntil(event => {
5607 if (event.reason === vscode_languageserver_1.TextDocumentSaveReason.AfterDelay) {
5610 let document = event.document;
5611 return resolveSettings(document).then(settings => {
5612 if (!settings.autoFixOnSave) {
5615 // If we validate on save and want to apply fixes on will save
5616 // we need to validate the file.
5617 if (settings.run === 'onSave') {
5618 // Do not queue this since we want to get the fixes as fast as possible.
5619 return validateSingle(document, false).then(() => util_1.getAllFixEdits(document, settings));
5622 return util_1.getAllFixEdits(document, settings);
5626 // A text document has been saved. Validate the document according the run setting.
5627 documents.onDidSave(event => {
5628 resolveSettings(event.document).then(settings => {
5629 if (!settings.validate || settings.run !== 'onSave') {
5632 messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
5635 documents.onDidClose(event => {
5636 resolveSettings(event.document).then(settings => {
5637 let uri = event.document.uri;
5638 document2Settings.delete(uri);
5639 codeActions.delete(uri);
5640 if (settings.validate) {
5641 connection.sendDiagnostics({ uri, diagnostics: [] });
5645 function environmentChanged() {
5646 document2Settings.clear();
5647 for (let document of documents.all()) {
5648 messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
5651 function trace(message, verbose) {
5652 connection.tracer.log(message, verbose);
5654 connection.onInitialize(_params => {
5659 change: vscode_languageserver_1.TextDocumentSyncKind.Full,
5660 willSaveWaitUntil: true,
5665 codeActionProvider: true,
5666 executeCommandProvider: {
5668 CommandIds.applySingleFix,
5669 CommandIds.applySameFixes,
5670 CommandIds.applyAllFixes,
5671 CommandIds.applyAutoFix,
5672 CommandIds.applyDisableLine,
5673 CommandIds.applyDisableFile,
5674 CommandIds.openRuleDoc,
5680 connection.onInitialized(() => {
5681 connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type, undefined);
5683 messageQueue.registerNotification(vscode_languageserver_1.DidChangeConfigurationNotification.type, _params => {
5684 environmentChanged();
5686 // messageQueue.registerNotification(
5687 // DidChangeWorkspaceFoldersNotification.type,
5689 // environmentChanged()
5692 const singleErrorHandlers = [
5694 tryHandleConfigError,
5695 tryHandleMissingModule,
5698 function validateSingle(document, publishDiagnostics = true) {
5699 // We validate document in a queue but open / close documents directly. So we need to deal with the
5700 // fact that a document might be gone from the server.
5701 if (!documents.get(document.uri)) {
5702 return Promise.resolve(undefined);
5704 return resolveSettings(document).then(settings => {
5705 if (!settings.validate) {
5709 validate(document, settings, publishDiagnostics);
5710 connection.sendNotification(StatusNotification.type, { state: Status.ok });
5714 for (let handler of singleErrorHandlers) {
5715 status = handler(err, document, settings.library);
5720 status = status || Status.error;
5721 connection.sendNotification(StatusNotification.type, { state: status });
5725 function validateMany(documents) {
5726 documents.forEach(document => {
5727 messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
5730 function getMessage(err, document) {
5732 if (typeof err.message === 'string' || err.message instanceof String) {
5733 result = err.message;
5734 result = result.replace(/\r?\n/g, ' ');
5735 if (/^CLI: /.test(result)) {
5736 result = result.substr(5);
5740 result = `An unknown error occured while validating document: ${document.uri}`;
5744 function validate(document, settings, publishDiagnostics = true) {
5745 const uri = document.uri;
5746 const content = document.getText();
5747 const newOptions = Object.assign(Object.create(null), settings.options);
5748 util_1.executeInWorkspaceDirectory(document, settings, newOptions, (file, options) => {
5749 const cli = new settings.library.CLIEngine(options);
5750 // Clean previously computed code actions.
5751 codeActions.delete(uri);
5752 const report = cli.executeOnText(content, file);
5753 const diagnostics = [];
5754 if (report && report.results && Array.isArray(report.results) && report.results.length > 0) {
5755 const docReport = report.results[0];
5756 if (docReport.messages && Array.isArray(docReport.messages)) {
5757 docReport.messages.forEach(problem => {
5759 const isWarning = convertSeverity(problem.severity) === vscode_languageserver_1.DiagnosticSeverity.Warning;
5760 if (settings.quiet && isWarning) {
5761 // Filter out warnings when quiet mode is enabled
5764 const diagnostic = makeDiagnostic(problem);
5765 diagnostics.push(diagnostic);
5766 if (settings.autoFix) {
5767 if (typeof cli.getRules === 'function' && problem.ruleId !== undefined && problem.fix !== undefined) {
5768 const rule = cli.getRules().get(problem.ruleId);
5769 if (rule !== undefined && rule.meta && typeof rule.meta.fixable == 'string') {
5770 recordCodeAction(document, diagnostic, problem);
5774 recordCodeAction(document, diagnostic, problem);
5781 if (publishDiagnostics) {
5782 connection.sendDiagnostics({ uri, diagnostics });
5784 // cache documentation urls for all rules
5785 if (typeof cli.getRules === 'function' && !ruleDocData.handled.has(uri)) {
5786 ruleDocData.handled.add(uri);
5787 cli.getRules().forEach((rule, key) => {
5788 if (rule.meta && rule.meta.docs && types_1.Is.string(rule.meta.docs.url)) {
5789 ruleDocData.urls.set(key, rule.meta.docs.url);
5795 let noConfigReported = new Map();
5796 function isNoConfigFoundError(error) {
5797 let candidate = error;
5798 return (candidate.messageTemplate === 'no-config-found' ||
5799 candidate.message === 'No ESLint configuration found.');
5801 function tryHandleNoConfig(error, document, library) {
5802 if (!isNoConfigFoundError(error)) {
5805 if (!noConfigReported.has(document.uri)) {
5807 .sendRequest(NoConfigRequest.type, {
5808 message: getMessage(error, document),
5813 .then(undefined, () => {
5816 noConfigReported.set(document.uri, library);
5820 let configErrorReported = new Map();
5821 function tryHandleConfigError(error, document, library) {
5822 if (!error.message) {
5825 function handleFileName(filename) {
5826 if (!configErrorReported.has(filename)) {
5827 connection.console.error(getMessage(error, document));
5828 if (!documents.get(vscode_uri_1.URI.file(filename).toString())) {
5829 connection.window.showInformationMessage(getMessage(error, document));
5831 configErrorReported.set(filename, library);
5835 let matches = /Cannot read config file:\s+(.*)\nError:\s+(.*)/.exec(error.message);
5836 if (matches && matches.length === 3) {
5837 return handleFileName(matches[1]);
5839 matches = /(.*):\n\s*Configuration for rule \"(.*)\" is /.exec(error.message);
5840 if (matches && matches.length === 3) {
5841 return handleFileName(matches[1]);
5843 matches = /Cannot find module '([^']*)'\nReferenced from:\s+(.*)/.exec(error.message);
5844 if (matches && matches.length === 3) {
5845 return handleFileName(matches[2]);
5849 let missingModuleReported = new Map();
5850 function tryHandleMissingModule(error, document, library) {
5851 if (!error.message) {
5854 function handleMissingModule(plugin, module, error) {
5855 if (!missingModuleReported.has(plugin)) {
5856 let fsPath = util_1.getFilePath(document);
5857 missingModuleReported.set(plugin, library);
5858 if (error.messageTemplate === 'plugin-missing') {
5859 connection.console.error([
5861 `${error.message.toString()}`,
5862 `Happened while validating ${fsPath ? fsPath : document.uri}`,
5863 `This can happen for a couple of reasons:`,
5864 `1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).`,
5865 `2. If ESLint is installed globally, then make sure ${module} is installed globally as well.`,
5866 `3. If ESLint is installed locally, then ${module} isn't installed correctly.`,
5868 `Consider running eslint --debug ${fsPath ? fsPath : document.uri} from a terminal to obtain a trace about the configuration files used.`
5872 connection.console.error([
5873 `${error.message.toString()}`,
5874 `Happend while validating ${fsPath ? fsPath : document.uri}`
5880 let matches = /Failed to load plugin (.*): Cannot find module (.*)/.exec(error.message);
5881 if (matches && matches.length === 3) {
5882 return handleMissingModule(matches[1], matches[2], error);
5886 function showErrorMessage(error, document) {
5887 connection.window.showErrorMessage(`ESLint: ${getMessage(error, document)}. Please see the 'ESLint' output channel for details.`);
5888 if (types_1.Is.string(error.stack)) {
5889 connection.console.error('ESLint stack trace:');
5890 connection.console.error(error.stack);
5892 return Status.error;
5894 messageQueue.registerNotification(vscode_languageserver_1.DidChangeWatchedFilesNotification.type, params => {
5895 // A .eslintrc has change. No smartness here.
5896 // Simply revalidate all file.
5897 noConfigReported = new Map();
5898 missingModuleReported = new Map();
5899 params.changes.forEach(change => {
5900 let fsPath = util_1.getFilePath(change.uri);
5901 if (!fsPath || util_1.isUNC(fsPath)) {
5904 let dirname = path.dirname(fsPath);
5906 let library = configErrorReported.get(fsPath);
5908 let cli = new library.CLIEngine({});
5910 cli.executeOnText('', path.join(dirname, '___test___.js'));
5911 configErrorReported.delete(fsPath);
5919 validateMany(documents.all());
5922 constructor(edits) {
5925 static overlaps(lastEdit, newEdit) {
5926 return !!lastEdit && lastEdit.edit.range[1] > newEdit.edit.range[0];
5929 return this.edits.size === 0;
5931 getDocumentVersion() {
5932 if (this.isEmpty()) {
5933 throw new Error('No edits recorded.');
5935 return this.edits.values().next().value.documentVersion;
5937 getScoped(diagnostics) {
5939 for (let diagnostic of diagnostics) {
5940 let key = computeKey(diagnostic);
5941 let editInfo = this.edits.get(key);
5943 result.push(editInfo);
5950 this.edits.forEach(value => result.push(value));
5951 return result.sort((a, b) => {
5952 let d = a.edit.range[0] - b.edit.range[0];
5956 if (a.edit.range[1] === 0) {
5959 if (b.edit.range[1] === 0) {
5962 return a.edit.range[1] - b.edit.range[1];
5966 let sorted = this.getAllSorted();
5967 if (sorted.length <= 1) {
5971 let last = sorted[0];
5973 for (let i = 1; i < sorted.length; i++) {
5974 let current = sorted[i];
5975 if (!Fixes.overlaps(last, current)) {
5976 result.push(current);
5984 messageQueue.registerRequest(vscode_languageserver_1.CodeActionRequest.type, params => {
5985 commands = new Map();
5986 let result = new CodeActionResult();
5987 let uri = params.textDocument.uri;
5988 let edits = codeActions.get(uri);
5991 let fixes = new Fixes(edits);
5992 if (fixes.isEmpty())
5994 let textDocument = documents.get(uri);
5995 let documentVersion = -1;
5996 let allFixableRuleIds = [];
5997 function createTextEdit(editInfo) {
5998 return vscode_languageserver_1.TextEdit.replace(vscode_languageserver_1.Range.create(textDocument.positionAt(editInfo.edit.range[0]), textDocument.positionAt(editInfo.edit.range[1])), editInfo.edit.text || '');
6000 function createDisableLineTextEdit(editInfo, indentationText) {
6001 return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(editInfo.line - 1, 0), `${indentationText}// eslint-disable-next-line ${editInfo.ruleId}\n`);
6003 function createDisableSameLineTextEdit(editInfo) {
6004 return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(editInfo.line - 1, Number.MAX_VALUE), ` // eslint-disable-line ${editInfo.ruleId}`);
6006 function createDisableFileTextEdit(editInfo) {
6007 return vscode_languageserver_1.TextEdit.insert(vscode_languageserver_1.Position.create(0, 0), `/* eslint-disable ${editInfo.ruleId} */\n`);
6009 function getLastEdit(array) {
6010 let length = array.length;
6014 return array[length - 1];
6016 return resolveSettings(textDocument).then(settings => {
6017 for (let editInfo of fixes.getScoped(params.context.diagnostics)) {
6018 documentVersion = editInfo.documentVersion;
6019 let ruleId = editInfo.ruleId;
6020 allFixableRuleIds.push(ruleId);
6021 if (!!editInfo.edit) {
6022 let workspaceChange = new vscode_languageserver_1.WorkspaceChange();
6023 workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createTextEdit(editInfo));
6024 commands.set(`${CommandIds.applySingleFix}:${ruleId}`, workspaceChange);
6025 result.get(ruleId).fixes.push(vscode_languageserver_1.CodeAction.create(editInfo.label, vscode_languageserver_1.Command.create(editInfo.label, CommandIds.applySingleFix, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix));
6027 if (settings.codeAction.disableRuleComment.enable) {
6028 let workspaceChange = new vscode_languageserver_1.WorkspaceChange();
6029 if (settings.codeAction.disableRuleComment.location === 'sameLine') {
6030 workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableSameLineTextEdit(editInfo));
6033 let lineText = textDocument.getText(vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(editInfo.line - 1, 0), vscode_languageserver_1.Position.create(editInfo.line - 1, Number.MAX_VALUE)));
6034 let indentationText = /^([ \t]*)/.exec(lineText)[1];
6035 workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableLineTextEdit(editInfo, indentationText));
6037 commands.set(`${CommandIds.applyDisableLine}:${ruleId}`, workspaceChange);
6038 let title = `Disable ${ruleId} for this line`;
6039 result.get(ruleId).disable = vscode_languageserver_1.CodeAction.create(title, vscode_languageserver_1.Command.create(title, CommandIds.applyDisableLine, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix);
6040 if (result.get(ruleId).disableFile === undefined) {
6041 workspaceChange = new vscode_languageserver_1.WorkspaceChange();
6042 workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableFileTextEdit(editInfo));
6043 commands.set(`${CommandIds.applyDisableFile}:${ruleId}`, workspaceChange);
6044 title = `Disable ${ruleId} for the entire file`;
6045 result.get(ruleId).disableFile = vscode_languageserver_1.CodeAction.create(title, vscode_languageserver_1.Command.create(title, CommandIds.applyDisableFile, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix);
6048 if (settings.codeAction.showDocumentation.enable && result.get(ruleId).showDocumentation === undefined) {
6049 if (ruleDocData.urls.has(ruleId)) {
6050 let title = `Show documentation for ${ruleId}`;
6051 result.get(ruleId).showDocumentation = vscode_languageserver_1.CodeAction.create(title, vscode_languageserver_1.Command.create(title, CommandIds.openRuleDoc, ruleId), vscode_languageserver_1.CodeActionKind.QuickFix);
6055 if (result.length > 0) {
6056 let sameProblems = new Map(allFixableRuleIds.map(s => [s, []]));
6058 for (let editInfo of fixes.getAllSorted()) {
6059 if (documentVersion === -1) {
6060 documentVersion = editInfo.documentVersion;
6062 if (sameProblems.has(editInfo.ruleId)) {
6063 let same = sameProblems.get(editInfo.ruleId);
6064 if (!Fixes.overlaps(getLastEdit(same), editInfo)) {
6065 same.push(editInfo);
6068 if (!Fixes.overlaps(getLastEdit(all), editInfo)) {
6072 sameProblems.forEach((same, ruleId) => {
6073 if (same.length > 1) {
6074 let sameFixes = new vscode_languageserver_1.WorkspaceChange();
6075 let sameTextChange = sameFixes.getTextEditChange({ uri, version: documentVersion });
6076 same.map(createTextEdit).forEach(edit => sameTextChange.add(edit));
6077 commands.set(CommandIds.applySameFixes, sameFixes);
6078 let title = `Fix all ${ruleId} problems`;
6079 let command = vscode_languageserver_1.Command.create(title, CommandIds.applySameFixes);
6080 result.get(ruleId).fixAll = vscode_languageserver_1.CodeAction.create(title, command, vscode_languageserver_1.CodeActionKind.QuickFix);
6083 if (all.length > 1) {
6084 let allFixes = new vscode_languageserver_1.WorkspaceChange();
6085 let allTextChange = allFixes.getTextEditChange({ uri, version: documentVersion });
6086 all.map(createTextEdit).forEach(edit => allTextChange.add(edit));
6087 commands.set(CommandIds.applyAllFixes, allFixes);
6088 let title = `Fix all auto-fixable problems`;
6089 let command = vscode_languageserver_1.Command.create(title, CommandIds.applyAllFixes);
6090 result.fixAll = vscode_languageserver_1.CodeAction.create(title, command, vscode_languageserver_1.CodeActionKind.SourceFixAll);
6093 return result.all();
6096 let document = documents.get(params.textDocument.uri);
6097 return document ? document.version : undefined;
6099 messageQueue.registerRequest(vscode_languageserver_1.ExecuteCommandRequest.type, (params) => __awaiter(void 0, void 0, void 0, function* () {
6100 let workspaceChange;
6101 if (params.command === CommandIds.applyAutoFix) {
6102 let identifier = params.arguments[0];
6103 if (!identifier.uri.startsWith('file:')) {
6106 let textDocument = documents.get(identifier.uri);
6107 let settings = yield Promise.resolve(resolveSettings(textDocument));
6108 let edits = util_1.getAllFixEdits(textDocument, settings);
6109 if (edits && edits.length) {
6110 workspaceChange = new vscode_languageserver_1.WorkspaceChange();
6111 let textChange = workspaceChange.getTextEditChange(identifier);
6112 edits.forEach(edit => textChange.add(edit));
6116 if ([CommandIds.applySingleFix, CommandIds.applyDisableLine, CommandIds.applyDisableFile].indexOf(params.command) !== -1) {
6117 let ruleId = params.arguments[0];
6118 workspaceChange = commands.get(`${params.command}:${ruleId}`);
6120 else if (params.command === CommandIds.openRuleDoc) {
6121 let ruleId = params.arguments[0];
6122 let url = ruleDocData.urls.get(ruleId);
6124 yield connection.sendRequest(OpenESLintDocRequest.type, { url });
6128 workspaceChange = commands.get(params.command);
6131 if (!workspaceChange) {
6135 let response = yield Promise.resolve(connection.workspace.applyEdit(workspaceChange.edit));
6136 if (!response.applied) {
6137 connection.console.error(`Failed to apply command: ${params.command}`);
6141 connection.console.error(`Failed to apply command: ${params.command}`);
6145 if (params.command === CommandIds.applyAutoFix) {
6146 let identifier = params.arguments[0];
6147 return identifier.version;
6153 connection.tracer.connection.listen();
6158 /***/ (function(module, exports, __webpack_require__) {
6161 /* --------------------------------------------------------------------------------------------
\r
6162 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
6163 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
6164 * ------------------------------------------------------------------------------------------ */
\r
6165 /// <reference path="../typings/thenable.d.ts" />
\r
6167 function __export(m) {
\r
6168 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
6170 Object.defineProperty(exports, "__esModule", { value: true });
\r
6171 const vscode_languageserver_protocol_1 = __webpack_require__(4);
\r
6172 exports.Event = vscode_languageserver_protocol_1.Event;
\r
6173 const configuration_1 = __webpack_require__(38);
\r
6174 const workspaceFolders_1 = __webpack_require__(40);
\r
6175 const progress_1 = __webpack_require__(41);
\r
6176 const Is = __webpack_require__(39);
\r
6177 const UUID = __webpack_require__(42);
\r
6178 // ------------- Reexport the API surface of the language worker API ----------------------
\r
6179 __export(__webpack_require__(4));
\r
6180 const fm = __webpack_require__(43);
\r
6182 (function (Files) {
\r
6183 Files.uriToFilePath = fm.uriToFilePath;
\r
6184 Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
\r
6185 Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
\r
6186 Files.resolve = fm.resolve;
\r
6187 Files.resolveModulePath = fm.resolveModulePath;
\r
6188 })(Files = exports.Files || (exports.Files = {}));
\r
6189 let shutdownReceived = false;
\r
6190 let exitTimer = undefined;
\r
6191 function setupExitTimer() {
\r
6192 const argName = '--clientProcessId';
\r
6193 function runTimer(value) {
\r
6195 let processId = parseInt(value);
\r
6196 if (!isNaN(processId)) {
\r
6197 exitTimer = setInterval(() => {
\r
6199 process.kill(processId, 0);
\r
6202 // Parent process doesn't exist anymore. Exit the server.
\r
6203 process.exit(shutdownReceived ? 0 : 1);
\r
6212 for (let i = 2; i < process.argv.length; i++) {
\r
6213 let arg = process.argv[i];
\r
6214 if (arg === argName && i + 1 < process.argv.length) {
\r
6215 runTimer(process.argv[i + 1]);
\r
6219 let args = arg.split('=');
\r
6220 if (args[0] === argName) {
\r
6221 runTimer(args[1]);
\r
6227 function null2Undefined(value) {
\r
6228 if (value === null) {
\r
6234 * A manager for simple text documents
\r
6236 class TextDocuments {
\r
6238 * Create a new text document manager.
\r
6240 constructor(configuration) {
\r
6241 this._documents = Object.create(null);
\r
6242 this._configuration = configuration;
\r
6243 this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
\r
6244 this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
\r
6245 this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
\r
6246 this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
\r
6247 this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
\r
6250 * An event that fires when a text document managed by this manager
\r
6251 * has been opened or the content changes.
\r
6253 get onDidChangeContent() {
\r
6254 return this._onDidChangeContent.event;
\r
6257 * An event that fires when a text document managed by this manager
\r
6258 * has been opened.
\r
6261 return this._onDidOpen.event;
\r
6264 * An event that fires when a text document managed by this manager
\r
6267 get onWillSave() {
\r
6268 return this._onWillSave.event;
\r
6271 * Sets a handler that will be called if a participant wants to provide
\r
6272 * edits during a text document save.
\r
6274 onWillSaveWaitUntil(handler) {
\r
6275 this._willSaveWaitUntil = handler;
\r
6278 * An event that fires when a text document managed by this manager
\r
6282 return this._onDidSave.event;
\r
6285 * An event that fires when a text document managed by this manager
\r
6286 * has been closed.
\r
6288 get onDidClose() {
\r
6289 return this._onDidClose.event;
\r
6292 * Returns the document for the given URI. Returns undefined if
\r
6293 * the document is not mananged by this instance.
\r
6295 * @param uri The text document's URI to retrieve.
\r
6296 * @return the text document or `undefined`.
\r
6299 return this._documents[uri];
\r
6302 * Returns all text documents managed by this instance.
\r
6304 * @return all text documents.
\r
6307 return Object.keys(this._documents).map(key => this._documents[key]);
\r
6310 * Returns the URIs of all text documents managed by this instance.
\r
6312 * @return the URI's of all text documents.
\r
6315 return Object.keys(this._documents);
\r
6318 * Listens for `low level` notification on the given connection to
\r
6319 * update the text documents managed by this instance.
\r
6321 * @param connection The connection to listen on.
\r
6323 listen(connection) {
\r
6324 connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
\r
6325 connection.onDidOpenTextDocument((event) => {
\r
6326 let td = event.textDocument;
\r
6327 let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
\r
6328 this._documents[td.uri] = document;
\r
6329 let toFire = Object.freeze({ document });
\r
6330 this._onDidOpen.fire(toFire);
\r
6331 this._onDidChangeContent.fire(toFire);
\r
6333 connection.onDidChangeTextDocument((event) => {
\r
6334 let td = event.textDocument;
\r
6335 let changes = event.contentChanges;
\r
6336 if (changes.length === 0) {
\r
6339 let document = this._documents[td.uri];
\r
6340 const { version } = td;
\r
6341 if (version === null || version === void 0) {
\r
6342 throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
\r
6344 document = this._configuration.update(document, changes, version);
\r
6345 this._documents[td.uri] = document;
\r
6346 this._onDidChangeContent.fire(Object.freeze({ document }));
\r
6348 connection.onDidCloseTextDocument((event) => {
\r
6349 let document = this._documents[event.textDocument.uri];
\r
6351 delete this._documents[event.textDocument.uri];
\r
6352 this._onDidClose.fire(Object.freeze({ document }));
\r
6355 connection.onWillSaveTextDocument((event) => {
\r
6356 let document = this._documents[event.textDocument.uri];
\r
6358 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
\r
6361 connection.onWillSaveTextDocumentWaitUntil((event, token) => {
\r
6362 let document = this._documents[event.textDocument.uri];
\r
6363 if (document && this._willSaveWaitUntil) {
\r
6364 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
\r
6370 connection.onDidSaveTextDocument((event) => {
\r
6371 let document = this._documents[event.textDocument.uri];
\r
6373 this._onDidSave.fire(Object.freeze({ document }));
\r
6378 exports.TextDocuments = TextDocuments;
\r
6380 * Helps tracking error message. Equal occurences of the same
\r
6381 * message are only stored once. This class is for example
\r
6382 * useful if text documents are validated in a loop and equal
\r
6383 * error message should be folded into one.
\r
6385 class ErrorMessageTracker {
\r
6387 this._messages = Object.create(null);
\r
6390 * Add a message to the tracker.
\r
6392 * @param message The message to add.
\r
6395 let count = this._messages[message];
\r
6400 this._messages[message] = count;
\r
6403 * Send all tracked messages to the connection's window.
\r
6405 * @param connection The connection established between client and server.
\r
6407 sendErrors(connection) {
\r
6408 Object.keys(this._messages).forEach(message => {
\r
6409 connection.window.showErrorMessage(message);
\r
6413 exports.ErrorMessageTracker = ErrorMessageTracker;
\r
6414 var BulkRegistration;
\r
6415 (function (BulkRegistration) {
\r
6417 * Creates a new bulk registration.
\r
6418 * @return an empty bulk registration.
\r
6420 function create() {
\r
6421 return new BulkRegistrationImpl();
\r
6423 BulkRegistration.create = create;
\r
6424 })(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
\r
6425 class BulkRegistrationImpl {
\r
6427 this._registrations = [];
\r
6428 this._registered = new Set();
\r
6430 add(type, registerOptions) {
\r
6431 const method = Is.string(type) ? type : type.method;
\r
6432 if (this._registered.has(method)) {
\r
6433 throw new Error(`${method} is already added to this registration`);
\r
6435 const id = UUID.generateUuid();
\r
6436 this._registrations.push({
\r
6439 registerOptions: registerOptions || {}
\r
6441 this._registered.add(method);
\r
6443 asRegistrationParams() {
\r
6445 registrations: this._registrations
\r
6449 var BulkUnregistration;
\r
6450 (function (BulkUnregistration) {
\r
6451 function create() {
\r
6452 return new BulkUnregistrationImpl(undefined, []);
\r
6454 BulkUnregistration.create = create;
\r
6455 })(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));
\r
6456 class BulkUnregistrationImpl {
\r
6457 constructor(_connection, unregistrations) {
\r
6458 this._connection = _connection;
\r
6459 this._unregistrations = new Map();
\r
6460 unregistrations.forEach(unregistration => {
\r
6461 this._unregistrations.set(unregistration.method, unregistration);
\r
6464 get isAttached() {
\r
6465 return !!this._connection;
\r
6467 attach(connection) {
\r
6468 this._connection = connection;
\r
6470 add(unregistration) {
\r
6471 this._unregistrations.set(unregistration.method, unregistration);
\r
6474 let unregistrations = [];
\r
6475 for (let unregistration of this._unregistrations.values()) {
\r
6476 unregistrations.push(unregistration);
\r
6479 unregisterations: unregistrations
\r
6481 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
\r
6482 this._connection.console.info(`Bulk unregistration failed.`);
\r
6485 disposeSingle(arg) {
\r
6486 const method = Is.string(arg) ? arg : arg.method;
\r
6487 const unregistration = this._unregistrations.get(method);
\r
6488 if (!unregistration) {
\r
6492 unregisterations: [unregistration]
\r
6494 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
\r
6495 this._unregistrations.delete(method);
\r
6497 this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);
\r
6502 class ConnectionLogger {
\r
6505 rawAttach(connection) {
\r
6506 this._rawConnection = connection;
\r
6508 attach(connection) {
\r
6509 this._connection = connection;
\r
6511 get connection() {
\r
6512 if (!this._connection) {
\r
6513 throw new Error('Remote is not attached to a connection yet.');
\r
6515 return this._connection;
\r
6517 fillServerCapabilities(_capabilities) {
\r
6519 initialize(_capabilities) {
\r
6522 this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
\r
6525 this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
\r
6528 this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
\r
6531 this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
\r
6533 send(type, message) {
\r
6534 if (this._rawConnection) {
\r
6535 this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
\r
6539 class _RemoteWindowImpl {
\r
6542 attach(connection) {
\r
6543 this._connection = connection;
\r
6545 get connection() {
\r
6546 if (!this._connection) {
\r
6547 throw new Error('Remote is not attached to a connection yet.');
\r
6549 return this._connection;
\r
6551 initialize(_capabilities) {
\r
6553 fillServerCapabilities(_capabilities) {
\r
6555 showErrorMessage(message, ...actions) {
\r
6556 let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
\r
6557 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
\r
6559 showWarningMessage(message, ...actions) {
\r
6560 let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
\r
6561 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
\r
6563 showInformationMessage(message, ...actions) {
\r
6564 let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
\r
6565 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
\r
6568 const RemoteWindowImpl = progress_1.ProgressFeature(_RemoteWindowImpl);
\r
6569 class RemoteClientImpl {
\r
6570 attach(connection) {
\r
6571 this._connection = connection;
\r
6573 get connection() {
\r
6574 if (!this._connection) {
\r
6575 throw new Error('Remote is not attached to a connection yet.');
\r
6577 return this._connection;
\r
6579 initialize(_capabilities) {
\r
6581 fillServerCapabilities(_capabilities) {
\r
6583 register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
\r
6584 if (typeOrRegistrations instanceof BulkRegistrationImpl) {
\r
6585 return this.registerMany(typeOrRegistrations);
\r
6587 else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
\r
6588 return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
\r
6591 return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
\r
6594 registerSingle1(unregistration, type, registerOptions) {
\r
6595 const method = Is.string(type) ? type : type.method;
\r
6596 const id = UUID.generateUuid();
\r
6598 registrations: [{ id, method, registerOptions: registerOptions || {} }]
\r
6600 if (!unregistration.isAttached) {
\r
6601 unregistration.attach(this._connection);
\r
6603 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
\r
6604 unregistration.add({ id: id, method: method });
\r
6605 return unregistration;
\r
6607 this.connection.console.info(`Registering request handler for ${method} failed.`);
\r
6608 return Promise.reject(_error);
\r
6611 registerSingle2(type, registerOptions) {
\r
6612 const method = Is.string(type) ? type : type.method;
\r
6613 const id = UUID.generateUuid();
\r
6615 registrations: [{ id, method, registerOptions: registerOptions || {} }]
\r
6617 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
\r
6618 return vscode_languageserver_protocol_1.Disposable.create(() => {
\r
6619 this.unregisterSingle(id, method);
\r
6622 this.connection.console.info(`Registering request handler for ${method} failed.`);
\r
6623 return Promise.reject(_error);
\r
6626 unregisterSingle(id, method) {
\r
6628 unregisterations: [{ id, method }]
\r
6630 return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
\r
6631 this.connection.console.info(`Unregistering request handler for ${id} failed.`);
\r
6634 registerMany(registrations) {
\r
6635 let params = registrations.asRegistrationParams();
\r
6636 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
\r
6637 return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
\r
6639 this.connection.console.info(`Bulk registration failed.`);
\r
6640 return Promise.reject(_error);
\r
6644 class _RemoteWorkspaceImpl {
\r
6647 attach(connection) {
\r
6648 this._connection = connection;
\r
6650 get connection() {
\r
6651 if (!this._connection) {
\r
6652 throw new Error('Remote is not attached to a connection yet.');
\r
6654 return this._connection;
\r
6656 initialize(_capabilities) {
\r
6658 fillServerCapabilities(_capabilities) {
\r
6660 applyEdit(paramOrEdit) {
\r
6661 function isApplyWorkspaceEditParams(value) {
\r
6662 return value && !!value.edit;
\r
6664 let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
\r
6665 return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
\r
6668 const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));
\r
6669 class TracerImpl {
\r
6671 this._trace = vscode_languageserver_protocol_1.Trace.Off;
\r
6673 attach(connection) {
\r
6674 this._connection = connection;
\r
6676 get connection() {
\r
6677 if (!this._connection) {
\r
6678 throw new Error('Remote is not attached to a connection yet.');
\r
6680 return this._connection;
\r
6682 initialize(_capabilities) {
\r
6684 fillServerCapabilities(_capabilities) {
\r
6686 set trace(value) {
\r
6687 this._trace = value;
\r
6689 log(message, verbose) {
\r
6690 if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
\r
6693 this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
\r
6695 verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
\r
6699 class TelemetryImpl {
\r
6702 attach(connection) {
\r
6703 this._connection = connection;
\r
6705 get connection() {
\r
6706 if (!this._connection) {
\r
6707 throw new Error('Remote is not attached to a connection yet.');
\r
6709 return this._connection;
\r
6711 initialize(_capabilities) {
\r
6713 fillServerCapabilities(_capabilities) {
\r
6716 this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
\r
6719 function combineConsoleFeatures(one, two) {
\r
6720 return function (Base) {
\r
6721 return two(one(Base));
\r
6724 exports.combineConsoleFeatures = combineConsoleFeatures;
\r
6725 function combineTelemetryFeatures(one, two) {
\r
6726 return function (Base) {
\r
6727 return two(one(Base));
\r
6730 exports.combineTelemetryFeatures = combineTelemetryFeatures;
\r
6731 function combineTracerFeatures(one, two) {
\r
6732 return function (Base) {
\r
6733 return two(one(Base));
\r
6736 exports.combineTracerFeatures = combineTracerFeatures;
\r
6737 function combineClientFeatures(one, two) {
\r
6738 return function (Base) {
\r
6739 return two(one(Base));
\r
6742 exports.combineClientFeatures = combineClientFeatures;
\r
6743 function combineWindowFeatures(one, two) {
\r
6744 return function (Base) {
\r
6745 return two(one(Base));
\r
6748 exports.combineWindowFeatures = combineWindowFeatures;
\r
6749 function combineWorkspaceFeatures(one, two) {
\r
6750 return function (Base) {
\r
6751 return two(one(Base));
\r
6754 exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
\r
6755 function combineFeatures(one, two) {
\r
6756 function combine(one, two, func) {
\r
6758 return func(one, two);
\r
6768 __brand: 'features',
\r
6769 console: combine(one.console, two.console, combineConsoleFeatures),
\r
6770 tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
\r
6771 telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
\r
6772 client: combine(one.client, two.client, combineClientFeatures),
\r
6773 window: combine(one.window, two.window, combineWindowFeatures),
\r
6774 workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
\r
6778 exports.combineFeatures = combineFeatures;
\r
6779 function createConnection(arg1, arg2, arg3, arg4) {
\r
6784 if (arg1 !== void 0 && arg1.__brand === 'features') {
\r
6790 if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {
\r
6798 return _createConnection(input, output, strategy, factories);
\r
6800 exports.createConnection = createConnection;
\r
6801 function _createConnection(input, output, strategy, factories) {
\r
6802 if (!input && !output && process.argv.length > 2) {
\r
6803 let port = void 0;
\r
6804 let pipeName = void 0;
\r
6805 let argv = process.argv.slice(2);
\r
6806 for (let i = 0; i < argv.length; i++) {
\r
6807 let arg = argv[i];
\r
6808 if (arg === '--node-ipc') {
\r
6809 input = new vscode_languageserver_protocol_1.IPCMessageReader(process);
\r
6810 output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);
\r
6813 else if (arg === '--stdio') {
\r
6814 input = process.stdin;
\r
6815 output = process.stdout;
\r
6818 else if (arg === '--socket') {
\r
6819 port = parseInt(argv[i + 1]);
\r
6822 else if (arg === '--pipe') {
\r
6823 pipeName = argv[i + 1];
\r
6827 var args = arg.split('=');
\r
6828 if (args[0] === '--socket') {
\r
6829 port = parseInt(args[1]);
\r
6832 else if (args[0] === '--pipe') {
\r
6833 pipeName = args[1];
\r
6839 let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);
\r
6840 input = transport[0];
\r
6841 output = transport[1];
\r
6843 else if (pipeName) {
\r
6844 let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);
\r
6845 input = transport[0];
\r
6846 output = transport[1];
\r
6849 var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
\r
6851 throw new Error('Connection input stream is not set. ' + commandLineMessage);
\r
6854 throw new Error('Connection output stream is not set. ' + commandLineMessage);
\r
6856 // Backwards compatibility
\r
6857 if (Is.func(input.read) && Is.func(input.on)) {
\r
6858 let inputStream = input;
\r
6859 inputStream.on('end', () => {
\r
6860 process.exit(shutdownReceived ? 0 : 1);
\r
6862 inputStream.on('close', () => {
\r
6863 process.exit(shutdownReceived ? 0 : 1);
\r
6866 const logger = (factories && factories.console ? new (factories.console(ConnectionLogger))() : new ConnectionLogger());
\r
6867 const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);
\r
6868 logger.rawAttach(connection);
\r
6869 const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
\r
6870 const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
\r
6871 const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
\r
6872 const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
\r
6873 const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
\r
6874 const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace];
\r
6875 function asPromise(value) {
\r
6876 if (value instanceof Promise) {
\r
6879 else if (Is.thenable(value)) {
\r
6880 return new Promise((resolve, reject) => {
\r
6881 value.then((resolved) => resolve(resolved), (error) => reject(error));
\r
6885 return Promise.resolve(value);
\r
6888 let shutdownHandler = undefined;
\r
6889 let initializeHandler = undefined;
\r
6890 let exitHandler = undefined;
\r
6891 let protocolConnection = {
\r
6892 listen: () => connection.listen(),
\r
6893 sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
\r
6894 onRequest: (type, handler) => connection.onRequest(type, handler),
\r
6895 sendNotification: (type, param) => {
\r
6896 const method = Is.string(type) ? type : type.method;
\r
6897 if (arguments.length === 1) {
\r
6898 connection.sendNotification(method);
\r
6901 connection.sendNotification(method, param);
\r
6904 onNotification: (type, handler) => connection.onNotification(type, handler),
\r
6905 onProgress: connection.onProgress,
\r
6906 sendProgress: connection.sendProgress,
\r
6907 onInitialize: (handler) => initializeHandler = handler,
\r
6908 onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
\r
6909 onShutdown: (handler) => shutdownHandler = handler,
\r
6910 onExit: (handler) => exitHandler = handler,
\r
6911 get console() { return logger; },
\r
6912 get telemetry() { return telemetry; },
\r
6913 get tracer() { return tracer; },
\r
6914 get client() { return client; },
\r
6915 get window() { return remoteWindow; },
\r
6916 get workspace() { return workspace; },
\r
6917 onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
\r
6918 onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
\r
6919 __textDocumentSync: undefined,
\r
6920 onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
\r
6921 onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
\r
6922 onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
\r
6923 onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
\r
6924 onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
\r
6925 onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
\r
6926 sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
\r
6927 onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
\r
6928 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
6930 onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
\r
6931 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6933 onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
\r
6934 onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
\r
6935 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
6937 onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
\r
6938 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6940 onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
\r
6941 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6943 onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
\r
6944 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6946 onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
\r
6947 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6949 onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
\r
6950 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6952 onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
\r
6953 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6955 onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
\r
6956 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6958 onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
\r
6959 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6961 onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
\r
6962 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6964 onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
\r
6965 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6967 onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, handler),
\r
6968 onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
\r
6969 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
6971 onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
\r
6972 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
6974 onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, handler),
\r
6975 onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
\r
6976 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
6978 onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
\r
6979 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
6981 onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
\r
6982 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6984 onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, handler),
\r
6985 onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
\r
6986 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6988 onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
\r
6989 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6991 onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
\r
6992 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6994 onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
\r
6995 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
\r
6997 onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
\r
6998 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
\r
7000 dispose: () => connection.dispose()
\r
7002 for (let remote of allRemotes) {
\r
7003 remote.attach(protocolConnection);
\r
7005 connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
\r
7006 const processId = params.processId;
\r
7007 if (Is.number(processId) && exitTimer === void 0) {
\r
7008 // We received a parent process id. Set up a timer to periodically check
\r
7009 // if the parent is still alive.
\r
7010 setInterval(() => {
\r
7012 process.kill(processId, 0);
\r
7015 // Parent process doesn't exist anymore. Exit the server.
\r
7016 process.exit(shutdownReceived ? 0 : 1);
\r
7020 if (Is.string(params.trace)) {
\r
7021 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
\r
7023 for (let remote of allRemotes) {
\r
7024 remote.initialize(params.capabilities);
\r
7026 if (initializeHandler) {
\r
7027 let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, progress_1.attachWorkDone(connection, params), undefined);
\r
7028 return asPromise(result).then((value) => {
\r
7029 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
\r
7032 let result = value;
\r
7034 result = { capabilities: {} };
\r
7036 let capabilities = result.capabilities;
\r
7037 if (!capabilities) {
\r
7038 capabilities = {};
\r
7039 result.capabilities = capabilities;
\r
7041 if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {
\r
7042 capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
\r
7044 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
\r
7045 capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
\r
7047 for (let remote of allRemotes) {
\r
7048 remote.fillServerCapabilities(capabilities);
\r
7054 let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
\r
7055 for (let remote of allRemotes) {
\r
7056 remote.fillServerCapabilities(result.capabilities);
\r
7061 connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
\r
7062 shutdownReceived = true;
\r
7063 if (shutdownHandler) {
\r
7064 return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
\r
7070 connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
\r
7072 if (exitHandler) {
\r
7077 if (shutdownReceived) {
\r
7085 connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
\r
7086 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
\r
7088 return protocolConnection;
\r
7090 // Export the protocol currently in proposed state.
\r
7091 var ProposedFeatures;
\r
7092 (function (ProposedFeatures) {
\r
7093 ProposedFeatures.all = {
\r
7094 __brand: 'features'
\r
7096 })(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
\r
7097 //# sourceMappingURL=main.js.map
7101 /***/ (function(module, exports, __webpack_require__) {
7104 /* --------------------------------------------------------------------------------------------
\r
7105 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7106 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
7107 * ------------------------------------------------------------------------------------------ */
\r
7109 Object.defineProperty(exports, "__esModule", { value: true });
\r
7110 const vscode_languageserver_protocol_1 = __webpack_require__(4);
\r
7111 const Is = __webpack_require__(39);
\r
7112 exports.ConfigurationFeature = (Base) => {
\r
7113 return class extends Base {
\r
7114 getConfiguration(arg) {
\r
7116 return this._getConfiguration({});
\r
7118 else if (Is.string(arg)) {
\r
7119 return this._getConfiguration({ section: arg });
\r
7122 return this._getConfiguration(arg);
\r
7125 _getConfiguration(arg) {
\r
7127 items: Array.isArray(arg) ? arg : [arg]
\r
7129 return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {
\r
7130 return Array.isArray(arg) ? result : result[0];
\r
7135 //# sourceMappingURL=configuration.js.map
7139 /***/ (function(module, exports, __webpack_require__) {
7142 /* --------------------------------------------------------------------------------------------
\r
7143 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7144 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
7145 * ------------------------------------------------------------------------------------------ */
\r
7147 Object.defineProperty(exports, "__esModule", { value: true });
\r
7148 function boolean(value) {
\r
7149 return value === true || value === false;
\r
7151 exports.boolean = boolean;
\r
7152 function string(value) {
\r
7153 return typeof value === 'string' || value instanceof String;
\r
7155 exports.string = string;
\r
7156 function number(value) {
\r
7157 return typeof value === 'number' || value instanceof Number;
\r
7159 exports.number = number;
\r
7160 function error(value) {
\r
7161 return value instanceof Error;
\r
7163 exports.error = error;
\r
7164 function func(value) {
\r
7165 return typeof value === 'function';
\r
7167 exports.func = func;
\r
7168 function array(value) {
\r
7169 return Array.isArray(value);
\r
7171 exports.array = array;
\r
7172 function stringArray(value) {
\r
7173 return array(value) && value.every(elem => string(elem));
\r
7175 exports.stringArray = stringArray;
\r
7176 function typedArray(value, check) {
\r
7177 return Array.isArray(value) && value.every(check);
\r
7179 exports.typedArray = typedArray;
\r
7180 function thenable(value) {
\r
7181 return value && func(value.then);
\r
7183 exports.thenable = thenable;
\r
7184 //# sourceMappingURL=is.js.map
7188 /***/ (function(module, exports, __webpack_require__) {
7191 /* --------------------------------------------------------------------------------------------
\r
7192 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7193 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
7194 * ------------------------------------------------------------------------------------------ */
\r
7196 Object.defineProperty(exports, "__esModule", { value: true });
\r
7197 const vscode_languageserver_protocol_1 = __webpack_require__(4);
\r
7198 exports.WorkspaceFoldersFeature = (Base) => {
\r
7199 return class extends Base {
\r
7200 initialize(capabilities) {
\r
7201 let workspaceCapabilities = capabilities.workspace;
\r
7202 if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
\r
7203 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
\r
7204 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
\r
7205 this._onDidChangeWorkspaceFolders.fire(params.event);
\r
7209 getWorkspaceFolders() {
\r
7210 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
\r
7212 get onDidChangeWorkspaceFolders() {
\r
7213 if (!this._onDidChangeWorkspaceFolders) {
\r
7214 throw new Error('Client doesn\'t support sending workspace folder change events.');
\r
7216 if (!this._unregistration) {
\r
7217 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
\r
7219 return this._onDidChangeWorkspaceFolders.event;
\r
7223 //# sourceMappingURL=workspaceFolders.js.map
7227 /***/ (function(module, exports, __webpack_require__) {
7230 /* --------------------------------------------------------------------------------------------
\r
7231 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7232 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
7233 * ------------------------------------------------------------------------------------------ */
\r
7235 Object.defineProperty(exports, "__esModule", { value: true });
\r
7236 const vscode_languageserver_protocol_1 = __webpack_require__(4);
\r
7237 const uuid_1 = __webpack_require__(42);
\r
7238 class WorkDoneProgressImpl {
\r
7239 constructor(_connection, _token) {
\r
7240 this._connection = _connection;
\r
7241 this._token = _token;
\r
7242 WorkDoneProgressImpl.Instances.set(this._token, this);
\r
7243 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
\r
7246 return this._source.token;
\r
7248 begin(title, percentage, message, cancellable) {
\r
7256 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
\r
7258 report(arg0, arg1) {
\r
7262 if (typeof arg0 === 'number') {
\r
7263 param.percentage = arg0;
\r
7264 if (arg1 !== undefined) {
\r
7265 param.message = arg1;
\r
7269 param.message = arg0;
\r
7271 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
\r
7274 WorkDoneProgressImpl.Instances.delete(this._token);
\r
7275 this._source.dispose();
\r
7276 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, { kind: 'end' });
\r
7279 this._source.cancel();
\r
7282 WorkDoneProgressImpl.Instances = new Map();
\r
7283 class NullProgress {
\r
7285 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
\r
7288 return this._source.token;
\r
7297 function attachWorkDone(connection, params) {
\r
7298 if (params === undefined || params.workDoneToken === undefined) {
\r
7299 return new NullProgress();
\r
7301 const token = params.workDoneToken;
\r
7302 delete params.workDoneToken;
\r
7303 return new WorkDoneProgressImpl(connection, token);
\r
7305 exports.attachWorkDone = attachWorkDone;
\r
7306 exports.ProgressFeature = (Base) => {
\r
7307 return class extends Base {
\r
7308 initialize(capabilities) {
\r
7310 if (((_b = (_a = capabilities) === null || _a === void 0 ? void 0 : _a.window) === null || _b === void 0 ? void 0 : _b.workDoneProgress) === true) {
\r
7311 this._progressSupported = true;
\r
7312 this.connection.onNotification(vscode_languageserver_protocol_1.WorkDoneProgressCancelNotification.type, (params) => {
\r
7313 let progress = WorkDoneProgressImpl.Instances.get(params.token);
\r
7314 if (progress !== undefined) {
\r
7315 progress.cancel();
\r
7320 attachWorkDoneProgress(token) {
\r
7321 if (token === undefined) {
\r
7322 return new NullProgress();
\r
7325 return new WorkDoneProgressImpl(this.connection, token);
\r
7328 createWorkDoneProgress() {
\r
7329 if (this._progressSupported) {
\r
7330 const token = uuid_1.generateUuid();
\r
7331 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkDoneProgressCreateRequest.type, { token }).then(() => {
\r
7332 const result = new WorkDoneProgressImpl(this.connection, token);
\r
7337 return Promise.resolve(new NullProgress());
\r
7342 var ResultProgress;
\r
7343 (function (ResultProgress) {
\r
7344 ResultProgress.type = new vscode_languageserver_protocol_1.ProgressType();
\r
7345 })(ResultProgress || (ResultProgress = {}));
\r
7346 class ResultProgressImpl {
\r
7347 constructor(_connection, _token) {
\r
7348 this._connection = _connection;
\r
7349 this._token = _token;
\r
7352 this._connection.sendProgress(ResultProgress.type, this._token, data);
\r
7355 function attachPartialResult(connection, params) {
\r
7356 if (params === undefined || params.partialResultToken === undefined) {
\r
7359 const token = params.partialResultToken;
\r
7360 delete params.partialResultToken;
\r
7361 return new ResultProgressImpl(connection, token);
\r
7363 exports.attachPartialResult = attachPartialResult;
\r
7364 //# sourceMappingURL=progress.js.map
7368 /***/ (function(module, exports, __webpack_require__) {
7371 /*---------------------------------------------------------------------------------------------
\r
7372 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7373 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
7374 *--------------------------------------------------------------------------------------------*/
\r
7376 Object.defineProperty(exports, "__esModule", { value: true });
\r
7378 constructor(_value) {
\r
7379 this._value = _value;
\r
7383 return this._value;
\r
7386 return this.asHex() === other.asHex();
\r
7389 class V4UUID extends ValueUUID {
\r
7392 V4UUID._randomHex(),
\r
7393 V4UUID._randomHex(),
\r
7394 V4UUID._randomHex(),
\r
7395 V4UUID._randomHex(),
\r
7396 V4UUID._randomHex(),
\r
7397 V4UUID._randomHex(),
\r
7398 V4UUID._randomHex(),
\r
7399 V4UUID._randomHex(),
\r
7401 V4UUID._randomHex(),
\r
7402 V4UUID._randomHex(),
\r
7403 V4UUID._randomHex(),
\r
7404 V4UUID._randomHex(),
\r
7407 V4UUID._randomHex(),
\r
7408 V4UUID._randomHex(),
\r
7409 V4UUID._randomHex(),
\r
7411 V4UUID._oneOf(V4UUID._timeHighBits),
\r
7412 V4UUID._randomHex(),
\r
7413 V4UUID._randomHex(),
\r
7414 V4UUID._randomHex(),
\r
7416 V4UUID._randomHex(),
\r
7417 V4UUID._randomHex(),
\r
7418 V4UUID._randomHex(),
\r
7419 V4UUID._randomHex(),
\r
7420 V4UUID._randomHex(),
\r
7421 V4UUID._randomHex(),
\r
7422 V4UUID._randomHex(),
\r
7423 V4UUID._randomHex(),
\r
7424 V4UUID._randomHex(),
\r
7425 V4UUID._randomHex(),
\r
7426 V4UUID._randomHex(),
\r
7427 V4UUID._randomHex(),
\r
7430 static _oneOf(array) {
\r
7431 return array[Math.floor(array.length * Math.random())];
\r
7433 static _randomHex() {
\r
7434 return V4UUID._oneOf(V4UUID._chars);
\r
7437 V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
\r
7438 V4UUID._timeHighBits = ['8', '9', 'a', 'b'];
\r
7440 * An empty UUID that contains only zeros.
\r
7442 exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
\r
7444 return new V4UUID();
\r
7447 const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
\r
7448 function isUUID(value) {
\r
7449 return _UUIDPattern.test(value);
\r
7451 exports.isUUID = isUUID;
\r
7453 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
\r
7454 * @param value A uuid string.
\r
7456 function parse(value) {
\r
7457 if (!isUUID(value)) {
\r
7458 throw new Error('invalid uuid');
\r
7460 return new ValueUUID(value);
\r
7462 exports.parse = parse;
\r
7463 function generateUuid() {
\r
7464 return v4().asHex();
\r
7466 exports.generateUuid = generateUuid;
\r
7467 //# sourceMappingURL=uuid.js.map
7471 /***/ (function(module, exports, __webpack_require__) {
7474 /* WEBPACK VAR INJECTION */(function(__filename) {/* --------------------------------------------------------------------------------------------
\r
7475 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
7476 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
7477 * ------------------------------------------------------------------------------------------ */
\r
7479 Object.defineProperty(exports, "__esModule", { value: true });
\r
7480 const url = __webpack_require__(44);
\r
7481 const path = __webpack_require__(3);
\r
7482 const fs = __webpack_require__(2);
\r
7483 const child_process_1 = __webpack_require__(45);
\r
7485 * @deprecated Use the `vscode-uri` npm module which provides a more
\r
7486 * complete implementation of handling VS Code URIs.
\r
7488 function uriToFilePath(uri) {
\r
7489 let parsed = url.parse(uri);
\r
7490 if (parsed.protocol !== 'file:' || !parsed.path) {
\r
7493 let segments = parsed.path.split('/');
\r
7494 for (var i = 0, len = segments.length; i < len; i++) {
\r
7495 segments[i] = decodeURIComponent(segments[i]);
\r
7497 if (process.platform === 'win32' && segments.length > 1) {
\r
7498 let first = segments[0];
\r
7499 let second = segments[1];
\r
7500 // Do we have a drive letter and we started with a / which is the
\r
7501 // case if the first segement is empty (see split above)
\r
7502 if (first.length === 0 && second.length > 1 && second[1] === ':') {
\r
7503 // Remove first slash
\r
7507 return path.normalize(segments.join('/'));
\r
7509 exports.uriToFilePath = uriToFilePath;
\r
7510 function isWindows() {
\r
7511 return process.platform === 'win32';
\r
7513 function resolve(moduleName, nodePath, cwd, tracer) {
\r
7514 const nodePathKey = 'NODE_PATH';
\r
7516 'var p = process;',
\r
7517 'p.on(\'message\',function(m){',
\r
7518 'if(m.c===\'e\'){',
\r
7521 'else if(m.c===\'rs\'){',
\r
7523 'var r=require.resolve(m.a);',
\r
7524 'p.send({c:\'r\',s:true,r:r});',
\r
7527 'p.send({c:\'r\',s:false});',
\r
7532 return new Promise((resolve, reject) => {
\r
7533 let env = process.env;
\r
7534 let newEnv = Object.create(null);
\r
7535 Object.keys(env).forEach(key => newEnv[key] = env[key]);
\r
7536 if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
\r
7537 if (newEnv[nodePathKey]) {
\r
7538 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
\r
7541 newEnv[nodePathKey] = nodePath;
\r
7544 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
\r
7547 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
\r
7549 let cp = child_process_1.fork('', [], {
\r
7552 execArgv: ['-e', app]
\r
7554 if (cp.pid === void 0) {
\r
7555 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
\r
7558 cp.on('error', (error) => {
\r
7561 cp.on('message', (message) => {
\r
7562 if (message.c === 'r') {
\r
7563 cp.send({ c: 'e' });
\r
7565 resolve(message.r);
\r
7568 reject(new Error(`Failed to resolve module: ${moduleName}`));
\r
7583 exports.resolve = resolve;
\r
7585 * Resolve the global npm package path.
\r
7586 * @deprecated Since this depends on the used package manager and their version the best is that servers
\r
7587 * implement this themselves since they know best what kind of package managers to support.
\r
7588 * @param tracer the tracer to use
\r
7590 function resolveGlobalNodePath(tracer) {
\r
7591 let npmCommand = 'npm';
\r
7592 const env = Object.create(null);
\r
7593 Object.keys(process.env).forEach(key => env[key] = process.env[key]);
\r
7594 env['NO_UPDATE_NOTIFIER'] = 'true';
\r
7599 if (isWindows()) {
\r
7600 npmCommand = 'npm.cmd';
\r
7601 options.shell = true;
\r
7603 let handler = () => { };
\r
7605 process.on('SIGPIPE', handler);
\r
7606 let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
\r
7609 tracer(`'npm config get prefix' didn't return a value.`);
\r
7613 let prefix = stdout.trim();
\r
7615 tracer(`'npm config get prefix' value is: ${prefix}`);
\r
7617 if (prefix.length > 0) {
\r
7618 if (isWindows()) {
\r
7619 return path.join(prefix, 'node_modules');
\r
7622 return path.join(prefix, 'lib', 'node_modules');
\r
7631 process.removeListener('SIGPIPE', handler);
\r
7634 exports.resolveGlobalNodePath = resolveGlobalNodePath;
\r
7636 * Resolve the global yarn pakage path.
\r
7637 * @deprecated Since this depends on the used package manager and their version the best is that servers
\r
7638 * implement this themselves since they know best what kind of package managers to support.
\r
7639 * @param tracer the tracer to use
\r
7641 function resolveGlobalYarnPath(tracer) {
\r
7642 let yarnCommand = 'yarn';
\r
7646 if (isWindows()) {
\r
7647 yarnCommand = 'yarn.cmd';
\r
7648 options.shell = true;
\r
7650 let handler = () => { };
\r
7652 process.on('SIGPIPE', handler);
\r
7653 let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);
\r
7654 let stdout = results.stdout;
\r
7657 tracer(`'yarn global dir' didn't return a value.`);
\r
7658 if (results.stderr) {
\r
7659 tracer(results.stderr);
\r
7664 let lines = stdout.trim().split(/\r?\n/);
\r
7665 for (let line of lines) {
\r
7667 let yarn = JSON.parse(line);
\r
7668 if (yarn.type === 'log') {
\r
7669 return path.join(yarn.data, 'node_modules');
\r
7673 // Do nothing. Ignore the line
\r
7682 process.removeListener('SIGPIPE', handler);
\r
7685 exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
\r
7687 (function (FileSystem) {
\r
7688 let _isCaseSensitive = undefined;
\r
7689 function isCaseSensitive() {
\r
7690 if (_isCaseSensitive !== void 0) {
\r
7691 return _isCaseSensitive;
\r
7693 if (process.platform === 'win32') {
\r
7694 _isCaseSensitive = false;
\r
7697 // convert current file name to upper case / lower case and check if file exists
\r
7698 // (guards against cases when name is already all uppercase or lowercase)
\r
7699 _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
\r
7701 return _isCaseSensitive;
\r
7703 FileSystem.isCaseSensitive = isCaseSensitive;
\r
7704 function isParent(parent, child) {
\r
7705 if (isCaseSensitive()) {
\r
7706 return path.normalize(child).indexOf(path.normalize(parent)) === 0;
\r
7709 return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
\r
7712 FileSystem.isParent = isParent;
\r
7713 })(FileSystem = exports.FileSystem || (exports.FileSystem = {}));
\r
7714 function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
\r
7716 if (!path.isAbsolute(nodePath)) {
\r
7717 nodePath = path.join(workspaceRoot, nodePath);
\r
7719 return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
\r
7720 if (FileSystem.isParent(nodePath, value)) {
\r
7724 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
\r
7726 }).then(undefined, (_error) => {
\r
7727 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
\r
7731 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
\r
7734 exports.resolveModulePath = resolveModulePath;
\r
7735 //# sourceMappingURL=files.js.map
7736 /* WEBPACK VAR INJECTION */}.call(this, "/index.js"))
7740 /***/ (function(module, exports) {
7742 module.exports = require("url");
7746 /***/ (function(module, exports) {
7748 module.exports = require("child_process");
7752 /***/ (function(module, __webpack_exports__, __webpack_require__) {
7755 __webpack_require__.r(__webpack_exports__);
7756 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "URI", function() { return URI; });
7757 /*---------------------------------------------------------------------------------------------
7758 * Copyright (c) Microsoft Corporation. All rights reserved.
7759 * Licensed under the MIT License. See License.txt in the project root for license information.
7760 *--------------------------------------------------------------------------------------------*/
7762 var __extends = (undefined && undefined.__extends) || (function () {
7763 var extendStatics = function (d, b) {
7764 extendStatics = Object.setPrototypeOf ||
7765 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7766 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7767 return extendStatics(d, b);
7769 return function (d, b) {
7770 extendStatics(d, b);
7771 function __() { this.constructor = d; }
7772 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7777 if (typeof process === 'object') {
7778 isWindows = process.platform === 'win32';
7780 else if (typeof navigator === 'object') {
7781 var userAgent = navigator.userAgent;
7782 isWindows = userAgent.indexOf('Windows') >= 0;
7784 function isHighSurrogate(charCode) {
7785 return (0xD800 <= charCode && charCode <= 0xDBFF);
7787 function isLowSurrogate(charCode) {
7788 return (0xDC00 <= charCode && charCode <= 0xDFFF);
7790 function isLowerAsciiHex(code) {
7791 return code >= 97 /* a */ && code <= 102 /* f */;
7793 function isLowerAsciiLetter(code) {
7794 return code >= 97 /* a */ && code <= 122 /* z */;
7796 function isUpperAsciiLetter(code) {
7797 return code >= 65 /* A */ && code <= 90 /* Z */;
7799 function isAsciiLetter(code) {
7800 return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);
7803 var _schemePattern = /^\w[\w\d+.-]*$/;
7804 var _singleSlashStart = /^\//;
7805 var _doubleSlashStart = /^\/\//;
7806 function _validateUri(ret, _strict) {
7807 // scheme, must be set
7808 if (!ret.scheme && _strict) {
7809 throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
7811 // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
7812 // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
7813 if (ret.scheme && !_schemePattern.test(ret.scheme)) {
7814 throw new Error('[UriError]: Scheme contains illegal characters.');
7816 // path, http://tools.ietf.org/html/rfc3986#section-3.3
7817 // If a URI contains an authority component, then the path component
7818 // must either be empty or begin with a slash ("/") character. If a URI
7819 // does not contain an authority component, then the path cannot begin
7820 // with two slash characters ("//").
7822 if (ret.authority) {
7823 if (!_singleSlashStart.test(ret.path)) {
7824 throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
7828 if (_doubleSlashStart.test(ret.path)) {
7829 throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
7834 // for a while we allowed uris *without* schemes and this is the migration
7835 // for them, e.g. an uri without scheme and without strict-mode warns and falls
7836 // back to the file-scheme. that should cause the least carnage and still be a
7838 function _schemeFix(scheme, _strict) {
7839 if (!scheme && !_strict) {
7844 // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
7845 function _referenceResolution(scheme, path) {
7846 // the slash-character is our 'default base' as we don't
7847 // support constructing URIs relative to other URIs. This
7848 // also means that we alter and potentially break paths.
7849 // see https://tools.ietf.org/html/rfc3986#section-5.1.4
7857 else if (path[0] !== _slash) {
7858 path = _slash + path;
7866 var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
7868 * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
7869 * This class is a simple parser which creates the basic component parts
7870 * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
7873 * foo://example.com:8042/over/there?name=ferret#nose
7874 * \_/ \______________/\_________/ \_________/ \__/
7876 * scheme authority path query fragment
7877 * | _____________________|__
7879 * urn:example:animal:ferret:nose
7881 var URI = /** @class */ (function () {
7885 function URI(schemeOrData, authority, path, query, fragment, _strict) {
7886 if (_strict === void 0) { _strict = false; }
7887 if (typeof schemeOrData === 'object') {
7888 this.scheme = schemeOrData.scheme || _empty;
7889 this.authority = schemeOrData.authority || _empty;
7890 this.path = schemeOrData.path || _empty;
7891 this.query = schemeOrData.query || _empty;
7892 this.fragment = schemeOrData.fragment || _empty;
7893 // no validation because it's this URI
7894 // that creates uri components.
7895 // _validateUri(this);
7898 this.scheme = _schemeFix(schemeOrData, _strict);
7899 this.authority = authority || _empty;
7900 this.path = _referenceResolution(this.scheme, path || _empty);
7901 this.query = query || _empty;
7902 this.fragment = fragment || _empty;
7903 _validateUri(this, _strict);
7906 URI.isUri = function (thing) {
7907 if (thing instanceof URI) {
7913 return typeof thing.authority === 'string'
7914 && typeof thing.fragment === 'string'
7915 && typeof thing.path === 'string'
7916 && typeof thing.query === 'string'
7917 && typeof thing.scheme === 'string'
7918 && typeof thing.fsPath === 'function'
7919 && typeof thing.with === 'function'
7920 && typeof thing.toString === 'function';
7922 Object.defineProperty(URI.prototype, "fsPath", {
7923 // ---- filesystem path -----------------------
7925 * Returns a string representing the corresponding file system path of this URI.
7926 * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
7927 * platform specific path separator.
7929 * * Will *not* validate the path for invalid characters and semantics.
7930 * * Will *not* look at the scheme of this URI.
7931 * * The result shall *not* be used for display purposes but for accessing a file on disk.
7934 * The *difference* to `URI#path` is the use of the platform specific separator and the handling
7935 * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
7938 const u = URI.parse('file://server/c$/folder/file.txt')
7939 u.authority === 'server'
7940 u.path === '/shares/c$/file.txt'
7941 u.fsPath === '\\server\c$\folder\file.txt'
7944 * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
7945 * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
7946 * with URIs that represent files on disk (`file` scheme).
7949 // if (this.scheme !== 'file') {
7950 // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
7952 return _makeFsPath(this);
7957 // ---- modify to new -------------------------
7958 URI.prototype.with = function (change) {
7962 var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
7963 if (scheme === undefined) {
7964 scheme = this.scheme;
7966 else if (scheme === null) {
7969 if (authority === undefined) {
7970 authority = this.authority;
7972 else if (authority === null) {
7975 if (path === undefined) {
7978 else if (path === null) {
7981 if (query === undefined) {
7984 else if (query === null) {
7987 if (fragment === undefined) {
7988 fragment = this.fragment;
7990 else if (fragment === null) {
7993 if (scheme === this.scheme
7994 && authority === this.authority
7995 && path === this.path
7996 && query === this.query
7997 && fragment === this.fragment) {
8000 return new _URI(scheme, authority, path, query, fragment);
8002 // ---- parse & validate ------------------------
8004 * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
8005 * `file:///usr/home`, or `scheme:with/path`.
8007 * @param value A string which represents an URI (see `URI#toString`).
8009 URI.parse = function (value, _strict) {
8010 if (_strict === void 0) { _strict = false; }
8011 var match = _regexp.exec(value);
8013 return new _URI(_empty, _empty, _empty, _empty, _empty);
8015 return new _URI(match[2] || _empty, decodeURIComponent(match[4] || _empty), decodeURIComponent(match[5] || _empty), decodeURIComponent(match[7] || _empty), decodeURIComponent(match[9] || _empty), _strict);
8018 * Creates a new URI from a file system path, e.g. `c:\my\files`,
8019 * `/usr/home`, or `\\server\share\some\path`.
8021 * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
8022 * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
8023 * `URI.parse('file://' + path)` because the path might contain characters that are
8024 * interpreted (# and ?). See the following sample:
8026 const good = URI.file('/coding/c#/project1');
8027 good.scheme === 'file';
8028 good.path === '/coding/c#/project1';
8029 good.fragment === '';
8030 const bad = URI.parse('file://' + '/coding/c#/project1');
8031 bad.scheme === 'file';
8032 bad.path === '/coding/c'; // path is now broken
8033 bad.fragment === '/project1';
8036 * @param path A file system path (see `URI#fsPath`)
8038 URI.file = function (path) {
8039 var authority = _empty;
8040 // normalize to fwd-slashes on windows,
8041 // on other systems bwd-slashes are valid
8042 // filename character, eg /f\oo/ba\r.txt
8044 path = path.replace(/\\/g, _slash);
8046 // check for authority as used in UNC shares
8047 // or use the path as given
8048 if (path[0] === _slash && path[1] === _slash) {
8049 var idx = path.indexOf(_slash, 2);
8051 authority = path.substring(2);
8055 authority = path.substring(2, idx);
8056 path = path.substring(idx) || _slash;
8059 return new _URI('file', authority, path, _empty, _empty);
8061 URI.from = function (components) {
8062 return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
8064 // ---- printing/externalize ---------------------------
8066 * Creates a string representation for this URI. It's guaranteed that calling
8067 * `URI.parse` with the result of this function creates an URI which is equal
8070 * * The result shall *not* be used for display purposes but for externalization or transport.
8071 * * The result will be encoded using the percentage encoding and encoding happens mostly
8072 * ignore the scheme-specific encoding rules.
8074 * @param skipEncoding Do not encode the result, default is `false`
8076 URI.prototype.toString = function (skipEncoding) {
8077 if (skipEncoding === void 0) { skipEncoding = false; }
8078 return _asFormatted(this, skipEncoding);
8080 URI.prototype.toJSON = function () {
8083 URI.revive = function (data) {
8087 else if (data instanceof URI) {
8091 var result = new _URI(data);
8092 result._formatted = data.external;
8093 result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
8100 var _pathSepMarker = isWindows ? 1 : undefined;
8101 // tslint:disable-next-line:class-name
8102 var _URI = /** @class */ (function (_super) {
8103 __extends(_URI, _super);
8105 var _this = _super !== null && _super.apply(this, arguments) || this;
8106 _this._formatted = null;
8107 _this._fsPath = null;
8110 Object.defineProperty(_URI.prototype, "fsPath", {
8112 if (!this._fsPath) {
8113 this._fsPath = _makeFsPath(this);
8115 return this._fsPath;
8120 _URI.prototype.toString = function (skipEncoding) {
8121 if (skipEncoding === void 0) { skipEncoding = false; }
8122 if (!skipEncoding) {
8123 if (!this._formatted) {
8124 this._formatted = _asFormatted(this, false);
8126 return this._formatted;
8129 // we don't cache that
8130 return _asFormatted(this, true);
8133 _URI.prototype.toJSON = function () {
8139 res.fsPath = this._fsPath;
8140 res._sep = _pathSepMarker;
8142 if (this._formatted) {
8143 res.external = this._formatted;
8147 res.path = this.path;
8150 res.scheme = this.scheme;
8152 if (this.authority) {
8153 res.authority = this.authority;
8156 res.query = this.query;
8158 if (this.fragment) {
8159 res.fragment = this.fragment;
8165 // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
8166 var encodeTable = (_a = {},
8167 _a[58 /* Colon */] = '%3A',
8168 _a[47 /* Slash */] = '%2F',
8169 _a[63 /* QuestionMark */] = '%3F',
8170 _a[35 /* Hash */] = '%23',
8171 _a[91 /* OpenSquareBracket */] = '%5B',
8172 _a[93 /* CloseSquareBracket */] = '%5D',
8173 _a[64 /* AtSign */] = '%40',
8174 _a[33 /* ExclamationMark */] = '%21',
8175 _a[36 /* DollarSign */] = '%24',
8176 _a[38 /* Ampersand */] = '%26',
8177 _a[39 /* SingleQuote */] = '%27',
8178 _a[40 /* OpenParen */] = '%28',
8179 _a[41 /* CloseParen */] = '%29',
8180 _a[42 /* Asterisk */] = '%2A',
8181 _a[43 /* Plus */] = '%2B',
8182 _a[44 /* Comma */] = '%2C',
8183 _a[59 /* Semicolon */] = '%3B',
8184 _a[61 /* Equals */] = '%3D',
8185 _a[32 /* Space */] = '%20',
8187 function encodeURIComponentFast(uriComponent, allowSlash) {
8188 var res = undefined;
8189 var nativeEncodePos = -1;
8190 for (var pos = 0; pos < uriComponent.length; pos++) {
8191 var code = uriComponent.charCodeAt(pos);
8192 // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
8193 if ((code >= 97 /* a */ && code <= 122 /* z */)
8194 || (code >= 65 /* A */ && code <= 90 /* Z */)
8195 || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
8196 || code === 45 /* Dash */
8197 || code === 46 /* Period */
8198 || code === 95 /* Underline */
8199 || code === 126 /* Tilde */
8200 || (allowSlash && code === 47 /* Slash */)) {
8201 // check if we are delaying native encode
8202 if (nativeEncodePos !== -1) {
8203 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
8204 nativeEncodePos = -1;
8206 // check if we write into a new string (by default we try to return the param)
8207 if (res !== undefined) {
8208 res += uriComponent.charAt(pos);
8212 // encoding needed, we need to allocate a new string
8213 if (res === undefined) {
8214 res = uriComponent.substr(0, pos);
8216 // check with default table first
8217 var escaped = encodeTable[code];
8218 if (escaped !== undefined) {
8219 // check if we are delaying native encode
8220 if (nativeEncodePos !== -1) {
8221 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
8222 nativeEncodePos = -1;
8224 // append escaped variant to result
8227 else if (nativeEncodePos === -1) {
8228 // use native encode only when needed
8229 nativeEncodePos = pos;
8233 if (nativeEncodePos !== -1) {
8234 res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
8236 return res !== undefined ? res : uriComponent;
8238 function encodeURIComponentMinimal(path) {
8239 var res = undefined;
8240 for (var pos = 0; pos < path.length; pos++) {
8241 var code = path.charCodeAt(pos);
8242 if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
8243 if (res === undefined) {
8244 res = path.substr(0, pos);
8246 res += encodeTable[code];
8249 if (res !== undefined) {
8254 return res !== undefined ? res : path;
8257 * Compute `fsPath` for the given uri
8259 function _makeFsPath(uri) {
8261 if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
8262 // unc path: file://shares/c$/far/boo
8263 value = "//" + uri.authority + uri.path;
8265 else if (uri.path.charCodeAt(0) === 47 /* Slash */
8266 && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
8267 && uri.path.charCodeAt(2) === 58 /* Colon */) {
8268 // windows drive letter: file:///c:/far/boo
8269 value = uri.path[1].toLowerCase() + uri.path.substr(2);
8276 value = value.replace(/\//g, '\\');
8281 * Create the external version of a uri
8283 function _asFormatted(uri, skipEncoding) {
8284 var encoder = !skipEncoding
8285 ? encodeURIComponentFast
8286 : encodeURIComponentMinimal;
8288 var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
8293 if (authority || scheme === 'file') {
8298 var idx = authority.indexOf('@');
8301 var userinfo = authority.substr(0, idx);
8302 authority = authority.substr(idx + 1);
8303 idx = userinfo.indexOf(':');
8305 res += encoder(userinfo, false);
8308 // <user>:<pass>@<auth>
8309 res += encoder(userinfo.substr(0, idx), false);
8311 res += encoder(userinfo.substr(idx + 1), false);
8315 authority = authority.toLowerCase();
8316 idx = authority.indexOf(':');
8318 res += encoder(authority, false);
8322 res += encoder(authority.substr(0, idx), false);
8323 res += authority.substr(idx);
8327 // lower-case windows drive letters in /C:/fff or C:/fff
8328 if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
8329 var code = path.charCodeAt(1);
8330 if (code >= 65 /* A */ && code <= 90 /* Z */) {
8331 path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
8334 else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
8335 var code = path.charCodeAt(0);
8336 if (code >= 65 /* A */ && code <= 90 /* Z */) {
8337 path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
8340 // encode the rest of the path
8341 res += encoder(path, true);
8345 res += encoder(query, false);
8349 res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
8357 /***/ (function(module, exports, __webpack_require__) {
8361 Object.defineProperty(exports, "__esModule", { value: true });
8364 const toString = Object.prototype.toString;
8365 function boolean(value) {
8366 return value === true || value === false;
8368 Is.boolean = boolean;
8369 function string(value) {
8370 return toString.call(value) === '[object String]';
8373 })(Is = exports.Is || (exports.Is = {}));
8375 (function (DirectoryItem) {
8377 let candidate = item;
8378 return (candidate &&
8379 Is.string(candidate.directory) &&
8380 (Is.boolean(candidate.changeProcessCWD) ||
8381 candidate.changeProcessCWD === void 0));
8383 DirectoryItem.is = is;
8384 })(DirectoryItem = exports.DirectoryItem || (exports.DirectoryItem = {}));
8389 /***/ (function(module, exports, __webpack_require__) {
8393 var __importStar = (this && this.__importStar) || function (mod) {
8394 if (mod && mod.__esModule) return mod;
8396 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
8397 result["default"] = mod;
8400 var __importDefault = (this && this.__importDefault) || function (mod) {
8401 return (mod && mod.__esModule) ? mod : { "default": mod };
8403 Object.defineProperty(exports, "__esModule", { value: true });
8404 const path = __importStar(__webpack_require__(3));
8405 const fast_diff_1 = __importDefault(__webpack_require__(49));
8406 const types_1 = __webpack_require__(47);
8407 const vscode_uri_1 = __webpack_require__(46);
8408 const resolve_from_1 = __importDefault(__webpack_require__(50));
8410 * Check if the path follows this pattern: `\\hostname\sharename`.
8412 * @see https://msdn.microsoft.com/en-us/library/gg465305.aspx
8413 * @return A boolean indication if the path is a UNC path, on none-windows
8416 function isUNC(path) {
8417 if (process.platform !== 'win32') {
8418 // UNC is a windows concept
8421 if (!path || path.length < 5) {
8425 let code = path.charCodeAt(0);
8426 if (code !== 92 /* Backslash */) {
8429 code = path.charCodeAt(1);
8430 if (code !== 92 /* Backslash */) {
8435 for (; pos < path.length; pos++) {
8436 code = path.charCodeAt(pos);
8437 if (code === 92 /* Backslash */) {
8441 if (start === pos) {
8444 code = path.charCodeAt(pos + 1);
8445 if (isNaN(code) || code === 92 /* Backslash */) {
8450 exports.isUNC = isUNC;
8451 function getFileSystemPath(uri) {
8452 let result = uri.fsPath;
8453 if (process.platform === 'win32' && result.length >= 2 && result[1] === ':') {
8454 // Node by default uses an upper case drive letter and ESLint uses
8455 // === to compare pathes which results in the equal check failing
8456 // if the drive letter is lower case in th URI. Ensure upper case.
8457 return result[0].toUpperCase() + result.substr(1);
8463 function getFilePath(documentOrUri) {
8464 if (!documentOrUri) {
8467 let uri = types_1.Is.string(documentOrUri)
8468 ? vscode_uri_1.URI.parse(documentOrUri)
8469 : vscode_uri_1.URI.parse(documentOrUri.uri);
8470 if (uri.scheme !== 'file') {
8473 return getFileSystemPath(uri);
8475 exports.getFilePath = getFilePath;
8476 function getAllFixEdits(document, settings) {
8477 const uri = vscode_uri_1.URI.parse(document.uri);
8478 if (uri.scheme != 'file')
8480 const content = document.getText();
8481 const newOptions = Object.assign(Object.assign({}, settings.options), { fix: true });
8482 return executeInWorkspaceDirectory(document, settings, newOptions, (filename, options) => {
8483 if (!settings.validate) {
8486 const engine = new settings.library.CLIEngine(options);
8487 const res = engine.executeOnText(content, filename);
8488 if (!res.results.length)
8490 const { output } = res.results[0];
8493 const change = getChange(content, output);
8496 start: document.positionAt(change.start),
8497 end: document.positionAt(change.end)
8499 newText: change.newText
8503 exports.getAllFixEdits = getAllFixEdits;
8504 function getChange(oldStr, newStr) {
8505 let result = fast_diff_1.default(oldStr, newStr, 1);
8511 for (let item of result) {
8512 let [t, str] = item;
8515 curr = curr + str.length;
8517 remain = remain + str;
8523 newText = newText + remain + str;
8527 newText = newText + remain;
8528 end = curr + str.length;
8532 curr = curr + str.length;
8535 return { start, end, newText };
8537 exports.getChange = getChange;
8538 function resolveModule(name, localPath, globalPath) {
8540 let path = resolve_from_1.default.silent(localPath, name);
8542 return Promise.resolve(path);
8545 let path = resolve_from_1.default(globalPath, name);
8546 return Promise.resolve(path);
8549 return Promise.reject(e);
8552 exports.resolveModule = resolveModule;
8553 function executeInWorkspaceDirectory(document, settings, newOptions, callback) {
8554 const filename = getFilePath(document);
8555 const cwd = process.cwd();
8558 if (settings.workingDirectory) {
8559 newOptions.cwd = settings.workingDirectory.directory;
8560 if (settings.workingDirectory.changeProcessCWD) {
8561 process.chdir(settings.workingDirectory.directory);
8564 else if (settings.workspaceFolder) {
8565 const workspaceFolderUri = vscode_uri_1.URI.parse(settings.workspaceFolder.uri);
8566 if (workspaceFolderUri.scheme === 'file') {
8567 const fsPath = getFileSystemPath(workspaceFolderUri);
8568 newOptions.cwd = fsPath;
8569 process.chdir(fsPath);
8572 else if (!settings.workspaceFolder && !isUNC(filename)) {
8573 const directory = path.dirname(filename);
8574 if (directory && path.isAbsolute(directory))
8575 newOptions.cwd = directory;
8578 return callback(filename, newOptions);
8581 if (cwd !== process.cwd())
8585 exports.executeInWorkspaceDirectory = executeInWorkspaceDirectory;
8590 /***/ (function(module, exports) {
8593 * This library modifies the diff-patch-match library by Neil Fraser
8594 * by removing the patch and match functionality and certain advanced
8595 * options in the diff function. The original license is as follows:
8599 * Diff Match and Patch
8601 * Copyright 2006 Google Inc.
8602 * http://code.google.com/p/google-diff-match-patch/
8604 * Licensed under the Apache License, Version 2.0 (the "License");
8605 * you may not use this file except in compliance with the License.
8606 * You may obtain a copy of the License at
8608 * http://www.apache.org/licenses/LICENSE-2.0
8610 * Unless required by applicable law or agreed to in writing, software
8611 * distributed under the License is distributed on an "AS IS" BASIS,
8612 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8613 * See the License for the specific language governing permissions and
8614 * limitations under the License.
8619 * The data structure representing a diff is an array of tuples:
8620 * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
8621 * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
8623 var DIFF_DELETE = -1;
8624 var DIFF_INSERT = 1;
8629 * Find the differences between two texts. Simplifies the problem by stripping
8630 * any common prefix or suffix off the texts before diffing.
8631 * @param {string} text1 Old string to be diffed.
8632 * @param {string} text2 New string to be diffed.
8633 * @param {Int|Object} [cursor_pos] Edit position in text1 or object with more info
8634 * @return {Array} Array of diff tuples.
8636 function diff_main(text1, text2, cursor_pos, _fix_unicode) {
8637 // Check for equality
8638 if (text1 === text2) {
8640 return [[DIFF_EQUAL, text1]];
8645 if (cursor_pos != null) {
8646 var editdiff = find_cursor_edit_diff(text1, text2, cursor_pos);
8652 // Trim off common prefix (speedup).
8653 var commonlength = diff_commonPrefix(text1, text2);
8654 var commonprefix = text1.substring(0, commonlength);
8655 text1 = text1.substring(commonlength);
8656 text2 = text2.substring(commonlength);
8658 // Trim off common suffix (speedup).
8659 commonlength = diff_commonSuffix(text1, text2);
8660 var commonsuffix = text1.substring(text1.length - commonlength);
8661 text1 = text1.substring(0, text1.length - commonlength);
8662 text2 = text2.substring(0, text2.length - commonlength);
8664 // Compute the diff on the middle block.
8665 var diffs = diff_compute_(text1, text2);
8667 // Restore the prefix and suffix.
8669 diffs.unshift([DIFF_EQUAL, commonprefix]);
8672 diffs.push([DIFF_EQUAL, commonsuffix]);
8674 diff_cleanupMerge(diffs, _fix_unicode);
8680 * Find the differences between two texts. Assumes that the texts do not
8681 * have any common prefix or suffix.
8682 * @param {string} text1 Old string to be diffed.
8683 * @param {string} text2 New string to be diffed.
8684 * @return {Array} Array of diff tuples.
8686 function diff_compute_(text1, text2) {
8690 // Just add some text (speedup).
8691 return [[DIFF_INSERT, text2]];
8695 // Just delete some text (speedup).
8696 return [[DIFF_DELETE, text1]];
8699 var longtext = text1.length > text2.length ? text1 : text2;
8700 var shorttext = text1.length > text2.length ? text2 : text1;
8701 var i = longtext.indexOf(shorttext);
8703 // Shorter text is inside the longer text (speedup).
8705 [DIFF_INSERT, longtext.substring(0, i)],
8706 [DIFF_EQUAL, shorttext],
8707 [DIFF_INSERT, longtext.substring(i + shorttext.length)]
8709 // Swap insertions for deletions if diff is reversed.
8710 if (text1.length > text2.length) {
8711 diffs[0][0] = diffs[2][0] = DIFF_DELETE;
8716 if (shorttext.length === 1) {
8717 // Single character string.
8718 // After the previous speedup, the character can't be an equality.
8719 return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
8722 // Check to see if the problem can be split in two.
8723 var hm = diff_halfMatch_(text1, text2);
8725 // A half-match was found, sort out the return data.
8726 var text1_a = hm[0];
8727 var text1_b = hm[1];
8728 var text2_a = hm[2];
8729 var text2_b = hm[3];
8730 var mid_common = hm[4];
8731 // Send both pairs off for separate processing.
8732 var diffs_a = diff_main(text1_a, text2_a);
8733 var diffs_b = diff_main(text1_b, text2_b);
8734 // Merge the results.
8735 return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
8738 return diff_bisect_(text1, text2);
8743 * Find the 'middle snake' of a diff, split the problem in two
8744 * and return the recursively constructed diff.
8745 * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
8746 * @param {string} text1 Old string to be diffed.
8747 * @param {string} text2 New string to be diffed.
8748 * @return {Array} Array of diff tuples.
8751 function diff_bisect_(text1, text2) {
8752 // Cache the text lengths to prevent multiple calls.
8753 var text1_length = text1.length;
8754 var text2_length = text2.length;
8755 var max_d = Math.ceil((text1_length + text2_length) / 2);
8756 var v_offset = max_d;
8757 var v_length = 2 * max_d;
8758 var v1 = new Array(v_length);
8759 var v2 = new Array(v_length);
8760 // Setting all elements to -1 is faster in Chrome & Firefox than mixing
8761 // integers and undefined.
8762 for (var x = 0; x < v_length; x++) {
8766 v1[v_offset + 1] = 0;
8767 v2[v_offset + 1] = 0;
8768 var delta = text1_length - text2_length;
8769 // If the total number of characters is odd, then the front path will collide
8770 // with the reverse path.
8771 var front = (delta % 2 !== 0);
8772 // Offsets for start and end of k loop.
8773 // Prevents mapping of space beyond the grid.
8778 for (var d = 0; d < max_d; d++) {
8779 // Walk the front path one step.
8780 for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
8781 var k1_offset = v_offset + k1;
8783 if (k1 === -d || (k1 !== d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
8784 x1 = v1[k1_offset + 1];
8786 x1 = v1[k1_offset - 1] + 1;
8790 x1 < text1_length && y1 < text2_length &&
8791 text1.charAt(x1) === text2.charAt(y1)
8797 if (x1 > text1_length) {
8798 // Ran off the right of the graph.
8800 } else if (y1 > text2_length) {
8801 // Ran off the bottom of the graph.
8804 var k2_offset = v_offset + delta - k1;
8805 if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] !== -1) {
8806 // Mirror x2 onto top-left coordinate system.
8807 var x2 = text1_length - v2[k2_offset];
8809 // Overlap detected.
8810 return diff_bisectSplit_(text1, text2, x1, y1);
8816 // Walk the reverse path one step.
8817 for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
8818 var k2_offset = v_offset + k2;
8820 if (k2 === -d || (k2 !== d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
8821 x2 = v2[k2_offset + 1];
8823 x2 = v2[k2_offset - 1] + 1;
8827 x2 < text1_length && y2 < text2_length &&
8828 text1.charAt(text1_length - x2 - 1) === text2.charAt(text2_length - y2 - 1)
8834 if (x2 > text1_length) {
8835 // Ran off the left of the graph.
8837 } else if (y2 > text2_length) {
8838 // Ran off the top of the graph.
8840 } else if (!front) {
8841 var k1_offset = v_offset + delta - k2;
8842 if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] !== -1) {
8843 var x1 = v1[k1_offset];
8844 var y1 = v_offset + x1 - k1_offset;
8845 // Mirror x2 onto top-left coordinate system.
8846 x2 = text1_length - x2;
8848 // Overlap detected.
8849 return diff_bisectSplit_(text1, text2, x1, y1);
8855 // Diff took too long and hit the deadline or
8856 // number of diffs equals number of characters, no commonality at all.
8857 return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
8862 * Given the location of the 'middle snake', split the diff in two parts
8864 * @param {string} text1 Old string to be diffed.
8865 * @param {string} text2 New string to be diffed.
8866 * @param {number} x Index of split point in text1.
8867 * @param {number} y Index of split point in text2.
8868 * @return {Array} Array of diff tuples.
8870 function diff_bisectSplit_(text1, text2, x, y) {
8871 var text1a = text1.substring(0, x);
8872 var text2a = text2.substring(0, y);
8873 var text1b = text1.substring(x);
8874 var text2b = text2.substring(y);
8876 // Compute both diffs serially.
8877 var diffs = diff_main(text1a, text2a);
8878 var diffsb = diff_main(text1b, text2b);
8880 return diffs.concat(diffsb);
8885 * Determine the common prefix of two strings.
8886 * @param {string} text1 First string.
8887 * @param {string} text2 Second string.
8888 * @return {number} The number of characters common to the start of each
8891 function diff_commonPrefix(text1, text2) {
8892 // Quick check for common null cases.
8893 if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
8897 // Performance analysis: http://neil.fraser.name/news/2007/10/09/
8899 var pointermax = Math.min(text1.length, text2.length);
8900 var pointermid = pointermax;
8901 var pointerstart = 0;
8902 while (pointermin < pointermid) {
8904 text1.substring(pointerstart, pointermid) ==
8905 text2.substring(pointerstart, pointermid)
8907 pointermin = pointermid;
8908 pointerstart = pointermin;
8910 pointermax = pointermid;
8912 pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
8915 if (is_surrogate_pair_start(text1.charCodeAt(pointermid - 1))) {
8924 * Determine the common suffix of two strings.
8925 * @param {string} text1 First string.
8926 * @param {string} text2 Second string.
8927 * @return {number} The number of characters common to the end of each string.
8929 function diff_commonSuffix(text1, text2) {
8930 // Quick check for common null cases.
8931 if (!text1 || !text2 || text1.slice(-1) !== text2.slice(-1)) {
8935 // Performance analysis: http://neil.fraser.name/news/2007/10/09/
8937 var pointermax = Math.min(text1.length, text2.length);
8938 var pointermid = pointermax;
8940 while (pointermin < pointermid) {
8942 text1.substring(text1.length - pointermid, text1.length - pointerend) ==
8943 text2.substring(text2.length - pointermid, text2.length - pointerend)
8945 pointermin = pointermid;
8946 pointerend = pointermin;
8948 pointermax = pointermid;
8950 pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
8953 if (is_surrogate_pair_end(text1.charCodeAt(text1.length - pointermid))) {
8962 * Do the two texts share a substring which is at least half the length of the
8964 * This speedup can produce non-minimal diffs.
8965 * @param {string} text1 First string.
8966 * @param {string} text2 Second string.
8967 * @return {Array.<string>} Five element Array, containing the prefix of
8968 * text1, the suffix of text1, the prefix of text2, the suffix of
8969 * text2 and the common middle. Or null if there was no match.
8971 function diff_halfMatch_(text1, text2) {
8972 var longtext = text1.length > text2.length ? text1 : text2;
8973 var shorttext = text1.length > text2.length ? text2 : text1;
8974 if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
8975 return null; // Pointless.
8979 * Does a substring of shorttext exist within longtext such that the substring
8980 * is at least half the length of longtext?
8981 * Closure, but does not reference any external variables.
8982 * @param {string} longtext Longer string.
8983 * @param {string} shorttext Shorter string.
8984 * @param {number} i Start index of quarter length substring within longtext.
8985 * @return {Array.<string>} Five element Array, containing the prefix of
8986 * longtext, the suffix of longtext, the prefix of shorttext, the suffix
8987 * of shorttext and the common middle. Or null if there was no match.
8990 function diff_halfMatchI_(longtext, shorttext, i) {
8991 // Start with a 1/4 length substring at position i as a seed.
8992 var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
8994 var best_common = '';
8995 var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
8996 while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
8997 var prefixLength = diff_commonPrefix(
8998 longtext.substring(i), shorttext.substring(j));
8999 var suffixLength = diff_commonSuffix(
9000 longtext.substring(0, i), shorttext.substring(0, j));
9001 if (best_common.length < suffixLength + prefixLength) {
9002 best_common = shorttext.substring(
9003 j - suffixLength, j) + shorttext.substring(j, j + prefixLength);
9004 best_longtext_a = longtext.substring(0, i - suffixLength);
9005 best_longtext_b = longtext.substring(i + prefixLength);
9006 best_shorttext_a = shorttext.substring(0, j - suffixLength);
9007 best_shorttext_b = shorttext.substring(j + prefixLength);
9010 if (best_common.length * 2 >= longtext.length) {
9012 best_longtext_a, best_longtext_b,
9013 best_shorttext_a, best_shorttext_b, best_common
9020 // First check if the second quarter is the seed for a half-match.
9021 var hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4));
9022 // Check again based on the third quarter.
9023 var hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
9032 // Both matched. Select the longest.
9033 hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
9036 // A half-match was found, sort out the return data.
9037 var text1_a, text1_b, text2_a, text2_b;
9038 if (text1.length > text2.length) {
9049 var mid_common = hm[4];
9050 return [text1_a, text1_b, text2_a, text2_b, mid_common];
9055 * Reorder and merge like edit sections. Merge equalities.
9056 * Any edit section can move as long as it doesn't cross an equality.
9057 * @param {Array} diffs Array of diff tuples.
9058 * @param {boolean} fix_unicode Whether to normalize to a unicode-correct diff
9060 function diff_cleanupMerge(diffs, fix_unicode) {
9061 diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
9063 var count_delete = 0;
9064 var count_insert = 0;
9065 var text_delete = '';
9066 var text_insert = '';
9068 while (pointer < diffs.length) {
9069 if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
9070 diffs.splice(pointer, 1);
9073 switch (diffs[pointer][0]) {
9077 text_insert += diffs[pointer][1];
9082 text_delete += diffs[pointer][1];
9086 var previous_equality = pointer - count_insert - count_delete - 1;
9088 // prevent splitting of unicode surrogate pairs. when fix_unicode is true,
9089 // we assume that the old and new text in the diff are complete and correct
9090 // unicode-encoded JS strings, but the tuple boundaries may fall between
9091 // surrogate pairs. we fix this by shaving off stray surrogates from the end
9092 // of the previous equality and the beginning of this equality. this may create
9093 // empty equalities or a common prefix or suffix. for example, if AB and AC are
9094 // emojis, `[[0, 'A'], [-1, 'BA'], [0, 'C']]` would turn into deleting 'ABAC' and
9095 // inserting 'AC', and then the common suffix 'AC' will be eliminated. in this
9096 // particular case, both equalities go away, we absorb any previous inequalities,
9097 // and we keep scanning for the next equality before rewriting the tuples.
9098 if (previous_equality >= 0 && ends_with_pair_start(diffs[previous_equality][1])) {
9099 var stray = diffs[previous_equality][1].slice(-1);
9100 diffs[previous_equality][1] = diffs[previous_equality][1].slice(0, -1);
9101 text_delete = stray + text_delete;
9102 text_insert = stray + text_insert;
9103 if (!diffs[previous_equality][1]) {
9104 // emptied out previous equality, so delete it and include previous delete/insert
9105 diffs.splice(previous_equality, 1);
9107 var k = previous_equality - 1;
9108 if (diffs[k] && diffs[k][0] === DIFF_INSERT) {
9110 text_insert = diffs[k][1] + text_insert;
9113 if (diffs[k] && diffs[k][0] === DIFF_DELETE) {
9115 text_delete = diffs[k][1] + text_delete;
9118 previous_equality = k;
9121 if (starts_with_pair_end(diffs[pointer][1])) {
9122 var stray = diffs[pointer][1].charAt(0);
9123 diffs[pointer][1] = diffs[pointer][1].slice(1);
9124 text_delete += stray;
9125 text_insert += stray;
9128 if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
9129 // for empty equality not at end, wait for next equality
9130 diffs.splice(pointer, 1);
9133 if (text_delete.length > 0 || text_insert.length > 0) {
9134 // note that diff_commonPrefix and diff_commonSuffix are unicode-aware
9135 if (text_delete.length > 0 && text_insert.length > 0) {
9136 // Factor out any common prefixes.
9137 commonlength = diff_commonPrefix(text_insert, text_delete);
9138 if (commonlength !== 0) {
9139 if (previous_equality >= 0) {
9140 diffs[previous_equality][1] += text_insert.substring(0, commonlength);
9142 diffs.splice(0, 0, [DIFF_EQUAL, text_insert.substring(0, commonlength)]);
9145 text_insert = text_insert.substring(commonlength);
9146 text_delete = text_delete.substring(commonlength);
9148 // Factor out any common suffixes.
9149 commonlength = diff_commonSuffix(text_insert, text_delete);
9150 if (commonlength !== 0) {
9152 text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
9153 text_insert = text_insert.substring(0, text_insert.length - commonlength);
9154 text_delete = text_delete.substring(0, text_delete.length - commonlength);
9157 // Delete the offending records and add the merged ones.
9158 var n = count_insert + count_delete;
9159 if (text_delete.length === 0 && text_insert.length === 0) {
9160 diffs.splice(pointer - n, n);
9161 pointer = pointer - n;
9162 } else if (text_delete.length === 0) {
9163 diffs.splice(pointer - n, n, [DIFF_INSERT, text_insert]);
9164 pointer = pointer - n + 1;
9165 } else if (text_insert.length === 0) {
9166 diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete]);
9167 pointer = pointer - n + 1;
9169 diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete], [DIFF_INSERT, text_insert]);
9170 pointer = pointer - n + 2;
9173 if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
9174 // Merge this equality with the previous one.
9175 diffs[pointer - 1][1] += diffs[pointer][1];
9176 diffs.splice(pointer, 1);
9187 if (diffs[diffs.length - 1][1] === '') {
9188 diffs.pop(); // Remove the dummy entry at the end.
9191 // Second pass: look for single edits surrounded on both sides by equalities
9192 // which can be shifted sideways to eliminate an equality.
9193 // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
9194 var changes = false;
9196 // Intentionally ignore the first and last element (don't need checking).
9197 while (pointer < diffs.length - 1) {
9198 if (diffs[pointer - 1][0] === DIFF_EQUAL &&
9199 diffs[pointer + 1][0] === DIFF_EQUAL) {
9200 // This is a single edit surrounded by equalities.
9201 if (diffs[pointer][1].substring(diffs[pointer][1].length -
9202 diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
9203 // Shift the edit over the previous equality.
9204 diffs[pointer][1] = diffs[pointer - 1][1] +
9205 diffs[pointer][1].substring(0, diffs[pointer][1].length -
9206 diffs[pointer - 1][1].length);
9207 diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
9208 diffs.splice(pointer - 1, 1);
9210 } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
9211 diffs[pointer + 1][1]) {
9212 // Shift the edit over the next equality.
9213 diffs[pointer - 1][1] += diffs[pointer + 1][1];
9215 diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
9216 diffs[pointer + 1][1];
9217 diffs.splice(pointer + 1, 1);
9223 // If shifts were made, the diff needs reordering and another shift sweep.
9225 diff_cleanupMerge(diffs, fix_unicode);
9229 function is_surrogate_pair_start(charCode) {
9230 return charCode >= 0xD800 && charCode <= 0xDBFF;
9233 function is_surrogate_pair_end(charCode) {
9234 return charCode >= 0xDC00 && charCode <= 0xDFFF;
9237 function starts_with_pair_end(str) {
9238 return is_surrogate_pair_end(str.charCodeAt(0));
9241 function ends_with_pair_start(str) {
9242 return is_surrogate_pair_start(str.charCodeAt(str.length - 1));
9245 function remove_empty_tuples(tuples) {
9247 for (var i = 0; i < tuples.length; i++) {
9248 if (tuples[i][1].length > 0) {
9249 ret.push(tuples[i]);
9255 function make_edit_splice(before, oldMiddle, newMiddle, after) {
9256 if (ends_with_pair_start(before) || starts_with_pair_end(after)) {
9259 return remove_empty_tuples([
9260 [DIFF_EQUAL, before],
9261 [DIFF_DELETE, oldMiddle],
9262 [DIFF_INSERT, newMiddle],
9267 function find_cursor_edit_diff(oldText, newText, cursor_pos) {
9268 // note: this runs after equality check has ruled out exact equality
9269 var oldRange = typeof cursor_pos === 'number' ?
9270 { index: cursor_pos, length: 0 } : cursor_pos.oldRange;
9271 var newRange = typeof cursor_pos === 'number' ?
9272 null : cursor_pos.newRange;
9273 // take into account the old and new selection to generate the best diff
9274 // possible for a text edit. for example, a text change from "xxx" to "xx"
9275 // could be a delete or forwards-delete of any one of the x's, or the
9276 // result of selecting two of the x's and typing "x".
9277 var oldLength = oldText.length;
9278 var newLength = newText.length;
9279 if (oldRange.length === 0 && (newRange === null || newRange.length === 0)) {
9280 // see if we have an insert or delete before or after cursor
9281 var oldCursor = oldRange.index;
9282 var oldBefore = oldText.slice(0, oldCursor);
9283 var oldAfter = oldText.slice(oldCursor);
9284 var maybeNewCursor = newRange ? newRange.index : null;
9286 // is this an insert or delete right before oldCursor?
9287 var newCursor = oldCursor + newLength - oldLength;
9288 if (maybeNewCursor !== null && maybeNewCursor !== newCursor) {
9291 if (newCursor < 0 || newCursor > newLength) {
9294 var newBefore = newText.slice(0, newCursor);
9295 var newAfter = newText.slice(newCursor);
9296 if (newAfter !== oldAfter) {
9299 var prefixLength = Math.min(oldCursor, newCursor);
9300 var oldPrefix = oldBefore.slice(0, prefixLength);
9301 var newPrefix = newBefore.slice(0, prefixLength);
9302 if (oldPrefix !== newPrefix) {
9305 var oldMiddle = oldBefore.slice(prefixLength);
9306 var newMiddle = newBefore.slice(prefixLength);
9307 return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldAfter);
9310 // is this an insert or delete right after oldCursor?
9311 if (maybeNewCursor !== null && maybeNewCursor !== oldCursor) {
9314 var cursor = oldCursor;
9315 var newBefore = newText.slice(0, cursor);
9316 var newAfter = newText.slice(cursor);
9317 if (newBefore !== oldBefore) {
9320 var suffixLength = Math.min(oldLength - cursor, newLength - cursor);
9321 var oldSuffix = oldAfter.slice(oldAfter.length - suffixLength);
9322 var newSuffix = newAfter.slice(newAfter.length - suffixLength);
9323 if (oldSuffix !== newSuffix) {
9326 var oldMiddle = oldAfter.slice(0, oldAfter.length - suffixLength);
9327 var newMiddle = newAfter.slice(0, newAfter.length - suffixLength);
9328 return make_edit_splice(oldBefore, oldMiddle, newMiddle, oldSuffix);
9331 if (oldRange.length > 0 && newRange && newRange.length === 0) {
9333 // see if diff could be a splice of the old selection range
9334 var oldPrefix = oldText.slice(0, oldRange.index);
9335 var oldSuffix = oldText.slice(oldRange.index + oldRange.length);
9336 var prefixLength = oldPrefix.length;
9337 var suffixLength = oldSuffix.length;
9338 if (newLength < prefixLength + suffixLength) {
9341 var newPrefix = newText.slice(0, prefixLength);
9342 var newSuffix = newText.slice(newLength - suffixLength);
9343 if (oldPrefix !== newPrefix || oldSuffix !== newSuffix) {
9346 var oldMiddle = oldText.slice(prefixLength, oldLength - suffixLength);
9347 var newMiddle = newText.slice(prefixLength, newLength - suffixLength);
9348 return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldSuffix);
9355 function diff(text1, text2, cursor_pos) {
9356 // only pass fix_unicode=true at the top level, not when diff_main is
9357 // recursively invoked
9358 return diff_main(text1, text2, cursor_pos, true);
9361 diff.INSERT = DIFF_INSERT;
9362 diff.DELETE = DIFF_DELETE;
9363 diff.EQUAL = DIFF_EQUAL;
9365 module.exports = diff;
9370 /***/ (function(module, exports, __webpack_require__) {
9374 const path = __webpack_require__(3);
9375 const Module = __webpack_require__(51);
9376 const fs = __webpack_require__(2);
9378 const resolveFrom = (fromDirectory, moduleId, silent) => {
9379 if (typeof fromDirectory !== 'string') {
9380 throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDirectory}\``);
9383 if (typeof moduleId !== 'string') {
9384 throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
9388 fromDirectory = fs.realpathSync(fromDirectory);
9390 if (error.code === 'ENOENT') {
9391 fromDirectory = path.resolve(fromDirectory);
9392 } else if (silent) {
9399 const fromFile = path.join(fromDirectory, 'noop.js');
9401 const resolveFileName = () => Module._resolveFilename(moduleId, {
9404 paths: Module._nodeModulePaths(fromDirectory)
9409 return resolveFileName();
9415 return resolveFileName();
9418 module.exports = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId);
9419 module.exports.silent = (fromDirectory, moduleId) => resolveFrom(fromDirectory, moduleId, true);
9424 /***/ (function(module, exports) {
9426 module.exports = require("module");
9430 /***/ (function(module, __webpack_exports__, __webpack_require__) {
9433 __webpack_require__.r(__webpack_exports__);
9434 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
9435 /* --------------------------------------------------------------------------------------------
\r
9436 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
9437 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
9438 * ------------------------------------------------------------------------------------------ */
\r
9440 var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
\r
9441 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
\r
9442 for (var r = Array(s), k = 0, i = 0; i < il; i++)
\r
9443 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
\r
9447 var FullTextDocument = /** @class */ (function () {
\r
9448 function FullTextDocument(uri, languageId, version, content) {
\r
9450 this._languageId = languageId;
\r
9451 this._version = version;
\r
9452 this._content = content;
\r
9453 this._lineOffsets = undefined;
\r
9455 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
9456 get: function () {
\r
9460 configurable: true
\r
9462 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
9463 get: function () {
\r
9464 return this._languageId;
\r
9467 configurable: true
\r
9469 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
9470 get: function () {
\r
9471 return this._version;
\r
9474 configurable: true
\r
9476 FullTextDocument.prototype.getText = function (range) {
\r
9478 var start = this.offsetAt(range.start);
\r
9479 var end = this.offsetAt(range.end);
\r
9480 return this._content.substring(start, end);
\r
9482 return this._content;
\r
9484 FullTextDocument.prototype.update = function (changes, version) {
\r
9485 for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
\r
9486 var change = changes_1[_i];
\r
9487 if (FullTextDocument.isIncremental(change)) {
\r
9488 // makes sure start is before end
\r
9489 var range = getWellformedRange(change.range);
\r
9491 var startOffset = this.offsetAt(range.start);
\r
9492 var endOffset = this.offsetAt(range.end);
\r
9493 this._content = this._content.substring(0, startOffset) + change.text + this._content.substring(endOffset, this._content.length);
\r
9494 // update the offsets
\r
9495 var startLine = Math.max(range.start.line, 0);
\r
9496 var endLine = Math.max(range.end.line, 0);
\r
9497 var lineOffsets = this._lineOffsets;
\r
9498 var addedLineOffsets = computeLineOffsets(change.text, false, startOffset);
\r
9499 if (endLine - startLine === addedLineOffsets.length) {
\r
9500 for (var i = 0, len = addedLineOffsets.length; i < len; i++) {
\r
9501 lineOffsets[i + startLine + 1] = addedLineOffsets[i];
\r
9505 if (addedLineOffsets.length < 10000) {
\r
9506 lineOffsets.splice.apply(lineOffsets, __spreadArrays([startLine + 1, endLine - startLine], addedLineOffsets));
\r
9508 else { // avoid too many arguments for splice
\r
9509 this._lineOffsets = lineOffsets = lineOffsets.slice(0, startLine + 1).concat(addedLineOffsets, lineOffsets.slice(endLine + 1));
\r
9512 var diff = change.text.length - (endOffset - startOffset);
\r
9514 for (var i = startLine + 1 + addedLineOffsets.length, len = lineOffsets.length; i < len; i++) {
\r
9515 lineOffsets[i] = lineOffsets[i] + diff;
\r
9519 else if (FullTextDocument.isFull(change)) {
\r
9520 this._content = change.text;
\r
9521 this._lineOffsets = undefined;
\r
9524 throw new Error('Unknown change event received');
\r
9527 this._version = version;
\r
9529 FullTextDocument.prototype.getLineOffsets = function () {
\r
9530 if (this._lineOffsets === undefined) {
\r
9531 this._lineOffsets = computeLineOffsets(this._content, true);
\r
9533 return this._lineOffsets;
\r
9535 FullTextDocument.prototype.positionAt = function (offset) {
\r
9536 offset = Math.max(Math.min(offset, this._content.length), 0);
\r
9537 var lineOffsets = this.getLineOffsets();
\r
9538 var low = 0, high = lineOffsets.length;
\r
9540 return { line: 0, character: offset };
\r
9542 while (low < high) {
\r
9543 var mid = Math.floor((low + high) / 2);
\r
9544 if (lineOffsets[mid] > offset) {
\r
9551 // low is the least x for which the line offset is larger than the current offset
\r
9552 // or array.length if no line offset is larger than the current offset
\r
9553 var line = low - 1;
\r
9554 return { line: line, character: offset - lineOffsets[line] };
\r
9556 FullTextDocument.prototype.offsetAt = function (position) {
\r
9557 var lineOffsets = this.getLineOffsets();
\r
9558 if (position.line >= lineOffsets.length) {
\r
9559 return this._content.length;
\r
9561 else if (position.line < 0) {
\r
9564 var lineOffset = lineOffsets[position.line];
\r
9565 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
\r
9566 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
\r
9568 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
9569 get: function () {
\r
9570 return this.getLineOffsets().length;
\r
9573 configurable: true
\r
9575 FullTextDocument.isIncremental = function (event) {
\r
9576 var candidate = event;
\r
9577 return candidate !== undefined && candidate !== null &&
\r
9578 typeof candidate.text === 'string' && candidate.range !== undefined &&
\r
9579 (candidate.rangeLength === undefined || typeof candidate.rangeLength === 'number');
\r
9581 FullTextDocument.isFull = function (event) {
\r
9582 var candidate = event;
\r
9583 return candidate !== undefined && candidate !== null &&
\r
9584 typeof candidate.text === 'string' && candidate.range === undefined && candidate.rangeLength === undefined;
\r
9586 return FullTextDocument;
\r
9589 (function (TextDocument) {
\r
9591 * Creates a new text document.
\r
9593 * @param uri The document's uri.
\r
9594 * @param languageId The document's language Id.
\r
9595 * @param version The document's initial version number.
\r
9596 * @param content The document's content.
\r
9598 function create(uri, languageId, version, content) {
\r
9599 return new FullTextDocument(uri, languageId, version, content);
\r
9601 TextDocument.create = create;
\r
9603 * Updates a TextDocument by modifing its content.
\r
9605 * @param document the document to update. Only documents created by TextDocument.create are valid inputs.
\r
9606 * @param changes the changes to apply to the document.
\r
9607 * @returns The updated TextDocument. Note: That's the same document instance passed in as first parameter.
\r
9610 function update(document, changes, version) {
\r
9611 if (document instanceof FullTextDocument) {
\r
9612 document.update(changes, version);
\r
9616 throw new Error('TextDocument.update: document must be created by TextDocument.create');
\r
9619 TextDocument.update = update;
\r
9620 function applyEdits(document, edits) {
\r
9621 var text = document.getText();
\r
9622 var sortedEdits = mergeSort(edits.map(getWellformedEdit), function (a, b) {
\r
9623 var diff = a.range.start.line - b.range.start.line;
\r
9625 return a.range.start.character - b.range.start.character;
\r
9629 var lastModifiedOffset = text.length;
\r
9630 for (var i = sortedEdits.length - 1; i >= 0; i--) {
\r
9631 var e = sortedEdits[i];
\r
9632 var startOffset = document.offsetAt(e.range.start);
\r
9633 var endOffset = document.offsetAt(e.range.end);
\r
9634 if (endOffset <= lastModifiedOffset) {
\r
9635 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
\r
9638 throw new Error('Overlapping edit');
\r
9640 lastModifiedOffset = startOffset;
\r
9644 TextDocument.applyEdits = applyEdits;
\r
9645 })(TextDocument || (TextDocument = {}));
\r
9646 function mergeSort(data, compare) {
\r
9647 if (data.length <= 1) {
\r
9651 var p = (data.length / 2) | 0;
\r
9652 var left = data.slice(0, p);
\r
9653 var right = data.slice(p);
\r
9654 mergeSort(left, compare);
\r
9655 mergeSort(right, compare);
\r
9659 while (leftIdx < left.length && rightIdx < right.length) {
\r
9660 var ret = compare(left[leftIdx], right[rightIdx]);
\r
9662 // smaller_equal -> take left to preserve order
\r
9663 data[i++] = left[leftIdx++];
\r
9666 // greater -> take right
\r
9667 data[i++] = right[rightIdx++];
\r
9670 while (leftIdx < left.length) {
\r
9671 data[i++] = left[leftIdx++];
\r
9673 while (rightIdx < right.length) {
\r
9674 data[i++] = right[rightIdx++];
\r
9678 function computeLineOffsets(text, isAtLineStart, textOffset) {
\r
9679 if (textOffset === void 0) { textOffset = 0; }
\r
9680 var result = isAtLineStart ? [textOffset] : [];
\r
9681 for (var i = 0; i < text.length; i++) {
\r
9682 var ch = text.charCodeAt(i);
\r
9683 if (ch === 13 /* CarriageReturn */ || ch === 10 /* LineFeed */) {
\r
9684 if (ch === 13 /* CarriageReturn */ && i + 1 < text.length && text.charCodeAt(i + 1) === 10 /* LineFeed */) {
\r
9687 result.push(textOffset + i + 1);
\r
9692 function getWellformedRange(range) {
\r
9693 var start = range.start;
\r
9694 var end = range.end;
\r
9695 if (start.line > end.line || (start.line === end.line && start.character > end.character)) {
\r
9696 return { start: end, end: start };
\r
9700 function getWellformedEdit(textEdit) {
\r
9701 var range = getWellformedRange(textEdit.range);
\r
9702 if (range !== textEdit.range) {
\r
9703 return { newText: textEdit.newText, range: range };
\r