Skip to content

Commit

Permalink
debt - add openExtensionDevelopmentHostWindow into IExtensionHostDebu…
Browse files Browse the repository at this point in the history
…gService
  • Loading branch information
bpasero committed Sep 17, 2019
1 parent 66a25a0 commit a62c6ee
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 60 deletions.
16 changes: 10 additions & 6 deletions src/vs/platform/debug/common/extensionHostDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Event } from 'vs/base/common/event';
import { IRemoteConsoleLog } from 'vs/base/common/console';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { IProcessEnvironment } from 'vs/base/common/platform';

export const IExtensionHostDebugService = createDecorator<IExtensionHostDebugService>('extensionHostDebugService');

Expand Down Expand Up @@ -37,17 +39,19 @@ export interface IExtensionHostDebugService {
_serviceBrand: undefined;

reload(sessionId: string): void;
onReload: Event<IReloadSessionEvent>;
readonly onReload: Event<IReloadSessionEvent>;

close(sessionId: string): void;
onClose: Event<ICloseSessionEvent>;
readonly onClose: Event<ICloseSessionEvent>;

attachSession(sessionId: string, port: number, subId?: string): void;
onAttachSession: Event<IAttachSessionEvent>;
readonly onAttachSession: Event<IAttachSessionEvent>;

logToSession(sessionId: string, log: IRemoteConsoleLog): void;
onLogToSession: Event<ILogToSessionEvent>;
readonly onLogToSession: Event<ILogToSessionEvent>;

terminateSession(sessionId: string, subId?: string): void;
onTerminateSession: Event<ITerminateSessionEvent>;
}
readonly onTerminateSession: Event<ITerminateSessionEvent>;

openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void>;
}
10 changes: 9 additions & 1 deletion src/vs/platform/debug/common/extensionHostDebugIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { IReloadSessionEvent, ICloseSessionEvent, IAttachSessionEvent, ILogToSes
import { Event, Emitter } from 'vs/base/common/event';
import { IRemoteConsoleLog } from 'vs/base/common/console';
import { Disposable } from 'vs/base/common/lifecycle';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { IProcessEnvironment } from 'vs/base/common/platform';

export class ExtensionHostDebugBroadcastChannel<TContext> implements IServerChannel<TContext> {

Expand Down Expand Up @@ -99,4 +101,10 @@ export class ExtensionHostDebugChannelClient extends Disposable implements IExte
get onTerminateSession(): Event<ITerminateSessionEvent> {
return this.channel.listen('terminate');
}
}

openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
// TODO@Isidor
//return this.channel.call('openExtensionDevelopmentHostWindow', [args, env]);
return Promise.resolve();
}
}
43 changes: 0 additions & 43 deletions src/vs/workbench/browser/web.simpleservices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,49 +454,6 @@ export class SimpleWindowsService implements IWindowsService {
}

openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {

// we pass the "ParsedArgs" as query parameters of the URL

let newAddress = `${document.location.origin}/?`;
let gotFolder = false;

const addQueryParameter = (key: string, value: string) => {
const lastChar = newAddress.charAt(newAddress.length - 1);
if (lastChar !== '?' && lastChar !== '&') {
newAddress += '&';
}
newAddress += `${key}=${encodeURIComponent(value)}`;
};

const f = args['folder-uri'];
if (f) {
const u = URI.parse(f[0]);
gotFolder = true;
addQueryParameter('folder', u.path);
}
if (!gotFolder) {
// request empty window
addQueryParameter('ew', 'true');
}

const ep = args['extensionDevelopmentPath'];
if (ep) {
let u = ep[0];
addQueryParameter('edp', u);
}

const di = args['debugId'];
if (di) {
addQueryParameter('di', di);
}

const ibe = args['inspect-brk-extensions'];
if (ibe) {
addQueryParameter('ibe', ibe);
}

window.open(newAddress);

return Promise.resolve();
}

Expand Down
7 changes: 4 additions & 3 deletions src/vs/workbench/contrib/debug/browser/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import { IWorkspaceFolder, IWorkspaceContextService } from 'vs/platform/workspac
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { RunOnceScheduler } from 'vs/base/common/async';
import { generateUuid } from 'vs/base/common/uuid';
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { normalizeDriveLetter } from 'vs/base/common/labels';
import { Range } from 'vs/editor/common/core/range';
Expand Down Expand Up @@ -74,7 +75,7 @@ export class DebugSession implements IDebugSession {
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@INotificationService private readonly notificationService: INotificationService,
@IProductService private readonly productService: IProductService,
@IWindowsService private readonly windowsService: IWindowsService,
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
@IOpenerService private readonly openerService: IOpenerService
) {
this.id = generateUuid();
Expand Down Expand Up @@ -186,7 +187,7 @@ export class DebugSession implements IDebugSession {

return dbgr.createDebugAdapter(this).then(debugAdapter => {

this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.windowsService, this.openerService);
this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.extensionHostDebugService, this.openerService);

return this.raw.start().then(() => {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@

import { ExtensionHostDebugChannelClient, ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
import { IDebugHelperService } from 'vs/workbench/contrib/debug/common/debug';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { Event } from 'vs/base/common/event';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';

class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient {
class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient implements IExtensionHostDebugService {

constructor(
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
Expand Down Expand Up @@ -45,6 +47,52 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient {
}
}));
}

openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
// we pass the "ParsedArgs" as query parameters of the URL

let newAddress = `${document.location.origin}/?`;
let gotFolder = false;

const addQueryParameter = (key: string, value: string) => {
const lastChar = newAddress.charAt(newAddress.length - 1);
if (lastChar !== '?' && lastChar !== '&') {
newAddress += '&';
}
newAddress += `${key}=${encodeURIComponent(value)}`;
};

const f = args['folder-uri'];
if (f) {
const u = URI.parse(f[0]);
gotFolder = true;
addQueryParameter('folder', u.path);
}
if (!gotFolder) {
// request empty window
addQueryParameter('ew', 'true');
}

const ep = args['extensionDevelopmentPath'];
if (ep) {
let u = ep[0];
addQueryParameter('edp', u);
}

const di = args['debugId'];
if (di) {
addQueryParameter('di', di);
}

const ibe = args['inspect-brk-extensions'];
if (ibe) {
addQueryParameter('ibe', ibe);
}

window.open(newAddress);

return Promise.resolve();
}
}

registerSingleton(IExtensionHostDebugService, BrowserExtensionHostDebugService);
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/debug/browser/rawDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { formatPII, isUri } from 'vs/workbench/contrib/debug/common/debugUtils';
import { IDebugAdapter, IConfig, AdapterEndEvent, IDebugger } from 'vs/workbench/contrib/debug/common/debug';
import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
import { URI } from 'vs/base/common/uri';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { env as processEnv } from 'vs/base/common/process';
Expand Down Expand Up @@ -79,7 +79,7 @@ export class RawDebugSession implements IDisposable {
dbgr: IDebugger,
private readonly telemetryService: ITelemetryService,
public readonly customTelemetryService: ITelemetryService | undefined,
private readonly windowsService: IWindowsService,
private readonly extensionHostDebugService: IExtensionHostDebugService,
private readonly openerService: IOpenerService

) {
Expand Down Expand Up @@ -632,7 +632,7 @@ export class RawDebugSession implements IDisposable {
Object.keys(env).filter(k => env[k] === null).forEach(key => delete env[key]);
}

return this.windowsService.openExtensionDevelopmentHostWindow(args, env);
return this.extensionHostDebugService.openExtensionDevelopmentHostWindow(args, env);
}

private send<R extends DebugProtocol.Response>(command: string, args: any, token?: CancellationToken, timeout?: number): Promise<R> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { ExtensionHostDebugChannelClient, ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { ParsedArgs } from 'vs/platform/environment/common/environment';

export class ExtensionHostDebugService extends ExtensionHostDebugChannelClient {

constructor(
@IMainProcessService readonly windowService: IMainProcessService,
@IMainProcessService readonly mainProcessService: IMainProcessService,
@IWindowsService private readonly windowsService: IWindowsService
) {
super(windowService.getChannel(ExtensionHostDebugBroadcastChannel.ChannelName));
super(mainProcessService.getChannel(ExtensionHostDebugBroadcastChannel.ChannelName));
}

openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
// TODO@Isidor use debug IPC channel
return this.windowsService.openExtensionDevelopmentHostWindow(args, env);
}
}

Expand Down

0 comments on commit a62c6ee

Please sign in to comment.