initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

11
node_modules/vscode-languageserver/License.txt generated vendored Normal file
View File

@@ -0,0 +1,11 @@
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

17
node_modules/vscode-languageserver/README.md generated vendored Normal file
View File

@@ -0,0 +1,17 @@
# VSCode Language Server
[![NPM Version](https://img.shields.io/npm/v/vscode-languageserver.svg)](https://npmjs.org/package/vscode-languageserver)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-languageserver.svg)](https://npmjs.org/package/vscode-languageserver)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
Npm module to implement a VSCode language server using [Node.js](https://nodejs.org/) as a runtime.
Click [here](https://code.visualstudio.com/docs/extensions/example-language-server) for a detailed document on how to use this npm module
to implement language servers for [VSCode](https://code.visualstudio.com/).
## History
For the history please see the [main repository](https://github.com/Microsoft/vscode-languageserver-node/blob/master/README.md)
## License
[MIT](https://github.com/Microsoft/vscode-languageserver-node/blob/master/License.txt)

View File

@@ -0,0 +1,73 @@
/* eslint-disable no-console */
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var cp = require('child_process');
var extensionDirectory = process.argv[2];
if (!extensionDirectory) {
console.error('No extension directory provided.');
process.exit(1);
}
extensionDirectory = path.resolve(extensionDirectory);
if (!fs.existsSync(extensionDirectory)) {
console.error('Extension directory ' + extensionDirectory + ' doesn\'t exist on disk.');
process.exit(1);
}
var packageFile = process.argv[3];
if (!packageFile) {
console.error('No package.json file provided.');
process.exit(1);
}
packageFile = path.resolve(packageFile);
if (!fs.existsSync(packageFile)) {
console.error('Package file ' + packageFile + ' doesn\'t exist on disk.');
process.exit(1);
}
var tsconfigFile = process.argv[4];
if (!tsconfigFile) {
console.error('No tsconfig.json file provided');
process.exit(1);
}
tsconfigFile = path.resolve(tsconfigFile);
if (!fs.existsSync(tsconfigFile)) {
console.error('tsconfig file ' + tsconfigFile + ' doesn\'t exist on disk.');
process.exit(1);
}
var extensionServerDirectory = path.join(extensionDirectory, 'server');
var json = require(tsconfigFile);
var compilerOptions = json.compilerOptions;
if (compilerOptions) {
var outDir = compilerOptions.outDir;
if (!outDir || path.join(path.dirname(tsconfigFile), outDir) !== extensionServerDirectory) {
console.error('outDir in ' + process.argv[4] + ' must point to ' + extensionServerDirectory + ' but it points to ' + path.join(path.dirname(tsconfigFile), outDir));
console.error('Please change outDir in ' + process.argv[4] + ' to ' + path.relative(path.dirname(tsconfigFile), extensionServerDirectory).replace(/\\/g, '/'));
process.exit(1);
}
}
if (!fs.existsSync(extensionServerDirectory)) {
fs.mkdirSync(extensionServerDirectory);
}
var dest = path.join(extensionServerDirectory, 'package.json');
console.log('Copying package.json to extension\'s server location...');
fs.writeFileSync(dest, fs.readFileSync(packageFile));
var shrinkwrapFile = process.argv[5];
if (fs.existsSync(shrinkwrapFile)) {
const shrinkWrapDest = path.join(extensionServerDirectory, 'npm-shrinkwrap.json');
shrinkwrapFile = path.resolve(shrinkwrapFile);
console.log('Copying npm-shrinkwrap.json to extension\'s server location...');
fs.writeFileSync(shrinkWrapDest, fs.readFileSync(shrinkwrapFile));
}
console.log('The script is deprecated. See https://github.com/microsoft/vscode-extension-samples/tree/master/lsp-sample for an example on how to setup an extension / server project.');
console.log('');
console.log('Updating server npm modules into extension\'s server location...');
cp.execSync('npm update --production --prefix ' + extensionServerDirectory);

6
node_modules/vscode-languageserver/browser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ----------------------------------------------------------------------------------------- */
export * from './lib/browser/main';

7
node_modules/vscode-languageserver/browser.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ----------------------------------------------------------------------------------------- */
'use strict';
module.exports = require('./lib/browser/main');

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;

59
node_modules/vscode-languageserver/lib/browser/main.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"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;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 api_1.createProtocolConnection(reader, writer, logger, options);
};
return api_1.createConnection(connectionFactory, watchDog, factories);
}
exports.createConnection = createConnection;
//# sourceMappingURL=main.js.map

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

@@ -0,0 +1,11 @@
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 };
export * from './server';
export declare namespace ProposedFeatures {
const all: Features<_, _, _, _, _, _, _>;
type Connection = _Connection<_, _, _, _, _, _, _>;
}

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

@@ -0,0 +1,28 @@
"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;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.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);
__exportStar(require("./server"), exports);
var ProposedFeatures;
(function (ProposedFeatures) {
ProposedFeatures.all = {
__brand: 'features'
};
})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
//# sourceMappingURL=api.js.map

View File

@@ -0,0 +1,15 @@
import { CallHierarchyItem, CallHierarchyPrepareParams, CallHierarchyIncomingCallsParams, CallHierarchyIncomingCall, CallHierarchyOutgoingCallsParams, CallHierarchyOutgoingCall } 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>): void;
onIncomingCalls(handler: ServerRequestHandler<CallHierarchyIncomingCallsParams, CallHierarchyIncomingCall[] | null, CallHierarchyIncomingCall[], void>): void;
onOutgoingCalls(handler: ServerRequestHandler<CallHierarchyOutgoingCallsParams, CallHierarchyOutgoingCall[] | null, CallHierarchyOutgoingCall[], void>): void;
};
}
export declare const CallHierarchyFeature: Feature<_Languages, CallHierarchy>;

View File

@@ -0,0 +1,35 @@
/* --------------------------------------------------------------------------------------------
* 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) => {
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;
this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
},
onOutgoingCalls: (handler) => {
const type = vscode_languageserver_protocol_1.CallHierarchyOutgoingCallsRequest.type;
this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
}
};
}
};
};
exports.CallHierarchyFeature = CallHierarchyFeature;
//# sourceMappingURL=callHierarchy.js.map

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,34 @@
"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) => {
return Array.isArray(arg) ? result : result[0];
});
}
};
};
exports.ConfigurationFeature = ConfigurationFeature;
//# sourceMappingURL=configuration.js.map

View File

@@ -0,0 +1,16 @@
import { RequestHandler, NotificationHandler, WorkspaceEdit, CreateFilesParams, RenameFilesParams, DeleteFilesParams } 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>): void;
onDidRenameFiles(handler: NotificationHandler<RenameFilesParams>): void;
onDidDeleteFiles(handler: NotificationHandler<DeleteFilesParams>): void;
onWillCreateFiles(handler: RequestHandler<CreateFilesParams, WorkspaceEdit | null, never>): void;
onWillRenameFiles(handler: RequestHandler<RenameFilesParams, WorkspaceEdit | null, never>): void;
onWillDeleteFiles(handler: RequestHandler<DeleteFilesParams, WorkspaceEdit | null, never>): void;
}
export declare const FileOperationsFeature: Feature<_RemoteWorkspace, FileOperationsFeatureShape>;

View File

@@ -0,0 +1,44 @@
"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) {
this.connection.onNotification(vscode_languageserver_protocol_1.DidCreateFilesNotification.type, (params) => {
handler(params);
});
}
onDidRenameFiles(handler) {
this.connection.onNotification(vscode_languageserver_protocol_1.DidRenameFilesNotification.type, (params) => {
handler(params);
});
}
onDidDeleteFiles(handler) {
this.connection.onNotification(vscode_languageserver_protocol_1.DidDeleteFilesNotification.type, (params) => {
handler(params);
});
}
onWillCreateFiles(handler) {
return this.connection.onRequest(vscode_languageserver_protocol_1.WillCreateFilesRequest.type, (params, cancel) => {
return handler(params, cancel);
});
}
onWillRenameFiles(handler) {
return this.connection.onRequest(vscode_languageserver_protocol_1.WillRenameFilesRequest.type, (params, cancel) => {
return handler(params, cancel);
});
}
onWillDeleteFiles(handler) {
return this.connection.onRequest(vscode_languageserver_protocol_1.WillDeleteFilesRequest.type, (params, cancel) => {
return handler(params, cancel);
});
}
};
};
exports.FileOperationsFeature = FileOperationsFeature;
//# sourceMappingURL=fileOperations.js.map

View File

@@ -0,0 +1,16 @@
import { LinkedEditingRangeParams, LinkedEditingRanges } 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>): void;
}
export declare const LinkedEditingRangeFeature: Feature<_Languages, LinkedEditingRangeFeatureShape>;

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.
* ------------------------------------------------------------------------------------------ */
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) {
this.connection.onRequest(vscode_languageserver_protocol_1.LinkedEditingRangeRequest.type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
});
}
};
};
exports.LinkedEditingRangeFeature = LinkedEditingRangeFeature;
//# sourceMappingURL=linkedEditingRange.js.map

View File

@@ -0,0 +1,13 @@
import { MonikerParams, Moniker } 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>): void;
};
}
export declare const MonikerFeature: Feature<_Languages, MonikerFeatureShape>;

View File

@@ -0,0 +1,24 @@
/* --------------------------------------------------------------------------------------------
* 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;
this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
},
};
}
};
};
exports.MonikerFeature = MonikerFeature;
//# sourceMappingURL=moniker.js.map

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,160 @@
"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) {
var _a;
if (((_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.window) === null || _a === void 0 ? void 0 : _a.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 = 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;
//# sourceMappingURL=progress.js.map

View File

@@ -0,0 +1,31 @@
import { SemanticTokens, SemanticTokensPartialResult, SemanticTokensDelta, SemanticTokensDeltaPartialResult, SemanticTokensParams, SemanticTokensDeltaParams, SemanticTokensRangeParams } 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: {
on(handler: ServerRequestHandler<SemanticTokensParams, SemanticTokens, SemanticTokensPartialResult, void>): void;
onDelta(handler: ServerRequestHandler<SemanticTokensDeltaParams, SemanticTokensDelta | SemanticTokens, SemanticTokensDeltaPartialResult | SemanticTokensDeltaPartialResult, void>): void;
onRange(handler: ServerRequestHandler<SemanticTokensRangeParams, SemanticTokens, SemanticTokensPartialResult, void>): void;
};
}
export declare const SemanticTokensFeature: Feature<_Languages, SemanticTokensFeatureShape>;
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,127 @@
"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.SemanticTokensFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const SemanticTokensFeature = (Base) => {
return class extends Base {
get semanticTokens() {
return {
on: (handler) => {
const type = vscode_languageserver_protocol_1.SemanticTokensRequest.type;
this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
},
onDelta: (handler) => {
const type = vscode_languageserver_protocol_1.SemanticTokensDeltaRequest.type;
this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
},
onRange: (handler) => {
const type = vscode_languageserver_protocol_1.SemanticTokensRangeRequest.type;
this.connection.onRequest(type, (params, cancel) => {
return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
});
}
};
}
};
};
exports.SemanticTokensFeature = SemanticTokensFeature;
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) {
const prevDataLength = this._prevData.length;
const dataLength = this._data.length;
let startIndex = 0;
while (startIndex < dataLength && startIndex < prevDataLength && this._prevData[startIndex] === this._data[startIndex]) {
startIndex++;
}
if (startIndex < dataLength && startIndex < prevDataLength) {
// Find end index
let endIndex = 0;
while (endIndex < dataLength && endIndex < prevDataLength && this._prevData[prevDataLength - 1 - endIndex] === this._data[dataLength - 1 - endIndex]) {
endIndex++;
}
const newData = this._data.slice(startIndex, dataLength - endIndex);
const result = {
resultId: this.id,
edits: [
{ start: startIndex, deleteCount: prevDataLength - endIndex - startIndex, data: newData }
]
};
return result;
}
else if (startIndex < dataLength) {
return { resultId: this.id, edits: [
{ start: startIndex, deleteCount: 0, data: this._data.slice(startIndex) }
] };
}
else if (startIndex < prevDataLength) {
return { resultId: this.id, edits: [
{ start: startIndex, deleteCount: prevDataLength - startIndex }
] };
}
else {
return { resultId: this.id, edits: [] };
}
}
else {
return this.build();
}
}
}
exports.SemanticTokensBuilder = SemanticTokensBuilder;
//# sourceMappingURL=semanticTokens.js.map

View File

@@ -0,0 +1,867 @@
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, TextDocumentContentChangeEvent, TextDocumentSaveReason, Event, MessageSignature, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse, WorkDoneProgressParams, PartialResultParams, RegistrationType, RequestType0, RequestType, NotificationType0, NotificationType } from 'vscode-languageserver-protocol';
import { WorkDoneProgressReporter, ResultProgressReporter, WindowProgress } from './progress';
import { Configuration } from './configuration';
import { WorkspaceFolders } from './workspaceFolders';
import { CallHierarchy } from './callHierarchy';
import { SemanticTokensFeatureShape } from './semanticTokens';
import { ShowDocumentFeatureShape } from './showDocument';
import { FileOperationsFeatureShape } from './fileOperations';
import { LinkedEditingRangeFeatureShape } from './linkedEditingRange';
import { MonikerFeatureShape } from './moniker';
export interface TextDocumentsConfiguration<T> {
create(uri: string, 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
*/
export declare class TextDocuments<T> {
private _configuration;
private _documents;
private _onDidChangeContent;
private _onDidOpen;
private _onDidClose;
private _onDidSave;
private _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 or the content changes.
*/
get onDidChangeContent(): Event<TextDocumentChangeEvent<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
* 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: Connection): void;
}
/**
* 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;
}
/**
*
*/
interface Remote {
/**
* 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;
/**
* 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;
}
/**
* 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 {
/**
* 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 {
/**
* 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 {
/**
* 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 {
/**
* 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 {
/**
* 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 {
/**
* 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 {
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 & MonikerFeatureShape;
/**
* 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 = _> {
/**
* Start listening on the input stream for messages to process.
*/
listen(): void;
/**
* Installs a request handler described by the given [RequestType](#RequestType).
*
* @param type The [RequestType](#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>): void;
onRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, handler: RequestHandler<P, R, E>): void;
onRequest<R, PR, E, RO>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): void;
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): void;
/**
* 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>): void;
/**
* 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): void;
/**
* Send a request to the client.
*
* @param type The [RequestType](#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 [NotificationType](#NotificationType).
*
* @param type The [NotificationType](#NotificationType) describing the notification.
* @param handler The handler to install.
*/
onNotification<RO>(type: ProtocolNotificationType0<RO>, handler: NotificationHandler0): void;
onNotification<P, RO>(type: ProtocolNotificationType<P, RO>, handler: NotificationHandler<P>): void;
onNotification(type: NotificationType0, handler: NotificationHandler0): void;
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): void;
/**
* 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): void;
/**
* 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): void;
/**
* Send a notification to the client.
*
* @param type The [NotificationType](#NotificationType) describing the notification.
* @param params The notification's parameters.
*/
sendNotification<RO>(type: ProtocolNotificationType0<RO>): void;
sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params: P): void;
sendNotification(type: NotificationType0): void;
sendNotification<P>(type: NotificationType<P>, params: P): 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): 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): void;
/**
* Installs a handler for the initialize request.
*
* @param handler The initialize handler.
*/
onInitialize(handler: ServerRequestHandler<InitializeParams, InitializeResult, never, InitializeError>): void;
/**
* Installs a handler for the initialized notification.
*
* @param handler The initialized handler.
*/
onInitialized(handler: NotificationHandler<InitializedParams>): void;
/**
* Installs a handler for the shutdown request.
*
* @param handler The initialize handler.
*/
onShutdown(handler: RequestHandler0<void, void>): void;
/**
* Installs a handler for the exit notification.
*
* @param handler The exit handler.
*/
onExit(handler: NotificationHandler0): void;
/**
* 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;
/**
* Installs a handler for the `DidChangeConfiguration` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeConfiguration(handler: NotificationHandler<DidChangeConfigurationParams>): void;
/**
* Installs a handler for the `DidChangeWatchedFiles` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeWatchedFiles(handler: NotificationHandler<DidChangeWatchedFilesParams>): void;
/**
* Installs a handler for the `DidOpenTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidOpenTextDocument(handler: NotificationHandler<DidOpenTextDocumentParams>): void;
/**
* Installs a handler for the `DidChangeTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeTextDocument(handler: NotificationHandler<DidChangeTextDocumentParams>): void;
/**
* Installs a handler for the `DidCloseTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidCloseTextDocument(handler: NotificationHandler<DidCloseTextDocumentParams>): void;
/**
* 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>): void;
/**
* 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>): void;
/**
* Installs a handler for the `DidSaveTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidSaveTextDocument(handler: NotificationHandler<DidSaveTextDocumentParams>): void;
/**
* Sends diagnostics computed for a given document to VSCode to render them in the
* user interface.
*
* @param params The diagnostic parameters.
*/
sendDiagnostics(params: PublishDiagnosticsParams): void;
/**
* Installs a handler for the `Hover` request.
*
* @param handler The corresponding handler.
*/
onHover(handler: ServerRequestHandler<HoverParams, Hover | undefined | null, never, void>): void;
/**
* Installs a handler for the `Completion` request.
*
* @param handler The corresponding handler.
*/
onCompletion(handler: ServerRequestHandler<CompletionParams, CompletionItem[] | CompletionList | undefined | null, CompletionItem[], void>): void;
/**
* Installs a handler for the `CompletionResolve` request.
*
* @param handler The corresponding handler.
*/
onCompletionResolve(handler: RequestHandler<CompletionItem, CompletionItem, void>): void;
/**
* Installs a handler for the `SignatureHelp` request.
*
* @param handler The corresponding handler.
*/
onSignatureHelp(handler: ServerRequestHandler<SignatureHelpParams, SignatureHelp | undefined | null, never, void>): void;
/**
* Installs a handler for the `Declaration` request.
*
* @param handler The corresponding handler.
*/
onDeclaration(handler: ServerRequestHandler<DeclarationParams, Declaration | DeclarationLink[] | undefined | null, Location[] | DeclarationLink[], void>): void;
/**
* Installs a handler for the `Definition` request.
*
* @param handler The corresponding handler.
*/
onDefinition(handler: ServerRequestHandler<DefinitionParams, Definition | DefinitionLink[] | undefined | null, Location[] | DefinitionLink[], void>): void;
/**
* Installs a handler for the `Type Definition` request.
*
* @param handler The corresponding handler.
*/
onTypeDefinition(handler: ServerRequestHandler<TypeDefinitionParams, Definition | DefinitionLink[] | undefined | null, Location[] | DefinitionLink[], void>): void;
/**
* Installs a handler for the `Implementation` request.
*
* @param handler The corresponding handler.
*/
onImplementation(handler: ServerRequestHandler<ImplementationParams, Definition | DefinitionLink[] | undefined | null, Location[] | DefinitionLink[], void>): void;
/**
* Installs a handler for the `References` request.
*
* @param handler The corresponding handler.
*/
onReferences(handler: ServerRequestHandler<ReferenceParams, Location[] | undefined | null, Location[], void>): void;
/**
* Installs a handler for the `DocumentHighlight` request.
*
* @param handler The corresponding handler.
*/
onDocumentHighlight(handler: ServerRequestHandler<DocumentHighlightParams, DocumentHighlight[] | undefined | null, DocumentHighlight[], void>): void;
/**
* Installs a handler for the `DocumentSymbol` request.
*
* @param handler The corresponding handler.
*/
onDocumentSymbol(handler: ServerRequestHandler<DocumentSymbolParams, SymbolInformation[] | DocumentSymbol[] | undefined | null, SymbolInformation[] | DocumentSymbol[], void>): void;
/**
* Installs a handler for the `WorkspaceSymbol` request.
*
* @param handler The corresponding handler.
*/
onWorkspaceSymbol(handler: ServerRequestHandler<WorkspaceSymbolParams, SymbolInformation[] | undefined | null, SymbolInformation[], void>): void;
/**
* Installs a handler for the `CodeAction` request.
*
* @param handler The corresponding handler.
*/
onCodeAction(handler: ServerRequestHandler<CodeActionParams, (Command | CodeAction)[] | undefined | null, (Command | CodeAction)[], void>): void;
/**
* Installs a handler for the `CodeAction` resolve request.
*
* @param handler The corresponding handler.
*/
onCodeActionResolve(handler: RequestHandler<CodeAction, CodeAction, void>): void;
/**
* Compute a list of [lenses](#CodeLens). 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>): void;
/**
* 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>): void;
/**
* Installs a handler for the document formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentFormatting(handler: ServerRequestHandler<DocumentFormattingParams, TextEdit[] | undefined | null, never, void>): void;
/**
* Installs a handler for the document range formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentRangeFormatting(handler: ServerRequestHandler<DocumentRangeFormattingParams, TextEdit[] | undefined | null, never, void>): void;
/**
* Installs a handler for the document on type formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentOnTypeFormatting(handler: RequestHandler<DocumentOnTypeFormattingParams, TextEdit[] | undefined | null, void>): void;
/**
* Installs a handler for the rename request.
*
* @param handler The corresponding handler.
*/
onRenameRequest(handler: ServerRequestHandler<RenameParams, WorkspaceEdit | undefined | null, never, void>): void;
/**
* Installs a handler for the prepare rename request.
*
* @param handler The corresponding handler.
*/
onPrepareRename(handler: RequestHandler<PrepareRenameParams, Range | {
range: Range;
placeholder: string;
} | undefined | null, void>): void;
/**
* Installs a handler for the document links request.
*
* @param handler The corresponding handler.
*/
onDocumentLinks(handler: ServerRequestHandler<DocumentLinkParams, DocumentLink[] | undefined | null, DocumentLink[], void>): void;
/**
* Installs a handler for the document links resolve request.
*
* @param handler The corresponding handler.
*/
onDocumentLinkResolve(handler: RequestHandler<DocumentLink, DocumentLink | undefined | null, void>): void;
/**
* Installs a handler for the document color request.
*
* @param handler The corresponding handler.
*/
onDocumentColor(handler: ServerRequestHandler<DocumentColorParams, ColorInformation[] | undefined | null, ColorInformation[], void>): void;
/**
* Installs a handler for the document color request.
*
* @param handler The corresponding handler.
*/
onColorPresentation(handler: ServerRequestHandler<ColorPresentationParams, ColorPresentation[] | undefined | null, ColorPresentation[], void>): void;
/**
* Installs a handler for the folding ranges request.
*
* @param handler The corresponding handler.
*/
onFoldingRanges(handler: ServerRequestHandler<FoldingRangeParams, FoldingRange[] | undefined | null, FoldingRange[], void>): void;
/**
* Installs a handler for the selection ranges request.
*
* @param handler The corresponding handler.
*/
onSelectionRanges(handler: ServerRequestHandler<SelectionRangeParams, SelectionRange[] | undefined | null, SelectionRange[], void>): void;
/**
* Installs a handler for the execute command request.
*
* @param handler The corresponding handler.
*/
onExecuteCommand(handler: ServerRequestHandler<ExecuteCommandParams, any | undefined | null, never, void>): void;
/**
* Disposes the connection
*/
dispose(): void;
}
export interface Connection extends _Connection {
}
export interface Feature<B, 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 interface Features<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _> {
__brand: 'features';
console?: ConsoleFeature<PConsole>;
tracer?: TracerFeature<PTracer>;
telemetry?: TelemetryFeature<PTelemetry>;
client?: ClientFeature<PClient>;
window?: WindowFeature<PWindow>;
workspace?: WorkspaceFeature<PWorkspace>;
languages?: LanguagesFeature<PLanguages>;
}
export declare function combineFeatures<OConsole, OTracer, OTelemetry, OClient, OWindow, OWorkspace, TConsole, TTracer, TTelemetry, TClient, TWindow, TWorkspace>(one: Features<OConsole, OTracer, OTelemetry, OClient, OWindow, OWorkspace>, two: Features<TConsole, TTracer, TTelemetry, TClient, TWindow, TWorkspace>): Features<OConsole & TConsole, OTracer & TTracer, OTelemetry & TTelemetry, OClient & TClient, OWindow & TWindow, OWorkspace & TWorkspace>;
export interface WatchDog {
shutdownReceived: boolean;
initialize(params: InitializeParams): void;
exit(code: number): void;
}
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _>(connectionFactory: (logger: Logger) => ProtocolConnection, watchDog: WatchDog, factories?: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>;
export {};

834
node_modules/vscode-languageserver/lib/common/server.js generated vendored Normal file
View File

@@ -0,0 +1,834 @@
"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.combineLanguagesFeatures = exports.combineWorkspaceFeatures = exports.combineWindowFeatures = exports.combineClientFeatures = exports.combineTracerFeatures = exports.combineTelemetryFeatures = exports.combineConsoleFeatures = exports._LanguagesImpl = exports.BulkUnregistration = exports.BulkRegistration = exports.ErrorMessageTracker = exports.TextDocuments = 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 workspaceFolders_1 = require("./workspaceFolders");
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 moniker_1 = require("./moniker");
function null2Undefined(value) {
if (value === null) {
return undefined;
}
return value;
}
/**
* A manager for simple text documents
*/
class TextDocuments {
/**
* Create a new text document manager.
*/
constructor(configuration) {
this._documents = Object.create(null);
this._configuration = configuration;
this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
}
/**
* 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
* has been opened.
*/
get onDidOpen() {
return this._onDidOpen.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._documents[uri];
}
/**
* Returns all text documents managed by this instance.
*
* @return all text documents.
*/
all() {
return Object.keys(this._documents).map(key => this._documents[key]);
}
/**
* Returns the URIs of all text documents managed by this instance.
*
* @return the URI's of all text documents.
*/
keys() {
return Object.keys(this._documents);
}
/**
* 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.Full;
connection.onDidOpenTextDocument((event) => {
let td = event.textDocument;
let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
this._documents[td.uri] = document;
let toFire = Object.freeze({ document });
this._onDidOpen.fire(toFire);
this._onDidChangeContent.fire(toFire);
});
connection.onDidChangeTextDocument((event) => {
let td = event.textDocument;
let changes = event.contentChanges;
if (changes.length === 0) {
return;
}
let document = this._documents[td.uri];
const { version } = td;
if (version === null || version === undefined) {
throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
}
document = this._configuration.update(document, changes, version);
this._documents[td.uri] = document;
this._onDidChangeContent.fire(Object.freeze({ document }));
});
connection.onDidCloseTextDocument((event) => {
let document = this._documents[event.textDocument.uri];
if (document) {
delete this._documents[event.textDocument.uri];
this._onDidClose.fire(Object.freeze({ document }));
}
});
connection.onWillSaveTextDocument((event) => {
let document = this._documents[event.textDocument.uri];
if (document) {
this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
}
});
connection.onWillSaveTextDocumentWaitUntil((event, token) => {
let document = this._documents[event.textDocument.uri];
if (document && this._willSaveWaitUntil) {
return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
}
else {
return [];
}
});
connection.onDidSaveTextDocument((event) => {
let document = this._documents[event.textDocument.uri];
if (document) {
this._onDidSave.fire(Object.freeze({ document }));
}
});
}
}
exports.TextDocuments = TextDocuments;
/**
* 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 });
}
}
}
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 = showDocument_1.ShowDocumentFeature(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).then(undefined, (_error) => {
this._connection.console.info(`Bulk unregistration failed.`);
});
}
disposeSingle(arg) {
const method = Is.string(arg) ? arg : arg.method;
const unregistration = this._unregistrations.get(method);
if (!unregistration) {
return false;
}
let params = {
unregisterations: [unregistration]
};
this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
this._unregistrations.delete(method);
}, (_error) => {
this._connection.console.info(`Un-registering request handler for ${unregistration.id} failed.`);
});
return true;
}
}
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);
});
}, (_error) => {
this.connection.console.info(`Registering request handler for ${method} failed.`);
return Promise.reject(_error);
});
}
unregisterSingle(id, method) {
let params = {
unregisterations: [{ id, method }]
};
return this.connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
this.connection.console.info(`Un-registering request handler for ${id} failed.`);
});
}
registerMany(registrations) {
let params = registrations.asRegistrationParams();
return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
}, (_error) => {
this.connection.console.info(`Bulk registration failed.`);
return Promise.reject(_error);
});
}
}
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 = fileOperations_1.FileOperationsFeature(workspaceFolders_1.WorkspaceFoldersFeature(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
});
}
}
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);
}
}
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 progress_1.attachWorkDone(this.connection, params);
}
attachPartialResultProgress(_type, params) {
return progress_1.attachPartialResult(this.connection, params);
}
}
exports._LanguagesImpl = _LanguagesImpl;
const LanguagesImpl = moniker_1.MonikerFeature(linkedEditingRange_1.LinkedEditingRangeFeature(semanticTokens_1.SemanticTokensFeature(callHierarchy_1.CallHierarchyFeature(_LanguagesImpl))));
function combineConsoleFeatures(one, two) {
return function (Base) {
return two(one(Base));
};
}
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 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)
};
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 allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages];
function asPromise(value) {
if (value instanceof Promise) {
return value;
}
else if (Is.thenable(value)) {
return new Promise((resolve, reject) => {
value.then((resolved) => resolve(resolved), (error) => reject(error));
});
}
else {
return Promise.resolve(value);
}
}
let shutdownHandler = 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) {
connection.sendNotification(method);
}
else {
connection.sendNotification(method, param);
}
},
onNotification: (type, handler) => connection.onNotification(type, handler),
onProgress: connection.onProgress,
sendProgress: connection.sendProgress,
onInitialize: (handler) => initializeHandler = handler,
onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
onShutdown: (handler) => shutdownHandler = handler,
onExit: (handler) => exitHandler = handler,
get console() { return logger; },
get telemetry() { return telemetry; },
get tracer() { return tracer; },
get client() { return client; },
get window() { return remoteWindow; },
get workspace() { return workspace; },
get languages() { return languages; },
onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
__textDocumentSync: 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, progress_1.attachWorkDone(connection, params), undefined);
}),
onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
}),
onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onCodeActionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionResolveRequest.type, (params, cancel) => {
return handler(params, cancel);
}),
onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
return handler(params, cancel);
}),
onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
}),
onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
return handler(params, cancel, 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, 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, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
return handler(params, cancel);
}),
onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
}),
onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
return handler(params, cancel, progress_1.attachWorkDone(connection, params), 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, 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;
//# sourceMappingURL=server.js.map

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,17 @@
"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;
//# sourceMappingURL=showDocument.js.map

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,44 @@
"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;
//# sourceMappingURL=is.js.map

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,98 @@
"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;
//# sourceMappingURL=uuid.js.map

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,35 @@
/* --------------------------------------------------------------------------------------------
* 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 {
initialize(capabilities) {
let workspaceCapabilities = capabilities.workspace;
if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
this._onDidChangeWorkspaceFolders.fire(params.event);
});
}
}
getWorkspaceFolders() {
return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
}
get onDidChangeWorkspaceFolders() {
if (!this._onDidChangeWorkspaceFolders) {
throw new Error('Client doesn\'t support sending workspace folder change events.');
}
if (!this._unregistration) {
this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
}
return this._onDidChangeWorkspaceFolders.event;
}
};
};
exports.WorkspaceFoldersFeature = WorkspaceFoldersFeature;
//# sourceMappingURL=workspaceFolders.js.map

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>;

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

@@ -0,0 +1,263 @@
"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 = 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 = 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 = 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;
//# sourceMappingURL=files.js.map

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 [connection](#IConnection)
*/
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 = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>;
/**
* 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 [connection](#IConnection)
*/
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages>, inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, 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<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>;

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

@@ -0,0 +1,208 @@
"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;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 = node_1.createServerSocketTransport(port);
input = transport[0];
output = transport[1];
}
else if (pipeName) {
let transport = node_1.createServerPipeTransport(pipeName);
input = transport[0];
output = transport[1];
}
}
var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
if (!input) {
throw new Error('Connection input stream is not set. ' + commandLineMessage);
}
if (!output) {
throw new Error('Connection output stream is not set. ' + commandLineMessage);
}
// 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 = node_1.createProtocolConnection(input, output, logger, options);
return result;
};
return server_1.createConnection(connectionFactory, watchDog, factories);
}
//# sourceMappingURL=main.js.map

View File

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

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

@@ -0,0 +1,20 @@
"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 });
}
}
});
//# sourceMappingURL=resolve.js.map

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

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

6
node_modules/vscode-languageserver/node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ----------------------------------------------------------------------------------------- */
export * from './lib/node/main';

7
node_modules/vscode-languageserver/node.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ----------------------------------------------------------------------------------------- */
'use strict';
module.exports = require('./lib/node/main');

35
node_modules/vscode-languageserver/package.json generated vendored Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "vscode-languageserver",
"description": "Language server implementation for node",
"version": "7.0.0",
"author": "Microsoft Corporation",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-languageserver-node.git",
"directory": "server"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"main": "./lib/node/main.js",
"browser": {
"./lib/node/main.js": "./lib/browser/main.js"
},
"typings": "./lib/common/api.d.ts",
"bin": {
"installServerIntoExtension": "./bin/installServerIntoExtension"
},
"dependencies": {
"vscode-languageserver-protocol": "3.16.0"
},
"scripts": {
"prepublishOnly": "git clean -xfd . && npm install && npm run clean && npm run compile && npm test",
"postpublish": "node ../build/npm/post-publish.js",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig-watch.json -w",
"clean": "node ../node_modules/rimraf/bin.js lib",
"test": "node ../node_modules/mocha/bin/_mocha",
"preversion": "npm test"
}
}

View File

@@ -0,0 +1,35 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
For Microsoft vscode-languageserver
This project incorporates material from the project(s) listed below (collectively, “Third Party Code”).
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
granted, whether by implication, estoppel or otherwise.
1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped)
%% DefinitelyTyped NOTICES AND INFORMATION BEGIN HERE
=========================================
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
=========================================
END OF DefinitelyTyped NOTICES AND INFORMATION

View File

@@ -0,0 +1,5 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
interface Thenable<T> extends PromiseLike<T> { }