From f28c78ff56ae25ac8e0934c4ec3082fb36180ad7 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 7 Jul 2016 10:15:40 +0200 Subject: [PATCH] debug: move DebugViewRegistry to its own file fixes #8803 --- .../parts/debug/browser/debugViewRegistry.ts | 38 +++++++++++++++++++ .../parts/debug/browser/debugViewlet.ts | 3 +- src/vs/workbench/parts/debug/common/debug.ts | 32 ---------------- .../electron-browser/debug.contribution.ts | 9 +++-- 4 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 src/vs/workbench/parts/debug/browser/debugViewRegistry.ts diff --git a/src/vs/workbench/parts/debug/browser/debugViewRegistry.ts b/src/vs/workbench/parts/debug/browser/debugViewRegistry.ts new file mode 100644 index 00000000000..3f890141abc --- /dev/null +++ b/src/vs/workbench/parts/debug/browser/debugViewRegistry.ts @@ -0,0 +1,38 @@ +/*--------------------------------------------------------------------------------------------- + * 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; }[]): 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 = new DebugViewRegistryImpl(); diff --git a/src/vs/workbench/parts/debug/browser/debugViewlet.ts b/src/vs/workbench/parts/debug/browser/debugViewlet.ts index 7b50c52639f..b9c4abf02d7 100644 --- a/src/vs/workbench/parts/debug/browser/debugViewlet.ts +++ b/src/vs/workbench/parts/debug/browser/debugViewlet.ts @@ -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) diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 6713b41b048..546478f66ab 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -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; } -// Debug view registration - -export interface IDebugViewConstructorSignature { - new (actionRunner: IActionRunner, viewletSetings: any, ...services: { serviceId: ServiceIdentifier; }[]): 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 = new DebugViewRegistryImpl(); - // utils const _formatPIIRegexp = /{([^}]+)}/g; diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index bf6be17e63e..9987fd94578 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -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 = { (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 = (platform.Registry.as(wbaregistry.Extensions.WorkbenchActions)); -- GitLab