diff --git a/src/vs/platform/editor/common/editor.ts b/src/vs/platform/editor/common/editor.ts index afc284c9b1c..24ab5896538 100644 --- a/src/vs/platform/editor/common/editor.ts +++ b/src/vs/platform/editor/common/editor.ts @@ -116,11 +116,6 @@ export enum Direction { export interface IEditorInput extends IEventEmitter { - /** - * Returns the identifier of this input or null if none. - */ - getId(): string; - /** * Returns the display name of this input. */ diff --git a/src/vs/workbench/browser/parts/editor/baseEditor.ts b/src/vs/workbench/browser/parts/editor/baseEditor.ts index a4e4fa2674c..bb7c4064c9e 100644 --- a/src/vs/workbench/browser/parts/editor/baseEditor.ts +++ b/src/vs/workbench/browser/parts/editor/baseEditor.ts @@ -450,7 +450,7 @@ export class EditorInputActionContributor extends ActionBarContributor { /* Subclasses can override to provide a custom cache implementation */ protected toId(context: IEditorInputActionContext): string { - return context.editor.getId() + context.input.getId(); + return context.editor.getId() + context.input.getTypeId(); } private clearInputsFromCache(position: Position, isPrimary: boolean): void { diff --git a/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts b/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts index 124465d93e2..ecc02d91e90 100644 --- a/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts +++ b/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts @@ -175,7 +175,7 @@ export class EditorHistoryModel extends QuickOpenModel { } // Using the factory we try to recreate the input - const factory = this.registry.getEditorInputFactory(input.getId()); + const factory = this.registry.getEditorInputFactory(input.getTypeId()); if (factory) { const inputRaw = factory.serialize(input); if (inputRaw) { @@ -217,12 +217,12 @@ export class EditorHistoryModel extends QuickOpenModel { let entry = this.entries[i]; let input = (entry).getInput(); - let factory = this.registry.getEditorInputFactory(input.getId()); + let factory = this.registry.getEditorInputFactory(input.getTypeId()); if (factory) { let value = factory.serialize(input); if (types.isString(value)) { entries.push({ - id: input.getId(), + id: input.getTypeId(), value: value }); } diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 652bcb061df..e9da47698eb 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -32,11 +32,6 @@ export abstract class EditorInput extends EventEmitter implements IEditorInput { this.disposed = false; } - /** - * Returns the unique id of this input. - */ - public abstract getId(): string; - /** * Returns the name of this input that can be shown to the user. Examples include showing the name of the input * above the editor area when the input is shown. @@ -55,6 +50,11 @@ export abstract class EditorInput extends EventEmitter implements IEditorInput { return null; } + /** + * Returns the unique type identifier of this input. + */ + public abstract getTypeId(): string; + /** * Returns the preferred editor for this input. A list of candidate editors is passed in that whee registered * for the input. This allows subclasses to decide late which editor to use for the input on a case by case basis. diff --git a/src/vs/workbench/common/editor/diffEditorInput.ts b/src/vs/workbench/common/editor/diffEditorInput.ts index a9b831affd7..e02eeff9e63 100644 --- a/src/vs/workbench/common/editor/diffEditorInput.ts +++ b/src/vs/workbench/common/editor/diffEditorInput.ts @@ -63,7 +63,7 @@ export class DiffEditorInput extends BaseDiffEditorInput { return this._toUnbind; } - public getId(): string { + public getTypeId(): string { return DiffEditorInput.ID; } diff --git a/src/vs/workbench/common/editor/editorStacksModel.ts b/src/vs/workbench/common/editor/editorStacksModel.ts index b85692c0baf..ed9e87048ed 100644 --- a/src/vs/workbench/common/editor/editorStacksModel.ts +++ b/src/vs/workbench/common/editor/editorStacksModel.ts @@ -556,11 +556,11 @@ export class EditorGroup implements IEditorGroup { let serializedEditors: ISerializedEditorInput[] = []; let serializablePreviewIndex: number; this.editors.forEach(e => { - let factory = registry.getEditorInputFactory(e.getId()); + let factory = registry.getEditorInputFactory(e.getTypeId()); if (factory) { let value = factory.serialize(e); if (typeof value === 'string') { - serializedEditors.push({ id: e.getId(), value }); + serializedEditors.push({ id: e.getTypeId(), value }); serializableEditors.push(e); if (this.preview === e) { @@ -1095,11 +1095,11 @@ export class EditorStacksModel implements IEditorStacksModel { if (event.pinned) { const registry = Registry.as(Extensions.Editors); - const factory = registry.getEditorInputFactory(editor.getId()); + const factory = registry.getEditorInputFactory(editor.getTypeId()); if (factory) { let value = factory.serialize(editor); if (typeof value === 'string') { - this.recentlyClosedEditors.push({ id: editor.getId(), value }); + this.recentlyClosedEditors.push({ id: editor.getTypeId(), value }); if (this.recentlyClosedEditors.length > EditorStacksModel.MAX_RECENTLY_CLOSED_EDITORS) { this.recentlyClosedEditors = this.recentlyClosedEditors.slice(this.recentlyClosedEditors.length - EditorStacksModel.MAX_RECENTLY_CLOSED_EDITORS); // upper bound of recently closed } diff --git a/src/vs/workbench/common/editor/iframeEditorInput.ts b/src/vs/workbench/common/editor/iframeEditorInput.ts index 005571b2b71..fc9bf180112 100644 --- a/src/vs/workbench/common/editor/iframeEditorInput.ts +++ b/src/vs/workbench/common/editor/iframeEditorInput.ts @@ -28,7 +28,7 @@ export abstract class IFrameEditorInput extends EditorInput { this.description = description; } - public getId(): string { + public getTypeId(): string { return IFrameEditorInput.ID; } diff --git a/src/vs/workbench/common/editor/resourceEditorInput.ts b/src/vs/workbench/common/editor/resourceEditorInput.ts index 01314f3e445..16de719596b 100644 --- a/src/vs/workbench/common/editor/resourceEditorInput.ts +++ b/src/vs/workbench/common/editor/resourceEditorInput.ts @@ -133,7 +133,7 @@ export class ResourceEditorInput extends EditorInput { this.resource = resource; } - public getId(): string { + public getTypeId(): string { return ResourceEditorInput.ID; } diff --git a/src/vs/workbench/common/editor/stringEditorInput.ts b/src/vs/workbench/common/editor/stringEditorInput.ts index fbc37bee430..f9b9b3298ea 100644 --- a/src/vs/workbench/common/editor/stringEditorInput.ts +++ b/src/vs/workbench/common/editor/stringEditorInput.ts @@ -48,7 +48,7 @@ export class StringEditorInput extends EditorInput { return null; } - public getId(): string { + public getTypeId(): string { return StringEditorInput.ID; } diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index 3b0fafe7968..85a4dba3d98 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -48,7 +48,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput { this.modeId = modeId; } - public getId(): string { + public getTypeId(): string { return UntitledEditorInput.ID; } diff --git a/src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts b/src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts index 1b9dc37f225..7a4c21d26b8 100644 --- a/src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts +++ b/src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts @@ -111,7 +111,7 @@ export class FileEditorInput extends CommonFileEditorInput { } } - public getId(): string { + public getTypeId(): string { return FILE_EDITOR_INPUT_ID; } diff --git a/src/vs/workbench/parts/files/browser/saveErrorHandler.ts b/src/vs/workbench/parts/files/browser/saveErrorHandler.ts index 066015be350..c0799b07877 100644 --- a/src/vs/workbench/parts/files/browser/saveErrorHandler.ts +++ b/src/vs/workbench/parts/files/browser/saveErrorHandler.ts @@ -148,7 +148,7 @@ export class ConflictResolutionDiffEditorInput extends DiffEditorInput { return this.model; } - public getId(): string { + public getTypeId(): string { return ConflictResolutionDiffEditorInput.ID; } } diff --git a/src/vs/workbench/parts/git/browser/gitEditorInputs.ts b/src/vs/workbench/parts/git/browser/gitEditorInputs.ts index d82366e8c5c..1b743b3eafd 100644 --- a/src/vs/workbench/parts/git/browser/gitEditorInputs.ts +++ b/src/vs/workbench/parts/git/browser/gitEditorInputs.ts @@ -37,10 +37,6 @@ export class GitDiffEditorInput this.status = status; } - public getId(): string { - throw new Error('To implement.'); - } - public getFileStatus():git.IFileStatus { return this.status; } @@ -72,7 +68,7 @@ export class GitWorkingTreeDiffEditorInput extends GitDiffEditorInput { super(name, description, originalInput, modifiedInput, status); } - public getId(): string { + public getTypeId(): string { return GitWorkingTreeDiffEditorInput.ID; } } @@ -85,7 +81,7 @@ export class GitIndexDiffEditorInput extends GitDiffEditorInput { super(name, description, originalInput, modifiedInput, status); } - public getId(): string { + public getTypeId(): string { return GitIndexDiffEditorInput.ID; } } @@ -123,7 +119,7 @@ export class NativeGitIndexStringEditorInput this.toDispose.push(this.gitService.addListener2(git.ServiceEvents.OPERATION_END, () => this.onGitServiceStateChange())); } - public getId(): string { + public getTypeId(): string { return NativeGitIndexStringEditorInput.ID; } diff --git a/src/vs/workbench/parts/markdown/common/markdownEditorInput.ts b/src/vs/workbench/parts/markdown/common/markdownEditorInput.ts index f5e72e58c6f..7ef61c1327e 100644 --- a/src/vs/workbench/parts/markdown/common/markdownEditorInput.ts +++ b/src/vs/workbench/parts/markdown/common/markdownEditorInput.ts @@ -35,7 +35,7 @@ export class MarkdownEditorInput extends IFrameEditorInput { return this.instantiationService.createInstance(MarkdownEditorInput, resource, void 0, void 0); } - public getId(): string { + public getTypeId(): string { return MarkdownEditorInput.ID; } diff --git a/src/vs/workbench/parts/output/common/outputEditorInput.ts b/src/vs/workbench/parts/output/common/outputEditorInput.ts index 8cdca2103f9..22750553902 100644 --- a/src/vs/workbench/parts/output/common/outputEditorInput.ts +++ b/src/vs/workbench/parts/output/common/outputEditorInput.ts @@ -105,7 +105,7 @@ export class OutputEditorInput extends StringEditorInput { } } - public getId(): string { + public getTypeId(): string { return OUTPUT_EDITOR_INPUT_ID; } diff --git a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts index 9f33eeda439..195ab30a533 100644 --- a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts @@ -72,7 +72,7 @@ class MyInput extends EditorInput { return ids[1]; } - public getId(): string { + public getTypeId(): string { return ''; } @@ -82,7 +82,7 @@ class MyInput extends EditorInput { } class MyOtherInput extends EditorInput { - public getId(): string { + public getTypeId(): string { return ''; } @@ -138,14 +138,14 @@ suite('Workbench BaseEditor', () => { assert.strictEqual(input, e.getInput()); assert.strictEqual(options, e.getOptions()); - e.setVisible(true) + e.setVisible(true); assert(e.isVisible()); input.addListener2('dispose', function () { assert(false); }); e.dispose(); e.clearInput(); - e.setVisible(false) + e.setVisible(false); assert(!e.isVisible()); assert(!e.getInput()); assert(!e.getOptions()); @@ -255,7 +255,7 @@ suite('Workbench BaseEditor', () => { // other input causes actions to loose input context let myInput = new MyInput(); - myInput.getId = function () { + myInput.getTypeId = function () { return 'foo.id'; }; diff --git a/src/vs/workbench/test/common/editor/editorInput.test.ts b/src/vs/workbench/test/common/editor/editorInput.test.ts index 155d7c81d75..e9cba941153 100644 --- a/src/vs/workbench/test/common/editor/editorInput.test.ts +++ b/src/vs/workbench/test/common/editor/editorInput.test.ts @@ -14,7 +14,7 @@ class MyEditorInput extends EditorInput { return 'text/css'; } - public getId(): string { + public getTypeId(): string { return ''; } diff --git a/src/vs/workbench/test/common/editor/editorStacksModel.test.ts b/src/vs/workbench/test/common/editor/editorStacksModel.test.ts index 3cff30d954d..7290dc0df3a 100644 --- a/src/vs/workbench/test/common/editor/editorStacksModel.test.ts +++ b/src/vs/workbench/test/common/editor/editorStacksModel.test.ts @@ -94,7 +94,7 @@ class TestEditorInput extends EditorInput { constructor(public id: string) { super(); } - public getId() { return 'testEditorInput'; } + public getTypeId() { return 'testEditorInput'; } public resolve() { return null; } public matches(other: TestEditorInput): boolean { @@ -106,7 +106,7 @@ class NonSerializableTestEditorInput extends EditorInput { constructor(public id: string) { super(); } - public getId() { return 'testEditorInput-nonSerializable'; } + public getTypeId() { return 'testEditorInput-nonSerializable'; } public resolve() { return null; } public matches(other: TestEditorInput): boolean {