@@ -480,43 +480,43 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
480480 }
481481 } ) ;
482482 }
483-
484- const adapter = this . configurationManager . getAdapter ( ) ;
485- if ( ! adapter ) {
483+ if ( ! this . configurationManager . getAdapter ( ) ) {
486484 return Promise . wrapError ( new Error ( `Configured debug type '${ configuration . type } ' is not supported.` ) ) ;
487485 }
488486
489- return this . runPreLaunchTask ( configuration ) . then ( ( ) => {
490- this . session = new session . RawDebugSession ( this . messageService , this . telemetryService , configuration . debugServer , adapter ) ;
491- this . registerSessionListeners ( ) ;
492-
493- return this . session . initialize ( {
494- adapterID : configuration . type ,
495- linesStartAt1 : true ,
496- pathFormat : 'path'
497- } ) . then ( ( result : DebugProtocol . InitializeResponse ) => {
498- this . setStateAndEmit ( debug . State . Initializing ) ;
499- return configuration . request === 'attach' ? this . session . attach ( configuration ) : this . session . launch ( configuration ) ;
500- } ) . then ( ( result : DebugProtocol . Response ) => {
501- if ( openViewlet ) {
502- this . viewletService . openViewlet ( debug . VIEWLET_ID ) ;
503- }
504- this . partService . addClass ( 'debugging' ) ;
505- this . contextService . updateOptions ( 'editor' , {
506- glyphMargin : true
507- } ) ;
508- this . inDebugMode . set ( true ) ;
509-
510- this . telemetryService . publicLog ( 'debugSessionStart' , { type : configuration . type , breakpointCount : this . model . getBreakpoints ( ) . length , exceptionBreakpoints : this . model . getExceptionBreakpoints ( ) } ) ;
511- } ) . then ( undefined , ( error : Error ) => {
512- this . telemetryService . publicLog ( 'debugMisconfiguration' , { type : configuration ? configuration . type : undefined } ) ;
513- if ( this . session ) {
514- this . session . disconnect ( ) ;
515- }
487+ return this . runPreLaunchTask ( configuration ) . then ( ( ) => this . doCreateSession ( configuration , openViewlet ) ) ;
488+ } ) ;
489+ }
516490
517- return Promise . wrapError ( errors . create ( error . message , { actions : [ CloseAction , this . instantiationService . createInstance ( debugactions . ConfigureAction , debugactions . ConfigureAction . ID , debugactions . ConfigureAction . LABEL ) ] } ) ) ;
518- } ) ;
491+ private doCreateSession ( configuration : debug . IConfig , openViewlet : boolean ) : Promise {
492+ this . session = new session . RawDebugSession ( this . messageService , this . telemetryService , configuration . debugServer , this . configurationManager . getAdapter ( ) ) ;
493+ this . registerSessionListeners ( ) ;
494+
495+ return this . session . initialize ( {
496+ adapterID : configuration . type ,
497+ linesStartAt1 : true ,
498+ pathFormat : 'path'
499+ } ) . then ( ( result : DebugProtocol . InitializeResponse ) => {
500+ this . setStateAndEmit ( debug . State . Initializing ) ;
501+ return configuration . request === 'attach' ? this . session . attach ( configuration ) : this . session . launch ( configuration ) ;
502+ } ) . then ( ( result : DebugProtocol . Response ) => {
503+ if ( openViewlet ) {
504+ this . viewletService . openViewlet ( debug . VIEWLET_ID ) ;
505+ }
506+ this . partService . addClass ( 'debugging' ) ;
507+ this . contextService . updateOptions ( 'editor' , {
508+ glyphMargin : true
519509 } ) ;
510+ this . inDebugMode . set ( true ) ;
511+
512+ this . telemetryService . publicLog ( 'debugSessionStart' , { type : configuration . type , breakpointCount : this . model . getBreakpoints ( ) . length , exceptionBreakpoints : this . model . getExceptionBreakpoints ( ) } ) ;
513+ } ) . then ( undefined , ( error : Error ) => {
514+ this . telemetryService . publicLog ( 'debugMisconfiguration' , { type : configuration ? configuration . type : undefined } ) ;
515+ if ( this . session ) {
516+ this . session . disconnect ( ) ;
517+ }
518+
519+ return Promise . wrapError ( errors . create ( error . message , { actions : [ CloseAction , this . instantiationService . createInstance ( debugactions . ConfigureAction , debugactions . ConfigureAction . ID , debugactions . ConfigureAction . LABEL ) ] } ) ) ;
520520 } ) ;
521521 }
522522
@@ -557,6 +557,18 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
557557 } ) ;
558558 }
559559
560+ public rawAttach ( type : string , port : number ) : Promise {
561+ if ( this . session ) {
562+ return this . session . attach ( { port } ) ;
563+ }
564+
565+ return this . doCreateSession ( {
566+ type,
567+ request : 'attach' ,
568+ port
569+ } , true ) ;
570+ }
571+
560572 public restartSession ( extensionHostData ?: any ) : Promise {
561573 return this . session ? this . session . disconnect ( true ) . then ( ( ) => {
562574 new Promise ( c => {
0 commit comments