提交 f28c78ff 编写于 作者: I isidor

debug: move DebugViewRegistry to its own file

fixes #8803
上级 6ba2be5e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IActionRunner } from 'vs/base/common/actions';
import { IViewletView } from 'vs/workbench/browser/viewlet';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
// Debug view registration
export interface IDebugViewConstructorSignature {
new (actionRunner: IActionRunner, viewletSetings: any, ...services: { serviceId: ServiceIdentifier<any>; }[]): IViewletView;
}
export interface IDebugViewRegistry {
registerDebugView(view: IDebugViewConstructorSignature, order: number): void;
getDebugViews(): IDebugViewConstructorSignature[];
}
class DebugViewRegistryImpl implements IDebugViewRegistry {
private debugViews: { view: IDebugViewConstructorSignature, order: number }[];
constructor() {
this.debugViews = [];
}
public registerDebugView(view: IDebugViewConstructorSignature, order: number): void {
this.debugViews.push({ view, order });
}
public getDebugViews(): IDebugViewConstructorSignature[] {
return this.debugViews.sort((first, second) => first.order - second.order)
.map(viewWithOrder => viewWithOrder.view);
}
}
export var DebugViewRegistry = <IDebugViewRegistry>new DebugViewRegistryImpl();
......@@ -14,6 +14,7 @@ import { SplitView } from 'vs/base/browser/ui/splitview/splitview';
import memento = require('vs/workbench/common/memento');
import { IViewletView, Viewlet } from 'vs/workbench/browser/viewlet';
import debug = require('vs/workbench/parts/debug/common/debug');
import { DebugViewRegistry } from 'vs/workbench/parts/debug/browser/debugViewRegistry';
import debugactions = require('vs/workbench/parts/debug/electron-browser/debugActions');
import dbgactionitems = require('vs/workbench/parts/debug/browser/debugActionItems');
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -65,7 +66,7 @@ export class DebugViewlet extends Viewlet {
if (this.contextService.getWorkspace()) {
const actionRunner = this.getActionRunner();
this.views = debug.DebugViewRegistry.getDebugViews().map(viewConstructor => this.instantiationService.createInstance(
this.views = DebugViewRegistry.getDebugViews().map(viewConstructor => this.instantiationService.createInstance(
viewConstructor,
actionRunner,
this.viewletSettings)
......
......@@ -5,10 +5,8 @@
import uri from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IActionRunner } from 'vs/base/common/actions';
import Event from 'vs/base/common/event';
import severity from 'vs/base/common/severity';
import { IViewletView } from 'vs/workbench/browser/viewlet';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import editor = require('vs/editor/common/editorCommon');
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
......@@ -415,36 +413,6 @@ export interface IDebugEditorContribution extends editor.IEditorContribution {
showHover(range: Range, hoveringOver: string, focus: boolean): TPromise<void>;
}
// Debug view registration
export interface IDebugViewConstructorSignature {
new (actionRunner: IActionRunner, viewletSetings: any, ...services: { serviceId: ServiceIdentifier<any>; }[]): IViewletView;
}
export interface IDebugViewRegistry {
registerDebugView(view: IDebugViewConstructorSignature, order: number): void;
getDebugViews(): IDebugViewConstructorSignature[];
}
class DebugViewRegistryImpl implements IDebugViewRegistry {
private debugViews: { view: IDebugViewConstructorSignature, order: number }[];
constructor() {
this.debugViews = [];
}
public registerDebugView(view: IDebugViewConstructorSignature, order: number): void {
this.debugViews.push({ view, order });
}
public getDebugViews(): IDebugViewConstructorSignature[] {
return this.debugViews.sort((first, second) => first.order - second.order)
.map(viewWithOrder => viewWithOrder.view);
}
}
export var DebugViewRegistry = <IDebugViewRegistry>new DebugViewRegistryImpl();
// utils
const _formatPIIRegexp = /{([^}]+)}/g;
......
......@@ -20,6 +20,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import wbaregistry = require('vs/workbench/common/actionRegistry');
import viewlet = require('vs/workbench/browser/viewlet');
import panel = require('vs/workbench/browser/panel');
import { DebugViewRegistry } from 'vs/workbench/parts/debug/browser/debugViewRegistry';
import { VariablesView, WatchExpressionsView, CallStackView, BreakpointsView } from 'vs/workbench/parts/debug/browser/debugViews';
import wbext = require('vs/workbench/common/contributions');
import * as debug from 'vs/workbench/parts/debug/common/debug';
......@@ -87,10 +88,10 @@ const openViewletKb: IKeybindings = {
(<panel.PanelRegistry>platform.Registry.as(panel.Extensions.Panels)).setDefaultPanelId(debug.REPL_ID);
// Register default debug views
debug.DebugViewRegistry.registerDebugView(VariablesView, 10);
debug.DebugViewRegistry.registerDebugView(WatchExpressionsView, 20);
debug.DebugViewRegistry.registerDebugView(CallStackView, 30);
debug.DebugViewRegistry.registerDebugView(BreakpointsView, 40);
DebugViewRegistry.registerDebugView(VariablesView, 10);
DebugViewRegistry.registerDebugView(WatchExpressionsView, 20);
DebugViewRegistry.registerDebugView(CallStackView, 30);
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.
先完成此消息的编辑!
想要评论请 注册