add hw2
This commit is contained in:
19
node_modules/vscode-languageserver/lib/node/files.d.ts
generated
vendored
Normal file
19
node_modules/vscode-languageserver/lib/node/files.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @deprecated Use the `vscode-uri` npm module which provides a more
|
||||
* complete implementation of handling VS Code URIs.
|
||||
*/
|
||||
export declare function uriToFilePath(uri: string): string | undefined;
|
||||
export declare function resolve(moduleName: string, nodePath: string | undefined, cwd: string | undefined, tracer: (message: string, verbose?: string) => void): Promise<string>;
|
||||
/**
|
||||
* Resolve the global npm package path.
|
||||
* @deprecated Since this depends on the used package manager and their version the best is that servers
|
||||
* implement this themselves since they know best what kind of package managers to support.
|
||||
* @param tracer the tracer to use
|
||||
*/
|
||||
export declare function resolveGlobalNodePath(tracer?: (message: string) => void): string | undefined;
|
||||
export declare function resolveGlobalYarnPath(tracer?: (message: string) => void): string | undefined;
|
||||
export declare namespace FileSystem {
|
||||
function isCaseSensitive(): boolean;
|
||||
function isParent(parent: string, child: string): boolean;
|
||||
}
|
||||
export declare function resolveModulePath(workspaceRoot: string, moduleName: string, nodePath: string, tracer: (message: string, verbose?: string) => void): Promise<string>;
|
||||
262
node_modules/vscode-languageserver/lib/node/files.js
generated
vendored
Normal file
262
node_modules/vscode-languageserver/lib/node/files.js
generated
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
"use strict";
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveModulePath = exports.FileSystem = exports.resolveGlobalYarnPath = exports.resolveGlobalNodePath = exports.resolve = exports.uriToFilePath = void 0;
|
||||
const url = require("url");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const child_process_1 = require("child_process");
|
||||
/**
|
||||
* @deprecated Use the `vscode-uri` npm module which provides a more
|
||||
* complete implementation of handling VS Code URIs.
|
||||
*/
|
||||
function uriToFilePath(uri) {
|
||||
let parsed = url.parse(uri);
|
||||
if (parsed.protocol !== 'file:' || !parsed.path) {
|
||||
return undefined;
|
||||
}
|
||||
let segments = parsed.path.split('/');
|
||||
for (var i = 0, len = segments.length; i < len; i++) {
|
||||
segments[i] = decodeURIComponent(segments[i]);
|
||||
}
|
||||
if (process.platform === 'win32' && segments.length > 1) {
|
||||
let first = segments[0];
|
||||
let second = segments[1];
|
||||
// Do we have a drive letter and we started with a / which is the
|
||||
// case if the first segement is empty (see split above)
|
||||
if (first.length === 0 && second.length > 1 && second[1] === ':') {
|
||||
// Remove first slash
|
||||
segments.shift();
|
||||
}
|
||||
}
|
||||
return path.normalize(segments.join('/'));
|
||||
}
|
||||
exports.uriToFilePath = uriToFilePath;
|
||||
function isWindows() {
|
||||
return process.platform === 'win32';
|
||||
}
|
||||
function resolve(moduleName, nodePath, cwd, tracer) {
|
||||
const nodePathKey = 'NODE_PATH';
|
||||
const app = [
|
||||
'var p = process;',
|
||||
'p.on(\'message\',function(m){',
|
||||
'if(m.c===\'e\'){',
|
||||
'p.exit(0);',
|
||||
'}',
|
||||
'else if(m.c===\'rs\'){',
|
||||
'try{',
|
||||
'var r=require.resolve(m.a);',
|
||||
'p.send({c:\'r\',s:true,r:r});',
|
||||
'}',
|
||||
'catch(err){',
|
||||
'p.send({c:\'r\',s:false});',
|
||||
'}',
|
||||
'}',
|
||||
'});'
|
||||
].join('');
|
||||
return new Promise((resolve, reject) => {
|
||||
let env = process.env;
|
||||
let newEnv = Object.create(null);
|
||||
Object.keys(env).forEach(key => newEnv[key] = env[key]);
|
||||
if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
|
||||
if (newEnv[nodePathKey]) {
|
||||
newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
|
||||
}
|
||||
else {
|
||||
newEnv[nodePathKey] = nodePath;
|
||||
}
|
||||
if (tracer) {
|
||||
tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
|
||||
}
|
||||
}
|
||||
newEnv['ELECTRON_RUN_AS_NODE'] = '1';
|
||||
try {
|
||||
let cp = (0, child_process_1.fork)('', [], {
|
||||
cwd: cwd,
|
||||
env: newEnv,
|
||||
execArgv: ['-e', app]
|
||||
});
|
||||
if (cp.pid === void 0) {
|
||||
reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
|
||||
return;
|
||||
}
|
||||
cp.on('error', (error) => {
|
||||
reject(error);
|
||||
});
|
||||
cp.on('message', (message) => {
|
||||
if (message.c === 'r') {
|
||||
cp.send({ c: 'e' });
|
||||
if (message.s) {
|
||||
resolve(message.r);
|
||||
}
|
||||
else {
|
||||
reject(new Error(`Failed to resolve module: ${moduleName}`));
|
||||
}
|
||||
}
|
||||
});
|
||||
let message = {
|
||||
c: 'rs',
|
||||
a: moduleName
|
||||
};
|
||||
cp.send(message);
|
||||
}
|
||||
catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.resolve = resolve;
|
||||
/**
|
||||
* Resolve the global npm package path.
|
||||
* @deprecated Since this depends on the used package manager and their version the best is that servers
|
||||
* implement this themselves since they know best what kind of package managers to support.
|
||||
* @param tracer the tracer to use
|
||||
*/
|
||||
function resolveGlobalNodePath(tracer) {
|
||||
let npmCommand = 'npm';
|
||||
const env = Object.create(null);
|
||||
Object.keys(process.env).forEach(key => env[key] = process.env[key]);
|
||||
env['NO_UPDATE_NOTIFIER'] = 'true';
|
||||
const options = {
|
||||
encoding: 'utf8',
|
||||
env
|
||||
};
|
||||
if (isWindows()) {
|
||||
npmCommand = 'npm.cmd';
|
||||
options.shell = true;
|
||||
}
|
||||
let handler = () => { };
|
||||
try {
|
||||
process.on('SIGPIPE', handler);
|
||||
let stdout = (0, child_process_1.spawnSync)(npmCommand, ['config', 'get', 'prefix'], options).stdout;
|
||||
if (!stdout) {
|
||||
if (tracer) {
|
||||
tracer(`'npm config get prefix' didn't return a value.`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
let prefix = stdout.trim();
|
||||
if (tracer) {
|
||||
tracer(`'npm config get prefix' value is: ${prefix}`);
|
||||
}
|
||||
if (prefix.length > 0) {
|
||||
if (isWindows()) {
|
||||
return path.join(prefix, 'node_modules');
|
||||
}
|
||||
else {
|
||||
return path.join(prefix, 'lib', 'node_modules');
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
finally {
|
||||
process.removeListener('SIGPIPE', handler);
|
||||
}
|
||||
}
|
||||
exports.resolveGlobalNodePath = resolveGlobalNodePath;
|
||||
/*
|
||||
* Resolve the global yarn pakage path.
|
||||
* @deprecated Since this depends on the used package manager and their version the best is that servers
|
||||
* implement this themselves since they know best what kind of package managers to support.
|
||||
* @param tracer the tracer to use
|
||||
*/
|
||||
function resolveGlobalYarnPath(tracer) {
|
||||
let yarnCommand = 'yarn';
|
||||
let options = {
|
||||
encoding: 'utf8'
|
||||
};
|
||||
if (isWindows()) {
|
||||
yarnCommand = 'yarn.cmd';
|
||||
options.shell = true;
|
||||
}
|
||||
let handler = () => { };
|
||||
try {
|
||||
process.on('SIGPIPE', handler);
|
||||
let results = (0, child_process_1.spawnSync)(yarnCommand, ['global', 'dir', '--json'], options);
|
||||
let stdout = results.stdout;
|
||||
if (!stdout) {
|
||||
if (tracer) {
|
||||
tracer(`'yarn global dir' didn't return a value.`);
|
||||
if (results.stderr) {
|
||||
tracer(results.stderr);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
let lines = stdout.trim().split(/\r?\n/);
|
||||
for (let line of lines) {
|
||||
try {
|
||||
let yarn = JSON.parse(line);
|
||||
if (yarn.type === 'log') {
|
||||
return path.join(yarn.data, 'node_modules');
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// Do nothing. Ignore the line
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
finally {
|
||||
process.removeListener('SIGPIPE', handler);
|
||||
}
|
||||
}
|
||||
exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
|
||||
var FileSystem;
|
||||
(function (FileSystem) {
|
||||
let _isCaseSensitive = undefined;
|
||||
function isCaseSensitive() {
|
||||
if (_isCaseSensitive !== void 0) {
|
||||
return _isCaseSensitive;
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
_isCaseSensitive = false;
|
||||
}
|
||||
else {
|
||||
// convert current file name to upper case / lower case and check if file exists
|
||||
// (guards against cases when name is already all uppercase or lowercase)
|
||||
_isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
|
||||
}
|
||||
return _isCaseSensitive;
|
||||
}
|
||||
FileSystem.isCaseSensitive = isCaseSensitive;
|
||||
function isParent(parent, child) {
|
||||
if (isCaseSensitive()) {
|
||||
return path.normalize(child).indexOf(path.normalize(parent)) === 0;
|
||||
}
|
||||
else {
|
||||
return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
|
||||
}
|
||||
}
|
||||
FileSystem.isParent = isParent;
|
||||
})(FileSystem || (exports.FileSystem = FileSystem = {}));
|
||||
function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
|
||||
if (nodePath) {
|
||||
if (!path.isAbsolute(nodePath)) {
|
||||
nodePath = path.join(workspaceRoot, nodePath);
|
||||
}
|
||||
return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
|
||||
if (FileSystem.isParent(nodePath, value)) {
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
|
||||
}
|
||||
}).then(undefined, (_error) => {
|
||||
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
||||
}
|
||||
}
|
||||
exports.resolveModulePath = resolveModulePath;
|
||||
61
node_modules/vscode-languageserver/lib/node/main.d.ts
generated
vendored
Normal file
61
node_modules/vscode-languageserver/lib/node/main.d.ts
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/// <reference path="../../typings/thenable.d.ts" />
|
||||
/// <reference types="node" />
|
||||
import { Connection, _, _Connection, Features } from '../common/server';
|
||||
import * as fm from './files';
|
||||
import { ConnectionStrategy, ConnectionOptions, MessageReader, MessageWriter } from 'vscode-languageserver-protocol/node';
|
||||
export * from 'vscode-languageserver-protocol/node';
|
||||
export * from '../common/api';
|
||||
export declare namespace Files {
|
||||
let uriToFilePath: typeof fm.uriToFilePath;
|
||||
let resolveGlobalNodePath: typeof fm.resolveGlobalNodePath;
|
||||
let resolveGlobalYarnPath: typeof fm.resolveGlobalYarnPath;
|
||||
let resolve: typeof fm.resolve;
|
||||
let resolveModulePath: typeof fm.resolveModulePath;
|
||||
}
|
||||
/**
|
||||
* Creates a new connection based on the processes command line arguments:
|
||||
*
|
||||
* @param options An optional connection strategy or connection options to control additional settings
|
||||
*/
|
||||
export declare function createConnection(options?: ConnectionStrategy | ConnectionOptions): Connection;
|
||||
/**
|
||||
* Creates a new connection using a the given streams.
|
||||
*
|
||||
* @param inputStream The stream to read messages from.
|
||||
* @param outputStream The stream to write messages to.
|
||||
* @param options An optional connection strategy or connection options to control additional settings
|
||||
* @return A {@link Connection connection}
|
||||
*/
|
||||
export declare function createConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, options?: ConnectionStrategy | ConnectionOptions): Connection;
|
||||
/**
|
||||
* Creates a new connection.
|
||||
*
|
||||
* @param reader The message reader to read messages from.
|
||||
* @param writer The message writer to write message to.
|
||||
* @param options An optional connection strategy or connection options to control additional settings
|
||||
*/
|
||||
export declare function createConnection(reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): Connection;
|
||||
/**
|
||||
* Creates a new connection based on the processes command line arguments. The new connection surfaces proposed API
|
||||
*
|
||||
* @param factories: the factories to use to implement the proposed API
|
||||
* @param options An optional connection strategy or connection options to control additional settings
|
||||
*/
|
||||
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
|
||||
/**
|
||||
* Creates a new connection using a the given streams.
|
||||
*
|
||||
* @param inputStream The stream to read messages from.
|
||||
* @param outputStream The stream to write messages to.
|
||||
* @param options An optional connection strategy or connection options to control additional settings
|
||||
* @return A {@link Connection connection}
|
||||
*/
|
||||
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
|
||||
/**
|
||||
* Creates a new connection.
|
||||
*
|
||||
* @param reader The message reader to read messages from.
|
||||
* @param writer The message writer to write message to.
|
||||
* @param options An optional connection strategy or connection options to control additional settings
|
||||
*/
|
||||
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
|
||||
274
node_modules/vscode-languageserver/lib/node/main.js
generated
vendored
Normal file
274
node_modules/vscode-languageserver/lib/node/main.js
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
"use strict";
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
/// <reference path="../../typings/thenable.d.ts" />
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createConnection = exports.Files = void 0;
|
||||
const node_util_1 = require("node:util");
|
||||
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 = 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) {
|
||||
let stdio = false;
|
||||
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') {
|
||||
stdio = true;
|
||||
input = process.stdin;
|
||||
output = process.stdout;
|
||||
break;
|
||||
}
|
||||
else if (arg === '--socket') {
|
||||
port = parseInt(argv[i + 1]);
|
||||
break;
|
||||
}
|
||||
else if (arg === '--pipe') {
|
||||
pipeName = argv[i + 1];
|
||||
break;
|
||||
}
|
||||
else {
|
||||
var args = arg.split('=');
|
||||
if (args[0] === '--socket') {
|
||||
port = parseInt(args[1]);
|
||||
break;
|
||||
}
|
||||
else if (args[0] === '--pipe') {
|
||||
pipeName = args[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (port) {
|
||||
let transport = (0, node_1.createServerSocketTransport)(port);
|
||||
input = transport[0];
|
||||
output = transport[1];
|
||||
}
|
||||
else if (pipeName) {
|
||||
let transport = (0, node_1.createServerPipeTransport)(pipeName);
|
||||
input = transport[0];
|
||||
output = transport[1];
|
||||
}
|
||||
}
|
||||
var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
|
||||
if (!input) {
|
||||
throw new Error('Connection input stream is not set. ' + commandLineMessage);
|
||||
}
|
||||
if (!output) {
|
||||
throw new Error('Connection output stream is not set. ' + commandLineMessage);
|
||||
}
|
||||
// Backwards compatibility
|
||||
if (Is.func(input.read) && Is.func(input.on)) {
|
||||
let inputStream = input;
|
||||
inputStream.on('end', () => {
|
||||
endProtocolConnection();
|
||||
process.exit(_shutdownReceived ? 0 : 1);
|
||||
});
|
||||
inputStream.on('close', () => {
|
||||
endProtocolConnection();
|
||||
process.exit(_shutdownReceived ? 0 : 1);
|
||||
});
|
||||
}
|
||||
const connectionFactory = (logger) => {
|
||||
const result = (0, node_1.createProtocolConnection)(input, output, logger, options);
|
||||
if (stdio) {
|
||||
patchConsole(logger);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return (0, server_1.createConnection)(connectionFactory, watchDog, factories);
|
||||
}
|
||||
function patchConsole(logger) {
|
||||
function serialize(args) {
|
||||
return args.map(arg => typeof arg === 'string' ? arg : (0, node_util_1.inspect)(arg)).join(' ');
|
||||
}
|
||||
const counters = new Map();
|
||||
console.assert = function assert(assertion, ...args) {
|
||||
if (assertion) {
|
||||
return;
|
||||
}
|
||||
if (args.length === 0) {
|
||||
logger.error('Assertion failed');
|
||||
}
|
||||
else {
|
||||
const [message, ...rest] = args;
|
||||
logger.error(`Assertion failed: ${message} ${serialize(rest)}`);
|
||||
}
|
||||
};
|
||||
console.count = function count(label = 'default') {
|
||||
const message = String(label);
|
||||
let counter = counters.get(message) ?? 0;
|
||||
counter += 1;
|
||||
counters.set(message, counter);
|
||||
logger.log(`${message}: ${message}`);
|
||||
};
|
||||
console.countReset = function countReset(label) {
|
||||
if (label === undefined) {
|
||||
counters.clear();
|
||||
}
|
||||
else {
|
||||
counters.delete(String(label));
|
||||
}
|
||||
};
|
||||
console.debug = function debug(...args) {
|
||||
logger.log(serialize(args));
|
||||
};
|
||||
console.dir = function dir(arg, options) {
|
||||
// @ts-expect-error https://github.com/DefinitelyTyped/DefinitelyTyped/pull/66626
|
||||
logger.log((0, node_util_1.inspect)(arg, options));
|
||||
};
|
||||
console.log = function log(...args) {
|
||||
logger.log(serialize(args));
|
||||
};
|
||||
console.error = function error(...args) {
|
||||
logger.error(serialize(args));
|
||||
};
|
||||
console.trace = function trace(...args) {
|
||||
const stack = new Error().stack.replace(/(.+\n){2}/, '');
|
||||
let message = 'Trace';
|
||||
if (args.length !== 0) {
|
||||
message += `: ${serialize(args)}`;
|
||||
}
|
||||
logger.log(`${message}\n${stack}`);
|
||||
};
|
||||
console.warn = function warn(...args) {
|
||||
logger.warn(serialize(args));
|
||||
};
|
||||
}
|
||||
6
node_modules/vscode-languageserver/lib/node/resolve.d.ts
generated
vendored
Normal file
6
node_modules/vscode-languageserver/lib/node/resolve.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
interface Message {
|
||||
command: string;
|
||||
success?: boolean;
|
||||
args?: any;
|
||||
result?: any;
|
||||
}
|
||||
19
node_modules/vscode-languageserver/lib/node/resolve.js
generated
vendored
Normal file
19
node_modules/vscode-languageserver/lib/node/resolve.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
process.on('message', (message) => {
|
||||
if (message.command === 'exit') {
|
||||
process.exit(0);
|
||||
}
|
||||
else if (message.command === 'resolve') {
|
||||
try {
|
||||
let result = require.resolve(message.args);
|
||||
process.send({ command: 'resolve', success: true, result: result });
|
||||
}
|
||||
catch (err) {
|
||||
process.send({ command: 'resolve', success: false });
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user