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

@@ -6,11 +6,12 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService, ICommand, ICommandEvent, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { ICommandService, ICommandEvent, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import Event, { Emitter } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ILogService } from 'vs/platform/log/common/log';
export class CommandService extends Disposable implements ICommandService {
@@ -24,26 +25,31 @@ export class CommandService extends Disposable implements ICommandService {
constructor(
@IInstantiationService private _instantiationService: IInstantiationService,
@IExtensionService private _extensionService: IExtensionService,
@IContextKeyService private _contextKeyService: IContextKeyService
@IContextKeyService private _contextKeyService: IContextKeyService,
@ILogService private _logService: ILogService
) {
super();
this._extensionService.onReady().then(value => this._extensionHostIsReady = value);
this._extensionService.whenInstalledExtensionsRegistered().then(value => this._extensionHostIsReady = value);
}
executeCommand<T>(id: string, ...args: any[]): TPromise<T> {
this._logService.trace('CommandService#executeCommand', id);
// we always send an activation event, but
// we don't wait for it when the extension
// host didn't yet start
// host didn't yet start and the command is already registered
const activation = this._extensionService.activateByEvent(`onCommand:${id}`);
return this._extensionHostIsReady
? activation.then(_ => this._tryExecuteCommand(id, args))
: this._tryExecuteCommand(id, args);
if (!this._extensionHostIsReady && CommandsRegistry.getCommand(id)) {
return this._tryExecuteCommand(id, args);
} else {
return activation.then(_ => this._tryExecuteCommand(id, args));
}
}
private _tryExecuteCommand(id: string, args: any[]): TPromise<any> {
const command = this._getCommand(id);
const command = CommandsRegistry.getCommand(id);
if (!command) {
return TPromise.wrapError(new Error(`command '${id}' not found`));
}
@@ -61,8 +67,4 @@ export class CommandService extends Disposable implements ICommandService {
return TPromise.wrapError(err);
}
}
private _getCommand(id: string): ICommand {
return CommandsRegistry.getCommand(id);
}
}

View File

@@ -9,19 +9,26 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { CommandService } from 'vs/platform/commands/common/commandService';
import { IExtensionService, ExtensionPointContribution, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { IExtensionService, ExtensionPointContribution, IExtensionDescription, IExtensionHostInformation, ProfileSession } from 'vs/platform/extensions/common/extensions';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { IExtensionPoint } from 'vs/platform/extensions/common/extensionsRegistry';
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
import { SimpleConfigurationService } from 'vs/editor/standalone/browser/simpleServices';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import Event, { Emitter } from 'vs/base/common/event';
import { NoopLogService } from 'vs/platform/log/common/log';
class SimpleExtensionService implements IExtensionService {
_serviceBrand: any;
activateByEvent(activationEvent: string): TPromise<void> {
return this.onReady().then(() => { });
private _onDidRegisterExtensions = new Emitter<IExtensionDescription[]>();
get onDidRegisterExtensions(): Event<IExtensionDescription[]> {
return this._onDidRegisterExtensions.event;
}
onReady(): TPromise<boolean> {
onDidChangeExtensionsStatus = null;
activateByEvent(activationEvent: string): TPromise<void> {
return this.whenInstalledExtensionsRegistered().then(() => { });
}
whenInstalledExtensionsRegistered(): TPromise<boolean> {
return TPromise.as(true);
}
readExtensionPointContributions<T>(extPoint: IExtensionPoint<T>): TPromise<ExtensionPointContribution<T>[]> {
@@ -30,12 +37,15 @@ class SimpleExtensionService implements IExtensionService {
getExtensionsStatus() {
return undefined;
}
getExtensionsActivationTimes() {
getExtensionHostInformation(): IExtensionHostInformation {
return undefined;
}
getExtensions(): TPromise<IExtensionDescription[]> {
return TPromise.wrap([]);
}
startExtensionHostProfile(): TPromise<ProfileSession> {
throw new Error('Not implemented');
}
restartExtensionHost(): void {
}
startExtensionHost(): void {
@@ -65,7 +75,7 @@ suite('CommandService', function () {
lastEvent = activationEvent;
return super.activateByEvent(activationEvent);
}
}, new ContextKeyService(new SimpleConfigurationService()));
}, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
return service.executeCommand('foo').then(() => {
assert.ok(lastEvent, 'onCommand:foo');
@@ -83,7 +93,7 @@ suite('CommandService', function () {
activateByEvent(activationEvent: string): TPromise<void> {
return TPromise.wrapError<void>(new Error('bad_activate'));
}
}, new ContextKeyService(new SimpleConfigurationService()));
}, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
return service.executeCommand('foo').then(() => assert.ok(false), err => {
assert.equal(err.message, 'bad_activate');
@@ -95,14 +105,36 @@ suite('CommandService', function () {
let callCounter = 0;
let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1);
let resolve: Function;
let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService {
onReady() {
return new TPromise<boolean>(_resolve => { resolve = _resolve; });
whenInstalledExtensionsRegistered() {
return new TPromise<boolean>(_resolve => { /*ignore*/ });
}
}, new ContextKeyService(new SimpleConfigurationService()));
}, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
return service.executeCommand('bar').then(() => {
service.executeCommand('bar');
assert.equal(callCounter, 1);
reg.dispose();
});
test('issue #34913: !onReady, unknown command', function () {
let callCounter = 0;
let resolveFunc: Function;
// let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1);
let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService {
whenInstalledExtensionsRegistered() {
return new TPromise<boolean>(_resolve => { resolveFunc = _resolve; });
}
}, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
let r = service.executeCommand('bar');
assert.equal(callCounter, 0);
let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1);
resolveFunc(true);
return r.then(() => {
reg.dispose();
assert.equal(callCounter, 1);
});
@@ -113,7 +145,8 @@ suite('CommandService', function () {
let commandService = new CommandService(
new InstantiationService(),
new SimpleExtensionService(),
contextKeyService
contextKeyService,
new NoopLogService()
);
let counter = 0;