44 *--------------------------------------------------------------------------------------------*/
55'use strict' ;
66
7- import { TPromise } from 'vs/base/common/winjs.base' ;
87import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
98import { ICommandService , ICommandEvent , CommandsRegistry } from 'vs/platform/commands/common/commands' ;
109import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
@@ -30,38 +29,38 @@ export class CommandService extends Disposable implements ICommandService {
3029 this . _extensionService . whenInstalledExtensionsRegistered ( ) . then ( value => this . _extensionHostIsReady = value ) ;
3130 }
3231
33- executeCommand < T > ( id : string , ...args : any [ ] ) : TPromise < T > {
32+ executeCommand < T > ( id : string , ...args : any [ ] ) : Promise < T > {
3433 this . _logService . trace ( 'CommandService#executeCommand' , id ) ;
3534
3635 // we always send an activation event, but
3736 // we don't wait for it when the extension
3837 // host didn't yet start and the command is already registered
3938
40- const activation = this . _extensionService . activateByEvent ( `onCommand:${ id } ` ) ;
39+ const activation = Promise . resolve ( this . _extensionService . activateByEvent ( `onCommand:${ id } ` ) ) ;
4140 const commandIsRegistered = ! ! CommandsRegistry . getCommand ( id ) ;
4241
4342 if ( ! this . _extensionHostIsReady && commandIsRegistered ) {
4443 return this . _tryExecuteCommand ( id , args ) ;
4544 } else {
46- let waitFor : TPromise < any > = activation ;
45+ let waitFor : Promise < any > = activation ;
4746 if ( ! commandIsRegistered ) {
48- waitFor = TPromise . join ( [ activation , this . _extensionService . activateByEvent ( `*` ) ] ) ;
47+ waitFor = Promise . all ( [ activation , this . _extensionService . activateByEvent ( `*` ) ] ) ;
4948 }
5049 return waitFor . then ( _ => this . _tryExecuteCommand ( id , args ) ) ;
5150 }
5251 }
5352
54- private _tryExecuteCommand ( id : string , args : any [ ] ) : TPromise < any > {
53+ private _tryExecuteCommand ( id : string , args : any [ ] ) : Promise < any > {
5554 const command = CommandsRegistry . getCommand ( id ) ;
5655 if ( ! command ) {
57- return TPromise . wrapError ( new Error ( `command '${ id } ' not found` ) ) ;
56+ return Promise . reject ( new Error ( `command '${ id } ' not found` ) ) ;
5857 }
5958 try {
6059 this . _onWillExecuteCommand . fire ( { commandId : id } ) ;
6160 const result = this . _instantiationService . invokeFunction . apply ( this . _instantiationService , [ command . handler ] . concat ( args ) ) ;
62- return TPromise . as ( result ) ;
61+ return Promise . resolve ( result ) ;
6362 } catch ( err ) {
64- return TPromise . wrapError ( err ) ;
63+ return Promise . reject ( err ) ;
6564 }
6665 }
6766}
0 commit comments