1
>
/*---------------------------------------------------------------------------------------------
commandService.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { CancelablePromise, notCancellablePromise, raceCancellablePromises, timeout } from '../../../../base/common/async.js';
7
>
import { Emitter, Event } from '../../../../base/common/event.js';
8
>
import { Disposable } from '../../../../base/common/lifecycle.js';
9
>
import { CommandsRegistry, ICommandEvent, ICommandService } from '../../../../platform/commands/common/commands.js';
10
>
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
11
>
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
12
>
import { ILogService } from '../../../../platform/log/common/log.js';
13
>
import { IExtensionService } from '../../extensions/common/extensions.js';
14
>
15
>
export class CommandService extends Disposable implements ICommandService {
16
>
17
>
declare readonly _serviceBrand: undefined;
18
>
19
>
private _extensionHostIsReady: boolean = false;
20
>
private _starActivation: CancelablePromise<void> | null;
21
>
22
>
private readonly _onWillExecuteCommand: Emitter<ICommandEvent> = this._register(new Emitter<ICommandEvent>());
23
>
public readonly onWillExecuteCommand: Event<ICommandEvent> = this._onWillExecuteCommand.event;
24
>
25
>
private readonly _onDidExecuteCommand = this._register(new Emitter<ICommandEvent>());
26
>
public readonly onDidExecuteCommand: Event<ICommandEvent> = this._onDidExecuteCommand.event;
27
>
28
>
constructor(
29
>
@IInstantiationService private readonly _instantiationService: IInstantiationService,
30
>
@IExtensionService private readonly _extensionService: IExtensionService,
31
>
@ILogService private readonly _logService: ILogService
32
>
) {
33
>
super();
34
>
this._extensionService.whenInstalledExtensionsRegistered().then(value => this._extensionHostIsReady = value);
35
>
this._starActivation = null;
36
>
}
37
>
38
>
private _activateStar(): Promise<void> {
39
if (!this._starActivation) {
40
// wait for * activation, limited to at most 30s.