@@ -28,7 +28,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
2828import { clipboard } from 'electron' ;
2929import { LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement' ;
3030import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
31- import { IWindowService } from 'vs/platform/windows/common/windows' ;
31+ import { IWindowService , IWindowsService } from 'vs/platform/windows/common/windows' ;
3232import { writeFile } from 'vs/base/node/pfs' ;
3333import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
3434import { memoize } from 'vs/base/common/decorators' ;
@@ -37,6 +37,9 @@ import { Event } from 'vs/base/common/event';
3737import { DisableForWorkspaceAction , DisableGloballyAction } from 'vs/workbench/parts/extensions/electron-browser/extensionsActions' ;
3838import { INotificationService } from 'vs/platform/notification/common/notification' ;
3939import { RuntimeExtensionsInput } from 'vs/workbench/services/extensions/electron-browser/runtimeExtensionsInput' ;
40+ import { IDebugService } from 'vs/workbench/parts/debug/common/debug' ;
41+ import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
42+ import { randomPort } from 'vs/base/node/ports' ;
4043
4144export const IExtensionHostProfileService = createDecorator < IExtensionHostProfileService > ( 'extensionHostProfileService' ) ;
4245
@@ -409,11 +412,17 @@ export class RuntimeExtensionsEditor extends BaseEditor {
409412
410413 public getActions ( ) : IAction [ ] {
411414 return [
415+ this . debugExtensionHostAction ,
412416 this . saveExtensionHostProfileAction ,
413417 this . extensionHostProfileAction
414418 ] ;
415419 }
416420
421+ @memoize
422+ private get debugExtensionHostAction ( ) : IAction {
423+ return this . _instantiationService . createInstance ( DebugExtensionHostAction ) ;
424+ }
425+
417426 @memoize
418427 private get extensionHostProfileAction ( ) : IAction {
419428 return this . _instantiationService . createInstance ( ExtensionHostProfileAction , ExtensionHostProfileAction . ID , ExtensionHostProfileAction . LABEL_START ) ;
@@ -484,6 +493,45 @@ class ReportExtensionIssueAction extends Action {
484493 }
485494}
486495
496+ class DebugExtensionHostAction extends Action {
497+ static readonly ID = 'workbench.extensions.action.debugExtensionHost' ;
498+ static LABEL = nls . localize ( 'debugExtensionHost' , "Start Debugging Extension Host" ) ;
499+ static CSS_CLASS = 'debug-extension-host' ;
500+
501+ constructor (
502+ @IDebugService private readonly _debugService : IDebugService ,
503+ @IWindowsService private readonly _windowsService : IWindowsService ,
504+ @IDialogService private readonly _dialogService : IDialogService ,
505+ @IExtensionService private readonly _extensionService : IExtensionService ,
506+ ) {
507+ super ( DebugExtensionHostAction . ID , DebugExtensionHostAction . LABEL , DebugExtensionHostAction . CSS_CLASS ) ;
508+ }
509+
510+ run ( ) : TPromise < any > {
511+
512+ const inspectPort = this . _extensionService . getInspectPort ( ) ;
513+ if ( ! inspectPort ) {
514+ return this . _dialogService . confirm ( {
515+ type : 'info' ,
516+ message : nls . localize ( 'restart1' , "Profile Extensions" ) ,
517+ detail : nls . localize ( 'restart2' , "In order to profile extensions a restart is required. Do you want to restart '{0}' now?" , product . nameLong ) ,
518+ primaryButton : nls . localize ( 'restart3' , "Restart" ) ,
519+ secondaryButton : nls . localize ( 'cancel' , "Cancel" )
520+ } ) . then ( res => {
521+ if ( res . confirmed ) {
522+ this . _windowsService . relaunch ( { addArgs : [ `--inspect-extensions=${ randomPort ( ) } ` ] } ) ;
523+ }
524+ } ) ;
525+ }
526+
527+ return this . _debugService . startDebugging ( null , {
528+ type : 'node' ,
529+ request : 'attach' ,
530+ port : inspectPort
531+ } ) ;
532+ }
533+ }
534+
487535class ExtensionHostProfileAction extends Action {
488536 static readonly ID = 'workbench.extensions.action.extensionHostProfile' ;
489537 static LABEL_START = nls . localize ( 'extensionHostProfileStart' , "Start Extension Host Profile" ) ;
0 commit comments