Merge from vscode fc10e26ea50f82cdd84e9141491357922e6f5fba (#4639)

This commit is contained in:
Anthony Dresser
2019-03-21 10:58:16 -07:00
committed by GitHub
parent 8298db7d13
commit b65ee5b42e
149 changed files with 1408 additions and 814 deletions

View File

@@ -397,7 +397,7 @@ export class InputBox extends Widget {
return errorMsg ? errorMsg.type !== MessageType.ERROR : true;
}
private stylesForType(type: MessageType | undefined): { border: Color | undefined | null; background: Color | undefined | null; foreground: Color | undefined | null } {
private stylesForType(type: MessageType | undefined): { border: Color | undefined; background: Color | undefined; foreground: Color | undefined } {
switch (type) {
case MessageType.INFO: return { border: this.inputValidationInfoBorder, background: this.inputValidationInfoBackground, foreground: this.inputValidationInfoForeground };
case MessageType.WARNING: return { border: this.inputValidationWarningBorder, background: this.inputValidationWarningBackground, foreground: this.inputValidationWarningForeground };

View File

@@ -379,6 +379,18 @@ export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
};
}
export function lastIndex<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): number {
for (let i = array.length - 1; i >= 0; i--) {
const element = array[i];
if (fn(element)) {
return i;
}
}
return -1;
}
export function firstIndex<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): number {
for (let i = 0; i < array.length; i++) {
const element = array[i];

View File

@@ -93,7 +93,6 @@ export function isUndefinedOrNull(obj: any): obj is undefined | null {
return isUndefined(obj) || obj === null;
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
/**

View File

@@ -10,7 +10,7 @@ import { deepClone, assign } from 'vs/base/common/objects';
import { Emitter, Event } from 'vs/base/common/event';
import { createQueuedSender } from 'vs/base/node/processes';
import { ChannelServer as IPCServer, ChannelClient as IPCClient, IChannelClient } from 'vs/base/parts/ipc/node/ipc';
import { isRemoteConsoleLog, log } from 'vs/base/node/console';
import { isRemoteConsoleLog, log } from 'vs/base/common/console';
import { CancellationToken } from 'vs/base/common/cancellation';
import * as errors from 'vs/base/common/errors';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';

View File

@@ -248,6 +248,7 @@ class ProtocolReader {
class ProtocolWriter {
private _isDisposed: boolean;
private readonly _socket: Socket;
private readonly _logFile: number;
private _data: Buffer[];
@@ -255,6 +256,7 @@ class ProtocolWriter {
public lastWriteTime: number;
constructor(socket: Socket, logFile: number) {
this._isDisposed = false;
this._socket = socket;
this._logFile = logFile;
this._data = [];
@@ -264,6 +266,7 @@ class ProtocolWriter {
public dispose(): void {
this.flush();
this._isDisposed = true;
}
public flush(): void {
@@ -272,6 +275,11 @@ class ProtocolWriter {
}
public write(msg: ProtocolMessage) {
if (this._isDisposed) {
console.warn(`Cannot write message in a disposed ProtocolWriter`);
console.warn(msg);
return;
}
if (this._logFile) {
log(this._logFile, `send-${ProtocolMessageTypeToString(msg.type)}-${msg.id}-${msg.ack}-`, msg.data);
}
@@ -373,12 +381,13 @@ export class Protocol implements IDisposable, IMessagePassingProtocol {
}
dispose(): void {
this._socketWriter.dispose();
this._socketReader.dispose();
this._socket.removeListener('close', this._socketCloseListener);
}
end(): void {
this._socket.end();
getSocket(): Socket {
return this._socket;
}
send(buffer: Buffer): void {
@@ -427,8 +436,9 @@ export class Client<TContext = string> extends IPCClient<TContext> {
dispose(): void {
super.dispose();
this.protocol.end();
const socket = this.protocol.getSocket();
this.protocol.dispose();
socket.end();
}
}
@@ -800,10 +810,6 @@ export class PersistentProtocol {
}
}
end(): void {
this._socket.end();
}
readEntireBuffer(): Buffer {
return this._socketReader.readEntireBuffer();
}

View File

@@ -143,7 +143,7 @@ class TestChannel implements IServerChannel {
constructor(private service: ITestService) { }
call(_, command: string, arg: any, cancellationToken: CancellationToken): Promise<any> {
call(_: unknown, command: string, arg: any, cancellationToken: CancellationToken): Promise<any> {
switch (command) {
case 'marco': return this.service.marco();
case 'error': return this.service.error(arg);
@@ -154,7 +154,7 @@ class TestChannel implements IServerChannel {
}
}
listen(_, event: string, arg?: any): Event<any> {
listen(_: unknown, event: string, arg?: any): Event<any> {
switch (event) {
case 'pong': return this.service.pong;
default: throw new Error('not implemented');

View File

@@ -41,7 +41,7 @@ export class TestChannel implements IServerChannel {
constructor(private testService: ITestService) { }
listen(_, event: string): Event<any> {
listen(_: unknown, event: string): Event<any> {
switch (event) {
case 'marco': return this.testService.onMarco;
}
@@ -49,7 +49,7 @@ export class TestChannel implements IServerChannel {
throw new Error('Event not found');
}
call(_, command: string, ...args: any[]): Promise<any> {
call(_: unknown, command: string, ...args: any[]): Promise<any> {
switch (command) {
case 'pong': return this.testService.pong(args[0]);
case 'cancelMe': return this.testService.cancelMe();

View File

@@ -270,7 +270,7 @@ suite('Arrays', () => {
}
test('coalesce', () => {
let a: Array<number | undefined | null> = arrays.coalesce([null, 1, null, 2, 3]);
let a: Array<number | null> = arrays.coalesce([null, 1, null, 2, 3]);
assert.equal(a.length, 3);
assert.equal(a[0], 1);
assert.equal(a[1], 2);
@@ -306,7 +306,7 @@ suite('Arrays', () => {
});
test('coalesce - inplace', function () {
let a: Array<number | undefined | null> = [null, 1, null, 2, 3];
let a: Array<number | null> = [null, 1, null, 2, 3];
arrays.coalesceInPlace(a);
assert.equal(a.length, 3);
assert.equal(a[0], 1);

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { getFirstFrame } from 'vs/base/node/console';
import { getFirstFrame } from 'vs/base/common/console';
import { normalize } from 'vs/base/common/path';
suite('Console', () => {