mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -13,10 +13,10 @@ import { StorageScope } from 'vs/platform/storage/common/storage';
|
||||
|
||||
class SimplePart extends Part {
|
||||
|
||||
minimumWidth: number;
|
||||
maximumWidth: number;
|
||||
minimumHeight: number;
|
||||
maximumHeight: number;
|
||||
minimumWidth: number = 50;
|
||||
maximumWidth: number = 50;
|
||||
minimumHeight: number = 50;
|
||||
maximumHeight: number = 50;
|
||||
|
||||
layout(width: number, height: number): void {
|
||||
throw new Error('Method not implemented.');
|
||||
|
||||
@@ -103,7 +103,7 @@ suite('Notifications', () => {
|
||||
|
||||
// Error with Action
|
||||
let item6 = NotificationViewItem.create({ severity: Severity.Error, message: createErrorWithActions('Hello Error', { actions: [new Action('id', 'label')] }) })!;
|
||||
assert.equal(item6.actions.primary!.length, 1);
|
||||
assert.equal(item6.actions!.primary!.length, 1);
|
||||
|
||||
// Links
|
||||
let item7 = NotificationViewItem.create({ severity: Severity.Info, message: 'Unable to [Link 1](http://link1.com) open [Link 2](command:open.me "Open This") and [Link 3](command:without.title) and [Invalid Link4](ftp://link4.com)' })!;
|
||||
@@ -219,4 +219,4 @@ suite('Notifications', () => {
|
||||
disposable3.dispose();
|
||||
assert.ok(!model.statusMessage);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -181,7 +181,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
test('executeWorkspaceSymbolProvider should accept empty string, #39522', async function () {
|
||||
|
||||
disposables.push(extHost.registerWorkspaceSymbolProvider(nullExtensionDescription, {
|
||||
provideWorkspaceSymbols(query): vscode.SymbolInformation[] {
|
||||
provideWorkspaceSymbols(): vscode.SymbolInformation[] {
|
||||
return [new types.SymbolInformation('hello', types.SymbolKind.Array, new types.Range(0, 0, 0, 0), URI.parse('foo:bar')) as vscode.SymbolInformation];
|
||||
}
|
||||
}));
|
||||
@@ -312,7 +312,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
test('reference search, back and forth', function () {
|
||||
|
||||
disposables.push(extHost.registerReferenceProvider(nullExtensionDescription, defaultSelector, <vscode.ReferenceProvider>{
|
||||
provideReferences(doc: any) {
|
||||
provideReferences() {
|
||||
return [
|
||||
new types.Location(URI.parse('some:uri/path'), new types.Range(0, 1, 0, 5))
|
||||
];
|
||||
@@ -388,7 +388,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
test('Suggest, back and forth', function () {
|
||||
disposables.push(extHost.registerCompletionItemProvider(nullExtensionDescription, defaultSelector, <vscode.CompletionItemProvider>{
|
||||
provideCompletionItems(doc, pos): any {
|
||||
provideCompletionItems(): any {
|
||||
let a = new types.CompletionItem('item1');
|
||||
let b = new types.CompletionItem('item2');
|
||||
b.textEdit = types.TextEdit.replace(new types.Range(0, 4, 0, 8), 'foo'); // overwite after
|
||||
@@ -631,6 +631,61 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
});
|
||||
});
|
||||
|
||||
test('vscode.executeCodeActionProvider passes Range to provider although Selection is passed in #77997', function () {
|
||||
disposables.push(extHost.registerCodeActionProvider(nullExtensionDescription, defaultSelector, {
|
||||
provideCodeActions(document, rangeOrSelection): vscode.CodeAction[] {
|
||||
return [{
|
||||
command: {
|
||||
arguments: [document, rangeOrSelection],
|
||||
command: 'command',
|
||||
title: 'command_title',
|
||||
},
|
||||
kind: types.CodeActionKind.Empty.append('foo'),
|
||||
title: 'title',
|
||||
}];
|
||||
}
|
||||
}));
|
||||
|
||||
const selection = new types.Selection(0, 0, 1, 1);
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, selection).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
const [first] = value;
|
||||
assert.ok(first.command);
|
||||
assert.ok(first.command!.arguments![1] instanceof types.Selection);
|
||||
assert.ok(first.command!.arguments![1].isEqual(selection));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('vscode.executeCodeActionProvider results seem to be missing their `isPreferred` property #78098', function () {
|
||||
disposables.push(extHost.registerCodeActionProvider(nullExtensionDescription, defaultSelector, {
|
||||
provideCodeActions(document, rangeOrSelection): vscode.CodeAction[] {
|
||||
return [{
|
||||
command: {
|
||||
arguments: [document, rangeOrSelection],
|
||||
command: 'command',
|
||||
title: 'command_title',
|
||||
},
|
||||
kind: types.CodeActionKind.Empty.append('foo'),
|
||||
title: 'title',
|
||||
isPreferred: true
|
||||
}];
|
||||
}
|
||||
}));
|
||||
|
||||
const selection = new types.Selection(0, 0, 1, 1);
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, selection).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
const [first] = value;
|
||||
assert.equal(first.isPreferred, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- code lens
|
||||
|
||||
test('CodeLens, back and forth', function () {
|
||||
@@ -724,7 +779,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
provideDocumentColors(): vscode.ColorInformation[] {
|
||||
return [new types.ColorInformation(new types.Range(0, 0, 0, 20), new types.Color(0.1, 0.2, 0.3, 0.4))];
|
||||
},
|
||||
provideColorPresentations(color: vscode.Color, context: { range: vscode.Range, document: vscode.TextDocument }): vscode.ColorPresentation[] {
|
||||
provideColorPresentations(): vscode.ColorPresentation[] {
|
||||
const cp = new types.ColorPresentation('#ABC');
|
||||
cp.textEdit = types.TextEdit.replace(new types.Range(1, 0, 1, 20), '#ABC');
|
||||
cp.additionalTextEdits = [types.TextEdit.insert(new types.Position(2, 20), '*')];
|
||||
|
||||
@@ -26,7 +26,10 @@ suite('ExtHostCommands', function () {
|
||||
}
|
||||
};
|
||||
|
||||
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), new NullLogService());
|
||||
const commands = new ExtHostCommands(
|
||||
SingleProxyRPCProtocol(shape),
|
||||
new NullLogService()
|
||||
);
|
||||
commands.registerCommand(true, 'foo', (): any => { }).dispose();
|
||||
assert.equal(lastUnregister!, 'foo');
|
||||
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
|
||||
@@ -46,7 +49,10 @@ suite('ExtHostCommands', function () {
|
||||
}
|
||||
};
|
||||
|
||||
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), new NullLogService());
|
||||
const commands = new ExtHostCommands(
|
||||
SingleProxyRPCProtocol(shape),
|
||||
new NullLogService()
|
||||
);
|
||||
const reg = commands.registerCommand(true, 'foo', (): any => { });
|
||||
reg.dispose();
|
||||
reg.dispose();
|
||||
|
||||
@@ -15,7 +15,7 @@ import { IWorkspaceFolder, WorkspaceFolder } from 'vs/platform/workspace/common/
|
||||
import { ConfigurationTarget, IConfigurationModel } from 'vs/platform/configuration/common/configuration';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { Counter } from 'vs/base/common/numbers';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
|
||||
suite('ExtHostConfiguration', function () {
|
||||
|
||||
@@ -27,11 +27,15 @@ suite('ExtHostConfiguration', function () {
|
||||
}
|
||||
}
|
||||
|
||||
function createExtHostWorkspace(): ExtHostWorkspace {
|
||||
return new ExtHostWorkspace(new TestRPCProtocol(), new class extends mock<IExtHostInitDataService>() { }, new NullLogService());
|
||||
}
|
||||
|
||||
function createExtHostConfiguration(contents: any = Object.create(null), shape?: MainThreadConfigurationShape) {
|
||||
if (!shape) {
|
||||
shape = new class extends mock<MainThreadConfigurationShape>() { };
|
||||
}
|
||||
return new ExtHostConfigProvider(shape, new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter()), createConfigurationData(contents));
|
||||
return new ExtHostConfigProvider(shape, createExtHostWorkspace(), createConfigurationData(contents));
|
||||
}
|
||||
|
||||
function createConfigurationData(contents: any): IConfigurationInitData {
|
||||
@@ -264,7 +268,7 @@ suite('ExtHostConfiguration', function () {
|
||||
test('inspect in no workspace context', function () {
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter()),
|
||||
createExtHostWorkspace(),
|
||||
{
|
||||
defaults: new ConfigurationModel({
|
||||
'editor': {
|
||||
@@ -304,7 +308,7 @@ suite('ExtHostConfiguration', function () {
|
||||
}
|
||||
}, ['editor.wordWrap']);
|
||||
folders.push([workspaceUri, workspace]);
|
||||
const extHostWorkspace = new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter());
|
||||
const extHostWorkspace = createExtHostWorkspace();
|
||||
extHostWorkspace.$initializeWorkspace({
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(URI.file('foo'), 0)],
|
||||
@@ -379,7 +383,7 @@ suite('ExtHostConfiguration', function () {
|
||||
}, ['editor.wordWrap'])]);
|
||||
folders.push([thirdRoot, new ConfigurationModel({}, [])]);
|
||||
|
||||
const extHostWorkspace = new ExtHostWorkspace(new TestRPCProtocol(), new NullLogService(), new Counter());
|
||||
const extHostWorkspace = createExtHostWorkspace();
|
||||
extHostWorkspace.$initializeWorkspace({
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
|
||||
@@ -589,7 +593,7 @@ 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());
|
||||
const extHostWorkspace = createExtHostWorkspace();
|
||||
extHostWorkspace.$initializeWorkspace({
|
||||
'id': 'foo',
|
||||
'folders': [workspaceFolder],
|
||||
|
||||
@@ -7,7 +7,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { TextDocumentSaveReason, TextEdit, Position, EndOfLine } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { MainThreadTextEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { MainThreadTextEditorsShape, IWorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/common/extHostDocumentSaveParticipant';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
@@ -262,9 +262,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
|
||||
test('event delivery, pushEdits sync', () => {
|
||||
|
||||
let dto: WorkspaceEditDto;
|
||||
let dto: IWorkspaceEditDto;
|
||||
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyWorkspaceEdit(_edits: WorkspaceEditDto) {
|
||||
$tryApplyWorkspaceEdit(_edits: IWorkspaceEditDto) {
|
||||
dto = _edits;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
@@ -286,9 +286,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
|
||||
test('event delivery, concurrent change', () => {
|
||||
|
||||
let edits: WorkspaceEditDto;
|
||||
let edits: IWorkspaceEditDto;
|
||||
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyWorkspaceEdit(_edits: WorkspaceEditDto) {
|
||||
$tryApplyWorkspaceEdit(_edits: IWorkspaceEditDto) {
|
||||
edits = _edits;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
test('event delivery, two listeners -> two document states', () => {
|
||||
|
||||
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyWorkspaceEdit(dto: WorkspaceEditDto) {
|
||||
$tryApplyWorkspaceEdit(dto: IWorkspaceEditDto) {
|
||||
|
||||
for (const edit of dto.edits) {
|
||||
if (!isResourceTextEdit(edit)) {
|
||||
|
||||
@@ -6,17 +6,14 @@
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
|
||||
|
||||
suite('ExtHostDocumentsAndEditors', () => {
|
||||
|
||||
let editors: ExtHostDocumentsAndEditors;
|
||||
|
||||
setup(function () {
|
||||
editors = new ExtHostDocumentsAndEditors({
|
||||
getProxy: () => { return undefined!; },
|
||||
set: undefined!,
|
||||
assertRegistered: undefined!
|
||||
});
|
||||
editors = new ExtHostDocumentsAndEditors(new TestRPCProtocol());
|
||||
});
|
||||
|
||||
test('The value of TextDocument.isClosed is incorrect when a text document is closed, #27949', () => {
|
||||
|
||||
@@ -18,6 +18,9 @@ import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteSt
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
|
||||
import * as vscode from 'vscode';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { URITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
|
||||
let rpcProtocol: TestRPCProtocol;
|
||||
let extHostSearch: ExtHostSearch;
|
||||
@@ -135,7 +138,17 @@ suite('ExtHostSearch', () => {
|
||||
rpcProtocol.set(MainContext.MainThreadSearch, mockMainThreadSearch);
|
||||
|
||||
mockPFS = {};
|
||||
extHostSearch = new ExtHostSearch(rpcProtocol, null!, logService, mockPFS as any);
|
||||
extHostSearch = new class extends ExtHostSearch {
|
||||
constructor() {
|
||||
super(
|
||||
rpcProtocol,
|
||||
new class extends mock<IExtHostInitDataService>() { remote = { isRemote: false, authority: undefined }; },
|
||||
new URITransformerService(null),
|
||||
logService
|
||||
);
|
||||
this._pfs = mockPFS as any;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { MainContext, MainThreadTextEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { MainContext, MainThreadTextEditorsShape, IWorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
@@ -16,14 +16,14 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
|
||||
const resource = URI.parse('foo:bar');
|
||||
let editors: ExtHostEditors;
|
||||
let workspaceResourceEdits: WorkspaceEditDto;
|
||||
let workspaceResourceEdits: IWorkspaceEditDto;
|
||||
|
||||
setup(() => {
|
||||
workspaceResourceEdits = null!;
|
||||
|
||||
let rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadTextEditors, new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyWorkspaceEdit(_workspaceResourceEdits: WorkspaceEditDto): Promise<boolean> {
|
||||
$tryApplyWorkspaceEdit(_workspaceResourceEdits: IWorkspaceEditDto): Promise<boolean> {
|
||||
workspaceResourceEdits = _workspaceResourceEdits;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,10 @@ suite('ExtHostTreeView', function () {
|
||||
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
|
||||
target = new RecordingShape();
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new NullLogService()), new NullLogService());
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(
|
||||
rpcProtocol,
|
||||
new NullLogService()
|
||||
), new NullLogService());
|
||||
onDidChangeTreeNode = new Emitter<{ key: string }>();
|
||||
onDidChangeTreeNodeWithId = new Emitter<{ key: string }>();
|
||||
testObject.createTreeView('testNodeTreeProvider', { treeDataProvider: aNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Counter } from 'vs/base/common/numbers';
|
||||
import { basename } from 'vs/base/common/path';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
@@ -17,9 +16,15 @@ import { RelativePattern } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { TestRPCProtocol } from './testRPCProtocol';
|
||||
import { ExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
|
||||
function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, logService: ILogService, requestIdProvider: Counter): ExtHostWorkspace {
|
||||
const result = new ExtHostWorkspace(mainContext, logService, requestIdProvider);
|
||||
function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, logService: ILogService): ExtHostWorkspace {
|
||||
const result = new ExtHostWorkspace(
|
||||
new ExtHostRpcService(mainContext),
|
||||
new class extends mock<IExtHostInitDataService>() { workspace = data; },
|
||||
logService
|
||||
);
|
||||
result.$initializeWorkspace(data);
|
||||
return result;
|
||||
}
|
||||
@@ -45,7 +50,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
test('asRelativePath', () => {
|
||||
|
||||
const ws = createExtHostWorkspace(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());
|
||||
|
||||
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',
|
||||
@@ -59,7 +64,7 @@ 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 = createExtHostWorkspace(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());
|
||||
|
||||
assertAsRelativePath(ws, input, input);
|
||||
|
||||
@@ -68,20 +73,20 @@ suite('ExtHostWorkspace', function () {
|
||||
});
|
||||
|
||||
test('asRelativePath, no workspace', function () {
|
||||
const ws = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService());
|
||||
assertAsRelativePath(ws, '', '');
|
||||
assertAsRelativePath(ws, '/foo/bar', '/foo/bar');
|
||||
});
|
||||
|
||||
test('asRelativePath, multiple folders', function () {
|
||||
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 ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService());
|
||||
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 = 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 mrws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService());
|
||||
|
||||
assertAsRelativePath(mrws, '/Coding/One/file.txt', 'One/file.txt');
|
||||
assertAsRelativePath(mrws, '/Coding/One/file.txt', 'One/file.txt', true);
|
||||
@@ -93,7 +98,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 = createExtHostWorkspace(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());
|
||||
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);
|
||||
@@ -103,24 +108,24 @@ suite('ExtHostWorkspace', function () {
|
||||
});
|
||||
|
||||
test('getPath, legacy', function () {
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
||||
assert.equal(ws.getPath(), undefined);
|
||||
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter());
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService());
|
||||
assert.equal(ws.getPath(), undefined);
|
||||
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), undefined!, new NullLogService(), new Counter());
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), undefined!, new NullLogService());
|
||||
assert.equal(ws.getPath(), undefined);
|
||||
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService(), new Counter());
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService());
|
||||
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());
|
||||
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('/Folder'), 0)] }, new NullLogService());
|
||||
assert.equal(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
|
||||
});
|
||||
|
||||
test('WorkspaceFolder has name and index', function () {
|
||||
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 ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/One'), 0), aWorkspaceFolderData(URI.file('/Coding/Two'), 1)], name: 'Test' }, new NullLogService());
|
||||
|
||||
const [one, two] = ws.getWorkspaceFolders()!;
|
||||
|
||||
@@ -139,7 +144,7 @@ suite('ExtHostWorkspace', function () {
|
||||
aWorkspaceFolderData(URI.file('/Coding/Two'), 1),
|
||||
aWorkspaceFolderData(URI.file('/Coding/Two/Nested'), 2)
|
||||
]
|
||||
}, new NullLogService(), new Counter());
|
||||
}, new NullLogService());
|
||||
|
||||
let folder = ws.getWorkspaceFolder(URI.file('/foo/bar'));
|
||||
assert.equal(folder, undefined);
|
||||
@@ -179,7 +184,7 @@ suite('ExtHostWorkspace', function () {
|
||||
});
|
||||
|
||||
test('Multiroot change event should have a delta, #29641', function (done) {
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
||||
|
||||
let finished = false;
|
||||
const finish = (error?: any) => {
|
||||
@@ -242,7 +247,7 @@ suite('ExtHostWorkspace', function () {
|
||||
});
|
||||
|
||||
test('Multiroot change keeps existing workspaces live', function () {
|
||||
let ws = createExtHostWorkspace(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());
|
||||
|
||||
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')] });
|
||||
@@ -262,7 +267,7 @@ suite('ExtHostWorkspace', function () {
|
||||
});
|
||||
|
||||
test('updateWorkspaceFolders - invalid arguments', function () {
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
||||
|
||||
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null!, null!));
|
||||
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0));
|
||||
@@ -271,7 +276,7 @@ suite('ExtHostWorkspace', function () {
|
||||
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, 0));
|
||||
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, -1));
|
||||
|
||||
ws = createExtHostWorkspace(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());
|
||||
|
||||
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 1));
|
||||
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2));
|
||||
@@ -289,11 +294,11 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
const protocol: IMainContext = {
|
||||
getProxy: () => { return undefined!; },
|
||||
set: undefined!,
|
||||
assertRegistered: undefined!
|
||||
set: () => { return undefined!; },
|
||||
assertRegistered: () => { }
|
||||
};
|
||||
|
||||
const ws = createExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
||||
|
||||
//
|
||||
// Add one folder
|
||||
@@ -526,7 +531,7 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
};
|
||||
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter());
|
||||
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
||||
let sub = ws.onDidChangeWorkspace(e => {
|
||||
try {
|
||||
assert.throws(() => {
|
||||
@@ -549,7 +554,7 @@ suite('ExtHostWorkspace', function () {
|
||||
id: 'foo', name: 'Test', folders: [
|
||||
aWorkspaceFolderData(URI.file('c:/Users/marek/Desktop/vsc_test/'), 0)
|
||||
]
|
||||
}, new NullLogService(), new Counter());
|
||||
}, new NullLogService());
|
||||
|
||||
assert.ok(ws.getWorkspaceFolder(URI.file('c:/Users/marek/Desktop/vsc_test/a.txt')));
|
||||
assert.ok(ws.getWorkspaceFolder(URI.file('C:/Users/marek/Desktop/vsc_test/b.txt')));
|
||||
@@ -583,7 +588,7 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
});
|
||||
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
|
||||
return ws.findFiles('foo', undefined, 10, new ExtensionIdentifier('test')).then(() => {
|
||||
assert(mainThreadCalled, 'mainThreadCalled');
|
||||
});
|
||||
@@ -604,7 +609,7 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
});
|
||||
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
|
||||
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), undefined, 10, new ExtensionIdentifier('test')).then(() => {
|
||||
assert(mainThreadCalled, 'mainThreadCalled');
|
||||
});
|
||||
@@ -625,7 +630,7 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
});
|
||||
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
|
||||
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), null!, 10, new ExtensionIdentifier('test')).then(() => {
|
||||
assert(mainThreadCalled, 'mainThreadCalled');
|
||||
});
|
||||
@@ -643,7 +648,7 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
});
|
||||
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
|
||||
|
||||
const token = CancellationToken.Cancelled;
|
||||
return ws.findFiles(new RelativePattern('/other/folder', 'glob/**'), null!, 10, new ExtensionIdentifier('test'), token).then(() => {
|
||||
@@ -664,7 +669,7 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
});
|
||||
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService(), new Counter());
|
||||
const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService());
|
||||
return ws.findFiles('', new RelativePattern(root, 'glob/**'), 10, new ExtensionIdentifier('test')).then(() => {
|
||||
assert(mainThreadCalled, 'mainThreadCalled');
|
||||
});
|
||||
|
||||
@@ -7,9 +7,11 @@ import { ProxyIdentifier } from 'vs/workbench/services/extensions/common/proxyId
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { isThenable } from 'vs/base/common/async';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
|
||||
export function SingleProxyRPCProtocol(thing: any): IExtHostContext {
|
||||
export function SingleProxyRPCProtocol(thing: any): IExtHostContext & IExtHostRpcService {
|
||||
return {
|
||||
_serviceBrand: undefined,
|
||||
remoteAuthority: null!,
|
||||
getProxy<T>(): T {
|
||||
return thing;
|
||||
@@ -21,13 +23,14 @@ export function SingleProxyRPCProtocol(thing: any): IExtHostContext {
|
||||
};
|
||||
}
|
||||
|
||||
export class TestRPCProtocol implements IExtHostContext {
|
||||
export class TestRPCProtocol implements IExtHostContext, IExtHostRpcService {
|
||||
|
||||
public _serviceBrand = undefined;
|
||||
public remoteAuthority = null!;
|
||||
|
||||
private _callCountValue: number = 0;
|
||||
private _idle?: Promise<any>;
|
||||
private _completeIdle: Function;
|
||||
private _completeIdle?: Function;
|
||||
|
||||
private readonly _locals: { [id: string]: any; };
|
||||
private readonly _proxies: { [id: string]: any; };
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as minimist from 'minimist';
|
||||
import * as minimist from 'vscode-minimist';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 minimist from 'vscode-minimist';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
|
||||
@@ -665,6 +665,7 @@ export class TestEditorGroupsService implements IEditorGroupsService {
|
||||
onDidAddGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidRemoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidMoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidGroupIndexChange: Event<IEditorGroup> = Event.None;
|
||||
onDidLayout: Event<IDimension> = Event.None;
|
||||
|
||||
orientation: any;
|
||||
@@ -761,6 +762,7 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
disposed: boolean;
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
label: string;
|
||||
index: number;
|
||||
whenRestored: Promise<void> = Promise.resolve(undefined);
|
||||
element: HTMLElement;
|
||||
minimumWidth: number;
|
||||
@@ -768,6 +770,9 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
minimumHeight: number;
|
||||
maximumHeight: number;
|
||||
|
||||
isEmpty = true;
|
||||
isMinimized = false;
|
||||
|
||||
onWillDispose: Event<void> = Event.None;
|
||||
onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
|
||||
onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
@@ -837,9 +842,8 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
isEmpty(): boolean { return true; }
|
||||
setActive(_isActive: boolean): void { }
|
||||
setLabel(_label: string): void { }
|
||||
notifyIndexChanged(_index: number): void { }
|
||||
dispose(): void { }
|
||||
toJSON(): object { return Object.create(null); }
|
||||
layout(_width: number, _height: number): void { }
|
||||
|
||||
Reference in New Issue
Block a user