Vscode merge (#4582)

* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd

* fix issues with merges

* bump node version in azpipe

* replace license headers

* remove duplicate launch task

* fix build errors

* fix build errors

* fix tslint issues

* working through package and linux build issues

* more work

* wip

* fix packaged builds

* working through linux build errors

* wip

* wip

* wip

* fix mac and linux file limits

* iterate linux pipeline

* disable editor typing

* revert series to parallel

* remove optimize vscode from linux

* fix linting issues

* revert testing change

* add work round for new node

* readd packaging for extensions

* fix issue with angular not resolving decorator dependencies
This commit is contained in:
Anthony Dresser
2019-03-19 17:44:35 -07:00
committed by GitHub
parent 833d197412
commit 87765e8673
1879 changed files with 54505 additions and 38058 deletions

View File

@@ -5,14 +5,17 @@
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { originalFSPath } from 'vs/workbench/api/node/extHost.api.impl';
import { originalFSPath } from 'vs/base/common/resources';
import { isWindows } from 'vs/base/common/platform';
suite('ExtHost API', function () {
test('issue #51387: originalFSPath', function () {
assert.equal(originalFSPath(URI.file('C:\\test')).charAt(0), 'C');
assert.equal(originalFSPath(URI.file('c:\\test')).charAt(0), 'c');
if (isWindows) {
assert.equal(originalFSPath(URI.file('C:\\test')).charAt(0), 'C');
assert.equal(originalFSPath(URI.file('c:\\test')).charAt(0), 'c');
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('C:\\test'))))).charAt(0), 'C');
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('c:\\test'))))).charAt(0), 'c');
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('C:\\test'))))).charAt(0), 'C');
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('c:\\test'))))).charAt(0), 'c');
}
});
});

View File

@@ -27,10 +27,11 @@ import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.proto
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
import * as vscode from 'vscode';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import 'vs/workbench/parts/search/electron-browser/search.contribution';
import 'vs/workbench/contrib/search/browser/search.contribution';
import { NullLogService } from 'vs/platform/log/common/log';
import { ITextModel } from 'vs/editor/common/model';
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { dispose } from 'vs/base/common/lifecycle';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = EditorModel.createFromString(
@@ -68,9 +69,8 @@ suite('ExtHostLanguageFeatureCommands', function () {
rpcProtocol = new TestRPCProtocol();
instantiationService.stub(IHeapService, {
_serviceBrand: undefined,
trackRecursive(args: any) {
trackObject(_obj: any) {
// nothing
return args;
}
});
instantiationService.stub(ICommandService, {
@@ -87,15 +87,15 @@ suite('ExtHostLanguageFeatureCommands', function () {
instantiationService.stub(IModelService, <IModelService>{
_serviceBrand: IModelService,
getModel(): any { return model; },
createModel(): any { throw new Error(); },
updateModel(): any { throw new Error(); },
setMode(): any { throw new Error(); },
destroyModel(): any { throw new Error(); },
getModels(): any { throw new Error(); },
onModelAdded: undefined,
onModelModeChanged: undefined,
onModelRemoved: undefined,
getCreationOptions(): any { throw new Error(); }
createModel() { throw new Error(); },
updateModel() { throw new Error(); },
setMode() { throw new Error(); },
destroyModel() { throw new Error(); },
getModels() { throw new Error(); },
onModelAdded: undefined!,
onModelModeChanged: undefined!,
onModelRemoved: undefined!,
getCreationOptions() { throw new Error(); }
});
inst = instantiationService;
}
@@ -138,10 +138,8 @@ suite('ExtHostLanguageFeatureCommands', function () {
mainThread.dispose();
});
teardown(function () {
while (disposables.length) {
disposables.pop().dispose();
}
teardown(() => {
disposables = dispose(disposables);
return rpcProtocol.sync();
});
@@ -192,8 +190,8 @@ suite('ExtHostLanguageFeatureCommands', function () {
test('executeWorkspaceSymbolProvider should accept empty string, #39522', async function () {
disposables.push(extHost.registerWorkspaceSymbolProvider(nullExtensionDescription, {
provideWorkspaceSymbols(query) {
return [new types.SymbolInformation('hello', types.SymbolKind.Array, new types.Range(0, 0, 0, 0), URI.parse('foo:bar'))];
provideWorkspaceSymbols(query): vscode.SymbolInformation[] {
return [new types.SymbolInformation('hello', types.SymbolKind.Array, new types.Range(0, 0, 0, 0), URI.parse('foo:bar')) as vscode.SymbolInformation];
}
}));
@@ -423,32 +421,32 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.equal(values.length, 4);
let [first, second, third, fourth] = values;
assert.equal(first.label, 'item1');
assert.equal(first.textEdit.newText, 'item1');
assert.equal(first.textEdit.range.start.line, 0);
assert.equal(first.textEdit.range.start.character, 0);
assert.equal(first.textEdit.range.end.line, 0);
assert.equal(first.textEdit.range.end.character, 4);
assert.equal(first.textEdit!.newText, 'item1');
assert.equal(first.textEdit!.range.start.line, 0);
assert.equal(first.textEdit!.range.start.character, 0);
assert.equal(first.textEdit!.range.end.line, 0);
assert.equal(first.textEdit!.range.end.character, 4);
assert.equal(second.label, 'item2');
assert.equal(second.textEdit.newText, 'foo');
assert.equal(second.textEdit.range.start.line, 0);
assert.equal(second.textEdit.range.start.character, 4);
assert.equal(second.textEdit.range.end.line, 0);
assert.equal(second.textEdit.range.end.character, 8);
assert.equal(second.textEdit!.newText, 'foo');
assert.equal(second.textEdit!.range.start.line, 0);
assert.equal(second.textEdit!.range.start.character, 4);
assert.equal(second.textEdit!.range.end.line, 0);
assert.equal(second.textEdit!.range.end.character, 8);
assert.equal(third.label, 'item3');
assert.equal(third.textEdit.newText, 'foobar');
assert.equal(third.textEdit.range.start.line, 0);
assert.equal(third.textEdit.range.start.character, 1);
assert.equal(third.textEdit.range.end.line, 0);
assert.equal(third.textEdit.range.end.character, 6);
assert.equal(third.textEdit!.newText, 'foobar');
assert.equal(third.textEdit!.range.start.line, 0);
assert.equal(third.textEdit!.range.start.character, 1);
assert.equal(third.textEdit!.range.end.line, 0);
assert.equal(third.textEdit!.range.end.character, 6);
assert.equal(fourth.label, 'item4');
assert.equal(fourth.textEdit, undefined);
assert.equal(fourth.range.start.line, 0);
assert.equal(fourth.range.start.character, 1);
assert.equal(fourth.range.end.line, 0);
assert.equal(fourth.range.end.character, 4);
assert.equal(fourth.range!.start.line, 0);
assert.equal(fourth.range!.start.character, 1);
assert.equal(fourth.range!.end.line, 0);
assert.equal(fourth.range!.end.character, 4);
assert.ok(fourth.insertText instanceof types.SnippetString);
assert.equal((<types.SnippetString>fourth.insertText).value, 'foo$0bar');
});
@@ -631,11 +629,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, new types.Range(0, 0, 1, 1)).then(value => {
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.ok(first.command);
assert.equal(first.command.command, 'command');
assert.equal(first.command.title, 'command_title');
assert.equal(first.kind.value, 'foo');
assert.equal(first.command!.command, 'command');
assert.equal(first.command!.title, 'command_title');
assert.equal(first.kind!.value, 'foo');
assert.equal(first.title, 'title');
});
@@ -661,13 +659,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.uri).then(value => {
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.command.title, 'Title');
assert.equal(first.command.command, 'cmd');
assert.equal(first.command.arguments[0], 1);
assert.equal(first.command.arguments[1], true);
assert.equal(first.command.arguments[2], complexArg);
assert.equal(first.command!.title, 'Title');
assert.equal(first.command!.command, 'cmd');
assert.equal(first.command!.arguments![0], 1);
assert.equal(first.command!.arguments![1], true);
assert.equal(first.command!.arguments![2], complexArg);
});
});
});
@@ -719,7 +717,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.equal(value.length, 1);
let [first] = value;
assert.equal(first.target.toString(), 'foo:bar');
assert.equal(first.target + '', 'foo:bar');
assert.equal(first.range.start.line, 0);
assert.equal(first.range.start.character, 0);
assert.equal(first.range.end.line, 0);
@@ -765,16 +763,16 @@ suite('ExtHostLanguageFeatureCommands', function () {
let [first] = value;
assert.equal(first.label, '#ABC');
assert.equal(first.textEdit.newText, '#ABC');
assert.equal(first.textEdit.range.start.line, 1);
assert.equal(first.textEdit.range.start.character, 0);
assert.equal(first.textEdit.range.end.line, 1);
assert.equal(first.textEdit.range.end.character, 20);
assert.equal(first.additionalTextEdits.length, 1);
assert.equal(first.additionalTextEdits[0].range.start.line, 2);
assert.equal(first.additionalTextEdits[0].range.start.character, 20);
assert.equal(first.additionalTextEdits[0].range.end.line, 2);
assert.equal(first.additionalTextEdits[0].range.end.character, 20);
assert.equal(first.textEdit!.newText, '#ABC');
assert.equal(first.textEdit!.range.start.line, 1);
assert.equal(first.textEdit!.range.start.character, 0);
assert.equal(first.textEdit!.range.end.line, 1);
assert.equal(first.textEdit!.range.end.character, 20);
assert.equal(first.additionalTextEdits!.length, 1);
assert.equal(first.additionalTextEdits![0].range.start.line, 2);
assert.equal(first.additionalTextEdits![0].range.start.character, 20);
assert.equal(first.additionalTextEdits![0].range.end.line, 2);
assert.equal(first.additionalTextEdits![0].range.end.character, 20);
});
});
});
@@ -797,20 +795,20 @@ suite('ExtHostLanguageFeatureCommands', function () {
// --- selection ranges
test('Links, back and forth', async function () {
test('Selection Range, back and forth', async function () {
disposables.push(extHost.registerSelectionRangeProvider(nullExtensionDescription, defaultSelector, <vscode.SelectionRangeProvider>{
provideSelectionRanges() {
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)
new types.SelectionRange(new types.Range(0, 10, 0, 18), new types.SelectionRange(new types.Range(0, 2, 0, 20))),
];
}
}));
await rpcProtocol.sync();
let value = await commands.executeCommand<vscode.DocumentLink[]>('vscode.executeSelectionRangeProvider', model.uri, new types.Position(0, 10));
assert.ok(value.length >= 2);
let value = await commands.executeCommand<vscode.SelectionRange[][]>('vscode.executeSelectionRangeProvider', model.uri, [new types.Position(0, 10)]);
assert.equal(value.length, 1);
assert.ok(value[0].length >= 2);
});
});

View File

@@ -31,7 +31,7 @@ suite('ExtHostConfiguration', function () {
if (!shape) {
shape = new class extends mock<MainThreadConfigurationShape>() { };
}
return new ExtHostConfigProvider(shape, new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()), createConfigurationData(contents));
return new ExtHostConfigProvider(shape, new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter()), createConfigurationData(contents));
}
function createConfigurationData(contents: any): IConfigurationInitData {
@@ -56,7 +56,7 @@ suite('ExtHostConfiguration', function () {
assert.equal(extHostConfig.getConfiguration('search.exclude')['**/node_modules'], true);
assert.equal(extHostConfig.getConfiguration('search.exclude').get('**/node_modules'), true);
assert.equal(extHostConfig.getConfiguration('search').get('exclude')['**/node_modules'], true);
assert.equal(extHostConfig.getConfiguration('search').get('exclude')!['**/node_modules'], true);
assert.equal(extHostConfig.getConfiguration('search.exclude').has('**/node_modules'), true);
assert.equal(extHostConfig.getConfiguration('search').has('exclude.**/node_modules'), true);
@@ -111,38 +111,38 @@ suite('ExtHostConfiguration', function () {
});
let testObject = all.getConfiguration();
let actual = testObject.get('farboo');
let actual = testObject.get('farboo')!;
actual['nested']['config1'] = 41;
assert.equal(41, actual['nested']['config1']);
actual['farboo1'] = 'newValue';
assert.equal('newValue', actual['farboo1']);
testObject = all.getConfiguration();
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
assert.equal(actual['nested']['config1'], 42);
assert.equal(actual['farboo1'], undefined);
testObject = all.getConfiguration();
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
assert.equal(actual['config0'], true);
actual['config0'] = false;
assert.equal(actual['config0'], false);
testObject = all.getConfiguration();
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
assert.equal(actual['config0'], true);
testObject = all.getConfiguration();
actual = testObject.inspect('farboo');
actual = testObject.inspect('farboo')!;
actual['value'] = 'effectiveValue';
assert.equal('effectiveValue', actual['value']);
testObject = all.getConfiguration('workbench');
actual = testObject.get('colorCustomizations');
actual = testObject.get('colorCustomizations')!;
delete actual['statusBar.foreground'];
assert.equal(actual['statusBar.foreground'], undefined);
testObject = all.getConfiguration('workbench');
actual = testObject.get('colorCustomizations');
actual = testObject.get('colorCustomizations')!;
assert.equal(actual['statusBar.foreground'], 'somevalue');
});
@@ -166,8 +166,8 @@ suite('ExtHostConfiguration', function () {
}
});
let testObject = all.getConfiguration();
let actual = testObject.get('farboo');
const testObject = all.getConfiguration();
let actual: any = testObject.get('farboo');
assert.deepEqual(JSON.stringify({
'config0': true,
'nested': {
@@ -179,7 +179,7 @@ suite('ExtHostConfiguration', function () {
assert.deepEqual(undefined, JSON.stringify(testObject.get('unknownkey')));
actual = testObject.get('farboo');
actual = testObject.get('farboo')!;
actual['config0'] = false;
assert.deepEqual(JSON.stringify({
'config0': false,
@@ -190,7 +190,7 @@ suite('ExtHostConfiguration', function () {
'config4': ''
}), JSON.stringify(actual));
actual = testObject.get('workbench')['colorCustomizations'];
actual = testObject.get('workbench')!['colorCustomizations']!;
actual['statusBar.background'] = 'anothervalue';
assert.deepEqual(JSON.stringify({
'statusBar.foreground': 'somevalue',
@@ -241,7 +241,7 @@ suite('ExtHostConfiguration', function () {
}
});
let testObject = all.getConfiguration();
let testObject: any = all.getConfiguration();
try {
testObject['get'] = null;
@@ -265,7 +265,7 @@ suite('ExtHostConfiguration', function () {
test('inspect in no workspace context', function () {
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()),
new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter()),
{
defaults: new ConfigurationModel({
'editor': {
@@ -284,13 +284,13 @@ suite('ExtHostConfiguration', function () {
}
);
let actual = testObject.getConfiguration().inspect('editor.wordWrap');
let actual = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'on');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, undefined);
actual = testObject.getConfiguration('editor').inspect('wordWrap');
actual = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'on');
assert.equal(actual.workspaceValue, undefined);
@@ -306,13 +306,15 @@ suite('ExtHostConfiguration', function () {
}
}, ['editor.wordWrap']);
folders[workspaceUri.toString()] = workspace;
const extHostWorkspace = new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter());
extHostWorkspace.$initializeWorkspace({
'id': 'foo',
'folders': [aWorkspaceFolder(URI.file('foo'), 0)],
'name': 'foo'
});
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), {
'id': 'foo',
'folders': [aWorkspaceFolder(URI.file('foo'), 0)],
'name': 'foo'
}, new NullLogService(), new Counter()),
extHostWorkspace,
{
defaults: new ConfigurationModel({
'editor': {
@@ -331,25 +333,25 @@ suite('ExtHostConfiguration', function () {
}
);
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap');
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
actual1 = testObject.getConfiguration('editor').inspect('wordWrap');
actual1 = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
let actual2 = testObject.getConfiguration(null, workspaceUri).inspect('editor.wordWrap');
let actual2 = testObject.getConfiguration(undefined, workspaceUri).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'bounded');
actual2 = testObject.getConfiguration('editor', workspaceUri).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', workspaceUri).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
@@ -380,13 +382,15 @@ suite('ExtHostConfiguration', function () {
}, ['editor.wordWrap']);
folders[thirdRoot.toString()] = new ConfigurationModel({}, []);
const extHostWorkspace = new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter());
extHostWorkspace.$initializeWorkspace({
'id': 'foo',
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
'name': 'foo'
});
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), {
'id': 'foo',
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
'name': 'foo'
}, new NullLogService(), new Counter()),
extHostWorkspace,
{
defaults: new ConfigurationModel({
'editor': {
@@ -406,62 +410,62 @@ suite('ExtHostConfiguration', function () {
}
);
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap');
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
actual1 = testObject.getConfiguration('editor').inspect('wordWrap');
actual1 = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
actual1 = testObject.getConfiguration('editor').inspect('lineNumbers');
actual1 = testObject.getConfiguration('editor').inspect('lineNumbers')!;
assert.equal(actual1.defaultValue, 'on');
assert.equal(actual1.globalValue, undefined);
assert.equal(actual1.workspaceValue, undefined);
assert.equal(actual1.workspaceFolderValue, undefined);
let actual2 = testObject.getConfiguration(null, firstRoot).inspect('editor.wordWrap');
let actual2 = testObject.getConfiguration(undefined, firstRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'off');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'off');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('lineNumbers');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('lineNumbers')!;
assert.equal(actual2.defaultValue, 'on');
assert.equal(actual2.globalValue, undefined);
assert.equal(actual2.workspaceValue, undefined);
assert.equal(actual2.workspaceFolderValue, 'relative');
actual2 = testObject.getConfiguration(null, secondRoot).inspect('editor.wordWrap');
actual2 = testObject.getConfiguration(undefined, secondRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'on');
actual2 = testObject.getConfiguration('editor', secondRoot).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', secondRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'on');
actual2 = testObject.getConfiguration(null, thirdRoot).inspect('editor.wordWrap');
actual2 = testObject.getConfiguration(undefined, thirdRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.ok(Object.keys(actual2).indexOf('workspaceFolderValue') !== -1);
assert.equal(actual2.workspaceFolderValue, undefined);
actual2 = testObject.getConfiguration('editor', thirdRoot).inspect('wordWrap');
actual2 = testObject.getConfiguration('editor', thirdRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
@@ -589,13 +593,15 @@ suite('ExtHostConfiguration', function () {
test('configuration change event', (done) => {
const workspaceFolder = aWorkspaceFolder(URI.file('folder1'), 0);
const extHostWorkspace = new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter());
extHostWorkspace.$initializeWorkspace({
'id': 'foo',
'folders': [workspaceFolder],
'name': 'foo'
});
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
new ExtHostWorkspace(new TestRPCProtocol(), {
'id': 'foo',
'folders': [workspaceFolder],
'name': 'foo'
}, new NullLogService(), new Counter()),
extHostWorkspace,
createConfigurationData({
'farboo': {
'config': false,

View File

@@ -188,7 +188,7 @@ suite('ExtHostDiagnostics', () => {
lastEntries = undefined!;
});
test('don\'t send message when not making a change', function () {
test('do send message when not making a change', function () {
let changeCount = 0;
let eventCount = 0;
@@ -209,7 +209,7 @@ suite('ExtHostDiagnostics', () => {
assert.equal(eventCount, 1);
collection.set(uri, [diag]);
assert.equal(changeCount, 1);
assert.equal(changeCount, 2);
assert.equal(eventCount, 2);
});
@@ -418,10 +418,10 @@ suite('ExtHostDiagnostics', () => {
assert.equal(callCount, 1);
collection.set(URI.parse('test:me'), array);
assert.equal(callCount, 1); // equal array
assert.equal(callCount, 2); // equal array
array.push(diag2);
collection.set(URI.parse('test:me'), array);
assert.equal(callCount, 2); // same but un-equal array
assert.equal(callCount, 3); // same but un-equal array
});
});

View File

@@ -13,11 +13,10 @@ import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import * as vscode from 'vscode';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
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';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
suite('ExtHostDocumentSaveParticipant', () => {
@@ -341,7 +340,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
rangeLength: undefined!,
}],
eol: undefined!,
versionId: documents.getDocumentData(uri).version + 1
versionId: documents.getDocumentData(uri)!.version + 1
}, true);
}
}
@@ -350,7 +349,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
}
});
const document = documents.getDocumentData(resource).document;
const document = documents.getDocument(resource);
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// the document state we started with

View File

@@ -29,11 +29,11 @@ import { getHover } from 'vs/editor/contrib/hover/getHover';
import { getOccurrencesAtPosition } from 'vs/editor/contrib/wordHighlighter/wordHighlighter';
import { provideReferences } from 'vs/editor/contrib/referenceSearch/referenceSearch';
import { getCodeActions } from 'vs/editor/contrib/codeAction/codeAction';
import { getWorkspaceSymbols } from 'vs/workbench/parts/search/common/search';
import { getWorkspaceSymbols } from 'vs/workbench/contrib/search/common/search';
import { rename } from 'vs/editor/contrib/rename/rename';
import { provideSignatureHelp } from 'vs/editor/contrib/parameterHints/provideSignatureHelp';
import { provideSuggestionItems } from 'vs/editor/contrib/suggest/suggest';
import { getDocumentFormattingEdits, getDocumentRangeFormattingEdits, getOnTypeFormattingEdits } from 'vs/editor/contrib/format/format';
import { provideSuggestionItems, CompletionOptions } from 'vs/editor/contrib/suggest/suggest';
import { getDocumentFormattingEdits, getDocumentRangeFormattingEdits, getOnTypeFormattingEdits, FormatMode } from 'vs/editor/contrib/format/format';
import { getLinks } from 'vs/editor/contrib/links/getLinks';
import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
@@ -46,6 +46,10 @@ import { getColors } from 'vs/editor/contrib/colorPicker/color';
import { CancellationToken } from 'vs/base/common/cancellation';
import { nullExtensionDescription as defaultExtension } from 'vs/workbench/services/extensions/common/extensions';
import { provideSelectionRanges } from 'vs/editor/contrib/smartSelect/smartSelect';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { dispose } from 'vs/base/common/lifecycle';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = EditorModel.createFromString(
@@ -64,6 +68,8 @@ let disposables: vscode.Disposable[] = [];
let rpcProtocol: TestRPCProtocol;
let originalErrorHandler: (e: any) => any;
suite('ExtHostLanguageFeatures', function () {
suiteSetup(() => {
@@ -77,9 +83,8 @@ suite('ExtHostLanguageFeatures', function () {
instantiationService.stub(IMarkerService, MarkerService);
instantiationService.stub(IHeapService, {
_serviceBrand: undefined,
trackRecursive(args: any) {
trackObject(_obj: any) {
// nothing
return args;
}
});
inst = instantiationService;
@@ -123,10 +128,8 @@ suite('ExtHostLanguageFeatures', function () {
mainThread.dispose();
});
teardown(function () {
while (disposables.length) {
disposables.pop().dispose();
}
teardown(() => {
disposables = dispose(disposables);
return rpcProtocol.sync();
});
@@ -215,10 +218,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getCodeLensData(model, CancellationToken.None);
assert.equal(value.length, 1);
let data = value[0];
const symbol = await Promise.resolve(data.provider.resolveCodeLens(model, data.symbol, CancellationToken.None));
assert.equal(symbol.command.id, 'id');
assert.equal(symbol.command.title, 'Title');
const data = value[0];
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
assert.equal(symbol!.command!.id, 'id');
assert.equal(symbol!.command!.title, 'Title');
});
test('CodeLens, missing command', async () => {
@@ -233,9 +236,9 @@ suite('ExtHostLanguageFeatures', function () {
const value = await getCodeLensData(model, CancellationToken.None);
assert.equal(value.length, 1);
let data = value[0];
const symbol = await Promise.resolve(data.provider.resolveCodeLens(model, data.symbol, CancellationToken.None));
assert.equal(symbol.command.id, 'missing');
assert.equal(symbol.command.title, '!!MISSING: command!!');
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
assert.equal(symbol!.command!.id, 'missing');
assert.equal(symbol!.command!.title, '!!MISSING: command!!');
});
// --- definition
@@ -457,9 +460,9 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
let [entry] = value;
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
});
@@ -478,9 +481,9 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
let [entry] = value;
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
});
@@ -499,9 +502,9 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
let [entry] = value;
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 3 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
});
@@ -522,7 +525,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
assert.equal(value.length, 1);
assert.equal(value!.length, 1);
});
// --- references
@@ -597,13 +600,13 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(value.length, 2);
const [first, second] = value;
const { actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(actions.length, 2);
const [first, second] = actions;
assert.equal(first.title, 'Testing1');
assert.equal(first.command.id, 'test1');
assert.equal(first.command!.id, 'test1');
assert.equal(second.title, 'Testing2');
assert.equal(second.command.id, 'test2');
assert.equal(second.command!.id, 'test2');
});
test('Quick Fix, code action data conversion', async () => {
@@ -621,12 +624,12 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(value.length, 1);
const [first] = value;
const { actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(actions.length, 1);
const [first] = actions;
assert.equal(first.title, 'Testing1');
assert.equal(first.command.title, 'Testing1Command');
assert.equal(first.command.id, 'test1');
assert.equal(first.command!.title, 'Testing1Command');
assert.equal(first.command!.id, 'test1');
assert.equal(first.kind, 'test.scope');
});
@@ -644,8 +647,8 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
const value = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(value.length, 1);
const { actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(actions.length, 1);
});
test('Quick Fix, evil provider', async () => {
@@ -662,8 +665,8 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
const value = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(value.length, 1);
const { actions } = await getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None);
assert.equal(actions.length, 1);
});
// --- navigate types
@@ -825,7 +828,7 @@ suite('ExtHostLanguageFeatures', function () {
}, []));
await rpcProtocol.sync();
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none');
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(value.length, 1);
assert.equal(value[0].completion.insertText, 'testing2');
});
@@ -845,7 +848,7 @@ suite('ExtHostLanguageFeatures', function () {
}, []));
await rpcProtocol.sync();
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none');
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(value.length, 1);
assert.equal(value[0].completion.insertText, 'weak-selector');
});
@@ -865,7 +868,7 @@ suite('ExtHostLanguageFeatures', function () {
}, []));
await rpcProtocol.sync();
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none');
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(value.length, 2);
assert.equal(value[0].completion.insertText, 'strong-1'); // sort by label
assert.equal(value[1].completion.insertText, 'strong-2');
@@ -887,7 +890,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none');
const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(value[0].container.incomplete, undefined);
});
@@ -900,13 +903,19 @@ suite('ExtHostLanguageFeatures', function () {
}, []));
await rpcProtocol.sync();
provideSuggestionItems(model, new EditorPosition(1, 1), 'none').then(value => {
provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet))).then(value => {
assert.equal(value[0].container.incomplete, true);
});
});
// --- format
const NullWorkerService = new class extends mock<IEditorWorkerService>() {
computeMoreMinimalEdits(resource: URI, edits: modes.TextEdit[] | null | undefined): Promise<modes.TextEdit[] | null | undefined> {
return Promise.resolve(edits);
}
};
test('Format Doc, data conversion', async () => {
disposables.push(extHost.registerDocumentFormattingEditProvider(defaultExtension, defaultSelector, new class implements vscode.DocumentFormattingEditProvider {
provideDocumentFormattingEdits(): any {
@@ -915,7 +924,7 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getDocumentFormattingEdits(model, { insertSpaces: true, tabSize: 4 }, CancellationToken.None);
let value = (await getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 2);
let [first, second] = value;
assert.equal(first.text, 'testing');
@@ -933,7 +942,7 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
return getDocumentFormattingEdits(model, { insertSpaces: true, tabSize: 4 }, CancellationToken.None);
return getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None);
});
test('Format Doc, order', async () => {
@@ -957,7 +966,7 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getDocumentFormattingEdits(model, { insertSpaces: true, tabSize: 4 }, CancellationToken.None);
let value = (await getDocumentFormattingEdits(NullTelemetryService, NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 1);
let [first] = value;
assert.equal(first.text, 'testing');
@@ -972,9 +981,9 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
let value = await getDocumentRangeFormattingEdits(model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, CancellationToken.None);
const value = (await getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.text, 'testing');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
@@ -996,9 +1005,9 @@ suite('ExtHostLanguageFeatures', function () {
}
}));
await rpcProtocol.sync();
let value = await getDocumentRangeFormattingEdits(model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, CancellationToken.None);
const value = (await getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None))!;
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.text, 'range2');
assert.equal(first.range.startLineNumber, 3);
assert.equal(first.range.startColumn, 4);
@@ -1014,7 +1023,7 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
return getDocumentRangeFormattingEdits(model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, CancellationToken.None);
return getDocumentRangeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, FormatMode.Auto, CancellationToken.None);
});
test('Format on Type, data conversion', async () => {
@@ -1026,9 +1035,9 @@ suite('ExtHostLanguageFeatures', function () {
}, [';']));
await rpcProtocol.sync();
let value = await getOnTypeFormattingEdits(model, new EditorPosition(1, 1), ';', { insertSpaces: true, tabSize: 2 });
const value = (await getOnTypeFormattingEdits(NullTelemetryService, NullWorkerService, model, new EditorPosition(1, 1), ';', { insertSpaces: true, tabSize: 2 }))!;
assert.equal(value.length, 1);
let [first] = value;
const [first] = value;
assert.equal(first.text, ';');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
@@ -1096,16 +1105,29 @@ suite('ExtHostLanguageFeatures', function () {
disposables.push(extHost.registerSelectionRangeProvider(defaultExtension, defaultSelector, new class implements vscode.SelectionRangeProvider {
provideSelectionRanges() {
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)
new types.SelectionRange(new types.Range(0, 10, 0, 18), new types.SelectionRange(new types.Range(0, 2, 0, 20))),
];
}
}));
await rpcProtocol.sync();
provideSelectionRanges(model, new Position(1, 17), CancellationToken.None).then(ranges => {
assert.ok(ranges.length >= 2);
provideSelectionRanges(model, [new Position(1, 17)], CancellationToken.None).then(ranges => {
assert.equal(ranges.length, 1);
assert.ok(ranges[0].length >= 2);
});
});
test('Selection Ranges, bad data', async () => {
try {
let _a = new types.SelectionRange(new types.Range(0, 10, 0, 18),
new types.SelectionRange(new types.Range(0, 11, 0, 18))
);
assert.ok(false, String(_a));
} catch (err) {
assert.ok(true);
}
});
});

View File

@@ -10,7 +10,7 @@ import { dispose } from 'vs/base/common/lifecycle';
import { joinPath } from 'vs/base/common/resources';
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 { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/workbench/services/search/common/search';
import { MainContext, MainThreadSearchShape } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostSearch } from 'vs/workbench/api/node/extHostSearch';
import { Range } from 'vs/workbench/api/node/extHostTypes';
@@ -33,10 +33,6 @@ class MockMainThreadSearch implements MainThreadSearchShape {
this.lastHandle = handle;
}
$registerFileIndexProvider(handle: number, scheme: string): void {
this.lastHandle = handle;
}
$registerTextSearchProvider(handle: number, scheme: string): void {
this.lastHandle = handle;
}

View File

@@ -19,7 +19,7 @@ suite('ExtHostTextEditor', () => {
], '\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, indentSize: 4 }, [], 1);
});
test('disposed editor', () => {
@@ -45,7 +45,7 @@ suite('ExtHostTextEditor', () => {
applyCount += 1;
return Promise.resolve(true);
}
}, 'edt1', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
}, 'edt1', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4, indentSize: 4 }, [], 1);
await editor.edit(edit => { });
assert.equal(applyCount, 0);
@@ -88,6 +88,7 @@ suite('ExtHostTextEditorOptions', () => {
};
opts = new ExtHostTextEditorOptions(mockProxy, '1', {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -102,6 +103,7 @@ suite('ExtHostTextEditorOptions', () => {
function assertState(opts: ExtHostTextEditorOptions, expected: IResolvedTextEditorConfiguration): void {
let actual = {
tabSize: opts.tabSize,
indentSize: opts.indentSize,
insertSpaces: opts.insertSpaces,
cursorStyle: opts.cursorStyle,
lineNumbers: opts.lineNumbers
@@ -113,6 +115,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = 4;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -124,6 +127,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = 1;
assertState(opts, {
tabSize: 1,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -135,6 +139,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = 2.3;
assertState(opts, {
tabSize: 2,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -146,6 +151,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = '2';
assertState(opts, {
tabSize: 2,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -157,6 +163,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = 'auto';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -168,6 +175,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = null!;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -179,6 +187,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = -5;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -190,6 +199,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = 'hello';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -201,6 +211,127 @@ suite('ExtHostTextEditorOptions', () => {
opts.tabSize = '-17';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, []);
});
test('can set indentSize to the same value', () => {
opts.indentSize = 4;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, []);
});
test('can change indentSize to positive integer', () => {
opts.indentSize = 1;
assertState(opts, {
tabSize: 4,
indentSize: 1,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, [{ indentSize: 1 }]);
});
test('can change indentSize to positive float', () => {
opts.indentSize = 2.3;
assertState(opts, {
tabSize: 4,
indentSize: 2,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, [{ indentSize: 2 }]);
});
test('can change indentSize to a string number', () => {
opts.indentSize = '2';
assertState(opts, {
tabSize: 4,
indentSize: 2,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, [{ indentSize: 2 }]);
});
test('indentSize can request to use tabSize', () => {
opts.indentSize = 'tabSize';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, [{ indentSize: 'tabSize' }]);
});
test('indentSize cannot request indentation detection', () => {
opts.indentSize = 'auto';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 1', () => {
opts.indentSize = null!;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 2', () => {
opts.indentSize = -5;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 3', () => {
opts.indentSize = 'hello';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 4', () => {
opts.indentSize = '-17';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -212,6 +343,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.insertSpaces = false;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -223,6 +355,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.insertSpaces = true;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -234,6 +367,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.insertSpaces = 'false';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -245,6 +379,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.insertSpaces = 'hello';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -256,6 +391,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.insertSpaces = 'auto';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -267,6 +403,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.cursorStyle = TextEditorCursorStyle.Line;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -278,6 +415,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.cursorStyle = TextEditorCursorStyle.Block;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Block,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -289,6 +427,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.lineNumbers = TextEditorLineNumbersStyle.On;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -300,6 +439,7 @@ suite('ExtHostTextEditorOptions', () => {
opts.lineNumbers = TextEditorLineNumbersStyle.Off;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.Off
@@ -316,6 +456,7 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -330,6 +471,7 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -344,6 +486,7 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 3,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: TextEditorLineNumbersStyle.On
@@ -358,6 +501,7 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Block,
lineNumbers: TextEditorLineNumbersStyle.Relative

View File

@@ -18,7 +18,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { TreeItemCollapsibleState, ITreeItem } from 'vs/workbench/common/views';
import { NullLogService } from 'vs/platform/log/common/log';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
suite('ExtHostTreeView', function () {
@@ -29,12 +29,12 @@ suite('ExtHostTreeView', function () {
$registerTreeViewDataProvider(treeViewId: string): void {
}
$refresh(viewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem }): Promise<void> {
$refresh(viewId: string, itemsToRefresh: { [treeItemHandle: string]: ITreeItem }): Promise<void> {
return Promise.resolve(null).then(() => this.onRefresh.fire(itemsToRefresh));
}
$reveal(): Promise<void> {
return null;
return Promise.resolve();
}
}
@@ -625,7 +625,7 @@ suite('ExtHostTreeView', function () {
getTreeItem: (element: { key: string }): TreeItem => {
return getTreeItem(element.key);
},
getParent: ({ key }: { key: string }): { key: string } => {
getParent: ({ key }: { key: string }): { key: string } | undefined => {
const parentKey = key.substring(0, key.length - 1);
return parentKey ? new Key(parentKey) : undefined;
},
@@ -672,7 +672,7 @@ suite('ExtHostTreeView', function () {
return parent;
}
function getChildren(key: string): string[] {
function getChildren(key: string | undefined): string[] {
if (!key) {
return Object.keys(tree);
}

View File

@@ -4,17 +4,25 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { basename } from 'path';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { TestRPCProtocol } from './testRPCProtocol';
import { normalize } from 'vs/base/common/paths';
import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { NullLogService } from 'vs/platform/log/common/log';
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Counter } from 'vs/base/common/numbers';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { basename } from 'vs/base/common/path';
import { URI, UriComponents } from 'vs/base/common/uri';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace';
import { MainThreadWorkspace } from 'vs/workbench/api/electron-browser/mainThreadWorkspace';
import { IMainContext, IWorkspaceData, MainContext } from 'vs/workbench/api/node/extHost.protocol';
import { RelativePattern } from 'vs/workbench/api/node/extHostTypes';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { TestRPCProtocol } from './testRPCProtocol';
function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, logService: ILogService, requestIdProvider: Counter): ExtHostWorkspace {
const result = new ExtHostWorkspace(mainContext, logService, requestIdProvider);
result.$initializeWorkspace(data);
return result;
}
suite('ExtHostWorkspace', function () {
@@ -32,16 +40,12 @@ suite('ExtHostWorkspace', function () {
function assertAsRelativePath(workspace: ExtHostWorkspace, input: string, expected: string, includeWorkspace?: boolean) {
const actual = workspace.getRelativePath(input, includeWorkspace);
if (actual === expected) {
assert.ok(true);
} else {
assert.equal(actual, normalize(expected, true));
}
assert.equal(actual, expected);
}
test('asRelativePath', () => {
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/Applications/NewsWoWBot'), 0)], name: 'Test' }, new NullLogService(), new Counter());
const ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/Applications/NewsWoWBot'), 0)], name: 'Test' }, new NullLogService(), new Counter());
assertAsRelativePath(ws, '/Coding/Applications/NewsWoWBot/bernd/das/brot', 'bernd/das/brot');
assertAsRelativePath(ws, '/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart',
@@ -55,29 +59,29 @@ suite('ExtHostWorkspace', function () {
test('asRelativePath, same paths, #11402', function () {
const root = '/home/aeschli/workspaces/samples/docker';
const input = '/home/aeschli/workspaces/samples/docker';
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
const ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
assertAsRelativePath(ws, (input), input);
assertAsRelativePath(ws, input, input);
const input2 = '/home/aeschli/workspaces/samples/docker/a.file';
assertAsRelativePath(ws, (input2), 'a.file');
assertAsRelativePath(ws, input2, 'a.file');
});
test('asRelativePath, no workspace', function () {
const ws = new ExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
assertAsRelativePath(ws, (''), '');
assertAsRelativePath(ws, ('/foo/bar'), '/foo/bar');
const ws = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
assertAsRelativePath(ws, '', '');
assertAsRelativePath(ws, '/foo/bar', '/foo/bar');
});
test('asRelativePath, multiple folders', function () {
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService(), new Counter());
const ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService(), new Counter());
assertAsRelativePath(ws, '/Coding/One/file.txt', 'One/file.txt');
assertAsRelativePath(ws, '/Coding/Two/files/out.txt', 'Two/files/out.txt');
assertAsRelativePath(ws, '/Coding/Two2/files/out.txt', '/Coding/Two2/files/out.txt');
});
test('slightly inconsistent behaviour of asRelativePath and getWorkspaceFolder, #31553', function () {
const mrws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService(), new Counter());
const mrws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService(), new Counter());
assertAsRelativePath(mrws, '/Coding/One/file.txt', 'One/file.txt');
assertAsRelativePath(mrws, '/Coding/One/file.txt', 'One/file.txt', true);
@@ -89,7 +93,7 @@ suite('ExtHostWorkspace', function () {
assertAsRelativePath(mrws, '/Coding/Two2/files/out.txt', '/Coding/Two2/files/out.txt', true);
assertAsRelativePath(mrws, '/Coding/Two2/files/out.txt', '/Coding/Two2/files/out.txt', false);
const srws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0)], name: 'Test' }, new NullLogService(), new Counter());
const srws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0)], name: 'Test' }, new NullLogService(), new Counter());
assertAsRelativePath(srws, '/Coding/One/file.txt', 'file.txt');
assertAsRelativePath(srws, '/Coding/One/file.txt', 'file.txt', false);
assertAsRelativePath(srws, '/Coding/One/file.txt', 'One/file.txt', true);
@@ -99,26 +103,26 @@ suite('ExtHostWorkspace', function () {
});
test('getPath, legacy', function () {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
let ws = createExtHostWorkspace(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 = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
assert.equal(ws.getPath(), undefined);
ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined!, new NullLogService(), new Counter());
ws = createExtHostWorkspace(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());
assert.equal(ws.getPath().replace(/\\/g, '/'), '/Folder');
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService(), new Counter());
assert.equal(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('/Folder'), 0)] }, new NullLogService(), new Counter());
assert.equal(ws.getPath().replace(/\\/g, '/'), '/Folder');
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('/Folder'), 0)] }, new NullLogService(), new Counter());
assert.equal(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
});
test('WorkspaceFolder has name and index', function () {
const ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService(), new Counter());
const ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService(), new Counter());
const [one, two] = ws.getWorkspaceFolders();
const [one, two] = ws.getWorkspaceFolders()!;
assert.equal(one.name, 'One');
assert.equal(one.index, 0);
@@ -127,7 +131,7 @@ suite('ExtHostWorkspace', function () {
});
test('getContainingWorkspaceFolder', () => {
const ws = new ExtHostWorkspace(new TestRPCProtocol(), {
const ws = createExtHostWorkspace(new TestRPCProtocol(), {
id: 'foo',
name: 'Test',
folders: [
@@ -140,42 +144,42 @@ suite('ExtHostWorkspace', function () {
let folder = ws.getWorkspaceFolder(URI.file('/foo/bar'));
assert.equal(folder, undefined);
folder = ws.getWorkspaceFolder(URI.file('/Coding/One/file/path.txt'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/One/file/path.txt'))!;
assert.equal(folder.name, 'One');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/file/path.txt'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/file/path.txt'))!;
assert.equal(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nest'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nest'))!;
assert.equal(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/file'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/file'))!;
assert.equal(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/f'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/f'))!;
assert.equal(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested'), true);
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested'), true)!;
assert.equal(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/'), true);
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/'), true)!;
assert.equal(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested'))!;
assert.equal(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/'));
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/'))!;
assert.equal(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two'), true);
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two'), true)!;
assert.equal(folder, undefined);
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two'), false);
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two'), false)!;
assert.equal(folder.name, 'Two');
});
test('Multiroot change event should have a delta, #29641', function (done) {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
let finished = false;
const finish = (error?: any) => {
@@ -238,27 +242,27 @@ suite('ExtHostWorkspace', function () {
});
test('Multiroot change keeps existing workspaces live', function () {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService(), new Counter());
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService(), new Counter());
let firstFolder = ws.getWorkspaceFolders()[0];
let firstFolder = ws.getWorkspaceFolders()![0];
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar2'), 0), aWorkspaceFolderData(URI.parse('foo:bar'), 1, 'renamed')] });
assert.equal(ws.getWorkspaceFolders()[1], firstFolder);
assert.equal(ws.getWorkspaceFolders()![1], firstFolder);
assert.equal(firstFolder.index, 1);
assert.equal(firstFolder.name, 'renamed');
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar2'), 1), aWorkspaceFolderData(URI.parse('foo:bar'), 2)] });
assert.equal(ws.getWorkspaceFolders()[2], firstFolder);
assert.equal(ws.getWorkspaceFolders()![2], firstFolder);
assert.equal(firstFolder.index, 2);
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0)] });
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar'), 1)] });
assert.notEqual(firstFolder, ws.workspace.folders[0]);
assert.notEqual(firstFolder, ws.workspace!.folders[0]);
});
test('updateWorkspaceFolders - invalid arguments', function () {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
let ws = createExtHostWorkspace(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, 0, 0));
@@ -267,7 +271,7 @@ suite('ExtHostWorkspace', function () {
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, 0));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, -1));
ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService(), new Counter());
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService(), new Counter());
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 1));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2));
@@ -289,17 +293,17 @@ suite('ExtHostWorkspace', function () {
assertRegistered: undefined!
};
const ws = new ExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
const ws = createExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
//
// Add one folder
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar'))));
assert.equal(1, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(1, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
const firstAddedFolder = ws.getWorkspaceFolders()[0];
const firstAddedFolder = ws.getWorkspaceFolders()![0];
let gotEvent = false;
let sub = ws.onDidChangeWorkspace(e => {
@@ -316,20 +320,20 @@ suite('ExtHostWorkspace', function () {
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
//
// Add two more folders
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar1')), asUpdateWorkspaceFolderData(URI.parse('foo:bar2'))));
assert.equal(3, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(ws.workspace.folders[2].uri.toString(), URI.parse('foo:bar2').toString());
assert.equal(3, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(ws.workspace!.folders[2].uri.toString(), URI.parse('foo:bar2').toString());
const secondAddedFolder = ws.getWorkspaceFolders()[1];
const thirdAddedFolder = ws.getWorkspaceFolders()[2];
const secondAddedFolder = ws.getWorkspaceFolders()![1];
const thirdAddedFolder = ws.getWorkspaceFolders()![2];
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
@@ -348,18 +352,18 @@ suite('ExtHostWorkspace', function () {
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0), aWorkspaceFolderData(URI.parse('foo:bar1'), 1), aWorkspaceFolderData(URI.parse('foo:bar2'), 2)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], secondAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[2], thirdAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![2], thirdAddedFolder); // verify object is still live
//
// Remove one folder
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 2, 1));
assert.equal(2, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
@@ -375,21 +379,21 @@ suite('ExtHostWorkspace', function () {
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0), aWorkspaceFolderData(URI.parse('foo:bar1'), 1)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], secondAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
//
// Rename folder
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar'), 'renamed 1'), asUpdateWorkspaceFolderData(URI.parse('foo:bar1'), 'renamed 2')));
assert.equal(2, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(ws.workspace.folders[0].name, 'renamed 1');
assert.equal(ws.workspace.folders[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()[0].name, 'renamed 1');
assert.equal(ws.getWorkspaceFolders()[1].name, 'renamed 2');
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(ws.workspace!.folders[0].name, 'renamed 1');
assert.equal(ws.workspace!.folders[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()![0].name, 'renamed 1');
assert.equal(ws.getWorkspaceFolders()![1].name, 'renamed 2');
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
@@ -404,24 +408,24 @@ suite('ExtHostWorkspace', function () {
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0, 'renamed 1'), aWorkspaceFolderData(URI.parse('foo:bar1'), 1, 'renamed 2')] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], secondAddedFolder); // verify object is still live
assert.equal(ws.workspace.folders[0].name, 'renamed 1');
assert.equal(ws.workspace.folders[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()[0].name, 'renamed 1');
assert.equal(ws.getWorkspaceFolders()[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.equal(ws.workspace!.folders[0].name, 'renamed 1');
assert.equal(ws.workspace!.folders[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()![0].name, 'renamed 1');
assert.equal(ws.getWorkspaceFolders()![1].name, 'renamed 2');
//
// Add and remove folders
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar3')), asUpdateWorkspaceFolderData(URI.parse('foo:bar4'))));
assert.equal(2, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.workspace.folders[1].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar4').toString());
const fourthAddedFolder = ws.getWorkspaceFolders()[0];
const fifthAddedFolder = ws.getWorkspaceFolders()[1];
const fourthAddedFolder = ws.getWorkspaceFolders()![0];
const fifthAddedFolder = ws.getWorkspaceFolders()![1];
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
@@ -440,20 +444,20 @@ suite('ExtHostWorkspace', function () {
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar4'), 1)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fifthAddedFolder); // verify object is still live
//
// Swap folders
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar4')), asUpdateWorkspaceFolderData(URI.parse('foo:bar3'))));
assert.equal(2, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(ws.workspace.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.getWorkspaceFolders()[0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
@@ -468,8 +472,8 @@ suite('ExtHostWorkspace', function () {
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar4'), 0), aWorkspaceFolderData(URI.parse('foo:bar3'), 1)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.equal(fifthAddedFolder.index, 0);
assert.equal(fourthAddedFolder.index, 1);
@@ -479,12 +483,12 @@ suite('ExtHostWorkspace', function () {
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 2, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar5'))));
assert.equal(3, ws.workspace.folders.length);
assert.equal(ws.workspace.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(ws.workspace.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.workspace.folders[2].uri.toString(), URI.parse('foo:bar5').toString());
assert.equal(3, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.workspace!.folders[2].uri.toString(), URI.parse('foo:bar5').toString());
const sixthAddedFolder = ws.getWorkspaceFolders()[2];
const sixthAddedFolder = ws.getWorkspaceFolders()![2];
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
@@ -506,17 +510,42 @@ suite('ExtHostWorkspace', function () {
assert.equal(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()[0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[1], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()[2], sixthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![2], sixthAddedFolder); // verify object is still live
finish();
});
// {{SQL CARBON EDIT}} remove broken test
test('Multiroot change event is immutable', function (done) {
let finished = false;
const finish = (error?: any) => {
if (!finished) {
finished = true;
done(error);
}
};
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
let sub = ws.onDidChangeWorkspace(e => {
try {
assert.throws(() => {
(<any>e).added = [];
});
// assert.throws(() => {
// (<any>e.added)[0] = null;
// });
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [] });
sub.dispose();
finish();
});
test('`vscode.workspace.getWorkspaceFolder(file)` don\'t return workspace folder when file open from command line. #36221', function () {
let ws = new ExtHostWorkspace(new TestRPCProtocol(), {
let ws = createExtHostWorkspace(new TestRPCProtocol(), {
id: 'foo', name: 'Test', folders: [
aWorkspaceFolderData(URI.file('c:/Users/marek/Desktop/vsc_test/'), 0)
]
@@ -537,4 +566,107 @@ suite('ExtHostWorkspace', function () {
function asUpdateWorkspaceFolderData(uri: URI, name?: string): { uri: URI, name?: string } {
return { uri, name };
}
test('findFiles - string include', () => {
const root = '/project/foo';
const rpcProtocol = new TestRPCProtocol();
let mainThreadCalled = false;
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
mainThreadCalled = true;
assert.equal(includePattern, 'foo');
assert.equal(_includeFolder, undefined);
assert.equal(excludePatternOrDisregardExcludes, undefined);
assert.equal(maxResults, 10);
return Promise.resolve(undefined);
}
});
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
return ws.findFiles('foo', undefined!, 10, new ExtensionIdentifier('test')).then(() => {
assert(mainThreadCalled, 'mainThreadCalled');
});
});
test('findFiles - RelativePattern include', () => {
const root = '/project/foo';
const rpcProtocol = new TestRPCProtocol();
let mainThreadCalled = false;
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
mainThreadCalled = true;
assert.equal(includePattern, 'glob/**');
assert.deepEqual(_includeFolder, URI.file('/other/folder').toJSON());
assert.equal(excludePatternOrDisregardExcludes, undefined);
return Promise.resolve(undefined);
}
});
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), undefined!, 10, new ExtensionIdentifier('test')).then(() => {
assert(mainThreadCalled, 'mainThreadCalled');
});
});
test('findFiles - no excludes', () => {
const root = '/project/foo';
const rpcProtocol = new TestRPCProtocol();
let mainThreadCalled = false;
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
mainThreadCalled = true;
assert.equal(includePattern, 'glob/**');
assert.deepEqual(_includeFolder, URI.file('/other/folder').toJSON());
assert.equal(excludePatternOrDisregardExcludes, false);
return Promise.resolve(undefined);
}
});
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), null!, 10, new ExtensionIdentifier('test')).then(() => {
assert(mainThreadCalled, 'mainThreadCalled');
});
});
test('findFiles - with cancelled token', () => {
const root = '/project/foo';
const rpcProtocol = new TestRPCProtocol();
let mainThreadCalled = false;
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
mainThreadCalled = true;
return Promise.resolve(undefined);
}
});
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
const token = CancellationToken.Cancelled;
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), null!, 10, new ExtensionIdentifier('test'), token).then(() => {
assert(!mainThreadCalled, '!mainThreadCalled');
});
});
test('findFiles - RelativePattern exclude', () => {
const root = '/project/foo';
const rpcProtocol = new TestRPCProtocol();
let mainThreadCalled = false;
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
mainThreadCalled = true;
assert(excludePatternOrDisregardExcludes, 'glob/**'); // Note that the base portion is ignored, see #52651
return Promise.resolve(undefined);
}
});
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
return ws.findFiles('', new RelativePattern(root, 'glob/**'), 10, new ExtensionIdentifier('test')).then(() => {
assert(mainThreadCalled, 'mainThreadCalled');
});
});
});

View File

@@ -63,7 +63,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', null);
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -81,7 +81,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', null);
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -90,7 +90,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', null);
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -117,7 +117,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', null);
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -162,7 +162,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', null);
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -180,7 +180,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', null);
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -189,7 +189,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.WORKSPACE });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', null);
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
@@ -216,7 +216,7 @@ suite('MainThreadConfiguration', function () {
instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{ getWorkbenchState: () => WorkbenchState.FOLDER });
const testObject: MainThreadConfiguration = instantiationService.createInstance(MainThreadConfiguration, SingleProxyRPCProtocol(proxy));
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', null);
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});

View File

@@ -19,7 +19,7 @@ suite('MainThreadDocumentContentProviders', function () {
let uri = URI.parse('test:uri');
let model = TextModel.createFromString('1', undefined, undefined, uri);
let providers = new MainThreadDocumentContentProviders(new TestRPCProtocol(), null, null,
let providers = new MainThreadDocumentContentProviders(new TestRPCProtocol(), null!, null!,
new class extends mock<IModelService>() {
getModel(_uri) {
assert.equal(uri.toString(), _uri.toString());

View File

@@ -29,7 +29,7 @@ suite('MainThreadDocumentsAndEditors', () => {
let deltas: IDocumentsAndEditorsDelta[] = [];
const hugeModelString = new Array(2 + (50 * 1024 * 1024)).join('-');
function myCreateTestCodeEditor(model: ITextModel): TestCodeEditor {
function myCreateTestCodeEditor(model: ITextModel | undefined): TestCodeEditor {
return createTestCodeEditor({
model: model,
serviceCollection: new ServiceCollection(
@@ -68,12 +68,12 @@ suite('MainThreadDocumentsAndEditors', () => {
textFileService,
workbenchEditorService,
codeEditorService,
null,
null!,
fileService,
null,
null,
null!,
null!,
editorGroupService,
null,
null!,
new class extends mock<IPanelService>() implements IPanelService {
_serviceBrand: any;
onDidPanelOpen = Event.None;
@@ -95,7 +95,7 @@ suite('MainThreadDocumentsAndEditors', () => {
assert.equal(deltas.length, 1);
const [delta] = deltas;
assert.equal(delta.addedDocuments.length, 1);
assert.equal(delta.addedDocuments!.length, 1);
assert.equal(delta.removedDocuments, undefined);
assert.equal(delta.addedEditors, undefined);
assert.equal(delta.removedEditors, undefined);
@@ -146,7 +146,7 @@ suite('MainThreadDocumentsAndEditors', () => {
});
test('ignore editor w/o model', () => {
const editor = myCreateTestCodeEditor(null);
const editor = myCreateTestCodeEditor(undefined);
assert.equal(deltas.length, 1);
const [delta] = deltas;
assert.equal(delta.newActiveEditor, null);
@@ -166,13 +166,13 @@ suite('MainThreadDocumentsAndEditors', () => {
assert.equal(deltas.length, 2);
const [first, second] = deltas;
assert.equal(first.addedDocuments.length, 1);
assert.equal(first.addedDocuments!.length, 1);
assert.equal(first.newActiveEditor, null);
assert.equal(first.removedDocuments, undefined);
assert.equal(first.addedEditors, undefined);
assert.equal(first.removedEditors, undefined);
assert.equal(second.addedEditors.length, 1);
assert.equal(second.addedEditors!.length, 1);
assert.equal(second.addedDocuments, undefined);
assert.equal(second.removedDocuments, undefined);
assert.equal(second.removedEditors, undefined);
@@ -194,8 +194,8 @@ suite('MainThreadDocumentsAndEditors', () => {
const [first] = deltas;
assert.equal(first.newActiveEditor, null);
assert.equal(first.removedEditors.length, 1);
assert.equal(first.removedDocuments.length, 1);
assert.equal(first.removedEditors!.length, 1);
assert.equal(first.removedDocuments!.length, 1);
assert.equal(first.addedDocuments, undefined);
assert.equal(first.addedEditors, undefined);

View File

@@ -19,11 +19,11 @@ import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';
import { IModelService } from 'vs/editor/common/services/modelService';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService, TestTextResourcePropertiesService, TestWindowService } from 'vs/workbench/test/workbenchTestServices';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { ResourceTextEdit } from 'vs/editor/common/modes';
import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser/bulkEditService';
import { BulkEditService } from 'vs/workbench/services/bulkEdit/browser/bulkEditService';
import { NullLogService } from 'vs/platform/log/common/log';
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
import { ITextModelService, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
import { IReference, ImmortalReference } from 'vs/base/common/lifecycle';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
@@ -73,16 +73,16 @@ suite('MainThreadEditors', () => {
const workbenchEditorService = new TestEditorService();
const editorGroupService = new TestEditorGroupsService();
const textModelService = new class extends mock<ITextModelService>() {
createModelReference(resource: URI): Promise<IReference<ITextEditorModel>> {
const textEditorModel: ITextEditorModel = new class extends mock<ITextEditorModel>() {
textEditorModel = modelService.getModel(resource);
createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
const textEditorModel = new class extends mock<IResolvedTextEditorModel>() {
textEditorModel = modelService.getModel(resource)!;
};
textEditorModel.isReadonly = () => false;
return Promise.resolve(new ImmortalReference(textEditorModel));
}
};
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new LabelService(TestEnvironmentService, new TestContextService(), new TestWindowService()), configService);
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new LabelService(TestEnvironmentService, new TestContextService()), configService);
const rpcProtocol = new TestRPCProtocol();
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
@@ -100,10 +100,10 @@ suite('MainThreadEditors', () => {
textFileService,
workbenchEditorService,
codeEditorService,
null,
null!,
fileService,
null,
null,
null!,
null!,
editorGroupService,
bulkEditService,
new class extends mock<IPanelService>() implements IPanelService {

View File

@@ -13,7 +13,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { ITextFileService, SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextFileService, SaveReason, IResolvedTextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager';
import { snapshotToString } from 'vs/platform/files/common/files';
@@ -38,45 +38,45 @@ suite('MainThreadSaveParticipant', function () {
});
test('insert final new line', async function () {
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/final_new_line.txt'), 'utf8');
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
await model.load();
const configService = new TestConfigurationService();
configService.setUserConfiguration('files', { 'insertFinalNewline': true });
const participant = new FinalNewLineParticipant(configService, undefined);
const participant = new FinalNewLineParticipant(configService, undefined!);
// No new line for empty lines
let lineContent = '';
model.textEditorModel.setValue(lineContent);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
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);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
assert.equal(snapshotToString(model.createSnapshot()!), lineContent);
// New empty line added (single line)
lineContent = 'Hello New Line';
model.textEditorModel.setValue(lineContent);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${lineContent}${model.textEditorModel.getEOL()}`);
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);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${lineContent}${model.textEditorModel.getEOL()}`);
assert.equal(snapshotToString(model.createSnapshot()!), `${lineContent}${model.textEditorModel.getEOL()}`);
});
test('trim final new lines', async function () {
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8');
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
await model.load();
const configService = new TestConfigurationService();
configService.setUserConfiguration('files', { 'trimFinalNewlines': true });
const participant = new TrimFinalNewLinesParticipant(configService, undefined);
const participant = new TrimFinalNewLinesParticipant(configService, undefined!);
const textContent = 'Trim New Line';
const eol = `${model.textEditorModel.getEOL()}`;
@@ -84,34 +84,34 @@ suite('MainThreadSaveParticipant', function () {
let lineContent = `${textContent}`;
model.textEditorModel.setValue(lineContent);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
assert.equal(snapshotToString(model.createSnapshot()!), lineContent);
// No new line removal if last line is single new line
lineContent = `${textContent}${eol}`;
model.textEditorModel.setValue(lineContent);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), lineContent);
assert.equal(snapshotToString(model.createSnapshot()!), lineContent);
// Remove new line (single line with two new lines)
lineContent = `${textContent}${eol}${eol}`;
model.textEditorModel.setValue(lineContent);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}`);
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);
await participant.participate(model, { reason: SaveReason.EXPLICIT });
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}${textContent}${eol}`);
assert.equal(snapshotToString(model.createSnapshot()!), `${textContent}${eol}${textContent}${eol}`);
});
test('trim final new lines bug#39750', async function () {
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8');
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
await model.load();
const configService = new TestConfigurationService();
configService.setUserConfiguration('files', { 'trimFinalNewlines': true });
const participant = new TrimFinalNewLinesParticipant(configService, undefined);
const participant = new TrimFinalNewLinesParticipant(configService, undefined!);
const textContent = 'Trim New Line';
// single line
@@ -124,21 +124,21 @@ suite('MainThreadSaveParticipant', function () {
// undo
model.textEditorModel.undo();
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}`);
assert.equal(snapshotToString(model.createSnapshot()!), `${textContent}`);
// trim final new lines should not mess the undo stack
await participant.participate(model, { reason: SaveReason.EXPLICIT });
model.textEditorModel.redo();
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}.`);
assert.equal(snapshotToString(model.createSnapshot()!), `${textContent}.`);
});
test('trim final new lines bug#46075', async function () {
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8');
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/trim_final_new_line.txt'), 'utf8') as IResolvedTextFileEditorModel;
await model.load();
const configService = new TestConfigurationService();
configService.setUserConfiguration('files', { 'trimFinalNewlines': true });
const participant = new TrimFinalNewLinesParticipant(configService, undefined);
const participant = new TrimFinalNewLinesParticipant(configService, undefined!);
const textContent = 'Test';
const eol = `${model.textEditorModel.getEOL()}`;
let content = `${textContent}${eol}${eol}`;
@@ -150,12 +150,12 @@ suite('MainThreadSaveParticipant', function () {
}
// confirm trimming
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}`);
assert.equal(snapshotToString(model.createSnapshot()!), `${textContent}${eol}`);
// undo should go back to previous content immediately
model.textEditorModel.undo();
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}${eol}`);
assert.equal(snapshotToString(model.createSnapshot()!), `${textContent}${eol}${eol}`);
model.textEditorModel.redo();
assert.equal(snapshotToString(model.createSnapshot()), `${textContent}${eol}`);
assert.equal(snapshotToString(model.createSnapshot()!), `${textContent}${eol}`);
});
});

View File

@@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ISearchService, IFileQuery } from 'vs/workbench/services/search/common/search';
import { MainThreadWorkspace } from 'vs/workbench/api/electron-browser/mainThreadWorkspace';
import * as assert from 'assert';
import { SingleProxyRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
suite('MainThreadWorkspace', () => {
let configService: TestConfigurationService;
let instantiationService: TestInstantiationService;
setup(() => {
instantiationService = workbenchInstantiationService() as TestInstantiationService;
configService = instantiationService.get(IConfigurationService) as TestConfigurationService;
configService.setUserConfiguration('search', {});
});
test('simple', () => {
instantiationService.stub(ISearchService, {
fileSearch(query: IFileQuery) {
assert.equal(query.folderQueries.length, 1);
assert.equal(query.folderQueries[0].disregardIgnoreFiles, true);
assert.deepEqual(query.includePattern, { 'foo': true });
assert.equal(query.maxResults, 10);
return Promise.resolve({ results: [] });
}
});
const mtw: MainThreadWorkspace = instantiationService.createInstance(<any>MainThreadWorkspace, SingleProxyRPCProtocol({ $initializeWorkspace: () => { } }));
return mtw.$startFileSearch('foo', undefined, undefined, 10, new CancellationTokenSource().token);
});
test('exclude defaults', () => {
configService.setUserConfiguration('search', {
'exclude': { 'searchExclude': true }
});
configService.setUserConfiguration('files', {
'exclude': { 'filesExclude': true }
});
instantiationService.stub(ISearchService, {
fileSearch(query: IFileQuery) {
assert.equal(query.folderQueries.length, 1);
assert.equal(query.folderQueries[0].disregardIgnoreFiles, true);
assert.deepEqual(query.folderQueries[0].excludePattern, { 'filesExclude': true });
return Promise.resolve({ results: [] });
}
});
const mtw: MainThreadWorkspace = instantiationService.createInstance(<any>MainThreadWorkspace, SingleProxyRPCProtocol({ $initializeWorkspace: () => { } }));
return mtw.$startFileSearch('', undefined, undefined, 10, new CancellationTokenSource().token);
});
test('disregard excludes', () => {
configService.setUserConfiguration('search', {
'exclude': { 'searchExclude': true }
});
configService.setUserConfiguration('files', {
'exclude': { 'filesExclude': true }
});
instantiationService.stub(ISearchService, {
fileSearch(query: IFileQuery) {
assert.equal(query.folderQueries[0].excludePattern, undefined);
assert.deepEqual(query.excludePattern, undefined);
return Promise.resolve({ results: [] });
}
});
const mtw: MainThreadWorkspace = instantiationService.createInstance(<any>MainThreadWorkspace, SingleProxyRPCProtocol({ $initializeWorkspace: () => { } }));
return mtw.$startFileSearch('', undefined, false, 10, new CancellationTokenSource().token);
});
test('exclude string', () => {
instantiationService.stub(ISearchService, {
fileSearch(query: IFileQuery) {
assert.equal(query.folderQueries[0].excludePattern, undefined);
assert.deepEqual(query.excludePattern, { 'exclude/**': true });
return Promise.resolve({ results: [] });
}
});
const mtw: MainThreadWorkspace = instantiationService.createInstance(<any>MainThreadWorkspace, SingleProxyRPCProtocol({ $initializeWorkspace: () => { } }));
return mtw.$startFileSearch('', undefined, 'exclude/**', 10, new CancellationTokenSource().token);
});
});

View File

@@ -10,23 +10,23 @@ import { isThenable } from 'vs/base/common/async';
export function SingleProxyRPCProtocol(thing: any): IExtHostContext {
return {
remoteAuthority: null,
remoteAuthority: null!,
getProxy<T>(): T {
return thing;
},
set<T, R extends T>(identifier: ProxyIdentifier<T>, value: R): R {
return value;
},
assertRegistered: undefined
assertRegistered: undefined!
};
}
export class TestRPCProtocol implements IExtHostContext {
public remoteAuthority = null;
public remoteAuthority = null!;
private _callCountValue: number = 0;
private _idle: Promise<any>;
private _idle?: Promise<any>;
private _completeIdle: Function;
private readonly _locals: { [id: string]: any; };

View File

@@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Registry } from 'vs/platform/registry/common/platform';
import { IColorRegistry, Extensions, ColorContribution } from 'vs/platform/theme/common/colorRegistry';
import { editorMarkerNavigationError } from 'vs/editor/contrib/gotoError/gotoErrorWidget';
import { overviewRulerModifiedForeground } from 'vs/workbench/contrib/scm/browser/dirtydiffDecorator';
import { STATUS_BAR_DEBUGGING_BACKGROUND } from 'vs/workbench/contrib/debug/browser/statusbarColorProvider';
import { debugExceptionWidgetBackground } from 'vs/workbench/contrib/debug/browser/exceptionWidget';
import { debugToolBarBackground } from 'vs/workbench/contrib/debug/browser/debugToolbar';
import { buttonBackground } from 'vs/workbench/contrib/welcome/page/browser/welcomePage';
import { embeddedEditorBackground } from 'vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart';
import { request, asText } from 'vs/base/node/request';
import * as pfs from 'vs/base/node/pfs';
import * as path from 'vs/base/common/path';
import * as assert from 'assert';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { CancellationToken } from 'vs/base/common/cancellation';
interface ColorInfo {
description: string;
offset: number;
length: number;
}
interface DescriptionDiff {
docDescription: string;
specDescription: string;
}
// add artificial dependencies to some files that are not loaded yet
export const forceColorLoad = [editorMarkerNavigationError, overviewRulerModifiedForeground, STATUS_BAR_DEBUGGING_BACKGROUND,
debugExceptionWidgetBackground, debugToolBarBackground, buttonBackground, embeddedEditorBackground];
export const experimental: string[] = []; // 'settings.modifiedItemForeground', 'editorUnnecessary.foreground' ];
suite('Color Registry', function () {
test('all colors documented', async function () {
const reqContext = await request({ url: 'https://raw.githubusercontent.com/Microsoft/vscode-docs/vnext/docs/getstarted/theme-color-reference.md' }, CancellationToken.None);
const content = (await asText(reqContext))!;
const expression = /\-\s*\`([\w\.]+)\`: (.*)/g;
let m: RegExpExecArray | null;
let colorsInDoc: { [id: string]: ColorInfo } = Object.create(null);
while (m = expression.exec(content)) {
colorsInDoc[m[1]] = { description: m[2], offset: m.index, length: m.length };
}
let missing = Object.create(null);
let descriptionDiffs: { [id: string]: DescriptionDiff } = Object.create(null);
let themingRegistry = Registry.as<IColorRegistry>(Extensions.ColorContribution);
for (let color of themingRegistry.getColors()) {
if (!colorsInDoc[color.id]) {
if (!color.deprecationMessage) {
missing[color.id] = getDescription(color);
}
} else {
let docDescription = colorsInDoc[color.id].description;
let specDescription = getDescription(color);
if (docDescription !== specDescription) {
descriptionDiffs[color.id] = { docDescription, specDescription };
}
delete colorsInDoc[color.id];
}
}
let colorsInExtensions = await getColorsFromExtension();
for (let colorId in colorsInExtensions) {
if (!colorsInDoc[colorId]) {
missing[colorId] = colorsInExtensions[colorId];
} else {
delete colorsInDoc[colorId];
}
}
for (let colorId of experimental) {
if (missing[colorId]) {
delete missing[colorId];
}
if (colorsInDoc[colorId]) {
assert.fail(`Color ${colorId} found in doc but marked experimental. Please remove from experimental list.`);
}
}
let undocumentedKeys = Object.keys(missing).map(k => `${k}: ${missing[k]}`);
assert.deepEqual(undocumentedKeys, [], 'Undocumented colors ids');
let superfluousKeys = Object.keys(colorsInDoc);
assert.deepEqual(superfluousKeys, [], 'Colors ids in doc that do not exist');
});
});
function getDescription(color: ColorContribution) {
let specDescription = color.description;
if (color.deprecationMessage) {
specDescription = specDescription + ' ' + color.deprecationMessage;
}
return specDescription;
}
async function getColorsFromExtension(): Promise<{ [id: string]: string }> {
let extPath = getPathFromAmdModule(require, '../../../../../../extensions');
let extFolders = await pfs.readDirsInDir(extPath);
let result: { [id: string]: string } = Object.create(null);
for (let folder of extFolders) {
try {
let packageJSON = JSON.parse((await pfs.readFile(path.join(extPath, folder, 'package.json'))).toString());
let contributes = packageJSON['contributes'];
if (contributes) {
let colors = contributes['colors'];
if (colors) {
for (let color of colors) {
let colorId = color['id'];
if (colorId) {
result[colorId] = colorId['description'];
}
}
}
}
} catch (e) {
// ignore
}
}
return result;
}

View File

@@ -5,7 +5,7 @@
import * as assert from 'assert';
import * as minimist from 'minimist';
import * as path from 'path';
import * as path from 'vs/base/common/path';
import { CancellationToken } from 'vs/base/common/cancellation';
import { URI } from 'vs/base/common/uri';
import { IModelService } from 'vs/editor/common/services/modelService';
@@ -18,14 +18,14 @@ import { createSyncDescriptor } from 'vs/platform/instantiation/common/descripto
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 { ISearchService } from 'vs/workbench/services/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 'vs/workbench/contrib/search/browser/search.contribution'; // load contributions
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/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';

View File

@@ -3,18 +3,18 @@
* 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 'vs/workbench/contrib/search/browser/search.contribution'; // load contributions
import * as assert from 'assert';
import * as fs from 'fs';
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 { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ISearchService } from 'vs/workbench/services/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 * as path from 'vs/base/common/path';
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';
@@ -26,8 +26,8 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
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 { SearchModel } from 'vs/workbench/contrib/search/common/searchModel';
import { QueryBuilder, ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/queryBuilder';
import { Event, Emitter } from 'vs/base/common/event';
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';