Use create functions for more descriptors

For #81574

This applies the fix from #84878 to a number of other descriptor classes in our codebase
This commit is contained in:
Matt Bierner 2019-11-14 17:10:34 -08:00
parent bf93700404
commit 5370653cf8
31 changed files with 94 additions and 67 deletions

View file

@ -446,7 +446,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
private registerPanel(commentsPanelAlreadyConstructed: boolean) {
if (!commentsPanelAlreadyConstructed) {
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
CommentsPanel,
COMMENTS_PANEL_ID,
COMMENTS_PANEL_TITLE,

View file

@ -335,7 +335,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
super(id, `${id}.state`, true, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
}
}
const viewletDescriptor = new ViewletDescriptor(
const viewletDescriptor = ViewletDescriptor.create(
CustomViewlet,
id,
title,

View file

@ -7,7 +7,7 @@ import { EditorInput } from 'vs/workbench/common/editor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { Registry } from 'vs/platform/registry/common/platform';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConstructorSignature0, IInstantiationService, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { find } from 'vs/base/common/arrays';
export interface IEditorDescriptor {
@ -54,6 +54,14 @@ export interface IEditorRegistry {
*/
export class EditorDescriptor implements IEditorDescriptor {
public static create<Services extends BrandedService[]>(
ctor: { new(...services: Services): BaseEditor },
id: string,
name: string
): EditorDescriptor {
return new EditorDescriptor(ctor as IConstructorSignature0<BaseEditor>, id, name);
}
constructor(
private readonly ctor: IConstructorSignature0<BaseEditor>,
private readonly id: string,

View file

@ -9,7 +9,7 @@ import { Composite, CompositeDescriptor, CompositeRegistry } from 'vs/workbench/
import { Action } from 'vs/base/common/actions';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
import { IConstructorSignature0, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { isAncestor } from 'vs/base/browser/dom';
import { assertIsDefined } from 'vs/base/common/types';
@ -20,7 +20,11 @@ export abstract class Panel extends Composite implements IPanel { }
*/
export class PanelDescriptor extends CompositeDescriptor<Panel> {
constructor(ctor: IConstructorSignature0<Panel>, id: string, name: string, cssClass?: string, order?: number, _commandId?: string) {
public static create<Services extends BrandedService[]>(ctor: { new(...services: Services): Panel }, id: string, name: string, cssClass?: string, order?: number, _commandId?: string): PanelDescriptor {
return new PanelDescriptor(ctor as IConstructorSignature0<Panel>, id, name, cssClass, order, _commandId);
}
private constructor(ctor: IConstructorSignature0<Panel>, id: string, name: string, cssClass?: string, order?: number, _commandId?: string) {
super(ctor, id, name, cssClass, order, _commandId);
}
}

View file

@ -57,7 +57,7 @@ import { IFilesConfigurationService } from 'vs/workbench/services/filesConfigura
// Register String Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
TextResourceEditor,
TextResourceEditor.ID,
nls.localize('textEditor', "Text Editor"),
@ -70,7 +70,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
// Register Text Diff Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
TextDiffEditor,
TextDiffEditor.ID,
nls.localize('textDiffEditor', "Text Diff Editor")
@ -82,7 +82,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
// Register Binary Resource Diff Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
BinaryResourceDiffEditor,
BinaryResourceDiffEditor.ID,
nls.localize('binaryDiffEditor', "Binary Diff Editor")
@ -93,7 +93,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
SideBySideEditor,
SideBySideEditor.ID,
nls.localize('sideBySideEditor', "Side by Side Editor")
@ -279,7 +279,7 @@ const editorPickerContextKey = 'inEditorsPicker';
const editorPickerContext = ContextKeyExpr.and(inQuickOpenContext, ContextKeyExpr.has(editorPickerContextKey));
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
ActiveEditorGroupPicker,
ActiveEditorGroupPicker.ID,
editorCommands.NAVIGATE_IN_ACTIVE_GROUP_PREFIX,
@ -295,7 +295,7 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
AllEditorsPicker,
AllEditorsPicker.ID,
editorCommands.NAVIGATE_ALL_EDITORS_GROUP_PREFIX,

View file

@ -15,7 +15,7 @@ import { QuickOpenEntry, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/bro
import { EditorOptions, EditorInput, IEditorInput } from 'vs/workbench/common/editor';
import { IResourceInput, IEditorOptions } from 'vs/platform/editor/common/editor';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConstructorSignature0, IInstantiationService, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { CancellationToken } from 'vs/base/common/cancellation';
@ -136,9 +136,13 @@ export class QuickOpenHandlerDescriptor {
private id: string;
private ctor: IConstructorSignature0<QuickOpenHandler>;
constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string | undefined, description: string, instantProgress?: boolean);
constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string | undefined, helpEntries: QuickOpenHandlerHelpEntry[], instantProgress?: boolean);
constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string | undefined, param: string | QuickOpenHandlerHelpEntry[], instantProgress: boolean = false) {
public static create<Services extends BrandedService[]>(ctor: { new(...services: Services): QuickOpenHandler }, id: string, prefix: string, contextKey: string | undefined, description: string, instantProgress?: boolean): QuickOpenHandlerDescriptor;
public static create<Services extends BrandedService[]>(ctor: { new(...services: Services): QuickOpenHandler }, id: string, prefix: string, contextKey: string | undefined, helpEntries: QuickOpenHandlerHelpEntry[], instantProgress?: boolean): QuickOpenHandlerDescriptor;
public static create<Services extends BrandedService[]>(ctor: { new(...services: Services): QuickOpenHandler }, id: string, prefix: string, contextKey: string | undefined, param: string | QuickOpenHandlerHelpEntry[], instantProgress: boolean = false): QuickOpenHandlerDescriptor {
return new QuickOpenHandlerDescriptor(ctor as IConstructorSignature0<QuickOpenHandler>, id, prefix, contextKey, param, instantProgress);
}
private constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string | undefined, param: string | QuickOpenHandlerHelpEntry[], instantProgress: boolean = false) {
this.ctor = ctor;
this.id = id;
this.prefix = prefix;

View file

@ -10,7 +10,7 @@ import { Action, IAction } from 'vs/base/common/actions';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { Composite, CompositeDescriptor, CompositeRegistry } from 'vs/workbench/browser/composite';
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
import { IConstructorSignature0, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { ToggleSidebarVisibilityAction, ToggleSidebarPositionAction } from 'vs/workbench/browser/actions/layoutActions';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
@ -56,7 +56,18 @@ export abstract class Viewlet extends Composite implements IViewlet {
*/
export class ViewletDescriptor extends CompositeDescriptor<Viewlet> {
constructor(
public static create<Services extends BrandedService[]>(
ctor: { new(...services: Services): Viewlet },
id: string,
name: string,
cssClass?: string,
order?: number,
iconUrl?: URI
): ViewletDescriptor {
return new ViewletDescriptor(ctor as IConstructorSignature0<Viewlet>, id, name, cssClass, order, iconUrl);
}
private constructor(
ctor: IConstructorSignature0<Viewlet>,
id: string,
name: string,

View file

@ -26,7 +26,7 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(CustomEditorContribution, LifecyclePhase.Starting);
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
WebviewEditor,
WebviewEditor.ID,
'Webview Editor',

View file

@ -80,7 +80,7 @@ class OpenDebugPanelAction extends TogglePanelAction {
}
// register viewlet
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
DebugViewlet,
VIEWLET_ID,
nls.localize('debug', "Debug"),
@ -96,7 +96,7 @@ const openPanelKb: IKeybindings = {
};
// register repl panel
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
Repl,
REPL_ID,
nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugPanel' }, 'Debug Console'),
@ -166,7 +166,7 @@ registerDebugCommandPaletteItem(TOGGLE_INLINE_BREAKPOINT_ID, nls.localize('inlin
// Register Quick Open
(Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
DebugQuickOpenHandler,
DebugQuickOpenHandler.ID,
'debug ',

View file

@ -54,7 +54,7 @@ Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
// Quickopen
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
ExtensionsHandler,
ExtensionsHandler.ID,
'ext ',
@ -66,7 +66,7 @@ Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
// Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
ExtensionEditor,
ExtensionEditor.ID,
localize('extension', "Extension")
@ -76,7 +76,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
]);
// Viewlet
const viewletDescriptor = new ViewletDescriptor(
const viewletDescriptor = ViewletDescriptor.create(
ExtensionsViewlet,
VIEWLET_ID,
localize('extensions', "Extensions"),
@ -350,7 +350,7 @@ class ExtensionsContributions implements IWorkbenchContribution {
if (canManageExtensions) {
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
GalleryExtensionsHandler,
GalleryExtensionsHandler.ID,
'ext install ',

View file

@ -34,7 +34,7 @@ workbenchRegistry.registerWorkbenchContribution(ExtensionsAutoProfiler, Lifecycl
// Running Extensions Editor
const runtimeExtensionsEditorDescriptor = new EditorDescriptor(
const runtimeExtensionsEditorDescriptor = EditorDescriptor.create(
RuntimeExtensionsEditor,
RuntimeExtensionsEditor.ID,
localize('runtimeExtension', "Running Extensions")

View file

@ -75,7 +75,7 @@ class FileUriLabelContribution implements IWorkbenchContribution {
}
// Register Viewlet
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
ExplorerViewlet,
VIEWLET_ID,
nls.localize('explore', "Explorer"),
@ -101,7 +101,7 @@ registry.registerWorkbenchAction(
// Register file editors
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
BinaryFileEditor,
BinaryFileEditor.ID,
nls.localize('binaryFileEditor', "Binary File Editor")

View file

@ -13,7 +13,7 @@ import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textF
// Register file editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
TextFileEditor,
TextFileEditor.ID,
nls.localize('textFileEditor', "Text File Editor")

View file

@ -13,7 +13,7 @@ import { NativeTextFileEditor } from 'vs/workbench/contrib/files/electron-browse
// Register file editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
NativeTextFileEditor,
NativeTextFileEditor.ID,
nls.localize('textFileEditor', "Text File Editor")

View file

@ -92,7 +92,7 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfigurat
// markers panel
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
MarkersPanel,
Constants.MARKERS_PANEL_ID,
Messages.MARKERS_PANEL_TITLE_PROBLEMS,

View file

@ -41,7 +41,7 @@ ModesRegistry.registerLanguage({
});
// Register Output Panel
Registry.as<PanelRegistry>(Extensions.Panels).registerPanel(new PanelDescriptor(
Registry.as<PanelRegistry>(Extensions.Panels).registerPanel(PanelDescriptor.create(
OutputPanel,
OUTPUT_PANEL_ID,
nls.localize('output', "Output"),
@ -51,7 +51,7 @@ Registry.as<PanelRegistry>(Extensions.Panels).registerPanel(new PanelDescriptor(
));
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
LogViewer,
LogViewer.LOG_VIEWER_EDITOR_ID,
nls.localize('logViewer', "Log Viewer")

View file

@ -42,7 +42,7 @@ import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
import { registerAndGetAmdImageURL } from 'vs/base/common/amd';
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
PreferencesEditor,
PreferencesEditor.ID,
nls.localize('defaultPreferencesEditor', "Default Preferences Editor")
@ -53,7 +53,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
SettingsEditor2,
SettingsEditor2.ID,
nls.localize('settingsEditor2', "Settings Editor 2")
@ -64,7 +64,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
KeybindingsEditor,
KeybindingsEditor.ID,
nls.localize('keybindingsEditor', "Keybindings Editor")

View file

@ -72,7 +72,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
// Register Quick Open Handler
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
CommandsHandler,
CommandsHandler.ID,
ALL_COMMANDS_PREFIX,
@ -82,7 +82,7 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
GotoLineHandler,
GotoLineHandler.ID,
GOTO_LINE_PREFIX,
@ -98,7 +98,7 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
GotoSymbolHandler,
GotoSymbolHandler.ID,
GOTO_SYMBOL_PREFIX,
@ -119,7 +119,7 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
HelpHandler,
HelpHandler.ID,
HELP_PREFIX,
@ -129,7 +129,7 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
ViewPickerHandler,
ViewPickerHandler.ID,
VIEW_PICKER_PREFIX,

View file

@ -274,7 +274,7 @@ export class RemoteViewlet extends FilterViewContainerViewlet {
}
}
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
RemoteViewlet,
VIEWLET_ID,
nls.localize('remote.explorer', "Remote Explorer"),

View file

@ -38,7 +38,7 @@ class OpenSCMViewletAction extends ShowViewletAction {
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(DirtyDiffWorkbenchController, LifecyclePhase.Restored);
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
SCMViewlet,
VIEWLET_ID,
localize('source control', "Source Control"),

View file

@ -502,7 +502,7 @@ class ShowAllSymbolsAction extends Action {
}
}
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
SearchViewlet,
VIEWLET_ID,
nls.localize('name', "Search"),
@ -510,7 +510,7 @@ Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new Vie
1
));
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
SearchPanel,
PANEL_ID,
nls.localize('name', "Search"),
@ -530,7 +530,7 @@ class RegisterSearchViewContribution implements IWorkbenchContribution {
const config = configurationService.getValue<ISearchConfiguration>();
if (config.search.location === 'panel') {
viewsRegistry.deregisterViews(viewsRegistry.getViews(VIEW_CONTAINER), VIEW_CONTAINER);
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(PanelDescriptor.create(
SearchPanel,
PANEL_ID,
nls.localize('name', "Search"),
@ -626,7 +626,7 @@ registry.registerWorkbenchAction(SyncActionDescriptor.create(ClearSearchResultsA
// Register Quick Open Handler
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerDefaultQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
OpenAnythingHandler,
OpenAnythingHandler.ID,
'',
@ -636,7 +636,7 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerDefaultQu
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
OpenSymbolHandler,
OpenSymbolHandler.ID,
ShowAllSymbolsAction.ALL_SYMBOLS_PREFIX,

View file

@ -254,7 +254,7 @@ const quickOpenRegistry = (Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Q
const tasksPickerContextKey = 'inTasksPicker';
quickOpenRegistry.registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
QuickOpenHandler,
QuickOpenHandler.ID,
'task ',

View file

@ -48,7 +48,7 @@ const quickOpenRegistry = (Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Q
const inTerminalsPicker = 'inTerminalPicker';
quickOpenRegistry.registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
QuickOpenHandlerDescriptor.create(
TerminalPickerHandler,
TerminalPickerHandler.ID,
TERMINAL_PICKER_PREFIX,

View file

@ -207,7 +207,7 @@ class TestCustomEditorModel extends EditorModel {
if (ENABLE) {
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
EditorDescriptor.create(
TestCustomEditor,
TestCustomEditor.ID,
nls.localize('testCustomEditor', "Test Custom Editor")

View file

@ -21,7 +21,7 @@ import { WebviewEditor } from '../browser/webviewEditor';
import { WebviewInput } from '../browser/webviewEditorInput';
import { IWebviewWorkbenchService, WebviewEditorService } from './webviewWorkbenchService';
(Registry.as<IEditorRegistry>(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(
(Registry.as<IEditorRegistry>(EditorExtensions.Editors)).registerEditor(EditorDescriptor.create(
WebviewEditor,
WebviewEditor.ID,
localize('webview.editor.label', "webview editor")),

View file

@ -20,7 +20,7 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(new EditorDescriptor(
.registerEditor(EditorDescriptor.create(
WalkThroughPart,
WalkThroughPart.ID,
localize('walkThrough.editor.label', "Interactive Playground"),

View file

@ -78,7 +78,7 @@ suite('EditorGroupsService', () => {
}
(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories)).registerEditorInputFactory('testEditorInputForGroupsService', TestEditorInputFactory);
(Registry.as<IEditorRegistry>(Extensions.Editors)).registerEditor(new EditorDescriptor(TestEditorControl, 'MyTestEditorForGroupsService', 'My Test File Editor'), [new SyncDescriptor(TestEditorInput)]);
(Registry.as<IEditorRegistry>(Extensions.Editors)).registerEditor(EditorDescriptor.create(TestEditorControl, 'MyTestEditorForGroupsService', 'My Test File Editor'), [new SyncDescriptor(TestEditorInput)]);
}
registerTestEditorInput();

View file

@ -83,7 +83,7 @@ class FileServiceProvider extends Disposable {
suite('EditorService', () => {
function registerTestEditorInput(): void {
Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(new EditorDescriptor(TestEditorControl, 'MyTestEditorForEditorService', 'My Test Editor For Next Editor Service'), [new SyncDescriptor(TestEditorInput)]);
Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(EditorDescriptor.create(TestEditorControl, 'MyTestEditorForEditorService', 'My Test Editor For Next Editor Service'), [new SyncDescriptor(TestEditorInput)]);
}
registerTestEditorInput();

View file

@ -115,14 +115,14 @@ suite('Workbench base editor', () => {
});
test('EditorDescriptor', () => {
let d = new EditorDescriptor(MyEditor, 'id', 'name');
let d = EditorDescriptor.create(MyEditor, 'id', 'name');
assert.strictEqual(d.getId(), 'id');
assert.strictEqual(d.getName(), 'name');
});
test('Editor Registration', function () {
let d1 = new EditorDescriptor(MyEditor, 'id1', 'name');
let d2 = new EditorDescriptor(MyOtherEditor, 'id2', 'name');
let d1 = EditorDescriptor.create(MyEditor, 'id1', 'name');
let d2 = EditorDescriptor.create(MyOtherEditor, 'id2', 'name');
let oldEditorsCnt = EditorRegistry.getEditors().length;
let oldInputCnt = (<any>EditorRegistry).getEditorInputs().length;
@ -142,8 +142,8 @@ suite('Workbench base editor', () => {
});
test('Editor Lookup favors specific class over superclass (match on specific class)', function () {
let d1 = new EditorDescriptor(MyEditor, 'id1', 'name');
let d2 = new EditorDescriptor(MyOtherEditor, 'id2', 'name');
let d1 = EditorDescriptor.create(MyEditor, 'id1', 'name');
let d2 = EditorDescriptor.create(MyOtherEditor, 'id2', 'name');
let oldEditors = EditorRegistry.getEditors();
(<any>EditorRegistry).setEditors([]);
@ -163,7 +163,7 @@ suite('Workbench base editor', () => {
});
test('Editor Lookup favors specific class over superclass (match on super class)', function () {
let d1 = new EditorDescriptor(MyOtherEditor, 'id1', 'name');
let d1 = EditorDescriptor.create(MyOtherEditor, 'id1', 'name');
let oldEditors = EditorRegistry.getEditors();
(<any>EditorRegistry).setEditors([]);

View file

@ -54,7 +54,7 @@ suite('QuickOpen', () => {
test('QuickOpen Handler and Registry', () => {
let registry = (Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen));
let handler = new QuickOpenHandlerDescriptor(
let handler = QuickOpenHandlerDescriptor.create(
TestHandler,
'testhandler',
',',
@ -77,4 +77,4 @@ suite('QuickOpen', () => {
defaultAction.run();
prefixAction.run();
});
});
});

View file

@ -22,7 +22,7 @@ suite('Viewlets', () => {
}
test('ViewletDescriptor API', function () {
let d = new ViewletDescriptor(TestViewlet, 'id', 'name', 'class', 5);
let d = ViewletDescriptor.create(TestViewlet, 'id', 'name', 'class', 5);
assert.strictEqual(d.id, 'id');
assert.strictEqual(d.name, 'name');
assert.strictEqual(d.cssClass, 'class');
@ -30,11 +30,11 @@ suite('Viewlets', () => {
});
test('Editor Aware ViewletDescriptor API', function () {
let d = new ViewletDescriptor(TestViewlet, 'id', 'name', 'class', 5);
let d = ViewletDescriptor.create(TestViewlet, 'id', 'name', 'class', 5);
assert.strictEqual(d.id, 'id');
assert.strictEqual(d.name, 'name');
d = new ViewletDescriptor(TestViewlet, 'id', 'name', 'class', 5);
d = ViewletDescriptor.create(TestViewlet, 'id', 'name', 'class', 5);
assert.strictEqual(d.id, 'id');
assert.strictEqual(d.name, 'name');
});
@ -45,7 +45,7 @@ suite('Viewlets', () => {
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets));
let oldCount = Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length;
let d = new ViewletDescriptor(TestViewlet, 'reg-test-id', 'name');
let d = ViewletDescriptor.create(TestViewlet, 'reg-test-id', 'name');
Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet(d);
assert(d === Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet('reg-test-id'));