This commit is contained in:
2019-02-17 18:07:28 +01:00
parent c69ffb9752
commit 95cff6f702
2301 changed files with 307810 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
export interface ITask<T> {
(): T;
}
export declare class Delayer<T> {
defaultDelay: number;
private timeout;
private completionPromise;
private onSuccess;
private task;
constructor(defaultDelay: number);
trigger(task: ITask<T>, delay?: number): Promise<T>;
forceDelivery(): T | undefined;
isTriggered(): boolean;
cancel(): void;
private cancelTimeout;
}

64
Client/node_modules/vscode-languageclient/lib/utils/async.js generated vendored Executable file
View File

@@ -0,0 +1,64 @@
/* --------------------------------------------------------------------------------------------
* 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 });
class Delayer {
constructor(defaultDelay) {
this.defaultDelay = defaultDelay;
this.timeout = undefined;
this.completionPromise = undefined;
this.onSuccess = undefined;
this.task = undefined;
}
trigger(task, delay = this.defaultDelay) {
this.task = task;
if (delay >= 0) {
this.cancelTimeout();
}
if (!this.completionPromise) {
this.completionPromise = new Promise((resolve) => {
this.onSuccess = resolve;
}).then(() => {
this.completionPromise = undefined;
this.onSuccess = undefined;
var result = this.task();
this.task = undefined;
return result;
});
}
if (delay >= 0 || this.timeout === void 0) {
this.timeout = setTimeout(() => {
this.timeout = undefined;
this.onSuccess(undefined);
}, delay >= 0 ? delay : this.defaultDelay);
}
return this.completionPromise;
}
forceDelivery() {
if (!this.completionPromise) {
return undefined;
}
this.cancelTimeout();
let result = this.task();
this.completionPromise = undefined;
this.onSuccess = undefined;
this.task = undefined;
return result;
}
isTriggered() {
return this.timeout !== void 0;
}
cancel() {
this.cancelTimeout();
this.completionPromise = undefined;
}
cancelTimeout() {
if (this.timeout !== void 0) {
clearTimeout(this.timeout);
this.timeout = undefined;
}
}
}
exports.Delayer = Delayer;

View File

@@ -0,0 +1,9 @@
/// <reference types="node" />
import * as cp from 'child_process';
export interface IForkOpts {
cwd?: string;
env?: any;
encoding?: string;
execArgv?: string[];
}
export declare function fork(modulePath: string, args: string[], options: IForkOpts, callback: (error: any, cp: cp.ChildProcess | undefined) => void): void;

View File

@@ -0,0 +1,101 @@
/* --------------------------------------------------------------------------------------------
* 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 });
const path = require("path");
const os = require("os");
const net = require("net");
const cp = require("child_process");
function makeRandomHexString(length) {
let chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
let result = '';
for (let i = 0; i < length; i++) {
let idx = Math.floor(chars.length * Math.random());
result += chars[idx];
}
return result;
}
function generatePipeName() {
let randomName = 'vscode-lang-' + makeRandomHexString(40);
if (process.platform === 'win32') {
return '\\\\.\\pipe\\' + randomName + '-sock';
}
// Mac/Unix: use socket file
return path.join(os.tmpdir(), randomName + '.sock');
}
function generatePatchedEnv(env, stdInPipeName, stdOutPipeName) {
// Set the two unique pipe names and the electron flag as process env
let newEnv = {};
for (let key in env) {
newEnv[key] = env[key];
}
newEnv['STDIN_PIPE_NAME'] = stdInPipeName;
newEnv['STDOUT_PIPE_NAME'] = stdOutPipeName;
newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
newEnv['ELECTRON_RUN_AS_NODE'] = '1';
return newEnv;
}
function fork(modulePath, args, options, callback) {
let callbackCalled = false;
let resolve = (result) => {
if (callbackCalled) {
return;
}
callbackCalled = true;
callback(undefined, result);
};
let reject = (err) => {
if (callbackCalled) {
return;
}
callbackCalled = true;
callback(err, undefined);
};
// Generate two unique pipe names
let stdInPipeName = generatePipeName();
let stdOutPipeName = generatePipeName();
let newEnv = generatePatchedEnv(options.env || process.env, stdInPipeName, stdOutPipeName);
let childProcess;
// Begin listening to stdout pipe
let stdOutServer = net.createServer((stdOutStream) => {
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
stdOutStream.once('data', (_chunk) => {
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
childProcess.stdin = net.connect(stdInPipeName);
// From now on the childProcess.stdout is available for reading
childProcess.stdout = stdOutStream;
resolve(childProcess);
});
});
stdOutServer.listen(stdOutPipeName);
let serverClosed = false;
let closeServer = () => {
if (serverClosed) {
return;
}
serverClosed = true;
process.removeListener('exit', closeServer);
stdOutServer.close();
};
// Create the process
let bootstrapperPath = path.join(__dirname, 'electronForkStart');
childProcess = cp.fork(bootstrapperPath, [modulePath].concat(args), {
silent: true,
cwd: options.cwd,
env: newEnv,
execArgv: options.execArgv
});
childProcess.once('error', (err) => {
closeServer();
reject(err);
});
childProcess.once('exit', (err) => {
closeServer();
reject(err);
});
// On exit still close server
process.once('exit', closeServer);
}
exports.fork = fork;

View File

@@ -0,0 +1,5 @@
declare var net: any, fs: any, stream: any, util: any;
declare var ENABLE_LOGGING: boolean;
declare var log: (str: string) => void;
declare var stdInPipeName: string | undefined;
declare var stdOutPipeName: string | undefined;

View File

@@ -0,0 +1,147 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var net = require('net'), fs = require('fs'), stream = require('stream'), util = require('util');
var ENABLE_LOGGING = false;
var log = (function () {
if (!ENABLE_LOGGING) {
return function () { };
}
var isFirst = true;
var LOG_LOCATION = 'C:\\stdFork.log';
return function log(str) {
if (isFirst) {
isFirst = false;
fs.writeFileSync(LOG_LOCATION, str + '\n');
return;
}
fs.appendFileSync(LOG_LOCATION, str + '\n');
};
})();
var stdInPipeName = process.env['STDIN_PIPE_NAME'];
var stdOutPipeName = process.env['STDOUT_PIPE_NAME'];
log('STDIN_PIPE_NAME: ' + stdInPipeName);
log('STDOUT_PIPE_NAME: ' + stdOutPipeName);
log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE']);
// stdout redirection to named pipe
(function () {
log('Beginning stdout redirection...');
// Create a writing stream to the stdout pipe
var stdOutStream = net.connect(stdOutPipeName);
// unref stdOutStream to behave like a normal standard out
stdOutStream.unref();
// handle process.stdout
process.__defineGetter__('stdout', function () { return stdOutStream; });
// handle process.stderr
process.__defineGetter__('stderr', function () { return stdOutStream; });
var fsWriteSyncString = function (fd, str, _position, encoding) {
// fs.writeSync(fd, string[, position[, encoding]]);
var buf = new Buffer(str, encoding || 'utf8');
return fsWriteSyncBuffer(fd, buf, 0, buf.length);
};
var fsWriteSyncBuffer = function (_fd, buffer, off, len) {
off = Math.abs(off | 0);
len = Math.abs(len | 0);
// fs.writeSync(fd, buffer, offset, length[, position]);
var buffer_length = buffer.length;
if (off > buffer_length) {
throw new Error('offset out of bounds');
}
if (len > buffer_length) {
throw new Error('length out of bounds');
}
if (((off + len) | 0) < off) {
throw new Error('off + len overflow');
}
if (buffer_length - off < len) {
// Asking for more than is left over in the buffer
throw new Error('off + len > buffer.length');
}
var slicedBuffer = buffer;
if (off !== 0 || len !== buffer_length) {
slicedBuffer = buffer.slice(off, off + len);
}
stdOutStream.write(slicedBuffer);
return slicedBuffer.length;
};
// handle fs.writeSync(1, ...)
var originalWriteSync = fs.writeSync;
fs.writeSync = function (fd, data, _position, _encoding) {
if (fd !== 1) {
return originalWriteSync.apply(fs, arguments);
}
// usage:
// fs.writeSync(fd, buffer, offset, length[, position]);
// OR
// fs.writeSync(fd, string[, position[, encoding]]);
if (data instanceof Buffer) {
return fsWriteSyncBuffer.apply(null, arguments);
}
// For compatibility reasons with fs.writeSync, writing null will write "null", etc
if (typeof data !== 'string') {
data += '';
}
return fsWriteSyncString.apply(null, arguments);
};
log('Finished defining process.stdout, process.stderr and fs.writeSync');
})();
// stdin redirection to named pipe
(function () {
// Begin listening to stdin pipe
var server = net.createServer(function (stream) {
// Stop accepting new connections, keep the existing one alive
server.close();
log('Parent process has connected to my stdin. All should be good now.');
// handle process.stdin
process.__defineGetter__('stdin', function () {
return stream;
});
// Remove myself from process.argv
process.argv.splice(1, 1);
// Load the actual program
var program = process.argv[1];
log('Loading program: ' + program);
// Unset the custom environmental variables that should not get inherited
delete process.env['STDIN_PIPE_NAME'];
delete process.env['STDOUT_PIPE_NAME'];
delete process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
delete process.env['ELECTRON_RUN_AS_NODE'];
require(program);
log('Finished loading program.');
var stdinIsReferenced = true;
var timer = setInterval(function () {
var listenerCount = (stream.listeners('data').length +
stream.listeners('end').length +
stream.listeners('close').length +
stream.listeners('error').length);
// log('listenerCount: ' + listenerCount);
if (listenerCount <= 1) {
// No more "actual" listeners, only internal node
if (stdinIsReferenced) {
stdinIsReferenced = false;
// log('unreferencing stream!!!');
stream.unref();
}
}
else {
// There are "actual" listeners
if (!stdinIsReferenced) {
stdinIsReferenced = true;
stream.ref();
}
}
// log(
// '' + stream.listeners('data').length +
// ' ' + stream.listeners('end').length +
// ' ' + stream.listeners('close').length +
// ' ' + stream.listeners('error').length
// );
}, 1000);
timer.unref();
});
server.listen(stdInPipeName, function () {
// signal via stdout that the parent process can now begin writing to stdin pipe
process.stdout.write('ready');
});
})();

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

43
Client/node_modules/vscode-languageclient/lib/utils/is.js generated vendored Executable file
View File

@@ -0,0 +1,43 @@
/* --------------------------------------------------------------------------------------------
* 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 });
const toString = Object.prototype.toString;
function boolean(value) {
return value === true || value === false;
}
exports.boolean = boolean;
function string(value) {
return toString.call(value) === '[object String]';
}
exports.string = string;
function number(value) {
return toString.call(value) === '[object Number]';
}
exports.number = number;
function error(value) {
return toString.call(value) === '[object Error]';
}
exports.error = error;
function func(value) {
return toString.call(value) === '[object Function]';
}
exports.func = func;
function array(value) {
return Array.isArray(value);
}
exports.array = array;
function stringArray(value) {
return array(value) && value.every(elem => string(elem));
}
exports.stringArray = stringArray;
function typedArray(value, check) {
return Array.isArray(value) && value.every(check);
}
exports.typedArray = typedArray;
function thenable(value) {
return value && func(value.then);
}
exports.thenable = thenable;

View File

@@ -0,0 +1,4 @@
/// <reference types="node" />
import * as cp from 'child_process';
import ChildProcess = cp.ChildProcess;
export declare function terminate(process: ChildProcess, cwd?: string): boolean;

View File

@@ -0,0 +1,46 @@
/* --------------------------------------------------------------------------------------------
* 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 });
const cp = require("child_process");
const path_1 = require("path");
const isWindows = (process.platform === 'win32');
const isMacintosh = (process.platform === 'darwin');
const isLinux = (process.platform === 'linux');
function terminate(process, cwd) {
if (isWindows) {
try {
// This we run in Atom execFileSync is available.
// Ignore stderr since this is otherwise piped to parent.stderr
// which might be already closed.
let options = {
stdio: ['pipe', 'pipe', 'ignore']
};
if (cwd) {
options.cwd = cwd;
}
cp.execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
return true;
}
catch (err) {
return false;
}
}
else if (isLinux || isMacintosh) {
try {
var cmd = path_1.join(__dirname, 'terminateProcess.sh');
var result = cp.spawnSync(cmd, [process.pid.toString()]);
return result.error ? false : true;
}
catch (err) {
return false;
}
}
else {
process.kill('SIGKILL');
return true;
}
}
exports.terminate = terminate;

View File

@@ -0,0 +1,16 @@
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
terminateTree() {
for cpid in $(pgrep -P $1); do
terminateTree $cpid
done
kill -9 $1 > /dev/null 2>&1
}
for pid in $*; do
terminateTree $pid
done

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;

96
Client/node_modules/vscode-languageclient/lib/utils/uuid.js generated vendored Executable file
View File

@@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------------------------
* 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 });
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;