Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -50,7 +50,7 @@ let commands: ExtHostCommands;
let disposables: vscode.Disposable[] = [];
let originalErrorHandler: (e: any) => any;
function assertRejects(fn: () => Thenable<any>, message: string = 'Expected rejection') {
function assertRejects(fn: () => Promise<any>, message: string = 'Expected rejection') {
return fn().then(() => assert.ok(false, message), _err => assert.ok(true));
}
@@ -564,6 +564,35 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.equal(b.commitCharacters, undefined);
});
// --- signatureHelp
test('Parameter Hints, back and forth', async () => {
disposables.push(extHost.registerSignatureHelpProvider(nullExtensionDescription, defaultSelector, new class implements vscode.SignatureHelpProvider {
provideSignatureHelp(_document, _position, _token, context: vscode.SignatureHelpContext): vscode.SignatureHelp {
return {
activeSignature: 0,
activeParameter: 1,
signatures: [
{
label: 'abc',
documentation: `${context.triggerKind === 1 /* vscode.SignatureHelpTriggerKind.Invoke */ ? 'invoked' : 'unknown'} ${context.triggerCharacter}`,
parameters: []
}
]
};
}
}, []));
await rpcProtocol.sync();
const firstValue = await commands.executeCommand<vscode.SignatureHelp>('vscode.executeSignatureHelpProvider', model.uri, new types.Position(0, 1), ',');
assert.strictEqual(firstValue.activeSignature, 0);
assert.strictEqual(firstValue.activeParameter, 1);
assert.strictEqual(firstValue.signatures.length, 1);
assert.strictEqual(firstValue.signatures[0].label, 'abc');
assert.strictEqual(firstValue.signatures[0].documentation, 'invoked ,');
});
// --- quickfix
test('QuickFix, back and forth', function () {
@@ -772,7 +801,10 @@ suite('ExtHostLanguageFeatureCommands', function () {
disposables.push(extHost.registerSelectionRangeProvider(nullExtensionDescription, defaultSelector, <vscode.SelectionRangeProvider>{
provideSelectionRanges() {
return [new types.Range(0, 10, 0, 18), new types.Range(0, 2, 0, 20)];
return [
new types.SelectionRange(new types.Range(0, 10, 0, 18), types.SelectionRangeKind.Empty),
new types.SelectionRange(new types.Range(0, 2, 0, 20), types.SelectionRangeKind.Empty)
];
}
}));

View File

@@ -26,9 +26,9 @@ suite('ExtHostCommands', function () {
}
};
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService());
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined!, new NullLogService());
commands.registerCommand(true, 'foo', (): any => { }).dispose();
assert.equal(lastUnregister, 'foo');
assert.equal(lastUnregister!, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
@@ -46,7 +46,7 @@ suite('ExtHostCommands', function () {
}
};
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService());
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined!, new NullLogService());
const reg = commands.registerCommand(true, 'foo', (): any => { });
reg.dispose();
reg.dispose();

View File

@@ -6,7 +6,7 @@
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
import { ExtHostConfigProvider } from 'vs/workbench/api/node/extHostConfiguration';
import { MainThreadConfigurationShape, IConfigurationInitData } from 'vs/workbench/api/node/extHost.protocol';
import { ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
import { TestRPCProtocol } from './testRPCProtocol';
@@ -23,7 +23,7 @@ suite('ExtHostConfiguration', function () {
lastArgs: [ConfigurationTarget, string, any];
$updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): Promise<void> {
this.lastArgs = [target, key, value];
return Promise.resolve(void 0);
return Promise.resolve(undefined);
}
}
@@ -31,7 +31,7 @@ suite('ExtHostConfiguration', function () {
if (!shape) {
shape = new class extends mock<MainThreadConfigurationShape>() { };
}
return new ExtHostConfiguration(shape, new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()), createConfigurationData(contents));
return new ExtHostConfigProvider(shape, new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()), createConfigurationData(contents));
}
function createConfigurationData(contents: any): IConfigurationInitData {
@@ -263,7 +263,7 @@ suite('ExtHostConfiguration', function () {
});
test('inspect in no workspace context', function () {
const testObject = new ExtHostConfiguration(
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()),
{
@@ -306,7 +306,7 @@ suite('ExtHostConfiguration', function () {
}
}, ['editor.wordWrap']);
folders[workspaceUri.toString()] = workspace;
const testObject = new ExtHostConfiguration(
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), {
'id': 'foo',
@@ -380,7 +380,7 @@ suite('ExtHostConfiguration', function () {
}, ['editor.wordWrap']);
folders[thirdRoot.toString()] = new ConfigurationModel({}, []);
const testObject = new ExtHostConfiguration(
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), {
'id': 'foo',
@@ -589,7 +589,7 @@ suite('ExtHostConfiguration', function () {
test('configuration change event', (done) => {
const workspaceFolder = aWorkspaceFolder(URI.file('folder1'), 0);
const testObject = new ExtHostConfiguration(
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), {
'id': 'foo',

View File

@@ -10,7 +10,7 @@ import { Diagnostic, DiagnosticSeverity, Range, DiagnosticRelatedInformation, Lo
import { MainThreadDiagnosticsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { Emitter, toPromise } from 'vs/base/common/event';
import { Emitter, Event } from 'vs/base/common/event';
suite('ExtHostDiagnostics', () => {
@@ -37,7 +37,7 @@ suite('ExtHostDiagnostics', () => {
assert.throws(() => collection.get(URI.parse('aa:bb')));
assert.throws(() => collection.has(URI.parse('aa:bb')));
assert.throws(() => collection.set(URI.parse('aa:bb'), []));
assert.throws(() => collection.set(URI.parse('aa:bb'), undefined));
assert.throws(() => collection.set(URI.parse('aa:bb'), undefined!));
});
@@ -132,7 +132,7 @@ suite('ExtHostDiagnostics', () => {
collection.set([
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
[URI.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]],
[uri, undefined]
[uri, undefined!]
]);
assert.ok(!collection.has(uri));
@@ -144,7 +144,7 @@ suite('ExtHostDiagnostics', () => {
collection.set([
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
[URI.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]],
[uri, undefined],
[uri, undefined!],
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-2')]],
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-3')]],
]);
@@ -160,7 +160,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostics collection, set tuple overrides, #11547', function () {
let lastEntries: [UriComponents, IMarkerData[]][];
let lastEntries!: [UriComponents, IMarkerData[]][];
let collection = new DiagnosticCollection('test', 'test', 100, new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
lastEntries = entries;
@@ -176,7 +176,7 @@ suite('ExtHostDiagnostics', () => {
let [[, data1]] = lastEntries;
assert.equal(data1.length, 1);
assert.equal(data1[0].message, 'error');
lastEntries = undefined;
lastEntries = undefined!;
collection.set([[uri, [new Diagnostic(new Range(0, 0, 1, 1), 'warning')]]]);
assert.equal(collection.get(uri).length, 1);
@@ -185,7 +185,7 @@ suite('ExtHostDiagnostics', () => {
let [[, data2]] = lastEntries;
assert.equal(data2.length, 1);
assert.equal(data2[0].message, 'warning');
lastEntries = undefined;
lastEntries = undefined!;
});
test('don\'t send message when not making a change', function () {
@@ -222,11 +222,11 @@ suite('ExtHostDiagnostics', () => {
collection.set([
[uri, [diag, diag, diag]],
[uri, undefined],
[uri, undefined!],
[uri, [diag]],
[uri2, [diag, diag]],
[uri2, undefined],
[uri2, undefined!],
[uri2, [diag]],
]);
@@ -244,7 +244,7 @@ suite('ExtHostDiagnostics', () => {
let diag = new Diagnostic(new Range(0, 0, 0, 1), i.toString());
tuples.push([uri, [diag, diag, diag]]);
tuples.push([uri, undefined]);
tuples.push([uri, undefined!]);
tuples.push([uri, [diag]]);
}
@@ -259,7 +259,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostic capping', function () {
let lastEntries: [UriComponents, IMarkerData[]][];
let lastEntries!: [UriComponents, IMarkerData[]][];
let collection = new DiagnosticCollection('test', 'test', 250, new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
lastEntries = entries;
@@ -285,14 +285,14 @@ suite('ExtHostDiagnostics', () => {
});
test('diagnostic eventing', async function () {
let emitter = new Emitter<(string | URI)[]>();
let emitter = new Emitter<Array<string | URI>>();
let collection = new DiagnosticCollection('ddd', 'test', 100, new DiagnosticsShape(), emitter);
let diag1 = new Diagnostic(new Range(1, 1, 2, 3), 'diag1');
let diag2 = new Diagnostic(new Range(1, 1, 2, 3), 'diag2');
let diag3 = new Diagnostic(new Range(1, 1, 2, 3), 'diag3');
let p = toPromise(emitter.event).then(a => {
let p = Event.toPromise(emitter.event).then(a => {
assert.equal(a.length, 1);
assert.equal(a[0].toString(), 'aa:bb');
assert.ok(URI.isUri(a[0]));
@@ -300,7 +300,7 @@ suite('ExtHostDiagnostics', () => {
collection.set(URI.parse('aa:bb'), []);
await p;
p = toPromise(emitter.event).then(e => {
p = Event.toPromise(emitter.event).then(e => {
assert.equal(e.length, 2);
assert.ok(URI.isUri(e[0]));
assert.ok(URI.isUri(e[1]));
@@ -313,7 +313,7 @@ suite('ExtHostDiagnostics', () => {
]);
await p;
p = toPromise(emitter.event).then(e => {
p = Event.toPromise(emitter.event).then(e => {
assert.equal(e.length, 2);
assert.ok(typeof e[0] === 'string');
assert.ok(typeof e[1] === 'string');
@@ -323,14 +323,14 @@ suite('ExtHostDiagnostics', () => {
});
test('vscode.languages.onDidChangeDiagnostics Does Not Provide Document URI #49582', async function () {
let emitter = new Emitter<(string | URI)[]>();
let emitter = new Emitter<Array<string | URI>>();
let collection = new DiagnosticCollection('ddd', 'test', 100, new DiagnosticsShape(), emitter);
let diag1 = new Diagnostic(new Range(1, 1, 2, 3), 'diag1');
// delete
collection.set(URI.parse('aa:bb'), [diag1]);
let p = toPromise(emitter.event).then(e => {
let p = Event.toPromise(emitter.event).then(e => {
assert.equal(e[0].toString(), 'aa:bb');
});
collection.delete(URI.parse('aa:bb'));
@@ -338,10 +338,10 @@ suite('ExtHostDiagnostics', () => {
// set->undefined (as delete)
collection.set(URI.parse('aa:bb'), [diag1]);
p = toPromise(emitter.event).then(e => {
p = Event.toPromise(emitter.event).then(e => {
assert.equal(e[0].toString(), 'aa:bb');
});
collection.set(URI.parse('aa:bb'), undefined);
collection.set(URI.parse('aa:bb'), undefined!);
await p;
});
@@ -355,9 +355,9 @@ suite('ExtHostDiagnostics', () => {
assert.equal(data.length, 1);
let [diag] = data;
assert.equal(diag.relatedInformation.length, 2);
assert.equal(diag.relatedInformation[0].message, 'more1');
assert.equal(diag.relatedInformation[1].message, 'more2');
assert.equal(diag.relatedInformation!.length, 2);
assert.equal(diag.relatedInformation![0].message, 'more1');
assert.equal(diag.relatedInformation![1].message, 'more2');
done();
}
}, new Emitter<any>());

View File

@@ -30,7 +30,7 @@ suite('ExtHostDocumentData', () => {
}
setup(function () {
data = new ExtHostDocumentData(undefined, URI.file(''), [
data = new ExtHostDocumentData(undefined!, URI.file(''), [
'This is line one', //16
'and this is line number two', //27
'it is followed by #3', //20
@@ -39,7 +39,7 @@ suite('ExtHostDocumentData', () => {
});
test('readonly-ness', () => {
assert.throws((): void => (data as any).document.uri = null);
assert.throws(() => (data as any).document.uri = null);
assert.throws(() => (data as any).document.fileName = 'foofile');
assert.throws(() => (data as any).document.isDirty = false);
assert.throws(() => (data as any).document.isUntitled = false);
@@ -98,12 +98,12 @@ suite('ExtHostDocumentData', () => {
data.onEvents({
changes: [{
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: '\t '
}],
eol: undefined,
versionId: undefined,
eol: undefined!,
versionId: undefined!,
});
// line didn't change
@@ -155,12 +155,12 @@ suite('ExtHostDocumentData', () => {
data.onEvents({
changes: [{
range: { startLineNumber: 1, startColumn: 3, endLineNumber: 1, endColumn: 6 },
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: ''
}],
eol: undefined,
versionId: undefined,
eol: undefined!,
versionId: undefined!,
});
assertOffsetAt(0, 1, 1);
@@ -173,12 +173,12 @@ suite('ExtHostDocumentData', () => {
data.onEvents({
changes: [{
range: { startLineNumber: 1, startColumn: 3, endLineNumber: 1, endColumn: 6 },
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: 'is could be'
}],
eol: undefined,
versionId: undefined,
eol: undefined!,
versionId: undefined!,
});
assertOffsetAt(0, 1, 1);
@@ -191,12 +191,12 @@ suite('ExtHostDocumentData', () => {
data.onEvents({
changes: [{
range: { startLineNumber: 1, startColumn: 3, endLineNumber: 1, endColumn: 6 },
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: 'is could be\na line with number'
}],
eol: undefined,
versionId: undefined,
eol: undefined!,
versionId: undefined!,
});
assertOffsetAt(0, 1, 1);
@@ -212,12 +212,12 @@ suite('ExtHostDocumentData', () => {
data.onEvents({
changes: [{
range: { startLineNumber: 1, startColumn: 3, endLineNumber: 2, endColumn: 6 },
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: ''
}],
eol: undefined,
versionId: undefined,
eol: undefined!,
versionId: undefined!,
});
assertOffsetAt(0, 1, 1);
@@ -240,41 +240,41 @@ suite('ExtHostDocumentData', () => {
});
test('getWordRangeAtPosition', () => {
data = new ExtHostDocumentData(undefined, URI.file(''), [
data = new ExtHostDocumentData(undefined!, URI.file(''), [
'aaaa bbbb+cccc abc'
], '\n', 'text', 1, false);
let range = data.document.getWordRangeAtPosition(new Position(0, 2));
let range = data.document.getWordRangeAtPosition(new Position(0, 2))!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 0);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 4);
// ignore bad regular expresson /.*/
range = data.document.getWordRangeAtPosition(new Position(0, 2), /.*/);
range = data.document.getWordRangeAtPosition(new Position(0, 2), /.*/)!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 0);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 4);
range = data.document.getWordRangeAtPosition(new Position(0, 5), /[a-z+]+/);
range = data.document.getWordRangeAtPosition(new Position(0, 5), /[a-z+]+/)!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 5);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 14);
range = data.document.getWordRangeAtPosition(new Position(0, 17), /[a-z+]+/);
range = data.document.getWordRangeAtPosition(new Position(0, 17), /[a-z+]+/)!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 15);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 18);
range = data.document.getWordRangeAtPosition(new Position(0, 11), /yy/);
range = data.document.getWordRangeAtPosition(new Position(0, 11), /yy/)!;
assert.equal(range, undefined);
});
test('getWordRangeAtPosition doesn\'t quite use the regex as expected, #29102', function () {
data = new ExtHostDocumentData(undefined, URI.file(''), [
data = new ExtHostDocumentData(undefined!, URI.file(''), [
'some text here',
'/** foo bar */',
'function() {',
@@ -285,7 +285,7 @@ suite('ExtHostDocumentData', () => {
let range = data.document.getWordRangeAtPosition(new Position(0, 0), /\/\*.+\*\//);
assert.equal(range, undefined);
range = data.document.getWordRangeAtPosition(new Position(1, 0), /\/\*.+\*\//);
range = data.document.getWordRangeAtPosition(new Position(1, 0), /\/\*.+\*\//)!;
assert.equal(range.start.line, 1);
assert.equal(range.start.character, 0);
assert.equal(range.end.line, 1);
@@ -294,7 +294,7 @@ suite('ExtHostDocumentData', () => {
range = data.document.getWordRangeAtPosition(new Position(3, 0), /("|').*\1/);
assert.equal(range, undefined);
range = data.document.getWordRangeAtPosition(new Position(3, 1), /("|').*\1/);
range = data.document.getWordRangeAtPosition(new Position(3, 1), /("|').*\1/)!;
assert.equal(range.start.line, 3);
assert.equal(range.start.character, 1);
assert.equal(range.end.line, 3);
@@ -346,17 +346,17 @@ suite('ExtHostDocumentData updates line mapping', () => {
return {
changes: [{
range: range,
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: text
}],
eol: eol,
versionId: undefined,
eol: eol!,
versionId: undefined!,
};
}
function testLineMappingDirectionAfterEvents(lines: string[], eol: string, direction: AssertDocumentLineMappingDirection, e: IModelChangedEvent): void {
let myDocument = new ExtHostDocumentData(undefined, URI.file(''), lines.slice(0), eol, 'text', 1, false);
let myDocument = new ExtHostDocumentData(undefined!, URI.file(''), lines.slice(0), eol, 'text', 1, false);
assertDocumentLineMapping(myDocument, direction);
myDocument.onEvents(e);
@@ -377,7 +377,7 @@ suite('ExtHostDocumentData updates line mapping', () => {
'and this is line number two',
'it is followed by #3',
'and finished with the fourth.',
], { changes: [], eol: undefined, versionId: 7 });
], { changes: [], eol: undefined!, versionId: 7 });
});
test('after remove', () => {

View File

@@ -17,6 +17,7 @@ import { IExtensionDescription } from 'vs/workbench/services/extensions/common/e
import { NullLogService } from 'vs/platform/log/common/log';
import { isResourceTextEdit, ResourceTextEdit } from 'vs/editor/common/modes';
import { timeout } from 'vs/base/common/async';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
suite('ExtHostDocumentSaveParticipant', () => {
@@ -25,15 +26,15 @@ suite('ExtHostDocumentSaveParticipant', () => {
let documents: ExtHostDocuments;
let nullLogService = new NullLogService();
let nullExtensionDescription: IExtensionDescription = {
id: 'nullExtensionDescription',
identifier: new ExtensionIdentifier('nullExtensionDescription'),
name: 'Null Extension Description',
publisher: 'vscode',
enableProposedApi: false,
engines: undefined,
extensionLocation: undefined,
engines: undefined!,
extensionLocation: undefined!,
isBuiltin: false,
isUnderDevelopment: false,
version: undefined
version: undefined!
};
setup(() => {
@@ -85,7 +86,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
sub.dispose();
assert.ok(event);
assert.throws(() => { event.document = null; });
assert.throws(() => { event.document = null!; });
});
});
@@ -212,7 +213,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
setTimeout(() => {
try {
assert.throws(() => event.waitUntil(timeout(10)));
resolve(void 0);
resolve(undefined);
} catch (e) {
reject(e);
}
@@ -300,11 +301,11 @@ suite('ExtHostDocumentSaveParticipant', () => {
documents.$acceptModelChanged(resource, {
changes: [{
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
text: 'bar'
}],
eol: undefined,
eol: undefined!,
versionId: 2
}, true);
@@ -336,10 +337,10 @@ suite('ExtHostDocumentSaveParticipant', () => {
changes: [{
range,
text,
rangeOffset: undefined,
rangeLength: undefined,
rangeOffset: undefined!,
rangeLength: undefined!,
}],
eol: undefined,
eol: undefined!,
versionId: documents.getDocumentData(uri).version + 1
}, true);
}

View File

@@ -13,9 +13,9 @@ suite('ExtHostDocumentsAndEditors', () => {
setup(function () {
editors = new ExtHostDocumentsAndEditors({
getProxy: () => { return undefined; },
set: undefined,
assertRegistered: undefined
getProxy: () => { return undefined!; },
set: undefined!,
assertRegistered: undefined!
});
});

View File

@@ -12,17 +12,17 @@ suite('ExtHostFileSystemEventService', () => {
test('FileSystemWatcher ignore events properties are reversed #26851', function () {
const protocol: IMainContext = {
getProxy: () => { return undefined; },
set: undefined,
assertRegistered: undefined
getProxy: () => { return undefined!; },
set: undefined!,
assertRegistered: undefined!
};
const watcher1 = new ExtHostFileSystemEventService(protocol, undefined).createFileSystemWatcher('**/somethingInteresting', false, false, false);
const watcher1 = new ExtHostFileSystemEventService(protocol, undefined!).createFileSystemWatcher('**/somethingInteresting', false, false, false);
assert.equal(watcher1.ignoreChangeEvents, false);
assert.equal(watcher1.ignoreCreateEvents, false);
assert.equal(watcher1.ignoreDeleteEvents, false);
const watcher2 = new ExtHostFileSystemEventService(protocol, undefined).createFileSystemWatcher('**/somethingBoring', true, true, true);
const watcher2 = new ExtHostFileSystemEventService(protocol, undefined!).createFileSystemWatcher('**/somethingBoring', true, true, true);
assert.equal(watcher2.ignoreChangeEvents, true);
assert.equal(watcher2.ignoreCreateEvents, true);
assert.equal(watcher2.ignoreDeleteEvents, true);

View File

@@ -25,7 +25,7 @@ const emptyCommandService: ICommandService = {
_serviceBrand: undefined,
onWillExecuteCommand: () => ({ dispose: () => { } }),
executeCommand: (commandId: string, ...args: any[]): Promise<any> => {
return Promise.resolve(void 0);
return Promise.resolve(undefined);
}
};
@@ -78,9 +78,9 @@ suite('ExtHostMessageService', function () {
test('propagte handle on select', async function () {
let service = new MainThreadMessageService(null, new EmptyNotificationService(notification => {
assert.equal(notification.actions.primary.length, 1);
setImmediate(() => notification.actions.primary[0].run());
let service = new MainThreadMessageService(null!, new EmptyNotificationService(notification => {
assert.equal(notification.actions!.primary!.length, 1);
setImmediate(() => notification.actions!.primary![0].run());
}), emptyCommandService, emptyDialogService);
const handle = await service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]);
@@ -89,7 +89,7 @@ suite('ExtHostMessageService', function () {
suite('modal', () => {
test('calls dialog service', async () => {
const service = new MainThreadMessageService(null, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show(severity, message, buttons) {
assert.equal(severity, 1);
assert.equal(message, 'h');
@@ -104,7 +104,7 @@ suite('ExtHostMessageService', function () {
});
test('returns undefined when cancelled', async () => {
const service = new MainThreadMessageService(null, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show(severity, message, buttons) {
return Promise.resolve(1);
}
@@ -115,7 +115,7 @@ suite('ExtHostMessageService', function () {
});
test('hides Cancel button when not needed', async () => {
const service = new MainThreadMessageService(null, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show(severity, message, buttons) {
assert.equal(buttons.length, 1);
return Promise.resolve(0);

View File

@@ -12,7 +12,6 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import * as extfs from 'vs/base/node/extfs';
import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/platform/search/common/search';
import { MainContext, MainThreadSearchShape } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
import { ExtHostSearch } from 'vs/workbench/api/node/extHostSearch';
import { Range } from 'vs/workbench/api/node/extHostTypes';
import { extensionResultIsMatch } from 'vs/workbench/services/search/node/textSearchManager';
@@ -28,7 +27,7 @@ let mockMainThreadSearch: MockMainThreadSearch;
class MockMainThreadSearch implements MainThreadSearchShape {
lastHandle: number;
results: (UriComponents | IRawFileMatch2)[] = [];
results: Array<UriComponents | IRawFileMatch2> = [];
$registerFileSearchProvider(handle: number, scheme: string): void {
this.lastHandle = handle;
@@ -60,12 +59,6 @@ class MockMainThreadSearch implements MainThreadSearchShape {
}
}
class MockExtHostConfiguration {
getConfiguration(section?: string, resource?: URI, extensionId?: string): vscode.WorkspaceConfiguration {
return <vscode.WorkspaceConfiguration>{};
}
}
let mockExtfs: Partial<typeof extfs>;
suite('ExtHostSearch', () => {
@@ -100,7 +93,7 @@ suite('ExtHostSearch', () => {
await rpcProtocol.sync();
return {
results: (<UriComponents[]>mockMainThreadSearch.results).map(r => URI.revive(r)),
stats
stats: stats!
};
}
@@ -130,7 +123,7 @@ suite('ExtHostSearch', () => {
}
}));
return { results, stats };
return { results, stats: stats! };
}
setup(() => {
@@ -138,12 +131,11 @@ suite('ExtHostSearch', () => {
mockMainThreadSearch = new MockMainThreadSearch();
const logService = new TestLogService();
const ehConfiguration: ExtHostConfiguration = new MockExtHostConfiguration() as any;
rpcProtocol.set(MainContext.MainThreadSearch, mockMainThreadSearch);
mockExtfs = {};
extHostSearch = new ExtHostSearch(rpcProtocol, null, logService, ehConfiguration, mockExtfs as typeof extfs);
extHostSearch = new ExtHostSearch(rpcProtocol, null!, logService, mockExtfs as typeof extfs);
});
teardown(() => {
@@ -179,8 +171,8 @@ suite('ExtHostSearch', () => {
test('no results', async () => {
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
return Promise.resolve(null);
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
return Promise.resolve(null!);
}
});
@@ -197,7 +189,7 @@ suite('ExtHostSearch', () => {
];
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
return Promise.resolve(reportedResults);
}
});
@@ -211,7 +203,7 @@ suite('ExtHostSearch', () => {
test('Search canceled', async () => {
let cancelRequested = false;
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
return new Promise((resolve, reject) => {
token.onCancellationRequested(() => {
cancelRequested = true;
@@ -229,8 +221,8 @@ suite('ExtHostSearch', () => {
test('provider returns null', async () => {
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
return null;
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
return null!;
}
});
@@ -244,9 +236,9 @@ suite('ExtHostSearch', () => {
test('all provider calls get global include/excludes', async () => {
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
assert(options.excludes.length === 2 && options.includes.length === 2, 'Missing global include/excludes');
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -273,7 +265,7 @@ suite('ExtHostSearch', () => {
test('global/local include/excludes combined', async () => {
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
if (options.folder.toString() === rootFolderA.toString()) {
assert.deepEqual(options.includes.sort(), ['*.ts', 'foo']);
assert.deepEqual(options.excludes.sort(), ['*.js', 'bar']);
@@ -282,7 +274,7 @@ suite('ExtHostSearch', () => {
assert.deepEqual(options.excludes.sort(), ['*.js']);
}
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -315,11 +307,11 @@ suite('ExtHostSearch', () => {
test('include/excludes resolved correctly', async () => {
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
assert.deepEqual(options.includes.sort(), ['*.jsx', '*.ts']);
assert.deepEqual(options.excludes.sort(), []);
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -358,7 +350,7 @@ suite('ExtHostSearch', () => {
];
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
return Promise.resolve(reportedResults
.map(relativePath => joinPath(options.folder, relativePath)));
}
@@ -389,7 +381,7 @@ suite('ExtHostSearch', () => {
test('multiroot sibling exclude clause', async () => {
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
let reportedResults: URI[];
if (options.folder.fsPath === rootFolderA.fsPath) {
reportedResults = [
@@ -459,7 +451,7 @@ suite('ExtHostSearch', () => {
let wasCanceled = false;
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
token.onCancellationRequested(() => wasCanceled = true);
return Promise.resolve(reportedResults);
@@ -495,7 +487,7 @@ suite('ExtHostSearch', () => {
let wasCanceled = false;
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
token.onCancellationRequested(() => wasCanceled = true);
return Promise.resolve(reportedResults);
@@ -530,7 +522,7 @@ suite('ExtHostSearch', () => {
let wasCanceled = false;
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
token.onCancellationRequested(() => wasCanceled = true);
return Promise.resolve(reportedResults);
@@ -603,7 +595,7 @@ suite('ExtHostSearch', () => {
];
await registerTestFileSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Thenable<URI[]> {
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
return Promise.resolve(reportedResults);
}
}, fancyScheme);
@@ -627,7 +619,7 @@ suite('ExtHostSearch', () => {
function makePreview(text: string): vscode.TextSearchMatch['preview'] {
return {
matches: new Range(0, 0, 0, text.length),
matches: [new Range(0, 0, 0, text.length)],
text
};
}
@@ -635,7 +627,7 @@ suite('ExtHostSearch', () => {
function makeTextResult(baseFolder: URI, relativePath: string): vscode.TextSearchMatch {
return {
preview: makePreview('foo'),
ranges: new Range(0, 0, 0, 3),
ranges: [new Range(0, 0, 0, 3)],
uri: joinPath(baseFolder, relativePath)
};
}
@@ -661,7 +653,7 @@ suite('ExtHostSearch', () => {
const actualTextSearchResults: vscode.TextSearchResult[] = [];
for (let fileMatch of actual) {
// Make relative
for (let lineResult of fileMatch.results) {
for (let lineResult of fileMatch.results!) {
if (resultIsMatch(lineResult)) {
actualTextSearchResults.push({
preview: {
@@ -714,8 +706,8 @@ suite('ExtHostSearch', () => {
test('no results', async () => {
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
return Promise.resolve(null);
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
return Promise.resolve(null!);
}
});
@@ -731,9 +723,9 @@ suite('ExtHostSearch', () => {
];
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -744,10 +736,10 @@ suite('ExtHostSearch', () => {
test('all provider calls get global include/excludes', async () => {
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
assert.equal(options.includes.length, 1);
assert.equal(options.excludes.length, 1);
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -774,7 +766,7 @@ suite('ExtHostSearch', () => {
test('global/local include/excludes combined', async () => {
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
if (options.folder.toString() === rootFolderA.toString()) {
assert.deepEqual(options.includes.sort(), ['*.ts', 'foo']);
assert.deepEqual(options.excludes.sort(), ['*.js', 'bar']);
@@ -783,7 +775,7 @@ suite('ExtHostSearch', () => {
assert.deepEqual(options.excludes.sort(), ['*.js']);
}
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -816,11 +808,11 @@ suite('ExtHostSearch', () => {
test('include/excludes resolved correctly', async () => {
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
assert.deepEqual(options.includes.sort(), ['*.jsx', '*.ts']);
assert.deepEqual(options.excludes.sort(), []);
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -854,7 +846,7 @@ suite('ExtHostSearch', () => {
test('provider fail', async () => {
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
throw new Error('Provider fail');
}
});
@@ -870,12 +862,12 @@ suite('ExtHostSearch', () => {
test('basic sibling clause', async () => {
mockExtfs.readdir = (_path: string, callback: (error: Error, files: string[]) => void) => {
if (_path === rootFolderA.fsPath) {
callback(null, [
callback(null!, [
'file1.js',
'file1.ts'
]);
} else {
callback(new Error('Wrong path'), null);
callback(new Error('Wrong path'), null!);
}
};
@@ -885,9 +877,9 @@ suite('ExtHostSearch', () => {
];
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -913,24 +905,24 @@ suite('ExtHostSearch', () => {
test('multiroot sibling clause', async () => {
mockExtfs.readdir = (_path: string, callback: (error: Error, files: string[]) => void) => {
if (_path === joinPath(rootFolderA, 'folder').fsPath) {
callback(null, [
callback(null!, [
'fileA.scss',
'fileA.css',
'file2.css'
]);
} else if (_path === rootFolderB.fsPath) {
callback(null, [
callback(null!, [
'fileB.ts',
'fileB.js',
'file3.js'
]);
} else {
callback(new Error('Wrong path'), null);
callback(new Error('Wrong path'), null!);
}
};
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
let reportedResults;
if (options.folder.fsPath === rootFolderA.fsPath) {
reportedResults = [
@@ -947,7 +939,7 @@ suite('ExtHostSearch', () => {
}
reportedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -995,9 +987,9 @@ suite('ExtHostSearch', () => {
];
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -1026,10 +1018,10 @@ suite('ExtHostSearch', () => {
let wasCanceled = false;
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
token.onCancellationRequested(() => wasCanceled = true);
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -1059,10 +1051,10 @@ suite('ExtHostSearch', () => {
let wasCanceled = false;
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
token.onCancellationRequested(() => wasCanceled = true);
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -1091,10 +1083,10 @@ suite('ExtHostSearch', () => {
let wasCanceled = false;
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
token.onCancellationRequested(() => wasCanceled = true);
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
});
@@ -1123,7 +1115,7 @@ suite('ExtHostSearch', () => {
];
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
providedResults.forEach(r => progress.report(r));
return Promise.resolve({ limitHit: true });
}
@@ -1156,7 +1148,7 @@ suite('ExtHostSearch', () => {
'file2.ts',
'file3.ts',
].forEach(f => progress.report(makeTextResult(options.folder, f)));
return null;
return null!;
}
});
@@ -1185,9 +1177,9 @@ suite('ExtHostSearch', () => {
];
await registerTestTextSearchProvider({
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<vscode.TextSearchComplete> {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
providedResults.forEach(r => progress.report(r));
return Promise.resolve(null);
return Promise.resolve(null!);
}
}, fancyScheme);

View File

@@ -14,12 +14,12 @@ import { mock } from 'vs/workbench/test/electron-browser/api/mock';
suite('ExtHostTextEditor', () => {
let editor: ExtHostTextEditor;
let doc = new ExtHostDocumentData(undefined, URI.file(''), [
let doc = new ExtHostDocumentData(undefined!, URI.file(''), [
'aaaa bbbb+cccc abc'
], '\n', 'text', 1, false);
setup(() => {
editor = new ExtHostTextEditor(null, 'fake', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
editor = new ExtHostTextEditor(null!, 'fake', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
});
test('disposed editor', () => {
@@ -34,7 +34,7 @@ suite('ExtHostTextEditor', () => {
assert.equal(3, editor.viewColumn);
assert.ok(editor.document);
assert.throws(() => editor._acceptOptions(null));
assert.throws(() => editor._acceptOptions(null!));
assert.throws(() => editor._acceptSelections([]));
});
@@ -66,25 +66,25 @@ suite('ExtHostTextEditorOptions', () => {
setup(() => {
calls = [];
let mockProxy: MainThreadTextEditorsShape = {
dispose: undefined,
dispose: undefined!,
$trySetOptions: (id: string, options: ITextEditorConfigurationUpdate) => {
assert.equal(id, '1');
calls.push(options);
return Promise.resolve(void 0);
return Promise.resolve(undefined);
},
$tryShowTextDocument: undefined,
$registerTextEditorDecorationType: undefined,
$removeTextEditorDecorationType: undefined,
$tryShowEditor: undefined,
$tryHideEditor: undefined,
$trySetDecorations: undefined,
$trySetDecorationsFast: undefined,
$tryRevealRange: undefined,
$trySetSelections: undefined,
$tryApplyEdits: undefined,
$tryApplyWorkspaceEdit: undefined,
$tryInsertSnippet: undefined,
$getDiffInformation: undefined
$tryShowTextDocument: undefined!,
$registerTextEditorDecorationType: undefined!,
$removeTextEditorDecorationType: undefined!,
$tryShowEditor: undefined!,
$tryHideEditor: undefined!,
$trySetDecorations: undefined!,
$trySetDecorationsFast: undefined!,
$tryRevealRange: undefined!,
$trySetSelections: undefined!,
$tryApplyEdits: undefined!,
$tryApplyWorkspaceEdit: undefined!,
$tryInsertSnippet: undefined!,
$getDiffInformation: undefined!
};
opts = new ExtHostTextEditorOptions(mockProxy, '1', {
tabSize: 4,
@@ -95,8 +95,8 @@ suite('ExtHostTextEditorOptions', () => {
});
teardown(() => {
opts = null;
calls = null;
opts = null!;
calls = null!;
});
function assertState(opts: ExtHostTextEditorOptions, expected: IResolvedTextEditorConfiguration): void {
@@ -165,7 +165,7 @@ suite('ExtHostTextEditorOptions', () => {
});
test('ignores invalid tabSize 1', () => {
opts.tabSize = null;
opts.tabSize = null!;
assertState(opts, {
tabSize: 4,
insertSpaces: false,

View File

@@ -19,7 +19,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
let workspaceResourceEdits: WorkspaceEditDto;
setup(() => {
workspaceResourceEdits = null;
workspaceResourceEdits = null!;
let rpcProtocol = new TestRPCProtocol();
rpcProtocol.set(MainContext.MainThreadTextEditors, new class extends mock<MainThreadTextEditorsShape>() {

View File

@@ -41,7 +41,7 @@ suite('ExtHostTreeView', function () {
let testObject: ExtHostTreeViews;
let target: RecordingShape;
let onDidChangeTreeNode: Emitter<{ key: string }>;
let onDidChangeTreeNode: Emitter<{ key: string } | undefined>;
let onDidChangeTreeNodeWithId: Emitter<{ key: string }>;
let tree, labels, nodes;
@@ -199,7 +199,7 @@ suite('ExtHostTreeView', function () {
.then(() => { assert.fail('Should fail with duplicate id'); done(); }, () => done());
});
});
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
});
test('refresh root', function (done) {
@@ -207,7 +207,7 @@ suite('ExtHostTreeView', function () {
assert.equal(undefined, actuals);
done();
});
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
});
test('refresh a parent node', () => {
@@ -219,7 +219,7 @@ suite('ExtHostTreeView', function () {
label: { label: 'b' },
collapsibleState: TreeItemCollapsibleState.Collapsed
});
c(null);
c(undefined);
});
onDidChangeTreeNode.fire(getNode('b'));
});
@@ -300,10 +300,10 @@ suite('ExtHostTreeView', function () {
assert.equal(undefined, actuals);
done();
});
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
onDidChangeTreeNode.fire(undefined);
onDidChangeTreeNode.fire(undefined);
onDidChangeTreeNode.fire(undefined);
});
test('refresh calls are throttled on elements', function (done) {
@@ -339,7 +339,7 @@ suite('ExtHostTreeView', function () {
onDidChangeTreeNode.fire(getNode('a'));
onDidChangeTreeNode.fire(getNode('b'));
onDidChangeTreeNode.fire(getNode('g'));
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
});
test('refresh calls are throttled on elements and root', function (done) {
@@ -350,7 +350,7 @@ suite('ExtHostTreeView', function () {
onDidChangeTreeNode.fire(getNode('a'));
onDidChangeTreeNode.fire(getNode('b'));
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
onDidChangeTreeNode.fire(getNode('a'));
});
@@ -366,7 +366,7 @@ suite('ExtHostTreeView', function () {
done();
});
});
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
});
test('tree with duplicate labels', (done) => {
@@ -415,7 +415,7 @@ suite('ExtHostTreeView', function () {
});
});
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
});
test('getChildren is not returned from cache if refreshed', (done) => {
@@ -431,7 +431,7 @@ suite('ExtHostTreeView', function () {
});
});
onDidChangeTreeNode.fire();
onDidChangeTreeNode.fire(undefined);
});
test('getChildren is returned from cache if not refreshed', () => {
@@ -596,7 +596,7 @@ suite('ExtHostTreeView', function () {
if (typeof obj === 'object') {
const result = {};
for (const key of Object.keys(obj)) {
if (obj[key] !== void 0) {
if (obj[key] !== undefined) {
result[key] = removeUnsetKeys(obj[key]);
}
}
@@ -627,7 +627,7 @@ suite('ExtHostTreeView', function () {
},
getParent: ({ key }: { key: string }): { key: string } => {
const parentKey = key.substring(0, key.length - 1);
return parentKey ? new Key(parentKey) : void 0;
return parentKey ? new Key(parentKey) : undefined;
},
onDidChangeTreeData: onDidChangeTreeNode.event
};

View File

@@ -29,34 +29,34 @@ suite('ExtHostTypeConverter', function () {
data = MarkdownString.from('Hello [link](foo:path)');
assert.equal(data.value, 'Hello [link](foo:path)');
assert.equal(size(data.uris), 1);
assert.ok(!!data.uris['foo:path']);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['foo:path']);
data = MarkdownString.from('hello@foo.bar');
assert.equal(data.value, 'hello@foo.bar');
assert.equal(size(data.uris), 1);
assert.ok(!!data.uris['mailto:hello@foo.bar']);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['mailto:hello@foo.bar']);
data = MarkdownString.from('*hello* [click](command:me)');
assert.equal(data.value, '*hello* [click](command:me)');
assert.equal(size(data.uris), 1);
assert.ok(!!data.uris['command:me']);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['command:me']);
data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(size(data.uris), 1);
assert.ok(!!data.uris['file:///somepath/here']);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['file:///somepath/here']);
data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(size(data.uris), 1);
assert.ok(!!data.uris['file:///somepath/here']);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['file:///somepath/here']);
data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here2)');
assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here2)');
assert.equal(size(data.uris), 2);
assert.ok(!!data.uris['file:///somepath/here']);
assert.ok(!!data.uris['file:///somepath/here2']);
assert.equal(size(data.uris!), 2);
assert.ok(!!data.uris!['file:///somepath/here']);
assert.ok(!!data.uris!['file:///somepath/here2']);
});
test('LogLevel', () => {

View File

@@ -56,7 +56,7 @@ suite('ExtHostTypes', function () {
d.dispose();
assert.equal(count, 1);
types.Disposable.from(undefined, { dispose() { count += 1; } }).dispose();
types.Disposable.from(undefined!, { dispose() { count += 1; } }).dispose();
assert.equal(count, 2);
@@ -66,7 +66,7 @@ suite('ExtHostTypes', function () {
}).dispose();
});
new types.Disposable(undefined).dispose();
new types.Disposable(undefined!).dispose();
});
@@ -154,11 +154,11 @@ suite('ExtHostTypes', function () {
assert.equal(res.line, 12);
assert.equal(res.character, 3);
assert.throws(() => p1.translate(null));
assert.throws(() => p1.translate(null, null));
assert.throws(() => p1.translate(null!));
assert.throws(() => p1.translate(null!, null!));
assert.throws(() => p1.translate(-2));
assert.throws(() => p1.translate({ lineDelta: -2 }));
assert.throws(() => p1.translate(-2, null));
assert.throws(() => p1.translate(-2, null!));
assert.throws(() => p1.translate(0, -4));
});
@@ -178,7 +178,7 @@ suite('ExtHostTypes', function () {
assert.equal(p2.line, 0);
assert.equal(p2.character, 11);
assert.throws(() => p1.with(null));
assert.throws(() => p1.with(null!));
assert.throws(() => p1.with(-9));
assert.throws(() => p1.with(0, -9));
assert.throws(() => p1.with({ line: -1 }));
@@ -188,10 +188,10 @@ suite('ExtHostTypes', function () {
test('Range', () => {
assert.throws(() => new types.Range(-1, 0, 0, 0));
assert.throws(() => new types.Range(0, -1, 0, 0));
assert.throws(() => new types.Range(new types.Position(0, 0), undefined));
assert.throws(() => new types.Range(new types.Position(0, 0), null));
assert.throws(() => new types.Range(undefined, new types.Position(0, 0)));
assert.throws(() => new types.Range(null, new types.Position(0, 0)));
assert.throws(() => new types.Range(new types.Position(0, 0), undefined!));
assert.throws(() => new types.Range(new types.Position(0, 0), null!));
assert.throws(() => new types.Range(undefined!, new types.Position(0, 0)));
assert.throws(() => new types.Range(null!, new types.Position(0, 0)));
let range = new types.Range(1, 0, 0, 0);
assert.throws(() => { (range as any).start = null; });
@@ -250,30 +250,30 @@ suite('ExtHostTypes', function () {
let range = new types.Range(1, 1, 2, 11);
let res: types.Range;
res = range.intersection(range);
res = range.intersection(range)!;
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
assert.equal(res.end.line, 2);
assert.equal(res.end.character, 11);
res = range.intersection(new types.Range(2, 12, 4, 0));
res = range.intersection(new types.Range(2, 12, 4, 0))!;
assert.equal(res, undefined);
res = range.intersection(new types.Range(0, 0, 1, 0));
res = range.intersection(new types.Range(0, 0, 1, 0))!;
assert.equal(res, undefined);
res = range.intersection(new types.Range(0, 0, 1, 1));
res = range.intersection(new types.Range(0, 0, 1, 1))!;
assert.ok(res.isEmpty);
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
res = range.intersection(new types.Range(2, 11, 61, 1));
res = range.intersection(new types.Range(2, 11, 61, 1))!;
assert.ok(res.isEmpty);
assert.equal(res.start.line, 2);
assert.equal(res.start.character, 11);
assert.throws(() => range.intersection(null));
assert.throws(() => range.intersection(undefined));
assert.throws(() => range.intersection(null!));
assert.throws(() => range.intersection(undefined!));
});
test('Range, union', function () {
@@ -325,18 +325,18 @@ suite('ExtHostTypes', function () {
assert.equal(res.start.line, 2);
assert.equal(res.start.character, 3);
assert.throws(() => range.with(null));
assert.throws(() => range.with(undefined, null));
assert.throws(() => range.with(null!));
assert.throws(() => range.with(undefined, null!));
});
test('TextEdit', () => {
let range = new types.Range(1, 1, 2, 11);
let edit = new types.TextEdit(range, undefined);
let edit = new types.TextEdit(range, undefined!);
assert.equal(edit.newText, '');
assertToJSON(edit, { range: [{ line: 1, character: 1 }, { line: 2, character: 11 }], newText: '' });
edit = new types.TextEdit(range, null);
edit = new types.TextEdit(range, null!);
assert.equal(edit.newText, '');
edit = new types.TextEdit(range, '');
@@ -365,7 +365,7 @@ suite('ExtHostTypes', function () {
[b.toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]]
]);
edit.set(b, undefined);
edit.set(b, undefined!);
assert.ok(!edit.has(b));
assert.equal(edit.size, 1);
@@ -395,17 +395,17 @@ suite('ExtHostTypes', function () {
}
const [first, second, third, fourth] = all;
assert.equal(first[0].toString(), 'foo:a');
assert.equal(first[0]!.toString(), 'foo:a');
assert.ok(!isFileChange(first));
assert.ok(isTextChange(first) && first[1].length === 1);
assert.equal(second[0].toString(), 'foo:a');
assert.equal(second[0]!.toString(), 'foo:a');
assert.ok(isFileChange(second));
assert.equal(third[0].toString(), 'foo:a');
assert.equal(third[0]!.toString(), 'foo:a');
assert.ok(isTextChange(third) && third[1].length === 1);
assert.equal(fourth[0].toString(), 'foo:b');
assert.equal(fourth[0]!.toString(), 'foo:b');
assert.ok(!isFileChange(fourth));
assert.ok(isTextChange(fourth) && fourth[1].length === 1);
});
@@ -423,8 +423,8 @@ suite('ExtHostTypes', function () {
});
test('DocumentLink', () => {
assert.throws(() => new types.DocumentLink(null, null));
assert.throws(() => new types.DocumentLink(new types.Range(1, 1, 1, 1), null));
assert.throws(() => new types.DocumentLink(null!, null!));
assert.throws(() => new types.DocumentLink(new types.Range(1, 1, 1, 1), null!));
});
test('toJSON & stringify', function () {
@@ -532,4 +532,24 @@ suite('ExtHostTypes', function () {
assert.ok(error instanceof Error);
assert.ok(error instanceof types.FileSystemError);
});
test('CodeActionKind contains', () => {
assert.ok(types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.RefactorExtract));
assert.ok(types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.RefactorExtract.append('other')));
assert.ok(!types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.Refactor));
assert.ok(!types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.Refactor.append('other')));
assert.ok(!types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.Empty.append('other').append('refactor')));
assert.ok(!types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.Empty.append('refactory')));
});
test('CodeActionKind intersects', () => {
assert.ok(types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.RefactorExtract));
assert.ok(types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.Refactor));
assert.ok(types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.RefactorExtract.append('other')));
assert.ok(!types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.Refactor.append('other')));
assert.ok(!types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.Empty.append('other').append('refactor')));
assert.ok(!types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.Empty.append('refactory')));
});
});

View File

@@ -14,19 +14,20 @@ import { IExtensionDescription } from 'vs/workbench/services/extensions/common/e
import { NullLogService } from 'vs/platform/log/common/log';
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { Counter } from 'vs/base/common/numbers';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
suite('ExtHostWorkspace', function () {
const extensionDescriptor: IExtensionDescription = {
id: 'nullExtensionDescription',
identifier: new ExtensionIdentifier('nullExtensionDescription'),
name: 'ext',
publisher: 'vscode',
enableProposedApi: false,
engines: undefined,
extensionLocation: undefined,
engines: undefined!,
extensionLocation: undefined!,
isBuiltin: false,
isUnderDevelopment: false,
version: undefined
version: undefined!
};
function assertAsRelativePath(workspace: ExtHostWorkspace, input: string, expected: string, includeWorkspace?: boolean) {
@@ -63,7 +64,7 @@ suite('ExtHostWorkspace', function () {
});
test('asRelativePath, no workspace', function () {
const ws = new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter());
const ws = new ExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
assertAsRelativePath(ws, (''), '');
assertAsRelativePath(ws, ('/foo/bar'), '/foo/bar');
});
@@ -101,10 +102,10 @@ suite('ExtHostWorkspace', function () {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
assert.equal(ws.getPath(), undefined);
ws = new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter());
ws = new ExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
assert.equal(ws.getPath(), undefined);
ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined, new NullLogService(), new Counter());
ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined!, new NullLogService(), new Counter());
assert.equal(ws.getPath(), undefined);
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService(), new Counter());
@@ -259,7 +260,7 @@ suite('ExtHostWorkspace', function () {
test('updateWorkspaceFolders - invalid arguments', function () {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null, null));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null!, null!));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 1));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0));
@@ -283,9 +284,9 @@ suite('ExtHostWorkspace', function () {
};
const protocol: IMainContext = {
getProxy: () => { return undefined; },
set: undefined,
assertRegistered: undefined
getProxy: () => { return undefined!; },
set: undefined!,
assertRegistered: undefined!
};
const ws = new ExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());

View File

@@ -12,7 +12,7 @@ suite('MainThreadCommands', function () {
test('dispose on unregister', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined);
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!);
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
// register
@@ -26,7 +26,7 @@ suite('MainThreadCommands', function () {
test('unregister all on dispose', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined);
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!);
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
commands.$registerCommand('foo');

View File

@@ -14,9 +14,13 @@ import { MainThreadConfiguration } from 'vs/workbench/api/electron-browser/mainT
import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
suite('MainThreadConfiguration', function () {
let proxy = {
$initializeConfiguration: () => { }
};
let instantiationService: TestInstantiationService;
let target: sinon.SinonSpy;
@@ -50,11 +54,14 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IConfigurationService, 'onDidUpdateConfiguration', sinon.mock());
instantiationService.stub(IConfigurationService, 'onDidChangeConfiguration', sinon.mock());
instantiationService.stub(IConfigurationService, 'updateValue', target);
instantiationService.stub(IEnvironmentService, {
isBuilt: false
});
});
test('update resource configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', null);
@@ -63,7 +70,7 @@ suite('MainThreadConfiguration', function () {
test('update resource configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', URI.file('abc'));
@@ -72,7 +79,7 @@ suite('MainThreadConfiguration', function () {
test('update resource configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', null);
@@ -81,7 +88,7 @@ suite('MainThreadConfiguration', function () {
test('update window configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', null);
@@ -90,7 +97,7 @@ suite('MainThreadConfiguration', function () {
test('update window configuration without configuration target defaults to workspace in multi root workspace when resource is provided', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', URI.file('abc'));
@@ -99,7 +106,7 @@ suite('MainThreadConfiguration', function () {
test('update window configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', URI.file('abc'));
@@ -108,7 +115,7 @@ suite('MainThreadConfiguration', function () {
test('update window configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', null);
@@ -117,7 +124,7 @@ suite('MainThreadConfiguration', function () {
test('update resource configuration without configuration target defaults to folder', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', URI.file('abc'));
@@ -126,7 +133,7 @@ suite('MainThreadConfiguration', function () {
test('update configuration with user configuration target', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(ConfigurationTarget.USER, 'extHostConfiguration.window', 'value', URI.file('abc'));
@@ -135,7 +142,7 @@ suite('MainThreadConfiguration', function () {
test('update configuration with workspace configuration target', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(ConfigurationTarget.WORKSPACE, 'extHostConfiguration.window', 'value', URI.file('abc'));
@@ -144,7 +151,7 @@ suite('MainThreadConfiguration', function () {
test('update configuration with folder configuration target', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(ConfigurationTarget.WORKSPACE_FOLDER, 'extHostConfiguration.window', 'value', URI.file('abc'));
@@ -153,7 +160,7 @@ suite('MainThreadConfiguration', function () {
test('remove resource configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', null);
@@ -162,7 +169,7 @@ suite('MainThreadConfiguration', function () {
test('remove resource configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', URI.file('abc'));
@@ -171,7 +178,7 @@ suite('MainThreadConfiguration', function () {
test('remove resource configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', null);
@@ -180,7 +187,7 @@ suite('MainThreadConfiguration', function () {
test('remove window configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', null);
@@ -189,7 +196,7 @@ suite('MainThreadConfiguration', function () {
test('remove window configuration without configuration target defaults to workspace in multi root workspace when resource is provided', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', URI.file('abc'));
@@ -198,7 +205,7 @@ suite('MainThreadConfiguration', function () {
test('remove window configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', URI.file('abc'));
@@ -207,7 +214,7 @@ suite('MainThreadConfiguration', function () {
test('remove window configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', null);
@@ -216,7 +223,7 @@ suite('MainThreadConfiguration', function () {
test('remove configuration without configuration target defaults to folder', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(null));
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', URI.file('abc'));

View File

@@ -19,7 +19,7 @@ suite('MainThreadDiagnostics', function () {
test('clear markers on dispose', function () {
let diag = new MainThreadDiagnostics(null, markerService);
let diag = new MainThreadDiagnostics(null!, markerService);
diag.$changeMany('foo', [[URI.file('a'), [{
code: '666',

View File

@@ -42,7 +42,7 @@ suite('MainThreadDocumentsAndEditors', () => {
deltas.length = 0;
const configService = new TestConfigurationService();
configService.setUserConfiguration('editor', { 'detectIndentation': false });
modelService = new ModelServiceImpl(null, configService, new TestTextResourcePropertiesService(configService));
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService));
codeEditorService = new TestCodeEditorService();
textFileService = new class extends mock<ITextFileService>() {
isDirty() { return false; }

View File

@@ -25,8 +25,8 @@ import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser
import { NullLogService } from 'vs/platform/log/common/log';
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
import { IReference, ImmortalReference } from 'vs/base/common/lifecycle';
import { LabelService } from 'vs/platform/label/common/label';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
suite('MainThreadEditors', () => {
@@ -41,7 +41,7 @@ suite('MainThreadEditors', () => {
setup(() => {
const configService = new TestConfigurationService();
modelService = new ModelServiceImpl(null, configService, new TestTextResourcePropertiesService(configService));
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService));
const codeEditorService = new TestCodeEditorService();
movedResources.clear();
@@ -54,15 +54,15 @@ suite('MainThreadEditors', () => {
isDirty() { return false; }
create(uri: URI, contents?: string, options?: any) {
createdResources.add(uri);
return Promise.resolve(void 0);
return Promise.resolve(undefined);
}
delete(resource: URI) {
deletedResources.add(resource);
return Promise.resolve(void 0);
return Promise.resolve(undefined);
}
move(source: URI, target: URI) {
movedResources.set(source, target);
return Promise.resolve(void 0);
return Promise.resolve(undefined);
}
models = <any>{
onModelSaved: Event.None,

View File

@@ -48,25 +48,25 @@ suite('MainThreadSaveParticipant', function () {
// No new line for empty lines
let lineContent = '';
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
// No new line if last line already empty
lineContent = `Hello New Line${model.textEditorModel.getEOL()}`;
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
// New empty line added (single line)
lineContent = 'Hello New Line';
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${lineContent}${model.textEditorModel.getEOL()}`);
// New empty line added (multi line)
lineContent = `Hello New Line${model.textEditorModel.getEOL()}Hello New Line${model.textEditorModel.getEOL()}Hello New Line`;
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${lineContent}${model.textEditorModel.getEOL()}`);
});
@@ -83,25 +83,25 @@ suite('MainThreadSaveParticipant', function () {
// No new line removal if last line is not new line
let lineContent = `${textContent}`;
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
// No new line removal if last line is single new line
lineContent = `${textContent}${eol}`;
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
// Remove new line (single line with two new lines)
lineContent = `${textContent}${eol}${eol}`;
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}`);
// Remove new lines (multiple lines with multiple new lines)
lineContent = `${textContent}${eol}${textContent}${eol}${eol}${eol}`;
model.textEditorModel.setValue(lineContent);
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}${textContent}${eol}`);
});
@@ -127,7 +127,7 @@ suite('MainThreadSaveParticipant', function () {
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}`);
// trim final new lines should not mess the undo stack
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
model.textEditorModel.redo();
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}.`);
});
@@ -146,7 +146,7 @@ suite('MainThreadSaveParticipant', function () {
// save many times
for (let i = 0; i < 10; i++) {
participant.participate(model, { reason: SaveReason.EXPLICIT });
await participant.participate(model, { reason: SaveReason.EXPLICIT });
}
// confirm trimming

View File

@@ -102,7 +102,7 @@ export class TestRPCProtocol implements IExtHostContext {
const instance = this._locals[proxyId];
// pretend the args went over the wire... (invoke .toJSON on objects...)
const wireArgs = simulateWireTransfer(args);
let p: Thenable<any>;
let p: Promise<any>;
try {
let result = (<Function>instance[path]).apply(instance, wireArgs);
p = isThenable(result) ? result : Promise.resolve(result);

View File

@@ -3,33 +3,32 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/workbench/parts/search/electron-browser/search.contribution'; // load contributions
import * as assert from 'assert';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { ISearchService } from 'vs/platform/search/common/search';
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import * as minimist from 'minimist';
import * as path from 'path';
import { IQuickOpenRegistry, Extensions } from 'vs/workbench/browser/quickopen';
import { Registry } from 'vs/platform/registry/common/platform';
import { SearchService } from 'vs/workbench/services/search/node/searchService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { TPromise } from 'vs/base/common/winjs.base';
import { URI } from 'vs/base/common/uri';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { IModelService } from 'vs/editor/common/services/modelService';
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { CancellationToken } from 'vs/base/common/cancellation';
import { URI } from 'vs/base/common/uri';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { Registry } from 'vs/platform/registry/common/platform';
import { ISearchService } from 'vs/platform/search/common/search';
import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { Extensions, IQuickOpenRegistry } from 'vs/workbench/browser/quickopen';
import 'vs/workbench/parts/search/electron-browser/search.contribution'; // load contributions
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { SearchService } from 'vs/workbench/services/search/node/searchService';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { TestContextService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
namespace Timer {
export interface ITimerEvent {
@@ -57,7 +56,7 @@ suite.skip('QuickOpen performance (integration)', () => {
test('Measure', () => {
if (process.env['VSCODE_PID']) {
return void 0; // TODO@Christoph find out why test fails when run from within VS Code
return undefined; // TODO@Christoph find out why test fails when run from within VS Code
}
const n = 3;
@@ -73,7 +72,7 @@ suite.skip('QuickOpen performance (integration)', () => {
[ITelemetryService, telemetryService],
[IConfigurationService, configurationService],
[ITextResourcePropertiesService, textResourcePropertiesService],
[IModelService, new ModelServiceImpl(null, configurationService, textResourcePropertiesService)],
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService)],
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
[IEditorService, new TestEditorService()],
[IEditorGroupsService, new TestEditorGroupsService()],
@@ -136,9 +135,9 @@ suite.skip('QuickOpen performance (integration)', () => {
if (testWorkspaceArg || verboseResults) { // Don't measure by default
const cachedEvents: Timer.ITimerEvent[] = [];
let i = n;
return (function iterate(): TPromise<Timer.ITimerEvent> {
return (function iterate(): Promise<Timer.ITimerEvent> {
if (!i--) {
return undefined;
return undefined!;
}
return measure()
.then(([uncachedEvent, cachedEvent]) => {
@@ -165,13 +164,13 @@ class TestTelemetryService implements ITelemetryService {
public events: any[] = [];
public publicLog(eventName: string, data?: any): TPromise<void> {
public publicLog(eventName: string, data?: any): Promise<void> {
this.events.push({ name: eventName, data: data });
return TPromise.wrap<void>(null);
return Promise.resolve(undefined);
}
public getTelemetryInfo(): TPromise<ITelemetryInfo> {
return TPromise.as({
public getTelemetryInfo(): Promise<ITelemetryInfo> {
return Promise.resolve({
instanceId: 'someValue.instanceId',
sessionId: 'someValue.sessionId',
machineId: 'someValue.machineId'

View File

@@ -29,7 +29,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { SearchModel } from 'vs/workbench/parts/search/common/searchModel';
import { QueryBuilder, ITextQueryBuilderOptions } from 'vs/workbench/parts/search/common/queryBuilder';
import * as event from 'vs/base/common/event';
import { Event, Emitter } from 'vs/base/common/event';
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { NullLogService, ILogService } from 'vs/platform/log/common/log';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
@@ -62,7 +62,7 @@ suite.skip('TextSearch performance (integration)', () => {
[ITelemetryService, telemetryService],
[IConfigurationService, configurationService],
[ITextResourcePropertiesService, textResourcePropertiesService],
[IModelService, new ModelServiceImpl(null, configurationService, textResourcePropertiesService)],
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService)],
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
[IEditorService, new TestEditorService()],
[IEditorGroupsService, new TestEditorGroupsService()],
@@ -82,8 +82,8 @@ suite.skip('TextSearch performance (integration)', () => {
const query = queryBuilder.text({ pattern: 'static_library(' }, [URI.file(testWorkspacePath)], queryOptions);
// Wait for the 'searchResultsFinished' event, which is fired after the search() promise is resolved
const onSearchResultsFinished = event.filterEvent(telemetryService.eventLogged, e => e.name === 'searchResultsFinished');
event.once(onSearchResultsFinished)(onComplete);
const onSearchResultsFinished = Event.filter(telemetryService.eventLogged, e => e.name === 'searchResultsFinished');
Event.once(onSearchResultsFinished)(onComplete);
function onComplete(): void {
try {
@@ -117,7 +117,7 @@ suite.skip('TextSearch performance (integration)', () => {
});
}
const finishedEvents = [];
const finishedEvents: any[] = [];
return runSearch() // Warm-up first
.then(() => {
if (testWorkspaceArg) { // Don't measure by default
@@ -148,9 +148,9 @@ class TestTelemetryService implements ITelemetryService {
public events: any[] = [];
private emitter = new event.Emitter<any>();
private emitter = new Emitter<any>();
public get eventLogged(): event.Event<any> {
public get eventLogged(): Event<any> {
return this.emitter.event;
}