提交 06fc2f75 编写于 作者: I isidor

debug service: fully remove the reference to active session

上级 e40ef831
...@@ -86,6 +86,7 @@ export interface ISession { ...@@ -86,6 +86,7 @@ export interface ISession {
completions(args: DebugProtocol.CompletionsArguments): TPromise<DebugProtocol.CompletionsResponse>; completions(args: DebugProtocol.CompletionsArguments): TPromise<DebugProtocol.CompletionsResponse>;
setVariable(args: DebugProtocol.SetVariableArguments): TPromise<DebugProtocol.SetVariableResponse>; setVariable(args: DebugProtocol.SetVariableArguments): TPromise<DebugProtocol.SetVariableResponse>;
source(args: DebugProtocol.SourceArguments): TPromise<DebugProtocol.SourceResponse>;
} }
export interface IProcess extends ITreeElement { export interface IProcess extends ITreeElement {
......
...@@ -141,26 +141,26 @@ export class DebugService implements debug.IDebugService { ...@@ -141,26 +141,26 @@ export class DebugService implements debug.IDebugService {
this.toDispose.push(this.windowService.onBroadcast(this.onBroadcast, this)); this.toDispose.push(this.windowService.onBroadcast(this.onBroadcast, this));
} }
private get session(): RawDebugSession {
return this.viewModel.focusedProcess ? <RawDebugSession>(<model.Process>this.viewModel.focusedProcess).session : null;
}
private onBroadcast(broadcast: IBroadcast): void { private onBroadcast(broadcast: IBroadcast): void {
// attach: PH is ready to be attached to // attach: PH is ready to be attached to
// TODO@Isidor this is a hack to just get any 'extensionHost' session.
// Optimally the broadcast would contain the id of the session
// We are only intersted if we have an active debug session for extensionHost
const session = <RawDebugSession>this.model.getProcesses().map(p => p.session).filter(s => s.configuration.type === 'extensionHost').pop();
if (broadcast.channel === EXTENSION_ATTACH_BROADCAST_CHANNEL) { if (broadcast.channel === EXTENSION_ATTACH_BROADCAST_CHANNEL) {
this.rawAttach(broadcast.payload.port); this.rawAttach(session, broadcast.payload.port);
return; return;
} }
if (broadcast.channel === EXTENSION_TERMINATE_BROADCAST_CHANNEL) { if (broadcast.channel === EXTENSION_TERMINATE_BROADCAST_CHANNEL) {
this.onSessionEnd(this.session); this.onSessionEnd(session);
return; return;
} }
// from this point on we require an active session // from this point on we require an active session
if (!this.session || this.session.configuration.type !== 'extensionHost') { if (!session) {
return; // we are only intersted if we have an active debug session for extensionHost return;
} }
// a plugin logged output, show it inside the REPL // a plugin logged output, show it inside the REPL
...@@ -720,9 +720,9 @@ export class DebugService implements debug.IDebugService { ...@@ -720,9 +720,9 @@ export class DebugService implements debug.IDebugService {
}); });
} }
private rawAttach(port: number): TPromise<any> { private rawAttach(session: RawDebugSession, port: number): TPromise<any> {
if (this.session) { if (session) {
return this.session.attach({ port }); return session.attach({ port });
} }
this.setStateAndEmit(debug.State.Initializing); this.setStateAndEmit(debug.State.Initializing);
...@@ -818,8 +818,9 @@ export class DebugService implements debug.IDebugService { ...@@ -818,8 +818,9 @@ export class DebugService implements debug.IDebugService {
if (source.inMemory) { if (source.inMemory) {
// internal module // internal module
if (source.reference !== 0 && this.session && source.available) { const process = this.viewModel.focusedProcess;
return this.session.source({ sourceReference: source.reference }).then(response => { if (source.reference !== 0 && process && source.available) {
return process.session.source({ sourceReference: source.reference }).then(response => {
const mime = response && response.body && response.body.mimeType ? response.body.mimeType : guessMimeTypes(source.name)[0]; const mime = response && response.body && response.body.mimeType ? response.body.mimeType : guessMimeTypes(source.name)[0];
const inputValue = response && response.body ? response.body.content : ''; const inputValue = response && response.body ? response.body.content : '';
return this.getDebugStringEditorInput(source, inputValue, mime); return this.getDebugStringEditorInput(source, inputValue, mime);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册