🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

View file

@ -0,0 +1,20 @@
import { MessageReader, MessageWriter, ConnectionStrategy, ConnectionOptions, Connection, Features, _Connection, _ } from '../common/api';
export * from 'vscode-languageserver-protocol/browser';
export * from '../common/api';
/**
* Creates a new connection.
*
* @param factories: The factories for proposed features.
* @param reader The message reader to read messages from.
* @param writer The message writer to write message to.
* @param options An optional connection strategy or connection options to control additional settings
*/
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>, reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>;
/**
* Creates a new connection.
*
* @param reader The message reader to read messages from.
* @param writer The message writer to write message to.
* @param options An optional connection strategy or connection options to control additional settings
*/
export declare function createConnection(reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): Connection;

62
node_modules/vscode-languageserver/lib/browser/main.js generated vendored Normal file
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;

15
node_modules/vscode-languageserver/lib/common/api.d.ts generated vendored Normal file
View file

@ -0,0 +1,15 @@
import { _, Features, _Connection } from './server';
import { SemanticTokensBuilder } from './semanticTokens';
import type { WorkDoneProgressReporter, WorkDoneProgressServerReporter, ResultProgressReporter } from './progress';
export * from 'vscode-languageserver-protocol/';
export { WorkDoneProgressReporter, WorkDoneProgressServerReporter, ResultProgressReporter };
export { SemanticTokensBuilder };
import { TextDocuments, TextDocumentsConfiguration, TextDocumentChangeEvent, TextDocumentWillSaveEvent } from './textDocuments';
export { TextDocuments, TextDocumentsConfiguration, TextDocumentChangeEvent, TextDocumentWillSaveEvent };
import { NotebookDocuments } from './notebook';
export { NotebookDocuments };
export * from './server';
export declare namespace ProposedFeatures {
const all: Features<_, _, _, _, _, _, _, _>;
type Connection = _Connection<_, _, _, _, _, _, _, _>;
}

35
node_modules/vscode-languageserver/lib/common/api.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
"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.ProposedFeatures = exports.NotebookDocuments = exports.TextDocuments = exports.SemanticTokensBuilder = void 0;
const semanticTokens_1 = require("./semanticTokens");
Object.defineProperty(exports, "SemanticTokensBuilder", { enumerable: true, get: function () { return semanticTokens_1.SemanticTokensBuilder; } });
__exportStar(require("vscode-languageserver-protocol/"), exports);
const textDocuments_1 = require("./textDocuments");
Object.defineProperty(exports, "TextDocuments", { enumerable: true, get: function () { return textDocuments_1.TextDocuments; } });
const notebook_1 = require("./notebook");
Object.defineProperty(exports, "NotebookDocuments", { enumerable: true, get: function () { return notebook_1.NotebookDocuments; } });
__exportStar(require("./server"), exports);
var ProposedFeatures;
(function (ProposedFeatures) {
ProposedFeatures.all = {
__brand: 'features',
};
})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));

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,9 @@
import { ConfigurationItem } from 'vscode-languageserver-protocol';
import type { Feature, _RemoteWorkspace } from './server';
export interface Configuration {
getConfiguration(): Promise<any>;
getConfiguration(section: string): Promise<any>;
getConfiguration(item: ConfigurationItem): Promise<any>;
getConfiguration(items: ConfigurationItem[]): Promise<any[]>;
}
export declare const ConfigurationFeature: Feature<_RemoteWorkspace, Configuration>;

View file

@ -0,0 +1,38 @@
"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.ConfigurationFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const Is = require("./utils/is");
const 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) => {
if (Array.isArray(result)) {
return Array.isArray(arg) ? result : result[0];
}
else {
return Array.isArray(arg) ? [] : null;
}
});
}
};
};
exports.ConfigurationFeature = ConfigurationFeature;

View file

@ -0,0 +1,29 @@
import { Disposable, DocumentDiagnosticParams, DocumentDiagnosticReport, DocumentDiagnosticReportPartialResult, DiagnosticServerCancellationData, WorkspaceDiagnosticParams, WorkspaceDiagnosticReport, WorkspaceDiagnosticReportPartialResult } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the linked editing feature
*
* @since 3.16.0
*/
export interface DiagnosticFeatureShape {
diagnostics: {
/**
* Asks the client to refresh all diagnostics provided by this server by
* pull for the corresponding documents again.
*/
refresh(): void;
/**
* Installs a handler for the document diagnostic request.
*
* @param handler The corresponding handler.
*/
on(handler: ServerRequestHandler<DocumentDiagnosticParams, DocumentDiagnosticReport, DocumentDiagnosticReportPartialResult, DiagnosticServerCancellationData>): Disposable;
/**
* Installs a handler for the workspace diagnostic request.
*
* @param handler The corresponding handler.
*/
onWorkspace(handler: ServerRequestHandler<WorkspaceDiagnosticParams, WorkspaceDiagnosticReport, WorkspaceDiagnosticReportPartialResult, DiagnosticServerCancellationData>): Disposable;
};
}
export declare const DiagnosticFeature: Feature<_Languages, DiagnosticFeatureShape>;

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,16 @@
import { RequestHandler, NotificationHandler, WorkspaceEdit, CreateFilesParams, RenameFilesParams, DeleteFilesParams, Disposable } from 'vscode-languageserver-protocol';
import type { Feature, _RemoteWorkspace } from './server';
/**
* Shape of the file operations feature
*
* @since 3.16.0
*/
export interface FileOperationsFeatureShape {
onDidCreateFiles(handler: NotificationHandler<CreateFilesParams>): Disposable;
onDidRenameFiles(handler: NotificationHandler<RenameFilesParams>): Disposable;
onDidDeleteFiles(handler: NotificationHandler<DeleteFilesParams>): Disposable;
onWillCreateFiles(handler: RequestHandler<CreateFilesParams, WorkspaceEdit | null, never>): Disposable;
onWillRenameFiles(handler: RequestHandler<RenameFilesParams, WorkspaceEdit | null, never>): Disposable;
onWillDeleteFiles(handler: RequestHandler<DeleteFilesParams, WorkspaceEdit | null, never>): Disposable;
}
export declare const FileOperationsFeature: Feature<_RemoteWorkspace, FileOperationsFeatureShape>;

View file

@ -0,0 +1,43 @@
"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.FileOperationsFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const FileOperationsFeature = (Base) => {
return class extends Base {
onDidCreateFiles(handler) {
return this.connection.onNotification(vscode_languageserver_protocol_1.DidCreateFilesNotification.type, (params) => {
handler(params);
});
}
onDidRenameFiles(handler) {
return this.connection.onNotification(vscode_languageserver_protocol_1.DidRenameFilesNotification.type, (params) => {
handler(params);
});
}
onDidDeleteFiles(handler) {
return 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);
});
}
};
};
exports.FileOperationsFeature = FileOperationsFeature;

View file

@ -0,0 +1,28 @@
import { InlayHint, InlayHintParams, Disposable, RequestHandler } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the inlay hints feature
*
* @since 3.17.0
*/
export interface InlayHintFeatureShape {
inlayHint: {
/**
* Ask the client to refresh all inlay hints.
*/
refresh(): Promise<void>;
/**
* Installs a handler for the inlay hints request.
*
* @param handler The corresponding handler.
*/
on(handler: ServerRequestHandler<InlayHintParams, InlayHint[] | undefined | null, InlayHint[], void>): Disposable;
/**
* Installs a handler for the inlay hint resolve request.
*
* @param handler The corresponding handler.
*/
resolve(handler: RequestHandler<InlayHint, InlayHint, void>): Disposable;
};
}
export declare const InlayHintFeature: Feature<_Languages, InlayHintFeatureShape>;

View file

@ -0,0 +1,30 @@
/* --------------------------------------------------------------------------------------------
* 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.InlayHintFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const InlayHintFeature = (Base) => {
return class extends Base {
get inlayHint() {
return {
refresh: () => {
return this.connection.sendRequest(vscode_languageserver_protocol_1.InlayHintRefreshRequest.type);
},
on: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.InlayHintRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params));
});
},
resolve: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.InlayHintResolveRequest.type, (params, cancel) => {
return handler(params, cancel);
});
}
};
}
};
};
exports.InlayHintFeature = InlayHintFeature;

View file

@ -0,0 +1,22 @@
import { InlineValue, Disposable, InlineValueParams } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the inline values feature
*
* @since 3.17.0
*/
export interface InlineValueFeatureShape {
inlineValue: {
/**
* Ask the client to refresh all inline values.
*/
refresh(): Promise<void>;
/**
* Installs a handler for the inline values request.
*
* @param handler The corresponding handler.
*/
on(handler: ServerRequestHandler<InlineValueParams, InlineValue[] | undefined | null, InlineValue[], void>): Disposable;
};
}
export declare const InlineValueFeature: Feature<_Languages, InlineValueFeatureShape>;

View file

@ -0,0 +1,25 @@
/* --------------------------------------------------------------------------------------------
* 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.InlineValueFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const InlineValueFeature = (Base) => {
return class extends Base {
get inlineValue() {
return {
refresh: () => {
return this.connection.sendRequest(vscode_languageserver_protocol_1.InlineValueRefreshRequest.type);
},
on: (handler) => {
return this.connection.onRequest(vscode_languageserver_protocol_1.InlineValueRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params));
});
}
};
}
};
};
exports.InlineValueFeature = InlineValueFeature;

View file

@ -0,0 +1,16 @@
import { LinkedEditingRangeParams, LinkedEditingRanges, Disposable } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the linked editing feature
*
* @since 3.16.0
*/
export interface LinkedEditingRangeFeatureShape {
/**
* Installs a handler for the linked editing range request.
*
* @param handler The corresponding handler.
*/
onLinkedEditingRange(handler: ServerRequestHandler<LinkedEditingRangeParams, LinkedEditingRanges | undefined | null, never, never>): Disposable;
}
export declare const LinkedEditingRangeFeature: Feature<_Languages, LinkedEditingRangeFeatureShape>;

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,13 @@
import { MonikerParams, Moniker, Disposable } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the moniker feature
*
* @since 3.16.0
*/
export interface MonikerFeatureShape {
moniker: {
on(handler: ServerRequestHandler<MonikerParams, Moniker[] | null, Moniker[], void>): Disposable;
};
}
export declare const MonikerFeature: Feature<_Languages, MonikerFeatureShape>;

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,99 @@
import { NotificationHandler1, Event, DocumentUri, URI, Disposable, DidOpenNotebookDocumentParams, DidChangeNotebookDocumentParams, DidSaveNotebookDocumentParams, DidCloseNotebookDocumentParams, NotebookDocument, NotebookCell, LSPObject } from 'vscode-languageserver-protocol';
import type { Feature, _Notebooks, Connection } from './server';
import { TextDocuments, TextDocumentsConfiguration } from './textDocuments';
/**
* Shape of the notebooks feature
*
* @since 3.17.0
*/
export interface NotebookSyncFeatureShape {
synchronization: {
onDidOpenNotebookDocument(handler: NotificationHandler1<DidOpenNotebookDocumentParams>): Disposable;
onDidChangeNotebookDocument(handler: NotificationHandler1<DidChangeNotebookDocumentParams>): Disposable;
onDidSaveNotebookDocument(handler: NotificationHandler1<DidSaveNotebookDocumentParams>): Disposable;
onDidCloseNotebookDocument(handler: NotificationHandler1<DidCloseNotebookDocumentParams>): Disposable;
};
}
export declare const NotebookSyncFeature: Feature<_Notebooks, NotebookSyncFeatureShape>;
export declare type NotebookDocumentChangeEvent = {
/**
* The notebook document that changed.
*/
notebookDocument: NotebookDocument;
/**
* The meta data change if any.
*
* Note: old and new should always be an object literal (e.g. LSPObject)
*/
metadata?: {
old: LSPObject | undefined;
new: LSPObject | undefined;
};
/**
* The cell changes if any.
*/
cells?: {
/**
* The cells that got added.
*/
added: NotebookCell[];
/**
* The cells that got removed.
*/
removed: NotebookCell[];
/**
* The cells that changed.
*/
changed: {
/**
* The cell data has changed, excluding its
* text content which is reported via
* `textContentChanged`.
*/
data: {
old: NotebookCell;
new: NotebookCell;
}[];
/**
* The text content of a cell has changed.
* The actual text is available via the `Notebooks`
* text document manager.
*/
textContent: NotebookCell[];
};
};
};
export declare class NotebookDocuments<T extends {
uri: DocumentUri;
}> {
private readonly notebookDocuments;
private readonly notebookCellMap;
private readonly _onDidOpen;
private readonly _onDidSave;
private readonly _onDidChange;
private readonly _onDidClose;
private _cellTextDocuments;
constructor(configurationOrTextDocuments: TextDocumentsConfiguration<T> | TextDocuments<T>);
get cellTextDocuments(): TextDocuments<T>;
getCellTextDocument(cell: NotebookCell): T | undefined;
getNotebookDocument(uri: URI): NotebookDocument | undefined;
getNotebookCell(uri: DocumentUri): NotebookCell | undefined;
findNotebookDocumentForCell(cell: DocumentUri | NotebookCell): NotebookDocument | undefined;
get onDidOpen(): Event<NotebookDocument>;
get onDidSave(): Event<NotebookDocument>;
get onDidChange(): Event<NotebookDocumentChangeEvent>;
get onDidClose(): Event<NotebookDocument>;
/**
* Listens for `low level` notification on the given connection to
* update the notebook documents managed by this instance.
*
* Please note that the connection only provides handlers not an event model. Therefore
* listening on a connection will overwrite the following handlers on a connection:
* `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
* and `onDidCloseNotebookDocument`.
*
* @param connection The connection to listen on.
*/
listen(connection: Connection): Disposable;
private updateCellMap;
}

View file

@ -0,0 +1,252 @@
/* --------------------------------------------------------------------------------------------
* 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.NotebookDocuments = exports.NotebookSyncFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const textDocuments_1 = require("./textDocuments");
const NotebookSyncFeature = (Base) => {
return class extends Base {
get synchronization() {
return {
onDidOpenNotebookDocument: (handler) => {
return this.connection.onNotification(vscode_languageserver_protocol_1.DidOpenNotebookDocumentNotification.type, (params) => {
handler(params);
});
},
onDidChangeNotebookDocument: (handler) => {
return this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeNotebookDocumentNotification.type, (params) => {
handler(params);
});
},
onDidSaveNotebookDocument: (handler) => {
return this.connection.onNotification(vscode_languageserver_protocol_1.DidSaveNotebookDocumentNotification.type, (params) => {
handler(params);
});
},
onDidCloseNotebookDocument: (handler) => {
return this.connection.onNotification(vscode_languageserver_protocol_1.DidCloseNotebookDocumentNotification.type, (params) => {
handler(params);
});
}
};
}
};
};
exports.NotebookSyncFeature = NotebookSyncFeature;
class CellTextDocumentConnection {
onDidOpenTextDocument(handler) {
this.openHandler = handler;
return vscode_languageserver_protocol_1.Disposable.create(() => { this.openHandler = undefined; });
}
openTextDocument(params) {
this.openHandler && this.openHandler(params);
}
onDidChangeTextDocument(handler) {
this.changeHandler = handler;
return vscode_languageserver_protocol_1.Disposable.create(() => { this.changeHandler = handler; });
}
changeTextDocument(params) {
this.changeHandler && this.changeHandler(params);
}
onDidCloseTextDocument(handler) {
this.closeHandler = handler;
return vscode_languageserver_protocol_1.Disposable.create(() => { this.closeHandler = undefined; });
}
closeTextDocument(params) {
this.closeHandler && this.closeHandler(params);
}
onWillSaveTextDocument() {
return CellTextDocumentConnection.NULL_DISPOSE;
}
onWillSaveTextDocumentWaitUntil() {
return CellTextDocumentConnection.NULL_DISPOSE;
}
onDidSaveTextDocument() {
return CellTextDocumentConnection.NULL_DISPOSE;
}
}
CellTextDocumentConnection.NULL_DISPOSE = Object.freeze({ dispose: () => { } });
class NotebookDocuments {
constructor(configurationOrTextDocuments) {
if (configurationOrTextDocuments instanceof textDocuments_1.TextDocuments) {
this._cellTextDocuments = configurationOrTextDocuments;
}
else {
this._cellTextDocuments = new textDocuments_1.TextDocuments(configurationOrTextDocuments);
}
this.notebookDocuments = new Map();
this.notebookCellMap = new Map();
this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
this._onDidChange = new vscode_languageserver_protocol_1.Emitter();
this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
}
get cellTextDocuments() {
return this._cellTextDocuments;
}
getCellTextDocument(cell) {
return this._cellTextDocuments.get(cell.document);
}
getNotebookDocument(uri) {
return this.notebookDocuments.get(uri);
}
getNotebookCell(uri) {
const value = this.notebookCellMap.get(uri);
return value && value[0];
}
findNotebookDocumentForCell(cell) {
const key = typeof cell === 'string' ? cell : cell.document;
const value = this.notebookCellMap.get(key);
return value && value[1];
}
get onDidOpen() {
return this._onDidOpen.event;
}
get onDidSave() {
return this._onDidSave.event;
}
get onDidChange() {
return this._onDidChange.event;
}
get onDidClose() {
return this._onDidClose.event;
}
/**
* Listens for `low level` notification on the given connection to
* update the notebook documents managed by this instance.
*
* Please note that the connection only provides handlers not an event model. Therefore
* listening on a connection will overwrite the following handlers on a connection:
* `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
* and `onDidCloseNotebookDocument`.
*
* @param connection The connection to listen on.
*/
listen(connection) {
const cellTextDocumentConnection = new CellTextDocumentConnection();
const disposables = [];
disposables.push(this.cellTextDocuments.listen(cellTextDocumentConnection));
disposables.push(connection.notebooks.synchronization.onDidOpenNotebookDocument((params) => {
this.notebookDocuments.set(params.notebookDocument.uri, params.notebookDocument);
for (const cellTextDocument of params.cellTextDocuments) {
cellTextDocumentConnection.openTextDocument({ textDocument: cellTextDocument });
}
this.updateCellMap(params.notebookDocument);
this._onDidOpen.fire(params.notebookDocument);
}));
disposables.push(connection.notebooks.synchronization.onDidChangeNotebookDocument((params) => {
const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
if (notebookDocument === undefined) {
return;
}
notebookDocument.version = params.notebookDocument.version;
const oldMetadata = notebookDocument.metadata;
let metadataChanged = false;
const change = params.change;
if (change.metadata !== undefined) {
metadataChanged = true;
notebookDocument.metadata = change.metadata;
}
const opened = [];
const closed = [];
const data = [];
const text = [];
if (change.cells !== undefined) {
const changedCells = change.cells;
if (changedCells.structure !== undefined) {
const array = changedCells.structure.array;
notebookDocument.cells.splice(array.start, array.deleteCount, ...(array.cells !== undefined ? array.cells : []));
// Additional open cell text documents.
if (changedCells.structure.didOpen !== undefined) {
for (const open of changedCells.structure.didOpen) {
cellTextDocumentConnection.openTextDocument({ textDocument: open });
opened.push(open.uri);
}
}
// Additional closed cell test documents.
if (changedCells.structure.didClose) {
for (const close of changedCells.structure.didClose) {
cellTextDocumentConnection.closeTextDocument({ textDocument: close });
closed.push(close.uri);
}
}
}
if (changedCells.data !== undefined) {
const cellUpdates = new Map(changedCells.data.map(cell => [cell.document, cell]));
for (let i = 0; i <= notebookDocument.cells.length; i++) {
const change = cellUpdates.get(notebookDocument.cells[i].document);
if (change !== undefined) {
const old = notebookDocument.cells.splice(i, 1, change);
data.push({ old: old[0], new: change });
cellUpdates.delete(change.document);
if (cellUpdates.size === 0) {
break;
}
}
}
}
if (changedCells.textContent !== undefined) {
for (const cellTextDocument of changedCells.textContent) {
cellTextDocumentConnection.changeTextDocument({ textDocument: cellTextDocument.document, contentChanges: cellTextDocument.changes });
text.push(cellTextDocument.document.uri);
}
}
}
// Update internal data structure.
this.updateCellMap(notebookDocument);
const changeEvent = { notebookDocument };
if (metadataChanged) {
changeEvent.metadata = { old: oldMetadata, new: notebookDocument.metadata };
}
const added = [];
for (const open of opened) {
added.push(this.getNotebookCell(open));
}
const removed = [];
for (const close of closed) {
removed.push(this.getNotebookCell(close));
}
const textContent = [];
for (const change of text) {
textContent.push(this.getNotebookCell(change));
}
if (added.length > 0 || removed.length > 0 || data.length > 0 || textContent.length > 0) {
changeEvent.cells = { added, removed, changed: { data, textContent } };
}
if (changeEvent.metadata !== undefined || changeEvent.cells !== undefined) {
this._onDidChange.fire(changeEvent);
}
}));
disposables.push(connection.notebooks.synchronization.onDidSaveNotebookDocument((params) => {
const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
if (notebookDocument === undefined) {
return;
}
this._onDidSave.fire(notebookDocument);
}));
disposables.push(connection.notebooks.synchronization.onDidCloseNotebookDocument((params) => {
const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
if (notebookDocument === undefined) {
return;
}
this._onDidClose.fire(notebookDocument);
for (const cellTextDocument of params.cellTextDocuments) {
cellTextDocumentConnection.closeTextDocument({ textDocument: cellTextDocument });
}
this.notebookDocuments.delete(params.notebookDocument.uri);
for (const cell of notebookDocument.cells) {
this.notebookCellMap.delete(cell.document);
}
}));
return vscode_languageserver_protocol_1.Disposable.create(() => { disposables.forEach(disposable => disposable.dispose()); });
}
updateCellMap(notebookDocument) {
for (const cell of notebookDocument.cells) {
this.notebookCellMap.set(cell.document, [cell, notebookDocument]);
}
}
}
exports.NotebookDocuments = NotebookDocuments;

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,159 @@
"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.attachPartialResult = exports.ProgressFeature = exports.attachWorkDone = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const uuid_1 = require("./utils/uuid");
class WorkDoneProgressReporterImpl {
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 !== undefined) {
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();
class WorkDoneProgressServerReporterImpl 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();
}
}
class NullProgressReporter {
constructor() {
}
begin() {
}
report() {
}
done() {
}
}
class NullProgressServerReporter 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 === undefined || params.workDoneToken === undefined) {
return new NullProgressReporter();
}
const token = params.workDoneToken;
delete params.workDoneToken;
return new WorkDoneProgressReporterImpl(connection, token);
}
exports.attachWorkDone = attachWorkDone;
const ProgressFeature = (Base) => {
return class extends Base {
constructor() {
super();
this._progressSupported = false;
}
initialize(capabilities) {
super.initialize(capabilities);
if (capabilities?.window?.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 === undefined) {
return new NullProgressReporter();
}
else {
return new WorkDoneProgressReporterImpl(this.connection, token);
}
}
createWorkDoneProgress() {
if (this._progressSupported) {
const token = (0, 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());
}
}
};
};
exports.ProgressFeature = ProgressFeature;
var ResultProgress;
(function (ResultProgress) {
ResultProgress.type = new vscode_languageserver_protocol_1.ProgressType();
})(ResultProgress || (ResultProgress = {}));
class ResultProgressReporterImpl {
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 === undefined || params.partialResultToken === undefined) {
return undefined;
}
const token = params.partialResultToken;
delete params.partialResultToken;
return new ResultProgressReporterImpl(connection, token);
}
exports.attachPartialResult = attachPartialResult;

View file

@ -0,0 +1,38 @@
import { SemanticTokens, SemanticTokensPartialResult, SemanticTokensDelta, SemanticTokensDeltaPartialResult, SemanticTokensParams, SemanticTokensDeltaParams, SemanticTokensRangeParams, SemanticTokensEdit, Disposable } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the semantic token feature
*
* @since 3.16.0
*/
export interface SemanticTokensFeatureShape {
semanticTokens: {
refresh(): void;
on(handler: ServerRequestHandler<SemanticTokensParams, SemanticTokens, SemanticTokensPartialResult, void>): Disposable;
onDelta(handler: ServerRequestHandler<SemanticTokensDeltaParams, SemanticTokensDelta | SemanticTokens, SemanticTokensDeltaPartialResult | SemanticTokensPartialResult, void>): Disposable;
onRange(handler: ServerRequestHandler<SemanticTokensRangeParams, SemanticTokens, SemanticTokensPartialResult, void>): Disposable;
};
}
export declare const SemanticTokensFeature: Feature<_Languages, SemanticTokensFeatureShape>;
export declare class SemanticTokensDiff {
private readonly originalSequence;
private readonly modifiedSequence;
constructor(originalSequence: number[], modifiedSequence: number[]);
computeDiff(): SemanticTokensEdit[];
}
export declare class SemanticTokensBuilder {
private _id;
private _prevLine;
private _prevChar;
private _data;
private _dataLen;
private _prevData;
constructor();
private initialize;
push(line: number, char: number, length: number, tokenType: number, tokenModifiers: number): void;
get id(): string;
previousResult(id: string): void;
build(): SemanticTokens;
canBuildEdits(): boolean;
buildEdits(): SemanticTokens | SemanticTokensDelta;
}

View file

@ -0,0 +1,154 @@
"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.SemanticTokensBuilder = exports.SemanticTokensDiff = exports.SemanticTokensFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const SemanticTokensFeature = (Base) => {
return class extends Base {
get semanticTokens() {
return {
refresh: () => {
return this.connection.sendRequest(vscode_languageserver_protocol_1.SemanticTokensRefreshRequest.type);
},
on: (handler) => {
const type = vscode_languageserver_protocol_1.SemanticTokensRequest.type;
return 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;
return 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;
return this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
}
};
}
};
};
exports.SemanticTokensFeature = SemanticTokensFeature;
class SemanticTokensDiff {
constructor(originalSequence, modifiedSequence) {
this.originalSequence = originalSequence;
this.modifiedSequence = modifiedSequence;
}
computeDiff() {
const originalLength = this.originalSequence.length;
const modifiedLength = this.modifiedSequence.length;
let startIndex = 0;
while (startIndex < modifiedLength && startIndex < originalLength && this.originalSequence[startIndex] === this.modifiedSequence[startIndex]) {
startIndex++;
}
if (startIndex < modifiedLength && startIndex < originalLength) {
let originalEndIndex = originalLength - 1;
let modifiedEndIndex = modifiedLength - 1;
while (originalEndIndex >= startIndex && modifiedEndIndex >= startIndex && this.originalSequence[originalEndIndex] === this.modifiedSequence[modifiedEndIndex]) {
originalEndIndex--;
modifiedEndIndex--;
}
// if one moved behind the start index move them forward again
if (originalEndIndex < startIndex || modifiedEndIndex < startIndex) {
originalEndIndex++;
modifiedEndIndex++;
}
const deleteCount = originalEndIndex - startIndex + 1;
const newData = this.modifiedSequence.slice(startIndex, modifiedEndIndex + 1);
// If we moved behind the start index we could have missed a simple delete.
if (newData.length === 1 && newData[0] === this.originalSequence[originalEndIndex]) {
return [
{ start: startIndex, deleteCount: deleteCount - 1 }
];
}
else {
return [
{ start: startIndex, deleteCount, data: newData }
];
}
}
else if (startIndex < modifiedLength) {
return [
{ start: startIndex, deleteCount: 0, data: this.modifiedSequence.slice(startIndex) }
];
}
else if (startIndex < originalLength) {
return [
{ start: startIndex, deleteCount: originalLength - startIndex }
];
}
else {
// The two arrays are the same.
return [];
}
}
}
exports.SemanticTokensDiff = SemanticTokensDiff;
class SemanticTokensBuilder {
constructor() {
this._prevData = undefined;
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 = undefined;
return {
resultId: this.id,
data: this._data
};
}
canBuildEdits() {
return this._prevData !== undefined;
}
buildEdits() {
if (this._prevData !== undefined) {
return {
resultId: this.id,
edits: (new SemanticTokensDiff(this._prevData, this._data)).computeDiff()
};
}
else {
return this.build();
}
}
}
exports.SemanticTokensBuilder = SemanticTokensBuilder;

View file

@ -0,0 +1,795 @@
import { CancellationToken, ProtocolRequestType0, RequestHandler0, ProtocolRequestType, RequestHandler, GenericRequestHandler, StarRequestHandler, HandlerResult, ProtocolNotificationType0, NotificationHandler0, ProtocolNotificationType, NotificationHandler, GenericNotificationHandler, StarNotificationHandler, ProgressType, Disposable, InitializeParams, InitializeResult, InitializeError, InitializedParams, DidChangeConfigurationParams, DidChangeWatchedFilesParams, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, WillSaveTextDocumentParams, TextEdit, DidSaveTextDocumentParams, PublishDiagnosticsParams, HoverParams, Hover, CompletionParams, CompletionItem, CompletionList, SignatureHelpParams, SignatureHelp, DeclarationParams, Declaration, DeclarationLink, Location, DefinitionParams, Definition, DefinitionLink, TypeDefinitionParams, ImplementationParams, ReferenceParams, DocumentHighlightParams, DocumentHighlight, DocumentSymbolParams, SymbolInformation, DocumentSymbol, WorkspaceSymbolParams, CodeActionParams, Command, CodeAction, CodeLensParams, CodeLens, DocumentFormattingParams, DocumentRangeFormattingParams, DocumentOnTypeFormattingParams, RenameParams, WorkspaceEdit, PrepareRenameParams, Range, DocumentLinkParams, DocumentLink, DocumentColorParams, ColorInformation, ColorPresentationParams, ColorPresentation, FoldingRangeParams, FoldingRange, SelectionRangeParams, SelectionRange, ExecuteCommandParams, MessageActionItem, ClientCapabilities, ServerCapabilities, Logger, ProtocolConnection, MessageSignature, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse, WorkDoneProgressParams, PartialResultParams, RegistrationType, RequestType0, RequestType, NotificationType0, NotificationType, WorkspaceSymbol } from 'vscode-languageserver-protocol';
import { WorkDoneProgressReporter, ResultProgressReporter, WindowProgress } from './progress';
import { Configuration } from './configuration';
import { WorkspaceFolders } from './workspaceFolder';
import { CallHierarchy } from './callHierarchy';
import { SemanticTokensFeatureShape } from './semanticTokens';
import { ShowDocumentFeatureShape } from './showDocument';
import { FileOperationsFeatureShape } from './fileOperations';
import { LinkedEditingRangeFeatureShape } from './linkedEditingRange';
import { TypeHierarchyFeatureShape } from './typeHierarchy';
import { InlineValueFeatureShape } from './inlineValue';
import { InlayHintFeatureShape } from './inlayHint';
import { DiagnosticFeatureShape } from './diagnostic';
import { NotebookSyncFeatureShape } from './notebook';
import { MonikerFeatureShape } from './moniker';
/**
* 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.
*/
export declare class ErrorMessageTracker {
private _messages;
constructor();
/**
* Add a message to the tracker.
*
* @param message The message to add.
*/
add(message: string): void;
/**
* Send all tracked messages to the connection's window.
*
* @param connection The connection established between client and server.
*/
sendErrors(connection: {
window: RemoteWindow;
}): void;
}
export interface FeatureBase {
/**
* Called to initialize the remote with the given
* client capabilities
*
* @param capabilities The client capabilities
*/
initialize(capabilities: ClientCapabilities): void;
/**
* Called to fill in the server capabilities this feature implements.
*
* @param capabilities The server capabilities to fill.
*/
fillServerCapabilities(capabilities: ServerCapabilities): void;
}
interface Remote extends FeatureBase {
/**
* Attach the remote to the given connection.
*
* @param connection The connection this remote is operating on.
*/
attach(connection: Connection): void;
/**
* The connection this remote is attached to.
*/
connection: Connection;
}
/**
* The RemoteConsole interface contains all functions to interact with
* the tools / clients console or log system. Internally it used `window/logMessage`
* notifications.
*/
export interface RemoteConsole extends FeatureBase {
/**
* The connection this remote is attached to.
*/
connection: Connection;
/**
* Show an error message.
*
* @param message The message to show.
*/
error(message: string): void;
/**
* Show a warning message.
*
* @param message The message to show.
*/
warn(message: string): void;
/**
* Show an information message.
*
* @param message The message to show.
*/
info(message: string): void;
/**
* Log a message.
*
* @param message The message to log.
*/
log(message: string): void;
}
/**
* The RemoteWindow interface contains all functions to interact with
* the visual window of VS Code.
*/
export interface _RemoteWindow extends FeatureBase {
/**
* The connection this remote is attached to.
*/
connection: Connection;
/**
* Shows an error message in the client's user interface. Depending on the client this might
* be a modal dialog with a confirmation button or a notification in a notification center
*
* @param message The message to show.
* @param actions Possible additional actions presented in the user interface. The selected action
* will be the value of the resolved promise
*/
showErrorMessage(message: string): void;
showErrorMessage<T extends MessageActionItem>(message: string, ...actions: T[]): Promise<T | undefined>;
/**
* Shows a warning message in the client's user interface. Depending on the client this might
* be a modal dialog with a confirmation button or a notification in a notification center
*
* @param message The message to show.
* @param actions Possible additional actions presented in the user interface. The selected action
* will be the value of the resolved promise
*/
showWarningMessage(message: string): void;
showWarningMessage<T extends MessageActionItem>(message: string, ...actions: T[]): Promise<T | undefined>;
/**
* Shows an information message in the client's user interface. Depending on the client this might
* be a modal dialog with a confirmation button or a notification in a notification center
*
* @param message The message to show.
* @param actions Possible additional actions presented in the user interface. The selected action
* will be the value of the resolved promise
*/
showInformationMessage(message: string): void;
showInformationMessage<T extends MessageActionItem>(message: string, ...actions: T[]): Promise<T | undefined>;
}
export declare type RemoteWindow = _RemoteWindow & WindowProgress & ShowDocumentFeatureShape;
/**
* A bulk registration manages n single registration to be able to register
* for n notifications or requests using one register request.
*/
export interface BulkRegistration {
/**
* Adds a single registration.
* @param type the notification type to register for.
* @param registerParams special registration parameters.
*/
add<RO>(type: ProtocolNotificationType0<RO>, registerParams: RO): void;
add<P, RO>(type: ProtocolNotificationType<P, RO>, registerParams: RO): void;
/**
* Adds a single registration.
* @param type the request type to register for.
* @param registerParams special registration parameters.
*/
add<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, registerParams: RO): void;
add<P, PR, R, E, RO>(type: ProtocolRequestType<P, PR, R, E, RO>, registerParams: RO): void;
/**
* Adds a single registration.
* @param type the notification type to register for.
* @param registerParams special registration parameters.
*/
add<RO>(type: RegistrationType<RO>, registerParams: RO): void;
}
export declare namespace BulkRegistration {
/**
* Creates a new bulk registration.
* @return an empty bulk registration.
*/
function create(): BulkRegistration;
}
/**
* A `BulkUnregistration` manages n unregistrations.
*/
export interface BulkUnregistration extends Disposable {
/**
* Disposes a single registration. It will be removed from the
* `BulkUnregistration`.
*/
disposeSingle(arg: string | MessageSignature): boolean;
}
export declare namespace BulkUnregistration {
function create(): BulkUnregistration;
}
/**
* Interface to register and unregister `listeners` on the client / tools side.
*/
export interface RemoteClient extends FeatureBase {
/**
* The connection this remote is attached to.
*/
connection: Connection;
/**
* Registers a listener for the given request.
*
* @param type the request type to register for.
* @param registerParams special registration parameters.
* @return a `Disposable` to unregister the listener again.
*/
register<P, RO>(type: ProtocolNotificationType<P, RO>, registerParams?: RO): Promise<Disposable>;
register<RO>(type: ProtocolNotificationType0<RO>, registerParams?: RO): Promise<Disposable>;
/**
* Registers a listener for the given request.
*
* @param unregisteration the unregistration to add a corresponding unregister action to.
* @param type the request type to register for.
* @param registerParams special registration parameters.
* @return the updated unregistration.
*/
register<P, RO>(unregisteration: BulkUnregistration, type: ProtocolNotificationType<P, RO>, registerParams?: RO): Promise<Disposable>;
register<RO>(unregisteration: BulkUnregistration, type: ProtocolNotificationType0<RO>, registerParams?: RO): Promise<Disposable>;
/**
* Registers a listener for the given request.
*
* @param type the request type to register for.
* @param registerParams special registration parameters.
* @return a `Disposable` to unregister the listener again.
*/
register<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, registerParams?: RO): Promise<Disposable>;
register<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, registerParams?: RO): Promise<Disposable>;
/**
* Registers a listener for the given request.
*
* @param unregisteration the unregistration to add a corresponding unregister action to.
* @param type the request type to register for.
* @param registerParams special registration parameters.
* @return the updated unregistration.
*/
register<P, R, PR, E, RO>(unregisteration: BulkUnregistration, type: ProtocolRequestType<P, R, PR, E, RO>, registerParams?: RO): Promise<Disposable>;
register<R, PR, E, RO>(unregisteration: BulkUnregistration, type: ProtocolRequestType0<R, PR, E, RO>, registerParams?: RO): Promise<Disposable>;
/**
* Registers a listener for the given registration type.
*
* @param type the registration type.
* @param registerParams special registration parameters.
* @return a `Disposable` to unregister the listener again.
*/
register<RO>(type: RegistrationType<RO>, registerParams?: RO): Promise<Disposable>;
/**
* Registers a listener for the given registration type.
*
* @param unregisteration the unregistration to add a corresponding unregister action to.
* @param type the registration type.
* @param registerParams special registration parameters.
* @return the updated unregistration.
*/
register<RO>(unregisteration: BulkUnregistration, type: RegistrationType<RO>, registerParams?: RO): Promise<Disposable>;
/**
* Registers a set of listeners.
* @param registrations the bulk registration
* @return a `Disposable` to unregister the listeners again.
*/
register(registrations: BulkRegistration): Promise<BulkUnregistration>;
}
/**
* Represents the workspace managed by the client.
*/
export interface _RemoteWorkspace extends FeatureBase {
/**
* The connection this remote is attached to.
*/
connection: Connection;
/**
* Applies a `WorkspaceEdit` to the workspace
* @param param the workspace edit params.
* @return a thenable that resolves to the `ApplyWorkspaceEditResponse`.
*/
applyEdit(paramOrEdit: ApplyWorkspaceEditParams | WorkspaceEdit): Promise<ApplyWorkspaceEditResponse>;
}
export declare type RemoteWorkspace = _RemoteWorkspace & Configuration & WorkspaceFolders & FileOperationsFeatureShape;
/**
* Interface to log telemetry events. The events are actually send to the client
* and the client needs to feed the event into a proper telemetry system.
*/
export interface Telemetry extends FeatureBase {
/**
* The connection this remote is attached to.
*/
connection: Connection;
/**
* Log the given data to telemetry.
*
* @param data The data to log. Must be a JSON serializable object.
*/
logEvent(data: any): void;
}
/**
* Interface to log traces to the client. The events are sent to the client and the
* client needs to log the trace events.
*/
export interface RemoteTracer extends FeatureBase {
/**
* The connection this remote is attached to.
*/
connection: Connection;
/**
* Log the given data to the trace Log
*/
log(message: string, verbose?: string): void;
}
export interface _Languages extends FeatureBase {
connection: Connection;
attachWorkDoneProgress(params: WorkDoneProgressParams): WorkDoneProgressReporter;
attachPartialResultProgress<PR>(type: ProgressType<PR>, params: PartialResultParams): ResultProgressReporter<PR> | undefined;
}
export declare class _LanguagesImpl implements Remote, _Languages {
private _connection;
constructor();
attach(connection: Connection): void;
get connection(): Connection;
initialize(_capabilities: ClientCapabilities): void;
fillServerCapabilities(_capabilities: ServerCapabilities): void;
attachWorkDoneProgress(params: WorkDoneProgressParams): WorkDoneProgressReporter;
attachPartialResultProgress<PR>(_type: ProgressType<PR>, params: PartialResultParams): ResultProgressReporter<PR> | undefined;
}
export declare type Languages = _Languages & CallHierarchy & SemanticTokensFeatureShape & LinkedEditingRangeFeatureShape & TypeHierarchyFeatureShape & InlineValueFeatureShape & InlayHintFeatureShape & DiagnosticFeatureShape & MonikerFeatureShape;
export interface _Notebooks extends FeatureBase {
connection: Connection;
attachWorkDoneProgress(params: WorkDoneProgressParams): WorkDoneProgressReporter;
attachPartialResultProgress<PR>(type: ProgressType<PR>, params: PartialResultParams): ResultProgressReporter<PR> | undefined;
}
export declare class _NotebooksImpl implements Remote, _Notebooks {
private _connection;
constructor();
attach(connection: Connection): void;
get connection(): Connection;
initialize(_capabilities: ClientCapabilities): void;
fillServerCapabilities(_capabilities: ServerCapabilities): void;
attachWorkDoneProgress(params: WorkDoneProgressParams): WorkDoneProgressReporter;
attachPartialResultProgress<PR>(_type: ProgressType<PR>, params: PartialResultParams): ResultProgressReporter<PR> | undefined;
}
export declare type Notebooks = _Notebooks & NotebookSyncFeatureShape;
/**
* An empty interface for new proposed API.
*/
export interface _ {
}
export interface ServerRequestHandler<P, R, PR, E> {
(params: P, token: CancellationToken, workDoneProgress: WorkDoneProgressReporter, resultProgress?: ResultProgressReporter<PR>): HandlerResult<R, E>;
}
/**
* Interface to describe the shape of the server connection.
*/
export interface _Connection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _> {
/**
* Start listening on the input stream for messages to process.
*/
listen(): void;
/**
* Installs a request handler described by the given {@link RequestType}.
*
* @param type The {@link RequestType} describing the request.
* @param handler The handler to install
*/
onRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, handler: RequestHandler0<R, E>): Disposable;
onRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, handler: RequestHandler<P, R, E>): Disposable;
onRequest<R, PR, E, RO>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable;
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): Disposable;
/**
* Installs a request handler for the given method.
*
* @param method The method to register a request handler for.
* @param handler The handler to install.
*/
onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): Disposable;
/**
* Installs a request handler that is invoked if no specific request handler can be found.
*
* @param handler a handler that handles all requests.
*/
onRequest(handler: StarRequestHandler): Disposable;
/**
* Send a request to the client.
*
* @param type The {@link RequestType} describing the request.
* @param params The request's parameters.
*/
sendRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, token?: CancellationToken): Promise<R>;
sendRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, params: P, token?: CancellationToken): Promise<R>;
sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>;
/**
* Send a request to the client.
*
* @param method The method to invoke on the client.
* @param params The request's parameters.
*/
sendRequest<R>(method: string, token?: CancellationToken): Promise<R>;
sendRequest<R>(method: string, params: any, token?: CancellationToken): Promise<R>;
/**
* Installs a notification handler described by the given {@link NotificationType}.
*
* @param type The {@link NotificationType} describing the notification.
* @param handler The handler to install.
*/
onNotification<RO>(type: ProtocolNotificationType0<RO>, handler: NotificationHandler0): Disposable;
onNotification<P, RO>(type: ProtocolNotificationType<P, RO>, handler: NotificationHandler<P>): Disposable;
onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable;
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): Disposable;
/**
* Installs a notification handler for the given method.
*
* @param method The method to register a request handler for.
* @param handler The handler to install.
*/
onNotification(method: string, handler: GenericNotificationHandler): Disposable;
/**
* Installs a notification handler that is invoked if no specific notification handler can be found.
*
* @param handler a handler that handles all notifications.
*/
onNotification(handler: StarNotificationHandler): Disposable;
/**
* Send a notification to the client.
*
* @param type The {@link NotificationType} describing the notification.
* @param params The notification's parameters.
*/
sendNotification<RO>(type: ProtocolNotificationType0<RO>): Promise<void>;
sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params: P): Promise<void>;
sendNotification(type: NotificationType0): Promise<void>;
sendNotification<P>(type: NotificationType<P>, params: P): Promise<void>;
/**
* Send a notification to the client.
*
* @param method The method to invoke on the client.
* @param params The notification's parameters.
*/
sendNotification(method: string, params?: any): Promise<void>;
/**
* Installs a progress handler for a given token.
* @param type the progress type
* @param token the token
* @param handler the handler
*/
onProgress<P>(type: ProgressType<P>, token: string | number, handler: NotificationHandler<P>): Disposable;
/**
* Sends progress.
* @param type the progress type
* @param token the token to use
* @param value the progress value
*/
sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): Promise<void>;
/**
* Installs a handler for the initialize request.
*
* @param handler The initialize handler.
*/
onInitialize(handler: ServerRequestHandler<InitializeParams, InitializeResult, never, InitializeError>): Disposable;
/**
* Installs a handler for the initialized notification.
*
* @param handler The initialized handler.
*/
onInitialized(handler: NotificationHandler<InitializedParams>): Disposable;
/**
* Installs a handler for the shutdown request.
*
* @param handler The initialize handler.
*/
onShutdown(handler: RequestHandler0<void, void>): Disposable;
/**
* Installs a handler for the exit notification.
*
* @param handler The exit handler.
*/
onExit(handler: NotificationHandler0): Disposable;
/**
* A property to provide access to console specific features.
*/
console: RemoteConsole & PConsole;
/**
* A property to provide access to tracer specific features.
*/
tracer: RemoteTracer & PTracer;
/**
* A property to provide access to telemetry specific features.
*/
telemetry: Telemetry & PTelemetry;
/**
* A property to provide access to client specific features like registering
* for requests or notifications.
*/
client: RemoteClient & PClient;
/**
* A property to provide access to windows specific features.
*/
window: RemoteWindow & PWindow;
/**
* A property to provide access to workspace specific features.
*/
workspace: RemoteWorkspace & PWorkspace;
/**
* A property to provide access to language specific features.
*/
languages: Languages & PLanguages;
/**
* A property to provide access to notebook specific features.
*/
notebooks: Notebooks & PNotebooks;
/**
* Installs a handler for the `DidChangeConfiguration` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeConfiguration(handler: NotificationHandler<DidChangeConfigurationParams>): Disposable;
/**
* Installs a handler for the `DidChangeWatchedFiles` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeWatchedFiles(handler: NotificationHandler<DidChangeWatchedFilesParams>): Disposable;
/**
* Installs a handler for the `DidOpenTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidOpenTextDocument(handler: NotificationHandler<DidOpenTextDocumentParams>): Disposable;
/**
* Installs a handler for the `DidChangeTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeTextDocument(handler: NotificationHandler<DidChangeTextDocumentParams>): Disposable;
/**
* Installs a handler for the `DidCloseTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidCloseTextDocument(handler: NotificationHandler<DidCloseTextDocumentParams>): Disposable;
/**
* Installs a handler for the `WillSaveTextDocument` notification.
*
* Note that this notification is opt-in. The client will not send it unless
* your server has the `textDocumentSync.willSave` capability or you've
* dynamically registered for the `textDocument/willSave` method.
*
* @param handler The corresponding handler.
*/
onWillSaveTextDocument(handler: NotificationHandler<WillSaveTextDocumentParams>): Disposable;
/**
* Installs a handler for the `WillSaveTextDocumentWaitUntil` request.
*
* Note that this request is opt-in. The client will not send it unless
* your server has the `textDocumentSync.willSaveWaitUntil` capability,
* or you've dynamically registered for the `textDocument/willSaveWaitUntil`
* method.
*
* @param handler The corresponding handler.
*/
onWillSaveTextDocumentWaitUntil(handler: RequestHandler<WillSaveTextDocumentParams, TextEdit[] | undefined | null, void>): Disposable;
/**
* Installs a handler for the `DidSaveTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidSaveTextDocument(handler: NotificationHandler<DidSaveTextDocumentParams>): Disposable;
/**
* Sends diagnostics computed for a given document to VSCode to render them in the
* user interface.
*
* @param params The diagnostic parameters.
*/
sendDiagnostics(params: PublishDiagnosticsParams): Promise<void>;
/**
* Installs a handler for the `Hover` request.
*
* @param handler The corresponding handler.
*/
onHover(handler: ServerRequestHandler<HoverParams, Hover | undefined | null, never, void>): Disposable;
/**
* Installs a handler for the `Completion` request.
*
* @param handler The corresponding handler.
*/
onCompletion(handler: ServerRequestHandler<CompletionParams, CompletionItem[] | CompletionList | undefined | null, CompletionItem[], void>): Disposable;
/**
* Installs a handler for the `CompletionResolve` request.
*
* @param handler The corresponding handler.
*/
onCompletionResolve(handler: RequestHandler<CompletionItem, CompletionItem, void>): Disposable;
/**
* Installs a handler for the `SignatureHelp` request.
*
* @param handler The corresponding handler.
*/
onSignatureHelp(handler: ServerRequestHandler<SignatureHelpParams, SignatureHelp | undefined | null, never, void>): Disposable;
/**
* Installs a handler for the `Declaration` request.
*
* @param handler The corresponding handler.
*/
onDeclaration(handler: ServerRequestHandler<DeclarationParams, Declaration | DeclarationLink[] | undefined | null, Location[] | DeclarationLink[], void>): Disposable;
/**
* Installs a handler for the `Definition` request.
*
* @param handler The corresponding handler.
*/
onDefinition(handler: ServerRequestHandler<DefinitionParams, Definition | DefinitionLink[] | undefined | null, Location[] | DefinitionLink[], void>): Disposable;
/**
* Installs a handler for the `Type Definition` request.
*
* @param handler The corresponding handler.
*/
onTypeDefinition(handler: ServerRequestHandler<TypeDefinitionParams, Definition | DefinitionLink[] | undefined | null, Location[] | DefinitionLink[], void>): Disposable;
/**
* Installs a handler for the `Implementation` request.
*
* @param handler The corresponding handler.
*/
onImplementation(handler: ServerRequestHandler<ImplementationParams, Definition | DefinitionLink[] | undefined | null, Location[] | DefinitionLink[], void>): Disposable;
/**
* Installs a handler for the `References` request.
*
* @param handler The corresponding handler.
*/
onReferences(handler: ServerRequestHandler<ReferenceParams, Location[] | undefined | null, Location[], void>): Disposable;
/**
* Installs a handler for the `DocumentHighlight` request.
*
* @param handler The corresponding handler.
*/
onDocumentHighlight(handler: ServerRequestHandler<DocumentHighlightParams, DocumentHighlight[] | undefined | null, DocumentHighlight[], void>): Disposable;
/**
* Installs a handler for the `DocumentSymbol` request.
*
* @param handler The corresponding handler.
*/
onDocumentSymbol(handler: ServerRequestHandler<DocumentSymbolParams, SymbolInformation[] | DocumentSymbol[] | undefined | null, SymbolInformation[] | DocumentSymbol[], void>): Disposable;
/**
* Installs a handler for the `WorkspaceSymbol` request.
*
* @param handler The corresponding handler.
*/
onWorkspaceSymbol(handler: ServerRequestHandler<WorkspaceSymbolParams, SymbolInformation[] | WorkspaceSymbol[] | undefined | null, SymbolInformation[], void>): Disposable;
/**
* Installs a handler for the `WorkspaceSymbol` request.
*
* @param handler The corresponding handler.
*/
onWorkspaceSymbolResolve(handler: RequestHandler<WorkspaceSymbol, WorkspaceSymbol, void>): Disposable;
/**
* Installs a handler for the `CodeAction` request.
*
* @param handler The corresponding handler.
*/
onCodeAction(handler: ServerRequestHandler<CodeActionParams, (Command | CodeAction)[] | undefined | null, (Command | CodeAction)[], void>): Disposable;
/**
* Installs a handler for the `CodeAction` resolve request.
*
* @param handler The corresponding handler.
*/
onCodeActionResolve(handler: RequestHandler<CodeAction, CodeAction, void>): Disposable;
/**
* Compute a list of {@link CodeLens lenses}. This call should return as fast as possible and if
* computing the commands is expensive implementers should only return code lens objects with the
* range set and handle the resolve request.
*
* @param handler The corresponding handler.
*/
onCodeLens(handler: ServerRequestHandler<CodeLensParams, CodeLens[] | undefined | null, CodeLens[], void>): Disposable;
/**
* This function will be called for each visible code lens, usually when scrolling and after
* the onCodeLens has been called.
*
* @param handler The corresponding handler.
*/
onCodeLensResolve(handler: RequestHandler<CodeLens, CodeLens, void>): Disposable;
/**
* Installs a handler for the document formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentFormatting(handler: ServerRequestHandler<DocumentFormattingParams, TextEdit[] | undefined | null, never, void>): Disposable;
/**
* Installs a handler for the document range formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentRangeFormatting(handler: ServerRequestHandler<DocumentRangeFormattingParams, TextEdit[] | undefined | null, never, void>): Disposable;
/**
* Installs a handler for the document on type formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentOnTypeFormatting(handler: RequestHandler<DocumentOnTypeFormattingParams, TextEdit[] | undefined | null, void>): Disposable;
/**
* Installs a handler for the rename request.
*
* @param handler The corresponding handler.
*/
onRenameRequest(handler: ServerRequestHandler<RenameParams, WorkspaceEdit | undefined | null, never, void>): Disposable;
/**
* Installs a handler for the prepare rename request.
*
* @param handler The corresponding handler.
*/
onPrepareRename(handler: RequestHandler<PrepareRenameParams, Range | {
range: Range;
placeholder: string;
} | {
defaultBehavior: boolean;
} | undefined | null, void>): Disposable;
/**
* Installs a handler for the document links request.
*
* @param handler The corresponding handler.
*/
onDocumentLinks(handler: ServerRequestHandler<DocumentLinkParams, DocumentLink[] | undefined | null, DocumentLink[], void>): Disposable;
/**
* Installs a handler for the document links resolve request.
*
* @param handler The corresponding handler.
*/
onDocumentLinkResolve(handler: RequestHandler<DocumentLink, DocumentLink | undefined | null, void>): Disposable;
/**
* Installs a handler for the document color request.
*
* @param handler The corresponding handler.
*/
onDocumentColor(handler: ServerRequestHandler<DocumentColorParams, ColorInformation[] | undefined | null, ColorInformation[], void>): Disposable;
/**
* Installs a handler for the document color request.
*
* @param handler The corresponding handler.
*/
onColorPresentation(handler: ServerRequestHandler<ColorPresentationParams, ColorPresentation[] | undefined | null, ColorPresentation[], void>): Disposable;
/**
* Installs a handler for the folding ranges request.
*
* @param handler The corresponding handler.
*/
onFoldingRanges(handler: ServerRequestHandler<FoldingRangeParams, FoldingRange[] | undefined | null, FoldingRange[], void>): Disposable;
/**
* Installs a handler for the selection ranges request.
*
* @param handler The corresponding handler.
*/
onSelectionRanges(handler: ServerRequestHandler<SelectionRangeParams, SelectionRange[] | undefined | null, SelectionRange[], void>): Disposable;
/**
* Installs a handler for the execute command request.
*
* @param handler The corresponding handler.
*/
onExecuteCommand(handler: ServerRequestHandler<ExecuteCommandParams, any | undefined | null, never, void>): Disposable;
/**
* Disposes the connection
*/
dispose(): void;
}
export interface Connection extends _Connection {
}
export interface Feature<B extends FeatureBase, P> {
(Base: new () => B): new () => B & P;
}
export declare type ConsoleFeature<P> = Feature<RemoteConsole, P>;
export declare function combineConsoleFeatures<O, T>(one: ConsoleFeature<O>, two: ConsoleFeature<T>): ConsoleFeature<O & T>;
export declare type TelemetryFeature<P> = Feature<Telemetry, P>;
export declare function combineTelemetryFeatures<O, T>(one: TelemetryFeature<O>, two: TelemetryFeature<T>): TelemetryFeature<O & T>;
export declare type TracerFeature<P> = Feature<RemoteTracer, P>;
export declare function combineTracerFeatures<O, T>(one: TracerFeature<O>, two: TracerFeature<T>): TracerFeature<O & T>;
export declare type ClientFeature<P> = Feature<RemoteClient, P>;
export declare function combineClientFeatures<O, T>(one: ClientFeature<O>, two: ClientFeature<T>): ClientFeature<O & T>;
export declare type WindowFeature<P> = Feature<_RemoteWindow, P>;
export declare function combineWindowFeatures<O, T>(one: WindowFeature<O>, two: WindowFeature<T>): WindowFeature<O & T>;
export declare type WorkspaceFeature<P> = Feature<_RemoteWorkspace, P>;
export declare function combineWorkspaceFeatures<O, T>(one: WorkspaceFeature<O>, two: WorkspaceFeature<T>): WorkspaceFeature<O & T>;
export declare type LanguagesFeature<P> = Feature<_Languages, P>;
export declare function combineLanguagesFeatures<O, T>(one: LanguagesFeature<O>, two: LanguagesFeature<T>): LanguagesFeature<O & T>;
export declare type NotebooksFeature<P> = Feature<_Notebooks, P>;
export declare function combineNotebooksFeatures<O, T>(one: NotebooksFeature<O>, two: NotebooksFeature<T>): NotebooksFeature<O & T>;
export interface Features<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _> {
__brand: 'features';
console?: ConsoleFeature<PConsole>;
tracer?: TracerFeature<PTracer>;
telemetry?: TelemetryFeature<PTelemetry>;
client?: ClientFeature<PClient>;
window?: WindowFeature<PWindow>;
workspace?: WorkspaceFeature<PWorkspace>;
languages?: LanguagesFeature<PLanguages>;
notebooks?: NotebooksFeature<PNotebooks>;
}
export declare function combineFeatures<OConsole, OTracer, OTelemetry, OClient, OWindow, OWorkspace, OLanguages, ONotebooks, TConsole, TTracer, TTelemetry, TClient, TWindow, TWorkspace, TLanguages, TNotebooks>(one: Features<OConsole, OTracer, OTelemetry, OClient, OWindow, OWorkspace, OLanguages, ONotebooks>, two: Features<TConsole, TTracer, TTelemetry, TClient, TWindow, TWorkspace, TLanguages, TNotebooks>): Features<OConsole & TConsole, OTracer & TTracer, OTelemetry & TTelemetry, OClient & TClient, OWindow & TWindow, OWorkspace & TWorkspace, OLanguages & TLanguages, ONotebooks & TNotebooks>;
export interface WatchDog {
shutdownReceived: boolean;
initialize(params: InitializeParams): void;
exit(code: number): void;
}
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(connectionFactory: (logger: Logger) => ProtocolConnection, watchDog: WatchDog, factories?: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
export {};

749
node_modules/vscode-languageserver/lib/common/server.js generated vendored Normal file
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 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);
}
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 || (exports.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 || (exports.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, 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;
if (arguments.length === 1) {
return connection.sendNotification(method);
}
else {
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,16 @@
"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.ShowDocumentFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const ShowDocumentFeature = (Base) => {
return class extends Base {
showDocument(params) {
return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowDocumentRequest.type, params);
}
};
};
exports.ShowDocumentFeature = ShowDocumentFeature;

View file

@ -0,0 +1,133 @@
import { NotificationHandler, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, WillSaveTextDocumentParams, RequestHandler, TextEdit, DidSaveTextDocumentParams, DocumentUri, TextDocumentContentChangeEvent, TextDocumentSaveReason, Event, TextDocumentSyncKind, Disposable } from 'vscode-languageserver-protocol';
/**
* We should use a mapped type to create this from Connection.
*/
export interface TextDocumentConnection {
onDidOpenTextDocument(handler: NotificationHandler<DidOpenTextDocumentParams>): Disposable;
onDidChangeTextDocument(handler: NotificationHandler<DidChangeTextDocumentParams>): Disposable;
onDidCloseTextDocument(handler: NotificationHandler<DidCloseTextDocumentParams>): Disposable;
onWillSaveTextDocument(handler: NotificationHandler<WillSaveTextDocumentParams>): Disposable;
onWillSaveTextDocumentWaitUntil(handler: RequestHandler<WillSaveTextDocumentParams, TextEdit[] | undefined | null, void>): Disposable;
onDidSaveTextDocument(handler: NotificationHandler<DidSaveTextDocumentParams>): Disposable;
}
export interface ConnectionState {
__textDocumentSync: TextDocumentSyncKind | undefined;
}
export interface TextDocumentsConfiguration<T extends {
uri: DocumentUri;
}> {
create(uri: DocumentUri, languageId: string, version: number, content: string): T;
update(document: T, changes: TextDocumentContentChangeEvent[], version: number): T;
}
/**
* Event to signal changes to a text document.
*/
export interface TextDocumentChangeEvent<T> {
/**
* The document that has changed.
*/
document: T;
}
/**
* Event to signal that a document will be saved.
*/
export interface TextDocumentWillSaveEvent<T> {
/**
* The document that will be saved
*/
document: T;
/**
* The reason why save was triggered.
*/
reason: TextDocumentSaveReason;
}
/**
* A manager for simple text documents. The manager requires at a minimum that
* the server registered for the following text document sync events in the
* initialize handler or via dynamic registration:
*
* - open and close events.
* - change events.
*
* Registering for save and will save events is optional.
*/
export declare class TextDocuments<T extends {
uri: DocumentUri;
}> {
private readonly _configuration;
private readonly _syncedDocuments;
private readonly _onDidChangeContent;
private readonly _onDidOpen;
private readonly _onDidClose;
private readonly _onDidSave;
private readonly _onWillSave;
private _willSaveWaitUntil;
/**
* Create a new text document manager.
*/
constructor(configuration: TextDocumentsConfiguration<T>);
/**
* An event that fires when a text document managed by this manager
* has been opened.
*/
get onDidOpen(): Event<TextDocumentChangeEvent<T>>;
/**
* An event that fires when a text document managed by this manager
* has been opened or the content changes.
*/
get onDidChangeContent(): Event<TextDocumentChangeEvent<T>>;
/**
* An event that fires when a text document managed by this manager
* will be saved.
*/
get onWillSave(): Event<TextDocumentWillSaveEvent<T>>;
/**
* Sets a handler that will be called if a participant wants to provide
* edits during a text document save.
*/
onWillSaveWaitUntil(handler: RequestHandler<TextDocumentWillSaveEvent<T>, TextEdit[], void>): void;
/**
* An event that fires when a text document managed by this manager
* has been saved.
*/
get onDidSave(): Event<TextDocumentChangeEvent<T>>;
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
get onDidClose(): Event<TextDocumentChangeEvent<T>>;
/**
* Returns the document for the given URI. Returns undefined if
* the document is not managed by this instance.
*
* @param uri The text document's URI to retrieve.
* @return the text document or `undefined`.
*/
get(uri: string): T | undefined;
/**
* Returns all text documents managed by this instance.
*
* @return all text documents.
*/
all(): T[];
/**
* Returns the URIs of all text documents managed by this instance.
*
* @return the URI's of all text documents.
*/
keys(): string[];
/**
* Listens for `low level` notification on the given connection to
* update the text documents managed by this instance.
*
* Please note that the connection only provides handlers not an event model. Therefore
* listening on a connection will overwrite the following handlers on a connection:
* `onDidOpenTextDocument`, `onDidChangeTextDocument`, `onDidCloseTextDocument`,
* `onWillSaveTextDocument`, `onWillSaveTextDocumentWaitUntil` and `onDidSaveTextDocument`.
*
* Use the corresponding events on the TextDocuments instance instead.
*
* @param connection The connection to listen on.
*/
listen(connection: TextDocumentConnection): Disposable;
}

View file

@ -0,0 +1,172 @@
"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.TextDocuments = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
/**
* A manager for simple text documents. The manager requires at a minimum that
* the server registered for the following text document sync events in the
* initialize handler or via dynamic registration:
*
* - open and close events.
* - change events.
*
* Registering for save and will save events is optional.
*/
class TextDocuments {
/**
* Create a new text document manager.
*/
constructor(configuration) {
this._configuration = configuration;
this._syncedDocuments = new Map();
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();
}
/**
* An event that fires when a text document managed by this manager
* has been opened.
*/
get onDidOpen() {
return this._onDidOpen.event;
}
/**
* An event that fires when a text document managed by this manager
* has been opened or the content changes.
*/
get onDidChangeContent() {
return this._onDidChangeContent.event;
}
/**
* An event that fires when a text document managed by this manager
* will be saved.
*/
get onWillSave() {
return this._onWillSave.event;
}
/**
* Sets a handler that will be called if a participant wants to provide
* edits during a text document save.
*/
onWillSaveWaitUntil(handler) {
this._willSaveWaitUntil = handler;
}
/**
* An event that fires when a text document managed by this manager
* has been saved.
*/
get onDidSave() {
return this._onDidSave.event;
}
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
get onDidClose() {
return this._onDidClose.event;
}
/**
* Returns the document for the given URI. Returns undefined if
* the document is not managed by this instance.
*
* @param uri The text document's URI to retrieve.
* @return the text document or `undefined`.
*/
get(uri) {
return this._syncedDocuments.get(uri);
}
/**
* Returns all text documents managed by this instance.
*
* @return all text documents.
*/
all() {
return Array.from(this._syncedDocuments.values());
}
/**
* Returns the URIs of all text documents managed by this instance.
*
* @return the URI's of all text documents.
*/
keys() {
return Array.from(this._syncedDocuments.keys());
}
/**
* Listens for `low level` notification on the given connection to
* update the text documents managed by this instance.
*
* Please note that the connection only provides handlers not an event model. Therefore
* listening on a connection will overwrite the following handlers on a connection:
* `onDidOpenTextDocument`, `onDidChangeTextDocument`, `onDidCloseTextDocument`,
* `onWillSaveTextDocument`, `onWillSaveTextDocumentWaitUntil` and `onDidSaveTextDocument`.
*
* Use the corresponding events on the TextDocuments instance instead.
*
* @param connection The connection to listen on.
*/
listen(connection) {
connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Incremental;
const disposables = [];
disposables.push(connection.onDidOpenTextDocument((event) => {
const td = event.textDocument;
const document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
this._syncedDocuments.set(td.uri, document);
const toFire = Object.freeze({ document });
this._onDidOpen.fire(toFire);
this._onDidChangeContent.fire(toFire);
}));
disposables.push(connection.onDidChangeTextDocument((event) => {
const td = event.textDocument;
const changes = event.contentChanges;
if (changes.length === 0) {
return;
}
const { version } = td;
if (version === null || version === undefined) {
throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
}
let syncedDocument = this._syncedDocuments.get(td.uri);
if (syncedDocument !== undefined) {
syncedDocument = this._configuration.update(syncedDocument, changes, version);
this._syncedDocuments.set(td.uri, syncedDocument);
this._onDidChangeContent.fire(Object.freeze({ document: syncedDocument }));
}
}));
disposables.push(connection.onDidCloseTextDocument((event) => {
let syncedDocument = this._syncedDocuments.get(event.textDocument.uri);
if (syncedDocument !== undefined) {
this._syncedDocuments.delete(event.textDocument.uri);
this._onDidClose.fire(Object.freeze({ document: syncedDocument }));
}
}));
disposables.push(connection.onWillSaveTextDocument((event) => {
let syncedDocument = this._syncedDocuments.get(event.textDocument.uri);
if (syncedDocument !== undefined) {
this._onWillSave.fire(Object.freeze({ document: syncedDocument, reason: event.reason }));
}
}));
disposables.push(connection.onWillSaveTextDocumentWaitUntil((event, token) => {
let syncedDocument = this._syncedDocuments.get(event.textDocument.uri);
if (syncedDocument !== undefined && this._willSaveWaitUntil) {
return this._willSaveWaitUntil(Object.freeze({ document: syncedDocument, reason: event.reason }), token);
}
else {
return [];
}
}));
disposables.push(connection.onDidSaveTextDocument((event) => {
let syncedDocument = this._syncedDocuments.get(event.textDocument.uri);
if (syncedDocument !== undefined) {
this._onDidSave.fire(Object.freeze({ document: syncedDocument }));
}
}));
return vscode_languageserver_protocol_1.Disposable.create(() => { disposables.forEach(disposable => disposable.dispose()); });
}
}
exports.TextDocuments = TextDocuments;

View file

@ -0,0 +1,15 @@
import { TypeHierarchyItem, Disposable, TypeHierarchyPrepareParams, TypeHierarchySupertypesParams, TypeHierarchySubtypesParams } from 'vscode-languageserver-protocol';
import type { Feature, _Languages, ServerRequestHandler } from './server';
/**
* Shape of the type hierarchy feature
*
* @since 3.17.0
*/
export interface TypeHierarchyFeatureShape {
typeHierarchy: {
onPrepare(handler: ServerRequestHandler<TypeHierarchyPrepareParams, TypeHierarchyItem[] | null, never, void>): Disposable;
onSupertypes(handler: ServerRequestHandler<TypeHierarchySupertypesParams, TypeHierarchyItem[] | null, TypeHierarchyItem[], void>): Disposable;
onSubtypes(handler: ServerRequestHandler<TypeHierarchySubtypesParams, TypeHierarchyItem[] | null, TypeHierarchyItem[], void>): Disposable;
};
}
export declare const TypeHierarchyFeature: Feature<_Languages, TypeHierarchyFeatureShape>;

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,9 @@
export declare function boolean(value: any): value is boolean;
export declare function string(value: any): value is string;
export declare function number(value: any): value is number;
export declare function error(value: any): value is Error;
export declare function func(value: any): value is Function;
export declare function array<T>(value: any): value is T[];
export declare function stringArray(value: any): value is string[];
export declare function typedArray<T>(value: any, check: (value: any) => boolean): value is T[];
export declare function thenable<T>(value: any): value is Thenable<T>;

View file

@ -0,0 +1,43 @@
"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.thenable = exports.typedArray = exports.stringArray = exports.array = exports.func = exports.error = exports.number = exports.string = exports.boolean = void 0;
function boolean(value) {
return value === true || value === false;
}
exports.boolean = boolean;
function string(value) {
return typeof value === 'string' || value instanceof String;
}
exports.string = string;
function number(value) {
return typeof value === 'number' || value instanceof Number;
}
exports.number = number;
function error(value) {
return value instanceof Error;
}
exports.error = error;
function func(value) {
return typeof value === 'function';
}
exports.func = func;
function array(value) {
return Array.isArray(value);
}
exports.array = array;
function stringArray(value) {
return array(value) && value.every(elem => string(elem));
}
exports.stringArray = stringArray;
function typedArray(value, check) {
return Array.isArray(value) && value.every(check);
}
exports.typedArray = typedArray;
function thenable(value) {
return value && func(value.then);
}
exports.thenable = thenable;

View file

@ -0,0 +1,22 @@
/**
* Represents a UUID as defined by rfc4122.
*/
export interface UUID {
/**
* @returns the canonical representation in sets of hexadecimal numbers separated by dashes.
*/
asHex(): string;
equals(other: UUID): boolean;
}
/**
* An empty UUID that contains only zeros.
*/
export declare const empty: UUID;
export declare function v4(): UUID;
export declare function isUUID(value: string): boolean;
/**
* Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
* @param value A uuid string.
*/
export declare function parse(value: string): UUID;
export declare function generateUuid(): string;

View file

@ -0,0 +1,97 @@
"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.generateUuid = exports.parse = exports.isUUID = exports.v4 = exports.empty = void 0;
class ValueUUID {
constructor(_value) {
this._value = _value;
// empty
}
asHex() {
return this._value;
}
equals(other) {
return this.asHex() === other.asHex();
}
}
class V4UUID 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'];
/**
* An empty UUID that contains only zeros.
*/
exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
function v4() {
return new V4UUID();
}
exports.v4 = v4;
const _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);
}
exports.isUUID = isUUID;
/**
* Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
* @param value A uuid string.
*/
function parse(value) {
if (!isUUID(value)) {
throw new Error('invalid uuid');
}
return new ValueUUID(value);
}
exports.parse = parse;
function generateUuid() {
return v4().asHex();
}
exports.generateUuid = generateUuid;

View file

@ -0,0 +1,7 @@
import { Event, WorkspaceFolder, WorkspaceFoldersChangeEvent } from 'vscode-languageserver-protocol';
import type { Feature, _RemoteWorkspace } from './server';
export interface WorkspaceFolders {
getWorkspaceFolders(): Promise<WorkspaceFolder[] | null>;
onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>;
}
export declare const WorkspaceFoldersFeature: Feature<_RemoteWorkspace, WorkspaceFolders>;

View file

@ -0,0 +1,44 @@
/* --------------------------------------------------------------------------------------------
* 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.WorkspaceFoldersFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const WorkspaceFoldersFeature = (Base) => {
return class extends Base {
constructor() {
super();
this._notificationIsAutoRegistered = false;
}
initialize(capabilities) {
super.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);
});
}
}
fillServerCapabilities(capabilities) {
super.fillServerCapabilities(capabilities);
const changeNotifications = capabilities.workspace?.workspaceFolders?.changeNotifications;
this._notificationIsAutoRegistered = changeNotifications === true || typeof changeNotifications === 'string';
}
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._notificationIsAutoRegistered && !this._unregistration) {
this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
}
return this._onDidChangeWorkspaceFolders.event;
}
};
};
exports.WorkspaceFoldersFeature = WorkspaceFoldersFeature;

19
node_modules/vscode-languageserver/lib/node/files.d.ts generated vendored Normal file
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>;

262
node_modules/vscode-languageserver/lib/node/files.js generated vendored Normal file
View file

@ -0,0 +1,262 @@
"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.resolveModulePath = exports.FileSystem = exports.resolveGlobalYarnPath = exports.resolveGlobalNodePath = exports.resolve = exports.uriToFilePath = void 0;
const url = require("url");
const path = require("path");
const fs = require("fs");
const child_process_1 = require("child_process");
/**
* @deprecated Use the `vscode-uri` npm module which provides a more
* complete implementation of handling VS Code URIs.
*/
function uriToFilePath(uri) {
let parsed = url.parse(uri);
if (parsed.protocol !== 'file:' || !parsed.path) {
return undefined;
}
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];
// Do we have a drive letter and we started with a / which is the
// case if the first segement is empty (see split above)
if (first.length === 0 && second.length > 1 && second[1] === ':') {
// Remove first slash
segments.shift();
}
}
return path.normalize(segments.join('/'));
}
exports.uriToFilePath = uriToFilePath;
function isWindows() {
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((resolve, reject) => {
let env = process.env;
let newEnv = Object.create(null);
Object.keys(env).forEach(key => newEnv[key] = env[key]);
if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
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 = (0, child_process_1.fork)('', [], {
cwd: 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', (message) => {
if (message.c === 'r') {
cp.send({ c: 'e' });
if (message.s) {
resolve(message.r);
}
else {
reject(new Error(`Failed to resolve module: ${moduleName}`));
}
}
});
let message = {
c: 'rs',
a: moduleName
};
cp.send(message);
}
catch (error) {
reject(error);
}
});
}
exports.resolve = resolve;
/**
* 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
*/
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 (isWindows()) {
npmCommand = 'npm.cmd';
options.shell = true;
}
let handler = () => { };
try {
process.on('SIGPIPE', handler);
let stdout = (0, 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 undefined;
}
let prefix = stdout.trim();
if (tracer) {
tracer(`'npm config get prefix' value is: ${prefix}`);
}
if (prefix.length > 0) {
if (isWindows()) {
return path.join(prefix, 'node_modules');
}
else {
return path.join(prefix, 'lib', 'node_modules');
}
}
return undefined;
}
catch (err) {
return undefined;
}
finally {
process.removeListener('SIGPIPE', handler);
}
}
exports.resolveGlobalNodePath = resolveGlobalNodePath;
/*
* Resolve the global yarn pakage 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
*/
function resolveGlobalYarnPath(tracer) {
let yarnCommand = 'yarn';
let options = {
encoding: 'utf8'
};
if (isWindows()) {
yarnCommand = 'yarn.cmd';
options.shell = true;
}
let handler = () => { };
try {
process.on('SIGPIPE', handler);
let results = (0, 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 undefined;
}
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) {
// Do nothing. Ignore the line
}
}
return undefined;
}
catch (err) {
return undefined;
}
finally {
process.removeListener('SIGPIPE', handler);
}
}
exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
var FileSystem;
(function (FileSystem) {
let _isCaseSensitive = undefined;
function isCaseSensitive() {
if (_isCaseSensitive !== void 0) {
return _isCaseSensitive;
}
if (process.platform === 'win32') {
_isCaseSensitive = false;
}
else {
// convert current file name to upper case / lower case and check if file exists
// (guards against cases when name is already all uppercase or lowercase)
_isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
}
return _isCaseSensitive;
}
FileSystem.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;
}
}
FileSystem.isParent = isParent;
})(FileSystem = exports.FileSystem || (exports.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(undefined, (_error) => {
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
});
}
else {
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
}
}
exports.resolveModulePath = resolveModulePath;

61
node_modules/vscode-languageserver/lib/node/main.d.ts generated vendored Normal file
View file

@ -0,0 +1,61 @@
/// <reference path="../../typings/thenable.d.ts" />
/// <reference types="node" />
import { Connection, _, _Connection, Features } from '../common/server';
import * as fm from './files';
import { ConnectionStrategy, ConnectionOptions, MessageReader, MessageWriter } from 'vscode-languageserver-protocol/node';
export * from 'vscode-languageserver-protocol/node';
export * from '../common/api';
export declare namespace Files {
let uriToFilePath: typeof fm.uriToFilePath;
let resolveGlobalNodePath: typeof fm.resolveGlobalNodePath;
let resolveGlobalYarnPath: typeof fm.resolveGlobalYarnPath;
let resolve: typeof fm.resolve;
let resolveModulePath: typeof fm.resolveModulePath;
}
/**
* Creates a new connection based on the processes command line arguments:
*
* @param options An optional connection strategy or connection options to control additional settings
*/
export declare function createConnection(options?: ConnectionStrategy | ConnectionOptions): Connection;
/**
* Creates a new connection using a the given streams.
*
* @param inputStream The stream to read messages from.
* @param outputStream The stream to write messages to.
* @param options An optional connection strategy or connection options to control additional settings
* @return A {@link Connection connection}
*/
export declare function createConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, options?: ConnectionStrategy | ConnectionOptions): Connection;
/**
* Creates a new connection.
*
* @param reader The message reader to read messages from.
* @param writer The message writer to write message to.
* @param options An optional connection strategy or connection options to control additional settings
*/
export declare function createConnection(reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): Connection;
/**
* Creates a new connection based on the processes command line arguments. The new connection surfaces proposed API
*
* @param factories: the factories to use to implement the proposed API
* @param options An optional connection strategy or connection options to control additional settings
*/
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
/**
* Creates a new connection using a the given streams.
*
* @param inputStream The stream to read messages from.
* @param outputStream The stream to write messages to.
* @param options An optional connection strategy or connection options to control additional settings
* @return A {@link Connection connection}
*/
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
/**
* Creates a new connection.
*
* @param reader The message reader to read messages from.
* @param writer The message writer to write message to.
* @param options An optional connection strategy or connection options to control additional settings
*/
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;

211
node_modules/vscode-languageserver/lib/node/main.js generated vendored Normal file
View file

@ -0,0 +1,211 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
/// <reference path="../../typings/thenable.d.ts" />
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 = exports.Files = void 0;
const Is = require("../common/utils/is");
const server_1 = require("../common/server");
const fm = require("./files");
const node_1 = require("vscode-languageserver-protocol/node");
__exportStar(require("vscode-languageserver-protocol/node"), exports);
__exportStar(require("../common/api"), exports);
var Files;
(function (Files) {
Files.uriToFilePath = fm.uriToFilePath;
Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
Files.resolve = fm.resolve;
Files.resolveModulePath = fm.resolveModulePath;
})(Files = exports.Files || (exports.Files = {}));
let _protocolConnection;
function endProtocolConnection() {
if (_protocolConnection === undefined) {
return;
}
try {
_protocolConnection.end();
}
catch (_err) {
// Ignore. The client process could have already
// did and we can't send an end into the connection.
}
}
let _shutdownReceived = false;
let exitTimer = undefined;
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) {
// Parent process doesn't exist anymore. Exit the server.
endProtocolConnection();
process.exit(_shutdownReceived ? 0 : 1);
}
}, 3000);
}
}
catch (e) {
// Ignore errors;
}
}
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();
const watchDog = {
initialize: (params) => {
const processId = params.processId;
if (Is.number(processId) && exitTimer === undefined) {
// We received a parent process id. Set up a timer to periodically check
// if the parent is still alive.
setInterval(() => {
try {
process.kill(processId, 0);
}
catch (ex) {
// Parent process doesn't exist anymore. Exit the server.
process.exit(_shutdownReceived ? 0 : 1);
}
}, 3000);
}
},
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);
}
exports.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 = (0, node_1.createServerSocketTransport)(port);
input = transport[0];
output = transport[1];
}
else if (pipeName) {
let transport = (0, 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);
}
// Backwards compatibility
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 = (0, node_1.createProtocolConnection)(input, output, logger, options);
return result;
};
return (0, server_1.createConnection)(connectionFactory, watchDog, factories);
}

View file

@ -0,0 +1,6 @@
interface Message {
command: string;
success?: boolean;
args?: any;
result?: any;
}

19
node_modules/vscode-languageserver/lib/node/resolve.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
process.on('message', (message) => {
if (message.command === 'exit') {
process.exit(0);
}
else if (message.command === 'resolve') {
try {
let result = require.resolve(message.args);
process.send({ command: 'resolve', success: true, result: result });
}
catch (err) {
process.send({ command: 'resolve', success: false });
}
}
});