Keep throwing but add a little more context, #30942

This commit is contained in:
Johannes Rieken 2017-07-24 12:28:03 +02:00
parent 4b20d3e9bf
commit a449cdf121
2 changed files with 8 additions and 3 deletions

View file

@ -21,13 +21,13 @@ export class Menu implements IMenu {
private _onDidChange = new Emitter<IMenu>();
constructor(
private id: MenuId,
private _id: MenuId,
startupSignal: TPromise<boolean>,
@ICommandService private _commandService: ICommandService,
@IContextKeyService private _contextKeyService: IContextKeyService
) {
startupSignal.then(_ => {
const menuItems = MenuRegistry.getMenuItems(id);
const menuItems = MenuRegistry.getMenuItems(_id);
const keysFilter = new Set<string>();
let group: MenuItemGroup;
@ -48,6 +48,9 @@ export class Menu implements IMenu {
// subscribe to context changes
this._disposables.push(this._contextKeyService.onDidChangeContext(keys => {
if (!keys) {
throw new Error(`Receiving bad onDidChangeContext-event form MenuId[${this._id.id}]`);
}
for (let k of keys) {
if (keysFilter.has(k)) {
this._onDidChange.fire();

View file

@ -126,7 +126,7 @@ class ContextKey<T> implements IContextKey<T> {
}
}
export abstract class AbstractContextKeyService {
export abstract class AbstractContextKeyService implements IContextKeyService {
public _serviceBrand: any;
protected _onDidChangeContext: Event<string[]>;
@ -138,6 +138,8 @@ export abstract class AbstractContextKeyService {
this._onDidChangeContextKey = new Emitter<string>();
}
abstract dispose(): void;
public createKey<T>(key: string, defaultValue: T): IContextKey<T> {
return new ContextKey(this, key, defaultValue);
}