@@ -364,10 +364,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
364
364
return Promise . resolve ( this . _variableResolver . resolveAny ( ws , config ) ) ;
365
365
}
366
366
367
- public $startDASession ( handle : number , sessionDto : IDebugSessionDto , folderUri : UriComponents | undefined , config : vscode . DebugConfiguration ) : Thenable < void > {
367
+ public $startDASession ( handle : number , sessionDto : IDebugSessionDto , config : vscode . DebugConfiguration ) : Thenable < void > {
368
368
const mythis = this ;
369
369
370
- return this . getAdapterDescriptor ( this . getAdapterProviderByType ( config . type ) , sessionDto , folderUri , config ) . then ( x => {
370
+ return this . getAdapterDescriptor ( this . getAdapterProviderByType ( config . type ) , sessionDto , config ) . then ( x => {
371
371
372
372
const adapter = this . convertToDto ( x ) ;
373
373
let da : AbstractDebugAdapter | undefined = undefined ;
@@ -393,7 +393,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
393
393
if ( da ) {
394
394
this . _debugAdapters . set ( handle , da ) ;
395
395
396
- return this . getDebugAdapterTrackers ( sessionDto , folderUri , config ) . then ( tracker => {
396
+ return this . getDebugAdapterTrackers ( sessionDto , config ) . then ( tracker => {
397
397
398
398
if ( tracker ) {
399
399
this . _debugAdaptersTrackers . set ( handle , tracker ) ;
@@ -565,12 +565,12 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
565
565
return asThenable ( ( ) => provider . debugAdapterExecutable ( this . getFolder ( folderUri ) , CancellationToken . None ) ) . then ( x => this . convertToDto ( x ) ) ;
566
566
}
567
567
568
- public $provideDebugAdapter ( handle : number , sessionDto : IDebugSessionDto , folderUri : UriComponents | undefined , config : vscode . DebugConfiguration ) : Thenable < IAdapterDescriptor > {
568
+ public $provideDebugAdapter ( handle : number , sessionDto : IDebugSessionDto , config : vscode . DebugConfiguration ) : Thenable < IAdapterDescriptor > {
569
569
let adapterProvider = this . getAdapterProviderByHandle ( handle ) ;
570
570
if ( ! adapterProvider ) {
571
571
return Promise . reject ( new Error ( 'no handler found' ) ) ;
572
572
}
573
- return this . getAdapterDescriptor ( adapterProvider , sessionDto , folderUri , config ) . then ( x => this . convertToDto ( x ) ) ;
573
+ return this . getAdapterDescriptor ( adapterProvider , sessionDto , config ) . then ( x => this . convertToDto ( x ) ) ;
574
574
}
575
575
576
576
public $acceptDebugSessionStarted ( sessionDto : IDebugSessionDto ) : void {
@@ -668,15 +668,14 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
668
668
return false ;
669
669
}
670
670
671
- private getDebugAdapterTrackers ( sessionDto : IDebugSessionDto , folderUri : UriComponents | undefined , config : vscode . DebugConfiguration ) : Promise < vscode . DebugAdapterTracker > {
671
+ private getDebugAdapterTrackers ( sessionDto : IDebugSessionDto , config : vscode . DebugConfiguration ) : Promise < vscode . DebugAdapterTracker > {
672
672
673
673
const session = this . getSession ( sessionDto ) ;
674
- const folder = this . getFolder ( folderUri ) ;
675
674
676
675
const type = config . type ;
677
676
const promises = this . _configProviders
678
677
. filter ( pair => pair . provider . provideDebugAdapterTracker && ( pair . type === type || pair . type === '*' ) )
679
- . map ( pair => asThenable ( ( ) => pair . provider . provideDebugAdapterTracker ( session , folder , config , CancellationToken . None ) ) . then ( p => p ) . catch ( err => null ) ) ;
678
+ . map ( pair => asThenable ( ( ) => pair . provider . provideDebugAdapterTracker ( session , config , CancellationToken . None ) ) . then ( p => p ) . catch ( err => null ) ) ;
680
679
681
680
return Promise . race ( [
682
681
Promise . all ( promises ) . then ( trackers => {
@@ -698,30 +697,34 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
698
697
} ) ;
699
698
}
700
699
701
- private getAdapterDescriptor ( adapterProvider : vscode . DebugAdapterProvider , sessionDto : IDebugSessionDto , folderUri : UriComponents | undefined , config : vscode . DebugConfiguration ) : Thenable < vscode . DebugAdapterDescriptor > {
700
+ private getAdapterDescriptor ( adapterProvider : vscode . DebugAdapterProvider , sessionDto : IDebugSessionDto , config : vscode . DebugConfiguration ) : Thenable < vscode . DebugAdapterDescriptor > {
702
701
703
702
// a "debugServer" attribute in the launch config takes precedence
704
703
if ( typeof config . debugServer === 'number' ) {
705
704
return Promise . resolve ( new DebugAdapterServer ( config . debugServer ) ) ;
706
705
}
707
706
707
+ const session = this . getSession ( sessionDto ) ;
708
+
708
709
// TODO@AW legacy
709
710
const pairs = this . _configProviders . filter ( p => p . type === config . type ) ;
710
711
if ( pairs . length > 0 ) {
711
712
if ( pairs [ 0 ] . provider . debugAdapterExecutable ) {
712
- return asThenable ( ( ) => pairs [ 0 ] . provider . debugAdapterExecutable ( this . getFolder ( folderUri ) , CancellationToken . None ) ) ;
713
+ return asThenable ( ( ) => pairs [ 0 ] . provider . debugAdapterExecutable ( session . workspaceFolder , CancellationToken . None ) ) ;
713
714
}
714
715
}
715
716
716
717
if ( adapterProvider ) {
717
718
const adapterExecutable = ExecutableDebugAdapter . platformAdapterExecutable ( this . _extensionService . getAllExtensionDescriptions ( ) , config . type ) ;
718
- return asThenable ( ( ) => adapterProvider . provideDebugAdapter ( this . getSession ( sessionDto ) , this . getFolder ( folderUri ) , adapterExecutable , config , CancellationToken . None ) ) ;
719
+ return asThenable ( ( ) => adapterProvider . provideDebugAdapter ( session , adapterExecutable , config , CancellationToken . None ) ) ;
719
720
}
720
721
721
722
// try deprecated command based extension API "adapterExecutableCommand" to determine the executable
723
+ // TODO@AW legacy
722
724
const aex = this . _aexCommands . get ( config . type ) ;
723
725
if ( aex ) {
724
- const rootFolder = folderUri ? URI . revive ( folderUri ) . toString ( ) : undefined ;
726
+ const folder = session . workspaceFolder ;
727
+ const rootFolder = folder ? folder . uri . toString ( ) : undefined ;
725
728
return this . _commandService . executeCommand ( aex , rootFolder ) . then ( ( ae : { command : string , args : string [ ] } ) => {
726
729
return new DebugAdapterExecutable ( ae . command , ae . args || [ ] ) ;
727
730
} ) ;
@@ -752,7 +755,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
752
755
if ( dto ) {
753
756
let debugSession = this . _debugSessions . get ( dto . id ) ;
754
757
if ( ! debugSession ) {
755
- debugSession = new ExtHostDebugSession ( this . _debugServiceProxy , dto . id , dto . type , dto . name ) ;
758
+ debugSession = new ExtHostDebugSession ( this . _debugServiceProxy , dto . id , dto . type , dto . name , this . getFolder ( dto . folderUri ) ) ;
756
759
this . _debugSessions . set ( dto . id , debugSession ) ;
757
760
}
758
761
return debugSession ;
@@ -771,17 +774,12 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
771
774
772
775
export class ExtHostDebugSession implements vscode . DebugSession {
773
776
774
- private _debugServiceProxy : MainThreadDebugServiceShape ;
775
-
776
- private _id : DebugSessionUUID ;
777
- private _type : string ;
778
- private _name : string ;
779
-
780
- constructor ( proxy : MainThreadDebugServiceShape , id : DebugSessionUUID , type : string , name : string ) {
781
- this . _debugServiceProxy = proxy ;
782
- this . _id = id ;
783
- this . _type = type ;
784
- this . _name = name ;
777
+ constructor (
778
+ private _debugServiceProxy : MainThreadDebugServiceShape ,
779
+ private _id : DebugSessionUUID ,
780
+ private _type : string ,
781
+ private _name : string ,
782
+ private _workspaceFolder : vscode . WorkspaceFolder | undefined ) {
785
783
}
786
784
787
785
public get id ( ) : string {
@@ -796,6 +794,10 @@ export class ExtHostDebugSession implements vscode.DebugSession {
796
794
return this . _name ;
797
795
}
798
796
797
+ public get workspaceFolder ( ) : vscode . WorkspaceFolder | undefined {
798
+ return this . _workspaceFolder ;
799
+ }
800
+
799
801
public customRequest ( command : string , args : any ) : Thenable < any > {
800
802
return this . _debugServiceProxy . $customDebugAdapterRequest ( this . _id , command , args ) ;
801
803
}
0 commit comments