本文整理汇总了TypeScript中vs/platform/commands/common/commands.CommandsRegistry.getCommand方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CommandsRegistry.getCommand方法的具体用法?TypeScript CommandsRegistry.getCommand怎么用?TypeScript CommandsRegistry.getCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/platform/commands/common/commands.CommandsRegistry
的用法示例。
在下文中一共展示了CommandsRegistry.getCommand方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('register/dispose', function () {
const command = function () { };
const reg = CommandsRegistry.registerCommand('foo', command);
assert.ok(CommandsRegistry.getCommand('foo').handler === command);
reg.dispose();
assert.ok(CommandsRegistry.getCommand('foo') === undefined);
});
示例2: test
test('dispose on unregister', function () {
const commands = new MainThreadCommands(OneGetThreadService(null), undefined);
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
// register
commands.$registerCommand('foo');
assert.ok(CommandsRegistry.getCommand('foo'));
// unregister
commands.$unregisterCommand('foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
示例3: test
test('dispose on unregister', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!);
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
// register
commands.$registerCommand('foo');
assert.ok(CommandsRegistry.getCommand('foo'));
// unregister
commands.$unregisterCommand('foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
示例4: test
test('CommandsRegistry with precondition', function () {
let r1 = CommandsRegistry.registerCommand('foo', () => { });
const precondition = new RawContextKey<boolean>('ddd', false);
let r2 = CommandsRegistry.registerCommand({
id: 'bar',
handler: () => { },
precondition
});
assert.ok(CommandsRegistry.getCommand('bar').precondition === precondition);
assert.equal(CommandsRegistry.getCommand('foo').precondition, undefined);
r1.dispose();
r2.dispose();
});
示例5: test
test('dispose calls unregister', function () {
let lastUnregister: string;
const shape = new class extends mock<MainThreadCommandsShape>() {
$registerCommand(id: string): void {
//
}
$unregisterCommand(id: string): void {
lastUnregister = id;
}
};
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService());
commands.registerCommand(true, 'foo', (): any => { }).dispose();
assert.equal(lastUnregister, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
示例6: test
test('dispose calls unregister', function () {
let lastUnregister: string;
const shape = new class extends mock<MainThreadCommandsShape>() {
$registerCommand(id: string): TPromise<any> {
return undefined;
}
$unregisterCommand(id: string): TPromise<any> {
lastUnregister = id;
return undefined;
}
};
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
commands.registerCommand('foo', (): any => { }).dispose();
assert.equal(lastUnregister, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
示例7:
let connectionService: IConnectionManagementService = accessor.get(IConnectionManagementService);
let objectExplorerService: IObjectExplorerService = accessor.get(IObjectExplorerService);
let connectionProfile = TaskUtilities.getCurrentGlobalConnection(objectExplorerService, connectionService, editorService);
let profilerInput = instantiationService.createInstance(ProfilerInput, connectionProfile);
return editorService.openEditor(profilerInput, { pinned: true }, false).then(() => TPromise.as(true));
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'profiler.newProfiler',
weight: KeybindingsRegistry.WEIGHT.builtinExtension(),
when: undefined,
primary: KeyMod.Alt | KeyCode.KEY_P,
mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_P },
handler: CommandsRegistry.getCommand('profiler.newProfiler').handler
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'profiler.toggleStartStop',
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
when: undefined,
primary: KeyMod.Alt | KeyCode.KEY_S,
mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_S },
handler: (accessor: ServicesAccessor) => {
let profilerService: IProfilerService = accessor.get(IProfilerService);
let editorService: IWorkbenchEditorService = accessor.get(IWorkbenchEditorService);
let activeEditor = editorService.getActiveEditor();
if (activeEditor instanceof ProfilerEditor) {
let profilerInput = activeEditor.input;