9860 lines
383 KiB
JavaScript
9860 lines
383 KiB
JavaScript
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
var __commonJS = (callback, module2) => () => {
|
|
if (!module2) {
|
|
module2 = {exports: {}};
|
|
callback(module2.exports, module2);
|
|
}
|
|
return module2.exports;
|
|
};
|
|
var __export = (target, all) => {
|
|
__markAsModule(target);
|
|
for (var name in all)
|
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
};
|
|
var __exportStar = (target, module2, desc) => {
|
|
__markAsModule(target);
|
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
for (let key of __getOwnPropNames(module2))
|
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
}
|
|
return target;
|
|
};
|
|
var __toModule = (module2) => {
|
|
if (module2 && module2.__esModule)
|
|
return module2;
|
|
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), module2);
|
|
};
|
|
|
|
// node_modules/vscode-languageserver/lib/common/utils/is.js
|
|
var require_is = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.thenable = exports2.typedArray = exports2.stringArray = exports2.array = exports2.func = exports2.error = exports2.number = exports2.string = exports2.boolean = void 0;
|
|
function boolean(value) {
|
|
return value === true || value === false;
|
|
}
|
|
exports2.boolean = boolean;
|
|
function string(value) {
|
|
return typeof value === "string" || value instanceof String;
|
|
}
|
|
exports2.string = string;
|
|
function number(value) {
|
|
return typeof value === "number" || value instanceof Number;
|
|
}
|
|
exports2.number = number;
|
|
function error(value) {
|
|
return value instanceof Error;
|
|
}
|
|
exports2.error = error;
|
|
function func(value) {
|
|
return typeof value === "function";
|
|
}
|
|
exports2.func = func;
|
|
function array(value) {
|
|
return Array.isArray(value);
|
|
}
|
|
exports2.array = array;
|
|
function stringArray(value) {
|
|
return array(value) && value.every((elem) => string(elem));
|
|
}
|
|
exports2.stringArray = stringArray;
|
|
function typedArray(value, check) {
|
|
return Array.isArray(value) && value.every(check);
|
|
}
|
|
exports2.typedArray = typedArray;
|
|
function thenable(value) {
|
|
return value && func(value.then);
|
|
}
|
|
exports2.thenable = thenable;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/ral.js
|
|
var require_ral = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
var _ral;
|
|
function RAL() {
|
|
if (_ral === void 0) {
|
|
throw new Error(`No runtime abstraction layer installed`);
|
|
}
|
|
return _ral;
|
|
}
|
|
(function(RAL2) {
|
|
function install(ral) {
|
|
if (ral === void 0) {
|
|
throw new Error(`No runtime abstraction layer provided`);
|
|
}
|
|
_ral = ral;
|
|
}
|
|
RAL2.install = install;
|
|
})(RAL || (RAL = {}));
|
|
exports2.default = RAL;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/disposable.js
|
|
var require_disposable = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.Disposable = void 0;
|
|
var Disposable;
|
|
(function(Disposable2) {
|
|
function create(func) {
|
|
return {
|
|
dispose: func
|
|
};
|
|
}
|
|
Disposable2.create = create;
|
|
})(Disposable = exports2.Disposable || (exports2.Disposable = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js
|
|
var require_messageBuffer = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.AbstractMessageBuffer = void 0;
|
|
var CR = 13;
|
|
var LF = 10;
|
|
var CRLF = "\r\n";
|
|
var AbstractMessageBuffer = class {
|
|
constructor(encoding = "utf-8") {
|
|
this._encoding = encoding;
|
|
this._chunks = [];
|
|
this._totalLength = 0;
|
|
}
|
|
get encoding() {
|
|
return this._encoding;
|
|
}
|
|
append(chunk) {
|
|
const toAppend = typeof chunk === "string" ? this.fromString(chunk, this._encoding) : chunk;
|
|
this._chunks.push(toAppend);
|
|
this._totalLength += toAppend.byteLength;
|
|
}
|
|
tryReadHeaders() {
|
|
if (this._chunks.length === 0) {
|
|
return void 0;
|
|
}
|
|
let state = 0;
|
|
let chunkIndex = 0;
|
|
let offset = 0;
|
|
let chunkBytesRead = 0;
|
|
row:
|
|
while (chunkIndex < this._chunks.length) {
|
|
const chunk = this._chunks[chunkIndex];
|
|
offset = 0;
|
|
column:
|
|
while (offset < chunk.length) {
|
|
const value = chunk[offset];
|
|
switch (value) {
|
|
case CR:
|
|
switch (state) {
|
|
case 0:
|
|
state = 1;
|
|
break;
|
|
case 2:
|
|
state = 3;
|
|
break;
|
|
default:
|
|
state = 0;
|
|
}
|
|
break;
|
|
case LF:
|
|
switch (state) {
|
|
case 1:
|
|
state = 2;
|
|
break;
|
|
case 3:
|
|
state = 4;
|
|
offset++;
|
|
break row;
|
|
default:
|
|
state = 0;
|
|
}
|
|
break;
|
|
default:
|
|
state = 0;
|
|
}
|
|
offset++;
|
|
}
|
|
chunkBytesRead += chunk.byteLength;
|
|
chunkIndex++;
|
|
}
|
|
if (state !== 4) {
|
|
return void 0;
|
|
}
|
|
const buffer = this._read(chunkBytesRead + offset);
|
|
const result = new Map();
|
|
const headers = this.toString(buffer, "ascii").split(CRLF);
|
|
if (headers.length < 2) {
|
|
return result;
|
|
}
|
|
for (let i = 0; i < headers.length - 2; i++) {
|
|
const header = headers[i];
|
|
const index = header.indexOf(":");
|
|
if (index === -1) {
|
|
throw new Error("Message header must separate key and value using :");
|
|
}
|
|
const key = header.substr(0, index);
|
|
const value = header.substr(index + 1).trim();
|
|
result.set(key, value);
|
|
}
|
|
return result;
|
|
}
|
|
tryReadBody(length) {
|
|
if (this._totalLength < length) {
|
|
return void 0;
|
|
}
|
|
return this._read(length);
|
|
}
|
|
get numberOfBytes() {
|
|
return this._totalLength;
|
|
}
|
|
_read(byteCount) {
|
|
if (byteCount === 0) {
|
|
return this.emptyBuffer();
|
|
}
|
|
if (byteCount > this._totalLength) {
|
|
throw new Error(`Cannot read so many bytes!`);
|
|
}
|
|
if (this._chunks[0].byteLength === byteCount) {
|
|
const chunk = this._chunks[0];
|
|
this._chunks.shift();
|
|
this._totalLength -= byteCount;
|
|
return this.asNative(chunk);
|
|
}
|
|
if (this._chunks[0].byteLength > byteCount) {
|
|
const chunk = this._chunks[0];
|
|
const result2 = this.asNative(chunk, byteCount);
|
|
this._chunks[0] = chunk.slice(byteCount);
|
|
this._totalLength -= byteCount;
|
|
return result2;
|
|
}
|
|
const result = this.allocNative(byteCount);
|
|
let resultOffset = 0;
|
|
let chunkIndex = 0;
|
|
while (byteCount > 0) {
|
|
const chunk = this._chunks[chunkIndex];
|
|
if (chunk.byteLength > byteCount) {
|
|
const chunkPart = chunk.slice(0, byteCount);
|
|
result.set(chunkPart, resultOffset);
|
|
resultOffset += byteCount;
|
|
this._chunks[chunkIndex] = chunk.slice(byteCount);
|
|
this._totalLength -= byteCount;
|
|
byteCount -= byteCount;
|
|
} else {
|
|
result.set(chunk, resultOffset);
|
|
resultOffset += chunk.byteLength;
|
|
this._chunks.shift();
|
|
this._totalLength -= chunk.byteLength;
|
|
byteCount -= chunk.byteLength;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
exports2.AbstractMessageBuffer = AbstractMessageBuffer;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/node/ril.js
|
|
var require_ril = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
var ral_1 = require_ral();
|
|
var util_1 = require("util");
|
|
var disposable_1 = require_disposable();
|
|
var messageBuffer_1 = require_messageBuffer();
|
|
var MessageBuffer = class extends messageBuffer_1.AbstractMessageBuffer {
|
|
constructor(encoding = "utf-8") {
|
|
super(encoding);
|
|
}
|
|
emptyBuffer() {
|
|
return MessageBuffer.emptyBuffer;
|
|
}
|
|
fromString(value, encoding) {
|
|
return Buffer.from(value, encoding);
|
|
}
|
|
toString(value, encoding) {
|
|
if (value instanceof Buffer) {
|
|
return value.toString(encoding);
|
|
} else {
|
|
return new util_1.TextDecoder(encoding).decode(value);
|
|
}
|
|
}
|
|
asNative(buffer, length) {
|
|
if (length === void 0) {
|
|
return buffer instanceof Buffer ? buffer : Buffer.from(buffer);
|
|
} else {
|
|
return buffer instanceof Buffer ? buffer.slice(0, length) : Buffer.from(buffer, 0, length);
|
|
}
|
|
}
|
|
allocNative(length) {
|
|
return Buffer.allocUnsafe(length);
|
|
}
|
|
};
|
|
MessageBuffer.emptyBuffer = Buffer.allocUnsafe(0);
|
|
var ReadableStreamWrapper = class {
|
|
constructor(stream) {
|
|
this.stream = stream;
|
|
}
|
|
onClose(listener) {
|
|
this.stream.on("close", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("close", listener));
|
|
}
|
|
onError(listener) {
|
|
this.stream.on("error", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("error", listener));
|
|
}
|
|
onEnd(listener) {
|
|
this.stream.on("end", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("end", listener));
|
|
}
|
|
onData(listener) {
|
|
this.stream.on("data", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("data", listener));
|
|
}
|
|
};
|
|
var WritableStreamWrapper = class {
|
|
constructor(stream) {
|
|
this.stream = stream;
|
|
}
|
|
onClose(listener) {
|
|
this.stream.on("close", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("close", listener));
|
|
}
|
|
onError(listener) {
|
|
this.stream.on("error", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("error", listener));
|
|
}
|
|
onEnd(listener) {
|
|
this.stream.on("end", listener);
|
|
return disposable_1.Disposable.create(() => this.stream.off("end", listener));
|
|
}
|
|
write(data, encoding) {
|
|
return new Promise((resolve, reject) => {
|
|
const callback = (error) => {
|
|
if (error === void 0 || error === null) {
|
|
resolve();
|
|
} else {
|
|
reject(error);
|
|
}
|
|
};
|
|
if (typeof data === "string") {
|
|
this.stream.write(data, encoding, callback);
|
|
} else {
|
|
this.stream.write(data, callback);
|
|
}
|
|
});
|
|
}
|
|
end() {
|
|
this.stream.end();
|
|
}
|
|
};
|
|
var _ril = Object.freeze({
|
|
messageBuffer: Object.freeze({
|
|
create: (encoding) => new MessageBuffer(encoding)
|
|
}),
|
|
applicationJson: Object.freeze({
|
|
encoder: Object.freeze({
|
|
name: "application/json",
|
|
encode: (msg, options) => {
|
|
try {
|
|
return Promise.resolve(Buffer.from(JSON.stringify(msg, void 0, 0), options.charset));
|
|
} catch (err) {
|
|
return Promise.reject(err);
|
|
}
|
|
}
|
|
}),
|
|
decoder: Object.freeze({
|
|
name: "application/json",
|
|
decode: (buffer, options) => {
|
|
try {
|
|
if (buffer instanceof Buffer) {
|
|
return Promise.resolve(JSON.parse(buffer.toString(options.charset)));
|
|
} else {
|
|
return Promise.resolve(JSON.parse(new util_1.TextDecoder(options.charset).decode(buffer)));
|
|
}
|
|
} catch (err) {
|
|
return Promise.reject(err);
|
|
}
|
|
}
|
|
})
|
|
}),
|
|
stream: Object.freeze({
|
|
asReadableStream: (stream) => new ReadableStreamWrapper(stream),
|
|
asWritableStream: (stream) => new WritableStreamWrapper(stream)
|
|
}),
|
|
console,
|
|
timer: Object.freeze({
|
|
setTimeout(callback, ms, ...args) {
|
|
return setTimeout(callback, ms, ...args);
|
|
},
|
|
clearTimeout(handle) {
|
|
clearTimeout(handle);
|
|
},
|
|
setImmediate(callback, ...args) {
|
|
return setImmediate(callback, ...args);
|
|
},
|
|
clearImmediate(handle) {
|
|
clearImmediate(handle);
|
|
}
|
|
})
|
|
});
|
|
function RIL() {
|
|
return _ril;
|
|
}
|
|
(function(RIL2) {
|
|
function install() {
|
|
ral_1.default.install(_ril);
|
|
}
|
|
RIL2.install = install;
|
|
})(RIL || (RIL = {}));
|
|
exports2.default = RIL;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/is.js
|
|
var require_is2 = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.stringArray = exports2.array = exports2.func = exports2.error = exports2.number = exports2.string = exports2.boolean = void 0;
|
|
function boolean(value) {
|
|
return value === true || value === false;
|
|
}
|
|
exports2.boolean = boolean;
|
|
function string(value) {
|
|
return typeof value === "string" || value instanceof String;
|
|
}
|
|
exports2.string = string;
|
|
function number(value) {
|
|
return typeof value === "number" || value instanceof Number;
|
|
}
|
|
exports2.number = number;
|
|
function error(value) {
|
|
return value instanceof Error;
|
|
}
|
|
exports2.error = error;
|
|
function func(value) {
|
|
return typeof value === "function";
|
|
}
|
|
exports2.func = func;
|
|
function array(value) {
|
|
return Array.isArray(value);
|
|
}
|
|
exports2.array = array;
|
|
function stringArray(value) {
|
|
return array(value) && value.every((elem) => string(elem));
|
|
}
|
|
exports2.stringArray = stringArray;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/messages.js
|
|
var require_messages = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.isResponseMessage = exports2.isNotificationMessage = exports2.isRequestMessage = exports2.NotificationType9 = exports2.NotificationType8 = exports2.NotificationType7 = exports2.NotificationType6 = exports2.NotificationType5 = exports2.NotificationType4 = exports2.NotificationType3 = exports2.NotificationType2 = exports2.NotificationType1 = exports2.NotificationType0 = exports2.NotificationType = exports2.RequestType9 = exports2.RequestType8 = exports2.RequestType7 = exports2.RequestType6 = exports2.RequestType5 = exports2.RequestType4 = exports2.RequestType3 = exports2.RequestType2 = exports2.RequestType1 = exports2.RequestType = exports2.RequestType0 = exports2.AbstractMessageSignature = exports2.ParameterStructures = exports2.ResponseError = exports2.ErrorCodes = void 0;
|
|
var is = require_is2();
|
|
var ErrorCodes;
|
|
(function(ErrorCodes2) {
|
|
ErrorCodes2.ParseError = -32700;
|
|
ErrorCodes2.InvalidRequest = -32600;
|
|
ErrorCodes2.MethodNotFound = -32601;
|
|
ErrorCodes2.InvalidParams = -32602;
|
|
ErrorCodes2.InternalError = -32603;
|
|
ErrorCodes2.jsonrpcReservedErrorRangeStart = -32099;
|
|
ErrorCodes2.serverErrorStart = ErrorCodes2.jsonrpcReservedErrorRangeStart;
|
|
ErrorCodes2.MessageWriteError = -32099;
|
|
ErrorCodes2.MessageReadError = -32098;
|
|
ErrorCodes2.ServerNotInitialized = -32002;
|
|
ErrorCodes2.UnknownErrorCode = -32001;
|
|
ErrorCodes2.jsonrpcReservedErrorRangeEnd = -32e3;
|
|
ErrorCodes2.serverErrorEnd = ErrorCodes2.jsonrpcReservedErrorRangeEnd;
|
|
})(ErrorCodes = exports2.ErrorCodes || (exports2.ErrorCodes = {}));
|
|
var ResponseError = class extends Error {
|
|
constructor(code, message, data) {
|
|
super(message);
|
|
this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
|
|
this.data = data;
|
|
Object.setPrototypeOf(this, ResponseError.prototype);
|
|
}
|
|
toJson() {
|
|
return {
|
|
code: this.code,
|
|
message: this.message,
|
|
data: this.data
|
|
};
|
|
}
|
|
};
|
|
exports2.ResponseError = ResponseError;
|
|
var ParameterStructures = class {
|
|
constructor(kind) {
|
|
this.kind = kind;
|
|
}
|
|
static is(value) {
|
|
return value === ParameterStructures.auto || value === ParameterStructures.byName || value === ParameterStructures.byPosition;
|
|
}
|
|
toString() {
|
|
return this.kind;
|
|
}
|
|
};
|
|
exports2.ParameterStructures = ParameterStructures;
|
|
ParameterStructures.auto = new ParameterStructures("auto");
|
|
ParameterStructures.byPosition = new ParameterStructures("byPosition");
|
|
ParameterStructures.byName = new ParameterStructures("byName");
|
|
var AbstractMessageSignature = class {
|
|
constructor(method, numberOfParams) {
|
|
this.method = method;
|
|
this.numberOfParams = numberOfParams;
|
|
}
|
|
get parameterStructures() {
|
|
return ParameterStructures.auto;
|
|
}
|
|
};
|
|
exports2.AbstractMessageSignature = AbstractMessageSignature;
|
|
var RequestType0 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 0);
|
|
}
|
|
};
|
|
exports2.RequestType0 = RequestType0;
|
|
var RequestType = class extends AbstractMessageSignature {
|
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
super(method, 1);
|
|
this._parameterStructures = _parameterStructures;
|
|
}
|
|
get parameterStructures() {
|
|
return this._parameterStructures;
|
|
}
|
|
};
|
|
exports2.RequestType = RequestType;
|
|
var RequestType1 = class extends AbstractMessageSignature {
|
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
super(method, 1);
|
|
this._parameterStructures = _parameterStructures;
|
|
}
|
|
get parameterStructures() {
|
|
return this._parameterStructures;
|
|
}
|
|
};
|
|
exports2.RequestType1 = RequestType1;
|
|
var RequestType2 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 2);
|
|
}
|
|
};
|
|
exports2.RequestType2 = RequestType2;
|
|
var RequestType3 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 3);
|
|
}
|
|
};
|
|
exports2.RequestType3 = RequestType3;
|
|
var RequestType4 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 4);
|
|
}
|
|
};
|
|
exports2.RequestType4 = RequestType4;
|
|
var RequestType5 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 5);
|
|
}
|
|
};
|
|
exports2.RequestType5 = RequestType5;
|
|
var RequestType6 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 6);
|
|
}
|
|
};
|
|
exports2.RequestType6 = RequestType6;
|
|
var RequestType7 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 7);
|
|
}
|
|
};
|
|
exports2.RequestType7 = RequestType7;
|
|
var RequestType8 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 8);
|
|
}
|
|
};
|
|
exports2.RequestType8 = RequestType8;
|
|
var RequestType9 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 9);
|
|
}
|
|
};
|
|
exports2.RequestType9 = RequestType9;
|
|
var NotificationType = class extends AbstractMessageSignature {
|
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
super(method, 1);
|
|
this._parameterStructures = _parameterStructures;
|
|
}
|
|
get parameterStructures() {
|
|
return this._parameterStructures;
|
|
}
|
|
};
|
|
exports2.NotificationType = NotificationType;
|
|
var NotificationType0 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 0);
|
|
}
|
|
};
|
|
exports2.NotificationType0 = NotificationType0;
|
|
var NotificationType1 = class extends AbstractMessageSignature {
|
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
super(method, 1);
|
|
this._parameterStructures = _parameterStructures;
|
|
}
|
|
get parameterStructures() {
|
|
return this._parameterStructures;
|
|
}
|
|
};
|
|
exports2.NotificationType1 = NotificationType1;
|
|
var NotificationType2 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 2);
|
|
}
|
|
};
|
|
exports2.NotificationType2 = NotificationType2;
|
|
var NotificationType3 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 3);
|
|
}
|
|
};
|
|
exports2.NotificationType3 = NotificationType3;
|
|
var NotificationType4 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 4);
|
|
}
|
|
};
|
|
exports2.NotificationType4 = NotificationType4;
|
|
var NotificationType5 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 5);
|
|
}
|
|
};
|
|
exports2.NotificationType5 = NotificationType5;
|
|
var NotificationType6 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 6);
|
|
}
|
|
};
|
|
exports2.NotificationType6 = NotificationType6;
|
|
var NotificationType7 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 7);
|
|
}
|
|
};
|
|
exports2.NotificationType7 = NotificationType7;
|
|
var NotificationType8 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 8);
|
|
}
|
|
};
|
|
exports2.NotificationType8 = NotificationType8;
|
|
var NotificationType9 = class extends AbstractMessageSignature {
|
|
constructor(method) {
|
|
super(method, 9);
|
|
}
|
|
};
|
|
exports2.NotificationType9 = NotificationType9;
|
|
function isRequestMessage(message) {
|
|
const candidate = message;
|
|
return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
|
|
}
|
|
exports2.isRequestMessage = isRequestMessage;
|
|
function isNotificationMessage(message) {
|
|
const candidate = message;
|
|
return candidate && is.string(candidate.method) && message.id === void 0;
|
|
}
|
|
exports2.isNotificationMessage = isNotificationMessage;
|
|
function isResponseMessage(message) {
|
|
const candidate = message;
|
|
return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
|
|
}
|
|
exports2.isResponseMessage = isResponseMessage;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/events.js
|
|
var require_events = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.Emitter = exports2.Event = void 0;
|
|
var ral_1 = require_ral();
|
|
var Event;
|
|
(function(Event2) {
|
|
const _disposable = {dispose() {
|
|
}};
|
|
Event2.None = function() {
|
|
return _disposable;
|
|
};
|
|
})(Event = exports2.Event || (exports2.Event = {}));
|
|
var CallbackList = class {
|
|
add(callback, context = null, bucket) {
|
|
if (!this._callbacks) {
|
|
this._callbacks = [];
|
|
this._contexts = [];
|
|
}
|
|
this._callbacks.push(callback);
|
|
this._contexts.push(context);
|
|
if (Array.isArray(bucket)) {
|
|
bucket.push({dispose: () => this.remove(callback, context)});
|
|
}
|
|
}
|
|
remove(callback, context = null) {
|
|
if (!this._callbacks) {
|
|
return;
|
|
}
|
|
let foundCallbackWithDifferentContext = false;
|
|
for (let i = 0, len = this._callbacks.length; i < len; i++) {
|
|
if (this._callbacks[i] === callback) {
|
|
if (this._contexts[i] === context) {
|
|
this._callbacks.splice(i, 1);
|
|
this._contexts.splice(i, 1);
|
|
return;
|
|
} else {
|
|
foundCallbackWithDifferentContext = true;
|
|
}
|
|
}
|
|
}
|
|
if (foundCallbackWithDifferentContext) {
|
|
throw new Error("When adding a listener with a context, you should remove it with the same context");
|
|
}
|
|
}
|
|
invoke(...args) {
|
|
if (!this._callbacks) {
|
|
return [];
|
|
}
|
|
const ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
|
|
for (let i = 0, len = callbacks.length; i < len; i++) {
|
|
try {
|
|
ret.push(callbacks[i].apply(contexts[i], args));
|
|
} catch (e) {
|
|
ral_1.default().console.error(e);
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
isEmpty() {
|
|
return !this._callbacks || this._callbacks.length === 0;
|
|
}
|
|
dispose() {
|
|
this._callbacks = void 0;
|
|
this._contexts = void 0;
|
|
}
|
|
};
|
|
var Emitter = class {
|
|
constructor(_options) {
|
|
this._options = _options;
|
|
}
|
|
get event() {
|
|
if (!this._event) {
|
|
this._event = (listener, thisArgs, disposables) => {
|
|
if (!this._callbacks) {
|
|
this._callbacks = new CallbackList();
|
|
}
|
|
if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
|
|
this._options.onFirstListenerAdd(this);
|
|
}
|
|
this._callbacks.add(listener, thisArgs);
|
|
const result = {
|
|
dispose: () => {
|
|
if (!this._callbacks) {
|
|
return;
|
|
}
|
|
this._callbacks.remove(listener, thisArgs);
|
|
result.dispose = Emitter._noop;
|
|
if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
|
|
this._options.onLastListenerRemove(this);
|
|
}
|
|
}
|
|
};
|
|
if (Array.isArray(disposables)) {
|
|
disposables.push(result);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
return this._event;
|
|
}
|
|
fire(event) {
|
|
if (this._callbacks) {
|
|
this._callbacks.invoke.call(this._callbacks, event);
|
|
}
|
|
}
|
|
dispose() {
|
|
if (this._callbacks) {
|
|
this._callbacks.dispose();
|
|
this._callbacks = void 0;
|
|
}
|
|
}
|
|
};
|
|
exports2.Emitter = Emitter;
|
|
Emitter._noop = function() {
|
|
};
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/cancellation.js
|
|
var require_cancellation = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.CancellationTokenSource = exports2.CancellationToken = void 0;
|
|
var ral_1 = require_ral();
|
|
var Is = require_is2();
|
|
var events_1 = require_events();
|
|
var CancellationToken;
|
|
(function(CancellationToken2) {
|
|
CancellationToken2.None = Object.freeze({
|
|
isCancellationRequested: false,
|
|
onCancellationRequested: events_1.Event.None
|
|
});
|
|
CancellationToken2.Cancelled = Object.freeze({
|
|
isCancellationRequested: true,
|
|
onCancellationRequested: events_1.Event.None
|
|
});
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && (candidate === CancellationToken2.None || candidate === CancellationToken2.Cancelled || Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested);
|
|
}
|
|
CancellationToken2.is = is;
|
|
})(CancellationToken = exports2.CancellationToken || (exports2.CancellationToken = {}));
|
|
var shortcutEvent = Object.freeze(function(callback, context) {
|
|
const handle = ral_1.default().timer.setTimeout(callback.bind(context), 0);
|
|
return {dispose() {
|
|
ral_1.default().timer.clearTimeout(handle);
|
|
}};
|
|
});
|
|
var MutableToken = class {
|
|
constructor() {
|
|
this._isCancelled = false;
|
|
}
|
|
cancel() {
|
|
if (!this._isCancelled) {
|
|
this._isCancelled = true;
|
|
if (this._emitter) {
|
|
this._emitter.fire(void 0);
|
|
this.dispose();
|
|
}
|
|
}
|
|
}
|
|
get isCancellationRequested() {
|
|
return this._isCancelled;
|
|
}
|
|
get onCancellationRequested() {
|
|
if (this._isCancelled) {
|
|
return shortcutEvent;
|
|
}
|
|
if (!this._emitter) {
|
|
this._emitter = new events_1.Emitter();
|
|
}
|
|
return this._emitter.event;
|
|
}
|
|
dispose() {
|
|
if (this._emitter) {
|
|
this._emitter.dispose();
|
|
this._emitter = void 0;
|
|
}
|
|
}
|
|
};
|
|
var CancellationTokenSource = class {
|
|
get token() {
|
|
if (!this._token) {
|
|
this._token = new MutableToken();
|
|
}
|
|
return this._token;
|
|
}
|
|
cancel() {
|
|
if (!this._token) {
|
|
this._token = CancellationToken.Cancelled;
|
|
} else {
|
|
this._token.cancel();
|
|
}
|
|
}
|
|
dispose() {
|
|
if (!this._token) {
|
|
this._token = CancellationToken.None;
|
|
} else if (this._token instanceof MutableToken) {
|
|
this._token.dispose();
|
|
}
|
|
}
|
|
};
|
|
exports2.CancellationTokenSource = CancellationTokenSource;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/messageReader.js
|
|
var require_messageReader = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ReadableStreamMessageReader = exports2.AbstractMessageReader = exports2.MessageReader = void 0;
|
|
var ral_1 = require_ral();
|
|
var Is = require_is2();
|
|
var events_1 = require_events();
|
|
var MessageReader;
|
|
(function(MessageReader2) {
|
|
function is(value) {
|
|
let candidate = value;
|
|
return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) && Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
|
|
}
|
|
MessageReader2.is = is;
|
|
})(MessageReader = exports2.MessageReader || (exports2.MessageReader = {}));
|
|
var AbstractMessageReader = class {
|
|
constructor() {
|
|
this.errorEmitter = new events_1.Emitter();
|
|
this.closeEmitter = new events_1.Emitter();
|
|
this.partialMessageEmitter = new events_1.Emitter();
|
|
}
|
|
dispose() {
|
|
this.errorEmitter.dispose();
|
|
this.closeEmitter.dispose();
|
|
}
|
|
get onError() {
|
|
return this.errorEmitter.event;
|
|
}
|
|
fireError(error) {
|
|
this.errorEmitter.fire(this.asError(error));
|
|
}
|
|
get onClose() {
|
|
return this.closeEmitter.event;
|
|
}
|
|
fireClose() {
|
|
this.closeEmitter.fire(void 0);
|
|
}
|
|
get onPartialMessage() {
|
|
return this.partialMessageEmitter.event;
|
|
}
|
|
firePartialMessage(info) {
|
|
this.partialMessageEmitter.fire(info);
|
|
}
|
|
asError(error) {
|
|
if (error instanceof Error) {
|
|
return error;
|
|
} else {
|
|
return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : "unknown"}`);
|
|
}
|
|
}
|
|
};
|
|
exports2.AbstractMessageReader = AbstractMessageReader;
|
|
var ResolvedMessageReaderOptions;
|
|
(function(ResolvedMessageReaderOptions2) {
|
|
function fromOptions(options) {
|
|
var _a2;
|
|
let charset;
|
|
let result;
|
|
let contentDecoder;
|
|
const contentDecoders = new Map();
|
|
let contentTypeDecoder;
|
|
const contentTypeDecoders = new Map();
|
|
if (options === void 0 || typeof options === "string") {
|
|
charset = options !== null && options !== void 0 ? options : "utf-8";
|
|
} else {
|
|
charset = (_a2 = options.charset) !== null && _a2 !== void 0 ? _a2 : "utf-8";
|
|
if (options.contentDecoder !== void 0) {
|
|
contentDecoder = options.contentDecoder;
|
|
contentDecoders.set(contentDecoder.name, contentDecoder);
|
|
}
|
|
if (options.contentDecoders !== void 0) {
|
|
for (const decoder of options.contentDecoders) {
|
|
contentDecoders.set(decoder.name, decoder);
|
|
}
|
|
}
|
|
if (options.contentTypeDecoder !== void 0) {
|
|
contentTypeDecoder = options.contentTypeDecoder;
|
|
contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
|
|
}
|
|
if (options.contentTypeDecoders !== void 0) {
|
|
for (const decoder of options.contentTypeDecoders) {
|
|
contentTypeDecoders.set(decoder.name, decoder);
|
|
}
|
|
}
|
|
}
|
|
if (contentTypeDecoder === void 0) {
|
|
contentTypeDecoder = ral_1.default().applicationJson.decoder;
|
|
contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
|
|
}
|
|
return {charset, contentDecoder, contentDecoders, contentTypeDecoder, contentTypeDecoders};
|
|
}
|
|
ResolvedMessageReaderOptions2.fromOptions = fromOptions;
|
|
})(ResolvedMessageReaderOptions || (ResolvedMessageReaderOptions = {}));
|
|
var ReadableStreamMessageReader = class extends AbstractMessageReader {
|
|
constructor(readable, options) {
|
|
super();
|
|
this.readable = readable;
|
|
this.options = ResolvedMessageReaderOptions.fromOptions(options);
|
|
this.buffer = ral_1.default().messageBuffer.create(this.options.charset);
|
|
this._partialMessageTimeout = 1e4;
|
|
this.nextMessageLength = -1;
|
|
this.messageToken = 0;
|
|
}
|
|
set partialMessageTimeout(timeout) {
|
|
this._partialMessageTimeout = timeout;
|
|
}
|
|
get partialMessageTimeout() {
|
|
return this._partialMessageTimeout;
|
|
}
|
|
listen(callback) {
|
|
this.nextMessageLength = -1;
|
|
this.messageToken = 0;
|
|
this.partialMessageTimer = void 0;
|
|
this.callback = callback;
|
|
const result = this.readable.onData((data) => {
|
|
this.onData(data);
|
|
});
|
|
this.readable.onError((error) => this.fireError(error));
|
|
this.readable.onClose(() => this.fireClose());
|
|
return result;
|
|
}
|
|
onData(data) {
|
|
this.buffer.append(data);
|
|
while (true) {
|
|
if (this.nextMessageLength === -1) {
|
|
const headers = this.buffer.tryReadHeaders();
|
|
if (!headers) {
|
|
return;
|
|
}
|
|
const contentLength = headers.get("Content-Length");
|
|
if (!contentLength) {
|
|
throw new Error("Header must provide a Content-Length property.");
|
|
}
|
|
const length = parseInt(contentLength);
|
|
if (isNaN(length)) {
|
|
throw new Error("Content-Length value must be a number.");
|
|
}
|
|
this.nextMessageLength = length;
|
|
}
|
|
const body = this.buffer.tryReadBody(this.nextMessageLength);
|
|
if (body === void 0) {
|
|
this.setPartialMessageTimer();
|
|
return;
|
|
}
|
|
this.clearPartialMessageTimer();
|
|
this.nextMessageLength = -1;
|
|
let p;
|
|
if (this.options.contentDecoder !== void 0) {
|
|
p = this.options.contentDecoder.decode(body);
|
|
} else {
|
|
p = Promise.resolve(body);
|
|
}
|
|
p.then((value) => {
|
|
this.options.contentTypeDecoder.decode(value, this.options).then((msg) => {
|
|
this.callback(msg);
|
|
}, (error) => {
|
|
this.fireError(error);
|
|
});
|
|
}, (error) => {
|
|
this.fireError(error);
|
|
});
|
|
}
|
|
}
|
|
clearPartialMessageTimer() {
|
|
if (this.partialMessageTimer) {
|
|
ral_1.default().timer.clearTimeout(this.partialMessageTimer);
|
|
this.partialMessageTimer = void 0;
|
|
}
|
|
}
|
|
setPartialMessageTimer() {
|
|
this.clearPartialMessageTimer();
|
|
if (this._partialMessageTimeout <= 0) {
|
|
return;
|
|
}
|
|
this.partialMessageTimer = ral_1.default().timer.setTimeout((token, timeout) => {
|
|
this.partialMessageTimer = void 0;
|
|
if (token === this.messageToken) {
|
|
this.firePartialMessage({messageToken: token, waitingTime: timeout});
|
|
this.setPartialMessageTimer();
|
|
}
|
|
}, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
|
|
}
|
|
};
|
|
exports2.ReadableStreamMessageReader = ReadableStreamMessageReader;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/semaphore.js
|
|
var require_semaphore = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.Semaphore = void 0;
|
|
var ral_1 = require_ral();
|
|
var Semaphore = class {
|
|
constructor(capacity = 1) {
|
|
if (capacity <= 0) {
|
|
throw new Error("Capacity must be greater than 0");
|
|
}
|
|
this._capacity = capacity;
|
|
this._active = 0;
|
|
this._waiting = [];
|
|
}
|
|
lock(thunk) {
|
|
return new Promise((resolve, reject) => {
|
|
this._waiting.push({thunk, resolve, reject});
|
|
this.runNext();
|
|
});
|
|
}
|
|
get active() {
|
|
return this._active;
|
|
}
|
|
runNext() {
|
|
if (this._waiting.length === 0 || this._active === this._capacity) {
|
|
return;
|
|
}
|
|
ral_1.default().timer.setImmediate(() => this.doRunNext());
|
|
}
|
|
doRunNext() {
|
|
if (this._waiting.length === 0 || this._active === this._capacity) {
|
|
return;
|
|
}
|
|
const next = this._waiting.shift();
|
|
this._active++;
|
|
if (this._active > this._capacity) {
|
|
throw new Error(`To many thunks active`);
|
|
}
|
|
try {
|
|
const result = next.thunk();
|
|
if (result instanceof Promise) {
|
|
result.then((value) => {
|
|
this._active--;
|
|
next.resolve(value);
|
|
this.runNext();
|
|
}, (err) => {
|
|
this._active--;
|
|
next.reject(err);
|
|
this.runNext();
|
|
});
|
|
} else {
|
|
this._active--;
|
|
next.resolve(result);
|
|
this.runNext();
|
|
}
|
|
} catch (err) {
|
|
this._active--;
|
|
next.reject(err);
|
|
this.runNext();
|
|
}
|
|
}
|
|
};
|
|
exports2.Semaphore = Semaphore;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/messageWriter.js
|
|
var require_messageWriter = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.WriteableStreamMessageWriter = exports2.AbstractMessageWriter = exports2.MessageWriter = void 0;
|
|
var ral_1 = require_ral();
|
|
var Is = require_is2();
|
|
var semaphore_1 = require_semaphore();
|
|
var events_1 = require_events();
|
|
var ContentLength = "Content-Length: ";
|
|
var CRLF = "\r\n";
|
|
var MessageWriter;
|
|
(function(MessageWriter2) {
|
|
function is(value) {
|
|
let candidate = value;
|
|
return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) && Is.func(candidate.onError) && Is.func(candidate.write);
|
|
}
|
|
MessageWriter2.is = is;
|
|
})(MessageWriter = exports2.MessageWriter || (exports2.MessageWriter = {}));
|
|
var AbstractMessageWriter = class {
|
|
constructor() {
|
|
this.errorEmitter = new events_1.Emitter();
|
|
this.closeEmitter = new events_1.Emitter();
|
|
}
|
|
dispose() {
|
|
this.errorEmitter.dispose();
|
|
this.closeEmitter.dispose();
|
|
}
|
|
get onError() {
|
|
return this.errorEmitter.event;
|
|
}
|
|
fireError(error, message, count) {
|
|
this.errorEmitter.fire([this.asError(error), message, count]);
|
|
}
|
|
get onClose() {
|
|
return this.closeEmitter.event;
|
|
}
|
|
fireClose() {
|
|
this.closeEmitter.fire(void 0);
|
|
}
|
|
asError(error) {
|
|
if (error instanceof Error) {
|
|
return error;
|
|
} else {
|
|
return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : "unknown"}`);
|
|
}
|
|
}
|
|
};
|
|
exports2.AbstractMessageWriter = AbstractMessageWriter;
|
|
var ResolvedMessageWriterOptions;
|
|
(function(ResolvedMessageWriterOptions2) {
|
|
function fromOptions(options) {
|
|
var _a2, _b;
|
|
if (options === void 0 || typeof options === "string") {
|
|
return {charset: options !== null && options !== void 0 ? options : "utf-8", contentTypeEncoder: ral_1.default().applicationJson.encoder};
|
|
} else {
|
|
return {charset: (_a2 = options.charset) !== null && _a2 !== void 0 ? _a2 : "utf-8", contentEncoder: options.contentEncoder, contentTypeEncoder: (_b = options.contentTypeEncoder) !== null && _b !== void 0 ? _b : ral_1.default().applicationJson.encoder};
|
|
}
|
|
}
|
|
ResolvedMessageWriterOptions2.fromOptions = fromOptions;
|
|
})(ResolvedMessageWriterOptions || (ResolvedMessageWriterOptions = {}));
|
|
var WriteableStreamMessageWriter = class extends AbstractMessageWriter {
|
|
constructor(writable, options) {
|
|
super();
|
|
this.writable = writable;
|
|
this.options = ResolvedMessageWriterOptions.fromOptions(options);
|
|
this.errorCount = 0;
|
|
this.writeSemaphore = new semaphore_1.Semaphore(1);
|
|
this.writable.onError((error) => this.fireError(error));
|
|
this.writable.onClose(() => this.fireClose());
|
|
}
|
|
async write(msg) {
|
|
return this.writeSemaphore.lock(async () => {
|
|
const payload = this.options.contentTypeEncoder.encode(msg, this.options).then((buffer) => {
|
|
if (this.options.contentEncoder !== void 0) {
|
|
return this.options.contentEncoder.encode(buffer);
|
|
} else {
|
|
return buffer;
|
|
}
|
|
});
|
|
return payload.then((buffer) => {
|
|
const headers = [];
|
|
headers.push(ContentLength, buffer.byteLength.toString(), CRLF);
|
|
headers.push(CRLF);
|
|
return this.doWrite(msg, headers, buffer);
|
|
}, (error) => {
|
|
this.fireError(error);
|
|
throw error;
|
|
});
|
|
});
|
|
}
|
|
async doWrite(msg, headers, data) {
|
|
try {
|
|
await this.writable.write(headers.join(""), "ascii");
|
|
return this.writable.write(data);
|
|
} catch (error) {
|
|
this.handleError(error, msg);
|
|
return Promise.reject(error);
|
|
}
|
|
}
|
|
handleError(error, msg) {
|
|
this.errorCount++;
|
|
this.fireError(error, msg, this.errorCount);
|
|
}
|
|
end() {
|
|
this.writable.end();
|
|
}
|
|
};
|
|
exports2.WriteableStreamMessageWriter = WriteableStreamMessageWriter;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/linkedMap.js
|
|
var require_linkedMap = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.LRUCache = exports2.LinkedMap = exports2.Touch = void 0;
|
|
var Touch;
|
|
(function(Touch2) {
|
|
Touch2.None = 0;
|
|
Touch2.First = 1;
|
|
Touch2.AsOld = Touch2.First;
|
|
Touch2.Last = 2;
|
|
Touch2.AsNew = Touch2.Last;
|
|
})(Touch = exports2.Touch || (exports2.Touch = {}));
|
|
var LinkedMap = class {
|
|
constructor() {
|
|
this[Symbol.toStringTag] = "LinkedMap";
|
|
this._map = new Map();
|
|
this._head = void 0;
|
|
this._tail = void 0;
|
|
this._size = 0;
|
|
this._state = 0;
|
|
}
|
|
clear() {
|
|
this._map.clear();
|
|
this._head = void 0;
|
|
this._tail = void 0;
|
|
this._size = 0;
|
|
this._state++;
|
|
}
|
|
isEmpty() {
|
|
return !this._head && !this._tail;
|
|
}
|
|
get size() {
|
|
return this._size;
|
|
}
|
|
get first() {
|
|
var _a2;
|
|
return (_a2 = this._head) === null || _a2 === void 0 ? void 0 : _a2.value;
|
|
}
|
|
get last() {
|
|
var _a2;
|
|
return (_a2 = this._tail) === null || _a2 === void 0 ? void 0 : _a2.value;
|
|
}
|
|
has(key) {
|
|
return this._map.has(key);
|
|
}
|
|
get(key, touch = Touch.None) {
|
|
const item = this._map.get(key);
|
|
if (!item) {
|
|
return void 0;
|
|
}
|
|
if (touch !== Touch.None) {
|
|
this.touch(item, touch);
|
|
}
|
|
return item.value;
|
|
}
|
|
set(key, value, touch = Touch.None) {
|
|
let item = this._map.get(key);
|
|
if (item) {
|
|
item.value = value;
|
|
if (touch !== Touch.None) {
|
|
this.touch(item, touch);
|
|
}
|
|
} else {
|
|
item = {key, value, next: void 0, previous: void 0};
|
|
switch (touch) {
|
|
case Touch.None:
|
|
this.addItemLast(item);
|
|
break;
|
|
case Touch.First:
|
|
this.addItemFirst(item);
|
|
break;
|
|
case Touch.Last:
|
|
this.addItemLast(item);
|
|
break;
|
|
default:
|
|
this.addItemLast(item);
|
|
break;
|
|
}
|
|
this._map.set(key, item);
|
|
this._size++;
|
|
}
|
|
return this;
|
|
}
|
|
delete(key) {
|
|
return !!this.remove(key);
|
|
}
|
|
remove(key) {
|
|
const item = this._map.get(key);
|
|
if (!item) {
|
|
return void 0;
|
|
}
|
|
this._map.delete(key);
|
|
this.removeItem(item);
|
|
this._size--;
|
|
return item.value;
|
|
}
|
|
shift() {
|
|
if (!this._head && !this._tail) {
|
|
return void 0;
|
|
}
|
|
if (!this._head || !this._tail) {
|
|
throw new Error("Invalid list");
|
|
}
|
|
const item = this._head;
|
|
this._map.delete(item.key);
|
|
this.removeItem(item);
|
|
this._size--;
|
|
return item.value;
|
|
}
|
|
forEach(callbackfn, thisArg) {
|
|
const state = this._state;
|
|
let current = this._head;
|
|
while (current) {
|
|
if (thisArg) {
|
|
callbackfn.bind(thisArg)(current.value, current.key, this);
|
|
} else {
|
|
callbackfn(current.value, current.key, this);
|
|
}
|
|
if (this._state !== state) {
|
|
throw new Error(`LinkedMap got modified during iteration.`);
|
|
}
|
|
current = current.next;
|
|
}
|
|
}
|
|
keys() {
|
|
const map = this;
|
|
const state = this._state;
|
|
let current = this._head;
|
|
const iterator = {
|
|
[Symbol.iterator]() {
|
|
return iterator;
|
|
},
|
|
next() {
|
|
if (map._state !== state) {
|
|
throw new Error(`LinkedMap got modified during iteration.`);
|
|
}
|
|
if (current) {
|
|
const result = {value: current.key, done: false};
|
|
current = current.next;
|
|
return result;
|
|
} else {
|
|
return {value: void 0, done: true};
|
|
}
|
|
}
|
|
};
|
|
return iterator;
|
|
}
|
|
values() {
|
|
const map = this;
|
|
const state = this._state;
|
|
let current = this._head;
|
|
const iterator = {
|
|
[Symbol.iterator]() {
|
|
return iterator;
|
|
},
|
|
next() {
|
|
if (map._state !== state) {
|
|
throw new Error(`LinkedMap got modified during iteration.`);
|
|
}
|
|
if (current) {
|
|
const result = {value: current.value, done: false};
|
|
current = current.next;
|
|
return result;
|
|
} else {
|
|
return {value: void 0, done: true};
|
|
}
|
|
}
|
|
};
|
|
return iterator;
|
|
}
|
|
entries() {
|
|
const map = this;
|
|
const state = this._state;
|
|
let current = this._head;
|
|
const iterator = {
|
|
[Symbol.iterator]() {
|
|
return iterator;
|
|
},
|
|
next() {
|
|
if (map._state !== state) {
|
|
throw new Error(`LinkedMap got modified during iteration.`);
|
|
}
|
|
if (current) {
|
|
const result = {value: [current.key, current.value], done: false};
|
|
current = current.next;
|
|
return result;
|
|
} else {
|
|
return {value: void 0, done: true};
|
|
}
|
|
}
|
|
};
|
|
return iterator;
|
|
}
|
|
[Symbol.iterator]() {
|
|
return this.entries();
|
|
}
|
|
trimOld(newSize) {
|
|
if (newSize >= this.size) {
|
|
return;
|
|
}
|
|
if (newSize === 0) {
|
|
this.clear();
|
|
return;
|
|
}
|
|
let current = this._head;
|
|
let currentSize = this.size;
|
|
while (current && currentSize > newSize) {
|
|
this._map.delete(current.key);
|
|
current = current.next;
|
|
currentSize--;
|
|
}
|
|
this._head = current;
|
|
this._size = currentSize;
|
|
if (current) {
|
|
current.previous = void 0;
|
|
}
|
|
this._state++;
|
|
}
|
|
addItemFirst(item) {
|
|
if (!this._head && !this._tail) {
|
|
this._tail = item;
|
|
} else if (!this._head) {
|
|
throw new Error("Invalid list");
|
|
} else {
|
|
item.next = this._head;
|
|
this._head.previous = item;
|
|
}
|
|
this._head = item;
|
|
this._state++;
|
|
}
|
|
addItemLast(item) {
|
|
if (!this._head && !this._tail) {
|
|
this._head = item;
|
|
} else if (!this._tail) {
|
|
throw new Error("Invalid list");
|
|
} else {
|
|
item.previous = this._tail;
|
|
this._tail.next = item;
|
|
}
|
|
this._tail = item;
|
|
this._state++;
|
|
}
|
|
removeItem(item) {
|
|
if (item === this._head && item === this._tail) {
|
|
this._head = void 0;
|
|
this._tail = void 0;
|
|
} else if (item === this._head) {
|
|
if (!item.next) {
|
|
throw new Error("Invalid list");
|
|
}
|
|
item.next.previous = void 0;
|
|
this._head = item.next;
|
|
} else if (item === this._tail) {
|
|
if (!item.previous) {
|
|
throw new Error("Invalid list");
|
|
}
|
|
item.previous.next = void 0;
|
|
this._tail = item.previous;
|
|
} else {
|
|
const next = item.next;
|
|
const previous = item.previous;
|
|
if (!next || !previous) {
|
|
throw new Error("Invalid list");
|
|
}
|
|
next.previous = previous;
|
|
previous.next = next;
|
|
}
|
|
item.next = void 0;
|
|
item.previous = void 0;
|
|
this._state++;
|
|
}
|
|
touch(item, touch) {
|
|
if (!this._head || !this._tail) {
|
|
throw new Error("Invalid list");
|
|
}
|
|
if (touch !== Touch.First && touch !== Touch.Last) {
|
|
return;
|
|
}
|
|
if (touch === Touch.First) {
|
|
if (item === this._head) {
|
|
return;
|
|
}
|
|
const next = item.next;
|
|
const previous = item.previous;
|
|
if (item === this._tail) {
|
|
previous.next = void 0;
|
|
this._tail = previous;
|
|
} else {
|
|
next.previous = previous;
|
|
previous.next = next;
|
|
}
|
|
item.previous = void 0;
|
|
item.next = this._head;
|
|
this._head.previous = item;
|
|
this._head = item;
|
|
this._state++;
|
|
} else if (touch === Touch.Last) {
|
|
if (item === this._tail) {
|
|
return;
|
|
}
|
|
const next = item.next;
|
|
const previous = item.previous;
|
|
if (item === this._head) {
|
|
next.previous = void 0;
|
|
this._head = next;
|
|
} else {
|
|
next.previous = previous;
|
|
previous.next = next;
|
|
}
|
|
item.next = void 0;
|
|
item.previous = this._tail;
|
|
this._tail.next = item;
|
|
this._tail = item;
|
|
this._state++;
|
|
}
|
|
}
|
|
toJSON() {
|
|
const data = [];
|
|
this.forEach((value, key) => {
|
|
data.push([key, value]);
|
|
});
|
|
return data;
|
|
}
|
|
fromJSON(data) {
|
|
this.clear();
|
|
for (const [key, value] of data) {
|
|
this.set(key, value);
|
|
}
|
|
}
|
|
};
|
|
exports2.LinkedMap = LinkedMap;
|
|
var LRUCache = class extends LinkedMap {
|
|
constructor(limit, ratio = 1) {
|
|
super();
|
|
this._limit = limit;
|
|
this._ratio = Math.min(Math.max(0, ratio), 1);
|
|
}
|
|
get limit() {
|
|
return this._limit;
|
|
}
|
|
set limit(limit) {
|
|
this._limit = limit;
|
|
this.checkTrim();
|
|
}
|
|
get ratio() {
|
|
return this._ratio;
|
|
}
|
|
set ratio(ratio) {
|
|
this._ratio = Math.min(Math.max(0, ratio), 1);
|
|
this.checkTrim();
|
|
}
|
|
get(key, touch = Touch.AsNew) {
|
|
return super.get(key, touch);
|
|
}
|
|
peek(key) {
|
|
return super.get(key, Touch.None);
|
|
}
|
|
set(key, value) {
|
|
super.set(key, value, Touch.Last);
|
|
this.checkTrim();
|
|
return this;
|
|
}
|
|
checkTrim() {
|
|
if (this.size > this._limit) {
|
|
this.trimOld(Math.round(this._limit * this._ratio));
|
|
}
|
|
}
|
|
};
|
|
exports2.LRUCache = LRUCache;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/connection.js
|
|
var require_connection = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.createMessageConnection = exports2.ConnectionOptions = exports2.CancellationStrategy = exports2.CancellationSenderStrategy = exports2.CancellationReceiverStrategy = exports2.ConnectionStrategy = exports2.ConnectionError = exports2.ConnectionErrors = exports2.LogTraceNotification = exports2.SetTraceNotification = exports2.TraceFormat = exports2.Trace = exports2.NullLogger = exports2.ProgressType = void 0;
|
|
var ral_1 = require_ral();
|
|
var Is = require_is2();
|
|
var messages_1 = require_messages();
|
|
var linkedMap_1 = require_linkedMap();
|
|
var events_1 = require_events();
|
|
var cancellation_1 = require_cancellation();
|
|
var CancelNotification;
|
|
(function(CancelNotification2) {
|
|
CancelNotification2.type = new messages_1.NotificationType("$/cancelRequest");
|
|
})(CancelNotification || (CancelNotification = {}));
|
|
var ProgressNotification;
|
|
(function(ProgressNotification2) {
|
|
ProgressNotification2.type = new messages_1.NotificationType("$/progress");
|
|
})(ProgressNotification || (ProgressNotification = {}));
|
|
var ProgressType = class {
|
|
constructor() {
|
|
}
|
|
};
|
|
exports2.ProgressType = ProgressType;
|
|
var StarRequestHandler;
|
|
(function(StarRequestHandler2) {
|
|
function is(value) {
|
|
return Is.func(value);
|
|
}
|
|
StarRequestHandler2.is = is;
|
|
})(StarRequestHandler || (StarRequestHandler = {}));
|
|
exports2.NullLogger = Object.freeze({
|
|
error: () => {
|
|
},
|
|
warn: () => {
|
|
},
|
|
info: () => {
|
|
},
|
|
log: () => {
|
|
}
|
|
});
|
|
var Trace;
|
|
(function(Trace2) {
|
|
Trace2[Trace2["Off"] = 0] = "Off";
|
|
Trace2[Trace2["Messages"] = 1] = "Messages";
|
|
Trace2[Trace2["Verbose"] = 2] = "Verbose";
|
|
})(Trace = exports2.Trace || (exports2.Trace = {}));
|
|
(function(Trace2) {
|
|
function fromString(value) {
|
|
if (!Is.string(value)) {
|
|
return Trace2.Off;
|
|
}
|
|
value = value.toLowerCase();
|
|
switch (value) {
|
|
case "off":
|
|
return Trace2.Off;
|
|
case "messages":
|
|
return Trace2.Messages;
|
|
case "verbose":
|
|
return Trace2.Verbose;
|
|
default:
|
|
return Trace2.Off;
|
|
}
|
|
}
|
|
Trace2.fromString = fromString;
|
|
function toString(value) {
|
|
switch (value) {
|
|
case Trace2.Off:
|
|
return "off";
|
|
case Trace2.Messages:
|
|
return "messages";
|
|
case Trace2.Verbose:
|
|
return "verbose";
|
|
default:
|
|
return "off";
|
|
}
|
|
}
|
|
Trace2.toString = toString;
|
|
})(Trace = exports2.Trace || (exports2.Trace = {}));
|
|
var TraceFormat;
|
|
(function(TraceFormat2) {
|
|
TraceFormat2["Text"] = "text";
|
|
TraceFormat2["JSON"] = "json";
|
|
})(TraceFormat = exports2.TraceFormat || (exports2.TraceFormat = {}));
|
|
(function(TraceFormat2) {
|
|
function fromString(value) {
|
|
value = value.toLowerCase();
|
|
if (value === "json") {
|
|
return TraceFormat2.JSON;
|
|
} else {
|
|
return TraceFormat2.Text;
|
|
}
|
|
}
|
|
TraceFormat2.fromString = fromString;
|
|
})(TraceFormat = exports2.TraceFormat || (exports2.TraceFormat = {}));
|
|
var SetTraceNotification;
|
|
(function(SetTraceNotification2) {
|
|
SetTraceNotification2.type = new messages_1.NotificationType("$/setTrace");
|
|
})(SetTraceNotification = exports2.SetTraceNotification || (exports2.SetTraceNotification = {}));
|
|
var LogTraceNotification;
|
|
(function(LogTraceNotification2) {
|
|
LogTraceNotification2.type = new messages_1.NotificationType("$/logTrace");
|
|
})(LogTraceNotification = exports2.LogTraceNotification || (exports2.LogTraceNotification = {}));
|
|
var ConnectionErrors;
|
|
(function(ConnectionErrors2) {
|
|
ConnectionErrors2[ConnectionErrors2["Closed"] = 1] = "Closed";
|
|
ConnectionErrors2[ConnectionErrors2["Disposed"] = 2] = "Disposed";
|
|
ConnectionErrors2[ConnectionErrors2["AlreadyListening"] = 3] = "AlreadyListening";
|
|
})(ConnectionErrors = exports2.ConnectionErrors || (exports2.ConnectionErrors = {}));
|
|
var ConnectionError = class extends Error {
|
|
constructor(code, message) {
|
|
super(message);
|
|
this.code = code;
|
|
Object.setPrototypeOf(this, ConnectionError.prototype);
|
|
}
|
|
};
|
|
exports2.ConnectionError = ConnectionError;
|
|
var ConnectionStrategy;
|
|
(function(ConnectionStrategy2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && Is.func(candidate.cancelUndispatched);
|
|
}
|
|
ConnectionStrategy2.is = is;
|
|
})(ConnectionStrategy = exports2.ConnectionStrategy || (exports2.ConnectionStrategy = {}));
|
|
var CancellationReceiverStrategy;
|
|
(function(CancellationReceiverStrategy2) {
|
|
CancellationReceiverStrategy2.Message = Object.freeze({
|
|
createCancellationTokenSource(_) {
|
|
return new cancellation_1.CancellationTokenSource();
|
|
}
|
|
});
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && Is.func(candidate.createCancellationTokenSource);
|
|
}
|
|
CancellationReceiverStrategy2.is = is;
|
|
})(CancellationReceiverStrategy = exports2.CancellationReceiverStrategy || (exports2.CancellationReceiverStrategy = {}));
|
|
var CancellationSenderStrategy;
|
|
(function(CancellationSenderStrategy2) {
|
|
CancellationSenderStrategy2.Message = Object.freeze({
|
|
sendCancellation(conn, id) {
|
|
conn.sendNotification(CancelNotification.type, {id});
|
|
},
|
|
cleanup(_) {
|
|
}
|
|
});
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && Is.func(candidate.sendCancellation) && Is.func(candidate.cleanup);
|
|
}
|
|
CancellationSenderStrategy2.is = is;
|
|
})(CancellationSenderStrategy = exports2.CancellationSenderStrategy || (exports2.CancellationSenderStrategy = {}));
|
|
var CancellationStrategy;
|
|
(function(CancellationStrategy2) {
|
|
CancellationStrategy2.Message = Object.freeze({
|
|
receiver: CancellationReceiverStrategy.Message,
|
|
sender: CancellationSenderStrategy.Message
|
|
});
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && CancellationReceiverStrategy.is(candidate.receiver) && CancellationSenderStrategy.is(candidate.sender);
|
|
}
|
|
CancellationStrategy2.is = is;
|
|
})(CancellationStrategy = exports2.CancellationStrategy || (exports2.CancellationStrategy = {}));
|
|
var ConnectionOptions;
|
|
(function(ConnectionOptions2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && (CancellationStrategy.is(candidate.cancellationStrategy) || ConnectionStrategy.is(candidate.connectionStrategy));
|
|
}
|
|
ConnectionOptions2.is = is;
|
|
})(ConnectionOptions = exports2.ConnectionOptions || (exports2.ConnectionOptions = {}));
|
|
var ConnectionState;
|
|
(function(ConnectionState2) {
|
|
ConnectionState2[ConnectionState2["New"] = 1] = "New";
|
|
ConnectionState2[ConnectionState2["Listening"] = 2] = "Listening";
|
|
ConnectionState2[ConnectionState2["Closed"] = 3] = "Closed";
|
|
ConnectionState2[ConnectionState2["Disposed"] = 4] = "Disposed";
|
|
})(ConnectionState || (ConnectionState = {}));
|
|
function createMessageConnection(messageReader, messageWriter, _logger, options) {
|
|
const logger = _logger !== void 0 ? _logger : exports2.NullLogger;
|
|
let sequenceNumber = 0;
|
|
let notificationSquenceNumber = 0;
|
|
let unknownResponseSquenceNumber = 0;
|
|
const version = "2.0";
|
|
let starRequestHandler = void 0;
|
|
const requestHandlers = Object.create(null);
|
|
let starNotificationHandler = void 0;
|
|
const notificationHandlers = Object.create(null);
|
|
const progressHandlers = new Map();
|
|
let timer;
|
|
let messageQueue = new linkedMap_1.LinkedMap();
|
|
let responsePromises = Object.create(null);
|
|
let requestTokens = Object.create(null);
|
|
let trace = Trace.Off;
|
|
let traceFormat = TraceFormat.Text;
|
|
let tracer;
|
|
let state = ConnectionState.New;
|
|
const errorEmitter = new events_1.Emitter();
|
|
const closeEmitter = new events_1.Emitter();
|
|
const unhandledNotificationEmitter = new events_1.Emitter();
|
|
const unhandledProgressEmitter = new events_1.Emitter();
|
|
const disposeEmitter = new events_1.Emitter();
|
|
const cancellationStrategy = options && options.cancellationStrategy ? options.cancellationStrategy : CancellationStrategy.Message;
|
|
function createRequestQueueKey(id) {
|
|
if (id === null) {
|
|
throw new Error(`Can't send requests with id null since the response can't be correlated.`);
|
|
}
|
|
return "req-" + id.toString();
|
|
}
|
|
function createResponseQueueKey(id) {
|
|
if (id === null) {
|
|
return "res-unknown-" + (++unknownResponseSquenceNumber).toString();
|
|
} else {
|
|
return "res-" + id.toString();
|
|
}
|
|
}
|
|
function createNotificationQueueKey() {
|
|
return "not-" + (++notificationSquenceNumber).toString();
|
|
}
|
|
function addMessageToQueue(queue, message) {
|
|
if (messages_1.isRequestMessage(message)) {
|
|
queue.set(createRequestQueueKey(message.id), message);
|
|
} else if (messages_1.isResponseMessage(message)) {
|
|
queue.set(createResponseQueueKey(message.id), message);
|
|
} else {
|
|
queue.set(createNotificationQueueKey(), message);
|
|
}
|
|
}
|
|
function cancelUndispatched(_message) {
|
|
return void 0;
|
|
}
|
|
function isListening() {
|
|
return state === ConnectionState.Listening;
|
|
}
|
|
function isClosed() {
|
|
return state === ConnectionState.Closed;
|
|
}
|
|
function isDisposed() {
|
|
return state === ConnectionState.Disposed;
|
|
}
|
|
function closeHandler() {
|
|
if (state === ConnectionState.New || state === ConnectionState.Listening) {
|
|
state = ConnectionState.Closed;
|
|
closeEmitter.fire(void 0);
|
|
}
|
|
}
|
|
function readErrorHandler(error) {
|
|
errorEmitter.fire([error, void 0, void 0]);
|
|
}
|
|
function writeErrorHandler(data) {
|
|
errorEmitter.fire(data);
|
|
}
|
|
messageReader.onClose(closeHandler);
|
|
messageReader.onError(readErrorHandler);
|
|
messageWriter.onClose(closeHandler);
|
|
messageWriter.onError(writeErrorHandler);
|
|
function triggerMessageQueue() {
|
|
if (timer || messageQueue.size === 0) {
|
|
return;
|
|
}
|
|
timer = ral_1.default().timer.setImmediate(() => {
|
|
timer = void 0;
|
|
processMessageQueue();
|
|
});
|
|
}
|
|
function processMessageQueue() {
|
|
if (messageQueue.size === 0) {
|
|
return;
|
|
}
|
|
const message = messageQueue.shift();
|
|
try {
|
|
if (messages_1.isRequestMessage(message)) {
|
|
handleRequest(message);
|
|
} else if (messages_1.isNotificationMessage(message)) {
|
|
handleNotification(message);
|
|
} else if (messages_1.isResponseMessage(message)) {
|
|
handleResponse(message);
|
|
} else {
|
|
handleInvalidMessage(message);
|
|
}
|
|
} finally {
|
|
triggerMessageQueue();
|
|
}
|
|
}
|
|
const callback = (message) => {
|
|
try {
|
|
if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
|
|
const key = createRequestQueueKey(message.params.id);
|
|
const toCancel = messageQueue.get(key);
|
|
if (messages_1.isRequestMessage(toCancel)) {
|
|
const strategy = options === null || options === void 0 ? void 0 : options.connectionStrategy;
|
|
const response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
|
|
if (response && (response.error !== void 0 || response.result !== void 0)) {
|
|
messageQueue.delete(key);
|
|
response.id = toCancel.id;
|
|
traceSendingResponse(response, message.method, Date.now());
|
|
messageWriter.write(response);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
addMessageToQueue(messageQueue, message);
|
|
} finally {
|
|
triggerMessageQueue();
|
|
}
|
|
};
|
|
function handleRequest(requestMessage) {
|
|
if (isDisposed()) {
|
|
return;
|
|
}
|
|
function reply(resultOrError, method, startTime2) {
|
|
const message = {
|
|
jsonrpc: version,
|
|
id: requestMessage.id
|
|
};
|
|
if (resultOrError instanceof messages_1.ResponseError) {
|
|
message.error = resultOrError.toJson();
|
|
} else {
|
|
message.result = resultOrError === void 0 ? null : resultOrError;
|
|
}
|
|
traceSendingResponse(message, method, startTime2);
|
|
messageWriter.write(message);
|
|
}
|
|
function replyError(error, method, startTime2) {
|
|
const message = {
|
|
jsonrpc: version,
|
|
id: requestMessage.id,
|
|
error: error.toJson()
|
|
};
|
|
traceSendingResponse(message, method, startTime2);
|
|
messageWriter.write(message);
|
|
}
|
|
function replySuccess(result, method, startTime2) {
|
|
if (result === void 0) {
|
|
result = null;
|
|
}
|
|
const message = {
|
|
jsonrpc: version,
|
|
id: requestMessage.id,
|
|
result
|
|
};
|
|
traceSendingResponse(message, method, startTime2);
|
|
messageWriter.write(message);
|
|
}
|
|
traceReceivedRequest(requestMessage);
|
|
const element = requestHandlers[requestMessage.method];
|
|
let type;
|
|
let requestHandler;
|
|
if (element) {
|
|
type = element.type;
|
|
requestHandler = element.handler;
|
|
}
|
|
const startTime = Date.now();
|
|
if (requestHandler || starRequestHandler) {
|
|
const tokenKey = String(requestMessage.id);
|
|
const cancellationSource = cancellationStrategy.receiver.createCancellationTokenSource(tokenKey);
|
|
requestTokens[tokenKey] = cancellationSource;
|
|
try {
|
|
let handlerResult;
|
|
if (requestHandler) {
|
|
if (requestMessage.params === void 0) {
|
|
if (type !== void 0 && type.numberOfParams !== 0) {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines ${type.numberOfParams} params but recevied none.`), requestMessage.method, startTime);
|
|
return;
|
|
}
|
|
handlerResult = requestHandler(cancellationSource.token);
|
|
} else if (Array.isArray(requestMessage.params)) {
|
|
if (type !== void 0 && type.parameterStructures === messages_1.ParameterStructures.byName) {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by name but received parameters by position`), requestMessage.method, startTime);
|
|
return;
|
|
}
|
|
handlerResult = requestHandler(...requestMessage.params, cancellationSource.token);
|
|
} else {
|
|
if (type !== void 0 && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by position but received parameters by name`), requestMessage.method, startTime);
|
|
return;
|
|
}
|
|
handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
|
|
}
|
|
} else if (starRequestHandler) {
|
|
handlerResult = starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
|
|
}
|
|
const promise = handlerResult;
|
|
if (!handlerResult) {
|
|
delete requestTokens[tokenKey];
|
|
replySuccess(handlerResult, requestMessage.method, startTime);
|
|
} else if (promise.then) {
|
|
promise.then((resultOrError) => {
|
|
delete requestTokens[tokenKey];
|
|
reply(resultOrError, requestMessage.method, startTime);
|
|
}, (error) => {
|
|
delete requestTokens[tokenKey];
|
|
if (error instanceof messages_1.ResponseError) {
|
|
replyError(error, requestMessage.method, startTime);
|
|
} else if (error && Is.string(error.message)) {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
|
|
} else {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
|
|
}
|
|
});
|
|
} else {
|
|
delete requestTokens[tokenKey];
|
|
reply(handlerResult, requestMessage.method, startTime);
|
|
}
|
|
} catch (error) {
|
|
delete requestTokens[tokenKey];
|
|
if (error instanceof messages_1.ResponseError) {
|
|
reply(error, requestMessage.method, startTime);
|
|
} else if (error && Is.string(error.message)) {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
|
|
} else {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
|
|
}
|
|
}
|
|
} else {
|
|
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
|
|
}
|
|
}
|
|
function handleResponse(responseMessage) {
|
|
if (isDisposed()) {
|
|
return;
|
|
}
|
|
if (responseMessage.id === null) {
|
|
if (responseMessage.error) {
|
|
logger.error(`Received response message without id: Error is:
|
|
${JSON.stringify(responseMessage.error, void 0, 4)}`);
|
|
} else {
|
|
logger.error(`Received response message without id. No further error information provided.`);
|
|
}
|
|
} else {
|
|
const key = String(responseMessage.id);
|
|
const responsePromise = responsePromises[key];
|
|
traceReceivedResponse(responseMessage, responsePromise);
|
|
if (responsePromise) {
|
|
delete responsePromises[key];
|
|
try {
|
|
if (responseMessage.error) {
|
|
const error = responseMessage.error;
|
|
responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
|
|
} else if (responseMessage.result !== void 0) {
|
|
responsePromise.resolve(responseMessage.result);
|
|
} else {
|
|
throw new Error("Should never happen.");
|
|
}
|
|
} catch (error) {
|
|
if (error.message) {
|
|
logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
|
|
} else {
|
|
logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function handleNotification(message) {
|
|
if (isDisposed()) {
|
|
return;
|
|
}
|
|
let type = void 0;
|
|
let notificationHandler;
|
|
if (message.method === CancelNotification.type.method) {
|
|
notificationHandler = (params) => {
|
|
const id = params.id;
|
|
const source = requestTokens[String(id)];
|
|
if (source) {
|
|
source.cancel();
|
|
}
|
|
};
|
|
} else {
|
|
const element = notificationHandlers[message.method];
|
|
if (element) {
|
|
notificationHandler = element.handler;
|
|
type = element.type;
|
|
}
|
|
}
|
|
if (notificationHandler || starNotificationHandler) {
|
|
try {
|
|
traceReceivedNotification(message);
|
|
if (notificationHandler) {
|
|
if (message.params === void 0) {
|
|
if (type !== void 0) {
|
|
if (type.numberOfParams !== 0 && type.parameterStructures !== messages_1.ParameterStructures.byName) {
|
|
logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but recevied none.`);
|
|
}
|
|
}
|
|
notificationHandler();
|
|
} else if (Array.isArray(message.params)) {
|
|
if (type !== void 0) {
|
|
if (type.parameterStructures === messages_1.ParameterStructures.byName) {
|
|
logger.error(`Notification ${message.method} defines parameters by name but received parameters by position`);
|
|
}
|
|
if (type.numberOfParams !== message.params.length) {
|
|
logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but received ${message.params.length} argumennts`);
|
|
}
|
|
}
|
|
notificationHandler(...message.params);
|
|
} else {
|
|
if (type !== void 0 && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
|
|
logger.error(`Notification ${message.method} defines parameters by position but received parameters by name`);
|
|
}
|
|
notificationHandler(message.params);
|
|
}
|
|
} else if (starNotificationHandler) {
|
|
starNotificationHandler(message.method, message.params);
|
|
}
|
|
} catch (error) {
|
|
if (error.message) {
|
|
logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
|
|
} else {
|
|
logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
|
|
}
|
|
}
|
|
} else {
|
|
unhandledNotificationEmitter.fire(message);
|
|
}
|
|
}
|
|
function handleInvalidMessage(message) {
|
|
if (!message) {
|
|
logger.error("Received empty message.");
|
|
return;
|
|
}
|
|
logger.error(`Received message which is neither a response nor a notification message:
|
|
${JSON.stringify(message, null, 4)}`);
|
|
const responseMessage = message;
|
|
if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
|
|
const key = String(responseMessage.id);
|
|
const responseHandler = responsePromises[key];
|
|
if (responseHandler) {
|
|
responseHandler.reject(new Error("The received response has neither a result nor an error property."));
|
|
}
|
|
}
|
|
}
|
|
function traceSendingRequest(message) {
|
|
if (trace === Trace.Off || !tracer) {
|
|
return;
|
|
}
|
|
if (traceFormat === TraceFormat.Text) {
|
|
let data = void 0;
|
|
if (trace === Trace.Verbose && message.params) {
|
|
data = `Params: ${JSON.stringify(message.params, null, 4)}
|
|
|
|
`;
|
|
}
|
|
tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
|
|
} else {
|
|
logLSPMessage("send-request", message);
|
|
}
|
|
}
|
|
function traceSendingNotification(message) {
|
|
if (trace === Trace.Off || !tracer) {
|
|
return;
|
|
}
|
|
if (traceFormat === TraceFormat.Text) {
|
|
let data = void 0;
|
|
if (trace === Trace.Verbose) {
|
|
if (message.params) {
|
|
data = `Params: ${JSON.stringify(message.params, null, 4)}
|
|
|
|
`;
|
|
} else {
|
|
data = "No parameters provided.\n\n";
|
|
}
|
|
}
|
|
tracer.log(`Sending notification '${message.method}'.`, data);
|
|
} else {
|
|
logLSPMessage("send-notification", message);
|
|
}
|
|
}
|
|
function traceSendingResponse(message, method, startTime) {
|
|
if (trace === Trace.Off || !tracer) {
|
|
return;
|
|
}
|
|
if (traceFormat === TraceFormat.Text) {
|
|
let data = void 0;
|
|
if (trace === Trace.Verbose) {
|
|
if (message.error && message.error.data) {
|
|
data = `Error data: ${JSON.stringify(message.error.data, null, 4)}
|
|
|
|
`;
|
|
} else {
|
|
if (message.result) {
|
|
data = `Result: ${JSON.stringify(message.result, null, 4)}
|
|
|
|
`;
|
|
} else if (message.error === void 0) {
|
|
data = "No result returned.\n\n";
|
|
}
|
|
}
|
|
}
|
|
tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
|
|
} else {
|
|
logLSPMessage("send-response", message);
|
|
}
|
|
}
|
|
function traceReceivedRequest(message) {
|
|
if (trace === Trace.Off || !tracer) {
|
|
return;
|
|
}
|
|
if (traceFormat === TraceFormat.Text) {
|
|
let data = void 0;
|
|
if (trace === Trace.Verbose && message.params) {
|
|
data = `Params: ${JSON.stringify(message.params, null, 4)}
|
|
|
|
`;
|
|
}
|
|
tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
|
|
} else {
|
|
logLSPMessage("receive-request", message);
|
|
}
|
|
}
|
|
function traceReceivedNotification(message) {
|
|
if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
|
|
return;
|
|
}
|
|
if (traceFormat === TraceFormat.Text) {
|
|
let data = void 0;
|
|
if (trace === Trace.Verbose) {
|
|
if (message.params) {
|
|
data = `Params: ${JSON.stringify(message.params, null, 4)}
|
|
|
|
`;
|
|
} else {
|
|
data = "No parameters provided.\n\n";
|
|
}
|
|
}
|
|
tracer.log(`Received notification '${message.method}'.`, data);
|
|
} else {
|
|
logLSPMessage("receive-notification", message);
|
|
}
|
|
}
|
|
function traceReceivedResponse(message, responsePromise) {
|
|
if (trace === Trace.Off || !tracer) {
|
|
return;
|
|
}
|
|
if (traceFormat === TraceFormat.Text) {
|
|
let data = void 0;
|
|
if (trace === Trace.Verbose) {
|
|
if (message.error && message.error.data) {
|
|
data = `Error data: ${JSON.stringify(message.error.data, null, 4)}
|
|
|
|
`;
|
|
} else {
|
|
if (message.result) {
|
|
data = `Result: ${JSON.stringify(message.result, null, 4)}
|
|
|
|
`;
|
|
} else if (message.error === void 0) {
|
|
data = "No result returned.\n\n";
|
|
}
|
|
}
|
|
}
|
|
if (responsePromise) {
|
|
const error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : "";
|
|
tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
|
|
} else {
|
|
tracer.log(`Received response ${message.id} without active response promise.`, data);
|
|
}
|
|
} else {
|
|
logLSPMessage("receive-response", message);
|
|
}
|
|
}
|
|
function logLSPMessage(type, message) {
|
|
if (!tracer || trace === Trace.Off) {
|
|
return;
|
|
}
|
|
const lspMessage = {
|
|
isLSPMessage: true,
|
|
type,
|
|
message,
|
|
timestamp: Date.now()
|
|
};
|
|
tracer.log(lspMessage);
|
|
}
|
|
function throwIfClosedOrDisposed() {
|
|
if (isClosed()) {
|
|
throw new ConnectionError(ConnectionErrors.Closed, "Connection is closed.");
|
|
}
|
|
if (isDisposed()) {
|
|
throw new ConnectionError(ConnectionErrors.Disposed, "Connection is disposed.");
|
|
}
|
|
}
|
|
function throwIfListening() {
|
|
if (isListening()) {
|
|
throw new ConnectionError(ConnectionErrors.AlreadyListening, "Connection is already listening");
|
|
}
|
|
}
|
|
function throwIfNotListening() {
|
|
if (!isListening()) {
|
|
throw new Error("Call listen() first.");
|
|
}
|
|
}
|
|
function undefinedToNull(param) {
|
|
if (param === void 0) {
|
|
return null;
|
|
} else {
|
|
return param;
|
|
}
|
|
}
|
|
function nullToUndefined(param) {
|
|
if (param === null) {
|
|
return void 0;
|
|
} else {
|
|
return param;
|
|
}
|
|
}
|
|
function isNamedParam(param) {
|
|
return param !== void 0 && param !== null && !Array.isArray(param) && typeof param === "object";
|
|
}
|
|
function computeSingleParam(parameterStructures, param) {
|
|
switch (parameterStructures) {
|
|
case messages_1.ParameterStructures.auto:
|
|
if (isNamedParam(param)) {
|
|
return nullToUndefined(param);
|
|
} else {
|
|
return [undefinedToNull(param)];
|
|
}
|
|
break;
|
|
case messages_1.ParameterStructures.byName:
|
|
if (!isNamedParam(param)) {
|
|
throw new Error(`Recevied parameters by name but param is not an object literal.`);
|
|
}
|
|
return nullToUndefined(param);
|
|
case messages_1.ParameterStructures.byPosition:
|
|
return [undefinedToNull(param)];
|
|
default:
|
|
throw new Error(`Unknown parameter structure ${parameterStructures.toString()}`);
|
|
}
|
|
}
|
|
function computeMessageParams(type, params) {
|
|
let result;
|
|
const numberOfParams = type.numberOfParams;
|
|
switch (numberOfParams) {
|
|
case 0:
|
|
result = void 0;
|
|
break;
|
|
case 1:
|
|
result = computeSingleParam(type.parameterStructures, params[0]);
|
|
break;
|
|
default:
|
|
result = [];
|
|
for (let i = 0; i < params.length && i < numberOfParams; i++) {
|
|
result.push(undefinedToNull(params[i]));
|
|
}
|
|
if (params.length < numberOfParams) {
|
|
for (let i = params.length; i < numberOfParams; i++) {
|
|
result.push(null);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
const connection = {
|
|
sendNotification: (type, ...args) => {
|
|
throwIfClosedOrDisposed();
|
|
let method;
|
|
let messageParams;
|
|
if (Is.string(type)) {
|
|
method = type;
|
|
const first = args[0];
|
|
let paramStart = 0;
|
|
let parameterStructures = messages_1.ParameterStructures.auto;
|
|
if (messages_1.ParameterStructures.is(first)) {
|
|
paramStart = 1;
|
|
parameterStructures = first;
|
|
}
|
|
let paramEnd = args.length;
|
|
const numberOfParams = paramEnd - paramStart;
|
|
switch (numberOfParams) {
|
|
case 0:
|
|
messageParams = void 0;
|
|
break;
|
|
case 1:
|
|
messageParams = computeSingleParam(parameterStructures, args[paramStart]);
|
|
break;
|
|
default:
|
|
if (parameterStructures === messages_1.ParameterStructures.byName) {
|
|
throw new Error(`Recevied ${numberOfParams} parameters for 'by Name' notification parameter structure.`);
|
|
}
|
|
messageParams = args.slice(paramStart, paramEnd).map((value) => undefinedToNull(value));
|
|
break;
|
|
}
|
|
} else {
|
|
const params = args;
|
|
method = type.method;
|
|
messageParams = computeMessageParams(type, params);
|
|
}
|
|
const notificationMessage = {
|
|
jsonrpc: version,
|
|
method,
|
|
params: messageParams
|
|
};
|
|
traceSendingNotification(notificationMessage);
|
|
messageWriter.write(notificationMessage);
|
|
},
|
|
onNotification: (type, handler) => {
|
|
throwIfClosedOrDisposed();
|
|
let method;
|
|
if (Is.func(type)) {
|
|
starNotificationHandler = type;
|
|
} else if (handler) {
|
|
if (Is.string(type)) {
|
|
method = type;
|
|
notificationHandlers[type] = {type: void 0, handler};
|
|
} else {
|
|
method = type.method;
|
|
notificationHandlers[type.method] = {type, handler};
|
|
}
|
|
}
|
|
return {
|
|
dispose: () => {
|
|
if (method !== void 0) {
|
|
delete notificationHandlers[method];
|
|
} else {
|
|
starNotificationHandler = void 0;
|
|
}
|
|
}
|
|
};
|
|
},
|
|
onProgress: (_type, token, handler) => {
|
|
if (progressHandlers.has(token)) {
|
|
throw new Error(`Progress handler for token ${token} already registered`);
|
|
}
|
|
progressHandlers.set(token, handler);
|
|
return {
|
|
dispose: () => {
|
|
progressHandlers.delete(token);
|
|
}
|
|
};
|
|
},
|
|
sendProgress: (_type, token, value) => {
|
|
connection.sendNotification(ProgressNotification.type, {token, value});
|
|
},
|
|
onUnhandledProgress: unhandledProgressEmitter.event,
|
|
sendRequest: (type, ...args) => {
|
|
throwIfClosedOrDisposed();
|
|
throwIfNotListening();
|
|
let method;
|
|
let messageParams;
|
|
let token = void 0;
|
|
if (Is.string(type)) {
|
|
method = type;
|
|
const first = args[0];
|
|
const last = args[args.length - 1];
|
|
let paramStart = 0;
|
|
let parameterStructures = messages_1.ParameterStructures.auto;
|
|
if (messages_1.ParameterStructures.is(first)) {
|
|
paramStart = 1;
|
|
parameterStructures = first;
|
|
}
|
|
let paramEnd = args.length;
|
|
if (cancellation_1.CancellationToken.is(last)) {
|
|
paramEnd = paramEnd - 1;
|
|
token = last;
|
|
}
|
|
const numberOfParams = paramEnd - paramStart;
|
|
switch (numberOfParams) {
|
|
case 0:
|
|
messageParams = void 0;
|
|
break;
|
|
case 1:
|
|
messageParams = computeSingleParam(parameterStructures, args[paramStart]);
|
|
break;
|
|
default:
|
|
if (parameterStructures === messages_1.ParameterStructures.byName) {
|
|
throw new Error(`Recevied ${numberOfParams} parameters for 'by Name' request parameter structure.`);
|
|
}
|
|
messageParams = args.slice(paramStart, paramEnd).map((value) => undefinedToNull(value));
|
|
break;
|
|
}
|
|
} else {
|
|
const params = args;
|
|
method = type.method;
|
|
messageParams = computeMessageParams(type, params);
|
|
const numberOfParams = type.numberOfParams;
|
|
token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : void 0;
|
|
}
|
|
const id = sequenceNumber++;
|
|
let disposable;
|
|
if (token) {
|
|
disposable = token.onCancellationRequested(() => {
|
|
cancellationStrategy.sender.sendCancellation(connection, id);
|
|
});
|
|
}
|
|
const result = new Promise((resolve, reject) => {
|
|
const requestMessage = {
|
|
jsonrpc: version,
|
|
id,
|
|
method,
|
|
params: messageParams
|
|
};
|
|
const resolveWithCleanup = (r) => {
|
|
resolve(r);
|
|
cancellationStrategy.sender.cleanup(id);
|
|
disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
|
|
};
|
|
const rejectWithCleanup = (r) => {
|
|
reject(r);
|
|
cancellationStrategy.sender.cleanup(id);
|
|
disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
|
|
};
|
|
let responsePromise = {method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup};
|
|
traceSendingRequest(requestMessage);
|
|
try {
|
|
messageWriter.write(requestMessage);
|
|
} catch (e) {
|
|
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : "Unknown reason"));
|
|
responsePromise = null;
|
|
}
|
|
if (responsePromise) {
|
|
responsePromises[String(id)] = responsePromise;
|
|
}
|
|
});
|
|
return result;
|
|
},
|
|
onRequest: (type, handler) => {
|
|
throwIfClosedOrDisposed();
|
|
let method = null;
|
|
if (StarRequestHandler.is(type)) {
|
|
method = void 0;
|
|
starRequestHandler = type;
|
|
} else if (Is.string(type)) {
|
|
method = null;
|
|
if (handler !== void 0) {
|
|
method = type;
|
|
requestHandlers[type] = {handler, type: void 0};
|
|
}
|
|
} else {
|
|
if (handler !== void 0) {
|
|
method = type.method;
|
|
requestHandlers[type.method] = {type, handler};
|
|
}
|
|
}
|
|
return {
|
|
dispose: () => {
|
|
if (method === null) {
|
|
return;
|
|
}
|
|
if (method !== void 0) {
|
|
delete requestHandlers[method];
|
|
} else {
|
|
starRequestHandler = void 0;
|
|
}
|
|
}
|
|
};
|
|
},
|
|
trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
|
|
let _sendNotification = false;
|
|
let _traceFormat = TraceFormat.Text;
|
|
if (sendNotificationOrTraceOptions !== void 0) {
|
|
if (Is.boolean(sendNotificationOrTraceOptions)) {
|
|
_sendNotification = sendNotificationOrTraceOptions;
|
|
} else {
|
|
_sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
|
|
_traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
|
|
}
|
|
}
|
|
trace = _value;
|
|
traceFormat = _traceFormat;
|
|
if (trace === Trace.Off) {
|
|
tracer = void 0;
|
|
} else {
|
|
tracer = _tracer;
|
|
}
|
|
if (_sendNotification && !isClosed() && !isDisposed()) {
|
|
connection.sendNotification(SetTraceNotification.type, {value: Trace.toString(_value)});
|
|
}
|
|
},
|
|
onError: errorEmitter.event,
|
|
onClose: closeEmitter.event,
|
|
onUnhandledNotification: unhandledNotificationEmitter.event,
|
|
onDispose: disposeEmitter.event,
|
|
end: () => {
|
|
messageWriter.end();
|
|
},
|
|
dispose: () => {
|
|
if (isDisposed()) {
|
|
return;
|
|
}
|
|
state = ConnectionState.Disposed;
|
|
disposeEmitter.fire(void 0);
|
|
const error = new Error("Connection got disposed.");
|
|
Object.keys(responsePromises).forEach((key) => {
|
|
responsePromises[key].reject(error);
|
|
});
|
|
responsePromises = Object.create(null);
|
|
requestTokens = Object.create(null);
|
|
messageQueue = new linkedMap_1.LinkedMap();
|
|
if (Is.func(messageWriter.dispose)) {
|
|
messageWriter.dispose();
|
|
}
|
|
if (Is.func(messageReader.dispose)) {
|
|
messageReader.dispose();
|
|
}
|
|
},
|
|
listen: () => {
|
|
throwIfClosedOrDisposed();
|
|
throwIfListening();
|
|
state = ConnectionState.Listening;
|
|
messageReader.listen(callback);
|
|
},
|
|
inspect: () => {
|
|
ral_1.default().console.log("inspect");
|
|
}
|
|
};
|
|
connection.onNotification(LogTraceNotification.type, (params) => {
|
|
if (trace === Trace.Off || !tracer) {
|
|
return;
|
|
}
|
|
tracer.log(params.message, trace === Trace.Verbose ? params.verbose : void 0);
|
|
});
|
|
connection.onNotification(ProgressNotification.type, (params) => {
|
|
const handler = progressHandlers.get(params.token);
|
|
if (handler) {
|
|
handler(params.value);
|
|
} else {
|
|
unhandledProgressEmitter.fire(params);
|
|
}
|
|
});
|
|
return connection;
|
|
}
|
|
exports2.createMessageConnection = createMessageConnection;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/common/api.js
|
|
var require_api = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.CancellationSenderStrategy = exports2.CancellationReceiverStrategy = exports2.ConnectionError = exports2.ConnectionErrors = exports2.LogTraceNotification = exports2.SetTraceNotification = exports2.TraceFormat = exports2.Trace = exports2.ProgressType = exports2.createMessageConnection = exports2.NullLogger = exports2.ConnectionOptions = exports2.ConnectionStrategy = exports2.WriteableStreamMessageWriter = exports2.AbstractMessageWriter = exports2.MessageWriter = exports2.ReadableStreamMessageReader = exports2.AbstractMessageReader = exports2.MessageReader = exports2.CancellationToken = exports2.CancellationTokenSource = exports2.Emitter = exports2.Event = exports2.Disposable = exports2.ParameterStructures = exports2.NotificationType9 = exports2.NotificationType8 = exports2.NotificationType7 = exports2.NotificationType6 = exports2.NotificationType5 = exports2.NotificationType4 = exports2.NotificationType3 = exports2.NotificationType2 = exports2.NotificationType1 = exports2.NotificationType0 = exports2.NotificationType = exports2.ErrorCodes = exports2.ResponseError = exports2.RequestType9 = exports2.RequestType8 = exports2.RequestType7 = exports2.RequestType6 = exports2.RequestType5 = exports2.RequestType4 = exports2.RequestType3 = exports2.RequestType2 = exports2.RequestType1 = exports2.RequestType0 = exports2.RequestType = exports2.RAL = void 0;
|
|
exports2.CancellationStrategy = void 0;
|
|
var messages_1 = require_messages();
|
|
Object.defineProperty(exports2, "RequestType", {enumerable: true, get: function() {
|
|
return messages_1.RequestType;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType0", {enumerable: true, get: function() {
|
|
return messages_1.RequestType0;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType1", {enumerable: true, get: function() {
|
|
return messages_1.RequestType1;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType2", {enumerable: true, get: function() {
|
|
return messages_1.RequestType2;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType3", {enumerable: true, get: function() {
|
|
return messages_1.RequestType3;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType4", {enumerable: true, get: function() {
|
|
return messages_1.RequestType4;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType5", {enumerable: true, get: function() {
|
|
return messages_1.RequestType5;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType6", {enumerable: true, get: function() {
|
|
return messages_1.RequestType6;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType7", {enumerable: true, get: function() {
|
|
return messages_1.RequestType7;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType8", {enumerable: true, get: function() {
|
|
return messages_1.RequestType8;
|
|
}});
|
|
Object.defineProperty(exports2, "RequestType9", {enumerable: true, get: function() {
|
|
return messages_1.RequestType9;
|
|
}});
|
|
Object.defineProperty(exports2, "ResponseError", {enumerable: true, get: function() {
|
|
return messages_1.ResponseError;
|
|
}});
|
|
Object.defineProperty(exports2, "ErrorCodes", {enumerable: true, get: function() {
|
|
return messages_1.ErrorCodes;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType0", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType0;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType1", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType1;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType2", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType2;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType3", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType3;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType4", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType4;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType5", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType5;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType6", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType6;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType7", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType7;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType8", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType8;
|
|
}});
|
|
Object.defineProperty(exports2, "NotificationType9", {enumerable: true, get: function() {
|
|
return messages_1.NotificationType9;
|
|
}});
|
|
Object.defineProperty(exports2, "ParameterStructures", {enumerable: true, get: function() {
|
|
return messages_1.ParameterStructures;
|
|
}});
|
|
var disposable_1 = require_disposable();
|
|
Object.defineProperty(exports2, "Disposable", {enumerable: true, get: function() {
|
|
return disposable_1.Disposable;
|
|
}});
|
|
var events_1 = require_events();
|
|
Object.defineProperty(exports2, "Event", {enumerable: true, get: function() {
|
|
return events_1.Event;
|
|
}});
|
|
Object.defineProperty(exports2, "Emitter", {enumerable: true, get: function() {
|
|
return events_1.Emitter;
|
|
}});
|
|
var cancellation_1 = require_cancellation();
|
|
Object.defineProperty(exports2, "CancellationTokenSource", {enumerable: true, get: function() {
|
|
return cancellation_1.CancellationTokenSource;
|
|
}});
|
|
Object.defineProperty(exports2, "CancellationToken", {enumerable: true, get: function() {
|
|
return cancellation_1.CancellationToken;
|
|
}});
|
|
var messageReader_1 = require_messageReader();
|
|
Object.defineProperty(exports2, "MessageReader", {enumerable: true, get: function() {
|
|
return messageReader_1.MessageReader;
|
|
}});
|
|
Object.defineProperty(exports2, "AbstractMessageReader", {enumerable: true, get: function() {
|
|
return messageReader_1.AbstractMessageReader;
|
|
}});
|
|
Object.defineProperty(exports2, "ReadableStreamMessageReader", {enumerable: true, get: function() {
|
|
return messageReader_1.ReadableStreamMessageReader;
|
|
}});
|
|
var messageWriter_1 = require_messageWriter();
|
|
Object.defineProperty(exports2, "MessageWriter", {enumerable: true, get: function() {
|
|
return messageWriter_1.MessageWriter;
|
|
}});
|
|
Object.defineProperty(exports2, "AbstractMessageWriter", {enumerable: true, get: function() {
|
|
return messageWriter_1.AbstractMessageWriter;
|
|
}});
|
|
Object.defineProperty(exports2, "WriteableStreamMessageWriter", {enumerable: true, get: function() {
|
|
return messageWriter_1.WriteableStreamMessageWriter;
|
|
}});
|
|
var connection_1 = require_connection();
|
|
Object.defineProperty(exports2, "ConnectionStrategy", {enumerable: true, get: function() {
|
|
return connection_1.ConnectionStrategy;
|
|
}});
|
|
Object.defineProperty(exports2, "ConnectionOptions", {enumerable: true, get: function() {
|
|
return connection_1.ConnectionOptions;
|
|
}});
|
|
Object.defineProperty(exports2, "NullLogger", {enumerable: true, get: function() {
|
|
return connection_1.NullLogger;
|
|
}});
|
|
Object.defineProperty(exports2, "createMessageConnection", {enumerable: true, get: function() {
|
|
return connection_1.createMessageConnection;
|
|
}});
|
|
Object.defineProperty(exports2, "ProgressType", {enumerable: true, get: function() {
|
|
return connection_1.ProgressType;
|
|
}});
|
|
Object.defineProperty(exports2, "Trace", {enumerable: true, get: function() {
|
|
return connection_1.Trace;
|
|
}});
|
|
Object.defineProperty(exports2, "TraceFormat", {enumerable: true, get: function() {
|
|
return connection_1.TraceFormat;
|
|
}});
|
|
Object.defineProperty(exports2, "SetTraceNotification", {enumerable: true, get: function() {
|
|
return connection_1.SetTraceNotification;
|
|
}});
|
|
Object.defineProperty(exports2, "LogTraceNotification", {enumerable: true, get: function() {
|
|
return connection_1.LogTraceNotification;
|
|
}});
|
|
Object.defineProperty(exports2, "ConnectionErrors", {enumerable: true, get: function() {
|
|
return connection_1.ConnectionErrors;
|
|
}});
|
|
Object.defineProperty(exports2, "ConnectionError", {enumerable: true, get: function() {
|
|
return connection_1.ConnectionError;
|
|
}});
|
|
Object.defineProperty(exports2, "CancellationReceiverStrategy", {enumerable: true, get: function() {
|
|
return connection_1.CancellationReceiverStrategy;
|
|
}});
|
|
Object.defineProperty(exports2, "CancellationSenderStrategy", {enumerable: true, get: function() {
|
|
return connection_1.CancellationSenderStrategy;
|
|
}});
|
|
Object.defineProperty(exports2, "CancellationStrategy", {enumerable: true, get: function() {
|
|
return connection_1.CancellationStrategy;
|
|
}});
|
|
var ral_1 = require_ral();
|
|
exports2.RAL = ral_1.default;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/lib/node/main.js
|
|
var require_main = __commonJS((exports2) => {
|
|
"use strict";
|
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
Object.defineProperty(o, k2, {enumerable: true, get: function() {
|
|
return m[k];
|
|
}});
|
|
} : function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
o[k2] = m[k];
|
|
});
|
|
var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
for (var p in m)
|
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
|
|
__createBinding(exports3, m, p);
|
|
};
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.createMessageConnection = exports2.createServerSocketTransport = exports2.createClientSocketTransport = exports2.createServerPipeTransport = exports2.createClientPipeTransport = exports2.generateRandomPipeName = exports2.StreamMessageWriter = exports2.StreamMessageReader = exports2.SocketMessageWriter = exports2.SocketMessageReader = exports2.IPCMessageWriter = exports2.IPCMessageReader = void 0;
|
|
var ril_1 = require_ril();
|
|
ril_1.default.install();
|
|
var api_1 = require_api();
|
|
var path = require("path");
|
|
var os = require("os");
|
|
var crypto_1 = require("crypto");
|
|
var net_1 = require("net");
|
|
__exportStar2(require_api(), exports2);
|
|
var IPCMessageReader = class extends api_1.AbstractMessageReader {
|
|
constructor(process2) {
|
|
super();
|
|
this.process = process2;
|
|
let eventEmitter = this.process;
|
|
eventEmitter.on("error", (error) => this.fireError(error));
|
|
eventEmitter.on("close", () => this.fireClose());
|
|
}
|
|
listen(callback) {
|
|
this.process.on("message", callback);
|
|
return api_1.Disposable.create(() => this.process.off("message", callback));
|
|
}
|
|
};
|
|
exports2.IPCMessageReader = IPCMessageReader;
|
|
var IPCMessageWriter = class extends api_1.AbstractMessageWriter {
|
|
constructor(process2) {
|
|
super();
|
|
this.process = process2;
|
|
this.errorCount = 0;
|
|
let eventEmitter = this.process;
|
|
eventEmitter.on("error", (error) => this.fireError(error));
|
|
eventEmitter.on("close", () => this.fireClose);
|
|
}
|
|
write(msg) {
|
|
try {
|
|
if (typeof this.process.send === "function") {
|
|
this.process.send(msg, void 0, void 0, (error) => {
|
|
if (error) {
|
|
this.errorCount++;
|
|
this.handleError(error, msg);
|
|
} else {
|
|
this.errorCount = 0;
|
|
}
|
|
});
|
|
}
|
|
return Promise.resolve();
|
|
} catch (error) {
|
|
this.handleError(error, msg);
|
|
return Promise.reject(error);
|
|
}
|
|
}
|
|
handleError(error, msg) {
|
|
this.errorCount++;
|
|
this.fireError(error, msg, this.errorCount);
|
|
}
|
|
end() {
|
|
}
|
|
};
|
|
exports2.IPCMessageWriter = IPCMessageWriter;
|
|
var SocketMessageReader = class extends api_1.ReadableStreamMessageReader {
|
|
constructor(socket, encoding = "utf-8") {
|
|
super(ril_1.default().stream.asReadableStream(socket), encoding);
|
|
}
|
|
};
|
|
exports2.SocketMessageReader = SocketMessageReader;
|
|
var SocketMessageWriter = class extends api_1.WriteableStreamMessageWriter {
|
|
constructor(socket, options) {
|
|
super(ril_1.default().stream.asWritableStream(socket), options);
|
|
this.socket = socket;
|
|
}
|
|
dispose() {
|
|
super.dispose();
|
|
this.socket.destroy();
|
|
}
|
|
};
|
|
exports2.SocketMessageWriter = SocketMessageWriter;
|
|
var StreamMessageReader = class extends api_1.ReadableStreamMessageReader {
|
|
constructor(readble, encoding) {
|
|
super(ril_1.default().stream.asReadableStream(readble), encoding);
|
|
}
|
|
};
|
|
exports2.StreamMessageReader = StreamMessageReader;
|
|
var StreamMessageWriter = class extends api_1.WriteableStreamMessageWriter {
|
|
constructor(writable, options) {
|
|
super(ril_1.default().stream.asWritableStream(writable), options);
|
|
}
|
|
};
|
|
exports2.StreamMessageWriter = StreamMessageWriter;
|
|
var XDG_RUNTIME_DIR = process.env["XDG_RUNTIME_DIR"];
|
|
var safeIpcPathLengths = new Map([
|
|
["linux", 107],
|
|
["darwin", 103]
|
|
]);
|
|
function generateRandomPipeName() {
|
|
const randomSuffix = crypto_1.randomBytes(21).toString("hex");
|
|
if (process.platform === "win32") {
|
|
return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
|
|
}
|
|
let result;
|
|
if (XDG_RUNTIME_DIR) {
|
|
result = path.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
|
|
} else {
|
|
result = path.join(os.tmpdir(), `vscode-${randomSuffix}.sock`);
|
|
}
|
|
const limit = safeIpcPathLengths.get(process.platform);
|
|
if (limit !== void 0 && result.length >= limit) {
|
|
ril_1.default().console.warn(`WARNING: IPC handle "${result}" is longer than ${limit} characters.`);
|
|
}
|
|
return result;
|
|
}
|
|
exports2.generateRandomPipeName = generateRandomPipeName;
|
|
function createClientPipeTransport(pipeName, encoding = "utf-8") {
|
|
let connectResolve;
|
|
const connected = new Promise((resolve, _reject) => {
|
|
connectResolve = resolve;
|
|
});
|
|
return new Promise((resolve, reject) => {
|
|
let server = net_1.createServer((socket) => {
|
|
server.close();
|
|
connectResolve([
|
|
new SocketMessageReader(socket, encoding),
|
|
new SocketMessageWriter(socket, encoding)
|
|
]);
|
|
});
|
|
server.on("error", reject);
|
|
server.listen(pipeName, () => {
|
|
server.removeListener("error", reject);
|
|
resolve({
|
|
onConnected: () => {
|
|
return connected;
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
exports2.createClientPipeTransport = createClientPipeTransport;
|
|
function createServerPipeTransport(pipeName, encoding = "utf-8") {
|
|
const socket = net_1.createConnection(pipeName);
|
|
return [
|
|
new SocketMessageReader(socket, encoding),
|
|
new SocketMessageWriter(socket, encoding)
|
|
];
|
|
}
|
|
exports2.createServerPipeTransport = createServerPipeTransport;
|
|
function createClientSocketTransport(port, encoding = "utf-8") {
|
|
let connectResolve;
|
|
const connected = new Promise((resolve, _reject) => {
|
|
connectResolve = resolve;
|
|
});
|
|
return new Promise((resolve, reject) => {
|
|
const server = net_1.createServer((socket) => {
|
|
server.close();
|
|
connectResolve([
|
|
new SocketMessageReader(socket, encoding),
|
|
new SocketMessageWriter(socket, encoding)
|
|
]);
|
|
});
|
|
server.on("error", reject);
|
|
server.listen(port, "127.0.0.1", () => {
|
|
server.removeListener("error", reject);
|
|
resolve({
|
|
onConnected: () => {
|
|
return connected;
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
exports2.createClientSocketTransport = createClientSocketTransport;
|
|
function createServerSocketTransport(port, encoding = "utf-8") {
|
|
const socket = net_1.createConnection(port, "127.0.0.1");
|
|
return [
|
|
new SocketMessageReader(socket, encoding),
|
|
new SocketMessageWriter(socket, encoding)
|
|
];
|
|
}
|
|
exports2.createServerSocketTransport = createServerSocketTransport;
|
|
function isReadableStream(value) {
|
|
const candidate = value;
|
|
return candidate.read !== void 0 && candidate.addListener !== void 0;
|
|
}
|
|
function isWritableStream(value) {
|
|
const candidate = value;
|
|
return candidate.write !== void 0 && candidate.addListener !== void 0;
|
|
}
|
|
function createMessageConnection(input, output, logger, options) {
|
|
if (!logger) {
|
|
logger = api_1.NullLogger;
|
|
}
|
|
const reader = isReadableStream(input) ? new StreamMessageReader(input) : input;
|
|
const writer = isWritableStream(output) ? new StreamMessageWriter(output) : output;
|
|
if (api_1.ConnectionStrategy.is(options)) {
|
|
options = {connectionStrategy: options};
|
|
}
|
|
return api_1.createMessageConnection(reader, writer, logger, options);
|
|
}
|
|
exports2.createMessageConnection = createMessageConnection;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-jsonrpc/node.js
|
|
var require_node = __commonJS((exports2, module2) => {
|
|
"use strict";
|
|
module2.exports = require_main();
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-types/lib/esm/main.js
|
|
var require_main2 = __commonJS((exports2) => {
|
|
__export(exports2, {
|
|
AnnotatedTextEdit: () => AnnotatedTextEdit,
|
|
ChangeAnnotation: () => ChangeAnnotation,
|
|
ChangeAnnotationIdentifier: () => ChangeAnnotationIdentifier,
|
|
CodeAction: () => CodeAction,
|
|
CodeActionContext: () => CodeActionContext,
|
|
CodeActionKind: () => CodeActionKind,
|
|
CodeDescription: () => CodeDescription,
|
|
CodeLens: () => CodeLens,
|
|
Color: () => Color,
|
|
ColorInformation: () => ColorInformation,
|
|
ColorPresentation: () => ColorPresentation,
|
|
Command: () => Command,
|
|
CompletionItem: () => CompletionItem,
|
|
CompletionItemKind: () => CompletionItemKind,
|
|
CompletionItemTag: () => CompletionItemTag,
|
|
CompletionList: () => CompletionList,
|
|
CreateFile: () => CreateFile,
|
|
DeleteFile: () => DeleteFile,
|
|
Diagnostic: () => Diagnostic,
|
|
DiagnosticRelatedInformation: () => DiagnosticRelatedInformation,
|
|
DiagnosticSeverity: () => DiagnosticSeverity,
|
|
DiagnosticTag: () => DiagnosticTag,
|
|
DocumentHighlight: () => DocumentHighlight,
|
|
DocumentHighlightKind: () => DocumentHighlightKind,
|
|
DocumentLink: () => DocumentLink,
|
|
DocumentSymbol: () => DocumentSymbol,
|
|
EOL: () => EOL,
|
|
FoldingRange: () => FoldingRange,
|
|
FoldingRangeKind: () => FoldingRangeKind,
|
|
FormattingOptions: () => FormattingOptions,
|
|
Hover: () => Hover,
|
|
InsertReplaceEdit: () => InsertReplaceEdit,
|
|
InsertTextFormat: () => InsertTextFormat,
|
|
InsertTextMode: () => InsertTextMode,
|
|
Location: () => Location,
|
|
LocationLink: () => LocationLink,
|
|
MarkedString: () => MarkedString,
|
|
MarkupContent: () => MarkupContent,
|
|
MarkupKind: () => MarkupKind,
|
|
OptionalVersionedTextDocumentIdentifier: () => OptionalVersionedTextDocumentIdentifier,
|
|
ParameterInformation: () => ParameterInformation,
|
|
Position: () => Position,
|
|
Range: () => Range,
|
|
RenameFile: () => RenameFile,
|
|
SelectionRange: () => SelectionRange,
|
|
SignatureInformation: () => SignatureInformation,
|
|
SymbolInformation: () => SymbolInformation,
|
|
SymbolKind: () => SymbolKind,
|
|
SymbolTag: () => SymbolTag,
|
|
TextDocument: () => TextDocument2,
|
|
TextDocumentEdit: () => TextDocumentEdit,
|
|
TextDocumentIdentifier: () => TextDocumentIdentifier,
|
|
TextDocumentItem: () => TextDocumentItem,
|
|
TextEdit: () => TextEdit,
|
|
VersionedTextDocumentIdentifier: () => VersionedTextDocumentIdentifier,
|
|
WorkspaceChange: () => WorkspaceChange,
|
|
WorkspaceEdit: () => WorkspaceEdit,
|
|
integer: () => integer,
|
|
uinteger: () => uinteger
|
|
});
|
|
"use strict";
|
|
var integer;
|
|
(function(integer2) {
|
|
integer2.MIN_VALUE = -2147483648;
|
|
integer2.MAX_VALUE = 2147483647;
|
|
})(integer || (integer = {}));
|
|
var uinteger;
|
|
(function(uinteger2) {
|
|
uinteger2.MIN_VALUE = 0;
|
|
uinteger2.MAX_VALUE = 2147483647;
|
|
})(uinteger || (uinteger = {}));
|
|
var Position;
|
|
(function(Position2) {
|
|
function create(line, character) {
|
|
if (line === Number.MAX_VALUE) {
|
|
line = uinteger.MAX_VALUE;
|
|
}
|
|
if (character === Number.MAX_VALUE) {
|
|
character = uinteger.MAX_VALUE;
|
|
}
|
|
return {line, character};
|
|
}
|
|
Position2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
|
|
}
|
|
Position2.is = is;
|
|
})(Position || (Position = {}));
|
|
var Range;
|
|
(function(Range2) {
|
|
function create(one, two, three, four) {
|
|
if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
|
|
return {start: Position.create(one, two), end: Position.create(three, four)};
|
|
} else if (Position.is(one) && Position.is(two)) {
|
|
return {start: one, end: two};
|
|
} else {
|
|
throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
|
|
}
|
|
}
|
|
Range2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
|
|
}
|
|
Range2.is = is;
|
|
})(Range || (Range = {}));
|
|
var Location;
|
|
(function(Location2) {
|
|
function create(uri, range) {
|
|
return {uri, range};
|
|
}
|
|
Location2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
|
|
}
|
|
Location2.is = is;
|
|
})(Location || (Location = {}));
|
|
var LocationLink;
|
|
(function(LocationLink2) {
|
|
function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
|
|
return {targetUri, targetRange, targetSelectionRange, originSelectionRange};
|
|
}
|
|
LocationLink2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
|
|
}
|
|
LocationLink2.is = is;
|
|
})(LocationLink || (LocationLink = {}));
|
|
var Color;
|
|
(function(Color2) {
|
|
function create(red, green, blue, alpha) {
|
|
return {
|
|
red,
|
|
green,
|
|
blue,
|
|
alpha
|
|
};
|
|
}
|
|
Color2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
|
|
}
|
|
Color2.is = is;
|
|
})(Color || (Color = {}));
|
|
var ColorInformation;
|
|
(function(ColorInformation2) {
|
|
function create(range, color) {
|
|
return {
|
|
range,
|
|
color
|
|
};
|
|
}
|
|
ColorInformation2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Range.is(candidate.range) && Color.is(candidate.color);
|
|
}
|
|
ColorInformation2.is = is;
|
|
})(ColorInformation || (ColorInformation = {}));
|
|
var ColorPresentation;
|
|
(function(ColorPresentation2) {
|
|
function create(label, textEdit, additionalTextEdits) {
|
|
return {
|
|
label,
|
|
textEdit,
|
|
additionalTextEdits
|
|
};
|
|
}
|
|
ColorPresentation2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
|
|
}
|
|
ColorPresentation2.is = is;
|
|
})(ColorPresentation || (ColorPresentation = {}));
|
|
var FoldingRangeKind;
|
|
(function(FoldingRangeKind2) {
|
|
FoldingRangeKind2["Comment"] = "comment";
|
|
FoldingRangeKind2["Imports"] = "imports";
|
|
FoldingRangeKind2["Region"] = "region";
|
|
})(FoldingRangeKind || (FoldingRangeKind = {}));
|
|
var FoldingRange;
|
|
(function(FoldingRange2) {
|
|
function create(startLine, endLine, startCharacter, endCharacter, kind) {
|
|
var result = {
|
|
startLine,
|
|
endLine
|
|
};
|
|
if (Is.defined(startCharacter)) {
|
|
result.startCharacter = startCharacter;
|
|
}
|
|
if (Is.defined(endCharacter)) {
|
|
result.endCharacter = endCharacter;
|
|
}
|
|
if (Is.defined(kind)) {
|
|
result.kind = kind;
|
|
}
|
|
return result;
|
|
}
|
|
FoldingRange2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine) && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter)) && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter)) && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
|
|
}
|
|
FoldingRange2.is = is;
|
|
})(FoldingRange || (FoldingRange = {}));
|
|
var DiagnosticRelatedInformation;
|
|
(function(DiagnosticRelatedInformation2) {
|
|
function create(location, message) {
|
|
return {
|
|
location,
|
|
message
|
|
};
|
|
}
|
|
DiagnosticRelatedInformation2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
|
|
}
|
|
DiagnosticRelatedInformation2.is = is;
|
|
})(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
|
|
var DiagnosticSeverity;
|
|
(function(DiagnosticSeverity2) {
|
|
DiagnosticSeverity2.Error = 1;
|
|
DiagnosticSeverity2.Warning = 2;
|
|
DiagnosticSeverity2.Information = 3;
|
|
DiagnosticSeverity2.Hint = 4;
|
|
})(DiagnosticSeverity || (DiagnosticSeverity = {}));
|
|
var DiagnosticTag;
|
|
(function(DiagnosticTag2) {
|
|
DiagnosticTag2.Unnecessary = 1;
|
|
DiagnosticTag2.Deprecated = 2;
|
|
})(DiagnosticTag || (DiagnosticTag = {}));
|
|
var CodeDescription;
|
|
(function(CodeDescription2) {
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate !== void 0 && candidate !== null && Is.string(candidate.href);
|
|
}
|
|
CodeDescription2.is = is;
|
|
})(CodeDescription || (CodeDescription = {}));
|
|
var Diagnostic;
|
|
(function(Diagnostic2) {
|
|
function create(range, message, severity, code, source, relatedInformation) {
|
|
var result = {range, message};
|
|
if (Is.defined(severity)) {
|
|
result.severity = severity;
|
|
}
|
|
if (Is.defined(code)) {
|
|
result.code = code;
|
|
}
|
|
if (Is.defined(source)) {
|
|
result.source = source;
|
|
}
|
|
if (Is.defined(relatedInformation)) {
|
|
result.relatedInformation = relatedInformation;
|
|
}
|
|
return result;
|
|
}
|
|
Diagnostic2.create = create;
|
|
function is(value) {
|
|
var _a2;
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a2 = candidate.codeDescription) === null || _a2 === void 0 ? void 0 : _a2.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
|
|
}
|
|
Diagnostic2.is = is;
|
|
})(Diagnostic || (Diagnostic = {}));
|
|
var Command;
|
|
(function(Command2) {
|
|
function create(title, command) {
|
|
var args = [];
|
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
args[_i - 2] = arguments[_i];
|
|
}
|
|
var result = {title, command};
|
|
if (Is.defined(args) && args.length > 0) {
|
|
result.arguments = args;
|
|
}
|
|
return result;
|
|
}
|
|
Command2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
|
|
}
|
|
Command2.is = is;
|
|
})(Command || (Command = {}));
|
|
var TextEdit;
|
|
(function(TextEdit2) {
|
|
function replace(range, newText) {
|
|
return {range, newText};
|
|
}
|
|
TextEdit2.replace = replace;
|
|
function insert(position, newText) {
|
|
return {range: {start: position, end: position}, newText};
|
|
}
|
|
TextEdit2.insert = insert;
|
|
function del(range) {
|
|
return {range, newText: ""};
|
|
}
|
|
TextEdit2.del = del;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
|
|
}
|
|
TextEdit2.is = is;
|
|
})(TextEdit || (TextEdit = {}));
|
|
var ChangeAnnotation;
|
|
(function(ChangeAnnotation2) {
|
|
function create(label, needsConfirmation, description) {
|
|
var result = {label};
|
|
if (needsConfirmation !== void 0) {
|
|
result.needsConfirmation = needsConfirmation;
|
|
}
|
|
if (description !== void 0) {
|
|
result.description = description;
|
|
}
|
|
return result;
|
|
}
|
|
ChangeAnnotation2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate !== void 0 && Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
|
|
}
|
|
ChangeAnnotation2.is = is;
|
|
})(ChangeAnnotation || (ChangeAnnotation = {}));
|
|
var ChangeAnnotationIdentifier;
|
|
(function(ChangeAnnotationIdentifier2) {
|
|
function is(value) {
|
|
var candidate = value;
|
|
return typeof candidate === "string";
|
|
}
|
|
ChangeAnnotationIdentifier2.is = is;
|
|
})(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
|
|
var AnnotatedTextEdit;
|
|
(function(AnnotatedTextEdit2) {
|
|
function replace(range, newText, annotation) {
|
|
return {range, newText, annotationId: annotation};
|
|
}
|
|
AnnotatedTextEdit2.replace = replace;
|
|
function insert(position, newText, annotation) {
|
|
return {range: {start: position, end: position}, newText, annotationId: annotation};
|
|
}
|
|
AnnotatedTextEdit2.insert = insert;
|
|
function del(range, annotation) {
|
|
return {range, newText: "", annotationId: annotation};
|
|
}
|
|
AnnotatedTextEdit2.del = del;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
|
|
}
|
|
AnnotatedTextEdit2.is = is;
|
|
})(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
|
|
var TextDocumentEdit;
|
|
(function(TextDocumentEdit2) {
|
|
function create(textDocument, edits) {
|
|
return {textDocument, edits};
|
|
}
|
|
TextDocumentEdit2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
|
|
}
|
|
TextDocumentEdit2.is = is;
|
|
})(TextDocumentEdit || (TextDocumentEdit = {}));
|
|
var CreateFile;
|
|
(function(CreateFile2) {
|
|
function create(uri, options, annotation) {
|
|
var result = {
|
|
kind: "create",
|
|
uri
|
|
};
|
|
if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
|
|
result.options = options;
|
|
}
|
|
if (annotation !== void 0) {
|
|
result.annotationId = annotation;
|
|
}
|
|
return result;
|
|
}
|
|
CreateFile2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && candidate.kind === "create" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
|
|
}
|
|
CreateFile2.is = is;
|
|
})(CreateFile || (CreateFile = {}));
|
|
var RenameFile;
|
|
(function(RenameFile2) {
|
|
function create(oldUri, newUri, options, annotation) {
|
|
var result = {
|
|
kind: "rename",
|
|
oldUri,
|
|
newUri
|
|
};
|
|
if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
|
|
result.options = options;
|
|
}
|
|
if (annotation !== void 0) {
|
|
result.annotationId = annotation;
|
|
}
|
|
return result;
|
|
}
|
|
RenameFile2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && candidate.kind === "rename" && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
|
|
}
|
|
RenameFile2.is = is;
|
|
})(RenameFile || (RenameFile = {}));
|
|
var DeleteFile;
|
|
(function(DeleteFile2) {
|
|
function create(uri, options, annotation) {
|
|
var result = {
|
|
kind: "delete",
|
|
uri
|
|
};
|
|
if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
|
|
result.options = options;
|
|
}
|
|
if (annotation !== void 0) {
|
|
result.annotationId = annotation;
|
|
}
|
|
return result;
|
|
}
|
|
DeleteFile2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && candidate.kind === "delete" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
|
|
}
|
|
DeleteFile2.is = is;
|
|
})(DeleteFile || (DeleteFile = {}));
|
|
var WorkspaceEdit;
|
|
(function(WorkspaceEdit2) {
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
|
|
if (Is.string(change.kind)) {
|
|
return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
|
|
} else {
|
|
return TextDocumentEdit.is(change);
|
|
}
|
|
}));
|
|
}
|
|
WorkspaceEdit2.is = is;
|
|
})(WorkspaceEdit || (WorkspaceEdit = {}));
|
|
var TextEditChangeImpl = function() {
|
|
function TextEditChangeImpl2(edits, changeAnnotations) {
|
|
this.edits = edits;
|
|
this.changeAnnotations = changeAnnotations;
|
|
}
|
|
TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
|
|
var edit;
|
|
var id;
|
|
if (annotation === void 0) {
|
|
edit = TextEdit.insert(position, newText);
|
|
} else if (ChangeAnnotationIdentifier.is(annotation)) {
|
|
id = annotation;
|
|
edit = AnnotatedTextEdit.insert(position, newText, annotation);
|
|
} else {
|
|
this.assertChangeAnnotations(this.changeAnnotations);
|
|
id = this.changeAnnotations.manage(annotation);
|
|
edit = AnnotatedTextEdit.insert(position, newText, id);
|
|
}
|
|
this.edits.push(edit);
|
|
if (id !== void 0) {
|
|
return id;
|
|
}
|
|
};
|
|
TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
|
|
var edit;
|
|
var id;
|
|
if (annotation === void 0) {
|
|
edit = TextEdit.replace(range, newText);
|
|
} else if (ChangeAnnotationIdentifier.is(annotation)) {
|
|
id = annotation;
|
|
edit = AnnotatedTextEdit.replace(range, newText, annotation);
|
|
} else {
|
|
this.assertChangeAnnotations(this.changeAnnotations);
|
|
id = this.changeAnnotations.manage(annotation);
|
|
edit = AnnotatedTextEdit.replace(range, newText, id);
|
|
}
|
|
this.edits.push(edit);
|
|
if (id !== void 0) {
|
|
return id;
|
|
}
|
|
};
|
|
TextEditChangeImpl2.prototype.delete = function(range, annotation) {
|
|
var edit;
|
|
var id;
|
|
if (annotation === void 0) {
|
|
edit = TextEdit.del(range);
|
|
} else if (ChangeAnnotationIdentifier.is(annotation)) {
|
|
id = annotation;
|
|
edit = AnnotatedTextEdit.del(range, annotation);
|
|
} else {
|
|
this.assertChangeAnnotations(this.changeAnnotations);
|
|
id = this.changeAnnotations.manage(annotation);
|
|
edit = AnnotatedTextEdit.del(range, id);
|
|
}
|
|
this.edits.push(edit);
|
|
if (id !== void 0) {
|
|
return id;
|
|
}
|
|
};
|
|
TextEditChangeImpl2.prototype.add = function(edit) {
|
|
this.edits.push(edit);
|
|
};
|
|
TextEditChangeImpl2.prototype.all = function() {
|
|
return this.edits;
|
|
};
|
|
TextEditChangeImpl2.prototype.clear = function() {
|
|
this.edits.splice(0, this.edits.length);
|
|
};
|
|
TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
|
|
if (value === void 0) {
|
|
throw new Error("Text edit change is not configured to manage change annotations.");
|
|
}
|
|
};
|
|
return TextEditChangeImpl2;
|
|
}();
|
|
var ChangeAnnotations = function() {
|
|
function ChangeAnnotations2(annotations) {
|
|
this._annotations = annotations === void 0 ? Object.create(null) : annotations;
|
|
this._counter = 0;
|
|
this._size = 0;
|
|
}
|
|
ChangeAnnotations2.prototype.all = function() {
|
|
return this._annotations;
|
|
};
|
|
Object.defineProperty(ChangeAnnotations2.prototype, "size", {
|
|
get: function() {
|
|
return this._size;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
|
|
var id;
|
|
if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
|
|
id = idOrAnnotation;
|
|
} else {
|
|
id = this.nextId();
|
|
annotation = idOrAnnotation;
|
|
}
|
|
if (this._annotations[id] !== void 0) {
|
|
throw new Error("Id " + id + " is already in use.");
|
|
}
|
|
if (annotation === void 0) {
|
|
throw new Error("No annotation provided for id " + id);
|
|
}
|
|
this._annotations[id] = annotation;
|
|
this._size++;
|
|
return id;
|
|
};
|
|
ChangeAnnotations2.prototype.nextId = function() {
|
|
this._counter++;
|
|
return this._counter.toString();
|
|
};
|
|
return ChangeAnnotations2;
|
|
}();
|
|
var WorkspaceChange = function() {
|
|
function WorkspaceChange2(workspaceEdit) {
|
|
var _this = this;
|
|
this._textEditChanges = Object.create(null);
|
|
if (workspaceEdit !== void 0) {
|
|
this._workspaceEdit = workspaceEdit;
|
|
if (workspaceEdit.documentChanges) {
|
|
this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
|
|
workspaceEdit.changeAnnotations = this._changeAnnotations.all();
|
|
workspaceEdit.documentChanges.forEach(function(change) {
|
|
if (TextDocumentEdit.is(change)) {
|
|
var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
|
|
_this._textEditChanges[change.textDocument.uri] = textEditChange;
|
|
}
|
|
});
|
|
} else if (workspaceEdit.changes) {
|
|
Object.keys(workspaceEdit.changes).forEach(function(key) {
|
|
var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
|
|
_this._textEditChanges[key] = textEditChange;
|
|
});
|
|
}
|
|
} else {
|
|
this._workspaceEdit = {};
|
|
}
|
|
}
|
|
Object.defineProperty(WorkspaceChange2.prototype, "edit", {
|
|
get: function() {
|
|
this.initDocumentChanges();
|
|
if (this._changeAnnotations !== void 0) {
|
|
if (this._changeAnnotations.size === 0) {
|
|
this._workspaceEdit.changeAnnotations = void 0;
|
|
} else {
|
|
this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
|
|
}
|
|
}
|
|
return this._workspaceEdit;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
WorkspaceChange2.prototype.getTextEditChange = function(key) {
|
|
if (OptionalVersionedTextDocumentIdentifier.is(key)) {
|
|
this.initDocumentChanges();
|
|
if (this._workspaceEdit.documentChanges === void 0) {
|
|
throw new Error("Workspace edit is not configured for document changes.");
|
|
}
|
|
var textDocument = {uri: key.uri, version: key.version};
|
|
var result = this._textEditChanges[textDocument.uri];
|
|
if (!result) {
|
|
var edits = [];
|
|
var textDocumentEdit = {
|
|
textDocument,
|
|
edits
|
|
};
|
|
this._workspaceEdit.documentChanges.push(textDocumentEdit);
|
|
result = new TextEditChangeImpl(edits, this._changeAnnotations);
|
|
this._textEditChanges[textDocument.uri] = result;
|
|
}
|
|
return result;
|
|
} else {
|
|
this.initChanges();
|
|
if (this._workspaceEdit.changes === void 0) {
|
|
throw new Error("Workspace edit is not configured for normal text edit changes.");
|
|
}
|
|
var result = this._textEditChanges[key];
|
|
if (!result) {
|
|
var edits = [];
|
|
this._workspaceEdit.changes[key] = edits;
|
|
result = new TextEditChangeImpl(edits);
|
|
this._textEditChanges[key] = result;
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
WorkspaceChange2.prototype.initDocumentChanges = function() {
|
|
if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
|
|
this._changeAnnotations = new ChangeAnnotations();
|
|
this._workspaceEdit.documentChanges = [];
|
|
this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
|
|
}
|
|
};
|
|
WorkspaceChange2.prototype.initChanges = function() {
|
|
if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
|
|
this._workspaceEdit.changes = Object.create(null);
|
|
}
|
|
};
|
|
WorkspaceChange2.prototype.createFile = function(uri, optionsOrAnnotation, options) {
|
|
this.initDocumentChanges();
|
|
if (this._workspaceEdit.documentChanges === void 0) {
|
|
throw new Error("Workspace edit is not configured for document changes.");
|
|
}
|
|
var annotation;
|
|
if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
|
|
annotation = optionsOrAnnotation;
|
|
} else {
|
|
options = optionsOrAnnotation;
|
|
}
|
|
var operation;
|
|
var id;
|
|
if (annotation === void 0) {
|
|
operation = CreateFile.create(uri, options);
|
|
} else {
|
|
id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
|
|
operation = CreateFile.create(uri, options, id);
|
|
}
|
|
this._workspaceEdit.documentChanges.push(operation);
|
|
if (id !== void 0) {
|
|
return id;
|
|
}
|
|
};
|
|
WorkspaceChange2.prototype.renameFile = function(oldUri, newUri, optionsOrAnnotation, options) {
|
|
this.initDocumentChanges();
|
|
if (this._workspaceEdit.documentChanges === void 0) {
|
|
throw new Error("Workspace edit is not configured for document changes.");
|
|
}
|
|
var annotation;
|
|
if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
|
|
annotation = optionsOrAnnotation;
|
|
} else {
|
|
options = optionsOrAnnotation;
|
|
}
|
|
var operation;
|
|
var id;
|
|
if (annotation === void 0) {
|
|
operation = RenameFile.create(oldUri, newUri, options);
|
|
} else {
|
|
id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
|
|
operation = RenameFile.create(oldUri, newUri, options, id);
|
|
}
|
|
this._workspaceEdit.documentChanges.push(operation);
|
|
if (id !== void 0) {
|
|
return id;
|
|
}
|
|
};
|
|
WorkspaceChange2.prototype.deleteFile = function(uri, optionsOrAnnotation, options) {
|
|
this.initDocumentChanges();
|
|
if (this._workspaceEdit.documentChanges === void 0) {
|
|
throw new Error("Workspace edit is not configured for document changes.");
|
|
}
|
|
var annotation;
|
|
if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
|
|
annotation = optionsOrAnnotation;
|
|
} else {
|
|
options = optionsOrAnnotation;
|
|
}
|
|
var operation;
|
|
var id;
|
|
if (annotation === void 0) {
|
|
operation = DeleteFile.create(uri, options);
|
|
} else {
|
|
id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
|
|
operation = DeleteFile.create(uri, options, id);
|
|
}
|
|
this._workspaceEdit.documentChanges.push(operation);
|
|
if (id !== void 0) {
|
|
return id;
|
|
}
|
|
};
|
|
return WorkspaceChange2;
|
|
}();
|
|
var TextDocumentIdentifier;
|
|
(function(TextDocumentIdentifier2) {
|
|
function create(uri) {
|
|
return {uri};
|
|
}
|
|
TextDocumentIdentifier2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.string(candidate.uri);
|
|
}
|
|
TextDocumentIdentifier2.is = is;
|
|
})(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
|
|
var VersionedTextDocumentIdentifier;
|
|
(function(VersionedTextDocumentIdentifier2) {
|
|
function create(uri, version) {
|
|
return {uri, version};
|
|
}
|
|
VersionedTextDocumentIdentifier2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
|
|
}
|
|
VersionedTextDocumentIdentifier2.is = is;
|
|
})(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
|
|
var OptionalVersionedTextDocumentIdentifier;
|
|
(function(OptionalVersionedTextDocumentIdentifier2) {
|
|
function create(uri, version) {
|
|
return {uri, version};
|
|
}
|
|
OptionalVersionedTextDocumentIdentifier2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
|
|
}
|
|
OptionalVersionedTextDocumentIdentifier2.is = is;
|
|
})(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
|
|
var TextDocumentItem;
|
|
(function(TextDocumentItem2) {
|
|
function create(uri, languageId, version, text) {
|
|
return {uri, languageId, version, text};
|
|
}
|
|
TextDocumentItem2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
|
|
}
|
|
TextDocumentItem2.is = is;
|
|
})(TextDocumentItem || (TextDocumentItem = {}));
|
|
var MarkupKind;
|
|
(function(MarkupKind2) {
|
|
MarkupKind2.PlainText = "plaintext";
|
|
MarkupKind2.Markdown = "markdown";
|
|
})(MarkupKind || (MarkupKind = {}));
|
|
(function(MarkupKind2) {
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
|
|
}
|
|
MarkupKind2.is = is;
|
|
})(MarkupKind || (MarkupKind = {}));
|
|
var MarkupContent;
|
|
(function(MarkupContent2) {
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
|
|
}
|
|
MarkupContent2.is = is;
|
|
})(MarkupContent || (MarkupContent = {}));
|
|
var CompletionItemKind;
|
|
(function(CompletionItemKind2) {
|
|
CompletionItemKind2.Text = 1;
|
|
CompletionItemKind2.Method = 2;
|
|
CompletionItemKind2.Function = 3;
|
|
CompletionItemKind2.Constructor = 4;
|
|
CompletionItemKind2.Field = 5;
|
|
CompletionItemKind2.Variable = 6;
|
|
CompletionItemKind2.Class = 7;
|
|
CompletionItemKind2.Interface = 8;
|
|
CompletionItemKind2.Module = 9;
|
|
CompletionItemKind2.Property = 10;
|
|
CompletionItemKind2.Unit = 11;
|
|
CompletionItemKind2.Value = 12;
|
|
CompletionItemKind2.Enum = 13;
|
|
CompletionItemKind2.Keyword = 14;
|
|
CompletionItemKind2.Snippet = 15;
|
|
CompletionItemKind2.Color = 16;
|
|
CompletionItemKind2.File = 17;
|
|
CompletionItemKind2.Reference = 18;
|
|
CompletionItemKind2.Folder = 19;
|
|
CompletionItemKind2.EnumMember = 20;
|
|
CompletionItemKind2.Constant = 21;
|
|
CompletionItemKind2.Struct = 22;
|
|
CompletionItemKind2.Event = 23;
|
|
CompletionItemKind2.Operator = 24;
|
|
CompletionItemKind2.TypeParameter = 25;
|
|
})(CompletionItemKind || (CompletionItemKind = {}));
|
|
var InsertTextFormat;
|
|
(function(InsertTextFormat2) {
|
|
InsertTextFormat2.PlainText = 1;
|
|
InsertTextFormat2.Snippet = 2;
|
|
})(InsertTextFormat || (InsertTextFormat = {}));
|
|
var CompletionItemTag;
|
|
(function(CompletionItemTag2) {
|
|
CompletionItemTag2.Deprecated = 1;
|
|
})(CompletionItemTag || (CompletionItemTag = {}));
|
|
var InsertReplaceEdit;
|
|
(function(InsertReplaceEdit2) {
|
|
function create(newText, insert, replace) {
|
|
return {newText, insert, replace};
|
|
}
|
|
InsertReplaceEdit2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
|
|
}
|
|
InsertReplaceEdit2.is = is;
|
|
})(InsertReplaceEdit || (InsertReplaceEdit = {}));
|
|
var InsertTextMode;
|
|
(function(InsertTextMode2) {
|
|
InsertTextMode2.asIs = 1;
|
|
InsertTextMode2.adjustIndentation = 2;
|
|
})(InsertTextMode || (InsertTextMode = {}));
|
|
var CompletionItem;
|
|
(function(CompletionItem2) {
|
|
function create(label) {
|
|
return {label};
|
|
}
|
|
CompletionItem2.create = create;
|
|
})(CompletionItem || (CompletionItem = {}));
|
|
var CompletionList;
|
|
(function(CompletionList2) {
|
|
function create(items, isIncomplete) {
|
|
return {items: items ? items : [], isIncomplete: !!isIncomplete};
|
|
}
|
|
CompletionList2.create = create;
|
|
})(CompletionList || (CompletionList = {}));
|
|
var MarkedString;
|
|
(function(MarkedString2) {
|
|
function fromPlainText(plainText) {
|
|
return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
|
|
}
|
|
MarkedString2.fromPlainText = fromPlainText;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
|
|
}
|
|
MarkedString2.is = is;
|
|
})(MarkedString || (MarkedString = {}));
|
|
var Hover;
|
|
(function(Hover2) {
|
|
function is(value) {
|
|
var candidate = value;
|
|
return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
|
|
}
|
|
Hover2.is = is;
|
|
})(Hover || (Hover = {}));
|
|
var ParameterInformation;
|
|
(function(ParameterInformation2) {
|
|
function create(label, documentation) {
|
|
return documentation ? {label, documentation} : {label};
|
|
}
|
|
ParameterInformation2.create = create;
|
|
})(ParameterInformation || (ParameterInformation = {}));
|
|
var SignatureInformation;
|
|
(function(SignatureInformation2) {
|
|
function create(label, documentation) {
|
|
var parameters = [];
|
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
parameters[_i - 2] = arguments[_i];
|
|
}
|
|
var result = {label};
|
|
if (Is.defined(documentation)) {
|
|
result.documentation = documentation;
|
|
}
|
|
if (Is.defined(parameters)) {
|
|
result.parameters = parameters;
|
|
} else {
|
|
result.parameters = [];
|
|
}
|
|
return result;
|
|
}
|
|
SignatureInformation2.create = create;
|
|
})(SignatureInformation || (SignatureInformation = {}));
|
|
var DocumentHighlightKind;
|
|
(function(DocumentHighlightKind2) {
|
|
DocumentHighlightKind2.Text = 1;
|
|
DocumentHighlightKind2.Read = 2;
|
|
DocumentHighlightKind2.Write = 3;
|
|
})(DocumentHighlightKind || (DocumentHighlightKind = {}));
|
|
var DocumentHighlight;
|
|
(function(DocumentHighlight2) {
|
|
function create(range, kind) {
|
|
var result = {range};
|
|
if (Is.number(kind)) {
|
|
result.kind = kind;
|
|
}
|
|
return result;
|
|
}
|
|
DocumentHighlight2.create = create;
|
|
})(DocumentHighlight || (DocumentHighlight = {}));
|
|
var SymbolKind;
|
|
(function(SymbolKind2) {
|
|
SymbolKind2.File = 1;
|
|
SymbolKind2.Module = 2;
|
|
SymbolKind2.Namespace = 3;
|
|
SymbolKind2.Package = 4;
|
|
SymbolKind2.Class = 5;
|
|
SymbolKind2.Method = 6;
|
|
SymbolKind2.Property = 7;
|
|
SymbolKind2.Field = 8;
|
|
SymbolKind2.Constructor = 9;
|
|
SymbolKind2.Enum = 10;
|
|
SymbolKind2.Interface = 11;
|
|
SymbolKind2.Function = 12;
|
|
SymbolKind2.Variable = 13;
|
|
SymbolKind2.Constant = 14;
|
|
SymbolKind2.String = 15;
|
|
SymbolKind2.Number = 16;
|
|
SymbolKind2.Boolean = 17;
|
|
SymbolKind2.Array = 18;
|
|
SymbolKind2.Object = 19;
|
|
SymbolKind2.Key = 20;
|
|
SymbolKind2.Null = 21;
|
|
SymbolKind2.EnumMember = 22;
|
|
SymbolKind2.Struct = 23;
|
|
SymbolKind2.Event = 24;
|
|
SymbolKind2.Operator = 25;
|
|
SymbolKind2.TypeParameter = 26;
|
|
})(SymbolKind || (SymbolKind = {}));
|
|
var SymbolTag;
|
|
(function(SymbolTag2) {
|
|
SymbolTag2.Deprecated = 1;
|
|
})(SymbolTag || (SymbolTag = {}));
|
|
var SymbolInformation;
|
|
(function(SymbolInformation2) {
|
|
function create(name, kind, range, uri, containerName) {
|
|
var result = {
|
|
name,
|
|
kind,
|
|
location: {uri, range}
|
|
};
|
|
if (containerName) {
|
|
result.containerName = containerName;
|
|
}
|
|
return result;
|
|
}
|
|
SymbolInformation2.create = create;
|
|
})(SymbolInformation || (SymbolInformation = {}));
|
|
var DocumentSymbol;
|
|
(function(DocumentSymbol2) {
|
|
function create(name, detail, kind, range, selectionRange, children) {
|
|
var result = {
|
|
name,
|
|
detail,
|
|
kind,
|
|
range,
|
|
selectionRange
|
|
};
|
|
if (children !== void 0) {
|
|
result.children = children;
|
|
}
|
|
return result;
|
|
}
|
|
DocumentSymbol2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
|
|
}
|
|
DocumentSymbol2.is = is;
|
|
})(DocumentSymbol || (DocumentSymbol = {}));
|
|
var CodeActionKind;
|
|
(function(CodeActionKind2) {
|
|
CodeActionKind2.Empty = "";
|
|
CodeActionKind2.QuickFix = "quickfix";
|
|
CodeActionKind2.Refactor = "refactor";
|
|
CodeActionKind2.RefactorExtract = "refactor.extract";
|
|
CodeActionKind2.RefactorInline = "refactor.inline";
|
|
CodeActionKind2.RefactorRewrite = "refactor.rewrite";
|
|
CodeActionKind2.Source = "source";
|
|
CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
|
|
CodeActionKind2.SourceFixAll = "source.fixAll";
|
|
})(CodeActionKind || (CodeActionKind = {}));
|
|
var CodeActionContext;
|
|
(function(CodeActionContext2) {
|
|
function create(diagnostics, only) {
|
|
var result = {diagnostics};
|
|
if (only !== void 0 && only !== null) {
|
|
result.only = only;
|
|
}
|
|
return result;
|
|
}
|
|
CodeActionContext2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
|
|
}
|
|
CodeActionContext2.is = is;
|
|
})(CodeActionContext || (CodeActionContext = {}));
|
|
var CodeAction;
|
|
(function(CodeAction2) {
|
|
function create(title, kindOrCommandOrEdit, kind) {
|
|
var result = {title};
|
|
var checkKind = true;
|
|
if (typeof kindOrCommandOrEdit === "string") {
|
|
checkKind = false;
|
|
result.kind = kindOrCommandOrEdit;
|
|
} else if (Command.is(kindOrCommandOrEdit)) {
|
|
result.command = kindOrCommandOrEdit;
|
|
} else {
|
|
result.edit = kindOrCommandOrEdit;
|
|
}
|
|
if (checkKind && kind !== void 0) {
|
|
result.kind = kind;
|
|
}
|
|
return result;
|
|
}
|
|
CodeAction2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
|
|
}
|
|
CodeAction2.is = is;
|
|
})(CodeAction || (CodeAction = {}));
|
|
var CodeLens;
|
|
(function(CodeLens2) {
|
|
function create(range, data) {
|
|
var result = {range};
|
|
if (Is.defined(data)) {
|
|
result.data = data;
|
|
}
|
|
return result;
|
|
}
|
|
CodeLens2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
|
|
}
|
|
CodeLens2.is = is;
|
|
})(CodeLens || (CodeLens = {}));
|
|
var FormattingOptions;
|
|
(function(FormattingOptions2) {
|
|
function create(tabSize, insertSpaces) {
|
|
return {tabSize, insertSpaces};
|
|
}
|
|
FormattingOptions2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
|
|
}
|
|
FormattingOptions2.is = is;
|
|
})(FormattingOptions || (FormattingOptions = {}));
|
|
var DocumentLink;
|
|
(function(DocumentLink2) {
|
|
function create(range, target, data) {
|
|
return {range, target, data};
|
|
}
|
|
DocumentLink2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
|
|
}
|
|
DocumentLink2.is = is;
|
|
})(DocumentLink || (DocumentLink = {}));
|
|
var SelectionRange;
|
|
(function(SelectionRange2) {
|
|
function create(range, parent) {
|
|
return {range, parent};
|
|
}
|
|
SelectionRange2.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return candidate !== void 0 && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
|
|
}
|
|
SelectionRange2.is = is;
|
|
})(SelectionRange || (SelectionRange = {}));
|
|
var EOL = ["\n", "\r\n", "\r"];
|
|
var TextDocument2;
|
|
(function(TextDocument3) {
|
|
function create(uri, languageId, version, content) {
|
|
return new FullTextDocument2(uri, languageId, version, content);
|
|
}
|
|
TextDocument3.create = create;
|
|
function is(value) {
|
|
var candidate = value;
|
|
return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount) && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
|
|
}
|
|
TextDocument3.is = is;
|
|
function applyEdits(document, edits) {
|
|
var text = document.getText();
|
|
var sortedEdits = mergeSort2(edits, function(a, b) {
|
|
var diff = a.range.start.line - b.range.start.line;
|
|
if (diff === 0) {
|
|
return a.range.start.character - b.range.start.character;
|
|
}
|
|
return diff;
|
|
});
|
|
var lastModifiedOffset = text.length;
|
|
for (var i = sortedEdits.length - 1; i >= 0; i--) {
|
|
var e = sortedEdits[i];
|
|
var startOffset = document.offsetAt(e.range.start);
|
|
var endOffset = document.offsetAt(e.range.end);
|
|
if (endOffset <= lastModifiedOffset) {
|
|
text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
|
|
} else {
|
|
throw new Error("Overlapping edit");
|
|
}
|
|
lastModifiedOffset = startOffset;
|
|
}
|
|
return text;
|
|
}
|
|
TextDocument3.applyEdits = applyEdits;
|
|
function mergeSort2(data, compare) {
|
|
if (data.length <= 1) {
|
|
return data;
|
|
}
|
|
var p = data.length / 2 | 0;
|
|
var left = data.slice(0, p);
|
|
var right = data.slice(p);
|
|
mergeSort2(left, compare);
|
|
mergeSort2(right, compare);
|
|
var leftIdx = 0;
|
|
var rightIdx = 0;
|
|
var i = 0;
|
|
while (leftIdx < left.length && rightIdx < right.length) {
|
|
var ret = compare(left[leftIdx], right[rightIdx]);
|
|
if (ret <= 0) {
|
|
data[i++] = left[leftIdx++];
|
|
} else {
|
|
data[i++] = right[rightIdx++];
|
|
}
|
|
}
|
|
while (leftIdx < left.length) {
|
|
data[i++] = left[leftIdx++];
|
|
}
|
|
while (rightIdx < right.length) {
|
|
data[i++] = right[rightIdx++];
|
|
}
|
|
return data;
|
|
}
|
|
})(TextDocument2 || (TextDocument2 = {}));
|
|
var FullTextDocument2 = function() {
|
|
function FullTextDocument3(uri, languageId, version, content) {
|
|
this._uri = uri;
|
|
this._languageId = languageId;
|
|
this._version = version;
|
|
this._content = content;
|
|
this._lineOffsets = void 0;
|
|
}
|
|
Object.defineProperty(FullTextDocument3.prototype, "uri", {
|
|
get: function() {
|
|
return this._uri;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(FullTextDocument3.prototype, "languageId", {
|
|
get: function() {
|
|
return this._languageId;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(FullTextDocument3.prototype, "version", {
|
|
get: function() {
|
|
return this._version;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
FullTextDocument3.prototype.getText = function(range) {
|
|
if (range) {
|
|
var start = this.offsetAt(range.start);
|
|
var end = this.offsetAt(range.end);
|
|
return this._content.substring(start, end);
|
|
}
|
|
return this._content;
|
|
};
|
|
FullTextDocument3.prototype.update = function(event, version) {
|
|
this._content = event.text;
|
|
this._version = version;
|
|
this._lineOffsets = void 0;
|
|
};
|
|
FullTextDocument3.prototype.getLineOffsets = function() {
|
|
if (this._lineOffsets === void 0) {
|
|
var lineOffsets = [];
|
|
var text = this._content;
|
|
var isLineStart = true;
|
|
for (var i = 0; i < text.length; i++) {
|
|
if (isLineStart) {
|
|
lineOffsets.push(i);
|
|
isLineStart = false;
|
|
}
|
|
var ch = text.charAt(i);
|
|
isLineStart = ch === "\r" || ch === "\n";
|
|
if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
|
|
i++;
|
|
}
|
|
}
|
|
if (isLineStart && text.length > 0) {
|
|
lineOffsets.push(text.length);
|
|
}
|
|
this._lineOffsets = lineOffsets;
|
|
}
|
|
return this._lineOffsets;
|
|
};
|
|
FullTextDocument3.prototype.positionAt = function(offset) {
|
|
offset = Math.max(Math.min(offset, this._content.length), 0);
|
|
var lineOffsets = this.getLineOffsets();
|
|
var low = 0, high = lineOffsets.length;
|
|
if (high === 0) {
|
|
return Position.create(0, offset);
|
|
}
|
|
while (low < high) {
|
|
var mid = Math.floor((low + high) / 2);
|
|
if (lineOffsets[mid] > offset) {
|
|
high = mid;
|
|
} else {
|
|
low = mid + 1;
|
|
}
|
|
}
|
|
var line = low - 1;
|
|
return Position.create(line, offset - lineOffsets[line]);
|
|
};
|
|
FullTextDocument3.prototype.offsetAt = function(position) {
|
|
var lineOffsets = this.getLineOffsets();
|
|
if (position.line >= lineOffsets.length) {
|
|
return this._content.length;
|
|
} else if (position.line < 0) {
|
|
return 0;
|
|
}
|
|
var lineOffset = lineOffsets[position.line];
|
|
var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
|
|
return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
|
|
};
|
|
Object.defineProperty(FullTextDocument3.prototype, "lineCount", {
|
|
get: function() {
|
|
return this.getLineOffsets().length;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
return FullTextDocument3;
|
|
}();
|
|
var Is;
|
|
(function(Is2) {
|
|
var toString = Object.prototype.toString;
|
|
function defined(value) {
|
|
return typeof value !== "undefined";
|
|
}
|
|
Is2.defined = defined;
|
|
function undefined2(value) {
|
|
return typeof value === "undefined";
|
|
}
|
|
Is2.undefined = undefined2;
|
|
function boolean(value) {
|
|
return value === true || value === false;
|
|
}
|
|
Is2.boolean = boolean;
|
|
function string(value) {
|
|
return toString.call(value) === "[object String]";
|
|
}
|
|
Is2.string = string;
|
|
function number(value) {
|
|
return toString.call(value) === "[object Number]";
|
|
}
|
|
Is2.number = number;
|
|
function numberRange(value, min, max) {
|
|
return toString.call(value) === "[object Number]" && min <= value && value <= max;
|
|
}
|
|
Is2.numberRange = numberRange;
|
|
function integer2(value) {
|
|
return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
|
|
}
|
|
Is2.integer = integer2;
|
|
function uinteger2(value) {
|
|
return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
|
|
}
|
|
Is2.uinteger = uinteger2;
|
|
function func(value) {
|
|
return toString.call(value) === "[object Function]";
|
|
}
|
|
Is2.func = func;
|
|
function objectLiteral(value) {
|
|
return value !== null && typeof value === "object";
|
|
}
|
|
Is2.objectLiteral = objectLiteral;
|
|
function typedArray(value, check) {
|
|
return Array.isArray(value) && value.every(check);
|
|
}
|
|
Is2.typedArray = typedArray;
|
|
})(Is || (Is = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/messages.js
|
|
var require_messages2 = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ProtocolNotificationType = exports2.ProtocolNotificationType0 = exports2.ProtocolRequestType = exports2.ProtocolRequestType0 = exports2.RegistrationType = void 0;
|
|
var vscode_jsonrpc_1 = require_main();
|
|
var RegistrationType = class {
|
|
constructor(method) {
|
|
this.method = method;
|
|
}
|
|
};
|
|
exports2.RegistrationType = RegistrationType;
|
|
var ProtocolRequestType0 = class extends vscode_jsonrpc_1.RequestType0 {
|
|
constructor(method) {
|
|
super(method);
|
|
}
|
|
};
|
|
exports2.ProtocolRequestType0 = ProtocolRequestType0;
|
|
var ProtocolRequestType = class extends vscode_jsonrpc_1.RequestType {
|
|
constructor(method) {
|
|
super(method, vscode_jsonrpc_1.ParameterStructures.byName);
|
|
}
|
|
};
|
|
exports2.ProtocolRequestType = ProtocolRequestType;
|
|
var ProtocolNotificationType0 = class extends vscode_jsonrpc_1.NotificationType0 {
|
|
constructor(method) {
|
|
super(method);
|
|
}
|
|
};
|
|
exports2.ProtocolNotificationType0 = ProtocolNotificationType0;
|
|
var ProtocolNotificationType = class extends vscode_jsonrpc_1.NotificationType {
|
|
constructor(method) {
|
|
super(method, vscode_jsonrpc_1.ParameterStructures.byName);
|
|
}
|
|
};
|
|
exports2.ProtocolNotificationType = ProtocolNotificationType;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/utils/is.js
|
|
var require_is3 = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.objectLiteral = exports2.typedArray = exports2.stringArray = exports2.array = exports2.func = exports2.error = exports2.number = exports2.string = exports2.boolean = void 0;
|
|
function boolean(value) {
|
|
return value === true || value === false;
|
|
}
|
|
exports2.boolean = boolean;
|
|
function string(value) {
|
|
return typeof value === "string" || value instanceof String;
|
|
}
|
|
exports2.string = string;
|
|
function number(value) {
|
|
return typeof value === "number" || value instanceof Number;
|
|
}
|
|
exports2.number = number;
|
|
function error(value) {
|
|
return value instanceof Error;
|
|
}
|
|
exports2.error = error;
|
|
function func(value) {
|
|
return typeof value === "function";
|
|
}
|
|
exports2.func = func;
|
|
function array(value) {
|
|
return Array.isArray(value);
|
|
}
|
|
exports2.array = array;
|
|
function stringArray(value) {
|
|
return array(value) && value.every((elem) => string(elem));
|
|
}
|
|
exports2.stringArray = stringArray;
|
|
function typedArray(value, check) {
|
|
return Array.isArray(value) && value.every(check);
|
|
}
|
|
exports2.typedArray = typedArray;
|
|
function objectLiteral(value) {
|
|
return value !== null && typeof value === "object";
|
|
}
|
|
exports2.objectLiteral = objectLiteral;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.implementation.js
|
|
var require_protocol_implementation = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ImplementationRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var ImplementationRequest;
|
|
(function(ImplementationRequest2) {
|
|
ImplementationRequest2.method = "textDocument/implementation";
|
|
ImplementationRequest2.type = new messages_1.ProtocolRequestType(ImplementationRequest2.method);
|
|
})(ImplementationRequest = exports2.ImplementationRequest || (exports2.ImplementationRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeDefinition.js
|
|
var require_protocol_typeDefinition = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.TypeDefinitionRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var TypeDefinitionRequest;
|
|
(function(TypeDefinitionRequest2) {
|
|
TypeDefinitionRequest2.method = "textDocument/typeDefinition";
|
|
TypeDefinitionRequest2.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest2.method);
|
|
})(TypeDefinitionRequest = exports2.TypeDefinitionRequest || (exports2.TypeDefinitionRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.workspaceFolders.js
|
|
var require_protocol_workspaceFolders = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.DidChangeWorkspaceFoldersNotification = exports2.WorkspaceFoldersRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var WorkspaceFoldersRequest;
|
|
(function(WorkspaceFoldersRequest2) {
|
|
WorkspaceFoldersRequest2.type = new messages_1.ProtocolRequestType0("workspace/workspaceFolders");
|
|
})(WorkspaceFoldersRequest = exports2.WorkspaceFoldersRequest || (exports2.WorkspaceFoldersRequest = {}));
|
|
var DidChangeWorkspaceFoldersNotification;
|
|
(function(DidChangeWorkspaceFoldersNotification2) {
|
|
DidChangeWorkspaceFoldersNotification2.type = new messages_1.ProtocolNotificationType("workspace/didChangeWorkspaceFolders");
|
|
})(DidChangeWorkspaceFoldersNotification = exports2.DidChangeWorkspaceFoldersNotification || (exports2.DidChangeWorkspaceFoldersNotification = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.configuration.js
|
|
var require_protocol_configuration = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ConfigurationRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var ConfigurationRequest;
|
|
(function(ConfigurationRequest2) {
|
|
ConfigurationRequest2.type = new messages_1.ProtocolRequestType("workspace/configuration");
|
|
})(ConfigurationRequest = exports2.ConfigurationRequest || (exports2.ConfigurationRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.colorProvider.js
|
|
var require_protocol_colorProvider = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ColorPresentationRequest = exports2.DocumentColorRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var DocumentColorRequest;
|
|
(function(DocumentColorRequest2) {
|
|
DocumentColorRequest2.method = "textDocument/documentColor";
|
|
DocumentColorRequest2.type = new messages_1.ProtocolRequestType(DocumentColorRequest2.method);
|
|
})(DocumentColorRequest = exports2.DocumentColorRequest || (exports2.DocumentColorRequest = {}));
|
|
var ColorPresentationRequest;
|
|
(function(ColorPresentationRequest2) {
|
|
ColorPresentationRequest2.type = new messages_1.ProtocolRequestType("textDocument/colorPresentation");
|
|
})(ColorPresentationRequest = exports2.ColorPresentationRequest || (exports2.ColorPresentationRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.foldingRange.js
|
|
var require_protocol_foldingRange = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.FoldingRangeRequest = exports2.FoldingRangeKind = void 0;
|
|
var messages_1 = require_messages2();
|
|
var FoldingRangeKind;
|
|
(function(FoldingRangeKind2) {
|
|
FoldingRangeKind2["Comment"] = "comment";
|
|
FoldingRangeKind2["Imports"] = "imports";
|
|
FoldingRangeKind2["Region"] = "region";
|
|
})(FoldingRangeKind = exports2.FoldingRangeKind || (exports2.FoldingRangeKind = {}));
|
|
var FoldingRangeRequest;
|
|
(function(FoldingRangeRequest2) {
|
|
FoldingRangeRequest2.method = "textDocument/foldingRange";
|
|
FoldingRangeRequest2.type = new messages_1.ProtocolRequestType(FoldingRangeRequest2.method);
|
|
})(FoldingRangeRequest = exports2.FoldingRangeRequest || (exports2.FoldingRangeRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.declaration.js
|
|
var require_protocol_declaration = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.DeclarationRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var DeclarationRequest;
|
|
(function(DeclarationRequest2) {
|
|
DeclarationRequest2.method = "textDocument/declaration";
|
|
DeclarationRequest2.type = new messages_1.ProtocolRequestType(DeclarationRequest2.method);
|
|
})(DeclarationRequest = exports2.DeclarationRequest || (exports2.DeclarationRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.selectionRange.js
|
|
var require_protocol_selectionRange = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.SelectionRangeRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var SelectionRangeRequest;
|
|
(function(SelectionRangeRequest2) {
|
|
SelectionRangeRequest2.method = "textDocument/selectionRange";
|
|
SelectionRangeRequest2.type = new messages_1.ProtocolRequestType(SelectionRangeRequest2.method);
|
|
})(SelectionRangeRequest = exports2.SelectionRangeRequest || (exports2.SelectionRangeRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.progress.js
|
|
var require_protocol_progress = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.WorkDoneProgressCancelNotification = exports2.WorkDoneProgressCreateRequest = exports2.WorkDoneProgress = void 0;
|
|
var vscode_jsonrpc_1 = require_main();
|
|
var messages_1 = require_messages2();
|
|
var WorkDoneProgress;
|
|
(function(WorkDoneProgress2) {
|
|
WorkDoneProgress2.type = new vscode_jsonrpc_1.ProgressType();
|
|
function is(value) {
|
|
return value === WorkDoneProgress2.type;
|
|
}
|
|
WorkDoneProgress2.is = is;
|
|
})(WorkDoneProgress = exports2.WorkDoneProgress || (exports2.WorkDoneProgress = {}));
|
|
var WorkDoneProgressCreateRequest;
|
|
(function(WorkDoneProgressCreateRequest2) {
|
|
WorkDoneProgressCreateRequest2.type = new messages_1.ProtocolRequestType("window/workDoneProgress/create");
|
|
})(WorkDoneProgressCreateRequest = exports2.WorkDoneProgressCreateRequest || (exports2.WorkDoneProgressCreateRequest = {}));
|
|
var WorkDoneProgressCancelNotification;
|
|
(function(WorkDoneProgressCancelNotification2) {
|
|
WorkDoneProgressCancelNotification2.type = new messages_1.ProtocolNotificationType("window/workDoneProgress/cancel");
|
|
})(WorkDoneProgressCancelNotification = exports2.WorkDoneProgressCancelNotification || (exports2.WorkDoneProgressCancelNotification = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.callHierarchy.js
|
|
var require_protocol_callHierarchy = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.CallHierarchyOutgoingCallsRequest = exports2.CallHierarchyIncomingCallsRequest = exports2.CallHierarchyPrepareRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var CallHierarchyPrepareRequest;
|
|
(function(CallHierarchyPrepareRequest2) {
|
|
CallHierarchyPrepareRequest2.method = "textDocument/prepareCallHierarchy";
|
|
CallHierarchyPrepareRequest2.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest2.method);
|
|
})(CallHierarchyPrepareRequest = exports2.CallHierarchyPrepareRequest || (exports2.CallHierarchyPrepareRequest = {}));
|
|
var CallHierarchyIncomingCallsRequest;
|
|
(function(CallHierarchyIncomingCallsRequest2) {
|
|
CallHierarchyIncomingCallsRequest2.method = "callHierarchy/incomingCalls";
|
|
CallHierarchyIncomingCallsRequest2.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest2.method);
|
|
})(CallHierarchyIncomingCallsRequest = exports2.CallHierarchyIncomingCallsRequest || (exports2.CallHierarchyIncomingCallsRequest = {}));
|
|
var CallHierarchyOutgoingCallsRequest;
|
|
(function(CallHierarchyOutgoingCallsRequest2) {
|
|
CallHierarchyOutgoingCallsRequest2.method = "callHierarchy/outgoingCalls";
|
|
CallHierarchyOutgoingCallsRequest2.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest2.method);
|
|
})(CallHierarchyOutgoingCallsRequest = exports2.CallHierarchyOutgoingCallsRequest || (exports2.CallHierarchyOutgoingCallsRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.semanticTokens.js
|
|
var require_protocol_semanticTokens = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.SemanticTokensRefreshRequest = exports2.SemanticTokensRangeRequest = exports2.SemanticTokensDeltaRequest = exports2.SemanticTokensRequest = exports2.SemanticTokensRegistrationType = exports2.TokenFormat = exports2.SemanticTokens = exports2.SemanticTokenModifiers = exports2.SemanticTokenTypes = void 0;
|
|
var messages_1 = require_messages2();
|
|
var SemanticTokenTypes;
|
|
(function(SemanticTokenTypes2) {
|
|
SemanticTokenTypes2["namespace"] = "namespace";
|
|
SemanticTokenTypes2["type"] = "type";
|
|
SemanticTokenTypes2["class"] = "class";
|
|
SemanticTokenTypes2["enum"] = "enum";
|
|
SemanticTokenTypes2["interface"] = "interface";
|
|
SemanticTokenTypes2["struct"] = "struct";
|
|
SemanticTokenTypes2["typeParameter"] = "typeParameter";
|
|
SemanticTokenTypes2["parameter"] = "parameter";
|
|
SemanticTokenTypes2["variable"] = "variable";
|
|
SemanticTokenTypes2["property"] = "property";
|
|
SemanticTokenTypes2["enumMember"] = "enumMember";
|
|
SemanticTokenTypes2["event"] = "event";
|
|
SemanticTokenTypes2["function"] = "function";
|
|
SemanticTokenTypes2["method"] = "method";
|
|
SemanticTokenTypes2["macro"] = "macro";
|
|
SemanticTokenTypes2["keyword"] = "keyword";
|
|
SemanticTokenTypes2["modifier"] = "modifier";
|
|
SemanticTokenTypes2["comment"] = "comment";
|
|
SemanticTokenTypes2["string"] = "string";
|
|
SemanticTokenTypes2["number"] = "number";
|
|
SemanticTokenTypes2["regexp"] = "regexp";
|
|
SemanticTokenTypes2["operator"] = "operator";
|
|
})(SemanticTokenTypes = exports2.SemanticTokenTypes || (exports2.SemanticTokenTypes = {}));
|
|
var SemanticTokenModifiers;
|
|
(function(SemanticTokenModifiers2) {
|
|
SemanticTokenModifiers2["declaration"] = "declaration";
|
|
SemanticTokenModifiers2["definition"] = "definition";
|
|
SemanticTokenModifiers2["readonly"] = "readonly";
|
|
SemanticTokenModifiers2["static"] = "static";
|
|
SemanticTokenModifiers2["deprecated"] = "deprecated";
|
|
SemanticTokenModifiers2["abstract"] = "abstract";
|
|
SemanticTokenModifiers2["async"] = "async";
|
|
SemanticTokenModifiers2["modification"] = "modification";
|
|
SemanticTokenModifiers2["documentation"] = "documentation";
|
|
SemanticTokenModifiers2["defaultLibrary"] = "defaultLibrary";
|
|
})(SemanticTokenModifiers = exports2.SemanticTokenModifiers || (exports2.SemanticTokenModifiers = {}));
|
|
var SemanticTokens;
|
|
(function(SemanticTokens2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate !== void 0 && (candidate.resultId === void 0 || typeof candidate.resultId === "string") && Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === "number");
|
|
}
|
|
SemanticTokens2.is = is;
|
|
})(SemanticTokens = exports2.SemanticTokens || (exports2.SemanticTokens = {}));
|
|
var TokenFormat;
|
|
(function(TokenFormat2) {
|
|
TokenFormat2.Relative = "relative";
|
|
})(TokenFormat = exports2.TokenFormat || (exports2.TokenFormat = {}));
|
|
var SemanticTokensRegistrationType;
|
|
(function(SemanticTokensRegistrationType2) {
|
|
SemanticTokensRegistrationType2.method = "textDocument/semanticTokens";
|
|
SemanticTokensRegistrationType2.type = new messages_1.RegistrationType(SemanticTokensRegistrationType2.method);
|
|
})(SemanticTokensRegistrationType = exports2.SemanticTokensRegistrationType || (exports2.SemanticTokensRegistrationType = {}));
|
|
var SemanticTokensRequest;
|
|
(function(SemanticTokensRequest2) {
|
|
SemanticTokensRequest2.method = "textDocument/semanticTokens/full";
|
|
SemanticTokensRequest2.type = new messages_1.ProtocolRequestType(SemanticTokensRequest2.method);
|
|
})(SemanticTokensRequest = exports2.SemanticTokensRequest || (exports2.SemanticTokensRequest = {}));
|
|
var SemanticTokensDeltaRequest;
|
|
(function(SemanticTokensDeltaRequest2) {
|
|
SemanticTokensDeltaRequest2.method = "textDocument/semanticTokens/full/delta";
|
|
SemanticTokensDeltaRequest2.type = new messages_1.ProtocolRequestType(SemanticTokensDeltaRequest2.method);
|
|
})(SemanticTokensDeltaRequest = exports2.SemanticTokensDeltaRequest || (exports2.SemanticTokensDeltaRequest = {}));
|
|
var SemanticTokensRangeRequest;
|
|
(function(SemanticTokensRangeRequest2) {
|
|
SemanticTokensRangeRequest2.method = "textDocument/semanticTokens/range";
|
|
SemanticTokensRangeRequest2.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest2.method);
|
|
})(SemanticTokensRangeRequest = exports2.SemanticTokensRangeRequest || (exports2.SemanticTokensRangeRequest = {}));
|
|
var SemanticTokensRefreshRequest;
|
|
(function(SemanticTokensRefreshRequest2) {
|
|
SemanticTokensRefreshRequest2.method = `workspace/semanticTokens/refresh`;
|
|
SemanticTokensRefreshRequest2.type = new messages_1.ProtocolRequestType0(SemanticTokensRefreshRequest2.method);
|
|
})(SemanticTokensRefreshRequest = exports2.SemanticTokensRefreshRequest || (exports2.SemanticTokensRefreshRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.showDocument.js
|
|
var require_protocol_showDocument = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ShowDocumentRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var ShowDocumentRequest;
|
|
(function(ShowDocumentRequest2) {
|
|
ShowDocumentRequest2.method = "window/showDocument";
|
|
ShowDocumentRequest2.type = new messages_1.ProtocolRequestType(ShowDocumentRequest2.method);
|
|
})(ShowDocumentRequest = exports2.ShowDocumentRequest || (exports2.ShowDocumentRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.linkedEditingRange.js
|
|
var require_protocol_linkedEditingRange = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.LinkedEditingRangeRequest = void 0;
|
|
var messages_1 = require_messages2();
|
|
var LinkedEditingRangeRequest;
|
|
(function(LinkedEditingRangeRequest2) {
|
|
LinkedEditingRangeRequest2.method = "textDocument/linkedEditingRange";
|
|
LinkedEditingRangeRequest2.type = new messages_1.ProtocolRequestType(LinkedEditingRangeRequest2.method);
|
|
})(LinkedEditingRangeRequest = exports2.LinkedEditingRangeRequest || (exports2.LinkedEditingRangeRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.fileOperations.js
|
|
var require_protocol_fileOperations = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.WillDeleteFilesRequest = exports2.DidDeleteFilesNotification = exports2.DidRenameFilesNotification = exports2.WillRenameFilesRequest = exports2.DidCreateFilesNotification = exports2.WillCreateFilesRequest = exports2.FileOperationPatternKind = void 0;
|
|
var messages_1 = require_messages2();
|
|
var FileOperationPatternKind;
|
|
(function(FileOperationPatternKind2) {
|
|
FileOperationPatternKind2.file = "file";
|
|
FileOperationPatternKind2.folder = "folder";
|
|
})(FileOperationPatternKind = exports2.FileOperationPatternKind || (exports2.FileOperationPatternKind = {}));
|
|
var WillCreateFilesRequest;
|
|
(function(WillCreateFilesRequest2) {
|
|
WillCreateFilesRequest2.method = "workspace/willCreateFiles";
|
|
WillCreateFilesRequest2.type = new messages_1.ProtocolRequestType(WillCreateFilesRequest2.method);
|
|
})(WillCreateFilesRequest = exports2.WillCreateFilesRequest || (exports2.WillCreateFilesRequest = {}));
|
|
var DidCreateFilesNotification;
|
|
(function(DidCreateFilesNotification2) {
|
|
DidCreateFilesNotification2.method = "workspace/didCreateFiles";
|
|
DidCreateFilesNotification2.type = new messages_1.ProtocolNotificationType(DidCreateFilesNotification2.method);
|
|
})(DidCreateFilesNotification = exports2.DidCreateFilesNotification || (exports2.DidCreateFilesNotification = {}));
|
|
var WillRenameFilesRequest;
|
|
(function(WillRenameFilesRequest2) {
|
|
WillRenameFilesRequest2.method = "workspace/willRenameFiles";
|
|
WillRenameFilesRequest2.type = new messages_1.ProtocolRequestType(WillRenameFilesRequest2.method);
|
|
})(WillRenameFilesRequest = exports2.WillRenameFilesRequest || (exports2.WillRenameFilesRequest = {}));
|
|
var DidRenameFilesNotification;
|
|
(function(DidRenameFilesNotification2) {
|
|
DidRenameFilesNotification2.method = "workspace/didRenameFiles";
|
|
DidRenameFilesNotification2.type = new messages_1.ProtocolNotificationType(DidRenameFilesNotification2.method);
|
|
})(DidRenameFilesNotification = exports2.DidRenameFilesNotification || (exports2.DidRenameFilesNotification = {}));
|
|
var DidDeleteFilesNotification;
|
|
(function(DidDeleteFilesNotification2) {
|
|
DidDeleteFilesNotification2.method = "workspace/didDeleteFiles";
|
|
DidDeleteFilesNotification2.type = new messages_1.ProtocolNotificationType(DidDeleteFilesNotification2.method);
|
|
})(DidDeleteFilesNotification = exports2.DidDeleteFilesNotification || (exports2.DidDeleteFilesNotification = {}));
|
|
var WillDeleteFilesRequest;
|
|
(function(WillDeleteFilesRequest2) {
|
|
WillDeleteFilesRequest2.method = "workspace/willDeleteFiles";
|
|
WillDeleteFilesRequest2.type = new messages_1.ProtocolRequestType(WillDeleteFilesRequest2.method);
|
|
})(WillDeleteFilesRequest = exports2.WillDeleteFilesRequest || (exports2.WillDeleteFilesRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.moniker.js
|
|
var require_protocol_moniker = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.MonikerRequest = exports2.MonikerKind = exports2.UniquenessLevel = void 0;
|
|
var messages_1 = require_messages2();
|
|
var UniquenessLevel;
|
|
(function(UniquenessLevel2) {
|
|
UniquenessLevel2["document"] = "document";
|
|
UniquenessLevel2["project"] = "project";
|
|
UniquenessLevel2["group"] = "group";
|
|
UniquenessLevel2["scheme"] = "scheme";
|
|
UniquenessLevel2["global"] = "global";
|
|
})(UniquenessLevel = exports2.UniquenessLevel || (exports2.UniquenessLevel = {}));
|
|
var MonikerKind;
|
|
(function(MonikerKind2) {
|
|
MonikerKind2["import"] = "import";
|
|
MonikerKind2["export"] = "export";
|
|
MonikerKind2["local"] = "local";
|
|
})(MonikerKind = exports2.MonikerKind || (exports2.MonikerKind = {}));
|
|
var MonikerRequest;
|
|
(function(MonikerRequest2) {
|
|
MonikerRequest2.method = "textDocument/moniker";
|
|
MonikerRequest2.type = new messages_1.ProtocolRequestType(MonikerRequest2.method);
|
|
})(MonikerRequest = exports2.MonikerRequest || (exports2.MonikerRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/protocol.js
|
|
var require_protocol = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.DocumentLinkRequest = exports2.CodeLensRefreshRequest = exports2.CodeLensResolveRequest = exports2.CodeLensRequest = exports2.WorkspaceSymbolRequest = exports2.CodeActionResolveRequest = exports2.CodeActionRequest = exports2.DocumentSymbolRequest = exports2.DocumentHighlightRequest = exports2.ReferencesRequest = exports2.DefinitionRequest = exports2.SignatureHelpRequest = exports2.SignatureHelpTriggerKind = exports2.HoverRequest = exports2.CompletionResolveRequest = exports2.CompletionRequest = exports2.CompletionTriggerKind = exports2.PublishDiagnosticsNotification = exports2.WatchKind = exports2.FileChangeType = exports2.DidChangeWatchedFilesNotification = exports2.WillSaveTextDocumentWaitUntilRequest = exports2.WillSaveTextDocumentNotification = exports2.TextDocumentSaveReason = exports2.DidSaveTextDocumentNotification = exports2.DidCloseTextDocumentNotification = exports2.DidChangeTextDocumentNotification = exports2.TextDocumentContentChangeEvent = exports2.DidOpenTextDocumentNotification = exports2.TextDocumentSyncKind = exports2.TelemetryEventNotification = exports2.LogMessageNotification = exports2.ShowMessageRequest = exports2.ShowMessageNotification = exports2.MessageType = exports2.DidChangeConfigurationNotification = exports2.ExitNotification = exports2.ShutdownRequest = exports2.InitializedNotification = exports2.InitializeError = exports2.InitializeRequest = exports2.WorkDoneProgressOptions = exports2.TextDocumentRegistrationOptions = exports2.StaticRegistrationOptions = exports2.FailureHandlingKind = exports2.ResourceOperationKind = exports2.UnregistrationRequest = exports2.RegistrationRequest = exports2.DocumentSelector = exports2.DocumentFilter = void 0;
|
|
exports2.MonikerRequest = exports2.MonikerKind = exports2.UniquenessLevel = exports2.WillDeleteFilesRequest = exports2.DidDeleteFilesNotification = exports2.WillRenameFilesRequest = exports2.DidRenameFilesNotification = exports2.WillCreateFilesRequest = exports2.DidCreateFilesNotification = exports2.FileOperationPatternKind = exports2.LinkedEditingRangeRequest = exports2.ShowDocumentRequest = exports2.SemanticTokensRegistrationType = exports2.SemanticTokensRefreshRequest = exports2.SemanticTokensRangeRequest = exports2.SemanticTokensDeltaRequest = exports2.SemanticTokensRequest = exports2.TokenFormat = exports2.SemanticTokens = exports2.SemanticTokenModifiers = exports2.SemanticTokenTypes = exports2.CallHierarchyPrepareRequest = exports2.CallHierarchyOutgoingCallsRequest = exports2.CallHierarchyIncomingCallsRequest = exports2.WorkDoneProgressCancelNotification = exports2.WorkDoneProgressCreateRequest = exports2.WorkDoneProgress = exports2.SelectionRangeRequest = exports2.DeclarationRequest = exports2.FoldingRangeRequest = exports2.ColorPresentationRequest = exports2.DocumentColorRequest = exports2.ConfigurationRequest = exports2.DidChangeWorkspaceFoldersNotification = exports2.WorkspaceFoldersRequest = exports2.TypeDefinitionRequest = exports2.ImplementationRequest = exports2.ApplyWorkspaceEditRequest = exports2.ExecuteCommandRequest = exports2.PrepareRenameRequest = exports2.RenameRequest = exports2.PrepareSupportDefaultBehavior = exports2.DocumentOnTypeFormattingRequest = exports2.DocumentRangeFormattingRequest = exports2.DocumentFormattingRequest = exports2.DocumentLinkResolveRequest = void 0;
|
|
var Is = require_is3();
|
|
var messages_1 = require_messages2();
|
|
var protocol_implementation_1 = require_protocol_implementation();
|
|
Object.defineProperty(exports2, "ImplementationRequest", {enumerable: true, get: function() {
|
|
return protocol_implementation_1.ImplementationRequest;
|
|
}});
|
|
var protocol_typeDefinition_1 = require_protocol_typeDefinition();
|
|
Object.defineProperty(exports2, "TypeDefinitionRequest", {enumerable: true, get: function() {
|
|
return protocol_typeDefinition_1.TypeDefinitionRequest;
|
|
}});
|
|
var protocol_workspaceFolders_1 = require_protocol_workspaceFolders();
|
|
Object.defineProperty(exports2, "WorkspaceFoldersRequest", {enumerable: true, get: function() {
|
|
return protocol_workspaceFolders_1.WorkspaceFoldersRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "DidChangeWorkspaceFoldersNotification", {enumerable: true, get: function() {
|
|
return protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
|
|
}});
|
|
var protocol_configuration_1 = require_protocol_configuration();
|
|
Object.defineProperty(exports2, "ConfigurationRequest", {enumerable: true, get: function() {
|
|
return protocol_configuration_1.ConfigurationRequest;
|
|
}});
|
|
var protocol_colorProvider_1 = require_protocol_colorProvider();
|
|
Object.defineProperty(exports2, "DocumentColorRequest", {enumerable: true, get: function() {
|
|
return protocol_colorProvider_1.DocumentColorRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "ColorPresentationRequest", {enumerable: true, get: function() {
|
|
return protocol_colorProvider_1.ColorPresentationRequest;
|
|
}});
|
|
var protocol_foldingRange_1 = require_protocol_foldingRange();
|
|
Object.defineProperty(exports2, "FoldingRangeRequest", {enumerable: true, get: function() {
|
|
return protocol_foldingRange_1.FoldingRangeRequest;
|
|
}});
|
|
var protocol_declaration_1 = require_protocol_declaration();
|
|
Object.defineProperty(exports2, "DeclarationRequest", {enumerable: true, get: function() {
|
|
return protocol_declaration_1.DeclarationRequest;
|
|
}});
|
|
var protocol_selectionRange_1 = require_protocol_selectionRange();
|
|
Object.defineProperty(exports2, "SelectionRangeRequest", {enumerable: true, get: function() {
|
|
return protocol_selectionRange_1.SelectionRangeRequest;
|
|
}});
|
|
var protocol_progress_1 = require_protocol_progress();
|
|
Object.defineProperty(exports2, "WorkDoneProgress", {enumerable: true, get: function() {
|
|
return protocol_progress_1.WorkDoneProgress;
|
|
}});
|
|
Object.defineProperty(exports2, "WorkDoneProgressCreateRequest", {enumerable: true, get: function() {
|
|
return protocol_progress_1.WorkDoneProgressCreateRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "WorkDoneProgressCancelNotification", {enumerable: true, get: function() {
|
|
return protocol_progress_1.WorkDoneProgressCancelNotification;
|
|
}});
|
|
var protocol_callHierarchy_1 = require_protocol_callHierarchy();
|
|
Object.defineProperty(exports2, "CallHierarchyIncomingCallsRequest", {enumerable: true, get: function() {
|
|
return protocol_callHierarchy_1.CallHierarchyIncomingCallsRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "CallHierarchyOutgoingCallsRequest", {enumerable: true, get: function() {
|
|
return protocol_callHierarchy_1.CallHierarchyOutgoingCallsRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "CallHierarchyPrepareRequest", {enumerable: true, get: function() {
|
|
return protocol_callHierarchy_1.CallHierarchyPrepareRequest;
|
|
}});
|
|
var protocol_semanticTokens_1 = require_protocol_semanticTokens();
|
|
Object.defineProperty(exports2, "SemanticTokenTypes", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokenTypes;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokenModifiers", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokenModifiers;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokens", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokens;
|
|
}});
|
|
Object.defineProperty(exports2, "TokenFormat", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.TokenFormat;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokensRequest", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokensRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokensDeltaRequest", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokensDeltaRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokensRangeRequest", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokensRangeRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokensRefreshRequest", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokensRefreshRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "SemanticTokensRegistrationType", {enumerable: true, get: function() {
|
|
return protocol_semanticTokens_1.SemanticTokensRegistrationType;
|
|
}});
|
|
var protocol_showDocument_1 = require_protocol_showDocument();
|
|
Object.defineProperty(exports2, "ShowDocumentRequest", {enumerable: true, get: function() {
|
|
return protocol_showDocument_1.ShowDocumentRequest;
|
|
}});
|
|
var protocol_linkedEditingRange_1 = require_protocol_linkedEditingRange();
|
|
Object.defineProperty(exports2, "LinkedEditingRangeRequest", {enumerable: true, get: function() {
|
|
return protocol_linkedEditingRange_1.LinkedEditingRangeRequest;
|
|
}});
|
|
var protocol_fileOperations_1 = require_protocol_fileOperations();
|
|
Object.defineProperty(exports2, "FileOperationPatternKind", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.FileOperationPatternKind;
|
|
}});
|
|
Object.defineProperty(exports2, "DidCreateFilesNotification", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.DidCreateFilesNotification;
|
|
}});
|
|
Object.defineProperty(exports2, "WillCreateFilesRequest", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.WillCreateFilesRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "DidRenameFilesNotification", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.DidRenameFilesNotification;
|
|
}});
|
|
Object.defineProperty(exports2, "WillRenameFilesRequest", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.WillRenameFilesRequest;
|
|
}});
|
|
Object.defineProperty(exports2, "DidDeleteFilesNotification", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.DidDeleteFilesNotification;
|
|
}});
|
|
Object.defineProperty(exports2, "WillDeleteFilesRequest", {enumerable: true, get: function() {
|
|
return protocol_fileOperations_1.WillDeleteFilesRequest;
|
|
}});
|
|
var protocol_moniker_1 = require_protocol_moniker();
|
|
Object.defineProperty(exports2, "UniquenessLevel", {enumerable: true, get: function() {
|
|
return protocol_moniker_1.UniquenessLevel;
|
|
}});
|
|
Object.defineProperty(exports2, "MonikerKind", {enumerable: true, get: function() {
|
|
return protocol_moniker_1.MonikerKind;
|
|
}});
|
|
Object.defineProperty(exports2, "MonikerRequest", {enumerable: true, get: function() {
|
|
return protocol_moniker_1.MonikerRequest;
|
|
}});
|
|
var DocumentFilter;
|
|
(function(DocumentFilter2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
|
|
}
|
|
DocumentFilter2.is = is;
|
|
})(DocumentFilter = exports2.DocumentFilter || (exports2.DocumentFilter = {}));
|
|
var DocumentSelector;
|
|
(function(DocumentSelector2) {
|
|
function is(value) {
|
|
if (!Array.isArray(value)) {
|
|
return false;
|
|
}
|
|
for (let elem of value) {
|
|
if (!Is.string(elem) && !DocumentFilter.is(elem)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
DocumentSelector2.is = is;
|
|
})(DocumentSelector = exports2.DocumentSelector || (exports2.DocumentSelector = {}));
|
|
var RegistrationRequest;
|
|
(function(RegistrationRequest2) {
|
|
RegistrationRequest2.type = new messages_1.ProtocolRequestType("client/registerCapability");
|
|
})(RegistrationRequest = exports2.RegistrationRequest || (exports2.RegistrationRequest = {}));
|
|
var UnregistrationRequest;
|
|
(function(UnregistrationRequest2) {
|
|
UnregistrationRequest2.type = new messages_1.ProtocolRequestType("client/unregisterCapability");
|
|
})(UnregistrationRequest = exports2.UnregistrationRequest || (exports2.UnregistrationRequest = {}));
|
|
var ResourceOperationKind;
|
|
(function(ResourceOperationKind2) {
|
|
ResourceOperationKind2.Create = "create";
|
|
ResourceOperationKind2.Rename = "rename";
|
|
ResourceOperationKind2.Delete = "delete";
|
|
})(ResourceOperationKind = exports2.ResourceOperationKind || (exports2.ResourceOperationKind = {}));
|
|
var FailureHandlingKind;
|
|
(function(FailureHandlingKind2) {
|
|
FailureHandlingKind2.Abort = "abort";
|
|
FailureHandlingKind2.Transactional = "transactional";
|
|
FailureHandlingKind2.TextOnlyTransactional = "textOnlyTransactional";
|
|
FailureHandlingKind2.Undo = "undo";
|
|
})(FailureHandlingKind = exports2.FailureHandlingKind || (exports2.FailureHandlingKind = {}));
|
|
var StaticRegistrationOptions;
|
|
(function(StaticRegistrationOptions2) {
|
|
function hasId(value) {
|
|
const candidate = value;
|
|
return candidate && Is.string(candidate.id) && candidate.id.length > 0;
|
|
}
|
|
StaticRegistrationOptions2.hasId = hasId;
|
|
})(StaticRegistrationOptions = exports2.StaticRegistrationOptions || (exports2.StaticRegistrationOptions = {}));
|
|
var TextDocumentRegistrationOptions;
|
|
(function(TextDocumentRegistrationOptions2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
|
|
}
|
|
TextDocumentRegistrationOptions2.is = is;
|
|
})(TextDocumentRegistrationOptions = exports2.TextDocumentRegistrationOptions || (exports2.TextDocumentRegistrationOptions = {}));
|
|
var WorkDoneProgressOptions;
|
|
(function(WorkDoneProgressOptions2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return Is.objectLiteral(candidate) && (candidate.workDoneProgress === void 0 || Is.boolean(candidate.workDoneProgress));
|
|
}
|
|
WorkDoneProgressOptions2.is = is;
|
|
function hasWorkDoneProgress(value) {
|
|
const candidate = value;
|
|
return candidate && Is.boolean(candidate.workDoneProgress);
|
|
}
|
|
WorkDoneProgressOptions2.hasWorkDoneProgress = hasWorkDoneProgress;
|
|
})(WorkDoneProgressOptions = exports2.WorkDoneProgressOptions || (exports2.WorkDoneProgressOptions = {}));
|
|
var InitializeRequest;
|
|
(function(InitializeRequest2) {
|
|
InitializeRequest2.type = new messages_1.ProtocolRequestType("initialize");
|
|
})(InitializeRequest = exports2.InitializeRequest || (exports2.InitializeRequest = {}));
|
|
var InitializeError;
|
|
(function(InitializeError2) {
|
|
InitializeError2.unknownProtocolVersion = 1;
|
|
})(InitializeError = exports2.InitializeError || (exports2.InitializeError = {}));
|
|
var InitializedNotification;
|
|
(function(InitializedNotification2) {
|
|
InitializedNotification2.type = new messages_1.ProtocolNotificationType("initialized");
|
|
})(InitializedNotification = exports2.InitializedNotification || (exports2.InitializedNotification = {}));
|
|
var ShutdownRequest;
|
|
(function(ShutdownRequest2) {
|
|
ShutdownRequest2.type = new messages_1.ProtocolRequestType0("shutdown");
|
|
})(ShutdownRequest = exports2.ShutdownRequest || (exports2.ShutdownRequest = {}));
|
|
var ExitNotification;
|
|
(function(ExitNotification2) {
|
|
ExitNotification2.type = new messages_1.ProtocolNotificationType0("exit");
|
|
})(ExitNotification = exports2.ExitNotification || (exports2.ExitNotification = {}));
|
|
var DidChangeConfigurationNotification;
|
|
(function(DidChangeConfigurationNotification2) {
|
|
DidChangeConfigurationNotification2.type = new messages_1.ProtocolNotificationType("workspace/didChangeConfiguration");
|
|
})(DidChangeConfigurationNotification = exports2.DidChangeConfigurationNotification || (exports2.DidChangeConfigurationNotification = {}));
|
|
var MessageType;
|
|
(function(MessageType2) {
|
|
MessageType2.Error = 1;
|
|
MessageType2.Warning = 2;
|
|
MessageType2.Info = 3;
|
|
MessageType2.Log = 4;
|
|
})(MessageType = exports2.MessageType || (exports2.MessageType = {}));
|
|
var ShowMessageNotification;
|
|
(function(ShowMessageNotification2) {
|
|
ShowMessageNotification2.type = new messages_1.ProtocolNotificationType("window/showMessage");
|
|
})(ShowMessageNotification = exports2.ShowMessageNotification || (exports2.ShowMessageNotification = {}));
|
|
var ShowMessageRequest;
|
|
(function(ShowMessageRequest2) {
|
|
ShowMessageRequest2.type = new messages_1.ProtocolRequestType("window/showMessageRequest");
|
|
})(ShowMessageRequest = exports2.ShowMessageRequest || (exports2.ShowMessageRequest = {}));
|
|
var LogMessageNotification;
|
|
(function(LogMessageNotification2) {
|
|
LogMessageNotification2.type = new messages_1.ProtocolNotificationType("window/logMessage");
|
|
})(LogMessageNotification = exports2.LogMessageNotification || (exports2.LogMessageNotification = {}));
|
|
var TelemetryEventNotification;
|
|
(function(TelemetryEventNotification2) {
|
|
TelemetryEventNotification2.type = new messages_1.ProtocolNotificationType("telemetry/event");
|
|
})(TelemetryEventNotification = exports2.TelemetryEventNotification || (exports2.TelemetryEventNotification = {}));
|
|
var TextDocumentSyncKind;
|
|
(function(TextDocumentSyncKind2) {
|
|
TextDocumentSyncKind2.None = 0;
|
|
TextDocumentSyncKind2.Full = 1;
|
|
TextDocumentSyncKind2.Incremental = 2;
|
|
})(TextDocumentSyncKind = exports2.TextDocumentSyncKind || (exports2.TextDocumentSyncKind = {}));
|
|
var DidOpenTextDocumentNotification;
|
|
(function(DidOpenTextDocumentNotification2) {
|
|
DidOpenTextDocumentNotification2.method = "textDocument/didOpen";
|
|
DidOpenTextDocumentNotification2.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification2.method);
|
|
})(DidOpenTextDocumentNotification = exports2.DidOpenTextDocumentNotification || (exports2.DidOpenTextDocumentNotification = {}));
|
|
var TextDocumentContentChangeEvent;
|
|
(function(TextDocumentContentChangeEvent2) {
|
|
function isIncremental(event) {
|
|
let candidate = event;
|
|
return candidate !== void 0 && candidate !== null && typeof candidate.text === "string" && candidate.range !== void 0 && (candidate.rangeLength === void 0 || typeof candidate.rangeLength === "number");
|
|
}
|
|
TextDocumentContentChangeEvent2.isIncremental = isIncremental;
|
|
function isFull(event) {
|
|
let candidate = event;
|
|
return candidate !== void 0 && candidate !== null && typeof candidate.text === "string" && candidate.range === void 0 && candidate.rangeLength === void 0;
|
|
}
|
|
TextDocumentContentChangeEvent2.isFull = isFull;
|
|
})(TextDocumentContentChangeEvent = exports2.TextDocumentContentChangeEvent || (exports2.TextDocumentContentChangeEvent = {}));
|
|
var DidChangeTextDocumentNotification;
|
|
(function(DidChangeTextDocumentNotification2) {
|
|
DidChangeTextDocumentNotification2.method = "textDocument/didChange";
|
|
DidChangeTextDocumentNotification2.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification2.method);
|
|
})(DidChangeTextDocumentNotification = exports2.DidChangeTextDocumentNotification || (exports2.DidChangeTextDocumentNotification = {}));
|
|
var DidCloseTextDocumentNotification;
|
|
(function(DidCloseTextDocumentNotification2) {
|
|
DidCloseTextDocumentNotification2.method = "textDocument/didClose";
|
|
DidCloseTextDocumentNotification2.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification2.method);
|
|
})(DidCloseTextDocumentNotification = exports2.DidCloseTextDocumentNotification || (exports2.DidCloseTextDocumentNotification = {}));
|
|
var DidSaveTextDocumentNotification;
|
|
(function(DidSaveTextDocumentNotification2) {
|
|
DidSaveTextDocumentNotification2.method = "textDocument/didSave";
|
|
DidSaveTextDocumentNotification2.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification2.method);
|
|
})(DidSaveTextDocumentNotification = exports2.DidSaveTextDocumentNotification || (exports2.DidSaveTextDocumentNotification = {}));
|
|
var TextDocumentSaveReason;
|
|
(function(TextDocumentSaveReason2) {
|
|
TextDocumentSaveReason2.Manual = 1;
|
|
TextDocumentSaveReason2.AfterDelay = 2;
|
|
TextDocumentSaveReason2.FocusOut = 3;
|
|
})(TextDocumentSaveReason = exports2.TextDocumentSaveReason || (exports2.TextDocumentSaveReason = {}));
|
|
var WillSaveTextDocumentNotification;
|
|
(function(WillSaveTextDocumentNotification2) {
|
|
WillSaveTextDocumentNotification2.method = "textDocument/willSave";
|
|
WillSaveTextDocumentNotification2.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification2.method);
|
|
})(WillSaveTextDocumentNotification = exports2.WillSaveTextDocumentNotification || (exports2.WillSaveTextDocumentNotification = {}));
|
|
var WillSaveTextDocumentWaitUntilRequest;
|
|
(function(WillSaveTextDocumentWaitUntilRequest2) {
|
|
WillSaveTextDocumentWaitUntilRequest2.method = "textDocument/willSaveWaitUntil";
|
|
WillSaveTextDocumentWaitUntilRequest2.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest2.method);
|
|
})(WillSaveTextDocumentWaitUntilRequest = exports2.WillSaveTextDocumentWaitUntilRequest || (exports2.WillSaveTextDocumentWaitUntilRequest = {}));
|
|
var DidChangeWatchedFilesNotification;
|
|
(function(DidChangeWatchedFilesNotification2) {
|
|
DidChangeWatchedFilesNotification2.type = new messages_1.ProtocolNotificationType("workspace/didChangeWatchedFiles");
|
|
})(DidChangeWatchedFilesNotification = exports2.DidChangeWatchedFilesNotification || (exports2.DidChangeWatchedFilesNotification = {}));
|
|
var FileChangeType;
|
|
(function(FileChangeType2) {
|
|
FileChangeType2.Created = 1;
|
|
FileChangeType2.Changed = 2;
|
|
FileChangeType2.Deleted = 3;
|
|
})(FileChangeType = exports2.FileChangeType || (exports2.FileChangeType = {}));
|
|
var WatchKind;
|
|
(function(WatchKind2) {
|
|
WatchKind2.Create = 1;
|
|
WatchKind2.Change = 2;
|
|
WatchKind2.Delete = 4;
|
|
})(WatchKind = exports2.WatchKind || (exports2.WatchKind = {}));
|
|
var PublishDiagnosticsNotification;
|
|
(function(PublishDiagnosticsNotification2) {
|
|
PublishDiagnosticsNotification2.type = new messages_1.ProtocolNotificationType("textDocument/publishDiagnostics");
|
|
})(PublishDiagnosticsNotification = exports2.PublishDiagnosticsNotification || (exports2.PublishDiagnosticsNotification = {}));
|
|
var CompletionTriggerKind;
|
|
(function(CompletionTriggerKind2) {
|
|
CompletionTriggerKind2.Invoked = 1;
|
|
CompletionTriggerKind2.TriggerCharacter = 2;
|
|
CompletionTriggerKind2.TriggerForIncompleteCompletions = 3;
|
|
})(CompletionTriggerKind = exports2.CompletionTriggerKind || (exports2.CompletionTriggerKind = {}));
|
|
var CompletionRequest;
|
|
(function(CompletionRequest2) {
|
|
CompletionRequest2.method = "textDocument/completion";
|
|
CompletionRequest2.type = new messages_1.ProtocolRequestType(CompletionRequest2.method);
|
|
})(CompletionRequest = exports2.CompletionRequest || (exports2.CompletionRequest = {}));
|
|
var CompletionResolveRequest;
|
|
(function(CompletionResolveRequest2) {
|
|
CompletionResolveRequest2.method = "completionItem/resolve";
|
|
CompletionResolveRequest2.type = new messages_1.ProtocolRequestType(CompletionResolveRequest2.method);
|
|
})(CompletionResolveRequest = exports2.CompletionResolveRequest || (exports2.CompletionResolveRequest = {}));
|
|
var HoverRequest;
|
|
(function(HoverRequest2) {
|
|
HoverRequest2.method = "textDocument/hover";
|
|
HoverRequest2.type = new messages_1.ProtocolRequestType(HoverRequest2.method);
|
|
})(HoverRequest = exports2.HoverRequest || (exports2.HoverRequest = {}));
|
|
var SignatureHelpTriggerKind;
|
|
(function(SignatureHelpTriggerKind2) {
|
|
SignatureHelpTriggerKind2.Invoked = 1;
|
|
SignatureHelpTriggerKind2.TriggerCharacter = 2;
|
|
SignatureHelpTriggerKind2.ContentChange = 3;
|
|
})(SignatureHelpTriggerKind = exports2.SignatureHelpTriggerKind || (exports2.SignatureHelpTriggerKind = {}));
|
|
var SignatureHelpRequest;
|
|
(function(SignatureHelpRequest2) {
|
|
SignatureHelpRequest2.method = "textDocument/signatureHelp";
|
|
SignatureHelpRequest2.type = new messages_1.ProtocolRequestType(SignatureHelpRequest2.method);
|
|
})(SignatureHelpRequest = exports2.SignatureHelpRequest || (exports2.SignatureHelpRequest = {}));
|
|
var DefinitionRequest;
|
|
(function(DefinitionRequest2) {
|
|
DefinitionRequest2.method = "textDocument/definition";
|
|
DefinitionRequest2.type = new messages_1.ProtocolRequestType(DefinitionRequest2.method);
|
|
})(DefinitionRequest = exports2.DefinitionRequest || (exports2.DefinitionRequest = {}));
|
|
var ReferencesRequest;
|
|
(function(ReferencesRequest2) {
|
|
ReferencesRequest2.method = "textDocument/references";
|
|
ReferencesRequest2.type = new messages_1.ProtocolRequestType(ReferencesRequest2.method);
|
|
})(ReferencesRequest = exports2.ReferencesRequest || (exports2.ReferencesRequest = {}));
|
|
var DocumentHighlightRequest;
|
|
(function(DocumentHighlightRequest2) {
|
|
DocumentHighlightRequest2.method = "textDocument/documentHighlight";
|
|
DocumentHighlightRequest2.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest2.method);
|
|
})(DocumentHighlightRequest = exports2.DocumentHighlightRequest || (exports2.DocumentHighlightRequest = {}));
|
|
var DocumentSymbolRequest;
|
|
(function(DocumentSymbolRequest2) {
|
|
DocumentSymbolRequest2.method = "textDocument/documentSymbol";
|
|
DocumentSymbolRequest2.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest2.method);
|
|
})(DocumentSymbolRequest = exports2.DocumentSymbolRequest || (exports2.DocumentSymbolRequest = {}));
|
|
var CodeActionRequest;
|
|
(function(CodeActionRequest2) {
|
|
CodeActionRequest2.method = "textDocument/codeAction";
|
|
CodeActionRequest2.type = new messages_1.ProtocolRequestType(CodeActionRequest2.method);
|
|
})(CodeActionRequest = exports2.CodeActionRequest || (exports2.CodeActionRequest = {}));
|
|
var CodeActionResolveRequest;
|
|
(function(CodeActionResolveRequest2) {
|
|
CodeActionResolveRequest2.method = "codeAction/resolve";
|
|
CodeActionResolveRequest2.type = new messages_1.ProtocolRequestType(CodeActionResolveRequest2.method);
|
|
})(CodeActionResolveRequest = exports2.CodeActionResolveRequest || (exports2.CodeActionResolveRequest = {}));
|
|
var WorkspaceSymbolRequest;
|
|
(function(WorkspaceSymbolRequest2) {
|
|
WorkspaceSymbolRequest2.method = "workspace/symbol";
|
|
WorkspaceSymbolRequest2.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest2.method);
|
|
})(WorkspaceSymbolRequest = exports2.WorkspaceSymbolRequest || (exports2.WorkspaceSymbolRequest = {}));
|
|
var CodeLensRequest;
|
|
(function(CodeLensRequest2) {
|
|
CodeLensRequest2.method = "textDocument/codeLens";
|
|
CodeLensRequest2.type = new messages_1.ProtocolRequestType(CodeLensRequest2.method);
|
|
})(CodeLensRequest = exports2.CodeLensRequest || (exports2.CodeLensRequest = {}));
|
|
var CodeLensResolveRequest;
|
|
(function(CodeLensResolveRequest2) {
|
|
CodeLensResolveRequest2.method = "codeLens/resolve";
|
|
CodeLensResolveRequest2.type = new messages_1.ProtocolRequestType(CodeLensResolveRequest2.method);
|
|
})(CodeLensResolveRequest = exports2.CodeLensResolveRequest || (exports2.CodeLensResolveRequest = {}));
|
|
var CodeLensRefreshRequest;
|
|
(function(CodeLensRefreshRequest2) {
|
|
CodeLensRefreshRequest2.method = `workspace/codeLens/refresh`;
|
|
CodeLensRefreshRequest2.type = new messages_1.ProtocolRequestType0(CodeLensRefreshRequest2.method);
|
|
})(CodeLensRefreshRequest = exports2.CodeLensRefreshRequest || (exports2.CodeLensRefreshRequest = {}));
|
|
var DocumentLinkRequest;
|
|
(function(DocumentLinkRequest2) {
|
|
DocumentLinkRequest2.method = "textDocument/documentLink";
|
|
DocumentLinkRequest2.type = new messages_1.ProtocolRequestType(DocumentLinkRequest2.method);
|
|
})(DocumentLinkRequest = exports2.DocumentLinkRequest || (exports2.DocumentLinkRequest = {}));
|
|
var DocumentLinkResolveRequest;
|
|
(function(DocumentLinkResolveRequest2) {
|
|
DocumentLinkResolveRequest2.method = "documentLink/resolve";
|
|
DocumentLinkResolveRequest2.type = new messages_1.ProtocolRequestType(DocumentLinkResolveRequest2.method);
|
|
})(DocumentLinkResolveRequest = exports2.DocumentLinkResolveRequest || (exports2.DocumentLinkResolveRequest = {}));
|
|
var DocumentFormattingRequest;
|
|
(function(DocumentFormattingRequest2) {
|
|
DocumentFormattingRequest2.method = "textDocument/formatting";
|
|
DocumentFormattingRequest2.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest2.method);
|
|
})(DocumentFormattingRequest = exports2.DocumentFormattingRequest || (exports2.DocumentFormattingRequest = {}));
|
|
var DocumentRangeFormattingRequest;
|
|
(function(DocumentRangeFormattingRequest2) {
|
|
DocumentRangeFormattingRequest2.method = "textDocument/rangeFormatting";
|
|
DocumentRangeFormattingRequest2.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest2.method);
|
|
})(DocumentRangeFormattingRequest = exports2.DocumentRangeFormattingRequest || (exports2.DocumentRangeFormattingRequest = {}));
|
|
var DocumentOnTypeFormattingRequest;
|
|
(function(DocumentOnTypeFormattingRequest2) {
|
|
DocumentOnTypeFormattingRequest2.method = "textDocument/onTypeFormatting";
|
|
DocumentOnTypeFormattingRequest2.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest2.method);
|
|
})(DocumentOnTypeFormattingRequest = exports2.DocumentOnTypeFormattingRequest || (exports2.DocumentOnTypeFormattingRequest = {}));
|
|
var PrepareSupportDefaultBehavior;
|
|
(function(PrepareSupportDefaultBehavior2) {
|
|
PrepareSupportDefaultBehavior2.Identifier = 1;
|
|
})(PrepareSupportDefaultBehavior = exports2.PrepareSupportDefaultBehavior || (exports2.PrepareSupportDefaultBehavior = {}));
|
|
var RenameRequest;
|
|
(function(RenameRequest2) {
|
|
RenameRequest2.method = "textDocument/rename";
|
|
RenameRequest2.type = new messages_1.ProtocolRequestType(RenameRequest2.method);
|
|
})(RenameRequest = exports2.RenameRequest || (exports2.RenameRequest = {}));
|
|
var PrepareRenameRequest;
|
|
(function(PrepareRenameRequest2) {
|
|
PrepareRenameRequest2.method = "textDocument/prepareRename";
|
|
PrepareRenameRequest2.type = new messages_1.ProtocolRequestType(PrepareRenameRequest2.method);
|
|
})(PrepareRenameRequest = exports2.PrepareRenameRequest || (exports2.PrepareRenameRequest = {}));
|
|
var ExecuteCommandRequest;
|
|
(function(ExecuteCommandRequest2) {
|
|
ExecuteCommandRequest2.type = new messages_1.ProtocolRequestType("workspace/executeCommand");
|
|
})(ExecuteCommandRequest = exports2.ExecuteCommandRequest || (exports2.ExecuteCommandRequest = {}));
|
|
var ApplyWorkspaceEditRequest;
|
|
(function(ApplyWorkspaceEditRequest2) {
|
|
ApplyWorkspaceEditRequest2.type = new messages_1.ProtocolRequestType("workspace/applyEdit");
|
|
})(ApplyWorkspaceEditRequest = exports2.ApplyWorkspaceEditRequest || (exports2.ApplyWorkspaceEditRequest = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/connection.js
|
|
var require_connection2 = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.createProtocolConnection = void 0;
|
|
var vscode_jsonrpc_1 = require_main();
|
|
function createProtocolConnection(input, output, logger, options) {
|
|
if (vscode_jsonrpc_1.ConnectionStrategy.is(options)) {
|
|
options = {connectionStrategy: options};
|
|
}
|
|
return vscode_jsonrpc_1.createMessageConnection(input, output, logger, options);
|
|
}
|
|
exports2.createProtocolConnection = createProtocolConnection;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/common/api.js
|
|
var require_api2 = __commonJS((exports2) => {
|
|
"use strict";
|
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
Object.defineProperty(o, k2, {enumerable: true, get: function() {
|
|
return m[k];
|
|
}});
|
|
} : function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
o[k2] = m[k];
|
|
});
|
|
var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
for (var p in m)
|
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
|
|
__createBinding(exports3, m, p);
|
|
};
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.LSPErrorCodes = exports2.createProtocolConnection = void 0;
|
|
__exportStar2(require_main(), exports2);
|
|
__exportStar2(require_main2(), exports2);
|
|
__exportStar2(require_messages2(), exports2);
|
|
__exportStar2(require_protocol(), exports2);
|
|
var connection_1 = require_connection2();
|
|
Object.defineProperty(exports2, "createProtocolConnection", {enumerable: true, get: function() {
|
|
return connection_1.createProtocolConnection;
|
|
}});
|
|
var LSPErrorCodes;
|
|
(function(LSPErrorCodes2) {
|
|
LSPErrorCodes2.lspReservedErrorRangeStart = -32899;
|
|
LSPErrorCodes2.ContentModified = -32801;
|
|
LSPErrorCodes2.RequestCancelled = -32800;
|
|
LSPErrorCodes2.lspReservedErrorRangeEnd = -32800;
|
|
})(LSPErrorCodes = exports2.LSPErrorCodes || (exports2.LSPErrorCodes = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/lib/node/main.js
|
|
var require_main3 = __commonJS((exports2) => {
|
|
"use strict";
|
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
Object.defineProperty(o, k2, {enumerable: true, get: function() {
|
|
return m[k];
|
|
}});
|
|
} : function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
o[k2] = m[k];
|
|
});
|
|
var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
for (var p in m)
|
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
|
|
__createBinding(exports3, m, p);
|
|
};
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.createProtocolConnection = void 0;
|
|
var node_1 = require_node();
|
|
__exportStar2(require_node(), exports2);
|
|
__exportStar2(require_api2(), exports2);
|
|
function createProtocolConnection(input, output, logger, options) {
|
|
return node_1.createMessageConnection(input, output, logger, options);
|
|
}
|
|
exports2.createProtocolConnection = createProtocolConnection;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/utils/uuid.js
|
|
var require_uuid = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.generateUuid = exports2.parse = exports2.isUUID = exports2.v4 = exports2.empty = void 0;
|
|
var ValueUUID = class {
|
|
constructor(_value) {
|
|
this._value = _value;
|
|
}
|
|
asHex() {
|
|
return this._value;
|
|
}
|
|
equals(other) {
|
|
return this.asHex() === other.asHex();
|
|
}
|
|
};
|
|
var V4UUID = class extends ValueUUID {
|
|
constructor() {
|
|
super([
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
"-",
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
"-",
|
|
"4",
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
"-",
|
|
V4UUID._oneOf(V4UUID._timeHighBits),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
"-",
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex(),
|
|
V4UUID._randomHex()
|
|
].join(""));
|
|
}
|
|
static _oneOf(array) {
|
|
return array[Math.floor(array.length * Math.random())];
|
|
}
|
|
static _randomHex() {
|
|
return V4UUID._oneOf(V4UUID._chars);
|
|
}
|
|
};
|
|
V4UUID._chars = ["0", "1", "2", "3", "4", "5", "6", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
|
V4UUID._timeHighBits = ["8", "9", "a", "b"];
|
|
exports2.empty = new ValueUUID("00000000-0000-0000-0000-000000000000");
|
|
function v4() {
|
|
return new V4UUID();
|
|
}
|
|
exports2.v4 = v4;
|
|
var _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
function isUUID(value) {
|
|
return _UUIDPattern.test(value);
|
|
}
|
|
exports2.isUUID = isUUID;
|
|
function parse(value) {
|
|
if (!isUUID(value)) {
|
|
throw new Error("invalid uuid");
|
|
}
|
|
return new ValueUUID(value);
|
|
}
|
|
exports2.parse = parse;
|
|
function generateUuid() {
|
|
return v4().asHex();
|
|
}
|
|
exports2.generateUuid = generateUuid;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/progress.js
|
|
var require_progress = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.attachPartialResult = exports2.ProgressFeature = exports2.attachWorkDone = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var uuid_1 = require_uuid();
|
|
var WorkDoneProgressReporterImpl = class {
|
|
constructor(_connection, _token) {
|
|
this._connection = _connection;
|
|
this._token = _token;
|
|
WorkDoneProgressReporterImpl.Instances.set(this._token, this);
|
|
}
|
|
begin(title, percentage, message, cancellable) {
|
|
let param = {
|
|
kind: "begin",
|
|
title,
|
|
percentage,
|
|
message,
|
|
cancellable
|
|
};
|
|
this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
|
|
}
|
|
report(arg0, arg1) {
|
|
let param = {
|
|
kind: "report"
|
|
};
|
|
if (typeof arg0 === "number") {
|
|
param.percentage = arg0;
|
|
if (arg1 !== void 0) {
|
|
param.message = arg1;
|
|
}
|
|
} else {
|
|
param.message = arg0;
|
|
}
|
|
this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
|
|
}
|
|
done() {
|
|
WorkDoneProgressReporterImpl.Instances.delete(this._token);
|
|
this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, {kind: "end"});
|
|
}
|
|
};
|
|
WorkDoneProgressReporterImpl.Instances = new Map();
|
|
var WorkDoneProgressServerReporterImpl = class extends WorkDoneProgressReporterImpl {
|
|
constructor(connection, token) {
|
|
super(connection, token);
|
|
this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
|
|
}
|
|
get token() {
|
|
return this._source.token;
|
|
}
|
|
done() {
|
|
this._source.dispose();
|
|
super.done();
|
|
}
|
|
cancel() {
|
|
this._source.cancel();
|
|
}
|
|
};
|
|
var NullProgressReporter = class {
|
|
constructor() {
|
|
}
|
|
begin() {
|
|
}
|
|
report() {
|
|
}
|
|
done() {
|
|
}
|
|
};
|
|
var NullProgressServerReporter = class extends NullProgressReporter {
|
|
constructor() {
|
|
super();
|
|
this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
|
|
}
|
|
get token() {
|
|
return this._source.token;
|
|
}
|
|
done() {
|
|
this._source.dispose();
|
|
}
|
|
cancel() {
|
|
this._source.cancel();
|
|
}
|
|
};
|
|
function attachWorkDone(connection, params) {
|
|
if (params === void 0 || params.workDoneToken === void 0) {
|
|
return new NullProgressReporter();
|
|
}
|
|
const token = params.workDoneToken;
|
|
delete params.workDoneToken;
|
|
return new WorkDoneProgressReporterImpl(connection, token);
|
|
}
|
|
exports2.attachWorkDone = attachWorkDone;
|
|
var ProgressFeature = (Base) => {
|
|
return class extends Base {
|
|
constructor() {
|
|
super();
|
|
this._progressSupported = false;
|
|
}
|
|
initialize(capabilities) {
|
|
var _a2;
|
|
if (((_a2 = capabilities === null || capabilities === void 0 ? void 0 : capabilities.window) === null || _a2 === void 0 ? void 0 : _a2.workDoneProgress) === true) {
|
|
this._progressSupported = true;
|
|
this.connection.onNotification(vscode_languageserver_protocol_1.WorkDoneProgressCancelNotification.type, (params) => {
|
|
let progress = WorkDoneProgressReporterImpl.Instances.get(params.token);
|
|
if (progress instanceof WorkDoneProgressServerReporterImpl || progress instanceof NullProgressServerReporter) {
|
|
progress.cancel();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
attachWorkDoneProgress(token) {
|
|
if (token === void 0) {
|
|
return new NullProgressReporter();
|
|
} else {
|
|
return new WorkDoneProgressReporterImpl(this.connection, token);
|
|
}
|
|
}
|
|
createWorkDoneProgress() {
|
|
if (this._progressSupported) {
|
|
const token = uuid_1.generateUuid();
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkDoneProgressCreateRequest.type, {token}).then(() => {
|
|
const result = new WorkDoneProgressServerReporterImpl(this.connection, token);
|
|
return result;
|
|
});
|
|
} else {
|
|
return Promise.resolve(new NullProgressServerReporter());
|
|
}
|
|
}
|
|
};
|
|
};
|
|
exports2.ProgressFeature = ProgressFeature;
|
|
var ResultProgress;
|
|
(function(ResultProgress2) {
|
|
ResultProgress2.type = new vscode_languageserver_protocol_1.ProgressType();
|
|
})(ResultProgress || (ResultProgress = {}));
|
|
var ResultProgressReporterImpl = class {
|
|
constructor(_connection, _token) {
|
|
this._connection = _connection;
|
|
this._token = _token;
|
|
}
|
|
report(data) {
|
|
this._connection.sendProgress(ResultProgress.type, this._token, data);
|
|
}
|
|
};
|
|
function attachPartialResult(connection, params) {
|
|
if (params === void 0 || params.partialResultToken === void 0) {
|
|
return void 0;
|
|
}
|
|
const token = params.partialResultToken;
|
|
delete params.partialResultToken;
|
|
return new ResultProgressReporterImpl(connection, token);
|
|
}
|
|
exports2.attachPartialResult = attachPartialResult;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/configuration.js
|
|
var require_configuration = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ConfigurationFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var Is = require_is();
|
|
var ConfigurationFeature = (Base) => {
|
|
return class extends Base {
|
|
getConfiguration(arg) {
|
|
if (!arg) {
|
|
return this._getConfiguration({});
|
|
} else if (Is.string(arg)) {
|
|
return this._getConfiguration({section: arg});
|
|
} else {
|
|
return this._getConfiguration(arg);
|
|
}
|
|
}
|
|
_getConfiguration(arg) {
|
|
let params = {
|
|
items: Array.isArray(arg) ? arg : [arg]
|
|
};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {
|
|
return Array.isArray(arg) ? result : result[0];
|
|
});
|
|
}
|
|
};
|
|
};
|
|
exports2.ConfigurationFeature = ConfigurationFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/workspaceFolders.js
|
|
var require_workspaceFolders = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.WorkspaceFoldersFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var WorkspaceFoldersFeature = (Base) => {
|
|
return class extends Base {
|
|
initialize(capabilities) {
|
|
let workspaceCapabilities = capabilities.workspace;
|
|
if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
|
|
this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
|
|
this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
|
|
this._onDidChangeWorkspaceFolders.fire(params.event);
|
|
});
|
|
}
|
|
}
|
|
getWorkspaceFolders() {
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
|
|
}
|
|
get onDidChangeWorkspaceFolders() {
|
|
if (!this._onDidChangeWorkspaceFolders) {
|
|
throw new Error("Client doesn't support sending workspace folder change events.");
|
|
}
|
|
if (!this._unregistration) {
|
|
this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
|
|
}
|
|
return this._onDidChangeWorkspaceFolders.event;
|
|
}
|
|
};
|
|
};
|
|
exports2.WorkspaceFoldersFeature = WorkspaceFoldersFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/callHierarchy.js
|
|
var require_callHierarchy = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.CallHierarchyFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var CallHierarchyFeature = (Base) => {
|
|
return class extends Base {
|
|
get callHierarchy() {
|
|
return {
|
|
onPrepare: (handler) => {
|
|
this.connection.onRequest(vscode_languageserver_protocol_1.CallHierarchyPrepareRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), void 0);
|
|
});
|
|
},
|
|
onIncomingCalls: (handler) => {
|
|
const type = vscode_languageserver_protocol_1.CallHierarchyIncomingCallsRequest.type;
|
|
this.connection.onRequest(type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
|
|
});
|
|
},
|
|
onOutgoingCalls: (handler) => {
|
|
const type = vscode_languageserver_protocol_1.CallHierarchyOutgoingCallsRequest.type;
|
|
this.connection.onRequest(type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
|
|
});
|
|
}
|
|
};
|
|
}
|
|
};
|
|
};
|
|
exports2.CallHierarchyFeature = CallHierarchyFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/semanticTokens.js
|
|
var require_semanticTokens = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.SemanticTokensBuilder = exports2.SemanticTokensFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var SemanticTokensFeature = (Base) => {
|
|
return class extends Base {
|
|
get semanticTokens() {
|
|
return {
|
|
on: (handler) => {
|
|
const type = vscode_languageserver_protocol_1.SemanticTokensRequest.type;
|
|
this.connection.onRequest(type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
|
|
});
|
|
},
|
|
onDelta: (handler) => {
|
|
const type = vscode_languageserver_protocol_1.SemanticTokensDeltaRequest.type;
|
|
this.connection.onRequest(type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
|
|
});
|
|
},
|
|
onRange: (handler) => {
|
|
const type = vscode_languageserver_protocol_1.SemanticTokensRangeRequest.type;
|
|
this.connection.onRequest(type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
|
|
});
|
|
}
|
|
};
|
|
}
|
|
};
|
|
};
|
|
exports2.SemanticTokensFeature = SemanticTokensFeature;
|
|
var SemanticTokensBuilder = class {
|
|
constructor() {
|
|
this._prevData = void 0;
|
|
this.initialize();
|
|
}
|
|
initialize() {
|
|
this._id = Date.now();
|
|
this._prevLine = 0;
|
|
this._prevChar = 0;
|
|
this._data = [];
|
|
this._dataLen = 0;
|
|
}
|
|
push(line, char, length, tokenType, tokenModifiers) {
|
|
let pushLine = line;
|
|
let pushChar = char;
|
|
if (this._dataLen > 0) {
|
|
pushLine -= this._prevLine;
|
|
if (pushLine === 0) {
|
|
pushChar -= this._prevChar;
|
|
}
|
|
}
|
|
this._data[this._dataLen++] = pushLine;
|
|
this._data[this._dataLen++] = pushChar;
|
|
this._data[this._dataLen++] = length;
|
|
this._data[this._dataLen++] = tokenType;
|
|
this._data[this._dataLen++] = tokenModifiers;
|
|
this._prevLine = line;
|
|
this._prevChar = char;
|
|
}
|
|
get id() {
|
|
return this._id.toString();
|
|
}
|
|
previousResult(id) {
|
|
if (this.id === id) {
|
|
this._prevData = this._data;
|
|
}
|
|
this.initialize();
|
|
}
|
|
build() {
|
|
this._prevData = void 0;
|
|
return {
|
|
resultId: this.id,
|
|
data: this._data
|
|
};
|
|
}
|
|
canBuildEdits() {
|
|
return this._prevData !== void 0;
|
|
}
|
|
buildEdits() {
|
|
if (this._prevData !== void 0) {
|
|
const prevDataLength = this._prevData.length;
|
|
const dataLength = this._data.length;
|
|
let startIndex = 0;
|
|
while (startIndex < dataLength && startIndex < prevDataLength && this._prevData[startIndex] === this._data[startIndex]) {
|
|
startIndex++;
|
|
}
|
|
if (startIndex < dataLength && startIndex < prevDataLength) {
|
|
let endIndex = 0;
|
|
while (endIndex < dataLength && endIndex < prevDataLength && this._prevData[prevDataLength - 1 - endIndex] === this._data[dataLength - 1 - endIndex]) {
|
|
endIndex++;
|
|
}
|
|
const newData = this._data.slice(startIndex, dataLength - endIndex);
|
|
const result = {
|
|
resultId: this.id,
|
|
edits: [
|
|
{start: startIndex, deleteCount: prevDataLength - endIndex - startIndex, data: newData}
|
|
]
|
|
};
|
|
return result;
|
|
} else if (startIndex < dataLength) {
|
|
return {resultId: this.id, edits: [
|
|
{start: startIndex, deleteCount: 0, data: this._data.slice(startIndex)}
|
|
]};
|
|
} else if (startIndex < prevDataLength) {
|
|
return {resultId: this.id, edits: [
|
|
{start: startIndex, deleteCount: prevDataLength - startIndex}
|
|
]};
|
|
} else {
|
|
return {resultId: this.id, edits: []};
|
|
}
|
|
} else {
|
|
return this.build();
|
|
}
|
|
}
|
|
};
|
|
exports2.SemanticTokensBuilder = SemanticTokensBuilder;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/showDocument.js
|
|
var require_showDocument = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ShowDocumentFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var ShowDocumentFeature = (Base) => {
|
|
return class extends Base {
|
|
showDocument(params) {
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowDocumentRequest.type, params);
|
|
}
|
|
};
|
|
};
|
|
exports2.ShowDocumentFeature = ShowDocumentFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/fileOperations.js
|
|
var require_fileOperations = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.FileOperationsFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var FileOperationsFeature = (Base) => {
|
|
return class extends Base {
|
|
onDidCreateFiles(handler) {
|
|
this.connection.onNotification(vscode_languageserver_protocol_1.DidCreateFilesNotification.type, (params) => {
|
|
handler(params);
|
|
});
|
|
}
|
|
onDidRenameFiles(handler) {
|
|
this.connection.onNotification(vscode_languageserver_protocol_1.DidRenameFilesNotification.type, (params) => {
|
|
handler(params);
|
|
});
|
|
}
|
|
onDidDeleteFiles(handler) {
|
|
this.connection.onNotification(vscode_languageserver_protocol_1.DidDeleteFilesNotification.type, (params) => {
|
|
handler(params);
|
|
});
|
|
}
|
|
onWillCreateFiles(handler) {
|
|
return this.connection.onRequest(vscode_languageserver_protocol_1.WillCreateFilesRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
});
|
|
}
|
|
onWillRenameFiles(handler) {
|
|
return this.connection.onRequest(vscode_languageserver_protocol_1.WillRenameFilesRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
});
|
|
}
|
|
onWillDeleteFiles(handler) {
|
|
return this.connection.onRequest(vscode_languageserver_protocol_1.WillDeleteFilesRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
});
|
|
}
|
|
};
|
|
};
|
|
exports2.FileOperationsFeature = FileOperationsFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/linkedEditingRange.js
|
|
var require_linkedEditingRange = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.LinkedEditingRangeFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var LinkedEditingRangeFeature = (Base) => {
|
|
return class extends Base {
|
|
onLinkedEditingRange(handler) {
|
|
this.connection.onRequest(vscode_languageserver_protocol_1.LinkedEditingRangeRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), void 0);
|
|
});
|
|
}
|
|
};
|
|
};
|
|
exports2.LinkedEditingRangeFeature = LinkedEditingRangeFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/moniker.js
|
|
var require_moniker = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.MonikerFeature = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var MonikerFeature = (Base) => {
|
|
return class extends Base {
|
|
get moniker() {
|
|
return {
|
|
on: (handler) => {
|
|
const type = vscode_languageserver_protocol_1.MonikerRequest.type;
|
|
this.connection.onRequest(type, (params, cancel) => {
|
|
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
|
|
});
|
|
}
|
|
};
|
|
}
|
|
};
|
|
};
|
|
exports2.MonikerFeature = MonikerFeature;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/server.js
|
|
var require_server = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.createConnection = exports2.combineFeatures = exports2.combineLanguagesFeatures = exports2.combineWorkspaceFeatures = exports2.combineWindowFeatures = exports2.combineClientFeatures = exports2.combineTracerFeatures = exports2.combineTelemetryFeatures = exports2.combineConsoleFeatures = exports2._LanguagesImpl = exports2.BulkUnregistration = exports2.BulkRegistration = exports2.ErrorMessageTracker = exports2.TextDocuments = void 0;
|
|
var vscode_languageserver_protocol_1 = require_main3();
|
|
var Is = require_is();
|
|
var UUID = require_uuid();
|
|
var progress_1 = require_progress();
|
|
var configuration_1 = require_configuration();
|
|
var workspaceFolders_1 = require_workspaceFolders();
|
|
var callHierarchy_1 = require_callHierarchy();
|
|
var semanticTokens_1 = require_semanticTokens();
|
|
var showDocument_1 = require_showDocument();
|
|
var fileOperations_1 = require_fileOperations();
|
|
var linkedEditingRange_1 = require_linkedEditingRange();
|
|
var moniker_1 = require_moniker();
|
|
function null2Undefined(value) {
|
|
if (value === null) {
|
|
return void 0;
|
|
}
|
|
return value;
|
|
}
|
|
var TextDocuments = class {
|
|
constructor(configuration) {
|
|
this._documents = Object.create(null);
|
|
this._configuration = configuration;
|
|
this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
|
|
this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
|
|
this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
|
|
this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
|
|
this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
|
|
}
|
|
get onDidChangeContent() {
|
|
return this._onDidChangeContent.event;
|
|
}
|
|
get onDidOpen() {
|
|
return this._onDidOpen.event;
|
|
}
|
|
get onWillSave() {
|
|
return this._onWillSave.event;
|
|
}
|
|
onWillSaveWaitUntil(handler) {
|
|
this._willSaveWaitUntil = handler;
|
|
}
|
|
get onDidSave() {
|
|
return this._onDidSave.event;
|
|
}
|
|
get onDidClose() {
|
|
return this._onDidClose.event;
|
|
}
|
|
get(uri) {
|
|
return this._documents[uri];
|
|
}
|
|
all() {
|
|
return Object.keys(this._documents).map((key) => this._documents[key]);
|
|
}
|
|
keys() {
|
|
return Object.keys(this._documents);
|
|
}
|
|
listen(connection) {
|
|
connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
|
|
connection.onDidOpenTextDocument((event) => {
|
|
let td = event.textDocument;
|
|
let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
|
|
this._documents[td.uri] = document;
|
|
let toFire = Object.freeze({document});
|
|
this._onDidOpen.fire(toFire);
|
|
this._onDidChangeContent.fire(toFire);
|
|
});
|
|
connection.onDidChangeTextDocument((event) => {
|
|
let td = event.textDocument;
|
|
let changes = event.contentChanges;
|
|
if (changes.length === 0) {
|
|
return;
|
|
}
|
|
let document = this._documents[td.uri];
|
|
const {version} = td;
|
|
if (version === null || version === void 0) {
|
|
throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
|
|
}
|
|
document = this._configuration.update(document, changes, version);
|
|
this._documents[td.uri] = document;
|
|
this._onDidChangeContent.fire(Object.freeze({document}));
|
|
});
|
|
connection.onDidCloseTextDocument((event) => {
|
|
let document = this._documents[event.textDocument.uri];
|
|
if (document) {
|
|
delete this._documents[event.textDocument.uri];
|
|
this._onDidClose.fire(Object.freeze({document}));
|
|
}
|
|
});
|
|
connection.onWillSaveTextDocument((event) => {
|
|
let document = this._documents[event.textDocument.uri];
|
|
if (document) {
|
|
this._onWillSave.fire(Object.freeze({document, reason: event.reason}));
|
|
}
|
|
});
|
|
connection.onWillSaveTextDocumentWaitUntil((event, token) => {
|
|
let document = this._documents[event.textDocument.uri];
|
|
if (document && this._willSaveWaitUntil) {
|
|
return this._willSaveWaitUntil(Object.freeze({document, reason: event.reason}), token);
|
|
} else {
|
|
return [];
|
|
}
|
|
});
|
|
connection.onDidSaveTextDocument((event) => {
|
|
let document = this._documents[event.textDocument.uri];
|
|
if (document) {
|
|
this._onDidSave.fire(Object.freeze({document}));
|
|
}
|
|
});
|
|
}
|
|
};
|
|
exports2.TextDocuments = TextDocuments;
|
|
var ErrorMessageTracker = class {
|
|
constructor() {
|
|
this._messages = Object.create(null);
|
|
}
|
|
add(message) {
|
|
let count = this._messages[message];
|
|
if (!count) {
|
|
count = 0;
|
|
}
|
|
count++;
|
|
this._messages[message] = count;
|
|
}
|
|
sendErrors(connection) {
|
|
Object.keys(this._messages).forEach((message) => {
|
|
connection.window.showErrorMessage(message);
|
|
});
|
|
}
|
|
};
|
|
exports2.ErrorMessageTracker = ErrorMessageTracker;
|
|
var RemoteConsoleImpl = class {
|
|
constructor() {
|
|
}
|
|
rawAttach(connection) {
|
|
this._rawConnection = connection;
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
error(message) {
|
|
this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
|
|
}
|
|
warn(message) {
|
|
this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
|
|
}
|
|
info(message) {
|
|
this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
|
|
}
|
|
log(message) {
|
|
this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
|
|
}
|
|
send(type, message) {
|
|
if (this._rawConnection) {
|
|
this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, {type, message});
|
|
}
|
|
}
|
|
};
|
|
var _RemoteWindowImpl = class {
|
|
constructor() {
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
showErrorMessage(message, ...actions) {
|
|
let params = {type: vscode_languageserver_protocol_1.MessageType.Error, message, actions};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
|
|
}
|
|
showWarningMessage(message, ...actions) {
|
|
let params = {type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
|
|
}
|
|
showInformationMessage(message, ...actions) {
|
|
let params = {type: vscode_languageserver_protocol_1.MessageType.Info, message, actions};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
|
|
}
|
|
};
|
|
var RemoteWindowImpl = showDocument_1.ShowDocumentFeature(progress_1.ProgressFeature(_RemoteWindowImpl));
|
|
var BulkRegistration;
|
|
(function(BulkRegistration2) {
|
|
function create() {
|
|
return new BulkRegistrationImpl();
|
|
}
|
|
BulkRegistration2.create = create;
|
|
})(BulkRegistration = exports2.BulkRegistration || (exports2.BulkRegistration = {}));
|
|
var BulkRegistrationImpl = class {
|
|
constructor() {
|
|
this._registrations = [];
|
|
this._registered = new Set();
|
|
}
|
|
add(type, registerOptions) {
|
|
const method = Is.string(type) ? type : type.method;
|
|
if (this._registered.has(method)) {
|
|
throw new Error(`${method} is already added to this registration`);
|
|
}
|
|
const id = UUID.generateUuid();
|
|
this._registrations.push({
|
|
id,
|
|
method,
|
|
registerOptions: registerOptions || {}
|
|
});
|
|
this._registered.add(method);
|
|
}
|
|
asRegistrationParams() {
|
|
return {
|
|
registrations: this._registrations
|
|
};
|
|
}
|
|
};
|
|
var BulkUnregistration;
|
|
(function(BulkUnregistration2) {
|
|
function create() {
|
|
return new BulkUnregistrationImpl(void 0, []);
|
|
}
|
|
BulkUnregistration2.create = create;
|
|
})(BulkUnregistration = exports2.BulkUnregistration || (exports2.BulkUnregistration = {}));
|
|
var BulkUnregistrationImpl = class {
|
|
constructor(_connection, unregistrations) {
|
|
this._connection = _connection;
|
|
this._unregistrations = new Map();
|
|
unregistrations.forEach((unregistration) => {
|
|
this._unregistrations.set(unregistration.method, unregistration);
|
|
});
|
|
}
|
|
get isAttached() {
|
|
return !!this._connection;
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
add(unregistration) {
|
|
this._unregistrations.set(unregistration.method, unregistration);
|
|
}
|
|
dispose() {
|
|
let unregistrations = [];
|
|
for (let unregistration of this._unregistrations.values()) {
|
|
unregistrations.push(unregistration);
|
|
}
|
|
let params = {
|
|
unregisterations: unregistrations
|
|
};
|
|
this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(void 0, (_error) => {
|
|
this._connection.console.info(`Bulk unregistration failed.`);
|
|
});
|
|
}
|
|
disposeSingle(arg) {
|
|
const method = Is.string(arg) ? arg : arg.method;
|
|
const unregistration = this._unregistrations.get(method);
|
|
if (!unregistration) {
|
|
return false;
|
|
}
|
|
let params = {
|
|
unregisterations: [unregistration]
|
|
};
|
|
this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
|
|
this._unregistrations.delete(method);
|
|
}, (_error) => {
|
|
this._connection.console.info(`Un-registering request handler for ${unregistration.id} failed.`);
|
|
});
|
|
return true;
|
|
}
|
|
};
|
|
var RemoteClientImpl = class {
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
|
|
if (typeOrRegistrations instanceof BulkRegistrationImpl) {
|
|
return this.registerMany(typeOrRegistrations);
|
|
} else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
|
|
return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
|
|
} else {
|
|
return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
|
|
}
|
|
}
|
|
registerSingle1(unregistration, type, registerOptions) {
|
|
const method = Is.string(type) ? type : type.method;
|
|
const id = UUID.generateUuid();
|
|
let params = {
|
|
registrations: [{id, method, registerOptions: registerOptions || {}}]
|
|
};
|
|
if (!unregistration.isAttached) {
|
|
unregistration.attach(this.connection);
|
|
}
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
|
|
unregistration.add({id, method});
|
|
return unregistration;
|
|
}, (_error) => {
|
|
this.connection.console.info(`Registering request handler for ${method} failed.`);
|
|
return Promise.reject(_error);
|
|
});
|
|
}
|
|
registerSingle2(type, registerOptions) {
|
|
const method = Is.string(type) ? type : type.method;
|
|
const id = UUID.generateUuid();
|
|
let params = {
|
|
registrations: [{id, method, registerOptions: registerOptions || {}}]
|
|
};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
|
|
return vscode_languageserver_protocol_1.Disposable.create(() => {
|
|
this.unregisterSingle(id, method);
|
|
});
|
|
}, (_error) => {
|
|
this.connection.console.info(`Registering request handler for ${method} failed.`);
|
|
return Promise.reject(_error);
|
|
});
|
|
}
|
|
unregisterSingle(id, method) {
|
|
let params = {
|
|
unregisterations: [{id, method}]
|
|
};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(void 0, (_error) => {
|
|
this.connection.console.info(`Un-registering request handler for ${id} failed.`);
|
|
});
|
|
}
|
|
registerMany(registrations) {
|
|
let params = registrations.asRegistrationParams();
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
|
|
return new BulkUnregistrationImpl(this._connection, params.registrations.map((registration) => {
|
|
return {id: registration.id, method: registration.method};
|
|
}));
|
|
}, (_error) => {
|
|
this.connection.console.info(`Bulk registration failed.`);
|
|
return Promise.reject(_error);
|
|
});
|
|
}
|
|
};
|
|
var _RemoteWorkspaceImpl = class {
|
|
constructor() {
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
applyEdit(paramOrEdit) {
|
|
function isApplyWorkspaceEditParams(value) {
|
|
return value && !!value.edit;
|
|
}
|
|
let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : {edit: paramOrEdit};
|
|
return this.connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
|
|
}
|
|
};
|
|
var RemoteWorkspaceImpl = fileOperations_1.FileOperationsFeature(workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl)));
|
|
var TracerImpl = class {
|
|
constructor() {
|
|
this._trace = vscode_languageserver_protocol_1.Trace.Off;
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
set trace(value) {
|
|
this._trace = value;
|
|
}
|
|
log(message, verbose) {
|
|
if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
|
|
return;
|
|
}
|
|
this.connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
|
|
message,
|
|
verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : void 0
|
|
});
|
|
}
|
|
};
|
|
var TelemetryImpl = class {
|
|
constructor() {
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
logEvent(data) {
|
|
this.connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
|
|
}
|
|
};
|
|
var _LanguagesImpl = class {
|
|
constructor() {
|
|
}
|
|
attach(connection) {
|
|
this._connection = connection;
|
|
}
|
|
get connection() {
|
|
if (!this._connection) {
|
|
throw new Error("Remote is not attached to a connection yet.");
|
|
}
|
|
return this._connection;
|
|
}
|
|
initialize(_capabilities) {
|
|
}
|
|
fillServerCapabilities(_capabilities) {
|
|
}
|
|
attachWorkDoneProgress(params) {
|
|
return progress_1.attachWorkDone(this.connection, params);
|
|
}
|
|
attachPartialResultProgress(_type, params) {
|
|
return progress_1.attachPartialResult(this.connection, params);
|
|
}
|
|
};
|
|
exports2._LanguagesImpl = _LanguagesImpl;
|
|
var LanguagesImpl = moniker_1.MonikerFeature(linkedEditingRange_1.LinkedEditingRangeFeature(semanticTokens_1.SemanticTokensFeature(callHierarchy_1.CallHierarchyFeature(_LanguagesImpl))));
|
|
function combineConsoleFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineConsoleFeatures = combineConsoleFeatures;
|
|
function combineTelemetryFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineTelemetryFeatures = combineTelemetryFeatures;
|
|
function combineTracerFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineTracerFeatures = combineTracerFeatures;
|
|
function combineClientFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineClientFeatures = combineClientFeatures;
|
|
function combineWindowFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineWindowFeatures = combineWindowFeatures;
|
|
function combineWorkspaceFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineWorkspaceFeatures = combineWorkspaceFeatures;
|
|
function combineLanguagesFeatures(one, two) {
|
|
return function(Base) {
|
|
return two(one(Base));
|
|
};
|
|
}
|
|
exports2.combineLanguagesFeatures = combineLanguagesFeatures;
|
|
function combineFeatures(one, two) {
|
|
function combine(one2, two2, func) {
|
|
if (one2 && two2) {
|
|
return func(one2, two2);
|
|
} else if (one2) {
|
|
return one2;
|
|
} else {
|
|
return two2;
|
|
}
|
|
}
|
|
let result = {
|
|
__brand: "features",
|
|
console: combine(one.console, two.console, combineConsoleFeatures),
|
|
tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
|
|
telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
|
|
client: combine(one.client, two.client, combineClientFeatures),
|
|
window: combine(one.window, two.window, combineWindowFeatures),
|
|
workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
|
|
};
|
|
return result;
|
|
}
|
|
exports2.combineFeatures = combineFeatures;
|
|
function createConnection(connectionFactory, watchDog, factories) {
|
|
const logger = factories && factories.console ? new (factories.console(RemoteConsoleImpl))() : new RemoteConsoleImpl();
|
|
const connection = connectionFactory(logger);
|
|
logger.rawAttach(connection);
|
|
const tracer = factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl();
|
|
const telemetry = factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl();
|
|
const client = factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl();
|
|
const remoteWindow = factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl();
|
|
const workspace = factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl();
|
|
const languages = factories && factories.languages ? new (factories.languages(LanguagesImpl))() : new LanguagesImpl();
|
|
const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages];
|
|
function asPromise(value) {
|
|
if (value instanceof Promise) {
|
|
return value;
|
|
} else if (Is.thenable(value)) {
|
|
return new Promise((resolve, reject) => {
|
|
value.then((resolved) => resolve(resolved), (error) => reject(error));
|
|
});
|
|
} else {
|
|
return Promise.resolve(value);
|
|
}
|
|
}
|
|
let shutdownHandler = void 0;
|
|
let initializeHandler = void 0;
|
|
let exitHandler = void 0;
|
|
let protocolConnection = {
|
|
listen: () => connection.listen(),
|
|
sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
|
|
onRequest: (type, handler) => connection.onRequest(type, handler),
|
|
sendNotification: (type, param) => {
|
|
const method = Is.string(type) ? type : type.method;
|
|
if (arguments.length === 1) {
|
|
connection.sendNotification(method);
|
|
} else {
|
|
connection.sendNotification(method, param);
|
|
}
|
|
},
|
|
onNotification: (type, handler) => connection.onNotification(type, handler),
|
|
onProgress: connection.onProgress,
|
|
sendProgress: connection.sendProgress,
|
|
onInitialize: (handler) => initializeHandler = handler,
|
|
onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
|
|
onShutdown: (handler) => shutdownHandler = handler,
|
|
onExit: (handler) => exitHandler = handler,
|
|
get console() {
|
|
return logger;
|
|
},
|
|
get telemetry() {
|
|
return telemetry;
|
|
},
|
|
get tracer() {
|
|
return tracer;
|
|
},
|
|
get client() {
|
|
return client;
|
|
},
|
|
get window() {
|
|
return remoteWindow;
|
|
},
|
|
get workspace() {
|
|
return workspace;
|
|
},
|
|
get languages() {
|
|
return languages;
|
|
},
|
|
onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
|
|
onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
|
|
__textDocumentSync: void 0,
|
|
onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
|
|
onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
|
|
onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
|
|
onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
|
|
onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
|
|
onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
|
|
sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
|
|
onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), void 0);
|
|
}),
|
|
onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
|
|
onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), void 0);
|
|
}),
|
|
onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onCodeActionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionResolveRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
}),
|
|
onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
}),
|
|
onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), void 0);
|
|
}),
|
|
onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), void 0);
|
|
}),
|
|
onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
}),
|
|
onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), void 0);
|
|
}),
|
|
onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
}),
|
|
onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
|
|
return handler(params, cancel);
|
|
}),
|
|
onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
|
|
}),
|
|
onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
|
|
return handler(params, cancel, progress_1.attachWorkDone(connection, params), void 0);
|
|
}),
|
|
dispose: () => connection.dispose()
|
|
};
|
|
for (let remote of allRemotes) {
|
|
remote.attach(protocolConnection);
|
|
}
|
|
connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
|
|
watchDog.initialize(params);
|
|
if (Is.string(params.trace)) {
|
|
tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
|
|
}
|
|
for (let remote of allRemotes) {
|
|
remote.initialize(params.capabilities);
|
|
}
|
|
if (initializeHandler) {
|
|
let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, progress_1.attachWorkDone(connection, params), void 0);
|
|
return asPromise(result).then((value) => {
|
|
if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
|
|
return value;
|
|
}
|
|
let result2 = value;
|
|
if (!result2) {
|
|
result2 = {capabilities: {}};
|
|
}
|
|
let capabilities = result2.capabilities;
|
|
if (!capabilities) {
|
|
capabilities = {};
|
|
result2.capabilities = capabilities;
|
|
}
|
|
if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {
|
|
capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
|
|
} else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
|
|
capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
|
|
}
|
|
for (let remote of allRemotes) {
|
|
remote.fillServerCapabilities(capabilities);
|
|
}
|
|
return result2;
|
|
});
|
|
} else {
|
|
let result = {capabilities: {textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None}};
|
|
for (let remote of allRemotes) {
|
|
remote.fillServerCapabilities(result.capabilities);
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
|
|
watchDog.shutdownReceived = true;
|
|
if (shutdownHandler) {
|
|
return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
|
|
} else {
|
|
return void 0;
|
|
}
|
|
});
|
|
connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
|
|
try {
|
|
if (exitHandler) {
|
|
exitHandler();
|
|
}
|
|
} finally {
|
|
if (watchDog.shutdownReceived) {
|
|
watchDog.exit(0);
|
|
} else {
|
|
watchDog.exit(1);
|
|
}
|
|
}
|
|
});
|
|
connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
|
|
tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
|
|
});
|
|
return protocolConnection;
|
|
}
|
|
exports2.createConnection = createConnection;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/node/files.js
|
|
var require_files = __commonJS((exports2) => {
|
|
"use strict";
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.resolveModulePath = exports2.FileSystem = exports2.resolveGlobalYarnPath = exports2.resolveGlobalNodePath = exports2.resolve = exports2.uriToFilePath = void 0;
|
|
var url = require("url");
|
|
var path = require("path");
|
|
var fs = require("fs");
|
|
var child_process_1 = require("child_process");
|
|
function uriToFilePath(uri) {
|
|
let parsed = url.parse(uri);
|
|
if (parsed.protocol !== "file:" || !parsed.path) {
|
|
return void 0;
|
|
}
|
|
let segments = parsed.path.split("/");
|
|
for (var i = 0, len = segments.length; i < len; i++) {
|
|
segments[i] = decodeURIComponent(segments[i]);
|
|
}
|
|
if (process.platform === "win32" && segments.length > 1) {
|
|
let first = segments[0];
|
|
let second = segments[1];
|
|
if (first.length === 0 && second.length > 1 && second[1] === ":") {
|
|
segments.shift();
|
|
}
|
|
}
|
|
return path.normalize(segments.join("/"));
|
|
}
|
|
exports2.uriToFilePath = uriToFilePath;
|
|
function isWindows2() {
|
|
return process.platform === "win32";
|
|
}
|
|
function resolve(moduleName, nodePath, cwd, tracer) {
|
|
const nodePathKey = "NODE_PATH";
|
|
const app = [
|
|
"var p = process;",
|
|
"p.on('message',function(m){",
|
|
"if(m.c==='e'){",
|
|
"p.exit(0);",
|
|
"}",
|
|
"else if(m.c==='rs'){",
|
|
"try{",
|
|
"var r=require.resolve(m.a);",
|
|
"p.send({c:'r',s:true,r:r});",
|
|
"}",
|
|
"catch(err){",
|
|
"p.send({c:'r',s:false});",
|
|
"}",
|
|
"}",
|
|
"});"
|
|
].join("");
|
|
return new Promise((resolve2, reject) => {
|
|
let env = process.env;
|
|
let newEnv = Object.create(null);
|
|
Object.keys(env).forEach((key) => newEnv[key] = env[key]);
|
|
if (nodePath && fs.existsSync(nodePath)) {
|
|
if (newEnv[nodePathKey]) {
|
|
newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
|
|
} else {
|
|
newEnv[nodePathKey] = nodePath;
|
|
}
|
|
if (tracer) {
|
|
tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
|
|
}
|
|
}
|
|
newEnv["ELECTRON_RUN_AS_NODE"] = "1";
|
|
try {
|
|
let cp = child_process_1.fork("", [], {
|
|
cwd,
|
|
env: newEnv,
|
|
execArgv: ["-e", app]
|
|
});
|
|
if (cp.pid === void 0) {
|
|
reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
|
|
return;
|
|
}
|
|
cp.on("error", (error) => {
|
|
reject(error);
|
|
});
|
|
cp.on("message", (message2) => {
|
|
if (message2.c === "r") {
|
|
cp.send({c: "e"});
|
|
if (message2.s) {
|
|
resolve2(message2.r);
|
|
} else {
|
|
reject(new Error(`Failed to resolve module: ${moduleName}`));
|
|
}
|
|
}
|
|
});
|
|
let message = {
|
|
c: "rs",
|
|
a: moduleName
|
|
};
|
|
cp.send(message);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
}
|
|
exports2.resolve = resolve;
|
|
function resolveGlobalNodePath(tracer) {
|
|
let npmCommand = "npm";
|
|
const env = Object.create(null);
|
|
Object.keys(process.env).forEach((key) => env[key] = process.env[key]);
|
|
env["NO_UPDATE_NOTIFIER"] = "true";
|
|
const options = {
|
|
encoding: "utf8",
|
|
env
|
|
};
|
|
if (isWindows2()) {
|
|
npmCommand = "npm.cmd";
|
|
options.shell = true;
|
|
}
|
|
let handler = () => {
|
|
};
|
|
try {
|
|
process.on("SIGPIPE", handler);
|
|
let stdout = child_process_1.spawnSync(npmCommand, ["config", "get", "prefix"], options).stdout;
|
|
if (!stdout) {
|
|
if (tracer) {
|
|
tracer(`'npm config get prefix' didn't return a value.`);
|
|
}
|
|
return void 0;
|
|
}
|
|
let prefix = stdout.trim();
|
|
if (tracer) {
|
|
tracer(`'npm config get prefix' value is: ${prefix}`);
|
|
}
|
|
if (prefix.length > 0) {
|
|
if (isWindows2()) {
|
|
return path.join(prefix, "node_modules");
|
|
} else {
|
|
return path.join(prefix, "lib", "node_modules");
|
|
}
|
|
}
|
|
return void 0;
|
|
} catch (err) {
|
|
return void 0;
|
|
} finally {
|
|
process.removeListener("SIGPIPE", handler);
|
|
}
|
|
}
|
|
exports2.resolveGlobalNodePath = resolveGlobalNodePath;
|
|
function resolveGlobalYarnPath(tracer) {
|
|
let yarnCommand = "yarn";
|
|
let options = {
|
|
encoding: "utf8"
|
|
};
|
|
if (isWindows2()) {
|
|
yarnCommand = "yarn.cmd";
|
|
options.shell = true;
|
|
}
|
|
let handler = () => {
|
|
};
|
|
try {
|
|
process.on("SIGPIPE", handler);
|
|
let results = child_process_1.spawnSync(yarnCommand, ["global", "dir", "--json"], options);
|
|
let stdout = results.stdout;
|
|
if (!stdout) {
|
|
if (tracer) {
|
|
tracer(`'yarn global dir' didn't return a value.`);
|
|
if (results.stderr) {
|
|
tracer(results.stderr);
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
let lines = stdout.trim().split(/\r?\n/);
|
|
for (let line of lines) {
|
|
try {
|
|
let yarn = JSON.parse(line);
|
|
if (yarn.type === "log") {
|
|
return path.join(yarn.data, "node_modules");
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
return void 0;
|
|
} catch (err) {
|
|
return void 0;
|
|
} finally {
|
|
process.removeListener("SIGPIPE", handler);
|
|
}
|
|
}
|
|
exports2.resolveGlobalYarnPath = resolveGlobalYarnPath;
|
|
var FileSystem;
|
|
(function(FileSystem2) {
|
|
let _isCaseSensitive = void 0;
|
|
function isCaseSensitive() {
|
|
if (_isCaseSensitive !== void 0) {
|
|
return _isCaseSensitive;
|
|
}
|
|
if (process.platform === "win32") {
|
|
_isCaseSensitive = false;
|
|
} else {
|
|
_isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
|
|
}
|
|
return _isCaseSensitive;
|
|
}
|
|
FileSystem2.isCaseSensitive = isCaseSensitive;
|
|
function isParent(parent, child) {
|
|
if (isCaseSensitive()) {
|
|
return path.normalize(child).indexOf(path.normalize(parent)) === 0;
|
|
} else {
|
|
return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
|
|
}
|
|
}
|
|
FileSystem2.isParent = isParent;
|
|
})(FileSystem = exports2.FileSystem || (exports2.FileSystem = {}));
|
|
function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
|
|
if (nodePath) {
|
|
if (!path.isAbsolute(nodePath)) {
|
|
nodePath = path.join(workspaceRoot, nodePath);
|
|
}
|
|
return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
|
|
if (FileSystem.isParent(nodePath, value)) {
|
|
return value;
|
|
} else {
|
|
return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
|
|
}
|
|
}).then(void 0, (_error) => {
|
|
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
|
});
|
|
} else {
|
|
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
|
}
|
|
}
|
|
exports2.resolveModulePath = resolveModulePath;
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol/node.js
|
|
var require_node2 = __commonJS((exports2, module2) => {
|
|
"use strict";
|
|
module2.exports = require_main3();
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/common/api.js
|
|
var require_api3 = __commonJS((exports2) => {
|
|
"use strict";
|
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
Object.defineProperty(o, k2, {enumerable: true, get: function() {
|
|
return m[k];
|
|
}});
|
|
} : function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
o[k2] = m[k];
|
|
});
|
|
var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
for (var p in m)
|
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
|
|
__createBinding(exports3, m, p);
|
|
};
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.ProposedFeatures = exports2.SemanticTokensBuilder = void 0;
|
|
var semanticTokens_1 = require_semanticTokens();
|
|
Object.defineProperty(exports2, "SemanticTokensBuilder", {enumerable: true, get: function() {
|
|
return semanticTokens_1.SemanticTokensBuilder;
|
|
}});
|
|
__exportStar2(require_main3(), exports2);
|
|
__exportStar2(require_server(), exports2);
|
|
var ProposedFeatures;
|
|
(function(ProposedFeatures2) {
|
|
ProposedFeatures2.all = {
|
|
__brand: "features"
|
|
};
|
|
})(ProposedFeatures = exports2.ProposedFeatures || (exports2.ProposedFeatures = {}));
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/lib/node/main.js
|
|
var require_main4 = __commonJS((exports2) => {
|
|
"use strict";
|
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
Object.defineProperty(o, k2, {enumerable: true, get: function() {
|
|
return m[k];
|
|
}});
|
|
} : function(o, m, k, k2) {
|
|
if (k2 === void 0)
|
|
k2 = k;
|
|
o[k2] = m[k];
|
|
});
|
|
var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
for (var p in m)
|
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
|
|
__createBinding(exports3, m, p);
|
|
};
|
|
Object.defineProperty(exports2, "__esModule", {value: true});
|
|
exports2.createConnection = exports2.Files = void 0;
|
|
var Is = require_is();
|
|
var server_1 = require_server();
|
|
var fm = require_files();
|
|
var node_1 = require_node2();
|
|
__exportStar2(require_node2(), exports2);
|
|
__exportStar2(require_api3(), exports2);
|
|
var Files;
|
|
(function(Files2) {
|
|
Files2.uriToFilePath = fm.uriToFilePath;
|
|
Files2.resolveGlobalNodePath = fm.resolveGlobalNodePath;
|
|
Files2.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
|
|
Files2.resolve = fm.resolve;
|
|
Files2.resolveModulePath = fm.resolveModulePath;
|
|
})(Files = exports2.Files || (exports2.Files = {}));
|
|
var _protocolConnection;
|
|
function endProtocolConnection() {
|
|
if (_protocolConnection === void 0) {
|
|
return;
|
|
}
|
|
try {
|
|
_protocolConnection.end();
|
|
} catch (_err) {
|
|
}
|
|
}
|
|
var _shutdownReceived = false;
|
|
var exitTimer = void 0;
|
|
function setupExitTimer() {
|
|
const argName = "--clientProcessId";
|
|
function runTimer(value) {
|
|
try {
|
|
let processId = parseInt(value);
|
|
if (!isNaN(processId)) {
|
|
exitTimer = setInterval(() => {
|
|
try {
|
|
process.kill(processId, 0);
|
|
} catch (ex) {
|
|
endProtocolConnection();
|
|
process.exit(_shutdownReceived ? 0 : 1);
|
|
}
|
|
}, 3e3);
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
for (let i = 2; i < process.argv.length; i++) {
|
|
let arg = process.argv[i];
|
|
if (arg === argName && i + 1 < process.argv.length) {
|
|
runTimer(process.argv[i + 1]);
|
|
return;
|
|
} else {
|
|
let args = arg.split("=");
|
|
if (args[0] === argName) {
|
|
runTimer(args[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setupExitTimer();
|
|
var watchDog = {
|
|
initialize: (params) => {
|
|
const processId = params.processId;
|
|
if (Is.number(processId) && exitTimer === void 0) {
|
|
setInterval(() => {
|
|
try {
|
|
process.kill(processId, 0);
|
|
} catch (ex) {
|
|
process.exit(_shutdownReceived ? 0 : 1);
|
|
}
|
|
}, 3e3);
|
|
}
|
|
},
|
|
get shutdownReceived() {
|
|
return _shutdownReceived;
|
|
},
|
|
set shutdownReceived(value) {
|
|
_shutdownReceived = value;
|
|
},
|
|
exit: (code) => {
|
|
endProtocolConnection();
|
|
process.exit(code);
|
|
}
|
|
};
|
|
function createConnection(arg1, arg2, arg3, arg4) {
|
|
let factories;
|
|
let input;
|
|
let output;
|
|
let options;
|
|
if (arg1 !== void 0 && arg1.__brand === "features") {
|
|
factories = arg1;
|
|
arg1 = arg2;
|
|
arg2 = arg3;
|
|
arg3 = arg4;
|
|
}
|
|
if (node_1.ConnectionStrategy.is(arg1) || node_1.ConnectionOptions.is(arg1)) {
|
|
options = arg1;
|
|
} else {
|
|
input = arg1;
|
|
output = arg2;
|
|
options = arg3;
|
|
}
|
|
return _createConnection(input, output, options, factories);
|
|
}
|
|
exports2.createConnection = createConnection;
|
|
function _createConnection(input, output, options, factories) {
|
|
if (!input && !output && process.argv.length > 2) {
|
|
let port = void 0;
|
|
let pipeName = void 0;
|
|
let argv = process.argv.slice(2);
|
|
for (let i = 0; i < argv.length; i++) {
|
|
let arg = argv[i];
|
|
if (arg === "--node-ipc") {
|
|
input = new node_1.IPCMessageReader(process);
|
|
output = new node_1.IPCMessageWriter(process);
|
|
break;
|
|
} else if (arg === "--stdio") {
|
|
input = process.stdin;
|
|
output = process.stdout;
|
|
break;
|
|
} else if (arg === "--socket") {
|
|
port = parseInt(argv[i + 1]);
|
|
break;
|
|
} else if (arg === "--pipe") {
|
|
pipeName = argv[i + 1];
|
|
break;
|
|
} else {
|
|
var args = arg.split("=");
|
|
if (args[0] === "--socket") {
|
|
port = parseInt(args[1]);
|
|
break;
|
|
} else if (args[0] === "--pipe") {
|
|
pipeName = args[1];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (port) {
|
|
let transport = node_1.createServerSocketTransport(port);
|
|
input = transport[0];
|
|
output = transport[1];
|
|
} else if (pipeName) {
|
|
let transport = node_1.createServerPipeTransport(pipeName);
|
|
input = transport[0];
|
|
output = transport[1];
|
|
}
|
|
}
|
|
var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";
|
|
if (!input) {
|
|
throw new Error("Connection input stream is not set. " + commandLineMessage);
|
|
}
|
|
if (!output) {
|
|
throw new Error("Connection output stream is not set. " + commandLineMessage);
|
|
}
|
|
if (Is.func(input.read) && Is.func(input.on)) {
|
|
let inputStream = input;
|
|
inputStream.on("end", () => {
|
|
endProtocolConnection();
|
|
process.exit(_shutdownReceived ? 0 : 1);
|
|
});
|
|
inputStream.on("close", () => {
|
|
endProtocolConnection();
|
|
process.exit(_shutdownReceived ? 0 : 1);
|
|
});
|
|
}
|
|
const connectionFactory = (logger) => {
|
|
const result = node_1.createProtocolConnection(input, output, logger, options);
|
|
return result;
|
|
};
|
|
return server_1.createConnection(connectionFactory, watchDog, factories);
|
|
}
|
|
});
|
|
|
|
// node_modules/vscode-languageserver/node.js
|
|
var require_node3 = __commonJS((exports2, module2) => {
|
|
"use strict";
|
|
module2.exports = require_main4();
|
|
});
|
|
|
|
// server/eslintServer.ts
|
|
var require_eslintServer = __commonJS(() => {
|
|
var import_node = __toModule(require_node3());
|
|
var path = __toModule(require("path"));
|
|
var fs = __toModule(require("fs"));
|
|
var import_child_process = __toModule(require("child_process"));
|
|
var import_os = __toModule(require("os"));
|
|
"use strict";
|
|
var Is;
|
|
(function(Is2) {
|
|
const toString = Object.prototype.toString;
|
|
function boolean(value) {
|
|
return value === true || value === false;
|
|
}
|
|
Is2.boolean = boolean;
|
|
function nullOrUndefined(value) {
|
|
return value === null || value === void 0;
|
|
}
|
|
Is2.nullOrUndefined = nullOrUndefined;
|
|
function string(value) {
|
|
return toString.call(value) === "[object String]";
|
|
}
|
|
Is2.string = string;
|
|
})(Is || (Is = {}));
|
|
var CommandIds;
|
|
(function(CommandIds2) {
|
|
CommandIds2.applySingleFix = "eslint.applySingleFix";
|
|
CommandIds2.applySuggestion = "eslint.applySuggestion";
|
|
CommandIds2.applySameFixes = "eslint.applySameFixes";
|
|
CommandIds2.applyAllFixes = "eslint.applyAllFixes";
|
|
CommandIds2.applyDisableLine = "eslint.applyDisableLine";
|
|
CommandIds2.applyDisableFile = "eslint.applyDisableFile";
|
|
CommandIds2.openRuleDoc = "eslint.openRuleDoc";
|
|
})(CommandIds || (CommandIds = {}));
|
|
var Status;
|
|
(function(Status2) {
|
|
Status2[Status2["ok"] = 1] = "ok";
|
|
Status2[Status2["warn"] = 2] = "warn";
|
|
Status2[Status2["error"] = 3] = "error";
|
|
Status2[Status2["confirmationPending"] = 4] = "confirmationPending";
|
|
Status2[Status2["confirmationCanceled"] = 5] = "confirmationCanceled";
|
|
Status2[Status2["executionDenied"] = 6] = "executionDenied";
|
|
})(Status || (Status = {}));
|
|
var StatusNotification;
|
|
(function(StatusNotification2) {
|
|
StatusNotification2.type = new import_node.NotificationType("eslint/status");
|
|
})(StatusNotification || (StatusNotification = {}));
|
|
var NoConfigRequest;
|
|
(function(NoConfigRequest2) {
|
|
NoConfigRequest2.type = new import_node.RequestType("eslint/noConfig");
|
|
})(NoConfigRequest || (NoConfigRequest = {}));
|
|
var NoESLintLibraryRequest;
|
|
(function(NoESLintLibraryRequest2) {
|
|
NoESLintLibraryRequest2.type = new import_node.RequestType("eslint/noLibrary");
|
|
})(NoESLintLibraryRequest || (NoESLintLibraryRequest = {}));
|
|
var OpenESLintDocRequest;
|
|
(function(OpenESLintDocRequest2) {
|
|
OpenESLintDocRequest2.type = new import_node.RequestType("eslint/openDoc");
|
|
})(OpenESLintDocRequest || (OpenESLintDocRequest = {}));
|
|
var ProbeFailedRequest;
|
|
(function(ProbeFailedRequest2) {
|
|
ProbeFailedRequest2.type = new import_node.RequestType("eslint/probeFailed");
|
|
})(ProbeFailedRequest || (ProbeFailedRequest = {}));
|
|
var ConfirmExecutionResult;
|
|
(function(ConfirmExecutionResult2) {
|
|
ConfirmExecutionResult2[ConfirmExecutionResult2["deny"] = 1] = "deny";
|
|
ConfirmExecutionResult2[ConfirmExecutionResult2["confirmationPending"] = 2] = "confirmationPending";
|
|
ConfirmExecutionResult2[ConfirmExecutionResult2["confirmationCanceled"] = 3] = "confirmationCanceled";
|
|
ConfirmExecutionResult2[ConfirmExecutionResult2["approved"] = 4] = "approved";
|
|
})(ConfirmExecutionResult || (ConfirmExecutionResult = {}));
|
|
(function(ConfirmExecutionResult2) {
|
|
function toStatus(value) {
|
|
switch (value) {
|
|
case ConfirmExecutionResult2.deny:
|
|
return 6;
|
|
case ConfirmExecutionResult2.confirmationPending:
|
|
return 4;
|
|
case ConfirmExecutionResult2.confirmationCanceled:
|
|
return 5;
|
|
case ConfirmExecutionResult2.approved:
|
|
return 1;
|
|
}
|
|
}
|
|
ConfirmExecutionResult2.toStatus = toStatus;
|
|
})(ConfirmExecutionResult || (ConfirmExecutionResult = {}));
|
|
var ConfirmExecution;
|
|
(function(ConfirmExecution2) {
|
|
ConfirmExecution2.type = new import_node.RequestType("eslint/confirmESLintExecution");
|
|
})(ConfirmExecution || (ConfirmExecution = {}));
|
|
var ShowOutputChannel;
|
|
(function(ShowOutputChannel2) {
|
|
ShowOutputChannel2.type = new import_node.NotificationType0("eslint/showOutputChannel");
|
|
})(ShowOutputChannel || (ShowOutputChannel = {}));
|
|
var ModeEnum;
|
|
(function(ModeEnum2) {
|
|
ModeEnum2["auto"] = "auto";
|
|
ModeEnum2["location"] = "location";
|
|
})(ModeEnum || (ModeEnum = {}));
|
|
(function(ModeEnum2) {
|
|
function is(value) {
|
|
return value === ModeEnum2.auto || value === ModeEnum2.location;
|
|
}
|
|
ModeEnum2.is = is;
|
|
})(ModeEnum || (ModeEnum = {}));
|
|
var ModeItem;
|
|
(function(ModeItem2) {
|
|
function is(item) {
|
|
const candidate = item;
|
|
return candidate && ModeEnum.is(candidate.mode);
|
|
}
|
|
ModeItem2.is = is;
|
|
})(ModeItem || (ModeItem = {}));
|
|
var DirectoryItem;
|
|
(function(DirectoryItem2) {
|
|
function is(item) {
|
|
const candidate = item;
|
|
return candidate && Is.string(candidate.directory) && (Is.boolean(candidate["!cwd"]) || candidate["!cwd"] === void 0);
|
|
}
|
|
DirectoryItem2.is = is;
|
|
})(DirectoryItem || (DirectoryItem = {}));
|
|
var Validate;
|
|
(function(Validate2) {
|
|
Validate2["on"] = "on";
|
|
Validate2["off"] = "off";
|
|
Validate2["probe"] = "probe";
|
|
})(Validate || (Validate = {}));
|
|
var ESLintSeverity;
|
|
(function(ESLintSeverity2) {
|
|
ESLintSeverity2["off"] = "off";
|
|
ESLintSeverity2["warn"] = "warn";
|
|
ESLintSeverity2["error"] = "error";
|
|
})(ESLintSeverity || (ESLintSeverity = {}));
|
|
var CodeActionsOnSaveMode;
|
|
(function(CodeActionsOnSaveMode2) {
|
|
CodeActionsOnSaveMode2["all"] = "all";
|
|
CodeActionsOnSaveMode2["problems"] = "problems";
|
|
})(CodeActionsOnSaveMode || (CodeActionsOnSaveMode = {}));
|
|
var TextDocumentSettings;
|
|
(function(TextDocumentSettings2) {
|
|
function hasLibrary(settings) {
|
|
return settings.library !== void 0;
|
|
}
|
|
TextDocumentSettings2.hasLibrary = hasLibrary;
|
|
})(TextDocumentSettings || (TextDocumentSettings = {}));
|
|
var RuleData;
|
|
(function(RuleData2) {
|
|
function hasMetaType(value) {
|
|
return value !== void 0 && value.meta !== void 0 && value.meta.type !== void 0;
|
|
}
|
|
RuleData2.hasMetaType = hasMetaType;
|
|
})(RuleData || (RuleData = {}));
|
|
var CLIEngine;
|
|
(function(CLIEngine2) {
|
|
function hasRule(value) {
|
|
return value.getRules !== void 0;
|
|
}
|
|
CLIEngine2.hasRule = hasRule;
|
|
})(CLIEngine || (CLIEngine = {}));
|
|
function loadNodeModule(moduleName) {
|
|
try {
|
|
return require(moduleName);
|
|
} catch (err) {
|
|
connection.console.error(err.stack.toString());
|
|
}
|
|
return void 0;
|
|
}
|
|
function makeDiagnostic(problem) {
|
|
const message = problem.message;
|
|
const startLine = Is.nullOrUndefined(problem.line) ? 0 : Math.max(0, problem.line - 1);
|
|
const startChar = Is.nullOrUndefined(problem.column) ? 0 : Math.max(0, problem.column - 1);
|
|
const endLine = Is.nullOrUndefined(problem.endLine) ? startLine : Math.max(0, problem.endLine - 1);
|
|
const endChar = Is.nullOrUndefined(problem.endColumn) ? startChar : Math.max(0, problem.endColumn - 1);
|
|
const result = {
|
|
message,
|
|
severity: convertSeverity(problem.severity),
|
|
source: "eslint",
|
|
range: {
|
|
start: {line: startLine, character: startChar},
|
|
end: {line: endLine, character: endChar}
|
|
}
|
|
};
|
|
if (problem.ruleId) {
|
|
const url = ruleDocData.urls.get(problem.ruleId);
|
|
result.code = problem.ruleId;
|
|
if (url !== void 0) {
|
|
result.codeDescription = {
|
|
href: url
|
|
};
|
|
}
|
|
if (problem.ruleId === "no-unused-vars") {
|
|
result.tags = [import_node.DiagnosticTag.Unnecessary];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
var Problem;
|
|
(function(Problem2) {
|
|
function isFixable(problem) {
|
|
return problem.edit !== void 0;
|
|
}
|
|
Problem2.isFixable = isFixable;
|
|
function hasSuggestions(problem) {
|
|
return problem.suggestions !== void 0;
|
|
}
|
|
Problem2.hasSuggestions = hasSuggestions;
|
|
})(Problem || (Problem = {}));
|
|
var FixableProblem;
|
|
(function(FixableProblem2) {
|
|
function createTextEdit(document, editInfo) {
|
|
return import_node.TextEdit.replace(import_node.Range.create(document.positionAt(editInfo.edit.range[0]), document.positionAt(editInfo.edit.range[1])), editInfo.edit.text || "");
|
|
}
|
|
FixableProblem2.createTextEdit = createTextEdit;
|
|
})(FixableProblem || (FixableProblem = {}));
|
|
var SuggestionsProblem;
|
|
(function(SuggestionsProblem2) {
|
|
function createTextEdit(document, suggestion) {
|
|
return import_node.TextEdit.replace(import_node.Range.create(document.positionAt(suggestion.fix.range[0]), document.positionAt(suggestion.fix.range[1])), suggestion.fix.text || "");
|
|
}
|
|
SuggestionsProblem2.createTextEdit = createTextEdit;
|
|
})(SuggestionsProblem || (SuggestionsProblem = {}));
|
|
function computeKey(diagnostic) {
|
|
const range = diagnostic.range;
|
|
return `[${range.start.line},${range.start.character},${range.end.line},${range.end.character}]-${diagnostic.code}`;
|
|
}
|
|
var codeActions = new Map();
|
|
function recordCodeAction(document, diagnostic, problem) {
|
|
if (!problem.ruleId) {
|
|
return;
|
|
}
|
|
const uri = document.uri;
|
|
let edits = codeActions.get(uri);
|
|
if (edits === void 0) {
|
|
edits = new Map();
|
|
codeActions.set(uri, edits);
|
|
}
|
|
edits.set(computeKey(diagnostic), {
|
|
label: `Fix this ${problem.ruleId} problem`,
|
|
documentVersion: document.version,
|
|
ruleId: problem.ruleId,
|
|
line: problem.line,
|
|
diagnostic,
|
|
edit: problem.fix,
|
|
suggestions: problem.suggestions
|
|
});
|
|
}
|
|
function convertSeverity(severity) {
|
|
switch (severity) {
|
|
case 1:
|
|
return import_node.DiagnosticSeverity.Warning;
|
|
case 2:
|
|
return import_node.DiagnosticSeverity.Error;
|
|
default:
|
|
return import_node.DiagnosticSeverity.Error;
|
|
}
|
|
}
|
|
var CharCode;
|
|
(function(CharCode2) {
|
|
CharCode2[CharCode2["Backslash"] = 92] = "Backslash";
|
|
})(CharCode || (CharCode = {}));
|
|
function isUNC(path2) {
|
|
if (process.platform !== "win32") {
|
|
return false;
|
|
}
|
|
if (!path2 || path2.length < 5) {
|
|
return false;
|
|
}
|
|
let code = path2.charCodeAt(0);
|
|
if (code !== 92) {
|
|
return false;
|
|
}
|
|
code = path2.charCodeAt(1);
|
|
if (code !== 92) {
|
|
return false;
|
|
}
|
|
let pos = 2;
|
|
const start = pos;
|
|
for (; pos < path2.length; pos++) {
|
|
code = path2.charCodeAt(pos);
|
|
if (code === 92) {
|
|
break;
|
|
}
|
|
}
|
|
if (start === pos) {
|
|
return false;
|
|
}
|
|
code = path2.charCodeAt(pos + 1);
|
|
if (isNaN(code) || code === 92) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function getFileSystemPath(uri) {
|
|
let result = uri.fsPath;
|
|
if (process.platform === "win32" && result.length >= 2 && result[1] === ":") {
|
|
result = result[0].toUpperCase() + result.substr(1);
|
|
}
|
|
if (!fs.existsSync(result)) {
|
|
return result;
|
|
}
|
|
if (process.platform === "win32" || process.platform === "darwin") {
|
|
const realpath = fs.realpathSync.native(result);
|
|
if (realpath.toLowerCase() === result.toLowerCase()) {
|
|
result = realpath;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function getFilePath(documentOrUri) {
|
|
if (!documentOrUri) {
|
|
return void 0;
|
|
}
|
|
const uri = Is.string(documentOrUri) ? URI.parse(documentOrUri) : documentOrUri instanceof URI ? documentOrUri : URI.parse(documentOrUri.uri);
|
|
if (uri.scheme !== "file") {
|
|
return void 0;
|
|
}
|
|
return getFileSystemPath(uri);
|
|
}
|
|
var exitCalled = new import_node.NotificationType("eslint/exitCalled");
|
|
var nodeExit = process.exit;
|
|
process.exit = (code) => {
|
|
const stack = new Error("stack");
|
|
connection.sendNotification(exitCalled, [code ? code : 0, stack.stack]);
|
|
setTimeout(() => {
|
|
nodeExit(code);
|
|
}, 1e3);
|
|
};
|
|
process.on("uncaughtException", (error) => {
|
|
let message;
|
|
if (error) {
|
|
if (typeof error.stack === "string") {
|
|
message = error.stack;
|
|
} else if (typeof error.message === "string") {
|
|
message = error.message;
|
|
} else if (typeof error === "string") {
|
|
message = error;
|
|
}
|
|
if (message === void 0 || message.length === 0) {
|
|
try {
|
|
message = JSON.stringify(error, void 0, 4);
|
|
} catch (e) {
|
|
}
|
|
}
|
|
}
|
|
console.error("Uncaught exception received.");
|
|
if (message) {
|
|
console.error(message);
|
|
}
|
|
});
|
|
var connection = import_node.createConnection();
|
|
connection.console.info(`ESLint server running in node ${process.version}`);
|
|
var documents;
|
|
var _globalPaths = {
|
|
yarn: {
|
|
cache: void 0,
|
|
get() {
|
|
return import_node.Files.resolveGlobalYarnPath(trace);
|
|
}
|
|
},
|
|
npm: {
|
|
cache: void 0,
|
|
get() {
|
|
return import_node.Files.resolveGlobalNodePath(trace);
|
|
}
|
|
},
|
|
pnpm: {
|
|
cache: void 0,
|
|
get() {
|
|
const pnpmPath = import_child_process.execSync("pnpm root -g").toString().trim();
|
|
return pnpmPath;
|
|
}
|
|
}
|
|
};
|
|
function globalPathGet(packageManager) {
|
|
const pm = _globalPaths[packageManager];
|
|
if (pm) {
|
|
if (pm.cache === void 0) {
|
|
pm.cache = pm.get();
|
|
}
|
|
return pm.cache;
|
|
}
|
|
return void 0;
|
|
}
|
|
var languageId2DefaultExt = new Map([
|
|
["javascript", "js"],
|
|
["javascriptreact", "jsx"],
|
|
["typescript", "ts"],
|
|
["typescriptreact", "tsx"],
|
|
["html", "html"],
|
|
["vue", "vue"]
|
|
]);
|
|
var languageId2ParserRegExp = function createLanguageId2ParserRegExp() {
|
|
const result = new Map();
|
|
const typescript = /\/@typescript-eslint\/parser\//;
|
|
const babelESLint = /\/babel-eslint\/lib\/index.js$/;
|
|
result.set("typescript", [typescript, babelESLint]);
|
|
result.set("typescriptreact", [typescript, babelESLint]);
|
|
return result;
|
|
}();
|
|
var languageId2ParserOptions = function createLanguageId2ParserOptionsRegExp() {
|
|
const result = new Map();
|
|
const vue = /vue-eslint-parser\/.*\.js$/;
|
|
const typescriptEslintParser = /@typescript-eslint\/parser\/.*\.js$/;
|
|
result.set("typescript", {regExps: [vue], parsers: new Set(["@typescript-eslint/parser"]), parserRegExps: [typescriptEslintParser]});
|
|
return result;
|
|
}();
|
|
var languageId2PluginName = new Map([
|
|
["html", "html"],
|
|
["vue", "vue"],
|
|
["markdown", "markdown"]
|
|
]);
|
|
var defaultLanguageIds = new Set([
|
|
"javascript",
|
|
"javascriptreact"
|
|
]);
|
|
var path2Library = new Map();
|
|
var document2Settings = new Map();
|
|
var executionConfirmations = new Map();
|
|
var projectFolderIndicators = [
|
|
["package.json", true],
|
|
[".eslintignore", true],
|
|
[".eslintrc", false],
|
|
[".eslintrc.json", false],
|
|
[".eslintrc.js", false],
|
|
[".eslintrc.yaml", false],
|
|
[".eslintrc.yml", false]
|
|
];
|
|
function findWorkingDirectory(workspaceFolder, file) {
|
|
if (file === void 0 || isUNC(file)) {
|
|
return workspaceFolder;
|
|
}
|
|
if (file.indexOf(`${path.sep}node_modules${path.sep}`) !== -1) {
|
|
return workspaceFolder;
|
|
}
|
|
let result = workspaceFolder;
|
|
let directory = path.dirname(file);
|
|
outer:
|
|
while (directory !== void 0 && directory.startsWith(workspaceFolder)) {
|
|
for (const item of projectFolderIndicators) {
|
|
if (fs.existsSync(path.join(directory, item[0]))) {
|
|
result = directory;
|
|
if (item[1]) {
|
|
break outer;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
const parent = path.dirname(directory);
|
|
directory = parent !== directory ? parent : void 0;
|
|
}
|
|
return result;
|
|
}
|
|
function resolveSettings(document) {
|
|
const uri = document.uri;
|
|
let resultPromise = document2Settings.get(uri);
|
|
if (resultPromise) {
|
|
return resultPromise;
|
|
}
|
|
resultPromise = connection.workspace.getConfiguration({scopeUri: uri, section: ""}).then((configuration) => {
|
|
var _a2;
|
|
const settings = Object.assign({}, configuration, {silent: false, library: void 0, resolvedGlobalPackageManagerPath: void 0}, {workingDirectory: void 0});
|
|
if (settings.validate === Validate.off) {
|
|
return settings;
|
|
}
|
|
settings.resolvedGlobalPackageManagerPath = globalPathGet(settings.packageManager);
|
|
const filePath = getFilePath(document);
|
|
const workspaceFolderPath = settings.workspaceFolder !== void 0 ? getFilePath(settings.workspaceFolder.uri) : void 0;
|
|
const hasUserDefinedWorkingDirectories = configuration.workingDirectory !== void 0;
|
|
const workingDirectoryConfig = (_a2 = configuration.workingDirectory) != null ? _a2 : {mode: ModeEnum.location};
|
|
if (ModeItem.is(workingDirectoryConfig)) {
|
|
let candidate;
|
|
if (workingDirectoryConfig.mode === ModeEnum.location) {
|
|
if (workspaceFolderPath !== void 0) {
|
|
candidate = workspaceFolderPath;
|
|
} else if (filePath !== void 0 && !isUNC(filePath)) {
|
|
candidate = path.dirname(filePath);
|
|
}
|
|
} else if (workingDirectoryConfig.mode === ModeEnum.auto) {
|
|
if (workspaceFolderPath !== void 0) {
|
|
candidate = findWorkingDirectory(workspaceFolderPath, filePath);
|
|
} else if (filePath !== void 0 && !isUNC(filePath)) {
|
|
candidate = path.dirname(filePath);
|
|
}
|
|
}
|
|
if (candidate !== void 0 && fs.existsSync(candidate)) {
|
|
settings.workingDirectory = {directory: candidate};
|
|
}
|
|
} else {
|
|
settings.workingDirectory = workingDirectoryConfig;
|
|
}
|
|
let promise;
|
|
let nodePath;
|
|
if (settings.nodePath !== null) {
|
|
nodePath = settings.nodePath;
|
|
if (!path.isAbsolute(nodePath) && settings.workspaceFolder !== void 0) {
|
|
const workspaceFolderPath2 = getFilePath(settings.workspaceFolder.uri);
|
|
if (workspaceFolderPath2 !== void 0) {
|
|
nodePath = path.join(workspaceFolderPath2, nodePath);
|
|
}
|
|
}
|
|
}
|
|
let moduleResolveWorkingDirectory;
|
|
if (!hasUserDefinedWorkingDirectories && filePath !== void 0) {
|
|
moduleResolveWorkingDirectory = path.dirname(filePath);
|
|
}
|
|
if (moduleResolveWorkingDirectory === void 0 && settings.workingDirectory !== void 0 && !settings.workingDirectory["!cwd"]) {
|
|
moduleResolveWorkingDirectory = settings.workingDirectory.directory;
|
|
}
|
|
if (nodePath !== void 0) {
|
|
promise = import_node.Files.resolve("eslint", nodePath, nodePath, trace).then(void 0, () => {
|
|
return import_node.Files.resolve("eslint", settings.resolvedGlobalPackageManagerPath, moduleResolveWorkingDirectory, trace);
|
|
});
|
|
} else {
|
|
promise = import_node.Files.resolve("eslint", settings.resolvedGlobalPackageManagerPath, moduleResolveWorkingDirectory, trace);
|
|
}
|
|
settings.silent = settings.validate === Validate.probe;
|
|
return promise.then((libraryPath) => {
|
|
const scope = settings.resolvedGlobalPackageManagerPath !== void 0 && libraryPath.startsWith(settings.resolvedGlobalPackageManagerPath) ? "global" : "local";
|
|
const cachedExecutionConfirmation = executionConfirmations.get(libraryPath);
|
|
const confirmationPromise = cachedExecutionConfirmation === void 0 ? connection.sendRequest(ConfirmExecution.type, {scope, uri, libraryPath}) : Promise.resolve(cachedExecutionConfirmation);
|
|
return confirmationPromise.then((confirmed) => {
|
|
var _a3;
|
|
if (confirmed !== 4) {
|
|
settings.validate = Validate.off;
|
|
connection.sendDiagnostics({uri, diagnostics: []});
|
|
connection.sendNotification(StatusNotification.type, {uri, state: ConfirmExecutionResult.toStatus(confirmed)});
|
|
return settings;
|
|
} else {
|
|
executionConfirmations.set(libraryPath, confirmed);
|
|
}
|
|
let library = path2Library.get(libraryPath);
|
|
if (library === void 0) {
|
|
library = loadNodeModule(libraryPath);
|
|
if (library === void 0) {
|
|
settings.validate = Validate.off;
|
|
if (!settings.silent) {
|
|
connection.console.error(`Failed to load eslint library from ${libraryPath}. See output panel for more information.`);
|
|
}
|
|
} else if (library.CLIEngine === void 0) {
|
|
settings.validate = Validate.off;
|
|
connection.console.error(`The eslint library loaded from ${libraryPath} doesn't export a CLIEngine. You need at least eslint@1.0.0`);
|
|
} else {
|
|
connection.console.info(`ESLint library loaded from: ${libraryPath}`);
|
|
settings.library = library;
|
|
path2Library.set(libraryPath, library);
|
|
}
|
|
} else {
|
|
settings.library = library;
|
|
}
|
|
if (settings.validate === Validate.probe && TextDocumentSettings.hasLibrary(settings)) {
|
|
settings.validate = Validate.off;
|
|
const uri2 = URI.parse(document.uri);
|
|
let filePath2 = getFilePath(document);
|
|
if (filePath2 === void 0 && uri2.scheme === "untitled" && settings.workspaceFolder !== void 0) {
|
|
const ext = languageId2DefaultExt.get(document.languageId);
|
|
const workspacePath = getFilePath(settings.workspaceFolder.uri);
|
|
if (workspacePath !== void 0 && ext !== void 0) {
|
|
filePath2 = path.join(workspacePath, `test${ext}`);
|
|
}
|
|
}
|
|
if (filePath2 !== void 0) {
|
|
const parserRegExps = languageId2ParserRegExp.get(document.languageId);
|
|
const pluginName = languageId2PluginName.get(document.languageId);
|
|
const parserOptions = languageId2ParserOptions.get(document.languageId);
|
|
if (defaultLanguageIds.has(document.languageId)) {
|
|
settings.validate = Validate.on;
|
|
} else if (parserRegExps !== void 0 || pluginName !== void 0 || parserOptions !== void 0) {
|
|
const eslintConfig = withCLIEngine((cli) => {
|
|
try {
|
|
if (typeof cli.getConfigForFile === "function") {
|
|
return cli.getConfigForFile(filePath2);
|
|
} else {
|
|
return void 0;
|
|
}
|
|
} catch (err) {
|
|
return void 0;
|
|
}
|
|
}, settings);
|
|
if (eslintConfig !== void 0) {
|
|
const parser = eslintConfig.parser !== null ? process.platform === "win32" ? eslintConfig.parser.replace(/\\/g, "/") : eslintConfig.parser : void 0;
|
|
if (parser !== void 0) {
|
|
if (parserRegExps !== void 0) {
|
|
for (const regExp of parserRegExps) {
|
|
if (regExp.test(parser)) {
|
|
settings.validate = Validate.on;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (settings.validate !== Validate.on && parserOptions !== void 0 && typeof ((_a3 = eslintConfig.parserOptions) == null ? void 0 : _a3.parser) === "string") {
|
|
for (const regExp of parserOptions.regExps) {
|
|
if (regExp.test(parser) && (parserOptions.parsers.has(eslintConfig.parserOptions.parser) || parserOptions.parserRegExps !== void 0 && parserOptions.parserRegExps.some((parserRegExp) => parserRegExp.test(eslintConfig.parserOptions.parser)))) {
|
|
settings.validate = Validate.on;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (settings.validate !== Validate.on && Array.isArray(eslintConfig.plugins) && eslintConfig.plugins.length > 0 && pluginName !== void 0) {
|
|
for (const name of eslintConfig.plugins) {
|
|
if (name === pluginName) {
|
|
settings.validate = Validate.on;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (settings.validate === Validate.off) {
|
|
const params = {textDocument: {uri: document.uri}};
|
|
connection.sendRequest(ProbeFailedRequest.type, params);
|
|
}
|
|
}
|
|
if (settings.format && settings.validate === Validate.on && TextDocumentSettings.hasLibrary(settings)) {
|
|
const Uri = URI.parse(uri);
|
|
const isFile = Uri.scheme === "file";
|
|
let pattern = isFile ? Uri.fsPath.replace(/\\/g, "/") : Uri.fsPath;
|
|
pattern = pattern.replace(/[\[\]\{\}]/g, "?");
|
|
const filter = {scheme: Uri.scheme, pattern};
|
|
const options = {documentSelector: [filter]};
|
|
if (!isFile) {
|
|
formatterRegistrations.set(uri, connection.client.register(import_node.DocumentFormattingRequest.type, options));
|
|
} else {
|
|
const filePath2 = getFilePath(uri);
|
|
withCLIEngine((cli) => {
|
|
if (!cli.isPathIgnored(filePath2)) {
|
|
formatterRegistrations.set(uri, connection.client.register(import_node.DocumentFormattingRequest.type, options));
|
|
}
|
|
}, settings);
|
|
}
|
|
}
|
|
return settings;
|
|
});
|
|
}, () => {
|
|
settings.validate = Validate.off;
|
|
if (!settings.silent) {
|
|
connection.sendRequest(NoESLintLibraryRequest.type, {source: {uri: document.uri}});
|
|
}
|
|
return settings;
|
|
});
|
|
});
|
|
document2Settings.set(uri, resultPromise);
|
|
return resultPromise;
|
|
}
|
|
var Request;
|
|
(function(Request2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && candidate.token !== void 0 && candidate.resolve !== void 0 && candidate.reject !== void 0;
|
|
}
|
|
Request2.is = is;
|
|
})(Request || (Request = {}));
|
|
var Thenable;
|
|
(function(Thenable2) {
|
|
function is(value) {
|
|
const candidate = value;
|
|
return candidate && typeof candidate.then === "function";
|
|
}
|
|
Thenable2.is = is;
|
|
})(Thenable || (Thenable = {}));
|
|
var BufferedMessageQueue = class {
|
|
constructor(connection2) {
|
|
this.connection = connection2;
|
|
this.queue = [];
|
|
this.requestHandlers = new Map();
|
|
this.notificationHandlers = new Map();
|
|
}
|
|
registerRequest(type, handler, versionProvider) {
|
|
this.connection.onRequest(type, (params, token) => {
|
|
return new Promise((resolve, reject) => {
|
|
this.queue.push({
|
|
method: type.method,
|
|
params,
|
|
documentVersion: versionProvider ? versionProvider(params) : void 0,
|
|
resolve,
|
|
reject,
|
|
token
|
|
});
|
|
this.trigger();
|
|
});
|
|
});
|
|
this.requestHandlers.set(type.method, {handler, versionProvider});
|
|
}
|
|
registerNotification(type, handler, versionProvider) {
|
|
connection.onNotification(type, (params) => {
|
|
this.queue.push({
|
|
method: type.method,
|
|
params,
|
|
documentVersion: versionProvider ? versionProvider(params) : void 0
|
|
});
|
|
this.trigger();
|
|
});
|
|
this.notificationHandlers.set(type.method, {handler, versionProvider});
|
|
}
|
|
addNotificationMessage(type, params, version) {
|
|
this.queue.push({
|
|
method: type.method,
|
|
params,
|
|
documentVersion: version
|
|
});
|
|
this.trigger();
|
|
}
|
|
onNotification(type, handler, versionProvider) {
|
|
this.notificationHandlers.set(type.method, {handler, versionProvider});
|
|
}
|
|
trigger() {
|
|
if (this.timer || this.queue.length === 0) {
|
|
return;
|
|
}
|
|
this.timer = setImmediate(() => {
|
|
this.timer = void 0;
|
|
this.processQueue();
|
|
this.trigger();
|
|
});
|
|
}
|
|
processQueue() {
|
|
const message = this.queue.shift();
|
|
if (!message) {
|
|
return;
|
|
}
|
|
if (Request.is(message)) {
|
|
const requestMessage = message;
|
|
if (requestMessage.token.isCancellationRequested) {
|
|
requestMessage.reject(new import_node.ResponseError(import_node.LSPErrorCodes.RequestCancelled, "Request got cancelled"));
|
|
return;
|
|
}
|
|
const elem = this.requestHandlers.get(requestMessage.method);
|
|
if (elem === void 0) {
|
|
throw new Error(`No handler registered`);
|
|
}
|
|
if (elem.versionProvider && requestMessage.documentVersion !== void 0 && requestMessage.documentVersion !== elem.versionProvider(requestMessage.params)) {
|
|
requestMessage.reject(new import_node.ResponseError(import_node.LSPErrorCodes.RequestCancelled, "Request got cancelled"));
|
|
return;
|
|
}
|
|
const result = elem.handler(requestMessage.params, requestMessage.token);
|
|
if (Thenable.is(result)) {
|
|
result.then((value) => {
|
|
requestMessage.resolve(value);
|
|
}, (error) => {
|
|
requestMessage.reject(error);
|
|
});
|
|
} else {
|
|
requestMessage.resolve(result);
|
|
}
|
|
} else {
|
|
const notificationMessage = message;
|
|
const elem = this.notificationHandlers.get(notificationMessage.method);
|
|
if (elem === void 0) {
|
|
throw new Error(`No handler registered`);
|
|
}
|
|
if (elem.versionProvider && notificationMessage.documentVersion !== void 0 && notificationMessage.documentVersion !== elem.versionProvider(notificationMessage.params)) {
|
|
return;
|
|
}
|
|
elem.handler(notificationMessage.params);
|
|
}
|
|
}
|
|
};
|
|
var messageQueue = new BufferedMessageQueue(connection);
|
|
var formatterRegistrations = new Map();
|
|
var ValidateNotification;
|
|
(function(ValidateNotification2) {
|
|
ValidateNotification2.type = new import_node.NotificationType("eslint/validate");
|
|
})(ValidateNotification || (ValidateNotification = {}));
|
|
messageQueue.onNotification(ValidateNotification.type, (document) => {
|
|
validateSingle(document, true);
|
|
}, (document) => {
|
|
return document.version;
|
|
});
|
|
function setupDocumentsListeners() {
|
|
documents.listen(connection);
|
|
documents.onDidOpen((event) => {
|
|
resolveSettings(event.document).then((settings) => {
|
|
if (settings.validate !== Validate.on || !TextDocumentSettings.hasLibrary(settings)) {
|
|
return;
|
|
}
|
|
if (settings.run === "onSave") {
|
|
messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
|
|
}
|
|
});
|
|
});
|
|
documents.onDidChangeContent((event) => {
|
|
const uri = event.document.uri;
|
|
codeActions.delete(uri);
|
|
resolveSettings(event.document).then((settings) => {
|
|
if (settings.validate !== Validate.on || settings.run !== "onType") {
|
|
return;
|
|
}
|
|
messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
|
|
});
|
|
});
|
|
documents.onDidSave((event) => {
|
|
resolveSettings(event.document).then((settings) => {
|
|
if (settings.validate !== Validate.on || settings.run !== "onSave") {
|
|
return;
|
|
}
|
|
messageQueue.addNotificationMessage(ValidateNotification.type, event.document, event.document.version);
|
|
});
|
|
});
|
|
documents.onDidClose((event) => {
|
|
resolveSettings(event.document).then((settings) => {
|
|
const uri = event.document.uri;
|
|
document2Settings.delete(uri);
|
|
codeActions.delete(uri);
|
|
const unregister = formatterRegistrations.get(event.document.uri);
|
|
if (unregister !== void 0) {
|
|
unregister.then((disposable) => disposable.dispose());
|
|
formatterRegistrations.delete(event.document.uri);
|
|
}
|
|
if (settings.validate === Validate.on) {
|
|
connection.sendDiagnostics({uri, diagnostics: []});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
function environmentChanged() {
|
|
document2Settings.clear();
|
|
executionConfirmations.clear();
|
|
for (let document of documents.all()) {
|
|
messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
|
|
}
|
|
for (const unregistration of formatterRegistrations.values()) {
|
|
unregistration.then((disposable) => disposable.dispose());
|
|
}
|
|
formatterRegistrations.clear();
|
|
}
|
|
function trace(message, verbose) {
|
|
connection.tracer.log(message, verbose);
|
|
}
|
|
connection.onInitialize((_params, _cancel, progress) => {
|
|
progress.begin("Initializing ESLint Server");
|
|
const syncKind = import_node.TextDocumentSyncKind.Incremental;
|
|
documents = new import_node.TextDocuments(TextDocument);
|
|
setupDocumentsListeners();
|
|
progress.done();
|
|
return {
|
|
capabilities: {
|
|
textDocumentSync: {
|
|
openClose: true,
|
|
change: syncKind,
|
|
willSaveWaitUntil: false,
|
|
save: {
|
|
includeText: false
|
|
}
|
|
},
|
|
workspace: {
|
|
workspaceFolders: {
|
|
supported: true
|
|
}
|
|
},
|
|
codeActionProvider: {codeActionKinds: [import_node.CodeActionKind.QuickFix, `${import_node.CodeActionKind.SourceFixAll}.eslint`]},
|
|
executeCommandProvider: {
|
|
commands: [
|
|
CommandIds.applySingleFix,
|
|
CommandIds.applySuggestion,
|
|
CommandIds.applySameFixes,
|
|
CommandIds.applyAllFixes,
|
|
CommandIds.applyDisableLine,
|
|
CommandIds.applyDisableFile,
|
|
CommandIds.openRuleDoc
|
|
]
|
|
}
|
|
}
|
|
};
|
|
});
|
|
connection.onInitialized(() => {
|
|
connection.client.register(import_node.DidChangeConfigurationNotification.type, void 0);
|
|
connection.client.register(import_node.DidChangeWorkspaceFoldersNotification.type, void 0);
|
|
});
|
|
messageQueue.registerNotification(import_node.DidChangeConfigurationNotification.type, (_params) => {
|
|
environmentChanged();
|
|
});
|
|
messageQueue.registerNotification(import_node.DidChangeWorkspaceFoldersNotification.type, (_params) => {
|
|
environmentChanged();
|
|
});
|
|
var singleErrorHandlers = [
|
|
tryHandleNoConfig,
|
|
tryHandleConfigError,
|
|
tryHandleMissingModule,
|
|
showErrorMessage
|
|
];
|
|
function validateSingle(document, publishDiagnostics = true) {
|
|
if (!documents.get(document.uri)) {
|
|
return Promise.resolve(void 0);
|
|
}
|
|
return resolveSettings(document).then((settings) => {
|
|
if (settings.validate !== Validate.on || !TextDocumentSettings.hasLibrary(settings)) {
|
|
return;
|
|
}
|
|
try {
|
|
validate(document, settings, publishDiagnostics);
|
|
connection.sendNotification(StatusNotification.type, {uri: document.uri, state: 1});
|
|
} catch (err) {
|
|
connection.sendDiagnostics({uri: document.uri, diagnostics: []});
|
|
if (!settings.silent) {
|
|
let status = void 0;
|
|
for (let handler of singleErrorHandlers) {
|
|
status = handler(err, document, settings.library);
|
|
if (status) {
|
|
break;
|
|
}
|
|
}
|
|
status = status || 3;
|
|
connection.sendNotification(StatusNotification.type, {uri: document.uri, state: status});
|
|
} else {
|
|
connection.console.info(getMessage(err, document));
|
|
connection.sendNotification(StatusNotification.type, {uri: document.uri, state: 1});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function validateMany(documents2) {
|
|
documents2.forEach((document) => {
|
|
messageQueue.addNotificationMessage(ValidateNotification.type, document, document.version);
|
|
});
|
|
}
|
|
function getMessage(err, document) {
|
|
let result = void 0;
|
|
if (typeof err.message === "string" || err.message instanceof String) {
|
|
result = err.message;
|
|
result = result.replace(/\r?\n/g, " ");
|
|
if (/^CLI: /.test(result)) {
|
|
result = result.substr(5);
|
|
}
|
|
} else {
|
|
result = `An unknown error occurred while validating document: ${document.uri}`;
|
|
}
|
|
return result;
|
|
}
|
|
var ruleDocData = {
|
|
handled: new Set(),
|
|
urls: new Map()
|
|
};
|
|
var validFixTypes = new Set(["problem", "suggestion", "layout"]);
|
|
function validate(document, settings, publishDiagnostics = true) {
|
|
const newOptions = Object.assign(Object.create(null), settings.options);
|
|
let fixTypes = void 0;
|
|
if (Array.isArray(newOptions.fixTypes) && newOptions.fixTypes.length > 0) {
|
|
fixTypes = new Set();
|
|
for (let item of newOptions.fixTypes) {
|
|
if (validFixTypes.has(item)) {
|
|
fixTypes.add(item);
|
|
}
|
|
}
|
|
if (fixTypes.size === 0) {
|
|
fixTypes = void 0;
|
|
}
|
|
}
|
|
const content = document.getText();
|
|
const uri = document.uri;
|
|
const file = getFilePath(document);
|
|
withCLIEngine((cli) => {
|
|
codeActions.delete(uri);
|
|
const report = cli.executeOnText(content, file, settings.onIgnoredFiles !== ESLintSeverity.off);
|
|
if (CLIEngine.hasRule(cli) && !ruleDocData.handled.has(uri)) {
|
|
ruleDocData.handled.add(uri);
|
|
cli.getRules().forEach((rule, key) => {
|
|
if (rule.meta && rule.meta.docs && Is.string(rule.meta.docs.url)) {
|
|
ruleDocData.urls.set(key, rule.meta.docs.url);
|
|
}
|
|
});
|
|
}
|
|
const diagnostics = [];
|
|
if (report && report.results && Array.isArray(report.results) && report.results.length > 0) {
|
|
const docReport = report.results[0];
|
|
if (docReport.messages && Array.isArray(docReport.messages)) {
|
|
docReport.messages.forEach((problem) => {
|
|
if (problem) {
|
|
const isWarning = convertSeverity(problem.severity) === import_node.DiagnosticSeverity.Warning;
|
|
if (settings.quiet && isWarning) {
|
|
return;
|
|
}
|
|
const diagnostic = makeDiagnostic(problem);
|
|
diagnostics.push(diagnostic);
|
|
if (fixTypes !== void 0 && CLIEngine.hasRule(cli) && problem.ruleId !== void 0 && problem.fix !== void 0) {
|
|
const rule = cli.getRules().get(problem.ruleId);
|
|
if (RuleData.hasMetaType(rule) && fixTypes.has(rule.meta.type)) {
|
|
recordCodeAction(document, diagnostic, problem);
|
|
}
|
|
} else {
|
|
recordCodeAction(document, diagnostic, problem);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
if (publishDiagnostics) {
|
|
connection.sendDiagnostics({uri, diagnostics});
|
|
}
|
|
}, settings);
|
|
}
|
|
function withCLIEngine(func, settings, options) {
|
|
const newOptions = options === void 0 ? Object.assign(Object.create(null), settings.options) : Object.assign(Object.create(null), settings.options, options);
|
|
const cwd = process.cwd();
|
|
try {
|
|
if (settings.workingDirectory) {
|
|
newOptions.cwd = settings.workingDirectory.directory;
|
|
if (settings.workingDirectory["!cwd"] !== true && fs.existsSync(settings.workingDirectory.directory)) {
|
|
process.chdir(settings.workingDirectory.directory);
|
|
}
|
|
}
|
|
const cli = new settings.library.CLIEngine(newOptions);
|
|
return func(cli);
|
|
} finally {
|
|
if (cwd !== process.cwd()) {
|
|
process.chdir(cwd);
|
|
}
|
|
}
|
|
}
|
|
var noConfigReported = new Map();
|
|
function isNoConfigFoundError(error) {
|
|
const candidate = error;
|
|
return candidate.messageTemplate === "no-config-found" || candidate.message === "No ESLint configuration found.";
|
|
}
|
|
function tryHandleNoConfig(error, document, library) {
|
|
if (!isNoConfigFoundError(error)) {
|
|
return void 0;
|
|
}
|
|
if (!noConfigReported.has(document.uri)) {
|
|
connection.sendRequest(NoConfigRequest.type, {
|
|
message: getMessage(error, document),
|
|
document: {
|
|
uri: document.uri
|
|
}
|
|
}).then(void 0, () => {
|
|
});
|
|
noConfigReported.set(document.uri, library);
|
|
}
|
|
return 2;
|
|
}
|
|
var configErrorReported = new Map();
|
|
function tryHandleConfigError(error, document, library) {
|
|
if (!error.message) {
|
|
return void 0;
|
|
}
|
|
function handleFileName(filename) {
|
|
if (!configErrorReported.has(filename)) {
|
|
connection.console.error(getMessage(error, document));
|
|
if (!documents.get(URI.file(filename).toString())) {
|
|
connection.window.showInformationMessage(getMessage(error, document));
|
|
}
|
|
configErrorReported.set(filename, library);
|
|
}
|
|
return 2;
|
|
}
|
|
let matches = /Cannot read config file:\s+(.*)\nError:\s+(.*)/.exec(error.message);
|
|
if (matches && matches.length === 3) {
|
|
return handleFileName(matches[1]);
|
|
}
|
|
matches = /(.*):\n\s*Configuration for rule \"(.*)\" is /.exec(error.message);
|
|
if (matches && matches.length === 3) {
|
|
return handleFileName(matches[1]);
|
|
}
|
|
matches = /Cannot find module '([^']*)'\nReferenced from:\s+(.*)/.exec(error.message);
|
|
if (matches && matches.length === 3) {
|
|
return handleFileName(matches[2]);
|
|
}
|
|
return void 0;
|
|
}
|
|
var missingModuleReported = new Map();
|
|
function tryHandleMissingModule(error, document, library) {
|
|
if (!error.message) {
|
|
return void 0;
|
|
}
|
|
function handleMissingModule(plugin, module3, error2) {
|
|
if (!missingModuleReported.has(plugin)) {
|
|
const fsPath = getFilePath(document);
|
|
missingModuleReported.set(plugin, library);
|
|
if (error2.messageTemplate === "plugin-missing") {
|
|
connection.console.error([
|
|
"",
|
|
`${error2.message.toString()}`,
|
|
`Happened while validating ${fsPath ? fsPath : document.uri}`,
|
|
`This can happen for a couple of reasons:`,
|
|
`1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).`,
|
|
`2. If ESLint is installed globally, then make sure ${module3} is installed globally as well.`,
|
|
`3. If ESLint is installed locally, then ${module3} isn't installed correctly.`,
|
|
"",
|
|
`Consider running eslint --debug ${fsPath ? fsPath : document.uri} from a terminal to obtain a trace about the configuration files used.`
|
|
].join("\n"));
|
|
} else {
|
|
connection.console.error([
|
|
`${error2.message.toString()}`,
|
|
`Happened while validating ${fsPath ? fsPath : document.uri}`
|
|
].join("\n"));
|
|
}
|
|
}
|
|
return 2;
|
|
}
|
|
const matches = /Failed to load plugin (.*): Cannot find module (.*)/.exec(error.message);
|
|
if (matches && matches.length === 3) {
|
|
return handleMissingModule(matches[1], matches[2], error);
|
|
}
|
|
return void 0;
|
|
}
|
|
function showErrorMessage(error, document) {
|
|
connection.window.showErrorMessage(`ESLint: ${getMessage(error, document)}. Please see the 'ESLint' output channel for details.`, {title: "Open Output", id: 1}).then((value) => {
|
|
if (value !== void 0 && value.id === 1) {
|
|
connection.sendNotification(ShowOutputChannel.type);
|
|
}
|
|
});
|
|
if (Is.string(error.stack)) {
|
|
connection.console.error("ESLint stack trace:");
|
|
connection.console.error(error.stack);
|
|
}
|
|
return 3;
|
|
}
|
|
messageQueue.registerNotification(import_node.DidChangeWatchedFilesNotification.type, (params) => {
|
|
ruleDocData.handled.clear();
|
|
ruleDocData.urls.clear();
|
|
noConfigReported.clear();
|
|
missingModuleReported.clear();
|
|
document2Settings.clear();
|
|
params.changes.forEach((change) => {
|
|
const fsPath = getFilePath(change.uri);
|
|
if (fsPath === void 0 || fsPath.length === 0 || isUNC(fsPath)) {
|
|
return;
|
|
}
|
|
const dirname2 = path.dirname(fsPath);
|
|
if (dirname2) {
|
|
const library = configErrorReported.get(fsPath);
|
|
if (library !== void 0) {
|
|
const cli = new library.CLIEngine({});
|
|
try {
|
|
cli.executeOnText("", path.join(dirname2, "___test___.js"));
|
|
configErrorReported.delete(fsPath);
|
|
} catch (error) {
|
|
}
|
|
}
|
|
}
|
|
});
|
|
validateMany(documents.all());
|
|
});
|
|
var Fixes = class {
|
|
constructor(edits) {
|
|
this.edits = edits;
|
|
}
|
|
static overlaps(a, b) {
|
|
return a !== void 0 && a.edit.range[1] > b.edit.range[0];
|
|
}
|
|
static isSame(a, b) {
|
|
return a.edit.range[0] === b.edit.range[0] && a.edit.range[1] === b.edit.range[1] && a.edit.text === b.edit.text;
|
|
}
|
|
isEmpty() {
|
|
return this.edits.size === 0;
|
|
}
|
|
getDocumentVersion() {
|
|
if (this.isEmpty()) {
|
|
throw new Error("No edits recorded.");
|
|
}
|
|
return this.edits.values().next().value.documentVersion;
|
|
}
|
|
getScoped(diagnostics) {
|
|
const result = [];
|
|
for (let diagnostic of diagnostics) {
|
|
const key = computeKey(diagnostic);
|
|
const editInfo = this.edits.get(key);
|
|
if (editInfo) {
|
|
result.push(editInfo);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
getAllSorted() {
|
|
const result = [];
|
|
this.edits.forEach((value) => {
|
|
if (Problem.isFixable(value)) {
|
|
result.push(value);
|
|
}
|
|
});
|
|
return result.sort((a, b) => {
|
|
const d = a.edit.range[0] - b.edit.range[0];
|
|
if (d !== 0) {
|
|
return d;
|
|
}
|
|
if (a.edit.range[1] === 0) {
|
|
return -1;
|
|
}
|
|
if (b.edit.range[1] === 0) {
|
|
return 1;
|
|
}
|
|
return a.edit.range[1] - b.edit.range[1];
|
|
});
|
|
}
|
|
getApplicable() {
|
|
const sorted = this.getAllSorted();
|
|
if (sorted.length <= 1) {
|
|
return sorted;
|
|
}
|
|
const result = [];
|
|
let last = sorted[0];
|
|
result.push(last);
|
|
for (let i = 1; i < sorted.length; i++) {
|
|
let current = sorted[i];
|
|
if (!Fixes.overlaps(last, current) && !Fixes.isSame(last, current)) {
|
|
result.push(current);
|
|
last = current;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
var CodeActionResult = class {
|
|
constructor() {
|
|
this._actions = new Map();
|
|
}
|
|
get(ruleId) {
|
|
let result = this._actions.get(ruleId);
|
|
if (result === void 0) {
|
|
result = {fixes: [], suggestions: []};
|
|
this._actions.set(ruleId, result);
|
|
}
|
|
return result;
|
|
}
|
|
get fixAll() {
|
|
if (this._fixAll === void 0) {
|
|
this._fixAll = [];
|
|
}
|
|
return this._fixAll;
|
|
}
|
|
all() {
|
|
const result = [];
|
|
for (let actions of this._actions.values()) {
|
|
result.push(...actions.fixes);
|
|
result.push(...actions.suggestions);
|
|
if (actions.disable) {
|
|
result.push(actions.disable);
|
|
}
|
|
if (actions.fixAll) {
|
|
result.push(actions.fixAll);
|
|
}
|
|
if (actions.disableFile) {
|
|
result.push(actions.disableFile);
|
|
}
|
|
if (actions.showDocumentation) {
|
|
result.push(actions.showDocumentation);
|
|
}
|
|
}
|
|
if (this._fixAll !== void 0) {
|
|
result.push(...this._fixAll);
|
|
}
|
|
return result;
|
|
}
|
|
get length() {
|
|
let result = 0;
|
|
for (let actions of this._actions.values()) {
|
|
result += actions.fixes.length;
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
var Changes = class {
|
|
constructor() {
|
|
this.values = new Map();
|
|
this.uri = void 0;
|
|
this.version = void 0;
|
|
}
|
|
clear(textDocument) {
|
|
if (textDocument === void 0) {
|
|
this.uri = void 0;
|
|
this.version = void 0;
|
|
} else {
|
|
this.uri = textDocument.uri;
|
|
this.version = textDocument.version;
|
|
}
|
|
this.values.clear();
|
|
}
|
|
isUsable(uri, version) {
|
|
return this.uri === uri && this.version === version;
|
|
}
|
|
set(key, change) {
|
|
this.values.set(key, change);
|
|
}
|
|
get(key) {
|
|
return this.values.get(key);
|
|
}
|
|
};
|
|
var CommandParams;
|
|
(function(CommandParams2) {
|
|
function create(textDocument, ruleId, sequence) {
|
|
return {uri: textDocument.uri, version: textDocument.version, ruleId, sequence};
|
|
}
|
|
CommandParams2.create = create;
|
|
function hasRuleId(value) {
|
|
return value.ruleId !== void 0;
|
|
}
|
|
CommandParams2.hasRuleId = hasRuleId;
|
|
})(CommandParams || (CommandParams = {}));
|
|
var changes = new Changes();
|
|
var ESLintSourceFixAll = `${import_node.CodeActionKind.SourceFixAll}.eslint`;
|
|
messageQueue.registerRequest(import_node.CodeActionRequest.type, (params) => {
|
|
const result = new CodeActionResult();
|
|
const uri = params.textDocument.uri;
|
|
const textDocument = documents.get(uri);
|
|
if (textDocument === void 0) {
|
|
changes.clear(textDocument);
|
|
return result.all();
|
|
}
|
|
function createCodeAction(title, kind, commandId, arg, diagnostic) {
|
|
const command = import_node.Command.create(title, commandId, arg);
|
|
const action = import_node.CodeAction.create(title, command, kind);
|
|
if (diagnostic !== void 0) {
|
|
action.diagnostics = [diagnostic];
|
|
}
|
|
return action;
|
|
}
|
|
function createDisableLineTextEdit(editInfo, indentationText) {
|
|
return import_node.TextEdit.insert(import_node.Position.create(editInfo.line - 1, 0), `${indentationText}// eslint-disable-next-line ${editInfo.ruleId}${import_os.EOL}`);
|
|
}
|
|
function createDisableSameLineTextEdit(editInfo) {
|
|
return import_node.TextEdit.insert(import_node.Position.create(editInfo.line - 1, 2147483647), ` // eslint-disable-line ${editInfo.ruleId}`);
|
|
}
|
|
function createDisableFileTextEdit(editInfo) {
|
|
const shebang = textDocument == null ? void 0 : textDocument.getText(import_node.Range.create(import_node.Position.create(0, 0), import_node.Position.create(0, 2)));
|
|
const line = shebang === "#!" ? 1 : 0;
|
|
return import_node.TextEdit.insert(import_node.Position.create(line, 0), `/* eslint-disable ${editInfo.ruleId} */${import_os.EOL}`);
|
|
}
|
|
function getLastEdit(array) {
|
|
const length = array.length;
|
|
if (length === 0) {
|
|
return void 0;
|
|
}
|
|
return array[length - 1];
|
|
}
|
|
return resolveSettings(textDocument).then(async (settings) => {
|
|
if (settings.validate !== Validate.on || !TextDocumentSettings.hasLibrary(settings)) {
|
|
return result.all();
|
|
}
|
|
const problems = codeActions.get(uri);
|
|
if (problems === void 0 && settings.run === "onType") {
|
|
return result.all();
|
|
}
|
|
const only = params.context.only !== void 0 && params.context.only.length > 0 ? params.context.only[0] : void 0;
|
|
const isSource = only === import_node.CodeActionKind.Source;
|
|
const isSourceFixAll = only === ESLintSourceFixAll || only === import_node.CodeActionKind.SourceFixAll;
|
|
if (isSourceFixAll || isSource) {
|
|
if (isSourceFixAll && settings.codeActionOnSave.enable) {
|
|
const textDocumentIdentifer = {uri: textDocument.uri, version: textDocument.version};
|
|
const edits = await computeAllFixes(textDocumentIdentifer, AllFixesMode.onSave);
|
|
if (edits !== void 0) {
|
|
result.fixAll.push(import_node.CodeAction.create(`Fix all ESLint auto-fixable problems`, {documentChanges: [import_node.TextDocumentEdit.create(textDocumentIdentifer, edits)]}, ESLintSourceFixAll));
|
|
}
|
|
} else if (isSource) {
|
|
result.fixAll.push(createCodeAction(`Fix all ESLint auto-fixable problems`, import_node.CodeActionKind.Source, CommandIds.applyAllFixes, CommandParams.create(textDocument)));
|
|
}
|
|
return result.all();
|
|
}
|
|
if (problems === void 0) {
|
|
return result.all();
|
|
}
|
|
const fixes = new Fixes(problems);
|
|
if (fixes.isEmpty()) {
|
|
return result.all();
|
|
}
|
|
let documentVersion = -1;
|
|
const allFixableRuleIds = [];
|
|
const kind = only != null ? only : import_node.CodeActionKind.QuickFix;
|
|
for (let editInfo of fixes.getScoped(params.context.diagnostics)) {
|
|
documentVersion = editInfo.documentVersion;
|
|
const ruleId = editInfo.ruleId;
|
|
allFixableRuleIds.push(ruleId);
|
|
if (Problem.isFixable(editInfo)) {
|
|
const workspaceChange = new import_node.WorkspaceChange();
|
|
workspaceChange.getTextEditChange({uri, version: documentVersion}).add(FixableProblem.createTextEdit(textDocument, editInfo));
|
|
changes.set(`${CommandIds.applySingleFix}:${ruleId}`, workspaceChange);
|
|
const action = createCodeAction(editInfo.label, kind, CommandIds.applySingleFix, CommandParams.create(textDocument, ruleId), editInfo.diagnostic);
|
|
action.isPreferred = true;
|
|
result.get(ruleId).fixes.push(action);
|
|
}
|
|
if (Problem.hasSuggestions(editInfo)) {
|
|
editInfo.suggestions.forEach((suggestion, suggestionSequence) => {
|
|
const workspaceChange = new import_node.WorkspaceChange();
|
|
workspaceChange.getTextEditChange({uri, version: documentVersion}).add(SuggestionsProblem.createTextEdit(textDocument, suggestion));
|
|
changes.set(`${CommandIds.applySuggestion}:${ruleId}:${suggestionSequence}`, workspaceChange);
|
|
const action = createCodeAction(`${suggestion.desc} (${editInfo.ruleId})`, import_node.CodeActionKind.QuickFix, CommandIds.applySuggestion, CommandParams.create(textDocument, ruleId, suggestionSequence), editInfo.diagnostic);
|
|
result.get(ruleId).suggestions.push(action);
|
|
});
|
|
}
|
|
if (settings.codeAction.disableRuleComment.enable) {
|
|
let workspaceChange = new import_node.WorkspaceChange();
|
|
if (settings.codeAction.disableRuleComment.location === "sameLine") {
|
|
workspaceChange.getTextEditChange({uri, version: documentVersion}).add(createDisableSameLineTextEdit(editInfo));
|
|
} else {
|
|
const lineText = textDocument.getText(import_node.Range.create(import_node.Position.create(editInfo.line - 1, 0), import_node.Position.create(editInfo.line - 1, 2147483647)));
|
|
const matches = /^([ \t]*)/.exec(lineText);
|
|
const indentationText = matches !== null && matches.length > 0 ? matches[1] : "";
|
|
workspaceChange.getTextEditChange({uri, version: documentVersion}).add(createDisableLineTextEdit(editInfo, indentationText));
|
|
}
|
|
changes.set(`${CommandIds.applyDisableLine}:${ruleId}`, workspaceChange);
|
|
result.get(ruleId).disable = createCodeAction(`Disable ${ruleId} for this line`, kind, CommandIds.applyDisableLine, CommandParams.create(textDocument, ruleId));
|
|
if (result.get(ruleId).disableFile === void 0) {
|
|
workspaceChange = new import_node.WorkspaceChange();
|
|
workspaceChange.getTextEditChange({uri, version: documentVersion}).add(createDisableFileTextEdit(editInfo));
|
|
changes.set(`${CommandIds.applyDisableFile}:${ruleId}`, workspaceChange);
|
|
result.get(ruleId).disableFile = createCodeAction(`Disable ${ruleId} for the entire file`, kind, CommandIds.applyDisableFile, CommandParams.create(textDocument, ruleId));
|
|
}
|
|
}
|
|
if (settings.codeAction.showDocumentation.enable && result.get(ruleId).showDocumentation === void 0) {
|
|
if (ruleDocData.urls.has(ruleId)) {
|
|
result.get(ruleId).showDocumentation = createCodeAction(`Show documentation for ${ruleId}`, kind, CommandIds.openRuleDoc, CommandParams.create(textDocument, ruleId));
|
|
}
|
|
}
|
|
}
|
|
if (result.length > 0) {
|
|
const sameProblems = new Map(allFixableRuleIds.map((s) => [s, []]));
|
|
for (let editInfo of fixes.getAllSorted()) {
|
|
if (documentVersion === -1) {
|
|
documentVersion = editInfo.documentVersion;
|
|
}
|
|
if (sameProblems.has(editInfo.ruleId)) {
|
|
const same = sameProblems.get(editInfo.ruleId);
|
|
if (!Fixes.overlaps(getLastEdit(same), editInfo)) {
|
|
same.push(editInfo);
|
|
}
|
|
}
|
|
}
|
|
sameProblems.forEach((same, ruleId) => {
|
|
if (same.length > 1) {
|
|
const sameFixes = new import_node.WorkspaceChange();
|
|
const sameTextChange = sameFixes.getTextEditChange({uri, version: documentVersion});
|
|
same.map((fix) => FixableProblem.createTextEdit(textDocument, fix)).forEach((edit) => sameTextChange.add(edit));
|
|
changes.set(CommandIds.applySameFixes, sameFixes);
|
|
result.get(ruleId).fixAll = createCodeAction(`Fix all ${ruleId} problems`, kind, CommandIds.applySameFixes, CommandParams.create(textDocument));
|
|
}
|
|
});
|
|
result.fixAll.push(createCodeAction(`Fix all auto-fixable problems`, kind, CommandIds.applyAllFixes, CommandParams.create(textDocument)));
|
|
}
|
|
return result.all();
|
|
});
|
|
}, (params) => {
|
|
const document = documents.get(params.textDocument.uri);
|
|
return document !== void 0 ? document.version : void 0;
|
|
});
|
|
var AllFixesMode;
|
|
(function(AllFixesMode2) {
|
|
AllFixesMode2["onSave"] = "onsave";
|
|
AllFixesMode2["format"] = "format";
|
|
AllFixesMode2["command"] = "command";
|
|
})(AllFixesMode || (AllFixesMode = {}));
|
|
function computeAllFixes(identifier, mode) {
|
|
const uri = identifier.uri;
|
|
const textDocument = documents.get(uri);
|
|
if (textDocument === void 0 || identifier.version !== textDocument.version) {
|
|
return void 0;
|
|
}
|
|
return resolveSettings(textDocument).then((settings) => {
|
|
if (settings.validate !== Validate.on || !TextDocumentSettings.hasLibrary(settings) || mode === AllFixesMode.format && !settings.format) {
|
|
return [];
|
|
}
|
|
const filePath = getFilePath(textDocument);
|
|
return withCLIEngine((cli) => {
|
|
const problems = codeActions.get(uri);
|
|
const originalContent = textDocument.getText();
|
|
let problemFixes;
|
|
const result = [];
|
|
let start = Date.now();
|
|
if (mode === AllFixesMode.onSave && problems !== void 0 && problems.size > 0) {
|
|
const fixes = new Fixes(problems).getApplicable();
|
|
if (fixes.length > 0) {
|
|
problemFixes = fixes.map((fix) => FixableProblem.createTextEdit(textDocument, fix));
|
|
}
|
|
}
|
|
if (mode === AllFixesMode.onSave && settings.codeActionOnSave.mode === CodeActionsOnSaveMode.problems) {
|
|
connection.tracer.log(`Computing all fixes took: ${Date.now() - start} ms.`);
|
|
if (problemFixes !== void 0) {
|
|
result.push(...problemFixes);
|
|
}
|
|
} else {
|
|
let content;
|
|
if (problemFixes !== void 0) {
|
|
content = TextDocument.applyEdits(textDocument, problemFixes);
|
|
} else {
|
|
content = originalContent;
|
|
}
|
|
const report = cli.executeOnText(content, filePath);
|
|
connection.tracer.log(`Computing all fixes took: ${Date.now() - start} ms.`);
|
|
if (Array.isArray(report.results) && report.results.length === 1 && report.results[0].output !== void 0) {
|
|
const fixedContent = report.results[0].output;
|
|
start = Date.now();
|
|
const diffs = stringDiff(originalContent, fixedContent, false);
|
|
connection.tracer.log(`Computing minimal edits took: ${Date.now() - start} ms.`);
|
|
for (let diff of diffs) {
|
|
result.push({
|
|
range: {
|
|
start: textDocument.positionAt(diff.originalStart),
|
|
end: textDocument.positionAt(diff.originalStart + diff.originalLength)
|
|
},
|
|
newText: fixedContent.substr(diff.modifiedStart, diff.modifiedLength)
|
|
});
|
|
}
|
|
} else if (problemFixes !== void 0) {
|
|
result.push(...problemFixes);
|
|
}
|
|
}
|
|
return result;
|
|
}, settings, {fix: true});
|
|
});
|
|
}
|
|
messageQueue.registerRequest(import_node.ExecuteCommandRequest.type, async (params) => {
|
|
let workspaceChange;
|
|
const commandParams = params.arguments[0];
|
|
if (params.command === CommandIds.applyAllFixes) {
|
|
const edits = await computeAllFixes(commandParams, AllFixesMode.command);
|
|
if (edits !== void 0) {
|
|
workspaceChange = new import_node.WorkspaceChange();
|
|
const textChange = workspaceChange.getTextEditChange(commandParams);
|
|
edits.forEach((edit) => textChange.add(edit));
|
|
}
|
|
} else {
|
|
if ([CommandIds.applySingleFix, CommandIds.applyDisableLine, CommandIds.applyDisableFile].indexOf(params.command) !== -1) {
|
|
workspaceChange = changes.get(`${params.command}:${commandParams.ruleId}`);
|
|
} else if ([CommandIds.applySuggestion].indexOf(params.command) !== -1) {
|
|
workspaceChange = changes.get(`${params.command}:${commandParams.ruleId}:${commandParams.sequence}`);
|
|
} else if (params.command === CommandIds.openRuleDoc && CommandParams.hasRuleId(commandParams)) {
|
|
const url = ruleDocData.urls.get(commandParams.ruleId);
|
|
if (url) {
|
|
connection.sendRequest(OpenESLintDocRequest.type, {url});
|
|
}
|
|
} else {
|
|
workspaceChange = changes.get(params.command);
|
|
}
|
|
}
|
|
if (workspaceChange === void 0) {
|
|
return {};
|
|
}
|
|
return connection.workspace.applyEdit(workspaceChange.edit).then((response) => {
|
|
if (!response.applied) {
|
|
connection.console.error(`Failed to apply command: ${params.command}`);
|
|
}
|
|
return {};
|
|
}, () => {
|
|
connection.console.error(`Failed to apply command: ${params.command}`);
|
|
});
|
|
}, (params) => {
|
|
const commandParam = params.arguments[0];
|
|
if (changes.isUsable(commandParam.uri, commandParam.version)) {
|
|
return commandParam.version;
|
|
} else {
|
|
return void 0;
|
|
}
|
|
});
|
|
messageQueue.registerRequest(import_node.DocumentFormattingRequest.type, (params) => {
|
|
const textDocument = documents.get(params.textDocument.uri);
|
|
if (textDocument === void 0) {
|
|
return [];
|
|
}
|
|
return computeAllFixes({uri: textDocument.uri, version: textDocument.version}, AllFixesMode.format);
|
|
}, (params) => {
|
|
const document = documents.get(params.textDocument.uri);
|
|
return document !== void 0 ? document.version : void 0;
|
|
});
|
|
connection.listen();
|
|
});
|
|
|
|
// node_modules/vscode-languageserver-textdocument/lib/esm/main.js
|
|
"use strict";
|
|
var FullTextDocument = function() {
|
|
function FullTextDocument2(uri, languageId, version, content) {
|
|
this._uri = uri;
|
|
this._languageId = languageId;
|
|
this._version = version;
|
|
this._content = content;
|
|
this._lineOffsets = void 0;
|
|
}
|
|
Object.defineProperty(FullTextDocument2.prototype, "uri", {
|
|
get: function() {
|
|
return this._uri;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(FullTextDocument2.prototype, "languageId", {
|
|
get: function() {
|
|
return this._languageId;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(FullTextDocument2.prototype, "version", {
|
|
get: function() {
|
|
return this._version;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
FullTextDocument2.prototype.getText = function(range) {
|
|
if (range) {
|
|
var start = this.offsetAt(range.start);
|
|
var end = this.offsetAt(range.end);
|
|
return this._content.substring(start, end);
|
|
}
|
|
return this._content;
|
|
};
|
|
FullTextDocument2.prototype.update = function(changes, version) {
|
|
for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
|
|
var change = changes_1[_i];
|
|
if (FullTextDocument2.isIncremental(change)) {
|
|
var range = getWellformedRange(change.range);
|
|
var startOffset = this.offsetAt(range.start);
|
|
var endOffset = this.offsetAt(range.end);
|
|
this._content = this._content.substring(0, startOffset) + change.text + this._content.substring(endOffset, this._content.length);
|
|
var startLine = Math.max(range.start.line, 0);
|
|
var endLine = Math.max(range.end.line, 0);
|
|
var lineOffsets = this._lineOffsets;
|
|
var addedLineOffsets = computeLineOffsets(change.text, false, startOffset);
|
|
if (endLine - startLine === addedLineOffsets.length) {
|
|
for (var i = 0, len = addedLineOffsets.length; i < len; i++) {
|
|
lineOffsets[i + startLine + 1] = addedLineOffsets[i];
|
|
}
|
|
} else {
|
|
if (addedLineOffsets.length < 1e4) {
|
|
lineOffsets.splice.apply(lineOffsets, [startLine + 1, endLine - startLine].concat(addedLineOffsets));
|
|
} else {
|
|
this._lineOffsets = lineOffsets = lineOffsets.slice(0, startLine + 1).concat(addedLineOffsets, lineOffsets.slice(endLine + 1));
|
|
}
|
|
}
|
|
var diff = change.text.length - (endOffset - startOffset);
|
|
if (diff !== 0) {
|
|
for (var i = startLine + 1 + addedLineOffsets.length, len = lineOffsets.length; i < len; i++) {
|
|
lineOffsets[i] = lineOffsets[i] + diff;
|
|
}
|
|
}
|
|
} else if (FullTextDocument2.isFull(change)) {
|
|
this._content = change.text;
|
|
this._lineOffsets = void 0;
|
|
} else {
|
|
throw new Error("Unknown change event received");
|
|
}
|
|
}
|
|
this._version = version;
|
|
};
|
|
FullTextDocument2.prototype.getLineOffsets = function() {
|
|
if (this._lineOffsets === void 0) {
|
|
this._lineOffsets = computeLineOffsets(this._content, true);
|
|
}
|
|
return this._lineOffsets;
|
|
};
|
|
FullTextDocument2.prototype.positionAt = function(offset) {
|
|
offset = Math.max(Math.min(offset, this._content.length), 0);
|
|
var lineOffsets = this.getLineOffsets();
|
|
var low = 0, high = lineOffsets.length;
|
|
if (high === 0) {
|
|
return {line: 0, character: offset};
|
|
}
|
|
while (low < high) {
|
|
var mid = Math.floor((low + high) / 2);
|
|
if (lineOffsets[mid] > offset) {
|
|
high = mid;
|
|
} else {
|
|
low = mid + 1;
|
|
}
|
|
}
|
|
var line = low - 1;
|
|
return {line, character: offset - lineOffsets[line]};
|
|
};
|
|
FullTextDocument2.prototype.offsetAt = function(position) {
|
|
var lineOffsets = this.getLineOffsets();
|
|
if (position.line >= lineOffsets.length) {
|
|
return this._content.length;
|
|
} else if (position.line < 0) {
|
|
return 0;
|
|
}
|
|
var lineOffset = lineOffsets[position.line];
|
|
var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
|
|
return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
|
|
};
|
|
Object.defineProperty(FullTextDocument2.prototype, "lineCount", {
|
|
get: function() {
|
|
return this.getLineOffsets().length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
FullTextDocument2.isIncremental = function(event) {
|
|
var candidate = event;
|
|
return candidate !== void 0 && candidate !== null && typeof candidate.text === "string" && candidate.range !== void 0 && (candidate.rangeLength === void 0 || typeof candidate.rangeLength === "number");
|
|
};
|
|
FullTextDocument2.isFull = function(event) {
|
|
var candidate = event;
|
|
return candidate !== void 0 && candidate !== null && typeof candidate.text === "string" && candidate.range === void 0 && candidate.rangeLength === void 0;
|
|
};
|
|
return FullTextDocument2;
|
|
}();
|
|
var TextDocument;
|
|
(function(TextDocument2) {
|
|
function create(uri, languageId, version, content) {
|
|
return new FullTextDocument(uri, languageId, version, content);
|
|
}
|
|
TextDocument2.create = create;
|
|
function update(document, changes, version) {
|
|
if (document instanceof FullTextDocument) {
|
|
document.update(changes, version);
|
|
return document;
|
|
} else {
|
|
throw new Error("TextDocument.update: document must be created by TextDocument.create");
|
|
}
|
|
}
|
|
TextDocument2.update = update;
|
|
function applyEdits(document, edits) {
|
|
var text = document.getText();
|
|
var sortedEdits = mergeSort(edits.map(getWellformedEdit), function(a, b) {
|
|
var diff = a.range.start.line - b.range.start.line;
|
|
if (diff === 0) {
|
|
return a.range.start.character - b.range.start.character;
|
|
}
|
|
return diff;
|
|
});
|
|
var lastModifiedOffset = 0;
|
|
var spans = [];
|
|
for (var _i = 0, sortedEdits_1 = sortedEdits; _i < sortedEdits_1.length; _i++) {
|
|
var e = sortedEdits_1[_i];
|
|
var startOffset = document.offsetAt(e.range.start);
|
|
if (startOffset < lastModifiedOffset) {
|
|
throw new Error("Overlapping edit");
|
|
} else if (startOffset > lastModifiedOffset) {
|
|
spans.push(text.substring(lastModifiedOffset, startOffset));
|
|
}
|
|
if (e.newText.length) {
|
|
spans.push(e.newText);
|
|
}
|
|
lastModifiedOffset = document.offsetAt(e.range.end);
|
|
}
|
|
spans.push(text.substr(lastModifiedOffset));
|
|
return spans.join("");
|
|
}
|
|
TextDocument2.applyEdits = applyEdits;
|
|
})(TextDocument || (TextDocument = {}));
|
|
function mergeSort(data, compare) {
|
|
if (data.length <= 1) {
|
|
return data;
|
|
}
|
|
var p = data.length / 2 | 0;
|
|
var left = data.slice(0, p);
|
|
var right = data.slice(p);
|
|
mergeSort(left, compare);
|
|
mergeSort(right, compare);
|
|
var leftIdx = 0;
|
|
var rightIdx = 0;
|
|
var i = 0;
|
|
while (leftIdx < left.length && rightIdx < right.length) {
|
|
var ret = compare(left[leftIdx], right[rightIdx]);
|
|
if (ret <= 0) {
|
|
data[i++] = left[leftIdx++];
|
|
} else {
|
|
data[i++] = right[rightIdx++];
|
|
}
|
|
}
|
|
while (leftIdx < left.length) {
|
|
data[i++] = left[leftIdx++];
|
|
}
|
|
while (rightIdx < right.length) {
|
|
data[i++] = right[rightIdx++];
|
|
}
|
|
return data;
|
|
}
|
|
function computeLineOffsets(text, isAtLineStart, textOffset) {
|
|
if (textOffset === void 0) {
|
|
textOffset = 0;
|
|
}
|
|
var result = isAtLineStart ? [textOffset] : [];
|
|
for (var i = 0; i < text.length; i++) {
|
|
var ch = text.charCodeAt(i);
|
|
if (ch === 13 || ch === 10) {
|
|
if (ch === 13 && i + 1 < text.length && text.charCodeAt(i + 1) === 10) {
|
|
i++;
|
|
}
|
|
result.push(textOffset + i + 1);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function getWellformedRange(range) {
|
|
var start = range.start;
|
|
var end = range.end;
|
|
if (start.line > end.line || start.line === end.line && start.character > end.character) {
|
|
return {start: end, end: start};
|
|
}
|
|
return range;
|
|
}
|
|
function getWellformedEdit(textEdit) {
|
|
var range = getWellformedRange(textEdit.range);
|
|
if (range !== textEdit.range) {
|
|
return {newText: textEdit.newText, range};
|
|
}
|
|
return textEdit;
|
|
}
|
|
|
|
// node_modules/vscode-uri/lib/esm/index.js
|
|
"use strict";
|
|
var __extends = function() {
|
|
var extendStatics = function(d, b) {
|
|
extendStatics = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(d2, b2) {
|
|
d2.__proto__ = b2;
|
|
} || function(d2, b2) {
|
|
for (var p in b2)
|
|
if (b2.hasOwnProperty(p))
|
|
d2[p] = b2[p];
|
|
};
|
|
return extendStatics(d, b);
|
|
};
|
|
return function(d, b) {
|
|
extendStatics(d, b);
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
}();
|
|
var _a;
|
|
var isWindows;
|
|
if (typeof process === "object") {
|
|
isWindows = process.platform === "win32";
|
|
} else if (typeof navigator === "object") {
|
|
userAgent = navigator.userAgent;
|
|
isWindows = userAgent.indexOf("Windows") >= 0;
|
|
}
|
|
var userAgent;
|
|
var _schemePattern = /^\w[\w\d+.-]*$/;
|
|
var _singleSlashStart = /^\//;
|
|
var _doubleSlashStart = /^\/\//;
|
|
function _validateUri(ret, _strict) {
|
|
if (!ret.scheme && _strict) {
|
|
throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "' + ret.authority + '", path: "' + ret.path + '", query: "' + ret.query + '", fragment: "' + ret.fragment + '"}');
|
|
}
|
|
if (ret.scheme && !_schemePattern.test(ret.scheme)) {
|
|
throw new Error("[UriError]: Scheme contains illegal characters.");
|
|
}
|
|
if (ret.path) {
|
|
if (ret.authority) {
|
|
if (!_singleSlashStart.test(ret.path)) {
|
|
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');
|
|
}
|
|
} else {
|
|
if (_doubleSlashStart.test(ret.path)) {
|
|
throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function _schemeFix(scheme, _strict) {
|
|
if (!scheme && !_strict) {
|
|
return "file";
|
|
}
|
|
return scheme;
|
|
}
|
|
function _referenceResolution(scheme, path) {
|
|
switch (scheme) {
|
|
case "https":
|
|
case "http":
|
|
case "file":
|
|
if (!path) {
|
|
path = _slash;
|
|
} else if (path[0] !== _slash) {
|
|
path = _slash + path;
|
|
}
|
|
break;
|
|
}
|
|
return path;
|
|
}
|
|
var _empty = "";
|
|
var _slash = "/";
|
|
var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
|
|
var URI = function() {
|
|
function URI2(schemeOrData, authority, path, query, fragment, _strict) {
|
|
if (_strict === void 0) {
|
|
_strict = false;
|
|
}
|
|
if (typeof schemeOrData === "object") {
|
|
this.scheme = schemeOrData.scheme || _empty;
|
|
this.authority = schemeOrData.authority || _empty;
|
|
this.path = schemeOrData.path || _empty;
|
|
this.query = schemeOrData.query || _empty;
|
|
this.fragment = schemeOrData.fragment || _empty;
|
|
} else {
|
|
this.scheme = _schemeFix(schemeOrData, _strict);
|
|
this.authority = authority || _empty;
|
|
this.path = _referenceResolution(this.scheme, path || _empty);
|
|
this.query = query || _empty;
|
|
this.fragment = fragment || _empty;
|
|
_validateUri(this, _strict);
|
|
}
|
|
}
|
|
URI2.isUri = function(thing) {
|
|
if (thing instanceof URI2) {
|
|
return true;
|
|
}
|
|
if (!thing) {
|
|
return false;
|
|
}
|
|
return typeof thing.authority === "string" && typeof thing.fragment === "string" && typeof thing.path === "string" && typeof thing.query === "string" && typeof thing.scheme === "string" && typeof thing.fsPath === "function" && typeof thing.with === "function" && typeof thing.toString === "function";
|
|
};
|
|
Object.defineProperty(URI2.prototype, "fsPath", {
|
|
get: function() {
|
|
return _makeFsPath(this);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
URI2.prototype.with = function(change) {
|
|
if (!change) {
|
|
return this;
|
|
}
|
|
var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
|
|
if (scheme === void 0) {
|
|
scheme = this.scheme;
|
|
} else if (scheme === null) {
|
|
scheme = _empty;
|
|
}
|
|
if (authority === void 0) {
|
|
authority = this.authority;
|
|
} else if (authority === null) {
|
|
authority = _empty;
|
|
}
|
|
if (path === void 0) {
|
|
path = this.path;
|
|
} else if (path === null) {
|
|
path = _empty;
|
|
}
|
|
if (query === void 0) {
|
|
query = this.query;
|
|
} else if (query === null) {
|
|
query = _empty;
|
|
}
|
|
if (fragment === void 0) {
|
|
fragment = this.fragment;
|
|
} else if (fragment === null) {
|
|
fragment = _empty;
|
|
}
|
|
if (scheme === this.scheme && authority === this.authority && path === this.path && query === this.query && fragment === this.fragment) {
|
|
return this;
|
|
}
|
|
return new _URI(scheme, authority, path, query, fragment);
|
|
};
|
|
URI2.parse = function(value, _strict) {
|
|
if (_strict === void 0) {
|
|
_strict = false;
|
|
}
|
|
var match = _regexp.exec(value);
|
|
if (!match) {
|
|
return new _URI(_empty, _empty, _empty, _empty, _empty);
|
|
}
|
|
return new _URI(match[2] || _empty, decodeURIComponent(match[4] || _empty), decodeURIComponent(match[5] || _empty), decodeURIComponent(match[7] || _empty), decodeURIComponent(match[9] || _empty), _strict);
|
|
};
|
|
URI2.file = function(path) {
|
|
var authority = _empty;
|
|
if (isWindows) {
|
|
path = path.replace(/\\/g, _slash);
|
|
}
|
|
if (path[0] === _slash && path[1] === _slash) {
|
|
var idx = path.indexOf(_slash, 2);
|
|
if (idx === -1) {
|
|
authority = path.substring(2);
|
|
path = _slash;
|
|
} else {
|
|
authority = path.substring(2, idx);
|
|
path = path.substring(idx) || _slash;
|
|
}
|
|
}
|
|
return new _URI("file", authority, path, _empty, _empty);
|
|
};
|
|
URI2.from = function(components) {
|
|
return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
|
|
};
|
|
URI2.prototype.toString = function(skipEncoding) {
|
|
if (skipEncoding === void 0) {
|
|
skipEncoding = false;
|
|
}
|
|
return _asFormatted(this, skipEncoding);
|
|
};
|
|
URI2.prototype.toJSON = function() {
|
|
return this;
|
|
};
|
|
URI2.revive = function(data) {
|
|
if (!data) {
|
|
return data;
|
|
} else if (data instanceof URI2) {
|
|
return data;
|
|
} else {
|
|
var result = new _URI(data);
|
|
result._formatted = data.external;
|
|
result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
|
|
return result;
|
|
}
|
|
};
|
|
return URI2;
|
|
}();
|
|
var _pathSepMarker = isWindows ? 1 : void 0;
|
|
var _URI = function(_super) {
|
|
__extends(_URI2, _super);
|
|
function _URI2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this._formatted = null;
|
|
_this._fsPath = null;
|
|
return _this;
|
|
}
|
|
Object.defineProperty(_URI2.prototype, "fsPath", {
|
|
get: function() {
|
|
if (!this._fsPath) {
|
|
this._fsPath = _makeFsPath(this);
|
|
}
|
|
return this._fsPath;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
_URI2.prototype.toString = function(skipEncoding) {
|
|
if (skipEncoding === void 0) {
|
|
skipEncoding = false;
|
|
}
|
|
if (!skipEncoding) {
|
|
if (!this._formatted) {
|
|
this._formatted = _asFormatted(this, false);
|
|
}
|
|
return this._formatted;
|
|
} else {
|
|
return _asFormatted(this, true);
|
|
}
|
|
};
|
|
_URI2.prototype.toJSON = function() {
|
|
var res = {
|
|
$mid: 1
|
|
};
|
|
if (this._fsPath) {
|
|
res.fsPath = this._fsPath;
|
|
res._sep = _pathSepMarker;
|
|
}
|
|
if (this._formatted) {
|
|
res.external = this._formatted;
|
|
}
|
|
if (this.path) {
|
|
res.path = this.path;
|
|
}
|
|
if (this.scheme) {
|
|
res.scheme = this.scheme;
|
|
}
|
|
if (this.authority) {
|
|
res.authority = this.authority;
|
|
}
|
|
if (this.query) {
|
|
res.query = this.query;
|
|
}
|
|
if (this.fragment) {
|
|
res.fragment = this.fragment;
|
|
}
|
|
return res;
|
|
};
|
|
return _URI2;
|
|
}(URI);
|
|
var encodeTable = (_a = {}, _a[58] = "%3A", _a[47] = "%2F", _a[63] = "%3F", _a[35] = "%23", _a[91] = "%5B", _a[93] = "%5D", _a[64] = "%40", _a[33] = "%21", _a[36] = "%24", _a[38] = "%26", _a[39] = "%27", _a[40] = "%28", _a[41] = "%29", _a[42] = "%2A", _a[43] = "%2B", _a[44] = "%2C", _a[59] = "%3B", _a[61] = "%3D", _a[32] = "%20", _a);
|
|
function encodeURIComponentFast(uriComponent, allowSlash) {
|
|
var res = void 0;
|
|
var nativeEncodePos = -1;
|
|
for (var pos = 0; pos < uriComponent.length; pos++) {
|
|
var code = uriComponent.charCodeAt(pos);
|
|
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 45 || code === 46 || code === 95 || code === 126 || allowSlash && code === 47) {
|
|
if (nativeEncodePos !== -1) {
|
|
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
|
|
nativeEncodePos = -1;
|
|
}
|
|
if (res !== void 0) {
|
|
res += uriComponent.charAt(pos);
|
|
}
|
|
} else {
|
|
if (res === void 0) {
|
|
res = uriComponent.substr(0, pos);
|
|
}
|
|
var escaped = encodeTable[code];
|
|
if (escaped !== void 0) {
|
|
if (nativeEncodePos !== -1) {
|
|
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
|
|
nativeEncodePos = -1;
|
|
}
|
|
res += escaped;
|
|
} else if (nativeEncodePos === -1) {
|
|
nativeEncodePos = pos;
|
|
}
|
|
}
|
|
}
|
|
if (nativeEncodePos !== -1) {
|
|
res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
|
|
}
|
|
return res !== void 0 ? res : uriComponent;
|
|
}
|
|
function encodeURIComponentMinimal(path) {
|
|
var res = void 0;
|
|
for (var pos = 0; pos < path.length; pos++) {
|
|
var code = path.charCodeAt(pos);
|
|
if (code === 35 || code === 63) {
|
|
if (res === void 0) {
|
|
res = path.substr(0, pos);
|
|
}
|
|
res += encodeTable[code];
|
|
} else {
|
|
if (res !== void 0) {
|
|
res += path[pos];
|
|
}
|
|
}
|
|
}
|
|
return res !== void 0 ? res : path;
|
|
}
|
|
function _makeFsPath(uri) {
|
|
var value;
|
|
if (uri.authority && uri.path.length > 1 && uri.scheme === "file") {
|
|
value = "//" + uri.authority + uri.path;
|
|
} else if (uri.path.charCodeAt(0) === 47 && (uri.path.charCodeAt(1) >= 65 && uri.path.charCodeAt(1) <= 90 || uri.path.charCodeAt(1) >= 97 && uri.path.charCodeAt(1) <= 122) && uri.path.charCodeAt(2) === 58) {
|
|
value = uri.path[1].toLowerCase() + uri.path.substr(2);
|
|
} else {
|
|
value = uri.path;
|
|
}
|
|
if (isWindows) {
|
|
value = value.replace(/\//g, "\\");
|
|
}
|
|
return value;
|
|
}
|
|
function _asFormatted(uri, skipEncoding) {
|
|
var encoder = !skipEncoding ? encodeURIComponentFast : encodeURIComponentMinimal;
|
|
var res = "";
|
|
var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
|
|
if (scheme) {
|
|
res += scheme;
|
|
res += ":";
|
|
}
|
|
if (authority || scheme === "file") {
|
|
res += _slash;
|
|
res += _slash;
|
|
}
|
|
if (authority) {
|
|
var idx = authority.indexOf("@");
|
|
if (idx !== -1) {
|
|
var userinfo = authority.substr(0, idx);
|
|
authority = authority.substr(idx + 1);
|
|
idx = userinfo.indexOf(":");
|
|
if (idx === -1) {
|
|
res += encoder(userinfo, false);
|
|
} else {
|
|
res += encoder(userinfo.substr(0, idx), false);
|
|
res += ":";
|
|
res += encoder(userinfo.substr(idx + 1), false);
|
|
}
|
|
res += "@";
|
|
}
|
|
authority = authority.toLowerCase();
|
|
idx = authority.indexOf(":");
|
|
if (idx === -1) {
|
|
res += encoder(authority, false);
|
|
} else {
|
|
res += encoder(authority.substr(0, idx), false);
|
|
res += authority.substr(idx);
|
|
}
|
|
}
|
|
if (path) {
|
|
if (path.length >= 3 && path.charCodeAt(0) === 47 && path.charCodeAt(2) === 58) {
|
|
var code = path.charCodeAt(1);
|
|
if (code >= 65 && code <= 90) {
|
|
path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3);
|
|
}
|
|
} else if (path.length >= 2 && path.charCodeAt(1) === 58) {
|
|
var code = path.charCodeAt(0);
|
|
if (code >= 65 && code <= 90) {
|
|
path = String.fromCharCode(code + 32) + ":" + path.substr(2);
|
|
}
|
|
}
|
|
res += encoder(path, true);
|
|
}
|
|
if (query) {
|
|
res += "?";
|
|
res += encoder(query, false);
|
|
}
|
|
if (fragment) {
|
|
res += "#";
|
|
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// server/diff.ts
|
|
function stringDiff(original, modified, pretty) {
|
|
return new LcsDiff(new StringDiffSequence(original), new StringDiffSequence(modified)).ComputeDiff(pretty).changes;
|
|
}
|
|
var StringDiffSequence = class {
|
|
constructor(source) {
|
|
this.source = source;
|
|
}
|
|
getElements() {
|
|
const source = this.source;
|
|
const characters = new Int32Array(source.length);
|
|
for (let i = 0, len = source.length; i < len; i++) {
|
|
characters[i] = source.charCodeAt(i);
|
|
}
|
|
return characters;
|
|
}
|
|
};
|
|
var DiffChange = class {
|
|
constructor(originalStart, originalLength, modifiedStart, modifiedLength) {
|
|
this.originalStart = originalStart;
|
|
this.originalLength = originalLength;
|
|
this.modifiedStart = modifiedStart;
|
|
this.modifiedLength = modifiedLength;
|
|
}
|
|
getOriginalEnd() {
|
|
return this.originalStart + this.originalLength;
|
|
}
|
|
getModifiedEnd() {
|
|
return this.modifiedStart + this.modifiedLength;
|
|
}
|
|
};
|
|
var Debug = class {
|
|
static Assert(condition, message) {
|
|
if (!condition) {
|
|
throw new Error(message);
|
|
}
|
|
}
|
|
};
|
|
var Constants;
|
|
(function(Constants2) {
|
|
Constants2[Constants2["MAX_SAFE_SMALL_INTEGER"] = 1073741824] = "MAX_SAFE_SMALL_INTEGER";
|
|
Constants2[Constants2["MIN_SAFE_SMALL_INTEGER"] = -1073741824] = "MIN_SAFE_SMALL_INTEGER";
|
|
Constants2[Constants2["MAX_UINT_8"] = 255] = "MAX_UINT_8";
|
|
Constants2[Constants2["MAX_UINT_16"] = 65535] = "MAX_UINT_16";
|
|
Constants2[Constants2["MAX_UINT_32"] = 4294967295] = "MAX_UINT_32";
|
|
Constants2[Constants2["UNICODE_SUPPLEMENTARY_PLANE_BEGIN"] = 65536] = "UNICODE_SUPPLEMENTARY_PLANE_BEGIN";
|
|
})(Constants || (Constants = {}));
|
|
var LocalConstants;
|
|
(function(LocalConstants2) {
|
|
LocalConstants2[LocalConstants2["MaxDifferencesHistory"] = 1447] = "MaxDifferencesHistory";
|
|
})(LocalConstants || (LocalConstants = {}));
|
|
var MyArray = class {
|
|
static Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
|
|
for (let i = 0; i < length; i++) {
|
|
destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
|
|
}
|
|
}
|
|
static Copy2(sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
|
|
for (let i = 0; i < length; i++) {
|
|
destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
|
|
}
|
|
}
|
|
};
|
|
var DiffChangeHelper = class {
|
|
constructor() {
|
|
this.m_changes = [];
|
|
this.m_originalStart = 1073741824;
|
|
this.m_modifiedStart = 1073741824;
|
|
this.m_originalCount = 0;
|
|
this.m_modifiedCount = 0;
|
|
}
|
|
MarkNextChange() {
|
|
if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
|
|
this.m_changes.push(new DiffChange(this.m_originalStart, this.m_originalCount, this.m_modifiedStart, this.m_modifiedCount));
|
|
}
|
|
this.m_originalCount = 0;
|
|
this.m_modifiedCount = 0;
|
|
this.m_originalStart = 1073741824;
|
|
this.m_modifiedStart = 1073741824;
|
|
}
|
|
AddOriginalElement(originalIndex, modifiedIndex) {
|
|
this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
|
|
this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
|
|
this.m_originalCount++;
|
|
}
|
|
AddModifiedElement(originalIndex, modifiedIndex) {
|
|
this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
|
|
this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
|
|
this.m_modifiedCount++;
|
|
}
|
|
getChanges() {
|
|
if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
|
|
this.MarkNextChange();
|
|
}
|
|
return this.m_changes;
|
|
}
|
|
getReverseChanges() {
|
|
if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
|
|
this.MarkNextChange();
|
|
}
|
|
this.m_changes.reverse();
|
|
return this.m_changes;
|
|
}
|
|
};
|
|
var LcsDiff = class {
|
|
constructor(originalSequence, modifiedSequence, continueProcessingPredicate = null) {
|
|
this.ContinueProcessingPredicate = continueProcessingPredicate;
|
|
const [originalStringElements, originalElementsOrHash, originalHasStrings] = LcsDiff._getElements(originalSequence);
|
|
const [modifiedStringElements, modifiedElementsOrHash, modifiedHasStrings] = LcsDiff._getElements(modifiedSequence);
|
|
this._hasStrings = originalHasStrings && modifiedHasStrings;
|
|
this._originalStringElements = originalStringElements;
|
|
this._originalElementsOrHash = originalElementsOrHash;
|
|
this._modifiedStringElements = modifiedStringElements;
|
|
this._modifiedElementsOrHash = modifiedElementsOrHash;
|
|
this.m_forwardHistory = [];
|
|
this.m_reverseHistory = [];
|
|
}
|
|
static _getElements(sequence) {
|
|
const elements = sequence.getElements();
|
|
if (elements instanceof Int32Array) {
|
|
return [[], elements, false];
|
|
}
|
|
return [[], new Int32Array(elements), false];
|
|
}
|
|
ElementsAreEqual(originalIndex, newIndex) {
|
|
if (this._originalElementsOrHash[originalIndex] !== this._modifiedElementsOrHash[newIndex]) {
|
|
return false;
|
|
}
|
|
return this._hasStrings ? this._originalStringElements[originalIndex] === this._modifiedStringElements[newIndex] : true;
|
|
}
|
|
OriginalElementsAreEqual(index1, index2) {
|
|
if (this._originalElementsOrHash[index1] !== this._originalElementsOrHash[index2]) {
|
|
return false;
|
|
}
|
|
return this._hasStrings ? this._originalStringElements[index1] === this._originalStringElements[index2] : true;
|
|
}
|
|
ModifiedElementsAreEqual(index1, index2) {
|
|
if (this._modifiedElementsOrHash[index1] !== this._modifiedElementsOrHash[index2]) {
|
|
return false;
|
|
}
|
|
return this._hasStrings ? this._modifiedStringElements[index1] === this._modifiedStringElements[index2] : true;
|
|
}
|
|
ComputeDiff(pretty) {
|
|
return this._ComputeDiff(0, this._originalElementsOrHash.length - 1, 0, this._modifiedElementsOrHash.length - 1, pretty);
|
|
}
|
|
_ComputeDiff(originalStart, originalEnd, modifiedStart, modifiedEnd, pretty) {
|
|
const quitEarlyArr = [false];
|
|
let changes = this.ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr);
|
|
if (pretty) {
|
|
changes = this.PrettifyChanges(changes);
|
|
}
|
|
return {
|
|
quitEarly: quitEarlyArr[0],
|
|
changes
|
|
};
|
|
}
|
|
ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr) {
|
|
quitEarlyArr[0] = false;
|
|
while (originalStart <= originalEnd && modifiedStart <= modifiedEnd && this.ElementsAreEqual(originalStart, modifiedStart)) {
|
|
originalStart++;
|
|
modifiedStart++;
|
|
}
|
|
while (originalEnd >= originalStart && modifiedEnd >= modifiedStart && this.ElementsAreEqual(originalEnd, modifiedEnd)) {
|
|
originalEnd--;
|
|
modifiedEnd--;
|
|
}
|
|
if (originalStart > originalEnd || modifiedStart > modifiedEnd) {
|
|
let changes;
|
|
if (modifiedStart <= modifiedEnd) {
|
|
Debug.Assert(originalStart === originalEnd + 1, "originalStart should only be one more than originalEnd");
|
|
changes = [
|
|
new DiffChange(originalStart, 0, modifiedStart, modifiedEnd - modifiedStart + 1)
|
|
];
|
|
} else if (originalStart <= originalEnd) {
|
|
Debug.Assert(modifiedStart === modifiedEnd + 1, "modifiedStart should only be one more than modifiedEnd");
|
|
changes = [
|
|
new DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, 0)
|
|
];
|
|
} else {
|
|
Debug.Assert(originalStart === originalEnd + 1, "originalStart should only be one more than originalEnd");
|
|
Debug.Assert(modifiedStart === modifiedEnd + 1, "modifiedStart should only be one more than modifiedEnd");
|
|
changes = [];
|
|
}
|
|
return changes;
|
|
}
|
|
const midOriginalArr = [0];
|
|
const midModifiedArr = [0];
|
|
const result = this.ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr);
|
|
const midOriginal = midOriginalArr[0];
|
|
const midModified = midModifiedArr[0];
|
|
if (result !== null) {
|
|
return result;
|
|
} else if (!quitEarlyArr[0]) {
|
|
const leftChanges = this.ComputeDiffRecursive(originalStart, midOriginal, modifiedStart, midModified, quitEarlyArr);
|
|
let rightChanges = [];
|
|
if (!quitEarlyArr[0]) {
|
|
rightChanges = this.ComputeDiffRecursive(midOriginal + 1, originalEnd, midModified + 1, modifiedEnd, quitEarlyArr);
|
|
} else {
|
|
rightChanges = [
|
|
new DiffChange(midOriginal + 1, originalEnd - (midOriginal + 1) + 1, midModified + 1, modifiedEnd - (midModified + 1) + 1)
|
|
];
|
|
}
|
|
return this.ConcatenateChanges(leftChanges, rightChanges);
|
|
}
|
|
return [
|
|
new DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
|
|
];
|
|
}
|
|
WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr) {
|
|
let forwardChanges = null;
|
|
let reverseChanges = null;
|
|
let changeHelper = new DiffChangeHelper();
|
|
let diagonalMin = diagonalForwardStart;
|
|
let diagonalMax = diagonalForwardEnd;
|
|
let diagonalRelative = midOriginalArr[0] - midModifiedArr[0] - diagonalForwardOffset;
|
|
let lastOriginalIndex = -1073741824;
|
|
let historyIndex = this.m_forwardHistory.length - 1;
|
|
do {
|
|
const diagonal = diagonalRelative + diagonalForwardBase;
|
|
if (diagonal === diagonalMin || diagonal < diagonalMax && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1]) {
|
|
originalIndex = forwardPoints[diagonal + 1];
|
|
modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
|
|
if (originalIndex < lastOriginalIndex) {
|
|
changeHelper.MarkNextChange();
|
|
}
|
|
lastOriginalIndex = originalIndex;
|
|
changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex);
|
|
diagonalRelative = diagonal + 1 - diagonalForwardBase;
|
|
} else {
|
|
originalIndex = forwardPoints[diagonal - 1] + 1;
|
|
modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
|
|
if (originalIndex < lastOriginalIndex) {
|
|
changeHelper.MarkNextChange();
|
|
}
|
|
lastOriginalIndex = originalIndex - 1;
|
|
changeHelper.AddOriginalElement(originalIndex, modifiedIndex + 1);
|
|
diagonalRelative = diagonal - 1 - diagonalForwardBase;
|
|
}
|
|
if (historyIndex >= 0) {
|
|
forwardPoints = this.m_forwardHistory[historyIndex];
|
|
diagonalForwardBase = forwardPoints[0];
|
|
diagonalMin = 1;
|
|
diagonalMax = forwardPoints.length - 1;
|
|
}
|
|
} while (--historyIndex >= -1);
|
|
forwardChanges = changeHelper.getReverseChanges();
|
|
if (quitEarlyArr[0]) {
|
|
let originalStartPoint = midOriginalArr[0] + 1;
|
|
let modifiedStartPoint = midModifiedArr[0] + 1;
|
|
if (forwardChanges !== null && forwardChanges.length > 0) {
|
|
const lastForwardChange = forwardChanges[forwardChanges.length - 1];
|
|
originalStartPoint = Math.max(originalStartPoint, lastForwardChange.getOriginalEnd());
|
|
modifiedStartPoint = Math.max(modifiedStartPoint, lastForwardChange.getModifiedEnd());
|
|
}
|
|
reverseChanges = [
|
|
new DiffChange(originalStartPoint, originalEnd - originalStartPoint + 1, modifiedStartPoint, modifiedEnd - modifiedStartPoint + 1)
|
|
];
|
|
} else {
|
|
changeHelper = new DiffChangeHelper();
|
|
diagonalMin = diagonalReverseStart;
|
|
diagonalMax = diagonalReverseEnd;
|
|
diagonalRelative = midOriginalArr[0] - midModifiedArr[0] - diagonalReverseOffset;
|
|
lastOriginalIndex = 1073741824;
|
|
historyIndex = deltaIsEven ? this.m_reverseHistory.length - 1 : this.m_reverseHistory.length - 2;
|
|
do {
|
|
const diagonal = diagonalRelative + diagonalReverseBase;
|
|
if (diagonal === diagonalMin || diagonal < diagonalMax && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1]) {
|
|
originalIndex = reversePoints[diagonal + 1] - 1;
|
|
modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
|
|
if (originalIndex > lastOriginalIndex) {
|
|
changeHelper.MarkNextChange();
|
|
}
|
|
lastOriginalIndex = originalIndex + 1;
|
|
changeHelper.AddOriginalElement(originalIndex + 1, modifiedIndex + 1);
|
|
diagonalRelative = diagonal + 1 - diagonalReverseBase;
|
|
} else {
|
|
originalIndex = reversePoints[diagonal - 1];
|
|
modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
|
|
if (originalIndex > lastOriginalIndex) {
|
|
changeHelper.MarkNextChange();
|
|
}
|
|
lastOriginalIndex = originalIndex;
|
|
changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex + 1);
|
|
diagonalRelative = diagonal - 1 - diagonalReverseBase;
|
|
}
|
|
if (historyIndex >= 0) {
|
|
reversePoints = this.m_reverseHistory[historyIndex];
|
|
diagonalReverseBase = reversePoints[0];
|
|
diagonalMin = 1;
|
|
diagonalMax = reversePoints.length - 1;
|
|
}
|
|
} while (--historyIndex >= -1);
|
|
reverseChanges = changeHelper.getChanges();
|
|
}
|
|
return this.ConcatenateChanges(forwardChanges, reverseChanges);
|
|
}
|
|
ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr) {
|
|
let originalIndex = 0, modifiedIndex = 0;
|
|
let diagonalForwardStart = 0, diagonalForwardEnd = 0;
|
|
let diagonalReverseStart = 0, diagonalReverseEnd = 0;
|
|
originalStart--;
|
|
modifiedStart--;
|
|
midOriginalArr[0] = 0;
|
|
midModifiedArr[0] = 0;
|
|
this.m_forwardHistory = [];
|
|
this.m_reverseHistory = [];
|
|
const maxDifferences = originalEnd - originalStart + (modifiedEnd - modifiedStart);
|
|
const numDiagonals = maxDifferences + 1;
|
|
const forwardPoints = new Int32Array(numDiagonals);
|
|
const reversePoints = new Int32Array(numDiagonals);
|
|
const diagonalForwardBase = modifiedEnd - modifiedStart;
|
|
const diagonalReverseBase = originalEnd - originalStart;
|
|
const diagonalForwardOffset = originalStart - modifiedStart;
|
|
const diagonalReverseOffset = originalEnd - modifiedEnd;
|
|
const delta = diagonalReverseBase - diagonalForwardBase;
|
|
const deltaIsEven = delta % 2 === 0;
|
|
forwardPoints[diagonalForwardBase] = originalStart;
|
|
reversePoints[diagonalReverseBase] = originalEnd;
|
|
quitEarlyArr[0] = false;
|
|
for (let numDifferences = 1; numDifferences <= maxDifferences / 2 + 1; numDifferences++) {
|
|
let furthestOriginalIndex = 0;
|
|
let furthestModifiedIndex = 0;
|
|
diagonalForwardStart = this.ClipDiagonalBound(diagonalForwardBase - numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
|
|
diagonalForwardEnd = this.ClipDiagonalBound(diagonalForwardBase + numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
|
|
for (let diagonal = diagonalForwardStart; diagonal <= diagonalForwardEnd; diagonal += 2) {
|
|
if (diagonal === diagonalForwardStart || diagonal < diagonalForwardEnd && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1]) {
|
|
originalIndex = forwardPoints[diagonal + 1];
|
|
} else {
|
|
originalIndex = forwardPoints[diagonal - 1] + 1;
|
|
}
|
|
modifiedIndex = originalIndex - (diagonal - diagonalForwardBase) - diagonalForwardOffset;
|
|
const tempOriginalIndex = originalIndex;
|
|
while (originalIndex < originalEnd && modifiedIndex < modifiedEnd && this.ElementsAreEqual(originalIndex + 1, modifiedIndex + 1)) {
|
|
originalIndex++;
|
|
modifiedIndex++;
|
|
}
|
|
forwardPoints[diagonal] = originalIndex;
|
|
if (originalIndex + modifiedIndex > furthestOriginalIndex + furthestModifiedIndex) {
|
|
furthestOriginalIndex = originalIndex;
|
|
furthestModifiedIndex = modifiedIndex;
|
|
}
|
|
if (!deltaIsEven && Math.abs(diagonal - diagonalReverseBase) <= numDifferences - 1) {
|
|
if (originalIndex >= reversePoints[diagonal]) {
|
|
midOriginalArr[0] = originalIndex;
|
|
midModifiedArr[0] = modifiedIndex;
|
|
if (tempOriginalIndex <= reversePoints[diagonal] && 1447 > 0 && numDifferences <= 1447 + 1) {
|
|
return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const matchLengthOfLongest = (furthestOriginalIndex - originalStart + (furthestModifiedIndex - modifiedStart) - numDifferences) / 2;
|
|
if (this.ContinueProcessingPredicate !== null && !this.ContinueProcessingPredicate(furthestOriginalIndex, matchLengthOfLongest)) {
|
|
quitEarlyArr[0] = true;
|
|
midOriginalArr[0] = furthestOriginalIndex;
|
|
midModifiedArr[0] = furthestModifiedIndex;
|
|
if (matchLengthOfLongest > 0 && 1447 > 0 && numDifferences <= 1447 + 1) {
|
|
return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
|
|
} else {
|
|
originalStart++;
|
|
modifiedStart++;
|
|
return [
|
|
new DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
|
|
];
|
|
}
|
|
}
|
|
diagonalReverseStart = this.ClipDiagonalBound(diagonalReverseBase - numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
|
|
diagonalReverseEnd = this.ClipDiagonalBound(diagonalReverseBase + numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
|
|
for (let diagonal = diagonalReverseStart; diagonal <= diagonalReverseEnd; diagonal += 2) {
|
|
if (diagonal === diagonalReverseStart || diagonal < diagonalReverseEnd && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1]) {
|
|
originalIndex = reversePoints[diagonal + 1] - 1;
|
|
} else {
|
|
originalIndex = reversePoints[diagonal - 1];
|
|
}
|
|
modifiedIndex = originalIndex - (diagonal - diagonalReverseBase) - diagonalReverseOffset;
|
|
const tempOriginalIndex = originalIndex;
|
|
while (originalIndex > originalStart && modifiedIndex > modifiedStart && this.ElementsAreEqual(originalIndex, modifiedIndex)) {
|
|
originalIndex--;
|
|
modifiedIndex--;
|
|
}
|
|
reversePoints[diagonal] = originalIndex;
|
|
if (deltaIsEven && Math.abs(diagonal - diagonalForwardBase) <= numDifferences) {
|
|
if (originalIndex <= forwardPoints[diagonal]) {
|
|
midOriginalArr[0] = originalIndex;
|
|
midModifiedArr[0] = modifiedIndex;
|
|
if (tempOriginalIndex >= forwardPoints[diagonal] && 1447 > 0 && numDifferences <= 1447 + 1) {
|
|
return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (numDifferences <= 1447) {
|
|
let temp = new Int32Array(diagonalForwardEnd - diagonalForwardStart + 2);
|
|
temp[0] = diagonalForwardBase - diagonalForwardStart + 1;
|
|
MyArray.Copy2(forwardPoints, diagonalForwardStart, temp, 1, diagonalForwardEnd - diagonalForwardStart + 1);
|
|
this.m_forwardHistory.push(temp);
|
|
temp = new Int32Array(diagonalReverseEnd - diagonalReverseStart + 2);
|
|
temp[0] = diagonalReverseBase - diagonalReverseStart + 1;
|
|
MyArray.Copy2(reversePoints, diagonalReverseStart, temp, 1, diagonalReverseEnd - diagonalReverseStart + 1);
|
|
this.m_reverseHistory.push(temp);
|
|
}
|
|
}
|
|
return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
|
|
}
|
|
PrettifyChanges(changes) {
|
|
for (let i = 0; i < changes.length; i++) {
|
|
const change = changes[i];
|
|
const originalStop = i < changes.length - 1 ? changes[i + 1].originalStart : this._originalElementsOrHash.length;
|
|
const modifiedStop = i < changes.length - 1 ? changes[i + 1].modifiedStart : this._modifiedElementsOrHash.length;
|
|
const checkOriginal = change.originalLength > 0;
|
|
const checkModified = change.modifiedLength > 0;
|
|
while (change.originalStart + change.originalLength < originalStop && change.modifiedStart + change.modifiedLength < modifiedStop && (!checkOriginal || this.OriginalElementsAreEqual(change.originalStart, change.originalStart + change.originalLength)) && (!checkModified || this.ModifiedElementsAreEqual(change.modifiedStart, change.modifiedStart + change.modifiedLength))) {
|
|
change.originalStart++;
|
|
change.modifiedStart++;
|
|
}
|
|
let mergedChangeArr = [null];
|
|
if (i < changes.length - 1 && this.ChangesOverlap(changes[i], changes[i + 1], mergedChangeArr)) {
|
|
changes[i] = mergedChangeArr[0];
|
|
changes.splice(i + 1, 1);
|
|
i--;
|
|
continue;
|
|
}
|
|
}
|
|
for (let i = changes.length - 1; i >= 0; i--) {
|
|
const change = changes[i];
|
|
let originalStop = 0;
|
|
let modifiedStop = 0;
|
|
if (i > 0) {
|
|
const prevChange = changes[i - 1];
|
|
if (prevChange.originalLength > 0) {
|
|
originalStop = prevChange.originalStart + prevChange.originalLength;
|
|
}
|
|
if (prevChange.modifiedLength > 0) {
|
|
modifiedStop = prevChange.modifiedStart + prevChange.modifiedLength;
|
|
}
|
|
}
|
|
const checkOriginal = change.originalLength > 0;
|
|
const checkModified = change.modifiedLength > 0;
|
|
let bestDelta = 0;
|
|
let bestScore = this._boundaryScore(change.originalStart, change.originalLength, change.modifiedStart, change.modifiedLength);
|
|
for (let delta = 1; ; delta++) {
|
|
const originalStart = change.originalStart - delta;
|
|
const modifiedStart = change.modifiedStart - delta;
|
|
if (originalStart < originalStop || modifiedStart < modifiedStop) {
|
|
break;
|
|
}
|
|
if (checkOriginal && !this.OriginalElementsAreEqual(originalStart, originalStart + change.originalLength)) {
|
|
break;
|
|
}
|
|
if (checkModified && !this.ModifiedElementsAreEqual(modifiedStart, modifiedStart + change.modifiedLength)) {
|
|
break;
|
|
}
|
|
const score = this._boundaryScore(originalStart, change.originalLength, modifiedStart, change.modifiedLength);
|
|
if (score > bestScore) {
|
|
bestScore = score;
|
|
bestDelta = delta;
|
|
}
|
|
}
|
|
change.originalStart -= bestDelta;
|
|
change.modifiedStart -= bestDelta;
|
|
}
|
|
return changes;
|
|
}
|
|
_OriginalIsBoundary(index) {
|
|
if (index <= 0 || index >= this._originalElementsOrHash.length - 1) {
|
|
return true;
|
|
}
|
|
return this._hasStrings && /^\s*$/.test(this._originalStringElements[index]);
|
|
}
|
|
_OriginalRegionIsBoundary(originalStart, originalLength) {
|
|
if (this._OriginalIsBoundary(originalStart) || this._OriginalIsBoundary(originalStart - 1)) {
|
|
return true;
|
|
}
|
|
if (originalLength > 0) {
|
|
const originalEnd = originalStart + originalLength;
|
|
if (this._OriginalIsBoundary(originalEnd - 1) || this._OriginalIsBoundary(originalEnd)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
_ModifiedIsBoundary(index) {
|
|
if (index <= 0 || index >= this._modifiedElementsOrHash.length - 1) {
|
|
return true;
|
|
}
|
|
return this._hasStrings && /^\s*$/.test(this._modifiedStringElements[index]);
|
|
}
|
|
_ModifiedRegionIsBoundary(modifiedStart, modifiedLength) {
|
|
if (this._ModifiedIsBoundary(modifiedStart) || this._ModifiedIsBoundary(modifiedStart - 1)) {
|
|
return true;
|
|
}
|
|
if (modifiedLength > 0) {
|
|
const modifiedEnd = modifiedStart + modifiedLength;
|
|
if (this._ModifiedIsBoundary(modifiedEnd - 1) || this._ModifiedIsBoundary(modifiedEnd)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
_boundaryScore(originalStart, originalLength, modifiedStart, modifiedLength) {
|
|
const originalScore = this._OriginalRegionIsBoundary(originalStart, originalLength) ? 1 : 0;
|
|
const modifiedScore = this._ModifiedRegionIsBoundary(modifiedStart, modifiedLength) ? 1 : 0;
|
|
return originalScore + modifiedScore;
|
|
}
|
|
ConcatenateChanges(left, right) {
|
|
let mergedChangeArr = [];
|
|
if (left.length === 0 || right.length === 0) {
|
|
return right.length > 0 ? right : left;
|
|
} else if (this.ChangesOverlap(left[left.length - 1], right[0], mergedChangeArr)) {
|
|
const result = new Array(left.length + right.length - 1);
|
|
MyArray.Copy(left, 0, result, 0, left.length - 1);
|
|
result[left.length - 1] = mergedChangeArr[0];
|
|
MyArray.Copy(right, 1, result, left.length, right.length - 1);
|
|
return result;
|
|
} else {
|
|
const result = new Array(left.length + right.length);
|
|
MyArray.Copy(left, 0, result, 0, left.length);
|
|
MyArray.Copy(right, 0, result, left.length, right.length);
|
|
return result;
|
|
}
|
|
}
|
|
ChangesOverlap(left, right, mergedChangeArr) {
|
|
Debug.Assert(left.originalStart <= right.originalStart, "Left change is not less than or equal to right change");
|
|
Debug.Assert(left.modifiedStart <= right.modifiedStart, "Left change is not less than or equal to right change");
|
|
if (left.originalStart + left.originalLength >= right.originalStart || left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
|
|
const originalStart = left.originalStart;
|
|
let originalLength = left.originalLength;
|
|
const modifiedStart = left.modifiedStart;
|
|
let modifiedLength = left.modifiedLength;
|
|
if (left.originalStart + left.originalLength >= right.originalStart) {
|
|
originalLength = right.originalStart + right.originalLength - left.originalStart;
|
|
}
|
|
if (left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
|
|
modifiedLength = right.modifiedStart + right.modifiedLength - left.modifiedStart;
|
|
}
|
|
mergedChangeArr[0] = new DiffChange(originalStart, originalLength, modifiedStart, modifiedLength);
|
|
return true;
|
|
} else {
|
|
mergedChangeArr[0] = null;
|
|
return false;
|
|
}
|
|
}
|
|
ClipDiagonalBound(diagonal, numDifferences, diagonalBaseIndex, numDiagonals) {
|
|
if (diagonal >= 0 && diagonal < numDiagonals) {
|
|
return diagonal;
|
|
}
|
|
const diagonalsBelow = diagonalBaseIndex;
|
|
const diagonalsAbove = numDiagonals - diagonalBaseIndex - 1;
|
|
const diffEven = numDifferences % 2 === 0;
|
|
if (diagonal < 0) {
|
|
const lowerBoundEven = diagonalsBelow % 2 === 0;
|
|
return diffEven === lowerBoundEven ? 0 : 1;
|
|
} else {
|
|
const upperBoundEven = diagonalsAbove % 2 === 0;
|
|
return diffEven === upperBoundEven ? numDiagonals - 1 : numDiagonals - 2;
|
|
}
|
|
}
|
|
};
|
|
|
|
// entry-ns:server.ts
|
|
require_eslintServer();
|
|
//# sourceMappingURL=server.js.map
|