Skip to content

Commit

Permalink
support to enable inspector when asking for inspect port and consume …
Browse files Browse the repository at this point in the history
…in auto extension profiler
  • Loading branch information
jrieken committed Oct 7, 2019
1 parent 2ca0000 commit 0f2cda1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio
}
}

public startProfiling(): Promise<any> | null {
public async startProfiling(): Promise<any> {
if (this._state !== ProfileSessionState.None) {
return null;
}

const inspectPort = this._extensionService.getInspectPort();
const inspectPort = await this._extensionService.getInspectPort(false);
if (!inspectPort) {
return this._dialogService.confirm({
type: 'info',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ExtensionsAutoProfiler extends Disposable implements IWorkbenchCont

private async _onDidChangeResponsiveChange(event: IResponsiveStateChangeEvent): Promise<void> {

const port = this._extensionService.getInspectPort();
const port = await this._extensionService.getInspectPort(true);

if (!port) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ export class DebugExtensionHostAction extends Action {

async run(): Promise<any> {

const inspectPort = this._extensionService.getInspectPort();
const inspectPort = await this._extensionService.getInspectPort(false);
if (!inspectPort) {
const res = await this._dialogService.confirm({
type: 'info',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
return result;
}

public getInspectPort(): number {
return 0;
public getInspectPort(_tryEnableInspector: boolean): Promise<number> {
return Promise.resolve(0);
}

public async setRemoteEnvironment(env: { [key: string]: string | null }): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ export class ExtensionHostProcessManager extends Disposable {
});
}

public getInspectPort(): number {
public async getInspectPort(tryEnableInspector: boolean): Promise<number> {
if (this._extensionHostProcessWorker) {
if (tryEnableInspector) {
await this._extensionHostProcessWorker.enableInspectPort();
}
let port = this._extensionHostProcessWorker.getInspectPort();
if (port) {
return port;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/services/extensions/common/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export interface IExtensionService {
* Return the inspect port or `0`, the latter means inspection
* is not possible.
*/
getInspectPort(): number;
getInspectPort(tryEnableInspector: boolean): Promise<number>;

/**
* Restarts the extension host.
Expand Down Expand Up @@ -271,7 +271,7 @@ export class NullExtensionService implements IExtensionService {
getExtension() { return Promise.resolve(undefined); }
readExtensionPointContributions<T>(_extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]> { return Promise.resolve(Object.create(null)); }
getExtensionsStatus(): { [id: string]: IExtensionsStatus; } { return Object.create(null); }
getInspectPort(): number { return 0; }
getInspectPort(_tryEnableInspector: boolean): Promise<number> { return Promise.resolve(0); }
restartExtensionHost(): void { }
async setRemoteEnvironment(_env: { [key: string]: string | null }): Promise<void> { }
canAddExtension(): boolean { return false; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ export class ExtensionService extends AbstractExtensionService implements IExten
this._doHandleExtensionPoints(this._registry.getAllExtensionDescriptions());
}

public getInspectPort(): number {
public async getInspectPort(tryEnableInspector: boolean): Promise<number> {
if (this._extensionHostProcessManagers.length > 0) {
return this._extensionHostProcessManagers[0].getInspectPort();
return this._extensionHostProcessManagers[0].getInspectPort(tryEnableInspector);
}
return 0;
}
Expand Down

0 comments on commit 0f2cda1

Please sign in to comment.