66
77import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
88import uri from 'vs/base/common/uri' ;
9- import { IDebugService , IConfig , IDebugConfigurationProvider , IBreakpoint , IFunctionBreakpoint , IBreakpointData , IAdapterExecutable , ITerminalSettings , IDebugAdapter } from 'vs/workbench/parts/debug/common/debug' ;
9+ import { IDebugService , IConfig , IDebugConfigurationProvider , IBreakpoint , IFunctionBreakpoint , IBreakpointData , IAdapterExecutable , ITerminalSettings , IDebugAdapter , IDebugAdapterProvider } from 'vs/workbench/parts/debug/common/debug' ;
1010import { TPromise } from 'vs/base/common/winjs.base' ;
1111import {
1212 ExtHostContext , ExtHostDebugServiceShape , MainThreadDebugServiceShape , DebugSessionUUID , MainContext ,
@@ -19,12 +19,14 @@ import * as paths from 'vs/base/common/paths';
1919
2020
2121@extHostNamedCustomer ( MainContext . MainThreadDebugService )
22- export class MainThreadDebugService implements MainThreadDebugServiceShape {
22+ export class MainThreadDebugService implements MainThreadDebugServiceShape , IDebugAdapterProvider {
2323
2424 private _proxy : ExtHostDebugServiceShape ;
2525 private _toDispose : IDisposable [ ] ;
2626 private _breakpointEventsActive : boolean ;
27- private _extensionHostDebugAdapterProvider : ExtensionHostDebugAdapterProvider ;
27+ private _debugAdapters : Map < number , ExtensionHostDebugAdapter > ;
28+ private _debugAdaptersHandleCounter = 1 ;
29+
2830
2931 constructor (
3032 extHostContext : IExtHostContext ,
@@ -50,12 +52,22 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
5052 }
5153 }
5254 } ) ) ;
53-
54- this . _extensionHostDebugAdapterProvider = new ExtensionHostDebugAdapterProvider ( this . _proxy ) ;
55+ this . _debugAdapters = new Map < number , ExtensionHostDebugAdapter > ( ) ;
5556 }
5657
5758 public $registerDebugTypes ( debugTypes : string [ ] ) {
58- this . _toDispose . push ( this . debugService . getConfigurationManager ( ) . registerDebugAdapterProvider ( debugTypes , this . _extensionHostDebugAdapterProvider ) ) ;
59+ this . _toDispose . push ( this . debugService . getConfigurationManager ( ) . registerDebugAdapterProvider ( debugTypes , this ) ) ;
60+ }
61+
62+ createDebugAdapter ( debugType : string , adapterInfo ) : IDebugAdapter {
63+ const handle = this . _debugAdaptersHandleCounter ++ ;
64+ const da = new ExtensionHostDebugAdapter ( handle , this . _proxy , debugType , adapterInfo ) ;
65+ this . _debugAdapters . set ( handle , da ) ;
66+ return da ;
67+ }
68+
69+ runInTerminal ( args : DebugProtocol . RunInTerminalRequestArguments , config : ITerminalSettings ) : TPromise < void > {
70+ return this . _proxy . $runInTerminal ( args , config ) ;
5971 }
6072
6173 public dispose ( ) : void {
@@ -227,15 +239,15 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
227239 }
228240 } ) ;
229241
230- this . _extensionHostDebugAdapterProvider . acceptMessage ( handle , message ) ;
242+ this . _debugAdapters . get ( handle ) . acceptMessage ( message ) ;
231243 }
232244
233245 public $acceptDAError ( handle : number , name : string , message : string , stack : string ) {
234- this . _extensionHostDebugAdapterProvider . acceptDAError ( handle , new Error ( `${ name } : ${ message } \n${ stack } ` ) ) ;
246+ this . _debugAdapters . get ( handle ) . fireError ( handle , new Error ( `${ name } : ${ message } \n${ stack } ` ) ) ;
235247 }
236248
237249 public $acceptDAExit ( handle : number , code : number , signal : string ) {
238- this . _extensionHostDebugAdapterProvider . acceptDAExit ( handle , code , signal ) ;
250+ this . _debugAdapters . get ( handle ) . fireExit ( handle , code , signal ) ;
239251 }
240252}
241253
@@ -277,39 +289,3 @@ class ExtensionHostDebugAdapter extends AbstractDebugAdapter {
277289 return this . _proxy . $stopDASession ( this . _handle ) ;
278290 }
279291}
280-
281- /**
282- * Interim abstraction for managing debug funtionality in EH.
283- */
284- class ExtensionHostDebugAdapterProvider {
285-
286- private _debugAdapters : Map < number , ExtensionHostDebugAdapter > ;
287- private _debugAdaptersHandleCounter = 1 ;
288-
289- constructor ( private _proxy : ExtHostDebugServiceShape ) {
290- this . _debugAdapters = new Map < number , ExtensionHostDebugAdapter > ( ) ;
291- }
292-
293- acceptMessage ( handle : number , message : DebugProtocol . ProtocolMessage ) {
294- this . _debugAdapters . get ( handle ) . acceptMessage ( message ) ;
295- }
296-
297- acceptDAError ( handle : number , error : Error ) {
298- this . _debugAdapters . get ( handle ) . fireError ( handle , error ) ;
299- }
300-
301- acceptDAExit ( handle : number , code : number , signal : string ) {
302- this . _debugAdapters . get ( handle ) . fireExit ( handle , code , signal ) ;
303- }
304-
305- createDebugAdapter ( debugType : string , adapterInfo ) : IDebugAdapter {
306- const handle = this . _debugAdaptersHandleCounter ++ ;
307- const da = new ExtensionHostDebugAdapter ( handle , this . _proxy , debugType , adapterInfo ) ;
308- this . _debugAdapters . set ( handle , da ) ;
309- return da ;
310- }
311-
312- runInTerminal ( args : DebugProtocol . RunInTerminalRequestArguments , config : ITerminalSettings ) : TPromise < void > {
313- return this . _proxy . $runInTerminal ( args , config ) ;
314- }
315- }
0 commit comments