提交 f0fc4ac3 编写于 作者: B Benjamin Pasero

no more IEditorService.resolveEditorModel()

上级 1741f67d
......@@ -162,21 +162,6 @@ export class SimpleEditorService implements IEditorService {
return model;
}
public resolveEditorModel(typedData: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel> {
let model: editorCommon.IModel;
model = this.editor.withTypedEditor(
(editor) => this.findModel(editor, typedData),
(diffEditor) => this.findModel(diffEditor.getOriginalEditor(), typedData) || this.findModel(diffEditor.getModifiedEditor(), typedData)
);
if (!model) {
return TPromise.as(null);
}
return TPromise.as(new SimpleModel(model));
}
}
export class SimpleEditorModelResolverService implements ITextModelResolverService {
......
......@@ -20,11 +20,6 @@ export interface IEditorService {
* Specific overload to open an instance of IResourceInput.
*/
openEditor(input: IResourceInput, sideBySide?: boolean): TPromise<IEditor>;
/**
* Specific overload to resolve a IResourceInput to an editor model with a text representation.
*/
resolveEditorModel(input: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel>;
}
export interface IEditorModel {
......
......@@ -7,7 +7,7 @@
import URI from 'vs/base/common/uri';
import * as assert from 'assert';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorService, ITextEditorModel, IResourceInput } from 'vs/platform/editor/common/editor';
import { IEditorService, IResourceInput } from 'vs/platform/editor/common/editor';
import { ICommandService, NullCommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { OpenerService } from 'vs/platform/opener/browser/openerService';
......@@ -20,12 +20,8 @@ suite('OpenerService', function () {
openEditor(input: IResourceInput): any {
lastInput = input;
}
resolveEditorModel(): any {
return TPromise.as(<ITextEditorModel>{});
}
};
let lastCommand: { id: string, args: any[] };
const commandService = new class implements ICommandService {
......
......@@ -24,7 +24,7 @@ import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickO
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelResolverService } from 'vs/platform/textmodelResolver/common/resolver';
import { IEditorInput, IEditorOptions, IEditorModel, Position, Direction, IEditor, IResourceInput, ITextEditorModel } from 'vs/platform/editor/common/editor';
import { IEditorInput, IEditorOptions, Position, Direction, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
import { IEventService } from 'vs/platform/event/common/event';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IMessageService, IConfirmation } from 'vs/platform/message/common/message';
......@@ -471,14 +471,6 @@ export class TestEditorService implements IWorkbenchEditorService {
return TPromise.as(null);
}
public resolveEditorModel(input: IEditorInput, refresh?: boolean): TPromise<IEditorModel>;
public resolveEditorModel(input: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel>;
public resolveEditorModel(input: any, refresh?: boolean): Promise {
this.callback('resolveEditorModel');
return input.resolve(refresh);
}
public closeEditor(position: Position, input: IEditorInput): TPromise<void> {
this.callback('closeEditor');
......
......@@ -18,7 +18,6 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorInput, EditorOptions, BINARY_DIFF_EDITOR_ID } from 'vs/workbench/common/editor';
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
import { DiffEditorModel } from 'vs/workbench/common/editor/diffEditorModel';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
......@@ -45,8 +44,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
private startLeftContainerWidth: number;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@ITelemetryService telemetryService: ITelemetryService
) {
super(BinaryResourceDiffEditor.ID, telemetryService);
......@@ -106,7 +104,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
}
// Different Input (Reload)
return this.editorService.resolveEditorModel(input, true /* Reload */).then((resolvedModel: DiffEditorModel) => {
return input.resolve(true).then((resolvedModel: DiffEditorModel) => {
// Assert model instance
if (!(resolvedModel.originalModel instanceof BinaryEditorModel) || !(resolvedModel.modifiedModel instanceof BinaryEditorModel)) {
......
......@@ -13,7 +13,6 @@ import { ResourceViewer } from 'vs/base/browser/ui/resourceviewer/resourceViewer
import { EditorModel, EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
......@@ -28,7 +27,10 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
private binaryContainer: Builder;
private scrollbar: DomScrollableElement;
constructor(id: string, telemetryService: ITelemetryService, private _editorService: IWorkbenchEditorService) {
constructor(
id: string,
telemetryService: ITelemetryService
) {
super(id, telemetryService);
this._onMetadataChanged = new Emitter<void>();
......@@ -42,10 +44,6 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
return this.getInput() ? this.getInput().getName() : nls.localize('binaryEditor', "Binary Viewer");
}
public get editorService() {
return this._editorService;
}
public createEditor(parent: Builder): void {
// Container for Binary
......@@ -72,7 +70,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
}
// Different Input (Reload)
return this._editorService.resolveEditorModel(input, true /* Reload */).then((resolvedModel: EditorModel) => {
return input.resolve(true).then((resolvedModel: EditorModel) => {
// Assert Model instance
if (!(resolvedModel instanceof BinaryEditorModel)) {
......@@ -141,9 +139,8 @@ export class BinaryResourceEditor extends BaseBinaryResourceEditor {
public static ID = 'workbench.editors.binaryResourceEditor';
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
@ITelemetryService telemetryService: ITelemetryService
) {
super(BinaryResourceEditor.ID, telemetryService, editorService);
super(BinaryResourceEditor.ID, telemetryService);
}
}
......@@ -93,7 +93,7 @@ export class StringEditor extends BaseTextEditor {
}
// Different Input (Reload)
return this.editorService.resolveEditorModel(input, true /* Reload */).then((resolvedModel: EditorModel) => {
return input.resolve(true).then((resolvedModel: EditorModel) => {
// Assert Model instance
if (!(resolvedModel instanceof BaseTextEditorModel)) {
......
......@@ -142,7 +142,7 @@ export class TextDiffEditor extends BaseTextEditor {
}
// Different Input (Reload)
return this.editorService.resolveEditorModel(input, true /* Reload */).then((resolvedModel: EditorModel) => {
return input.resolve(true).then((resolvedModel: EditorModel) => {
// Assert Model Instance
if (!(resolvedModel instanceof TextDiffEditorModel) && this.openAsBinary(input, options)) {
......
......@@ -8,7 +8,6 @@ import nls = require('vs/nls');
import { BaseBinaryResourceEditor } from 'vs/workbench/browser/parts/editor/binaryEditor';
import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/parts/files/common/files';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
/**
* An implementation of editor for binary files like images.
......@@ -18,10 +17,9 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
public static ID = BINARY_FILE_EDITOR_ID;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
@ITelemetryService telemetryService: ITelemetryService
) {
super(BinaryFileEditor.ID, telemetryService, editorService);
super(BinaryFileEditor.ID, telemetryService);
}
public getTitle(): string {
......
......@@ -118,7 +118,7 @@ export class TextFileEditor extends BaseTextEditor {
}
// Different Input (Reload)
return this.editorService.resolveEditorModel(input, true /* Reload */).then(resolvedModel => {
return input.resolve(true).then(resolvedModel => {
// There is a special case where the text editor has to handle binary file editor input: if a binary file
// has been resolved and cached before, it maybe an actual instance of BinaryEditorModel. In this case our text
......
......@@ -8,7 +8,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import paths = require('vs/base/common/paths');
import labels = require('vs/base/common/labels');
import URI from 'vs/base/common/uri';
import { EditorModel, EncodingMode, ConfirmResult } from 'vs/workbench/common/editor';
import { EncodingMode, ConfirmResult } from 'vs/workbench/common/editor';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
import { IFileOperationResult, FileOperationResult } from 'vs/platform/files/common/files';
import { BINARY_FILE_EDITOR_ID, TEXT_FILE_EDITOR_ID, FILE_EDITOR_INPUT_ID, FileEditorInput as CommonFileEditorInput } from 'vs/workbench/parts/files/common/files';
......@@ -177,7 +178,7 @@ export class FileEditorInput extends CommonFileEditorInput {
return this.forceOpenAsBinary ? BINARY_FILE_EDITOR_ID : TEXT_FILE_EDITOR_ID;
}
public resolve(refresh?: boolean): TPromise<EditorModel> {
public resolve(refresh?: boolean): TPromise<TextFileEditorModel> {
return this.textFileService.models.loadOrCreate(this.resource, this.preferredEncoding, refresh).then(null, error => {
// In case of an error that indicates that the file is binary or too large, just return with the binary editor model
......
......@@ -13,8 +13,9 @@ import { workbenchInstantiationService, TestTextFileService } from 'vs/test/util
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { EncodingMode } from 'vs/workbench/common/editor';
import { IEventService } from 'vs/platform/event/common/event';
import { ITextFileEditorModel, ITextFileService, } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { FileOperationResult, IFileOperationResult } from 'vs/platform/files/common/files';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
function toResource(path) {
return URI.file(join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path));
......@@ -62,17 +63,17 @@ suite('Files - FileEditorInput', () => {
const inputToResolve: any = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/file.js'), void 0);
const sameOtherInput = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/file.js'), void 0);
return accessor.editorService.resolveEditorModel(inputToResolve, true).then(resolved => {
return inputToResolve.resolve(true).then(resolved => {
const resolvedModelA = resolved;
return accessor.editorService.resolveEditorModel(inputToResolve, true).then(resolved => {
return inputToResolve.resolve(true).then(resolved => {
assert(resolvedModelA === resolved); // OK: Resolved Model cached globally per input
return accessor.editorService.resolveEditorModel(sameOtherInput, true).then(otherResolved => {
return sameOtherInput.resolve(true).then(otherResolved => {
assert(otherResolved === resolvedModelA); // OK: Resolved Model cached globally per input
inputToResolve.dispose(false);
return accessor.editorService.resolveEditorModel(inputToResolve, true).then(resolved => {
return inputToResolve.resolve(true).then(resolved => {
assert(resolvedModelA === resolved); // Model is still the same because we had 2 clients
inputToResolve.dispose();
......@@ -80,15 +81,15 @@ suite('Files - FileEditorInput', () => {
resolvedModelA.dispose();
return accessor.editorService.resolveEditorModel(inputToResolve, true).then(resolved => {
return inputToResolve.resolve(true).then(resolved => {
assert(resolvedModelA !== resolved); // Different instance, because input got disposed
let stat = (<any>resolved).versionOnDiskStat;
return accessor.editorService.resolveEditorModel(inputToResolve, true).then(resolved => {
return inputToResolve.resolve(true).then(resolved => {
assert(stat !== (<any>resolved).versionOnDiskStat); // Different stat, because resolve always goes to the server for refresh
stat = (<any>resolved).versionOnDiskStat;
return accessor.editorService.resolveEditorModel(inputToResolve, false).then(resolved => {
return inputToResolve.resolve(false).then(resolved => {
assert(stat === (<any>resolved).versionOnDiskStat); // Same stat, because not refreshed
done();
......@@ -116,7 +117,7 @@ suite('Files - FileEditorInput', () => {
input.setEncoding('utf16', EncodingMode.Encode);
assert.equal(input.getEncoding(), 'utf16');
return accessor.editorService.resolveEditorModel(input, true).then((resolved: ITextFileEditorModel) => {
return input.resolve(true).then((resolved: TextFileEditorModel) => {
assert.equal(input.getEncoding(), resolved.getEncoding());
resolved.dispose();
......@@ -128,7 +129,7 @@ suite('Files - FileEditorInput', () => {
test('save', function (done) {
const input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0);
return accessor.editorService.resolveEditorModel(input, true).then((resolved: ITextFileEditorModel) => {
return input.resolve(true).then((resolved: TextFileEditorModel) => {
resolved.textEditorModel.setValue('changed');
assert.ok(input.isDirty());
......@@ -145,7 +146,7 @@ suite('Files - FileEditorInput', () => {
test('revert', function (done) {
const input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0);
return accessor.editorService.resolveEditorModel(input, true).then((resolved: ITextFileEditorModel) => {
return input.resolve(true).then((resolved: TextFileEditorModel) => {
resolved.textEditorModel.setValue('changed');
assert.ok(input.isDirty());
......@@ -167,7 +168,7 @@ suite('Files - FileEditorInput', () => {
fileOperationResult: FileOperationResult.FILE_IS_BINARY
});
return accessor.editorService.resolveEditorModel(input, true).then(resolved => {
return input.resolve(true).then(resolved => {
assert.ok(resolved);
resolved.dispose();
......
......@@ -19,7 +19,7 @@ import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorIn
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorInput, IEditorModel, IEditorOptions, ITextEditorOptions, Position, Direction, IEditor, IResourceInput, ITextEditorModel } from 'vs/platform/editor/common/editor';
import { IEditorInput, IEditorOptions, ITextEditorOptions, Position, Direction, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { AsyncDescriptor0 } from 'vs/platform/instantiation/common/descriptors';
......@@ -195,18 +195,6 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
return this.editorPart.closeAllEditors(except);
}
public resolveEditorModel(input: IEditorInput, refresh?: boolean): TPromise<IEditorModel>;
public resolveEditorModel(input: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel>;
public resolveEditorModel(input: any, refresh?: boolean): TPromise<IEditorModel> {
return this.createInput(input).then(typedInput => {
if (typedInput instanceof EditorInput) {
return typedInput.resolve(!!refresh);
}
return TPromise.as<IEditorModel>(null);
});
}
public createInput(input: EditorInput): TPromise<EditorInput>;
public createInput(input: IResourceInput): TPromise<EditorInput>;
public createInput(input: any): TPromise<IEditorInput> {
......
......@@ -7,8 +7,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IEditorService, IEditor, IEditorInput, IEditorOptions, ITextEditorOptions, Position, Direction, IResourceInput, IEditorModel } from 'vs/platform/editor/common/editor';
import { ITextEditorModel } from 'vs/workbench/common/editor';
import { IEditorService, IEditor, IEditorInput, IEditorOptions, ITextEditorOptions, Position, Direction, IResourceInput } from 'vs/platform/editor/common/editor';
export const IWorkbenchEditorService = createDecorator<IWorkbenchEditorService>('editorService');
......@@ -86,18 +85,6 @@ export interface IWorkbenchEditorService extends IEditorService {
*/
closeAllEditors(except?: Position): TPromise<void>;
/**
* Resolves an input to its model representation. The optional parameter refresh allows to specify
* if a cached model should be returned (false) or a new version (true). The default is returning a
* cached version.
*/
resolveEditorModel(input: IEditorInput, refresh?: boolean): TPromise<IEditorModel>;
/**
* Specific overload to resolve a IResourceInput to an editor model with a text representation.
*/
resolveEditorModel(input: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel>;
/**
* Allows to resolve an untyped input to a workbench typed instanceof editor input
*/
......
......@@ -7,9 +7,8 @@
import { TPromise } from 'vs/base/common/winjs.base';
import URI from 'vs/base/common/uri';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommonCodeEditor, IModel, EditorType, IEditor as ICommonEditor } from 'vs/editor/common/editorCommon';
import { IDiffEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ITextEditorModel, IEditorInput } from 'vs/platform/editor/common/editor';
import { IModel } from 'vs/editor/common/editorCommon';
import { ITextEditorModel } from 'vs/platform/editor/common/editor';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IModelService } from 'vs/editor/common/services/modelService';
import { sequence } from 'vs/base/common/async';
......@@ -20,8 +19,6 @@ import { ITextModelResolverService, ITextModelContentProvider, IResolveOptions }
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import types = require('vs/base/common/types');
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { EditorInput } from 'vs/workbench/common/editor';
export class TextModelResolverService implements ITextModelResolverService {
......@@ -54,68 +51,17 @@ export class TextModelResolverService implements ITextModelResolverService {
// In Memory: only works on the active editor
if (resource.scheme === network.Schemas.inMemory) {
return this.resolveInMemory(resource);
}
// Any other resource: use registry
return this.resolveTextModelContent(this.modelService, resource).then(() => this.instantiationService.createInstance(ResourceEditorModel, resource));
}
private resolveInMemory(resource: URI): TPromise<ITextEditorModel> {
// For in-memory resources we only support to resolve the input from the current active editor
// because the workbench does not track editor models by in memory URL. This concept is only
// being used in the code editor.
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
const control = <ICommonEditor>activeEditor.getControl();
if (types.isFunction(control.getEditorType)) {
// Single Editor: If code editor model matches, return input from editor
if (control.getEditorType() === EditorType.ICodeEditor) {
const codeEditor = <ICodeEditor>control;
const model = this.findModel(codeEditor, resource);
if (model) {
return this.resolveFromInput(activeEditor.input);
}
}
// Diff Editor: If left or right code editor model matches, return associated input
else if (control.getEditorType() === EditorType.IDiffEditor) {
const diffInput = <DiffEditorInput>activeEditor.input;
const diffCodeEditor = <IDiffEditor>control;
const originalModel = this.findModel(diffCodeEditor.getOriginalEditor(), resource);
if (originalModel) {
return this.resolveFromInput(diffInput.originalInput);
}
const modifiedModel = this.findModel(diffCodeEditor.getModifiedEditor(), resource);
if (modifiedModel) {
return this.resolveFromInput(diffInput.modifiedInput);
}
return this.editorService.createInput({ resource }).then(input => {
if (input instanceof EditorInput) {
return input.resolve();
}
}
}
return TPromise.as(null);
}
private resolveFromInput(input: IEditorInput): TPromise<ITextEditorModel> {
if (input instanceof EditorInput) {
return input.resolve();
}
return TPromise.as(null);
}
private findModel(editor: ICommonCodeEditor, resource: URI): IModel {
const model = editor.getModel();
if (!model) {
return null;
return null;
});
}
return model.uri.toString() === resource.toString() ? model : null;
// Any other resource: use registry
return this.resolveTextModelContent(this.modelService, resource).then(() => this.instantiationService.createInstance(ResourceEditorModel, resource));
}
public registerTextModelContentProvider(scheme: string, provider: ITextModelContentProvider): IDisposable {
......
......@@ -16,7 +16,6 @@ import { EditorInput, EditorOptions, TextEditorOptions } from 'vs/workbench/comm
import { StringEditorInput } from 'vs/workbench/common/editor/stringEditorInput';
import { StringEditorModel } from 'vs/workbench/common/editor/stringEditorModel';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { workbenchInstantiationService } from 'vs/test/utils/servicesTestUtils';
import { Viewlet } from 'vs/workbench/browser/viewlet';
import { IPanel } from 'vs/workbench/common/panel';
......@@ -313,22 +312,17 @@ suite('Workbench UI Services', () => {
// Resolve Editor Model (Typed EditorInput)
let input = instantiationService.createInstance(StringEditorInput, 'name', 'description', 'hello world', 'text/plain', false);
service.resolveEditorModel(input, true).then((model: StringEditorModel) => {
input.resolve(true).then((model: StringEditorModel) => {
assert(model instanceof StringEditorModel);
assert(model.isResolved());
service.resolveEditorModel(input, false).then((otherModel) => {
input.resolve().then((otherModel) => {
assert(model === otherModel);
input.dispose();
});
});
// Resolve Editor Model (Untyped Input)
service.resolveEditorModel({ resource: toResource.call(this, '/index.html') }, true).then((model) => {
assert(model instanceof TextFileEditorModel);
});
});
test('DelegatingWorkbenchEditorService', function () {
......
......@@ -50,22 +50,22 @@ suite('Workbench - StringEditorInput', () => {
input = instantiationService.createInstance(StringEditorInput, 'name', 'description', 'value', 'mode', false);
input = instantiationService.createInstance(StringEditorInput, 'name', 'description', 'value', 'mode', false);
editorService.resolveEditorModel(input, true).then(resolved => {
input.resolve(true).then(resolved => {
let resolvedModelA = resolved;
return editorService.resolveEditorModel(input, true).then(resolved => {
return input.resolve(true).then(resolved => {
assert(resolvedModelA === resolved); // assert: Resolved Model cached per instance
let otherInput = instantiationService.createInstance(StringEditorInput, 'name', 'description', 'value', 'mode', false);
return editorService.resolveEditorModel(otherInput, true).then(resolved => {
return otherInput.resolve(true).then(resolved => {
assert(resolvedModelA !== resolved); // NOT assert: Different instance, different model
input.dispose();
return editorService.resolveEditorModel(input, true).then(resolved => {
return input.resolve(true).then(resolved => {
assert(resolvedModelA !== resolved); // Different instance, because input got disposed
let model = (<any>resolved).textEditorModel;
return editorService.resolveEditorModel(input, true).then(againResolved => {
return input.resolve(true).then(againResolved => {
assert(model === (<any>againResolved).textEditorModel); // Models should not differ because string input is constant
input.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册