Skip to content

Commit

Permalink
editors - baseEditor => editorPane
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Aug 24, 2020
1 parent 4dcc6b5 commit f44d46d
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 68 deletions.
15 changes: 8 additions & 7 deletions src/vs/workbench/browser/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
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 { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IConstructorSignature0, IInstantiationService, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { insert } from 'vs/base/common/arrays';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';

export interface IEditorDescriptor {
instantiate(instantiationService: IInstantiationService): BaseEditor;

getId(): string;
getName(): string;

instantiate(instantiationService: IInstantiationService): EditorPane;

describes(obj: unknown): boolean;
}

Expand Down Expand Up @@ -56,20 +57,20 @@ export interface IEditorRegistry {
export class EditorDescriptor implements IEditorDescriptor {

static create<Services extends BrandedService[]>(
ctor: { new(...services: Services): BaseEditor },
ctor: { new(...services: Services): EditorPane },
id: string,
name: string
): EditorDescriptor {
return new EditorDescriptor(ctor as IConstructorSignature0<BaseEditor>, id, name);
return new EditorDescriptor(ctor as IConstructorSignature0<EditorPane>, id, name);
}

constructor(
private readonly ctor: IConstructorSignature0<BaseEditor>,
private readonly ctor: IConstructorSignature0<EditorPane>,
private readonly id: string,
private readonly name: string
) { }

instantiate(instantiationService: IInstantiationService): BaseEditor {
instantiate(instantiationService: IInstantiationService): EditorPane {
return instantiationService.createInstance(this.ctor);
}

Expand All @@ -82,7 +83,7 @@ export class EditorDescriptor implements IEditorDescriptor {
}

describes(obj: unknown): boolean {
return obj instanceof BaseEditor && obj.getId() === this.id;
return obj instanceof EditorPane && obj.getId() === this.id;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/binaryEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'vs/css!./media/binaryeditor';
import * as nls from 'vs/nls';
import { Emitter } from 'vs/base/common/event';
import { EditorInput, EditorOptions, IEditorOpenContext } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
Expand All @@ -30,7 +30,7 @@ export interface IOpenCallbacks {
/*
* This class is only intended to be subclassed and not instantiated.
*/
export abstract class BaseBinaryResourceEditor extends BaseEditor {
export abstract class BaseBinaryResourceEditor extends EditorPane {

private readonly _onMetadataChanged = this._register(new Emitter<void>());
readonly onMetadataChanged = this._onMetadataChanged.event;
Expand Down
18 changes: 9 additions & 9 deletions src/vs/workbench/browser/parts/editor/editorControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { Dimension, show, hide, addClass } from 'vs/base/browser/dom';
import { Registry } from 'vs/platform/registry/common/platform';
import { IEditorRegistry, Extensions as EditorExtensions, IEditorDescriptor } from 'vs/workbench/browser/editor';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress';
import { IEditorGroupView, DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';
import { Emitter } from 'vs/base/common/event';
import { assertIsDefined } from 'vs/base/common/types';

export interface IOpenEditorResult {
readonly editorPane: BaseEditor;
readonly editorPane: EditorPane;
readonly editorChanged: boolean;
}

Expand All @@ -34,10 +34,10 @@ export class EditorControl extends Disposable {
private _onDidSizeConstraintsChange = this._register(new Emitter<{ width: number; height: number; } | undefined>());
readonly onDidSizeConstraintsChange = this._onDidSizeConstraintsChange.event;

private _activeEditorPane: BaseEditor | null = null;
private _activeEditorPane: EditorPane | null = null;
get activeEditorPane(): IVisibleEditorPane | null { return this._activeEditorPane as IVisibleEditorPane | null; }

private readonly editorPanes: BaseEditor[] = [];
private readonly editorPanes: EditorPane[] = [];

private readonly activeEditorPaneDisposables = this._register(new DisposableStore());
private dimension: Dimension | undefined;
Expand Down Expand Up @@ -67,7 +67,7 @@ export class EditorControl extends Disposable {
return { editorPane, editorChanged };
}

private doShowEditorPane(descriptor: IEditorDescriptor): BaseEditor {
private doShowEditorPane(descriptor: IEditorDescriptor): EditorPane {

// Return early if the currently active editor pane can handle the input
if (this._activeEditorPane && descriptor.describes(this._activeEditorPane)) {
Expand Down Expand Up @@ -99,7 +99,7 @@ export class EditorControl extends Disposable {
return editorPane;
}

private doCreateEditorPane(descriptor: IEditorDescriptor): BaseEditor {
private doCreateEditorPane(descriptor: IEditorDescriptor): EditorPane {

// Instantiate editor
const editorPane = this.doInstantiateEditorPane(descriptor);
Expand All @@ -116,7 +116,7 @@ export class EditorControl extends Disposable {
return editorPane;
}

private doInstantiateEditorPane(descriptor: IEditorDescriptor): BaseEditor {
private doInstantiateEditorPane(descriptor: IEditorDescriptor): EditorPane {

// Return early if already instantiated
const existingEditorPane = this.editorPanes.find(editorPane => descriptor.describes(editorPane));
Expand All @@ -131,7 +131,7 @@ export class EditorControl extends Disposable {
return editorPane;
}

private doSetActiveEditorPane(editorPane: BaseEditor | null) {
private doSetActiveEditorPane(editorPane: EditorPane | null) {
this._activeEditorPane = editorPane;

// Clear out previous active editor pane listeners
Expand All @@ -147,7 +147,7 @@ export class EditorControl extends Disposable {
this._onDidSizeConstraintsChange.fire(undefined);
}

private async doSetInput(editorPane: BaseEditor, editor: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext): Promise<boolean> {
private async doSetInput(editorPane: EditorPane, editor: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext): Promise<boolean> {

// If the input did not change, return early and only apply the options
// unless the options instruct us to force open it even if it is the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
*
* This class is only intended to be subclassed and not instantiated.
*/
export abstract class BaseEditor extends Composite implements IEditorPane {
export abstract class EditorPane extends Composite implements IEditorPane {

private static readonly EDITOR_MEMENTOS = new Map<string, EditorMemento<any>>();

Expand Down Expand Up @@ -148,10 +148,10 @@ export abstract class BaseEditor extends Composite implements IEditorPane {
protected getEditorMemento<T>(editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento<T> {
const mementoKey = `${this.getId()}${key}`;

let editorMemento = BaseEditor.EDITOR_MEMENTOS.get(mementoKey);
let editorMemento = EditorPane.EDITOR_MEMENTOS.get(mementoKey);
if (!editorMemento) {
editorMemento = new EditorMemento(this.getId(), key, this.getMemento(StorageScope.WORKSPACE), limit, editorGroupService);
BaseEditor.EDITOR_MEMENTOS.set(mementoKey, editorMemento);
EditorPane.EDITOR_MEMENTOS.set(mementoKey, editorMemento);
}

return editorMemento;
Expand All @@ -160,7 +160,7 @@ export abstract class BaseEditor extends Composite implements IEditorPane {
protected saveState(): void {

// Save all editor memento for this editor type
BaseEditor.EDITOR_MEMENTOS.forEach(editorMemento => {
EditorPane.EDITOR_MEMENTOS.forEach(editorMemento => {
if (editorMemento.id === this.getId()) {
editorMemento.saveState();
}
Expand Down
14 changes: 7 additions & 7 deletions src/vs/workbench/browser/parts/editor/sideBySideEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as DOM from 'vs/base/browser/dom';
import { Registry } from 'vs/platform/registry/common/platform';
import { EditorInput, EditorOptions, SideBySideEditorInput, IEditorControl, IEditorPane, IEditorOpenContext } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IThemeService } from 'vs/platform/theme/common/themeService';
Expand All @@ -19,7 +19,7 @@ import { Event, Relay, Emitter } from 'vs/base/common/event';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { assertIsDefined } from 'vs/base/common/types';

export class SideBySideEditor extends BaseEditor {
export class SideBySideEditor extends EditorPane {

static readonly ID: string = 'workbench.editor.sidebysideEditor';

Expand All @@ -33,7 +33,7 @@ export class SideBySideEditor extends BaseEditor {
private get minimumSecondaryHeight() { return this.secondaryEditorPane ? this.secondaryEditorPane.minimumHeight : 0; }
private get maximumSecondaryHeight() { return this.secondaryEditorPane ? this.secondaryEditorPane.maximumHeight : Number.POSITIVE_INFINITY; }

// these setters need to exist because this extends from BaseEditor
// these setters need to exist because this extends from EditorPane
set minimumWidth(value: number) { /* noop */ }
set maximumWidth(value: number) { /* noop */ }
set minimumHeight(value: number) { /* noop */ }
Expand All @@ -44,8 +44,8 @@ export class SideBySideEditor extends BaseEditor {
get minimumHeight() { return this.minimumPrimaryHeight + this.minimumSecondaryHeight; }
get maximumHeight() { return this.maximumPrimaryHeight + this.maximumSecondaryHeight; }

protected primaryEditorPane?: BaseEditor;
protected secondaryEditorPane?: BaseEditor;
protected primaryEditorPane?: EditorPane;
protected secondaryEditorPane?: EditorPane;

private primaryEditorContainer: HTMLElement | undefined;
private secondaryEditorContainer: HTMLElement | undefined;
Expand Down Expand Up @@ -188,7 +188,7 @@ export class SideBySideEditor extends BaseEditor {
return this.onEditorsCreated(secondaryEditor, primaryEditor, newInput.secondary, newInput.primary, options, context, token);
}

private doCreateEditor(editorInput: EditorInput, container: HTMLElement): BaseEditor {
private doCreateEditor(editorInput: EditorInput, container: HTMLElement): EditorPane {
const descriptor = Registry.as<IEditorRegistry>(EditorExtensions.Editors).getEditor(editorInput);
if (!descriptor) {
throw new Error('No descriptor for editor found');
Expand All @@ -201,7 +201,7 @@ export class SideBySideEditor extends BaseEditor {
return editor;
}

private async onEditorsCreated(secondary: BaseEditor, primary: BaseEditor, secondaryInput: EditorInput, primaryInput: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
private async onEditorsCreated(secondary: EditorPane, primary: EditorPane, secondaryInput: EditorInput, primaryInput: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
this.secondaryEditorPane = secondary;
this.primaryEditorPane = primary;

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/textEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { isObject, assertIsDefined, withNullAsUndefined, isFunction } from 'vs/b
import { Dimension } from 'vs/base/browser/dom';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import { EditorInput, EditorOptions, IEditorMemento, ITextEditorPane, TextEditorOptions, IEditorCloseEvent, IEditorInput, computeEditorAriaLabel, IEditorOpenContext, toResource, SideBySideEditor } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IEditorViewState, IEditor, ScrollType } from 'vs/editor/common/editorCommon';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
Expand All @@ -35,7 +35,7 @@ export interface IEditorConfiguration {
* The base class of editors that leverage the text editor for the editing experience. This class is only intended to
* be subclassed and not instantiated.
*/
export abstract class BaseTextEditor extends BaseEditor implements ITextEditorPane {
export abstract class BaseTextEditor extends EditorPane implements ITextEditorPane {

static readonly TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'textEditorViewState';

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/editor/titleControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { listActiveSelectionBackground, listActiveSelectionForeground } from 'vs/platform/theme/common/colorRegistry';
import { ICssStyleCollector, IColorTheme, IThemeService, registerThemingParticipant, Themable } from 'vs/platform/theme/common/themeService';
import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, fillResourceDataTransfers, LocalSelectionTransfer } from 'vs/workbench/browser/dnd';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs';
import { BreadcrumbsControl, IBreadcrumbsControlOptions } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
import { IEditorGroupsAccessor, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
Expand Down Expand Up @@ -163,7 +163,7 @@ export abstract class TitleControl extends Themable {
const activeEditorPane = this.group.activeEditorPane;

// Check Active Editor
if (activeEditorPane instanceof BaseEditor) {
if (activeEditorPane instanceof EditorPane) {
const result = activeEditorPane.getActionViewItem(action);

if (result) {
Expand Down Expand Up @@ -236,7 +236,7 @@ export abstract class TitleControl extends Themable {

// Editor actions require the editor control to be there, so we retrieve it via service
const activeEditorPane = this.group.activeEditorPane;
if (activeEditorPane instanceof BaseEditor) {
if (activeEditorPane instanceof EditorPane) {
const codeEditor = getCodeEditor(activeEditorPane.getControl());
const scopedContextKeyService = codeEditor?.invokeWithinContext(accessor => accessor.get(IContextKeyService)) || this.contextKeyService;
const titleBarMenu = this.menuService.createMenu(MenuId.EditorTitle, scopedContextKeyService);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ export class TextEditorOptions extends EditorOptions implements ITextEditorOptio
}

/**
* Context passed into `BaseEditor#setInput` to give additional
* Context passed into `EditorPane#setInput` to give additional
* context information around why the editor was opened.
*/
export interface IEditorOpenContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { isPromiseCanceledError } from 'vs/base/common/errors';
import { dispose, toDisposable, Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { domEvent } from 'vs/base/browser/event';
import { append, $, addClass, removeClass, finalHandler, join, toggleClass, hide, show, addDisposableListener, EventType } from 'vs/base/browser/dom';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
Expand Down Expand Up @@ -164,7 +164,7 @@ interface IExtensionEditorTemplate {
header: HTMLElement;
}

export class ExtensionEditor extends BaseEditor {
export class ExtensionEditor extends EditorPane {

static readonly ID: string = 'workbench.editor.extension';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
import * as os from 'os';
import { IProductService } from 'vs/platform/product/common/productService';
import { Action, IAction, Separator } from 'vs/base/common/actions';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionsWorkbenchService, IExtension } from 'vs/workbench/contrib/extensions/common/extensions';
Expand Down Expand Up @@ -100,7 +100,7 @@ interface IRuntimeExtension {
unresponsiveProfile?: IExtensionHostProfile;
}

export class RuntimeExtensionsEditor extends BaseEditor {
export class RuntimeExtensionsEditor extends EditorPane {

public static readonly ID: string = 'workbench.editor.runtimeExtensions';

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { EditorOptions, IEditorInput, IEditorMemento, IEditorOpenContext } from 'vs/workbench/common/editor';
import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/browser/notebookEditorInput';
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
Expand All @@ -28,7 +28,7 @@ import { NotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/not

const NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'NotebookEditorViewState';

export class NotebookEditor extends BaseEditor {
export class NotebookEditor extends EditorPane {
static readonly ID: string = 'workbench.editor.notebook';

private readonly _editorMemento: IEditorMemento<INotebookEditorViewState>;
Expand Down Expand Up @@ -74,7 +74,7 @@ export class NotebookEditor extends BaseEditor {
get minimumWidth(): number { return 375; }
get maximumWidth(): number { return Number.POSITIVE_INFINITY; }

// these setters need to exist because this extends from BaseEditor
// these setters need to exist because this extends from EditorPane
set minimumWidth(value: number) { /*noop*/ }
set maximumWidth(value: number) { /*noop*/ }

Expand Down
Loading

0 comments on commit f44d46d

Please sign in to comment.