Skip to content

Commit

Permalink
Strict null supression in some test files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Feb 5, 2019
1 parent 6551c68 commit 7842634
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 81 deletions.
26 changes: 13 additions & 13 deletions src/vs/workbench/test/common/editor/editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FileEditorInput extends EditorInput {
return this.resource;
}

resolve(): Promise<IEditorModel> {
resolve(): Promise<IEditorModel | null> {
return Promise.resolve(null);
}
}
Expand All @@ -55,22 +55,22 @@ suite('Workbench editor', () => {
test('toResource', () => {
const service = accessor.untitledEditorService;

assert.ok(!toResource(null));
assert.ok(!toResource(null!));

const untitled = service.createOrGet();

assert.equal(toResource(untitled).toString(), untitled.getResource().toString());
assert.equal(toResource(untitled, { supportSideBySide: true }).toString(), untitled.getResource().toString());
assert.equal(toResource(untitled, { filter: Schemas.untitled }).toString(), untitled.getResource().toString());
assert.equal(toResource(untitled, { filter: [Schemas.file, Schemas.untitled] }).toString(), untitled.getResource().toString());
assert.equal(toResource(untitled)!.toString(), untitled.getResource().toString());
assert.equal(toResource(untitled, { supportSideBySide: true })!.toString(), untitled.getResource().toString());
assert.equal(toResource(untitled, { filter: Schemas.untitled })!.toString(), untitled.getResource().toString());
assert.equal(toResource(untitled, { filter: [Schemas.file, Schemas.untitled] })!.toString(), untitled.getResource().toString());
assert.ok(!toResource(untitled, { filter: Schemas.file }));

const file = new FileEditorInput(URI.file('/some/path.txt'));

assert.equal(toResource(file).toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true }).toString(), file.getResource().toString());
assert.equal(toResource(file, { filter: Schemas.file }).toString(), file.getResource().toString());
assert.equal(toResource(file, { filter: [Schemas.file, Schemas.untitled] }).toString(), file.getResource().toString());
assert.equal(toResource(file)!.toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true })!.toString(), file.getResource().toString());
assert.equal(toResource(file, { filter: Schemas.file })!.toString(), file.getResource().toString());
assert.equal(toResource(file, { filter: [Schemas.file, Schemas.untitled] })!.toString(), file.getResource().toString());
assert.ok(!toResource(file, { filter: Schemas.untitled }));

const diffEditorInput = new DiffEditorInput('name', 'description', untitled, file);
Expand All @@ -79,8 +79,8 @@ suite('Workbench editor', () => {
assert.ok(!toResource(diffEditorInput, { filter: Schemas.file }));
assert.ok(!toResource(diffEditorInput, { supportSideBySide: false }));

assert.equal(toResource(file, { supportSideBySide: true }).toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true, filter: Schemas.file }).toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true, filter: [Schemas.file, Schemas.untitled] }).toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true })!.toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true, filter: Schemas.file })!.toString(), file.getResource().toString());
assert.equal(toResource(file, { supportSideBySide: true, filter: [Schemas.file, Schemas.untitled] })!.toString(), file.getResource().toString());
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -423,32 +423,32 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.equal(values.length, 4);
let [first, second, third, fourth] = values;
assert.equal(first.label, 'item1');
assert.equal(first.textEdit.newText, 'item1');
assert.equal(first.textEdit.range.start.line, 0);
assert.equal(first.textEdit.range.start.character, 0);
assert.equal(first.textEdit.range.end.line, 0);
assert.equal(first.textEdit.range.end.character, 4);
assert.equal(first.textEdit!.newText, 'item1');
assert.equal(first.textEdit!.range.start.line, 0);
assert.equal(first.textEdit!.range.start.character, 0);
assert.equal(first.textEdit!.range.end.line, 0);
assert.equal(first.textEdit!.range.end.character, 4);

assert.equal(second.label, 'item2');
assert.equal(second.textEdit.newText, 'foo');
assert.equal(second.textEdit.range.start.line, 0);
assert.equal(second.textEdit.range.start.character, 4);
assert.equal(second.textEdit.range.end.line, 0);
assert.equal(second.textEdit.range.end.character, 8);
assert.equal(second.textEdit!.newText, 'foo');
assert.equal(second.textEdit!.range.start.line, 0);
assert.equal(second.textEdit!.range.start.character, 4);
assert.equal(second.textEdit!.range.end.line, 0);
assert.equal(second.textEdit!.range.end.character, 8);

assert.equal(third.label, 'item3');
assert.equal(third.textEdit.newText, 'foobar');
assert.equal(third.textEdit.range.start.line, 0);
assert.equal(third.textEdit.range.start.character, 1);
assert.equal(third.textEdit.range.end.line, 0);
assert.equal(third.textEdit.range.end.character, 6);
assert.equal(third.textEdit!.newText, 'foobar');
assert.equal(third.textEdit!.range.start.line, 0);
assert.equal(third.textEdit!.range.start.character, 1);
assert.equal(third.textEdit!.range.end.line, 0);
assert.equal(third.textEdit!.range.end.character, 6);

assert.equal(fourth.label, 'item4');
assert.equal(fourth.textEdit, undefined);
assert.equal(fourth.range.start.line, 0);
assert.equal(fourth.range.start.character, 1);
assert.equal(fourth.range.end.line, 0);
assert.equal(fourth.range.end.character, 4);
assert.equal(fourth.range!.start.line, 0);
assert.equal(fourth.range!.start.character, 1);
assert.equal(fourth.range!.end.line, 0);
assert.equal(fourth.range!.end.character, 4);
assert.ok(fourth.insertText instanceof types.SnippetString);
assert.equal((<types.SnippetString>fourth.insertText).value, 'foo$0bar');
});
Expand Down Expand Up @@ -631,11 +631,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, new types.Range(0, 0, 1, 1)).then(value => {
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.ok(first.command);
assert.equal(first.command.command, 'command');
assert.equal(first.command.title, 'command_title');
assert.equal(first.kind.value, 'foo');
assert.equal(first.command!.command, 'command');
assert.equal(first.command!.title, 'command_title');
assert.equal(first.kind!.value, 'foo');
assert.equal(first.title, 'title');

});
Expand All @@ -661,13 +661,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.uri).then(value => {
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;

assert.equal(first.command.title, 'Title');
assert.equal(first.command.command, 'cmd');
assert.equal(first.command.arguments[0], 1);
assert.equal(first.command.arguments[1], true);
assert.equal(first.command.arguments[2], complexArg);
assert.equal(first.command!.title, 'Title');
assert.equal(first.command!.command, 'cmd');
assert.equal(first.command!.arguments[0], 1);
assert.equal(first.command!.arguments[1], true);
assert.equal(first.command!.arguments[2], complexArg);
});
});
});
Expand Down Expand Up @@ -719,7 +719,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.equal(value.length, 1);
let [first] = value;

assert.equal(first.target.toString(), 'foo:bar');
assert.equal(first.target + '', 'foo:bar');
assert.equal(first.range.start.line, 0);
assert.equal(first.range.start.character, 0);
assert.equal(first.range.end.line, 0);
Expand Down Expand Up @@ -765,16 +765,16 @@ suite('ExtHostLanguageFeatureCommands', function () {
let [first] = value;

assert.equal(first.label, '#ABC');
assert.equal(first.textEdit.newText, '#ABC');
assert.equal(first.textEdit.range.start.line, 1);
assert.equal(first.textEdit.range.start.character, 0);
assert.equal(first.textEdit.range.end.line, 1);
assert.equal(first.textEdit.range.end.character, 20);
assert.equal(first.additionalTextEdits.length, 1);
assert.equal(first.additionalTextEdits[0].range.start.line, 2);
assert.equal(first.additionalTextEdits[0].range.start.character, 20);
assert.equal(first.additionalTextEdits[0].range.end.line, 2);
assert.equal(first.additionalTextEdits[0].range.end.character, 20);
assert.equal(first.textEdit!.newText, '#ABC');
assert.equal(first.textEdit!.range.start.line, 1);
assert.equal(first.textEdit!.range.start.character, 0);
assert.equal(first.textEdit!.range.end.line, 1);
assert.equal(first.textEdit!.range.end.character, 20);
assert.equal(first.additionalTextEdits!.length, 1);
assert.equal(first.additionalTextEdits![0].range.start.line, 2);
assert.equal(first.additionalTextEdits![0].range.start.character, 20);
assert.equal(first.additionalTextEdits![0].range.end.line, 2);
assert.equal(first.additionalTextEdits![0].range.end.character, 20);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,38 +111,38 @@ suite('ExtHostConfiguration', function () {
});

let testObject = all.getConfiguration();
let actual = testObject.get('farboo');
let actual = testObject.get('farboo')!;
actual['nested']['config1'] = 41;
assert.equal(41, actual['nested']['config1']);
actual['farboo1'] = 'newValue';
assert.equal('newValue', actual['farboo1']);

testObject = all.getConfiguration();
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
assert.equal(actual['nested']['config1'], 42);
assert.equal(actual['farboo1'], undefined);

testObject = all.getConfiguration();
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
assert.equal(actual['config0'], true);
actual['config0'] = false;
assert.equal(actual['config0'], false);

testObject = all.getConfiguration();
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
assert.equal(actual['config0'], true);

testObject = all.getConfiguration();
actual = testObject.inspect('farboo');
actual = testObject.inspect('farboo')!;
actual['value'] = 'effectiveValue';
assert.equal('effectiveValue', actual['value']);

testObject = all.getConfiguration('workbench');
actual = testObject.get('colorCustomizations');
actual = testObject.get('colorCustomizations')!;
delete actual['statusBar.foreground'];
assert.equal(actual['statusBar.foreground'], undefined);
testObject = all.getConfiguration('workbench');
actual = testObject.get('colorCustomizations');
actual = testObject.get('colorCustomizations')!;
assert.equal(actual['statusBar.foreground'], 'somevalue');
});

Expand All @@ -166,7 +166,7 @@ suite('ExtHostConfiguration', function () {
}
});

let testObject = all.getConfiguration();
const testObject = all.getConfiguration();
let actual = testObject.get('farboo');
assert.deepEqual(JSON.stringify({
'config0': true,
Expand All @@ -179,7 +179,7 @@ suite('ExtHostConfiguration', function () {

assert.deepEqual(undefined, JSON.stringify(testObject.get('unknownkey')));

actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
actual['config0'] = false;
assert.deepEqual(JSON.stringify({
'config0': false,
Expand All @@ -190,7 +190,7 @@ suite('ExtHostConfiguration', function () {
'config4': ''
}), JSON.stringify(actual));

actual = testObject.get('workbench')['colorCustomizations'];
actual = testObject.get('workbench')['colorCustomizations']!;
actual['statusBar.background'] = 'anothervalue';
assert.deepEqual(JSON.stringify({
'statusBar.foreground': 'somevalue',
Expand Down Expand Up @@ -284,13 +284,13 @@ suite('ExtHostConfiguration', function () {
}
);

let actual = testObject.getConfiguration().inspect('editor.wordWrap');
let actual = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'on');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, undefined);

actual = testObject.getConfiguration('editor').inspect('wordWrap');
actual = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'on');
assert.equal(actual.workspaceValue, undefined);
Expand Down Expand Up @@ -331,25 +331,25 @@ suite('ExtHostConfiguration', function () {
}
);

let actual1 = testObject.getConfiguration().inspect('editor.wordWrap');
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);

actual1 = testObject.getConfiguration('editor').inspect('wordWrap');
actual1 = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);

let actual2 = testObject.getConfiguration(null, workspaceUri).inspect('editor.wordWrap');
let actual2 = testObject.getConfiguration(undefined, workspaceUri).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'bounded');

actual2 = testObject.getConfiguration('editor', workspaceUri).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', workspaceUri).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
Expand Down Expand Up @@ -406,62 +406,62 @@ suite('ExtHostConfiguration', function () {
}
);

let actual1 = testObject.getConfiguration().inspect('editor.wordWrap');
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);

actual1 = testObject.getConfiguration('editor').inspect('wordWrap');
actual1 = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);

actual1 = testObject.getConfiguration('editor').inspect('lineNumbers');
actual1 = testObject.getConfiguration('editor').inspect('lineNumbers')!;
assert.equal(actual1.defaultValue, 'on');
assert.equal(actual1.globalValue, undefined);
assert.equal(actual1.workspaceValue, undefined);
assert.equal(actual1.workspaceFolderValue, undefined);

let actual2 = testObject.getConfiguration(null, firstRoot).inspect('editor.wordWrap');
let actual2 = testObject.getConfiguration(undefined, firstRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'off');

actual2 = testObject.getConfiguration('editor', firstRoot).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'off');

actual2 = testObject.getConfiguration('editor', firstRoot).inspect('lineNumbers');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('lineNumbers')!;
assert.equal(actual2.defaultValue, 'on');
assert.equal(actual2.globalValue, undefined);
assert.equal(actual2.workspaceValue, undefined);
assert.equal(actual2.workspaceFolderValue, 'relative');

actual2 = testObject.getConfiguration(null, secondRoot).inspect('editor.wordWrap');
actual2 = testObject.getConfiguration(undefined, secondRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'on');

actual2 = testObject.getConfiguration('editor', secondRoot).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', secondRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'on');

actual2 = testObject.getConfiguration(null, thirdRoot).inspect('editor.wordWrap');
actual2 = testObject.getConfiguration(undefined, thirdRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.ok(Object.keys(actual2).indexOf('workspaceFolderValue') !== -1);
assert.equal(actual2.workspaceFolderValue, undefined);

actual2 = testObject.getConfiguration('editor', thirdRoot).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', thirdRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ suite('ExtHostLanguageFeatures', function () {
}));

await rpcProtocol.sync();
let value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
let [entry] = value;
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 3 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
});
Expand Down

0 comments on commit 7842634

Please sign in to comment.