@@ -21,7 +21,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
2121import * as vscode from 'vscode' ;
2222import {
2323 TaskDefinitionDTO , TaskExecutionDTO , TaskPresentationOptionsDTO , ProcessExecutionOptionsDTO , ProcessExecutionDTO ,
24- ShellExecutionOptionsDTO , ShellExecutionDTO , TaskDTO , TaskHandleDTO , TaskFilterDTO
24+ ShellExecutionOptionsDTO , ShellExecutionDTO , TaskDTO , TaskHandleDTO , TaskFilterDTO , TaskProcessStartedDTO , TaskProcessEndedDTO
2525} from '../shared/tasks' ;
2626
2727export { TaskExecutionDTO } ;
@@ -689,21 +689,47 @@ namespace TaskFilterDTO {
689689}
690690
691691class TaskExecutionImpl implements vscode . TaskExecution {
692- constructor ( readonly _id : string , private readonly _task : vscode . Task , private readonly _tasks : ExtHostTask ) {
692+
693+ private readonly _onDidTaskProcessStarted : Emitter < vscode . TaskProcessStartEvent > = new Emitter < vscode . TaskProcessStartEvent > ( ) ;
694+ private readonly _onDidTaskProcessEnded : Emitter < vscode . TaskProcessEndEvent > = new Emitter < vscode . TaskProcessEndEvent > ( ) ;
695+
696+ constructor ( private readonly _tasks : ExtHostTask , readonly _id : string , private readonly _task : vscode . Task ) {
693697 }
694698
695- get task ( ) : vscode . Task {
699+ public get task ( ) : vscode . Task {
696700 return this . _task ;
697701 }
698702
699703 public terminate ( ) : void {
700704 this . _tasks . terminateTask ( this ) ;
701705 }
706+
707+ public get onDidStartProcess ( ) : Event < vscode . TaskProcessStartEvent > {
708+ return this . _onDidTaskProcessStarted . event ;
709+ }
710+
711+ public fireDidStartProcess ( value : TaskProcessStartedDTO ) : void {
712+ this . _onDidTaskProcessStarted . fire ( {
713+ execution : this ,
714+ processId : value . processId
715+ } ) ;
716+ }
717+
718+ public get onDidEndProcess ( ) : Event < vscode . TaskProcessEndEvent > {
719+ return this . _onDidTaskProcessEnded . event ;
720+ }
721+
722+ public fireDidEndProcess ( value : TaskProcessEndedDTO ) : void {
723+ this . _onDidTaskProcessEnded . fire ( {
724+ execution : this ,
725+ exitCode : value . exitCode
726+ } ) ;
727+ }
702728}
703729
704730namespace TaskExecutionDTO {
705731 export function to ( value : TaskExecutionDTO , tasks : ExtHostTask ) : vscode . TaskExecution {
706- return new TaskExecutionImpl ( value . id , TaskDTO . to ( value . task , tasks . extHostWorkspace ) , tasks ) ;
732+ return new TaskExecutionImpl ( tasks , value . id , TaskDTO . to ( value . task , tasks . extHostWorkspace ) ) ;
707733 }
708734 export function from ( value : vscode . TaskExecution ) : TaskExecutionDTO {
709735 return {
@@ -781,12 +807,26 @@ export class ExtHostTask implements ExtHostTaskShape {
781807 }
782808 }
783809
784- public $taskStarted ( execution : TaskExecutionDTO ) : void {
810+ public $onDidStartTask ( execution : TaskExecutionDTO ) : void {
785811 this . _onDidExecuteTask . fire ( {
786812 execution : this . getTaskExecution ( execution )
787813 } ) ;
788814 }
789815
816+ public $onDidStartTaskProcess ( value : TaskProcessStartedDTO ) : void {
817+ const execution = this . getTaskExecution ( value . id ) ;
818+ if ( execution ) {
819+ execution . fireDidStartProcess ( value ) ;
820+ }
821+ }
822+
823+ public $onDidEndTaskProcess ( value : TaskProcessEndedDTO ) : void {
824+ const execution = this . getTaskExecution ( value . id ) ;
825+ if ( execution ) {
826+ execution . fireDidEndProcess ( value ) ;
827+ }
828+ }
829+
790830 get taskExecutions ( ) : vscode . TaskExecution [ ] {
791831 let result : vscode . TaskExecution [ ] = [ ] ;
792832 this . _taskExecutions . forEach ( value => result . push ( value ) ) ;
@@ -804,7 +844,7 @@ export class ExtHostTask implements ExtHostTaskShape {
804844 return this . _proxy . $terminateTask ( ( execution as TaskExecutionImpl ) . _id ) ;
805845 }
806846
807- public $taskEnded ( execution : TaskExecutionDTO ) : void {
847+ public $OnDidEndTask ( execution : TaskExecutionDTO ) : void {
808848 const _execution = this . getTaskExecution ( execution ) ;
809849 this . _taskExecutions . delete ( execution . id ) ;
810850 this . _onDidTerminateTask . fire ( {
@@ -834,12 +874,16 @@ export class ExtHostTask implements ExtHostTaskShape {
834874 return this . _handleCounter ++ ;
835875 }
836876
837- private getTaskExecution ( execution : TaskExecutionDTO , task ?: vscode . Task ) : TaskExecutionImpl {
877+ private getTaskExecution ( execution : TaskExecutionDTO | string , task ?: vscode . Task ) : TaskExecutionImpl {
878+ if ( typeof execution === 'string' ) {
879+ return this . _taskExecutions . get ( execution ) ;
880+ }
881+
838882 let result : TaskExecutionImpl = this . _taskExecutions . get ( execution . id ) ;
839883 if ( result ) {
840884 return result ;
841885 }
842- result = new TaskExecutionImpl ( execution . id , task ? task : TaskDTO . to ( execution . task , this . _extHostWorkspace ) , this ) ;
886+ result = new TaskExecutionImpl ( this , execution . id , task ? task : TaskDTO . to ( execution . task , this . _extHostWorkspace ) ) ;
843887 this . _taskExecutions . set ( execution . id , result ) ;
844888 return result ;
845889 }
0 commit comments