Initial VS Code 1.19 source merge (#571)

* Initial 1.19 xcopy

* Fix yarn build

* Fix numerous build breaks

* Next batch of build break fixes

* More build break fixes

* Runtime breaks

* Additional post merge fixes

* Fix windows setup file

* Fix test failures.

* Update license header blocks to refer to source eula
This commit is contained in:
Karl Burtram
2018-01-28 23:37:17 -08:00
committed by GitHub
parent 9a1ac20710
commit 251ae01c3e
8009 changed files with 93378 additions and 35634 deletions

View File

@@ -5,9 +5,7 @@
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEventEmitter, EventEmitter } from 'vs/base/common/eventEmitter';
import { IDisposable } from 'vs/base/common/lifecycle';
import * as Events from 'vs/base/common/events';
import Event, { Emitter } from 'vs/base/common/event';
export interface ITelemetryData {
@@ -27,11 +25,13 @@ export interface IAction extends IDisposable {
run(event?: any): TPromise<any>;
}
export interface IActionRunner extends IEventEmitter {
export interface IActionRunner extends IDisposable {
run(action: IAction, context?: any): TPromise<any>;
onDidRun: Event<IRunEvent>;
onDidBeforeRun: Event<IRunEvent>;
}
export interface IActionItem extends IEventEmitter {
export interface IActionItem {
actionRunner: IActionRunner;
setActionContext(context: any): void;
render(element: any /* HTMLElement */): void;
@@ -41,33 +41,6 @@ export interface IActionItem extends IEventEmitter {
dispose(): void;
}
/**
* Checks if the provided object is compatible
* with the IAction interface.
* @param thing an object
*/
export function isAction(thing: any): thing is IAction {
if (!thing) {
return false;
} else if (thing instanceof Action) {
return true;
} else if (typeof thing.id !== 'string') {
return false;
} else if (typeof thing.label !== 'string') {
return false;
} else if (typeof thing.class !== 'string') {
return false;
} else if (typeof thing.enabled !== 'boolean') {
return false;
} else if (typeof thing.checked !== 'boolean') {
return false;
} else if (typeof thing.run !== 'function') {
return false;
} else {
return true;
}
}
export interface IActionChangeEvent {
label?: string;
tooltip?: string;
@@ -222,23 +195,44 @@ export interface IRunEvent {
error?: any;
}
export class ActionRunner extends EventEmitter implements IActionRunner {
export class ActionRunner implements IActionRunner {
private _onDidBeforeRun = new Emitter<IRunEvent>();
private _onDidRun = new Emitter<IRunEvent>();
public get onDidRun(): Event<IRunEvent> {
return this._onDidRun.event;
}
public get onDidBeforeRun(): Event<IRunEvent> {
return this._onDidBeforeRun.event;
}
public run(action: IAction, context?: any): TPromise<any> {
if (!action.enabled) {
return TPromise.as(null);
}
this.emit(Events.EventType.BEFORE_RUN, { action: action });
this._onDidBeforeRun.fire({ action: action });
return this.runAction(action, context).then((result: any) => {
this.emit(Events.EventType.RUN, <IRunEvent>{ action: action, result: result });
this._onDidRun.fire({ action: action, result: result });
}, (error: any) => {
this.emit(Events.EventType.RUN, <IRunEvent>{ action: action, error: error });
this._onDidRun.fire({ action: action, error: error });
});
}
protected runAction(action: IAction, context?: any): TPromise<any> {
return TPromise.as(context ? action.run(context) : action.run());
const res = context ? action.run(context) : action.run();
if (TPromise.is(res)) {
return res;
}
return TPromise.wrap(res);
}
public dispose(): void {
// noop
}
}