当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CommandsRegistry.getCommand方法代码示例

本文整理汇总了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);
	});
开发者ID:GYGit,项目名称:vscode,代码行数:7,代码来源:commands.test.ts

示例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);
	});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:13,代码来源:mainThreadCommands.test.ts

示例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);
	});
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:13,代码来源:mainThreadCommands.test.ts

示例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();
	});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:16,代码来源:commands.test.ts

示例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);

	});
开发者ID:AllureFer,项目名称:vscode,代码行数:19,代码来源:extHostCommands.test.ts

示例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);

	});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:20,代码来源:extHostCommands.test.ts

示例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;
开发者ID:jumpinjackie,项目名称:sqlopsstudio,代码行数:31,代码来源:profilerActions.contribution.ts


注:本文中的vs/platform/commands/common/commands.CommandsRegistry.getCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。