提交 d7b9db88 编写于 作者: M Matt Bierner

Strict null supressions in extHostLanguageFeatures.test

上级 fe6bd12a
......@@ -49,6 +49,7 @@ import { provideSelectionRanges } from 'vs/editor/contrib/smartSelect/smartSelec
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { dispose } from 'vs/base/common/lifecycle';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = EditorModel.createFromString(
......@@ -127,10 +128,8 @@ suite('ExtHostLanguageFeatures', function () {
mainThread.dispose();
});
teardown(function () {
while (disposables.length) {
disposables.pop().dispose();
}
teardown(() => {
disposables = dispose(disposables);
return rpcProtocol.sync();
});
......@@ -219,10 +218,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getCodeLensData(model, CancellationToken.None);
assert.equal(value.length, 1);
let data = value[0];
const symbol = await Promise.resolve(data.provider.resolveCodeLens(model, data.symbol, CancellationToken.None));
assert.equal(symbol.command.id, 'id');
assert.equal(symbol.command.title, 'Title');
const data = value[0];
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
assert.equal(symbol!.command!.id, 'id');
assert.equal(symbol!.command!.title, 'Title');
});
test('CodeLens, missing command', async () => {
......@@ -237,9 +236,9 @@ suite('ExtHostLanguageFeatures', function () {
const value = await getCodeLensData(model, CancellationToken.None);
assert.equal(value.length, 1);
let data = value[0];
const symbol = await Promise.resolve(data.provider.resolveCodeLens(model, data.symbol, CancellationToken.None));
assert.equal(symbol.command.id, 'missing');
assert.equal(symbol.command.title, '!!MISSING: command!!');
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
assert.equal(symbol!.command!.id, 'missing');
assert.equal(symbol!.command!.title, '!!MISSING: command!!');
});
// --- definition
......@@ -461,9 +460,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: 5 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
});
......@@ -482,9 +481,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: 5 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
});
......@@ -526,7 +525,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
assert.equal(value.length, 1);
assert.equal(value!.length, 1);
});
// --- references
......@@ -605,9 +604,9 @@ suite('ExtHostLanguageFeatures', function () {
assert.equal(value.length, 2);
const [first, second] = value;
assert.equal(first.title, 'Testing1');
assert.equal(first.command.id, 'test1');
assert.equal(first.command!.id, 'test1');
assert.equal(second.title, 'Testing2');
assert.equal(second.command.id, 'test2');
assert.equal(second.command!.id, 'test2');
});
test('Quick Fix, code action data conversion', async () => {
......@@ -629,8 +628,8 @@ suite('ExtHostLanguageFeatures', function () {
assert.equal(value.length, 1);
const [first] = value;
assert.equal(first.title, 'Testing1');
assert.equal(first.command.title, 'Testing1Command');
assert.equal(first.command.id, 'test1');
assert.equal(first.command!.title, 'Testing1Command');
assert.equal(first.command!.id, 'test1');
assert.equal(first.kind, 'test.scope');
});
......@@ -925,7 +924,7 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None);
let value = (await getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 2);
let [first, second] = value;
assert.equal(first.text, 'testing');
......@@ -967,7 +966,7 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None);
let value = (await getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 1);
let [first] = value;
assert.equal(first.text, 'testing');
......@@ -982,9 +981,9 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None);
const value = (await getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.text, 'testing');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
......@@ -1006,9 +1005,9 @@ suite('ExtHostLanguageFeatures', function () {
}
}));
await rpcProtocol.sync();
let value = await getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None);
const value = (await getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.text, 'range2');
assert.equal(first.range.startLineNumber, 3);
assert.equal(first.range.startColumn, 4);
......@@ -1036,9 +1035,9 @@ suite('ExtHostLanguageFeatures', function () {
}, [';']));
await rpcProtocol.sync();
let value = await getOnTypeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorPosition(1, 1), ';', { insertSpaces: true, tabSize: 2 });
const value = (await getOnTypeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorPosition(1, 1), ';', { insertSpaces: true, tabSize: 2 }))!;
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.text, ';');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册