提交 e54afc6c 编写于 作者: I isidor

debug debt: remove revealRepl from service interface

上级 ec34824b
......@@ -14,6 +14,8 @@ import dom = require('vs/base/browser/dom');
import platform = require('vs/base/common/platform');
import tree = require('vs/base/parts/tree/browser/tree');
import treeimpl = require('vs/base/parts/tree/browser/treeImpl');
import { IEventService } from 'vs/platform/event/common/event';
import { EventType, CompositeEvent } from 'vs/workbench/common/events';
import viewer = require('vs/workbench/parts/debug/browser/replViewer');
import debug = require('vs/workbench/parts/debug/common/debug');
import debugactions = require('vs/workbench/parts/debug/electron-browser/debugActions');
......@@ -61,7 +63,8 @@ export class Repl extends Panel {
@ITelemetryService telemetryService: ITelemetryService,
@IInstantiationService private instantiationService: IInstantiationService,
@IContextViewService private contextViewService: IContextViewService,
@IStorageService private storageService: IStorageService
@IStorageService private storageService: IStorageService,
@IEventService private eventService: IEventService
) {
super(debug.REPL_ID, telemetryService);
......@@ -73,6 +76,14 @@ export class Repl extends Panel {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.REPL_ELEMENTS_UPDATED, (re: debug.ITreeElement|debug.ITreeElement[]) => {
this.onReplElementsUpdated(re);
}));
this.toDispose.push(this.eventService.addListener2(EventType.COMPOSITE_OPENED, (e: CompositeEvent) => {
if (e.compositeId === debug.REPL_ID) {
const elements = this.debugService.getModel().getReplElements();
if (elements.length > 0) {
return this.reveal(elements[elements.length - 1]);
}
}
}));
}
private onReplElementsUpdated(re: debug.ITreeElement | debug.ITreeElement[]): void {
......
......@@ -338,11 +338,6 @@ export interface IDebugService extends ee.IEventEmitter {
* Opens a new or reveals an already visible editor showing the source.
*/
openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): TPromise<any>;
/**
* Reveals the repl.
*/
revealRepl(focus?: boolean): TPromise<void>;
}
// Editor interfaces
......
......@@ -591,13 +591,19 @@ export class SelectionToWatchExpressionsAction extends EditorAction {
export class SelectionToReplAction extends EditorAction {
static ID = 'editor.debug.action.selectionToRepl';
constructor(descriptor: editorCommon.IEditorActionDescriptorData, editor: editorCommon.ICommonCodeEditor, @IDebugService private debugService: IDebugService) {
constructor(
descriptor: editorCommon.IEditorActionDescriptorData,
editor: editorCommon.ICommonCodeEditor,
@IDebugService private debugService: IDebugService,
@IPanelService private panelService: IPanelService
) {
super(descriptor, editor, Behaviour.TextFocus);
}
public run(): TPromise<any> {
const text = this.editor.getModel().getValueInRange(this.editor.getSelection());
return this.debugService.addReplExpression(text).then(() => this.debugService.revealRepl());
return this.debugService.addReplExpression(text)
.then(() => this.panelService.openPanel(debug.REPL_ID, true));
}
public getGroupId(): string {
......@@ -693,7 +699,11 @@ export class ClearReplAction extends AbstractDebugAction {
static ID = 'workbench.debug.panel.action.clearReplAction';
static LABEL = nls.localize('clearRepl', "Clear Console");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@IPanelService private panelService: IPanelService
) {
super(id, label, 'debug-action clear-repl', debugService, keybindingService);
}
......@@ -701,7 +711,7 @@ export class ClearReplAction extends AbstractDebugAction {
this.debugService.clearReplExpressions();
// focus back to repl
return this.debugService.revealRepl();
return this.panelService.openPanel(debug.REPL_ID, true);
}
}
......@@ -737,7 +747,7 @@ export class ToggleReplAction extends AbstractDebugAction {
return TPromise.as(null);
}
return this.debugService.revealRepl();
return this.panelService.openPanel(debug.REPL_ID, true);
}
private registerListeners(): void {
......
......@@ -35,7 +35,6 @@ import model = require('vs/workbench/parts/debug/common/debugModel');
import { DebugStringEditorInput } from 'vs/workbench/parts/debug/browser/debugEditorInputs';
import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel');
import debugactions = require('vs/workbench/parts/debug/electron-browser/debugActions');
import { Repl } from 'vs/workbench/parts/debug/browser/repl';
import { BreakpointWidget } from 'vs/workbench/parts/debug/browser/breakpointWidget';
import { ConfigurationManager } from 'vs/workbench/parts/debug/node/debugConfigurationManager';
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
......@@ -607,7 +606,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
}).then((result: DebugProtocol.Response) => {
if (changeViewState) {
this.viewletService.openViewlet(debug.VIEWLET_ID);
this.revealRepl(false).done(undefined, errors.onUnexpectedError);
this.panelService.openPanel(debug.REPL_ID, false).done(undefined, errors.onUnexpectedError);
}
// Do not change status bar to orange if we are just running without debug.
......@@ -824,15 +823,6 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
return this.editorService.openEditor(editorInput, wbeditorcommon.TextEditorOptions.create({ preserveFocus: true }), sideBySide);
}
public revealRepl(focus = true): TPromise<void> {
return this.panelService.openPanel(debug.REPL_ID, focus).then((repl: Repl) => {
const elements = this.model.getReplElements();
if (repl && elements.length > 0) {
return repl.reveal(elements[elements.length - 1]);
}
});
}
public canSetBreakpointsIn(model: editor.IModel): boolean {
return this.configurationManager.canSetBreakpointsIn(model);
}
......
......@@ -134,10 +134,6 @@ export class MockDebugService extends ee.EventEmitter implements debug.IDebugSer
public openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): TPromise<any> {
return TPromise.as(null);
}
public revealRepl(focus?: boolean): TPromise<void> {
return TPromise.as(null);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册