完成世界书、骰子、apiconfig页面处理

This commit is contained in:
2026-04-30 01:35:10 +08:00
parent a3e3711b2b
commit ba9b925c32
4602 changed files with 785225 additions and 23 deletions

View File

@@ -0,0 +1,62 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConnection = void 0;
const api_1 = require("../common/api");
__exportStar(require("vscode-languageserver-protocol/browser"), exports);
__exportStar(require("../common/api"), exports);
let _shutdownReceived = false;
const watchDog = {
initialize: (_params) => {
},
get shutdownReceived() {
return _shutdownReceived;
},
set shutdownReceived(value) {
_shutdownReceived = value;
},
exit: (_code) => {
}
};
function createConnection(arg1, arg2, arg3, arg4) {
let factories;
let reader;
let writer;
let options;
if (arg1 !== void 0 && arg1.__brand === 'features') {
factories = arg1;
arg1 = arg2;
arg2 = arg3;
arg3 = arg4;
}
if (api_1.ConnectionStrategy.is(arg1) || api_1.ConnectionOptions.is(arg1)) {
options = arg1;
}
else {
reader = arg1;
writer = arg2;
options = arg3;
}
const connectionFactory = (logger) => {
return (0, api_1.createProtocolConnection)(reader, writer, logger, options);
};
return (0, api_1.createConnection)(connectionFactory, watchDog, factories);
}
exports.createConnection = createConnection;

View File

@@ -0,0 +1,15 @@
import { CallHierarchyItem, CallHierarchyPrepareParams, CallHierarchyIncomingCallsParams, CallHierarchyIncomingCall, CallHierarchyOutgoingCallsParams, CallHierarchyOutgoingCall, Disposable } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the call hierarchy feature
*
* @since 3.16.0
*/
export interface CallHierarchy {
callHierarchy: {
onPrepare(handler: ServerRequestHandler<CallHierarchyPrepareParams, CallHierarchyItem[] | null, never, void>): Disposable;
onIncomingCalls(handler: ServerRequestHandler<CallHierarchyIncomingCallsParams, CallHierarchyIncomingCall[] | null, CallHierarchyIncomingCall[], void>): Disposable;
onOutgoingCalls(handler: ServerRequestHandler<CallHierarchyOutgoingCallsParams, CallHierarchyOutgoingCall[] | null, CallHierarchyOutgoingCall[], void>): Disposable;
};
}
export declare const CallHierarchyFeature: Feature<_Languages, CallHierarchy>;

View File

@@ -0,0 +1,34 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.CallHierarchyFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const CallHierarchyFeature = (Base) => {
return class extends Base {
get callHierarchy() {
return {
onPrepare: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.CallHierarchyPrepareRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
});
},
onIncomingCalls: (handler) => {
const type = vscode_languageserver_protocol_1.CallHierarchyIncomingCallsRequest.type;
return 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;
return this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
}
};
}
};
};
exports.CallHierarchyFeature = CallHierarchyFeature;

View File

@@ -0,0 +1,30 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagnosticFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const DiagnosticFeature = (Base) => {
return class extends Base {
get diagnostics() {
return {
refresh: () => {
return this.connection.sendRequest(vscode_languageserver_protocol_1.DiagnosticRefreshRequest.type);
},
on: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.partialResult, params));
});
},
onWorkspace: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.WorkspaceDiagnosticRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(vscode_languageserver_protocol_1.WorkspaceDiagnosticRequest.partialResult, params));
});
}
};
}
};
};
exports.DiagnosticFeature = DiagnosticFeature;

View File

@@ -0,0 +1,22 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.InlineCompletionFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const InlineCompletionFeature = (Base) => {
return class extends Base {
get inlineCompletion() {
return {
on: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.InlineCompletionRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params));
});
}
};
}
};
};
exports.InlineCompletionFeature = InlineCompletionFeature;

View File

@@ -0,0 +1,18 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkedEditingRangeFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const LinkedEditingRangeFeature = (Base) => {
return class extends Base {
onLinkedEditingRange(handler) {
return this.connection.onRequest(vscode_languageserver_protocol_1.LinkedEditingRangeRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
});
}
};
};
exports.LinkedEditingRangeFeature = LinkedEditingRangeFeature;

View File

@@ -0,0 +1,23 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.MonikerFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const MonikerFeature = (Base) => {
return class extends Base {
get moniker() {
return {
on: (handler) => {
const type = vscode_languageserver_protocol_1.MonikerRequest.type;
return this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
},
};
}
};
};
exports.MonikerFeature = MonikerFeature;

View File

@@ -0,0 +1,25 @@
import { CancellationToken, ProgressToken, ProgressType, WorkDoneProgressParams, PartialResultParams } from 'vscode-languageserver-protocol';
import type { Feature, _RemoteWindow } from './server';
export interface ProgressContext {
sendProgress<P>(type: ProgressType<P>, token: ProgressToken, value: P): void;
}
export interface WorkDoneProgressReporter {
begin(title: string, percentage?: number, message?: string, cancellable?: boolean): void;
report(percentage: number): void;
report(message: string): void;
report(percentage: number, message: string): void;
done(): void;
}
export interface WorkDoneProgressServerReporter extends WorkDoneProgressReporter {
readonly token: CancellationToken;
}
export interface WindowProgress {
attachWorkDoneProgress(token: ProgressToken | undefined): WorkDoneProgressReporter;
createWorkDoneProgress(): Promise<WorkDoneProgressServerReporter>;
}
export declare function attachWorkDone(connection: ProgressContext, params: WorkDoneProgressParams | undefined): WorkDoneProgressReporter;
export declare const ProgressFeature: Feature<_RemoteWindow, WindowProgress>;
export interface ResultProgressReporter<R> {
report(data: R): void;
}
export declare function attachPartialResult<R>(connection: ProgressContext, params: PartialResultParams): ResultProgressReporter<R> | undefined;

View File

@@ -0,0 +1,749 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConnection = exports.combineFeatures = exports.combineNotebooksFeatures = exports.combineLanguagesFeatures = exports.combineWorkspaceFeatures = exports.combineWindowFeatures = exports.combineClientFeatures = exports.combineTracerFeatures = exports.combineTelemetryFeatures = exports.combineConsoleFeatures = exports._NotebooksImpl = exports._LanguagesImpl = exports.BulkUnregistration = exports.BulkRegistration = exports.ErrorMessageTracker = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const Is = require("./utils/is");
const UUID = require("./utils/uuid");
const progress_1 = require("./progress");
const configuration_1 = require("./configuration");
const workspaceFolder_1 = require("./workspaceFolder");
const callHierarchy_1 = require("./callHierarchy");
const semanticTokens_1 = require("./semanticTokens");
const showDocument_1 = require("./showDocument");
const fileOperations_1 = require("./fileOperations");
const linkedEditingRange_1 = require("./linkedEditingRange");
const typeHierarchy_1 = require("./typeHierarchy");
const inlineValue_1 = require("./inlineValue");
const foldingRange_1 = require("./foldingRange");
// import { InlineCompletionFeatureShape, InlineCompletionFeature } from './inlineCompletion.proposed';
const inlayHint_1 = require("./inlayHint");
const diagnostic_1 = require("./diagnostic");
const notebook_1 = require("./notebook");
const moniker_1 = require("./moniker");
function null2Undefined(value) {
if (value === null) {
return undefined;
}
return value;
}
/**
* Helps tracking error message. Equal occurrences of the same
* message are only stored once. This class is for example
* useful if text documents are validated in a loop and equal
* error message should be folded into one.
*/
class ErrorMessageTracker {
constructor() {
this._messages = Object.create(null);
}
/**
* Add a message to the tracker.
*
* @param message The message to add.
*/
add(message) {
let count = this._messages[message];
if (!count) {
count = 0;
}
count++;
this._messages[message] = count;
}
/**
* Send all tracked messages to the connection's window.
*
* @param connection The connection established between client and server.
*/
sendErrors(connection) {
Object.keys(this._messages).forEach(message => {
connection.window.showErrorMessage(message);
});
}
}
exports.ErrorMessageTracker = ErrorMessageTracker;
class RemoteConsoleImpl {
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);
}
debug(message) {
this.send(vscode_languageserver_protocol_1.MessageType.Debug, message);
}
send(type, message) {
if (this._rawConnection) {
this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message }).catch(() => {
(0, vscode_languageserver_protocol_1.RAL)().console.error(`Sending log message failed`);
});
}
}
}
class _RemoteWindowImpl {
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);
}
}
const RemoteWindowImpl = (0, showDocument_1.ShowDocumentFeature)((0, progress_1.ProgressFeature)(_RemoteWindowImpl));
var BulkRegistration;
(function (BulkRegistration) {
/**
* Creates a new bulk registration.
* @return an empty bulk registration.
*/
function create() {
return new BulkRegistrationImpl();
}
BulkRegistration.create = create;
})(BulkRegistration || (exports.BulkRegistration = BulkRegistration = {}));
class BulkRegistrationImpl {
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: id,
method: method,
registerOptions: registerOptions || {}
});
this._registered.add(method);
}
asRegistrationParams() {
return {
registrations: this._registrations
};
}
}
var BulkUnregistration;
(function (BulkUnregistration) {
function create() {
return new BulkUnregistrationImpl(undefined, []);
}
BulkUnregistration.create = create;
})(BulkUnregistration || (exports.BulkUnregistration = BulkUnregistration = {}));
class BulkUnregistrationImpl {
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).catch(() => {
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;
}
}
class RemoteClientImpl {
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: id, method: 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).catch(() => { this.connection.console.info(`Un-registering capability with id ${id} failed.`); });
});
}, (_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).catch(() => {
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);
});
}
}
class _RemoteWorkspaceImpl {
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);
}
}
const RemoteWorkspaceImpl = (0, fileOperations_1.FileOperationsFeature)((0, workspaceFolder_1.WorkspaceFoldersFeature)((0, configuration_1.ConfigurationFeature)(_RemoteWorkspaceImpl)));
class TracerImpl {
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: message,
verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
}).catch(() => {
// Very hard to decide what to do. We tried to send a log
// message which failed so we can't simply send another :-(.
});
}
}
class TelemetryImpl {
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).catch(() => {
this.connection.console.log(`Sending TelemetryEventNotification failed`);
});
}
}
class _LanguagesImpl {
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 (0, progress_1.attachWorkDone)(this.connection, params);
}
attachPartialResultProgress(_type, params) {
return (0, progress_1.attachPartialResult)(this.connection, params);
}
}
exports._LanguagesImpl = _LanguagesImpl;
const LanguagesImpl = (0, foldingRange_1.FoldingRangeFeature)((0, moniker_1.MonikerFeature)((0, diagnostic_1.DiagnosticFeature)((0, inlayHint_1.InlayHintFeature)((0, inlineValue_1.InlineValueFeature)((0, typeHierarchy_1.TypeHierarchyFeature)((0, linkedEditingRange_1.LinkedEditingRangeFeature)((0, semanticTokens_1.SemanticTokensFeature)((0, callHierarchy_1.CallHierarchyFeature)(_LanguagesImpl)))))))));
class _NotebooksImpl {
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 (0, progress_1.attachWorkDone)(this.connection, params);
}
attachPartialResultProgress(_type, params) {
return (0, progress_1.attachPartialResult)(this.connection, params);
}
}
exports._NotebooksImpl = _NotebooksImpl;
const NotebooksImpl = (0, notebook_1.NotebookSyncFeature)(_NotebooksImpl);
function combineConsoleFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineConsoleFeatures = combineConsoleFeatures;
function combineTelemetryFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineTelemetryFeatures = combineTelemetryFeatures;
function combineTracerFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineTracerFeatures = combineTracerFeatures;
function combineClientFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineClientFeatures = combineClientFeatures;
function combineWindowFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineWindowFeatures = combineWindowFeatures;
function combineWorkspaceFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
function combineLanguagesFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineLanguagesFeatures = combineLanguagesFeatures;
function combineNotebooksFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
exports.combineNotebooksFeatures = combineNotebooksFeatures;
function combineFeatures(one, two) {
function combine(one, two, func) {
if (one && two) {
return func(one, two);
}
else if (one) {
return one;
}
else {
return two;
}
}
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),
languages: combine(one.languages, two.languages, combineLanguagesFeatures),
notebooks: combine(one.notebooks, two.notebooks, combineNotebooksFeatures)
};
return result;
}
exports.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 notebooks = (factories && factories.notebooks ? new (factories.notebooks(NotebooksImpl))() : new NotebooksImpl());
const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages, notebooks];
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 = undefined;
let initializeHandler = undefined;
let exitHandler = undefined;
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;
return connection.sendNotification(method, param);
},
onNotification: (type, handler) => connection.onNotification(type, handler),
onProgress: connection.onProgress,
sendProgress: connection.sendProgress,
onInitialize: (handler) => {
initializeHandler = handler;
return {
dispose: () => {
initializeHandler = undefined;
}
};
},
onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
onShutdown: (handler) => {
shutdownHandler = handler;
return {
dispose: () => {
shutdownHandler = undefined;
}
};
},
onExit: (handler) => {
exitHandler = handler;
return {
dispose: () => {
exitHandler = undefined;
}
};
},
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; },
get notebooks() { return notebooks; },
onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
__textDocumentSync: undefined,
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, (0, progress_1.attachWorkDone)(connection, params), undefined);
}),
onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, 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, (0, progress_1.attachWorkDone)(connection, params), undefined);
}),
onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onWorkspaceSymbolResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolResolveRequest.type, handler),
onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, 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, (0, progress_1.attachWorkDone)(connection, params), (0, 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, (0, progress_1.attachWorkDone)(connection, params), undefined);
}),
onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
}),
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, (0, progress_1.attachWorkDone)(connection, params), undefined);
}),
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, (0, progress_1.attachWorkDone)(connection, params), (0, 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, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), (0, progress_1.attachPartialResult)(connection, params));
}),
onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
return handler(params, cancel, (0, progress_1.attachWorkDone)(connection, params), undefined);
}),
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, (0, progress_1.attachWorkDone)(connection, params), undefined);
return asPromise(result).then((value) => {
if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
return value;
}
let result = value;
if (!result) {
result = { capabilities: {} };
}
let capabilities = result.capabilities;
if (!capabilities) {
capabilities = {};
result.capabilities = capabilities;
}
if (capabilities.textDocumentSync === undefined || 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 result;
});
}
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 undefined;
}
});
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;
}
exports.createConnection = createConnection;

View File

@@ -0,0 +1,6 @@
import { ShowDocumentParams, ShowDocumentResult } from 'vscode-languageserver-protocol';
import type { Feature, _RemoteWindow } from './server';
export interface ShowDocumentFeatureShape {
showDocument(params: ShowDocumentParams): Promise<ShowDocumentResult>;
}
export declare const ShowDocumentFeature: Feature<_RemoteWindow, ShowDocumentFeatureShape>;

View File

@@ -0,0 +1,34 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeHierarchyFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const TypeHierarchyFeature = (Base) => {
return class extends Base {
get typeHierarchy() {
return {
onPrepare: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.TypeHierarchyPrepareRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
});
},
onSupertypes: (handler) => {
const type = vscode_languageserver_protocol_1.TypeHierarchySupertypesRequest.type;
return this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
},
onSubtypes: (handler) => {
const type = vscode_languageserver_protocol_1.TypeHierarchySubtypesRequest.type;
return this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
}
};
}
};
};
exports.TypeHierarchyFeature = TypeHierarchyFeature;

View File

@@ -0,0 +1,19 @@
/**
* @deprecated Use the `vscode-uri` npm module which provides a more
* complete implementation of handling VS Code URIs.
*/
export declare function uriToFilePath(uri: string): string | undefined;
export declare function resolve(moduleName: string, nodePath: string | undefined, cwd: string | undefined, tracer: (message: string, verbose?: string) => void): Promise<string>;
/**
* Resolve the global npm package path.
* @deprecated Since this depends on the used package manager and their version the best is that servers
* implement this themselves since they know best what kind of package managers to support.
* @param tracer the tracer to use
*/
export declare function resolveGlobalNodePath(tracer?: (message: string) => void): string | undefined;
export declare function resolveGlobalYarnPath(tracer?: (message: string) => void): string | undefined;
export declare namespace FileSystem {
function isCaseSensitive(): boolean;
function isParent(parent: string, child: string): boolean;
}
export declare function resolveModulePath(workspaceRoot: string, moduleName: string, nodePath: string, tracer: (message: string, verbose?: string) => void): Promise<string>;

5
frontend/node_modules/vscode-languageserver/node.cmd generated vendored Normal file
View File

@@ -0,0 +1,5 @@
@echo off
REM This file is necessary to ensure that under Windows we don't
REM run the node.js file in the Windows Script Host when using
REM node in packakge.json scripts. See also PATHEXT setting
node.exe %*

View File

@@ -0,0 +1,42 @@
{
"name": "vscode-languageserver",
"description": "Language server implementation for node",
"version": "9.0.1",
"author": "Microsoft Corporation",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-languageserver-node.git",
"directory": "server"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"main": "./lib/node/main.js",
"browser": {
"./lib/node/main.js": "./lib/browser/main.js"
},
"typings": "./lib/common/api.d.ts",
"bin": {
"installServerIntoExtension": "./bin/installServerIntoExtension"
},
"devDependencies": {
"vscode-languageserver-textdocument": "1.0.11"
},
"dependencies": {
"vscode-languageserver-protocol": "3.17.5"
},
"scripts": {
"prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail",
"prepack": "npm run all:publish",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"clean": "node ../node_modules/.bin/rimraf lib",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "node ../node_modules/mocha/bin/_mocha",
"all": "npm run clean && npm run compile && npm run lint && npm test",
"compile:publish": "node ../build/bin/tsc -b ./tsconfig.publish.json",
"all:publish": "git clean -xfd . && npm install && npm run compile:publish && npm run lint && npm test",
"preversion": "npm test"
}
}