mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
@@ -8,13 +8,30 @@ import { Part } from 'vs/workbench/browser/part';
|
||||
import * as Types from 'vs/base/common/types';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { append, $, hide } from 'vs/base/browser/dom';
|
||||
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestStorageService, TestLayoutService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { Orientation } from 'vs/base/browser/ui/grid/grid';
|
||||
|
||||
class MyPart extends Part {
|
||||
class SimplePart extends Part {
|
||||
|
||||
minimumWidth: number;
|
||||
maximumWidth: number;
|
||||
minimumHeight: number;
|
||||
maximumHeight: number;
|
||||
|
||||
layout(width: number, height: number, orientation: Orientation): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
toJSON(): object {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
class MyPart extends SimplePart {
|
||||
|
||||
constructor(private expectedParent: HTMLElement) {
|
||||
super('myPart', { hasTitle: true }, new TestThemeService(), new TestStorageService());
|
||||
super('myPart', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
|
||||
}
|
||||
|
||||
createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
@@ -36,10 +53,10 @@ class MyPart extends Part {
|
||||
}
|
||||
}
|
||||
|
||||
class MyPart2 extends Part {
|
||||
class MyPart2 extends SimplePart {
|
||||
|
||||
constructor() {
|
||||
super('myPart2', { hasTitle: true }, new TestThemeService(), new TestStorageService());
|
||||
super('myPart2', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
|
||||
}
|
||||
|
||||
createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
@@ -61,10 +78,10 @@ class MyPart2 extends Part {
|
||||
}
|
||||
}
|
||||
|
||||
class MyPart3 extends Part {
|
||||
class MyPart3 extends SimplePart {
|
||||
|
||||
constructor() {
|
||||
super('myPart2', { hasTitle: false }, new TestThemeService(), new TestStorageService());
|
||||
super('myPart2', { hasTitle: false }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
|
||||
}
|
||||
|
||||
createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
|
||||
@@ -154,10 +154,10 @@ suite('Workbench base editor', () => {
|
||||
|
||||
let inst = new TestInstantiationService();
|
||||
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'))).instantiate(inst);
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake')))!.instantiate(inst);
|
||||
assert.strictEqual(editor.getId(), 'myEditor');
|
||||
|
||||
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', URI.file('/fake'))).instantiate(inst);
|
||||
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', URI.file('/fake')))!.instantiate(inst);
|
||||
assert.strictEqual(otherEditor.getId(), 'myOtherEditor');
|
||||
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
@@ -173,14 +173,14 @@ suite('Workbench base editor', () => {
|
||||
|
||||
let inst = new TestInstantiationService();
|
||||
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'))).instantiate(inst);
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake')))!.instantiate(inst);
|
||||
assert.strictEqual('myOtherEditor', editor.getId());
|
||||
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
});
|
||||
|
||||
test('Editor Input Factory', function () {
|
||||
EditorInputRegistry.setInstantiationService(workbenchInstantiationService());
|
||||
workbenchInstantiationService().invokeFunction(accessor => EditorInputRegistry.start(accessor));
|
||||
EditorInputRegistry.registerEditorInputFactory('myInputId', MyInputFactory);
|
||||
|
||||
let factory = EditorInputRegistry.getEditorInputFactory('myInputId');
|
||||
@@ -211,12 +211,12 @@ suite('Workbench base editor', () => {
|
||||
memento.saveEditorState(testGroup0, URI.file('/A'), { line: 3 });
|
||||
res = memento.loadEditorState(testGroup0, URI.file('/A'));
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 3);
|
||||
assert.equal(res!.line, 3);
|
||||
|
||||
memento.saveEditorState(testGroup1, URI.file('/A'), { line: 5 });
|
||||
res = memento.loadEditorState(testGroup1, URI.file('/A'));
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 5);
|
||||
assert.equal(res!.line, 5);
|
||||
|
||||
// Ensure capped at 3 elements
|
||||
memento.saveEditorState(testGroup0, URI.file('/B'), { line: 1 });
|
||||
@@ -289,7 +289,7 @@ suite('Workbench base editor', () => {
|
||||
memento.saveEditorState(testGroup0, testInputA, { line: 3 });
|
||||
res = memento.loadEditorState(testGroup0, testInputA);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 3);
|
||||
assert.equal(res!.line, 3);
|
||||
|
||||
// State removed when input gets disposed
|
||||
testInputA.dispose();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ContributableViewsModel, ViewsService } from 'vs/workbench/browser/parts/views/views';
|
||||
import { ViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewsService } from 'vs/workbench/common/views';
|
||||
import { IViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewsService } from 'vs/workbench/common/views';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { move } from 'vs/base/common/arrays';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
@@ -15,6 +15,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
|
||||
const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer('test');
|
||||
const ViewsRegistry = Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry);
|
||||
|
||||
class ViewDescriptorSequence {
|
||||
|
||||
@@ -63,7 +64,7 @@ suite('ContributableViewsModel', () => {
|
||||
|
||||
const viewDescriptor: IViewDescriptor = {
|
||||
id: 'view1',
|
||||
ctor: null,
|
||||
ctorDescriptor: null!,
|
||||
name: 'Test View 1'
|
||||
};
|
||||
|
||||
@@ -89,7 +90,7 @@ suite('ContributableViewsModel', () => {
|
||||
|
||||
const viewDescriptor: IViewDescriptor = {
|
||||
id: 'view1',
|
||||
ctor: null,
|
||||
ctorDescriptor: null!,
|
||||
name: 'Test View 1',
|
||||
when: ContextKeyExpr.equals('showview1', true)
|
||||
};
|
||||
@@ -128,8 +129,8 @@ suite('ContributableViewsModel', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, name: 'Test View 2', when: ContextKeyExpr.equals('showview2', true) };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctorDescriptor: null!, name: 'Test View 2', when: ContextKeyExpr.equals('showview2', true) };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2], container);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1], 'only view1 should be visible');
|
||||
@@ -151,8 +152,8 @@ suite('ContributableViewsModel', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, name: 'Test View 1', when: ContextKeyExpr.equals('showview1', true) };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, name: 'Test View 2' };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1', when: ContextKeyExpr.equals('showview1', true) };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctorDescriptor: null!, name: 'Test View 2' };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2], container);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view2], 'only view2 should be visible');
|
||||
@@ -174,9 +175,9 @@ suite('ContributableViewsModel', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, name: 'Test View 1', canToggleVisibility: true };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, name: 'Test View 2', canToggleVisibility: true };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctor: null, name: 'Test View 3', canToggleVisibility: true };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1', canToggleVisibility: true };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctorDescriptor: null!, name: 'Test View 2', canToggleVisibility: true };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctorDescriptor: null!, name: 'Test View 3', canToggleVisibility: true };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2, view3], container);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2, view3]);
|
||||
@@ -219,9 +220,9 @@ suite('ContributableViewsModel', () => {
|
||||
const model = new ContributableViewsModel(container, viewsService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, name: 'Test View 2' };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctor: null, name: 'Test View 3' };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctorDescriptor: null!, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctorDescriptor: null!, name: 'Test View 2' };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctorDescriptor: null!, name: 'Test View 3' };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2, view3], container);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2, view3], 'model views should be OK');
|
||||
|
||||
@@ -32,7 +32,7 @@ class FileEditorInput extends EditorInput {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
resolve(): Promise<IEditorModel> {
|
||||
resolve(): Promise<IEditorModel | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
@@ -55,22 +55,22 @@ suite('Workbench editor', () => {
|
||||
test('toResource', () => {
|
||||
const service = accessor.untitledEditorService;
|
||||
|
||||
assert.ok(!toResource(null));
|
||||
assert.ok(!toResource(null!));
|
||||
|
||||
const untitled = service.createOrGet();
|
||||
|
||||
assert.equal(toResource(untitled).toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: true }).toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { filter: Schemas.untitled }).toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { filter: [Schemas.file, Schemas.untitled] }).toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled)!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: true })!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { filter: Schemas.untitled })!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { filter: [Schemas.file, Schemas.untitled] })!.toString(), untitled.getResource().toString());
|
||||
assert.ok(!toResource(untitled, { filter: Schemas.file }));
|
||||
|
||||
const file = new FileEditorInput(URI.file('/some/path.txt'));
|
||||
|
||||
assert.equal(toResource(file).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { filter: Schemas.file }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { filter: [Schemas.file, Schemas.untitled] }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file)!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { filter: Schemas.file })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { filter: [Schemas.file, Schemas.untitled] })!.toString(), file.getResource().toString());
|
||||
assert.ok(!toResource(file, { filter: Schemas.untitled }));
|
||||
|
||||
const diffEditorInput = new DiffEditorInput('name', 'description', untitled, file);
|
||||
@@ -79,8 +79,8 @@ suite('Workbench editor', () => {
|
||||
assert.ok(!toResource(diffEditorInput, { filter: Schemas.file }));
|
||||
assert.ok(!toResource(diffEditorInput, { supportSideBySide: false }));
|
||||
|
||||
assert.equal(toResource(file, { supportSideBySide: true }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true, filter: Schemas.file }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true, filter: [Schemas.file, Schemas.untitled] }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true, filter: Schemas.file })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true, filter: [Schemas.file, Schemas.untitled] })!.toString(), file.getResource().toString());
|
||||
});
|
||||
});
|
||||
@@ -215,7 +215,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('group serialization', function () {
|
||||
Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).setInstantiationService(inst());
|
||||
inst().invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
const group = createGroup();
|
||||
|
||||
const input1 = input();
|
||||
@@ -656,7 +656,7 @@ suite('Workbench editor groups', () => {
|
||||
config.setUserConfiguration('workbench', { editor: { focusRecentEditorAfterClose: false } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
const group = inst.createInstance(EditorGroup);
|
||||
const group = inst.createInstance(EditorGroup, undefined);
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -1003,7 +1003,7 @@ suite('Workbench editor groups', () => {
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories)).setInstantiationService(inst);
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group = createGroup();
|
||||
|
||||
@@ -1037,7 +1037,7 @@ suite('Workbench editor groups', () => {
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories)).setInstantiationService(inst);
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group1 = createGroup();
|
||||
|
||||
@@ -1107,7 +1107,7 @@ suite('Workbench editor groups', () => {
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories)).setInstantiationService(inst);
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group = createGroup();
|
||||
|
||||
@@ -1151,7 +1151,7 @@ suite('Workbench editor groups', () => {
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories)).setInstantiationService(inst);
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group1 = createGroup();
|
||||
let group2 = createGroup();
|
||||
|
||||
@@ -36,9 +36,9 @@ suite('Workbench resource editor input', () => {
|
||||
accessor.modelService.createModel('function test() {}', accessor.modeService.create('text'), resource);
|
||||
let input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource);
|
||||
|
||||
return input.resolve().then((model: ResourceEditorModel) => {
|
||||
return input.resolve().then(model => {
|
||||
assert.ok(model);
|
||||
assert.equal(snapshotToString(model.createSnapshot()), 'function test() {}');
|
||||
assert.equal(snapshotToString((model as ResourceEditorModel).createSnapshot()!), 'function test() {}');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as assert from 'assert';
|
||||
import { join } from 'vs/base/common/paths';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -18,7 +18,7 @@ import { snapshotToString } from 'vs/platform/files/common/files';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
export class TestUntitledEditorService extends UntitledEditorService {
|
||||
get(resource: URI): UntitledEditorInput { return super.get(resource); }
|
||||
get(resource: URI) { return super.get(resource); }
|
||||
getAll(resources?: URI[]): UntitledEditorInput[] { return super.getAll(resources); }
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ suite('Workbench untitled editors', () => {
|
||||
assert.equal(service.getAll().length, 1);
|
||||
|
||||
// dirty
|
||||
input2.resolve().then((model: UntitledEditorModel) => {
|
||||
input2.resolve().then(model => {
|
||||
assert.ok(!service.isDirty(input2.getResource()));
|
||||
|
||||
const listener = service.onDidChangeDirty(resource => {
|
||||
@@ -112,7 +112,7 @@ suite('Workbench untitled editors', () => {
|
||||
const input = service.createOrGet();
|
||||
|
||||
// dirty
|
||||
return input.resolve().then((model: UntitledEditorModel) => {
|
||||
return input.resolve().then(model => {
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
assert.ok(model.isDirty());
|
||||
|
||||
@@ -126,14 +126,14 @@ suite('Workbench untitled editors', () => {
|
||||
test('Untitled via loadOrCreate', function () {
|
||||
const service = accessor.untitledEditorService;
|
||||
service.loadOrCreate().then(model1 => {
|
||||
model1.textEditorModel.setValue('foo bar');
|
||||
model1.textEditorModel!.setValue('foo bar');
|
||||
assert.ok(model1.isDirty());
|
||||
|
||||
model1.textEditorModel.setValue('');
|
||||
model1.textEditorModel!.setValue('');
|
||||
assert.ok(!model1.isDirty());
|
||||
|
||||
return service.loadOrCreate({ initialValue: 'Hello World' }).then(model2 => {
|
||||
assert.equal(snapshotToString(model2.createSnapshot()), 'Hello World');
|
||||
assert.equal(snapshotToString(model2.createSnapshot()!), 'Hello World');
|
||||
|
||||
const input = service.createOrGet();
|
||||
|
||||
@@ -169,7 +169,7 @@ suite('Workbench untitled editors', () => {
|
||||
const input = service.createOrGet(file);
|
||||
|
||||
// dirty
|
||||
return input.resolve().then((model: UntitledEditorModel) => {
|
||||
return input.resolve().then(model => {
|
||||
model.textEditorModel.setValue('foo bar');
|
||||
assert.ok(model.isDirty());
|
||||
|
||||
@@ -223,7 +223,7 @@ suite('Workbench untitled editors', () => {
|
||||
});
|
||||
|
||||
// dirty
|
||||
return input.resolve().then((model: UntitledEditorModel) => {
|
||||
return input.resolve().then(model => {
|
||||
model.setEncoding('utf16');
|
||||
|
||||
assert.equal(counter, 1);
|
||||
@@ -245,7 +245,7 @@ suite('Workbench untitled editors', () => {
|
||||
assert.equal(r.toString(), input.getResource().toString());
|
||||
});
|
||||
|
||||
return input.resolve().then((model: UntitledEditorModel) => {
|
||||
return input.resolve().then(model => {
|
||||
model.textEditorModel.setValue('foo');
|
||||
assert.equal(counter, 0, 'Dirty model should not trigger event immediately');
|
||||
|
||||
@@ -288,7 +288,7 @@ suite('Workbench untitled editors', () => {
|
||||
assert.equal(r.toString(), input.getResource().toString());
|
||||
});
|
||||
|
||||
return input.resolve().then((model: UntitledEditorModel) => {
|
||||
return input.resolve().then(model => {
|
||||
assert.equal(counter, 0);
|
||||
input.dispose();
|
||||
assert.equal(counter, 1);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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]);
|
||||
});
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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; };
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/workbench/parts/files/electron-browser/files.contribution'; // load our contribution into the test
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import 'vs/workbench/contrib/files/browser/files.contribution'; // load our contribution into the test
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, EditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent, IEditorPartOptions } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IPartService, Parts, Position as PartPosition, IDimension } from 'vs/workbench/services/part/common/partService';
|
||||
import { IWorkbenchLayoutService, Parts, Position as PartPosition } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
@@ -26,7 +26,7 @@ import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchS
|
||||
import { ILifecycleService, BeforeShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
|
||||
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings } from 'vs/platform/files/common/files';
|
||||
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings, IResourceEncoding } from 'vs/platform/files/common/files';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
@@ -37,15 +37,14 @@ import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, MenuBarVisibility } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, MenuBarVisibility, IURIToOpen } from 'vs/platform/windows/common/windows';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
|
||||
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
|
||||
import { IMenuService, MenuId, IMenu, ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
@@ -57,13 +56,12 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { IExtensionService, ProfileSession, IExtensionsStatus, ExtensionPointContribution, IExtensionDescription, IWillActivateEvent, IResponsiveStateChangeEvent } from '../services/extensions/common/extensions';
|
||||
import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
|
||||
import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope, EditorGroupLayout } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler, IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IDecorationRenderOptions } from 'vs/editor/common/editorCommon';
|
||||
@@ -73,13 +71,17 @@ import { ILogService, LogLevel } from 'vs/platform/log/common/log';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||
import { ViewletDescriptor, Viewlet } from 'vs/workbench/browser/viewlet';
|
||||
import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { LabelService } from 'vs/workbench/services/label/common/labelService';
|
||||
import { IDimension } from 'vs/platform/layout/browser/layoutService';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { IPanel } from 'vs/workbench/common/panel';
|
||||
import { IBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
|
||||
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined);
|
||||
@@ -140,7 +142,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
return this.workspace;
|
||||
}
|
||||
|
||||
public getWorkspaceFolder(resource: URI): IWorkspaceFolder {
|
||||
public getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
|
||||
return this.workspace.getFolder(resource);
|
||||
}
|
||||
|
||||
@@ -165,7 +167,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
}
|
||||
|
||||
public toResource(workspaceRelativePath: string): URI {
|
||||
return URI.file(paths.join('C:\\', workspaceRelativePath));
|
||||
return URI.file(join('C:\\', workspaceRelativePath));
|
||||
}
|
||||
|
||||
public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
|
||||
@@ -178,24 +180,48 @@ export class TestTextFileService extends TextFileService {
|
||||
|
||||
private promptPath: URI;
|
||||
private confirmResult: ConfirmResult;
|
||||
private resolveTextContentError: FileOperationError;
|
||||
private resolveTextContentError: FileOperationError | null;
|
||||
|
||||
constructor(
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IFileService protected fileService: IFileService,
|
||||
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IWindowService windowService: IWindowService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IBackupFileService backupFileService: IBackupFileService,
|
||||
@IWindowsService windowsService: IWindowsService,
|
||||
@IWindowService windowService: IWindowService,
|
||||
@IHistoryService historyService: IHistoryService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IModelService modelService: IModelService
|
||||
@IDialogService dialogService: IDialogService,
|
||||
@IFileDialogService fileDialogService: IFileDialogService,
|
||||
@IEditorService editorService: IEditorService
|
||||
) {
|
||||
super(lifecycleService, contextService, configurationService, fileService, untitledEditorService, instantiationService, notificationService, TestEnvironmentService, backupFileService, windowsService, windowService, historyService, contextKeyService, modelService);
|
||||
super(
|
||||
contextService,
|
||||
fileService,
|
||||
untitledEditorService,
|
||||
lifecycleService,
|
||||
instantiationService,
|
||||
configurationService,
|
||||
modeService,
|
||||
modelService,
|
||||
windowService,
|
||||
environmentService,
|
||||
notificationService,
|
||||
backupFileService,
|
||||
windowsService,
|
||||
historyService,
|
||||
contextKeyService,
|
||||
dialogService,
|
||||
fileDialogService,
|
||||
editorService
|
||||
);
|
||||
}
|
||||
|
||||
public setPromptPath(path: URI): void {
|
||||
@@ -238,6 +264,10 @@ export class TestTextFileService extends TextFileService {
|
||||
return Promise.resolve(this.confirmResult);
|
||||
}
|
||||
|
||||
public confirmOverwrite(_resource: URI): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public onFilesConfigurationChange(configuration: any): void {
|
||||
super.onFilesConfigurationChange(configuration);
|
||||
}
|
||||
@@ -250,6 +280,7 @@ export class TestTextFileService extends TextFileService {
|
||||
|
||||
export function workbenchInstantiationService(): IInstantiationService {
|
||||
let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
|
||||
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
|
||||
const workspaceContextService = new TestContextService(TestWorkspace);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceContextService);
|
||||
@@ -258,7 +289,7 @@ export function workbenchInstantiationService(): IInstantiationService {
|
||||
instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
|
||||
instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
|
||||
instantiationService.stub(IStorageService, new TestStorageService());
|
||||
instantiationService.stub(IPartService, new TestPartService());
|
||||
instantiationService.stub(IWorkbenchLayoutService, new TestLayoutService());
|
||||
instantiationService.stub(IModeService, instantiationService.createInstance(ModeServiceImpl));
|
||||
instantiationService.stub(IHistoryService, new TestHistoryService());
|
||||
instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
|
||||
@@ -276,7 +307,6 @@ export function workbenchInstantiationService(): IInstantiationService {
|
||||
instantiationService.stub(IWindowsService, new TestWindowsService());
|
||||
instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
|
||||
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
|
||||
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(IThemeService, new TestThemeService());
|
||||
instantiationService.stub(IHashService, new TestHashService());
|
||||
instantiationService.stub(ILogService, new TestLogService());
|
||||
@@ -307,31 +337,10 @@ export class TestDecorationsService implements IDecorationsService {
|
||||
_serviceBrand: any;
|
||||
onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
|
||||
registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }
|
||||
getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration { return undefined; }
|
||||
getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }
|
||||
}
|
||||
|
||||
export class TestExtensionService implements IExtensionService {
|
||||
_serviceBrand: any;
|
||||
onDidRegisterExtensions: Event<void> = Event.None;
|
||||
onDidChangeExtensionsStatus: Event<ExtensionIdentifier[]> = Event.None;
|
||||
onDidChangeExtensions: Event<void> = Event.None;
|
||||
onWillActivateByEvent: Event<IWillActivateEvent> = Event.None;
|
||||
onDidChangeResponsiveChange: Event<IResponsiveStateChangeEvent> = Event.None;
|
||||
activateByEvent(_activationEvent: string): Promise<void> { return Promise.resolve(undefined); }
|
||||
whenInstalledExtensionsRegistered(): Promise<boolean> { return Promise.resolve(true); }
|
||||
getExtensions(): Promise<IExtensionDescription[]> { return Promise.resolve([]); }
|
||||
getExtension() { return Promise.resolve(undefined); }
|
||||
readExtensionPointContributions<T>(_extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]> { return Promise.resolve(Object.create(null)); }
|
||||
getExtensionsStatus(): { [id: string]: IExtensionsStatus; } { return Object.create(null); }
|
||||
canProfileExtensionHost(): boolean { return false; }
|
||||
getInspectPort(): number { return 0; }
|
||||
startExtensionHostProfile(): Promise<ProfileSession> { return Promise.resolve(Object.create(null)); }
|
||||
restartExtensionHost(): void { }
|
||||
startExtensionHost(): void { }
|
||||
stopExtensionHost(): void { }
|
||||
canAddExtension(): boolean { return false; }
|
||||
canRemoveExtension(): boolean { return false; }
|
||||
}
|
||||
export class TestExtensionService extends NullExtensionService { }
|
||||
|
||||
export class TestMenuService implements IMenuService {
|
||||
|
||||
@@ -378,11 +387,11 @@ export class TestHistoryService implements IHistoryService {
|
||||
return [];
|
||||
}
|
||||
|
||||
public getLastActiveWorkspaceRoot(_schemeFilter: string): URI {
|
||||
public getLastActiveWorkspaceRoot(_schemeFilter: string): URI | undefined {
|
||||
return this.root;
|
||||
}
|
||||
|
||||
public getLastActiveFile(_schemeFilter: string): URI {
|
||||
public getLastActiveFile(_schemeFilter: string): URI | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -407,13 +416,13 @@ export class TestFileDialogService implements IFileDialogService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
public defaultFilePath(_schemeFilter: string): URI {
|
||||
public defaultFilePath(_schemeFilter?: string): URI | undefined {
|
||||
return undefined;
|
||||
}
|
||||
public defaultFolderPath(_schemeFilter: string): URI {
|
||||
public defaultFolderPath(_schemeFilter?: string): URI | undefined {
|
||||
return undefined;
|
||||
}
|
||||
public defaultWorkspacePath(_schemeFilter: string): URI {
|
||||
public defaultWorkspacePath(_schemeFilter?: string): URI | undefined {
|
||||
return undefined;
|
||||
}
|
||||
public pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
|
||||
@@ -428,21 +437,27 @@ export class TestFileDialogService implements IFileDialogService {
|
||||
public pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> {
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
public showSaveDialog(_options: ISaveDialogOptions): Promise<URI> {
|
||||
return Promise.resolve();
|
||||
public showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
public showOpenDialog(_options: IOpenDialogOptions): Promise<URI[]> {
|
||||
return Promise.resolve();
|
||||
public showOpenDialog(_options: IOpenDialogOptions): Promise<URI[] | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestPartService implements IPartService {
|
||||
export class TestLayoutService implements IWorkbenchLayoutService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
dimension: IDimension = { width: 800, height: 600 };
|
||||
|
||||
container: HTMLElement = window.document.body;
|
||||
|
||||
onZenModeChange: Event<boolean> = Event.None;
|
||||
onLayout = Event.None;
|
||||
|
||||
private _onTitleBarVisibilityChange = new Emitter<void>();
|
||||
private _onMenubarVisibilityChange = new Emitter<Dimension>();
|
||||
private _onEditorLayout = new Emitter<IDimension>();
|
||||
|
||||
public get onTitleBarVisibilityChange(): Event<void> {
|
||||
return this._onTitleBarVisibilityChange.event;
|
||||
@@ -452,10 +467,6 @@ export class TestPartService implements IPartService {
|
||||
return this._onMenubarVisibilityChange.event;
|
||||
}
|
||||
|
||||
public get onEditorLayout(): Event<IDimension> {
|
||||
return this._onEditorLayout.event;
|
||||
}
|
||||
|
||||
public isRestored(): boolean {
|
||||
return true;
|
||||
}
|
||||
@@ -469,7 +480,7 @@ export class TestPartService implements IPartService {
|
||||
}
|
||||
|
||||
public getContainer(_part: Parts): HTMLElement {
|
||||
return null;
|
||||
return null!;
|
||||
}
|
||||
|
||||
public isTitleBarHidden(): boolean {
|
||||
@@ -494,15 +505,19 @@ export class TestPartService implements IPartService {
|
||||
return false;
|
||||
}
|
||||
|
||||
public setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
|
||||
public get hasWorkbench(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
public setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
|
||||
public setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
|
||||
|
||||
public setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
|
||||
|
||||
public isPanelHidden(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public setPanelHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
|
||||
public setPanelHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
|
||||
|
||||
public toggleMaximizedPanel(): void { }
|
||||
|
||||
@@ -511,7 +526,7 @@ export class TestPartService implements IPartService {
|
||||
}
|
||||
|
||||
public getMenubarVisibility(): MenuBarVisibility {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
public getSideBarPosition() {
|
||||
@@ -523,12 +538,12 @@ export class TestPartService implements IPartService {
|
||||
}
|
||||
|
||||
public setPanelPosition(_position: PartPosition): Promise<void> {
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public addClass(_clazz: string): void { }
|
||||
public removeClass(_clazz: string): void { }
|
||||
public getWorkbenchElement(): HTMLElement { return undefined; }
|
||||
public getWorkbenchElement(): HTMLElement { throw new Error('not implemented'); }
|
||||
|
||||
public toggleZenMode(): void { }
|
||||
|
||||
@@ -537,23 +552,121 @@ export class TestPartService implements IPartService {
|
||||
|
||||
|
||||
public resizePart(_part: Parts, _sizeChange: number): void { }
|
||||
|
||||
public registerPart(part: Part): void { }
|
||||
}
|
||||
|
||||
let activeViewlet: Viewlet = {} as any;
|
||||
|
||||
export class TestViewletService implements IViewletService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
onDidViewletRegisterEmitter = new Emitter<ViewletDescriptor>();
|
||||
onDidViewletDeregisterEmitter = new Emitter<ViewletDescriptor>();
|
||||
onDidViewletOpenEmitter = new Emitter<IViewlet>();
|
||||
onDidViewletCloseEmitter = new Emitter<IViewlet>();
|
||||
|
||||
onDidViewletRegister = this.onDidViewletRegisterEmitter.event;
|
||||
onDidViewletDeregister = this.onDidViewletDeregisterEmitter.event;
|
||||
onDidViewletOpen = this.onDidViewletOpenEmitter.event;
|
||||
onDidViewletClose = this.onDidViewletCloseEmitter.event;
|
||||
|
||||
public openViewlet(id: string, focus?: boolean): Promise<IViewlet> {
|
||||
return Promise.resolve(null!);
|
||||
}
|
||||
|
||||
public getViewlets(): ViewletDescriptor[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public getAllViewlets(): ViewletDescriptor[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public getActiveViewlet(): IViewlet {
|
||||
return activeViewlet;
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
}
|
||||
|
||||
public getDefaultViewletId(): string {
|
||||
return 'workbench.view.explorer';
|
||||
}
|
||||
|
||||
public getViewlet(id: string): ViewletDescriptor | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public getProgressIndicator(id: string) {
|
||||
return null!;
|
||||
}
|
||||
|
||||
public hideActiveViewlet(): void { }
|
||||
|
||||
public getLastActiveViewletId(): string {
|
||||
return undefined!;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestPanelService implements IPanelService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
|
||||
onDidPanelClose = new Emitter<IPanel>().event;
|
||||
|
||||
public openPanel(id: string, focus?: boolean): IPanel {
|
||||
return null!;
|
||||
}
|
||||
|
||||
public getPanels(): any[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public getPinnedPanels(): any[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public getActivePanel(): IViewlet {
|
||||
return activeViewlet;
|
||||
}
|
||||
|
||||
public setPanelEnablement(id: string, enabled: boolean): void { }
|
||||
|
||||
public dispose() {
|
||||
}
|
||||
|
||||
public showActivity(panelId: string, badge: IBadge, clazz?: string): IDisposable {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
public hideActivePanel(): void { }
|
||||
|
||||
public getLastActivePanelId(): string {
|
||||
return undefined!;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestStorageService extends InMemoryStorageService { }
|
||||
|
||||
export class TestEditorGroupsService implements EditorGroupsServiceImpl {
|
||||
export class TestEditorGroupsService implements IEditorGroupsService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
|
||||
constructor(public groups: TestEditorGroup[] = []) { }
|
||||
|
||||
onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
|
||||
onDidActivateGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidAddGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidRemoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidMoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidLayout: Event<IDimension> = Event.None;
|
||||
|
||||
orientation: any;
|
||||
whenRestored: Promise<void> = Promise.resolve(undefined);
|
||||
|
||||
dimension = { width: 800, height: 600 };
|
||||
|
||||
get activeGroup(): IEditorGroup {
|
||||
return this.groups[0];
|
||||
}
|
||||
@@ -573,7 +686,7 @@ export class TestEditorGroupsService implements EditorGroupsServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return undefined!;
|
||||
}
|
||||
|
||||
getLabel(_identifier: number): string {
|
||||
@@ -581,11 +694,11 @@ export class TestEditorGroupsService implements EditorGroupsServiceImpl {
|
||||
}
|
||||
|
||||
findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
activateGroup(_group: number | IEditorGroup): IEditorGroup {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
getSize(_group: number | IEditorGroup): number {
|
||||
@@ -601,21 +714,32 @@ export class TestEditorGroupsService implements EditorGroupsServiceImpl {
|
||||
setGroupOrientation(_orientation: any): void { }
|
||||
|
||||
addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
removeGroup(_group: number | IEditorGroup): void { }
|
||||
|
||||
moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
centerLayout(active: boolean): void { }
|
||||
|
||||
isLayoutCentered(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
partOptions: IEditorPartOptions;
|
||||
enforcePartOptions(options: IEditorPartOptions): IDisposable {
|
||||
return Disposable.None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,8 +747,8 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
|
||||
constructor(public id: number) { }
|
||||
|
||||
group: EditorGroup = undefined;
|
||||
activeControl: IEditor;
|
||||
get group(): EditorGroup { throw new Error('not implemented'); }
|
||||
activeControl: IVisibleEditor;
|
||||
activeEditor: IEditorInput;
|
||||
previewEditor: IEditorInput;
|
||||
count: number;
|
||||
@@ -652,7 +776,7 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
}
|
||||
|
||||
getEditor(_index: number): IEditorInput {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
getIndexOfEditor(_editor: IEditorInput): number {
|
||||
@@ -660,11 +784,11 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
}
|
||||
|
||||
openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
|
||||
return Promise.resolve(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
|
||||
return Promise.resolve(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
isOpened(_editor: IEditorInput): boolean {
|
||||
@@ -683,11 +807,11 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
|
||||
copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
|
||||
|
||||
closeEditor(_editor?: IEditorInput): Promise<void> {
|
||||
closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
closeEditors(_editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): Promise<void> {
|
||||
closeEditors(_editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }, options?: ICloseEditorOptions): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -704,7 +828,7 @@ export class TestEditorGroup implements IEditorGroupView {
|
||||
focus(): void { }
|
||||
|
||||
invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
|
||||
return fn(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
isEmpty(): boolean { return true; }
|
||||
@@ -725,11 +849,11 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;
|
||||
|
||||
activeControl: IEditor;
|
||||
activeControl: IVisibleEditor;
|
||||
activeTextEditorWidget: any;
|
||||
activeEditor: IEditorInput;
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
visibleControls: ReadonlyArray<IEditor> = [];
|
||||
visibleControls: ReadonlyArray<IVisibleEditor> = [];
|
||||
visibleTextEditorWidgets = [];
|
||||
visibleEditors: ReadonlyArray<IEditorInput> = [];
|
||||
|
||||
@@ -737,12 +861,12 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
return toDisposable(() => undefined);
|
||||
}
|
||||
|
||||
openEditor(_editor: any, _options?: any, _group?: any) {
|
||||
return Promise.resolve(null);
|
||||
openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
openEditors(_editors: any, _group?: any) {
|
||||
return Promise.resolve(null);
|
||||
openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
|
||||
@@ -750,7 +874,7 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
}
|
||||
|
||||
getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
|
||||
return undefined;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
replaceEditors(_editors: any, _group: any) {
|
||||
@@ -758,11 +882,11 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
}
|
||||
|
||||
invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
|
||||
return fn(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +937,7 @@ export class TestFileService implements IFileService {
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
isDirectory: false,
|
||||
name: paths.basename(resource.fsPath)
|
||||
name: resources.basename(resource)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -822,7 +946,7 @@ export class TestFileService implements IFileService {
|
||||
}
|
||||
|
||||
existsFile(_resource: URI): Promise<boolean> {
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
resolveContent(resource: URI, _options?: IResolveContentOptions): Promise<IContent> {
|
||||
@@ -832,7 +956,7 @@ export class TestFileService implements IFileService {
|
||||
etag: 'index.txt',
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
name: paths.basename(resource.fsPath)
|
||||
name: resources.basename(resource)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -852,7 +976,7 @@ export class TestFileService implements IFileService {
|
||||
etag: 'index.txt',
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
name: paths.basename(resource.fsPath)
|
||||
name: resources.basename(resource)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -863,20 +987,20 @@ export class TestFileService implements IFileService {
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
isDirectory: false,
|
||||
name: paths.basename(resource.fsPath)
|
||||
name: resources.basename(resource)
|
||||
}));
|
||||
}
|
||||
|
||||
moveFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStat> {
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve(null!);
|
||||
}
|
||||
|
||||
copyFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStat> {
|
||||
return Promise.resolve(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): Promise<IFileStat> {
|
||||
return Promise.resolve(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
readFolder(_resource: URI) {
|
||||
@@ -884,7 +1008,7 @@ export class TestFileService implements IFileService {
|
||||
}
|
||||
|
||||
createFolder(_resource: URI): Promise<IFileStat> {
|
||||
return Promise.resolve(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
onDidChangeFileSystemProviderRegistrations = Event.None;
|
||||
@@ -893,8 +1017,8 @@ export class TestFileService implements IFileService {
|
||||
return { dispose() { } };
|
||||
}
|
||||
|
||||
activateProvider(_scheme: string) {
|
||||
return Promise.resolve(null);
|
||||
activateProvider(_scheme: string): Promise<void> {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
canHandleResource(resource: URI): boolean {
|
||||
@@ -902,7 +1026,7 @@ export class TestFileService implements IFileService {
|
||||
}
|
||||
|
||||
del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
watchFileChanges(_resource: URI): void {
|
||||
@@ -911,8 +1035,8 @@ export class TestFileService implements IFileService {
|
||||
unwatchFileChanges(_resource: URI): void {
|
||||
}
|
||||
|
||||
getWriteEncoding(_resource: URI): string {
|
||||
return 'utf8';
|
||||
getWriteEncoding(_resource: URI): IResourceEncoding {
|
||||
return { encoding: 'utf8', hasBOM: false };
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
@@ -930,7 +1054,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
public loadBackupResource(resource: URI): Promise<URI> {
|
||||
public loadBackupResource(resource: URI): Promise<URI | undefined> {
|
||||
return this.hasBackup(resource).then(hasBackup => {
|
||||
if (hasBackup) {
|
||||
return this.toBackupResource(resource);
|
||||
@@ -949,7 +1073,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
}
|
||||
|
||||
public toBackupResource(_resource: URI): URI {
|
||||
return null;
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
|
||||
@@ -968,7 +1092,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
}
|
||||
|
||||
public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
|
||||
return Promise.resolve(null);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
public discardResourceBackup(_resource: URI): Promise<void> {
|
||||
@@ -995,14 +1119,14 @@ export class TestCodeEditorService implements ICodeEditorService {
|
||||
addDiffEditor(_editor: IDiffEditor): void { }
|
||||
removeDiffEditor(_editor: IDiffEditor): void { }
|
||||
listDiffEditors(): IDiffEditor[] { return []; }
|
||||
getFocusedCodeEditor(): ICodeEditor { return null; }
|
||||
getFocusedCodeEditor(): ICodeEditor | null { return null; }
|
||||
registerDecorationType(_key: string, _options: IDecorationRenderOptions, _parentTypeKey?: string): void { }
|
||||
removeDecorationType(_key: string): void { }
|
||||
resolveDecorationOptions(_typeKey: string, _writable: boolean): IModelDecorationOptions { return Object.create(null); }
|
||||
setTransientModelProperty(_model: ITextModel, _key: string, _value: any): void { }
|
||||
getTransientModelProperty(_model: ITextModel, _key: string) { }
|
||||
getActiveCodeEditor(): ICodeEditor { return null; }
|
||||
openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor> { return Promise.resolve(); }
|
||||
getActiveCodeEditor(): ICodeEditor | null { return null; }
|
||||
openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | null> { return Promise.resolve(null); }
|
||||
}
|
||||
|
||||
export class TestWindowService implements IWindowService {
|
||||
@@ -1062,8 +1186,8 @@ export class TestWindowService implements IWindowService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult> {
|
||||
return Promise.resolve();
|
||||
enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
toggleFullScreen(): Promise<void> {
|
||||
@@ -1075,7 +1199,10 @@ export class TestWindowService implements IWindowService {
|
||||
}
|
||||
|
||||
getRecentlyOpened(): Promise<IRecentlyOpened> {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve({
|
||||
workspaces: [],
|
||||
files: []
|
||||
});
|
||||
}
|
||||
|
||||
focusWindow(): Promise<void> {
|
||||
@@ -1094,7 +1221,7 @@ export class TestWindowService implements IWindowService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
openWindow(_paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
|
||||
openWindow(_uris: IURIToOpen[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -1119,11 +1246,11 @@ export class TestWindowService implements IWindowService {
|
||||
}
|
||||
|
||||
showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
|
||||
return Promise.resolve(undefined);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
|
||||
return Promise.resolve(undefined);
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
|
||||
@@ -1223,8 +1350,8 @@ export class TestWindowsService implements IWindowsService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult> {
|
||||
return Promise.resolve();
|
||||
enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
toggleFullScreen(_windowId: number): Promise<void> {
|
||||
@@ -1235,7 +1362,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
addRecentlyOpened(_files: URI[]): Promise<void> {
|
||||
addRecentlyOpened(_recents: IRecent[]): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -1248,7 +1375,10 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve({
|
||||
workspaces: [],
|
||||
files: []
|
||||
});
|
||||
}
|
||||
|
||||
focusWindow(_windowId: number): Promise<void> {
|
||||
@@ -1260,7 +1390,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
isMaximized(_windowId: number): Promise<boolean> {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
maximizeWindow(_windowId: number): Promise<void> {
|
||||
@@ -1300,7 +1430,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
// Global methods
|
||||
openWindow(_windowId: number, _paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
|
||||
openWindow(_windowId: number, _uris: IURIToOpen[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -1313,7 +1443,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
|
||||
return Promise.resolve();
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
getWindowCount(): Promise<number> {
|
||||
@@ -1324,7 +1454,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
showItemInFolder(_path: string): Promise<void> {
|
||||
showItemInFolder(_path: URI): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -1372,15 +1502,15 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
|
||||
return Promise.resolve();
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
|
||||
return Promise.resolve();
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
showOpenDialog(_windowId: number, _options: Electron.OpenDialogOptions): Promise<string[]> {
|
||||
return Promise.resolve();
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
openAboutDialog(): Promise<void> {
|
||||
@@ -1404,8 +1534,8 @@ export class TestTextResourceConfigurationService implements ITextResourceConfig
|
||||
}
|
||||
|
||||
getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
|
||||
const position: IPosition = EditorPosition.isIPosition(arg2) ? arg2 : null;
|
||||
const section: string = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
|
||||
const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
|
||||
const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
|
||||
return this.configurationService.getValue(section, { resource });
|
||||
}
|
||||
}
|
||||
@@ -1434,36 +1564,18 @@ export class TestTextResourcePropertiesService implements ITextResourcePropertie
|
||||
export class TestHashService implements IHashService {
|
||||
_serviceBrand: any;
|
||||
|
||||
createSHA1(content: string): string {
|
||||
return content;
|
||||
createSHA1(content: string): Thenable<string> {
|
||||
return Promise.resolve(content);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestViewletService implements IViewletService {
|
||||
export class TestSharedProcessService implements ISharedProcessService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
|
||||
readonly onDidViewletRegister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
|
||||
readonly onDidViewletDeregister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
|
||||
onDidViewletOpen: Event<IViewlet> = new Emitter<IViewlet>().event;
|
||||
onDidViewletClose: Event<IViewlet> = new Emitter<IViewlet>().event;
|
||||
getChannel(channelName: string): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
openViewlet(_id: string, _focus?: boolean): Promise<IViewlet> { return null; }
|
||||
|
||||
getActiveViewlet(): IViewlet { return null; }
|
||||
|
||||
getDefaultViewletId(): string { return null; }
|
||||
|
||||
getViewlet(_id: string): ViewletDescriptor { return null; }
|
||||
|
||||
getAllViewlets(): ViewletDescriptor[] { return null; }
|
||||
|
||||
getViewlets(): ViewletDescriptor[] { return null; }
|
||||
|
||||
getProgressIndicator(_id: string): IProgressService { return null; }
|
||||
|
||||
}
|
||||
|
||||
export function getRandomTestPath(tmpdir: string, ...segments: string[]): string {
|
||||
return paths.join(tmpdir, ...segments, generateUuid());
|
||||
}
|
||||
registerChannel(channelName: string, channel: any): void { }
|
||||
}
|
||||
Reference in New Issue
Block a user