提交 44a8a1f1 编写于 作者: B Benjamin Pasero

getId() => getTypeId() for (#6324)

上级 29b583c3
......@@ -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.
*/
......
......@@ -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 {
......
......@@ -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 = (<EditorHistoryEntry>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
});
}
......
......@@ -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.
......
......@@ -63,7 +63,7 @@ export class DiffEditorInput extends BaseDiffEditorInput {
return this._toUnbind;
}
public getId(): string {
public getTypeId(): string {
return DiffEditorInput.ID;
}
......
......@@ -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<IEditorRegistry>(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
}
......
......@@ -28,7 +28,7 @@ export abstract class IFrameEditorInput extends EditorInput {
this.description = description;
}
public getId(): string {
public getTypeId(): string {
return IFrameEditorInput.ID;
}
......
......@@ -133,7 +133,7 @@ export class ResourceEditorInput extends EditorInput {
this.resource = resource;
}
public getId(): string {
public getTypeId(): string {
return ResourceEditorInput.ID;
}
......
......@@ -48,7 +48,7 @@ export class StringEditorInput extends EditorInput {
return null;
}
public getId(): string {
public getTypeId(): string {
return StringEditorInput.ID;
}
......
......@@ -48,7 +48,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
this.modeId = modeId;
}
public getId(): string {
public getTypeId(): string {
return UntitledEditorInput.ID;
}
......
......@@ -111,7 +111,7 @@ export class FileEditorInput extends CommonFileEditorInput {
}
}
public getId(): string {
public getTypeId(): string {
return FILE_EDITOR_INPUT_ID;
}
......
......@@ -148,7 +148,7 @@ export class ConflictResolutionDiffEditorInput extends DiffEditorInput {
return this.model;
}
public getId(): string {
public getTypeId(): string {
return ConflictResolutionDiffEditorInput.ID;
}
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -105,7 +105,7 @@ export class OutputEditorInput extends StringEditorInput {
}
}
public getId(): string {
public getTypeId(): string {
return OUTPUT_EDITOR_INPUT_ID;
}
......
......@@ -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';
};
......
......@@ -14,7 +14,7 @@ class MyEditorInput extends EditorInput {
return 'text/css';
}
public getId(): string {
public getTypeId(): string {
return '';
}
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册