提交 943835bf 编写于 作者: I isidor

debug: remove isAttach field from debugService, get it from configuration

fixes #11163
上级 b7ab0e8c
......@@ -38,14 +38,15 @@ export class DebugSelectActionItem extends SelectActionItem {
}
private updateOptions(changeDebugConfiguration: boolean): TPromise<any> {
return this.debugService.getConfigurationManager().loadLaunchConfig().then(config => {
const configurationManager = this.debugService.getConfigurationManager();
return configurationManager.loadLaunchConfig().then(config => {
if (!config || !config.configurations || config.configurations.length === 0) {
this.setOptions([nls.localize('noConfigurations', "No Configurations")], 0);
return changeDebugConfiguration ? this.actionRunner.run(this._action, null) : null;
}
const configurationNames = config.configurations.filter(cfg => !!cfg.name).map(cfg => cfg.name);
const configurationName = this.debugService.getConfigurationManager().configurationName;
const configurationName = configurationManager.configuration ? configurationManager.configuration.name : null;
let selected = configurationNames.indexOf(configurationName);
this.setOptions(configurationNames, selected);
......
......@@ -142,12 +142,12 @@ export class RestartAction extends AbstractDebugAction {
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action restart', debugService, keybindingService);
this.toDispose.push(this.debugService.onDidChangeState(() => {
const session = this.debugService.getActiveSession();
if (session) {
this.updateLabel(session.configuration.isAttach ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL);
}
}));
this.setLabel(this.debugService.getConfigurationManager().configuration);
this.toDispose.push(this.debugService.getConfigurationManager().onDidConfigurationChange(config => this.setLabel(config)));
}
private setLabel(config: debug.IConfig): void {
this.updateLabel(config.request === 'attach' ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL);
}
public run(): TPromise<any> {
......@@ -273,8 +273,7 @@ export class DisconnectAction extends AbstractDebugAction {
}
protected isEnabled(state: debug.State): boolean {
const session = this.debugService.getActiveSession();
return super.isEnabled(state) && state !== debug.State.Inactive && session && session.configuration.isAttach;
return super.isEnabled(state) && state !== debug.State.Inactive;
}
}
......
......@@ -180,10 +180,11 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution {
this.toDispose.push(this.pauseAction);
this.toDispose.push(this.disconnectAction);
}
this.actions[0] = state === debug.State.Running ? this.pauseAction : this.continueAction;
const session = this.debugService.getActiveSession();
this.actions[5] = session && session.configuration.isAttach ? this.disconnectAction : this.stopAction;
const configuration = this.debugService.getConfigurationManager().configuration;
this.actions[5] = configuration && configuration.request === 'attach' ? this.disconnectAction : this.stopAction;
if (session && session.configuration.capabilities.supportsStepBack) {
if (!this.stepBackAction) {
......
......@@ -250,7 +250,7 @@ export interface IRawBreakpointContribution {
}
export interface IRawDebugSession {
configuration: { type: string, isAttach: boolean, capabilities: DebugProtocol.Capabilites };
configuration: { type: string, capabilities: DebugProtocol.Capabilites };
disconnect(restart?: boolean, force?: boolean): TPromise<DebugProtocol.DisconnectResponse>;
......@@ -265,7 +265,7 @@ export interface IRawDebugSession {
}
export interface IConfigurationManager {
configurationName: string;
configuration: IConfig;
setConfiguration(name: string): TPromise<void>;
openConfigFile(sideBySide: boolean): TPromise<boolean>;
loadLaunchConfig(): TPromise<IGlobalConfig>;
......@@ -274,7 +274,7 @@ export interface IConfigurationManager {
/**
* Allows to register on change of debug configuration.
*/
onDidConfigurationChange: Event<string>;
onDidConfigurationChange: Event<IConfig>;
}
export const IDebugService = createDecorator<IDebugService>(DEBUG_SERVICE_ID);
......
......@@ -118,7 +118,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
const configurationManager = debugService.getConfigurationManager();
return configurationManager.setConfiguration(configuration)
.then(() => {
return configurationManager.configurationName ? debugService.createSession(false)
return configurationManager.configuration ? debugService.createSession(false)
: TPromise.wrapError(new Error(nls.localize('launchConfigDoesNotExist', "Launch configuration '{0}' does not exist.", configuration)));
});
}
......
......@@ -739,11 +739,7 @@ export class DebugService implements debug.IDebugService {
private rawAttach(port: number): TPromise<any> {
if (this.session) {
if (!this.session.configuration.isAttach) {
return this.session.attach({ port });
}
this.session.disconnect().done(null, errors.onUnexpectedError);
return this.session.attach({ port });
}
this.setStateAndEmit(debug.State.Initializing);
......
......@@ -52,7 +52,6 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
private startTime: number;
private stopServerPending: boolean;
private sentPromises: TPromise<DebugProtocol.Response>[];
private isAttach: boolean;
private capabilities: DebugProtocol.Capabilites;
private _onDidInitialize: Emitter<DebugProtocol.InitializedEvent>;
......@@ -212,10 +211,9 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this._onDidEvent.fire(event);
}
public get configuration(): { type: string, isAttach: boolean, capabilities: DebugProtocol.Capabilites } {
public get configuration(): { type: string, capabilities: DebugProtocol.Capabilites } {
return {
type: this.adapter.type,
isAttach: this.isAttach,
capabilities: this.capabilities || {}
};
}
......@@ -233,12 +231,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
}
public launch(args: DebugProtocol.LaunchRequestArguments): TPromise<DebugProtocol.LaunchResponse> {
this.isAttach = false;
return this.send('launch', args).then(response => this.readCapabilities(response));
}
public attach(args: DebugProtocol.AttachRequestArguments): TPromise<DebugProtocol.AttachResponse> {
this.isAttach = true;
return this.send('attach', args).then(response => this.readCapabilities(response));
}
......@@ -358,7 +354,7 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
let command = '';
if (platform.isWindows) {
const quote = (s: string) => {
s = s.replace(/\"/g, '""');
return (s.indexOf(' ') >= 0 || s.indexOf('"') >= 0) ? `"${s}"` : s;
......
......@@ -175,7 +175,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
private systemVariables: ISystemVariables;
private adapters: Adapter[];
private allModeIdsForBreakpoints: { [key: string]: boolean };
private _onDidConfigurationChange: Emitter<string>;
private _onDidConfigurationChange: Emitter<debug.IConfig>;
constructor(
configName: string,
......@@ -189,7 +189,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
@ICommandService private commandService: ICommandService
) {
this.systemVariables = this.contextService.getWorkspace() ? new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService) : null;
this._onDidConfigurationChange = new Emitter<string>();
this._onDidConfigurationChange = new Emitter<debug.IConfig>();
this.setConfiguration(configName);
this.adapters = [];
this.registerListeners();
......@@ -252,7 +252,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
});
}
public get onDidConfigurationChange(): Event<string> {
public get onDidConfigurationChange(): Event<debug.IConfig> {
return this._onDidConfigurationChange.event;
}
......@@ -364,7 +364,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
});
}
}
}).then(() => this._onDidConfigurationChange.fire(this.configurationName));
}).then(() => this._onDidConfigurationChange.fire(this.configuration));
}
public openConfigFile(sideBySide: boolean): TPromise<boolean> {
......
......@@ -145,10 +145,9 @@ export class MockDebugService implements debug.IDebugService {
class MockRawSession implements debug.IRawDebugSession {
public get configuration(): { type: string, isAttach: boolean, capabilities: DebugProtocol.Capabilites } {
public get configuration(): { type: string, capabilities: DebugProtocol.Capabilites } {
return {
type: 'mock',
isAttach: false,
capabilities: {}
};
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册