Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -9,6 +9,7 @@ import { ServicesAccessor, createDecorator } from 'vs/platform/instantiation/com
import { Event, Emitter } from 'vs/base/common/event';
import { LinkedList } from 'vs/base/common/linkedList';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { keys } from 'vs/base/common/map';
export const ICommandService = createDecorator<ICommandService>('commandService');
@@ -22,9 +23,7 @@ export interface ICommandService {
executeCommand<T = any>(commandId: string, ...args: any[]): Promise<T | undefined>;
}
export interface ICommandsMap {
[id: string]: ICommand;
}
export type ICommandsMap = Map<string, ICommand>;
export interface ICommandHandler {
(accessor: ServicesAccessor, ...args: any[]): void;
@@ -122,10 +121,13 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
}
getCommands(): ICommandsMap {
const result: ICommandsMap = Object.create(null);
this._commands.forEach((value, key) => {
result[key] = this.getCommand(key)!;
});
const result = new Map<string, ICommand>();
for (const key of keys(this._commands)) {
const command = this.getCommand(key);
if (command) {
result.set(key, command);
}
}
return result;
}
};

View File

@@ -68,10 +68,10 @@ suite('Command Tests', function () {
}
});
CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined!, 'string']);
CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined!, 'string']);
assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 'string']));
assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 1]), true);
CommandsRegistry.getCommands().get('test')!.handler.apply(undefined, [undefined!, 'string']);
CommandsRegistry.getCommands().get('test2')!.handler.apply(undefined, [undefined!, 'string']);
assert.throws(() => CommandsRegistry.getCommands().get('test3')!.handler.apply(undefined, [undefined!, 'string']));
assert.equal(CommandsRegistry.getCommands().get('test3')!.handler.apply(undefined, [undefined!, 1]), true);
});
});