提交 a2fa13b3 编写于 作者: I isidor

debug: improve registration of debug views

上级 f033f511
......@@ -34,7 +34,6 @@ export class DebugViewlet extends viewlet.Viewlet {
private $el: builder.Builder;
private splitView: splitview.SplitView;
// TODO@Isidor views need to be splitView.collapsibleView to make them more general
private views: (viewlet.CollapsibleViewletView | viewlet.AdaptiveCollapsibleViewletView)[];
private lastFocusedView: viewlet.CollapsibleViewletView | viewlet.AdaptiveCollapsibleViewletView;
......@@ -65,10 +64,11 @@ export class DebugViewlet extends viewlet.Viewlet {
if (this.contextService.getWorkspace()) {
const actionRunner = this.getActionRunner();
const viewDescriptors = debug.DebugViewRegistry.getDebugViews().sort((first, second) => first.order - second.order);
// TODO@Isi viewDescriptors mixed descriptors with different arguments (# of arguments) which means
// you fail to use the createInstance method which checks for the ctor-args of the type you create.
this.views = viewDescriptors.map(dsc => <any> this.instantiationService.createInstance(<any> dsc, actionRunner, this.viewletSettings));
this.views = debug.DebugViewRegistry.getDebugViews().map(viewConstructor => this.instantiationService.createInstance(
viewConstructor,
actionRunner,
this.viewletSettings)
);
this.splitView = new splitview.SplitView(this.$el.getHTMLElement());
this.toDispose.push(this.splitView);
......
......@@ -5,11 +5,11 @@
import uri from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IActionRunner } from 'vs/base/common/actions';
import ee = require('vs/base/common/eventEmitter');
import severity from 'vs/base/common/severity';
import { AdaptiveCollapsibleViewletView, CollapsibleViewletView } from 'vs/workbench/browser/viewlet';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import editor = require('vs/editor/common/editorCommon');
import editorbrowser = require('vs/editor/browser/editorBrowser');
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
......@@ -348,36 +348,31 @@ export interface IDebugEditorContribution extends editor.IEditorContribution {
showHover(range: editor.IEditorRange, hoveringOver: string, focus: boolean): TPromise<void>;
}
// Debug view descriptors and registration
// Debug view registration
export class DebugViewDescriptor extends SyncDescriptor<CollapsibleViewletView | AdaptiveCollapsibleViewletView> {
constructor(ctor: any, public order: number) {
super(ctor);
}
export interface IDebugViewConstructorSignature {
new (actionRunner: IActionRunner, viewletSetings: any, ...services: { serviceId: ServiceIdentifier<any>; }[]): AdaptiveCollapsibleViewletView | CollapsibleViewletView;
}
export interface IDebugViewRegistry {
registerDebugView(descriptor: DebugViewDescriptor): void;
getDebugViews(): DebugViewDescriptor[];
registerDebugView(view: IDebugViewConstructorSignature, order: number): void;
getDebugViews(): IDebugViewConstructorSignature[];
}
class DebugViewRegistryImpl implements IDebugViewRegistry {
private debugViews: DebugViewDescriptor[];
private debugViews: { view: IDebugViewConstructorSignature, order: number }[];
constructor() {
this.debugViews = [];
}
public registerDebugView(descriptor: DebugViewDescriptor): void {
if (this.debugViews.some(dsc => dsc.equals(descriptor))) {
return;
}
this.debugViews.push(descriptor);
public registerDebugView(view: IDebugViewConstructorSignature, order: number): void {
this.debugViews.push({ view, order });
}
public getDebugViews(): DebugViewDescriptor[] {
return this.debugViews;
public getDebugViews(): IDebugViewConstructorSignature[] {
return this.debugViews.sort((first, second) => first.order - second.order)
.map(viewWithOrder => viewWithOrder.view);
}
}
......
......@@ -85,10 +85,10 @@ const openViewletKb: IKeybindings = {
(<panel.PanelRegistry>platform.Registry.as(panel.Extensions.Panels)).setDefaultPanelId(debug.REPL_ID);
// Register default debug views
debug.DebugViewRegistry.registerDebugView(new debug.DebugViewDescriptor(VariablesView, 10));
debug.DebugViewRegistry.registerDebugView(new debug.DebugViewDescriptor(WatchExpressionsView, 20));
debug.DebugViewRegistry.registerDebugView(new debug.DebugViewDescriptor(CallStackView, 30));
debug.DebugViewRegistry.registerDebugView(new debug.DebugViewDescriptor(BreakpointsView, 40));
debug.DebugViewRegistry.registerDebugView(VariablesView, 10);
debug.DebugViewRegistry.registerDebugView(WatchExpressionsView, 20);
debug.DebugViewRegistry.registerDebugView(CallStackView, 30);
debug.DebugViewRegistry.registerDebugView(BreakpointsView, 40);
// register action to open viewlet
const registry = (<wbaregistry.IWorkbenchActionRegistry> platform.Registry.as(wbaregistry.Extensions.WorkbenchActions));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册