提交 9cdacb46 编写于 作者: M Matt Bierner

Strict null supressions in tests

上级 3b228755
......@@ -68,14 +68,14 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd
/**
* Creates the text editor model with the provided value, modeId (can be comma separated for multiple values) and optional resource URL.
*/
protected createTextEditorModel(value: ITextBufferFactory, resource: URI, modeId?: string): EditorModel {
protected createTextEditorModel(value: ITextBufferFactory, resource: URI | undefined, modeId?: string): EditorModel {
const firstLineText = this.getFirstLineText(value);
const languageSelection = this.getOrCreateMode(this.modeService, modeId, firstLineText);
return this.doCreateTextEditorModel(value, languageSelection, resource);
}
private doCreateTextEditorModel(value: ITextBufferFactory, languageSelection: ILanguageSelection, resource: URI): EditorModel {
private doCreateTextEditorModel(value: ITextBufferFactory, languageSelection: ILanguageSelection, resource: URI | undefined): EditorModel {
let model = resource && this.modelService.getModel(resource);
if (!model) {
model = this.modelService.createModel(value, languageSelection, resource);
......
......@@ -52,7 +52,7 @@ export class TestEditorInput extends EditorInput implements IFileEditorInput {
resolve(): Promise<IEditorModel> { return !this.fails ? Promise.resolve(null) : Promise.reject(new Error('fails')); }
matches(other: TestEditorInput): boolean { return other && other.resource && this.resource.toString() === other.resource.toString() && other instanceof TestEditorInput; }
setEncoding(encoding: string) { }
getEncoding(): string { return null; }
getEncoding(): string { return null!; }
setPreferredEncoding(encoding: string) { }
getResource(): URI { return this.resource; }
setForceOpenAsBinary(): void { }
......@@ -120,7 +120,7 @@ suite('Editor service', () => {
assert.equal(visibleEditorChangeEventCounter, 1);
// Close input
return editor.group!.closeEditor(input).then(() => {
return editor!.group!.closeEditor(input).then(() => {
assert.equal(didCloseEditorListenerCounter, 1);
assert.equal(activeEditorChangeEventCounter, 2);
assert.equal(visibleEditorChangeEventCounter, 2);
......@@ -347,13 +347,13 @@ suite('Editor service', () => {
return service.openEditor(input1, { pinned: true, preserveFocus: true }, SIDE_GROUP).then(editor => {
assert.equal(part.activeGroup, rootGroup);
assert.equal(part.count, 2);
assert.equal(editor.group, part.groups[1]);
assert.equal(editor!.group, part.groups[1]);
// Open to the side uses existing neighbour group if any
return service.openEditor(input2, { pinned: true, preserveFocus: true }, SIDE_GROUP).then(editor => {
assert.equal(part.activeGroup, rootGroup);
assert.equal(part.count, 2);
assert.equal(editor.group, part.groups[1]);
assert.equal(editor!.group, part.groups[1]);
});
});
});
......@@ -403,7 +403,7 @@ suite('Editor service', () => {
// 1.) open, open same, open other, close
let editor = await service.openEditor(input, { pinned: true });
const group = editor.group!;
const group = editor!.group!;
assertActiveEditorChangedEvent(true);
assertVisibleEditorsChangedEvent(true);
......
......@@ -36,9 +36,9 @@ suite('Workbench resource editor input', () => {
accessor.modelService.createModel('function test() {}', accessor.modeService.create('text'), resource);
let input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource);
return input.resolve().then((model: ResourceEditorModel) => {
return input.resolve().then(model => {
assert.ok(model);
assert.equal(snapshotToString(model.createSnapshot()), 'function test() {}');
assert.equal(snapshotToString((model as ResourceEditorModel).createSnapshot()!), 'function test() {}');
});
});
});
\ No newline at end of file
......@@ -18,7 +18,7 @@ import { snapshotToString } from 'vs/platform/files/common/files';
import { timeout } from 'vs/base/common/async';
export class TestUntitledEditorService extends UntitledEditorService {
get(resource: URI): UntitledEditorInput { return super.get(resource); }
get(resource: URI) { return super.get(resource); }
getAll(resources?: URI[]): UntitledEditorInput[] { return super.getAll(resources); }
}
......
......@@ -601,7 +601,7 @@ export class TestViewletService implements IViewletService {
public hideActiveViewlet(): void { }
public getLastActiveViewletId(): string {
return undefined;
return undefined!;
}
}
......@@ -639,7 +639,7 @@ export class TestPanelService implements IPanelService {
public hideActivePanel(): void { }
public getLastActivePanelId(): string {
return undefined;
return undefined!;
}
}
......@@ -847,7 +847,7 @@ export class TestEditorService implements EditorServiceImpl {
activeTextEditorWidget: any;
activeEditor: IEditorInput;
editors: ReadonlyArray<IEditorInput> = [];
visibleControls: ReadonlyArray<IEditor> = [];
visibleControls: ReadonlyArray<IVisibleEditor> = [];
visibleTextEditorWidgets = [];
visibleEditors: ReadonlyArray<IEditorInput> = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册