mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -10,13 +10,6 @@ import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { prepareActions } from 'vs/workbench/browser/actions';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
|
||||
|
||||
class MyClass extends Action {
|
||||
constructor(id: string, label: string) {
|
||||
super(id, label);
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench Action Registry', () => {
|
||||
|
||||
test('Workbench Action Bar prepareActions()', function () {
|
||||
|
||||
@@ -70,12 +70,12 @@ class MyInputFactory implements IEditorInputFactory {
|
||||
}
|
||||
|
||||
deserialize(instantiationService: IInstantiationService, raw: string): EditorInput {
|
||||
return <EditorInput>{};
|
||||
return {} as EditorInput;
|
||||
}
|
||||
}
|
||||
|
||||
class MyInput extends EditorInput {
|
||||
getPreferredEditorId(ids) {
|
||||
getPreferredEditorId(ids: string[]) {
|
||||
return ids[1];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,12 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Position, Direction } from 'vs/platform/editor/common/editor';
|
||||
import { Position, Direction, IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
function create(): EditorStacksModel {
|
||||
let inst = new TestInstantiationService();
|
||||
@@ -60,7 +61,7 @@ interface GroupEvents {
|
||||
}
|
||||
|
||||
function modelListener(model: EditorStacksModel): ModelEvents {
|
||||
const modelEvents = {
|
||||
const modelEvents: ModelEvents = {
|
||||
opened: [],
|
||||
activated: [],
|
||||
closed: [],
|
||||
@@ -86,7 +87,7 @@ function modelListener(model: EditorStacksModel): ModelEvents {
|
||||
}
|
||||
|
||||
function groupListener(group: EditorGroup): GroupEvents {
|
||||
const groupEvents = {
|
||||
const groupEvents: GroupEvents = {
|
||||
opened: [],
|
||||
closed: [],
|
||||
activated: [],
|
||||
@@ -111,7 +112,7 @@ class TestEditorInput extends EditorInput {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testEditorInput'; }
|
||||
public resolve() { return null; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
@@ -131,7 +132,7 @@ class NonSerializableTestEditorInput extends EditorInput {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testEditorInput-nonSerializable'; }
|
||||
public resolve() { return null; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof NonSerializableTestEditorInput;
|
||||
@@ -144,7 +145,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testFileEditorInput'; }
|
||||
public resolve() { return null; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestFileEditorInput;
|
||||
@@ -364,6 +365,7 @@ suite('Editor Stacks Model', () => {
|
||||
|
||||
model.moveGroup(group3, 1);
|
||||
assert.equal(events.moved.length, 2);
|
||||
assert.ok(group2);
|
||||
});
|
||||
|
||||
test('Groups - Event Aggregation', function () {
|
||||
@@ -504,7 +506,7 @@ suite('Editor Stacks Model', () => {
|
||||
assert.equal(group.activeEditor, void 0);
|
||||
assert.equal(events.closed[0].editor, input1);
|
||||
assert.equal(events.closed[0].index, 0);
|
||||
assert.equal(events.closed[0].pinned, true);
|
||||
assert.equal(events.closed[0].replaced, false);
|
||||
|
||||
// Active && Preview
|
||||
const input2 = input();
|
||||
@@ -527,7 +529,7 @@ suite('Editor Stacks Model', () => {
|
||||
assert.equal(group.activeEditor, void 0);
|
||||
assert.equal(events.closed[1].editor, input2);
|
||||
assert.equal(events.closed[1].index, 0);
|
||||
assert.equal(events.closed[1].pinned, false);
|
||||
assert.equal(events.closed[1].replaced, false);
|
||||
|
||||
group.closeEditor(input2);
|
||||
assert.equal(group.count, 0);
|
||||
@@ -746,6 +748,8 @@ suite('Editor Stacks Model', () => {
|
||||
assert.equal(events.opened[2], input3);
|
||||
assert.equal(events.closed[0].editor, input1);
|
||||
assert.equal(events.closed[1].editor, input2);
|
||||
assert.equal(events.closed[0].replaced, true);
|
||||
assert.equal(events.closed[1].replaced, true);
|
||||
|
||||
const mru = group.getEditors(true);
|
||||
assert.equal(mru[0], input3);
|
||||
@@ -1497,6 +1501,13 @@ suite('Editor Stacks Model', () => {
|
||||
previous = model.previous(true /* jump groups */);
|
||||
assert.equal(previous.group, group1);
|
||||
assert.equal(previous.editor, input3);
|
||||
|
||||
model.setActive(<EditorGroup>previous.group);
|
||||
(<EditorGroup>next.group).setActive(<EditorInput>previous.editor);
|
||||
|
||||
const last = model.last();
|
||||
assert.equal(last.group, group1);
|
||||
assert.equal(last.editor, input3);
|
||||
});
|
||||
|
||||
test('Stack - Multiple Editors - Navigation (in group)', function () {
|
||||
|
||||
@@ -11,10 +11,9 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import WorkbenchEditorService = require('vs/workbench/services/editor/common/editorService');
|
||||
import { RangeHighlightDecorations } from 'vs/workbench/common/editor/rangeDecorations';
|
||||
import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { mockCodeEditor } from 'vs/editor/test/common/mocks/mockCodeEditor';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { IEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
@@ -23,15 +22,13 @@ import { Position } from 'vs/editor/common/core/position';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { CoreNavigationCommands } from 'vs/editor/common/controller/coreCommands';
|
||||
import { CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
suite('Editor - Range decorations', () => {
|
||||
|
||||
let instantiationService: TestInstantiationService;
|
||||
let editorService: WorkbenchEditorService.IWorkbenchEditorService;
|
||||
let modelService: IModelService;
|
||||
let modeService: IModeService;
|
||||
let codeEditor: editorCommon.ICommonCodeEditor;
|
||||
let codeEditor: ICodeEditor;
|
||||
let model: Model;
|
||||
let text: string;
|
||||
let testObject: RangeHighlightDecorations;
|
||||
@@ -39,12 +36,12 @@ suite('Editor - Range decorations', () => {
|
||||
|
||||
setup(() => {
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
editorService = <WorkbenchEditorService.IWorkbenchEditorService>instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, new TestEditorService());
|
||||
modeService = instantiationService.stub(IModeService, ModeServiceImpl);
|
||||
modelService = <IModelService>instantiationService.stub(IModelService, stubModelService(instantiationService));
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, new TestEditorService());
|
||||
instantiationService.stub(IModeService, ModeServiceImpl);
|
||||
instantiationService.stub(IModelService, stubModelService(instantiationService));
|
||||
text = 'LINE1' + '\n' + 'LINE2' + '\n' + 'LINE3' + '\n' + 'LINE4' + '\r\n' + 'LINE5';
|
||||
model = aModel(URI.file('some_file'));
|
||||
codeEditor = mockCodeEditor([], { model });
|
||||
codeEditor = createTestCodeEditor(model);
|
||||
mockEditorService(codeEditor.getModel().uri);
|
||||
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, 'getActiveEditor', { getControl: () => { return codeEditor; } });
|
||||
@@ -172,4 +169,4 @@ suite('Editor - Range decorations', () => {
|
||||
instantiationService.stub(IConfigurationService, new TestConfigurationService());
|
||||
return instantiationService.createInstance(ModelServiceImpl);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { DataUriEditorInput } from 'vs/workbench/common/editor/dataUriEditorInput';
|
||||
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
|
||||
|
||||
suite('Workbench - DataUriEditorInput', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
|
||||
setup(() => {
|
||||
instantiationService = workbenchInstantiationService();
|
||||
});
|
||||
|
||||
test('simple', function () {
|
||||
const resource = URI.parse('data:image/png;label:SomeLabel;description:SomeDescription;size:1024;base64,77+9UE5');
|
||||
const input: DataUriEditorInput = instantiationService.createInstance(DataUriEditorInput, void 0, void 0, resource);
|
||||
|
||||
assert.equal(input.getName(), 'SomeLabel');
|
||||
assert.equal(input.getDescription(), 'SomeDescription');
|
||||
|
||||
return input.resolve().then((model: BinaryEditorModel) => {
|
||||
assert.ok(model);
|
||||
assert.equal(model.getSize(), 1024);
|
||||
assert.equal(model.getMime(), 'image/png');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -6,8 +6,6 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EditorModel } from 'vs/workbench/common/editor';
|
||||
import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel';
|
||||
import { TextDiffEditorModel } from 'vs/workbench/common/editor/textDiffEditorModel';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -21,9 +19,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IModel } from 'vs/editor/common/editorCommon';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
class MyEditorModel extends EditorModel { }
|
||||
class MyTextEditorModel extends BaseTextEditorModel { }
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@ITextModelService public textModelResolverService: ITextModelService,
|
||||
|
||||
@@ -13,8 +13,8 @@ import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
|
||||
suite('Workbench Memento', () => {
|
||||
let context;
|
||||
let storage;
|
||||
let context: Scope = undefined;
|
||||
let storage: StorageService;
|
||||
|
||||
setup(() => {
|
||||
storage = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
|
||||
@@ -70,9 +70,9 @@ suite('Workbench Memento', () => {
|
||||
assert.deepEqual(memento, {});
|
||||
|
||||
// Assert the Mementos are also removed from storage
|
||||
assert.strictEqual(storage.get('memento/memento.test', Scope.GLOBAL, null), null);
|
||||
assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null), null);
|
||||
|
||||
assert.strictEqual(storage.get('memento/memento.test', Scope.WORKSPACE, null), null);
|
||||
assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null), null);
|
||||
});
|
||||
|
||||
test('Save and Load', () => {
|
||||
|
||||
@@ -31,6 +31,8 @@ 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 { NoopLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
const defaultSelector = { scheme: 'far' };
|
||||
const model: EditorCommon.IModel = EditorModel.createFromString(
|
||||
@@ -112,7 +114,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
const heapService = new ExtHostHeapService();
|
||||
|
||||
commands = new ExtHostCommands(threadService, heapService);
|
||||
commands = new ExtHostCommands(threadService, heapService, new NoopLogService());
|
||||
threadService.set(ExtHostContext.ExtHostCommands, commands);
|
||||
threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService));
|
||||
ExtHostApiCommands.register(commands);
|
||||
@@ -131,6 +133,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
suiteTeardown(() => {
|
||||
setUnexpectedErrorHandler(originalErrorHandler);
|
||||
model.dispose();
|
||||
mainThread.dispose();
|
||||
});
|
||||
|
||||
teardown(function (done) {
|
||||
@@ -193,6 +196,22 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('executeWorkspaceSymbolProvider should accept empty string, #39522', async function () {
|
||||
|
||||
disposables.push(extHost.registerWorkspaceSymbolProvider({
|
||||
provideWorkspaceSymbols(query) {
|
||||
return [new types.SymbolInformation('hello', types.SymbolKind.Array, new types.Range(0, 0, 0, 0), URI.parse('foo:bar'))];
|
||||
}
|
||||
}));
|
||||
|
||||
await threadService.sync();
|
||||
let symbols = await commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeWorkspaceSymbolProvider', '');
|
||||
assert.equal(symbols.length, 1);
|
||||
|
||||
await threadService.sync();
|
||||
symbols = await commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeWorkspaceSymbolProvider', '*');
|
||||
assert.equal(symbols.length, 1);
|
||||
});
|
||||
|
||||
// --- definition
|
||||
|
||||
@@ -368,8 +387,8 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
// --- quickfix
|
||||
|
||||
test('QuickFix, back and forth', function () {
|
||||
disposables.push(extHost.registerCodeActionProvider(defaultSelector, <vscode.CodeActionProvider>{
|
||||
provideCodeActions(): any {
|
||||
disposables.push(extHost.registerCodeActionProvider(defaultSelector, {
|
||||
provideCodeActions(): vscode.Command[] {
|
||||
return [{ command: 'testing', title: 'Title', arguments: [1, 2, true] }];
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { OneGetThreadService } from './testThreadService';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { NoopLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
suite('ExtHostCommands', function () {
|
||||
|
||||
@@ -29,7 +30,7 @@ suite('ExtHostCommands', function () {
|
||||
}
|
||||
};
|
||||
|
||||
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined);
|
||||
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
|
||||
commands.registerCommand('foo', (): any => { }).dispose();
|
||||
assert.equal(lastUnregister, 'foo');
|
||||
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
|
||||
@@ -50,7 +51,7 @@ suite('ExtHostCommands', function () {
|
||||
}
|
||||
};
|
||||
|
||||
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined);
|
||||
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
|
||||
const reg = commands.registerCommand('foo', (): any => { });
|
||||
reg.dispose();
|
||||
reg.dispose();
|
||||
|
||||
@@ -25,7 +25,7 @@ suite('ExtHostConfiguration', function () {
|
||||
this.lastArgs = [target, key, value];
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createExtHostConfiguration(contents: any = Object.create(null), shape?: MainThreadConfigurationShape) {
|
||||
if (!shape) {
|
||||
@@ -91,6 +91,47 @@ suite('ExtHostConfiguration', function () {
|
||||
assert.deepEqual(config.get('nested'), { config1: 42, config2: 'Das Pferd frisst kein Reis.' });
|
||||
});
|
||||
|
||||
test('can modify the returned configuration', function () {
|
||||
|
||||
const all = createExtHostConfiguration({
|
||||
'farboo': {
|
||||
'config0': true,
|
||||
'nested': {
|
||||
'config1': 42,
|
||||
'config2': 'Das Pferd frisst kein Reis.'
|
||||
},
|
||||
'config4': ''
|
||||
}
|
||||
});
|
||||
|
||||
let testObject = all.getConfiguration();
|
||||
let actual = testObject.get('farboo');
|
||||
actual['farboo1'] = 'newValue';
|
||||
assert.equal('newValue', actual['farboo1']);
|
||||
|
||||
testObject = all.getConfiguration();
|
||||
testObject['farboo']['farboo1'] = 'newValue';
|
||||
assert.equal('newValue', testObject['farboo']['farboo1']);
|
||||
|
||||
testObject = all.getConfiguration();
|
||||
testObject['farboo']['farboo1'] = 'newValue';
|
||||
assert.equal('newValue', testObject.get('farboo')['farboo1']);
|
||||
|
||||
testObject = all.getConfiguration();
|
||||
actual = testObject.inspect('farboo');
|
||||
actual['value'] = 'effectiveValue';
|
||||
assert.equal('effectiveValue', actual['value']);
|
||||
|
||||
testObject = all.getConfiguration();
|
||||
actual = testObject.get('farboo');
|
||||
assert.equal(undefined, actual['farboo1']);
|
||||
|
||||
testObject = all.getConfiguration();
|
||||
testObject['farboo']['farboo1'] = 'newValue';
|
||||
testObject = all.getConfiguration();
|
||||
assert.equal(undefined, testObject['farboo']['farboo1']);
|
||||
});
|
||||
|
||||
test('inspect in no workspace context', function () {
|
||||
const testObject = new ExtHostConfiguration(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
|
||||
@@ -24,7 +24,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
$clear(owner: string): TPromise<any> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test('disposeCheck', function () {
|
||||
|
||||
@@ -35,6 +35,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
assert.throws(() => collection.name);
|
||||
assert.throws(() => collection.clear());
|
||||
assert.throws(() => collection.delete(URI.parse('aa:bb')));
|
||||
// tslint:disable-next-line:semicolon
|
||||
assert.throws(() => collection.forEach(() => { ; }));
|
||||
assert.throws(() => collection.get(URI.parse('aa:bb')));
|
||||
assert.throws(() => collection.has(URI.parse('aa:bb')));
|
||||
|
||||
@@ -42,18 +42,18 @@ suite('ExtHostDocumentData', () => {
|
||||
});
|
||||
|
||||
test('readonly-ness', function () {
|
||||
assert.throws(() => (<any>data).document.uri = null);
|
||||
assert.throws(() => (<any>data).document.fileName = 'foofile');
|
||||
assert.throws(() => (<any>data).document.isDirty = false);
|
||||
assert.throws(() => (<any>data).document.isUntitled = false);
|
||||
assert.throws(() => (<any>data).document.languageId = 'dddd');
|
||||
assert.throws(() => (<any>data).document.lineCount = 9);
|
||||
assert.throws((): void => (data as any).document.uri = null);
|
||||
assert.throws(() => (data as any).document.fileName = 'foofile');
|
||||
assert.throws(() => (data as any).document.isDirty = false);
|
||||
assert.throws(() => (data as any).document.isUntitled = false);
|
||||
assert.throws(() => (data as any).document.languageId = 'dddd');
|
||||
assert.throws(() => (data as any).document.lineCount = 9);
|
||||
});
|
||||
|
||||
test('save, when disposed', function () {
|
||||
let saved: URI;
|
||||
let data = new ExtHostDocumentData(new class extends mock<MainThreadDocumentsShape>() {
|
||||
$trySaveDocument(uri) {
|
||||
$trySaveDocument(uri: URI) {
|
||||
assert.ok(!saved);
|
||||
saved = uri;
|
||||
return TPromise.as(true);
|
||||
|
||||
@@ -24,26 +24,27 @@ import { MainThreadCommands } from 'vs/workbench/api/electron-browser/mainThread
|
||||
import { IHeapService } from 'vs/workbench/api/electron-browser/mainThreadHeapService';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors';
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/common/quickOpen';
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
|
||||
import { DocumentSymbolProviderRegistry, DocumentHighlightKind, Hover } from 'vs/editor/common/modes';
|
||||
import { getCodeLensData } from 'vs/editor/contrib/codelens/browser/codelens';
|
||||
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition } from 'vs/editor/contrib/goToDeclaration/browser/goToDeclaration';
|
||||
import { getHover } from 'vs/editor/contrib/hover/common/hover';
|
||||
import { getOccurrencesAtPosition } from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter';
|
||||
import { provideReferences } from 'vs/editor/contrib/referenceSearch/browser/referenceSearch';
|
||||
import { getCodeActions } from 'vs/editor/contrib/quickFix/browser/quickFix';
|
||||
import { getCodeLensData } from 'vs/editor/contrib/codelens/codelens';
|
||||
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition } from 'vs/editor/contrib/goToDeclaration/goToDeclaration';
|
||||
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/quickFix/quickFix';
|
||||
import { getWorkspaceSymbols } from 'vs/workbench/parts/search/common/search';
|
||||
import { rename } from 'vs/editor/contrib/rename/browser/rename';
|
||||
import { provideSignatureHelp } from 'vs/editor/contrib/parameterHints/common/parameterHints';
|
||||
import { provideSuggestionItems } from 'vs/editor/contrib/suggest/browser/suggest';
|
||||
import { getDocumentFormattingEdits, getDocumentRangeFormattingEdits, getOnTypeFormattingEdits } from 'vs/editor/contrib/format/common/format';
|
||||
import { getLinks } from 'vs/editor/contrib/links/common/links';
|
||||
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 { getLinks } from 'vs/editor/contrib/links/getLinks';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
|
||||
import * as vscode from 'vscode';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { NoopLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
const defaultSelector = { scheme: 'far' };
|
||||
const model: EditorCommon.IModel = EditorModel.createFromString(
|
||||
@@ -102,7 +103,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
const heapService = new ExtHostHeapService();
|
||||
|
||||
const commands = new ExtHostCommands(threadService, heapService);
|
||||
const commands = new ExtHostCommands(threadService, heapService, new NoopLogService());
|
||||
threadService.set(ExtHostContext.ExtHostCommands, commands);
|
||||
threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService));
|
||||
|
||||
@@ -118,6 +119,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
suiteTeardown(() => {
|
||||
setUnexpectedErrorHandler(originalErrorHandler);
|
||||
model.dispose();
|
||||
mainThread.dispose();
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
@@ -641,11 +643,11 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
test('Quick Fix, data conversion', function () {
|
||||
|
||||
disposables.push(extHost.registerCodeActionProvider(defaultSelector, <vscode.CodeActionProvider>{
|
||||
provideCodeActions(): any {
|
||||
disposables.push(extHost.registerCodeActionProvider(defaultSelector, {
|
||||
provideCodeActions(): vscode.Command[] {
|
||||
return [
|
||||
<vscode.Command>{ command: 'test1', title: 'Testing1' },
|
||||
<vscode.Command>{ command: 'test2', title: 'Testing2' }
|
||||
{ command: 'test1', title: 'Testing1' },
|
||||
{ command: 'test2', title: 'Testing2' }
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -654,11 +656,11 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
return getCodeActions(model, model.getFullModelRange()).then(value => {
|
||||
assert.equal(value.length, 2);
|
||||
|
||||
let [first, second] = value;
|
||||
const [first, second] = value;
|
||||
assert.equal(first.title, 'Testing1');
|
||||
assert.equal(first.id, 'test1');
|
||||
assert.equal(first.command.id, 'test1');
|
||||
assert.equal(second.title, 'Testing2');
|
||||
assert.equal(second.id, 'test2');
|
||||
assert.equal(second.command.id, 'test2');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -732,6 +734,24 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
// --- rename
|
||||
|
||||
test('Rename, evil provider 0/2', function () {
|
||||
|
||||
disposables.push(extHost.registerRenameProvider(defaultSelector, <vscode.RenameProvider>{
|
||||
provideRenameEdits(): any {
|
||||
throw new class Foo { };
|
||||
}
|
||||
}));
|
||||
|
||||
return threadService.sync().then(() => {
|
||||
|
||||
return rename(model, new EditorPosition(1, 1), 'newName').then(value => {
|
||||
throw Error();
|
||||
}, err => {
|
||||
// expected
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('Rename, evil provider 1/2', function () {
|
||||
|
||||
disposables.push(extHost.registerRenameProvider(defaultSelector, <vscode.RenameProvider>{
|
||||
@@ -743,9 +763,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
return threadService.sync().then(() => {
|
||||
|
||||
return rename(model, new EditorPosition(1, 1), 'newName').then(value => {
|
||||
throw new Error('');
|
||||
}, err => {
|
||||
// expected
|
||||
assert.equal(value.rejectReason, 'evil');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,22 +9,23 @@ import * as assert from 'assert';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { MainThreadMessageService } from 'vs/workbench/api/electron-browser/mainThreadMessageService';
|
||||
import { TPromise as Promise } from 'vs/base/common/winjs.base';
|
||||
import { IMessageService, IChoiceService } from 'vs/platform/message/common/message';
|
||||
|
||||
suite('ExtHostMessageService', function () {
|
||||
|
||||
test('propagte handle on select', function () {
|
||||
|
||||
let service = new MainThreadMessageService(null, null, <any>{
|
||||
show(sev: number, m: { message; actions: Action[] }) {
|
||||
let service = new MainThreadMessageService(null, {
|
||||
show(sev: number, m: { actions: Action[] }) {
|
||||
assert.equal(m.actions.length, 1);
|
||||
setImmediate(() => m.actions[0].run());
|
||||
return () => { };
|
||||
}
|
||||
}, <any>{
|
||||
choose() {
|
||||
} as IMessageService, {
|
||||
choose(severity, message, options, modal) {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
return service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => {
|
||||
assert.equal(handle, 42);
|
||||
@@ -34,15 +35,15 @@ suite('ExtHostMessageService', function () {
|
||||
test('isCloseAffordance', function () {
|
||||
|
||||
let actions: Action[];
|
||||
let service = new MainThreadMessageService(null, null, <any>{
|
||||
show(sev: number, m: { message; actions: Action[] }) {
|
||||
let service = new MainThreadMessageService(null, {
|
||||
show(sev: number, m: { actions: Action[] }) {
|
||||
actions = m.actions;
|
||||
}
|
||||
}, <any>{
|
||||
choose() {
|
||||
} as IMessageService, {
|
||||
choose(severity, message, options, modal) {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
// default close action
|
||||
service.$showMessage(1, '', {}, [{ title: 'a thing', isCloseAffordance: false, handle: 0 }]);
|
||||
@@ -62,19 +63,19 @@ suite('ExtHostMessageService', function () {
|
||||
|
||||
let actions: Action[];
|
||||
let c: number;
|
||||
let service = new MainThreadMessageService(null, null, <any>{
|
||||
show(sev: number, m: { message; actions: Action[] }) {
|
||||
let service = new MainThreadMessageService(null, {
|
||||
show(sev: number, m: { actions: Action[] }) {
|
||||
c = 0;
|
||||
actions = m.actions;
|
||||
return () => {
|
||||
c += 1;
|
||||
};
|
||||
}
|
||||
}, <any>{
|
||||
choose() {
|
||||
} as IMessageService, {
|
||||
choose(severity, message, options, modal) {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
service.$showMessage(1, '', {}, [{ title: 'a thing', isCloseAffordance: true, handle: 0 }]);
|
||||
assert.equal(actions.length, 1);
|
||||
@@ -85,11 +86,11 @@ suite('ExtHostMessageService', function () {
|
||||
|
||||
suite('modal', () => {
|
||||
test('calls choice service', () => {
|
||||
const service = new MainThreadMessageService(null, null, <any>{
|
||||
show(sev: number, m: { message; actions: Action[] }) {
|
||||
const service = new MainThreadMessageService(null, {
|
||||
show(sev: number, m: { actions: Action[] }) {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
}, <any>{
|
||||
} as IMessageService, {
|
||||
choose(severity, message, options, modal) {
|
||||
assert.equal(severity, 1);
|
||||
assert.equal(message, 'h');
|
||||
@@ -97,7 +98,7 @@ suite('ExtHostMessageService', function () {
|
||||
assert.equal(options[1], 'Cancel');
|
||||
return Promise.as(0);
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]).then(handle => {
|
||||
assert.equal(handle, 42);
|
||||
@@ -105,15 +106,15 @@ suite('ExtHostMessageService', function () {
|
||||
});
|
||||
|
||||
test('returns undefined when cancelled', () => {
|
||||
const service = new MainThreadMessageService(null, null, <any>{
|
||||
show(sev: number, m: { message; actions: Action[] }) {
|
||||
const service = new MainThreadMessageService(null, {
|
||||
show(sev: number, m: { actions: Action[] }) {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
}, <any>{
|
||||
} as IMessageService, {
|
||||
choose(severity, message, options, modal) {
|
||||
return Promise.as(1);
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]).then(handle => {
|
||||
assert.equal(handle, undefined);
|
||||
@@ -121,16 +122,16 @@ suite('ExtHostMessageService', function () {
|
||||
});
|
||||
|
||||
test('hides Cancel button when not needed', () => {
|
||||
const service = new MainThreadMessageService(null, null, <any>{
|
||||
show(sev: number, m: { message; actions: Action[] }) {
|
||||
const service = new MainThreadMessageService(null, {
|
||||
show(sev: number, m: { actions: Action[] }) {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
}, <any>{
|
||||
} as IMessageService, {
|
||||
choose(severity, message, options, modal) {
|
||||
assert.equal(options.length, 1);
|
||||
return Promise.as(0);
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => {
|
||||
assert.equal(handle, 42);
|
||||
|
||||
@@ -17,27 +17,45 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
||||
import { MainThreadCommands } from 'vs/workbench/api/electron-browser/mainThreadCommands';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TreeItemCollapsibleState, ITreeItem } from 'vs/workbench/common/views';
|
||||
import { NoopLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
suite('ExtHostConfiguration', function () {
|
||||
|
||||
suite('ExtHostTreeView', function () {
|
||||
|
||||
class RecordingShape extends mock<MainThreadTreeViewsShape>() {
|
||||
|
||||
onRefresh = new Emitter<number[]>();
|
||||
onRefresh = new Emitter<{ [treeItemHandle: string]: ITreeItem }>();
|
||||
|
||||
$registerView(treeViewId: string): void {
|
||||
}
|
||||
|
||||
$refresh(viewId: string, itemHandles: number[]): void {
|
||||
this.onRefresh.fire(itemHandles);
|
||||
$refresh(viewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem }): void {
|
||||
this.onRefresh.fire(itemsToRefresh);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let testObject: ExtHostTreeViews;
|
||||
let target: RecordingShape;
|
||||
let onDidChangeTreeData: Emitter<string>;
|
||||
let onDidChangeTreeNode: Emitter<{ key: string }>;
|
||||
let onDidChangeTreeKey: Emitter<string>;
|
||||
let tree, labels, nodes;
|
||||
|
||||
setup(() => {
|
||||
tree = {
|
||||
'a': {
|
||||
'aa': {},
|
||||
'ab': {}
|
||||
},
|
||||
'b': {
|
||||
'ba': {},
|
||||
'bb': {}
|
||||
}
|
||||
};
|
||||
|
||||
labels = {};
|
||||
nodes = {};
|
||||
|
||||
let threadService = new TestThreadService();
|
||||
// Use IInstantiationService to get typechecking when instantiating
|
||||
let inst: IInstantiationService;
|
||||
@@ -48,97 +66,307 @@ suite('ExtHostConfiguration', function () {
|
||||
|
||||
threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService));
|
||||
target = new RecordingShape();
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(threadService, new ExtHostHeapService()));
|
||||
onDidChangeTreeData = new Emitter<string>();
|
||||
testObject.registerTreeDataProvider('testDataProvider', aTreeDataProvider());
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(threadService, new ExtHostHeapService(), new NoopLogService()));
|
||||
onDidChangeTreeNode = new Emitter<{ key: string }>();
|
||||
onDidChangeTreeKey = new Emitter<string>();
|
||||
testObject.registerTreeDataProvider('testNodeTreeProvider', aNodeTreeDataProvider());
|
||||
testObject.registerTreeDataProvider('testStringTreeProvider', aStringTreeDataProvider());
|
||||
|
||||
testObject.$getElements('testDataProvider').then(elements => {
|
||||
testObject.$getElements('testNodeTreeProvider').then(elements => {
|
||||
for (const element of elements) {
|
||||
testObject.$getChildren('testDataProvider', element.handle);
|
||||
testObject.$getChildren('testNodeTreeProvider', element.handle);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('refresh calls are throttled on roots', function (done) {
|
||||
test('construct node tree', () => {
|
||||
return testObject.$getElements('testNodeTreeProvider')
|
||||
.then(elements => {
|
||||
const actuals = elements.map(e => e.handle);
|
||||
assert.deepEqual(actuals, ['0/0:a', '0/1:b']);
|
||||
return TPromise.join([
|
||||
testObject.$getChildren('testNodeTreeProvider', '0/0:a')
|
||||
.then(children => {
|
||||
const actuals = children.map(e => e.handle);
|
||||
assert.deepEqual(actuals, ['0/0:a/0:aa', '0/0:a/1:ab']);
|
||||
return TPromise.join([
|
||||
testObject.$getChildren('testNodeTreeProvider', '0/0:a/0:aa').then(children => assert.equal(children.length, 0)),
|
||||
testObject.$getChildren('testNodeTreeProvider', '0/0:a/1:ab').then(children => assert.equal(children.length, 0))
|
||||
]);
|
||||
}),
|
||||
testObject.$getChildren('testNodeTreeProvider', '0/1:b')
|
||||
.then(children => {
|
||||
const actuals = children.map(e => e.handle);
|
||||
assert.deepEqual(actuals, ['0/1:b/0:ba', '0/1:b/1:bb']);
|
||||
return TPromise.join([
|
||||
testObject.$getChildren('testNodeTreeProvider', '0/1:b/0:ba').then(children => assert.equal(children.length, 0)),
|
||||
testObject.$getChildren('testNodeTreeProvider', '0/1:b/1:bb').then(children => assert.equal(children.length, 0))
|
||||
]);
|
||||
})
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
test('construct string tree', () => {
|
||||
return testObject.$getElements('testStringTreeProvider')
|
||||
.then(elements => {
|
||||
const actuals = elements.map(e => e.handle);
|
||||
assert.deepEqual(actuals, ['a', 'b']);
|
||||
return TPromise.join([
|
||||
testObject.$getChildren('testStringTreeProvider', 'a')
|
||||
.then(children => {
|
||||
const actuals = children.map(e => e.handle);
|
||||
assert.deepEqual(actuals, ['aa', 'ab']);
|
||||
return TPromise.join([
|
||||
testObject.$getChildren('testStringTreeProvider', 'aa').then(children => assert.equal(children.length, 0)),
|
||||
testObject.$getChildren('testStringTreeProvider', 'ab').then(children => assert.equal(children.length, 0))
|
||||
]);
|
||||
}),
|
||||
testObject.$getChildren('testStringTreeProvider', 'b')
|
||||
.then(children => {
|
||||
const actuals = children.map(e => e.handle);
|
||||
assert.deepEqual(actuals, ['ba', 'bb']);
|
||||
return TPromise.join([
|
||||
testObject.$getChildren('testStringTreeProvider', 'ba').then(children => assert.equal(children.length, 0)),
|
||||
testObject.$getChildren('testStringTreeProvider', 'bb').then(children => assert.equal(children.length, 0))
|
||||
]);
|
||||
})
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
test('refresh root', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.equal(0, actuals.length);
|
||||
assert.equal(undefined, actuals);
|
||||
done();
|
||||
});
|
||||
onDidChangeTreeData.fire();
|
||||
onDidChangeTreeData.fire();
|
||||
onDidChangeTreeData.fire();
|
||||
onDidChangeTreeData.fire();
|
||||
onDidChangeTreeNode.fire();
|
||||
});
|
||||
|
||||
test('refresh a parent node', () => {
|
||||
return new TPromise((c, e) => {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual(['0/1:b'], Object.keys(actuals));
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/1:b']), {
|
||||
handle: '0/1:b',
|
||||
label: 'b',
|
||||
});
|
||||
c(null);
|
||||
});
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
});
|
||||
});
|
||||
|
||||
test('refresh a leaf node', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual(['0/1:b/1:bb'], Object.keys(actuals));
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/1:b/1:bb']), {
|
||||
handle: '0/1:b/1:bb',
|
||||
parentHandle: '0/1:b',
|
||||
label: 'bb'
|
||||
});
|
||||
done();
|
||||
});
|
||||
onDidChangeTreeNode.fire(getNode('bb'));
|
||||
});
|
||||
|
||||
test('refresh parent and child node trigger refresh only on parent - scenario 1', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual(['0/1:b', '0/0:a/0:aa'], Object.keys(actuals));
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/1:b']), {
|
||||
handle: '0/1:b',
|
||||
label: 'b',
|
||||
});
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/0:a/0:aa']), {
|
||||
handle: '0/0:a/0:aa',
|
||||
parentHandle: '0/0:a',
|
||||
label: 'aa',
|
||||
});
|
||||
done();
|
||||
});
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
onDidChangeTreeNode.fire(getNode('aa'));
|
||||
onDidChangeTreeNode.fire(getNode('bb'));
|
||||
});
|
||||
|
||||
test('refresh parent and child node trigger refresh only on parent - scenario 2', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual(['0/0:a/0:aa', '0/1:b'], Object.keys(actuals));
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/1:b']), {
|
||||
handle: '0/1:b',
|
||||
label: 'b',
|
||||
});
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/0:a/0:aa']), {
|
||||
handle: '0/0:a/0:aa',
|
||||
parentHandle: '0/0:a',
|
||||
label: 'aa',
|
||||
});
|
||||
done();
|
||||
});
|
||||
onDidChangeTreeNode.fire(getNode('bb'));
|
||||
onDidChangeTreeNode.fire(getNode('aa'));
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
});
|
||||
|
||||
test('refresh an element for label change', function (done) {
|
||||
labels['a'] = 'aa';
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual(['0/0:a'], Object.keys(actuals));
|
||||
assert.deepEqual(removeUnsetKeys(actuals['0/0:a']), {
|
||||
handle: '0/0:aa',
|
||||
label: 'aa',
|
||||
});
|
||||
done();
|
||||
});
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
});
|
||||
|
||||
test('refresh calls are throttled on roots', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.equal(undefined, actuals);
|
||||
done();
|
||||
});
|
||||
onDidChangeTreeNode.fire();
|
||||
onDidChangeTreeNode.fire();
|
||||
onDidChangeTreeNode.fire();
|
||||
onDidChangeTreeNode.fire();
|
||||
});
|
||||
|
||||
test('refresh calls are throttled on elements', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual([1, 2], actuals);
|
||||
assert.deepEqual(['0/0:a', '0/1:b'], Object.keys(actuals));
|
||||
done();
|
||||
});
|
||||
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeData.fire('b');
|
||||
onDidChangeTreeData.fire('b');
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
});
|
||||
|
||||
test('refresh calls are throttled on unknown elements', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.deepEqual([1, 2], actuals);
|
||||
assert.deepEqual(['0/0:a', '0/1:b'], Object.keys(actuals));
|
||||
done();
|
||||
});
|
||||
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeData.fire('b');
|
||||
onDidChangeTreeData.fire('g');
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
onDidChangeTreeNode.fire(getNode('g'));
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
});
|
||||
|
||||
test('refresh calls are throttled on unknown elements and root', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.equal(0, actuals.length);
|
||||
assert.equal(undefined, actuals);
|
||||
done();
|
||||
});
|
||||
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeData.fire('b');
|
||||
onDidChangeTreeData.fire('g');
|
||||
onDidChangeTreeData.fire('');
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
onDidChangeTreeNode.fire(getNode('g'));
|
||||
onDidChangeTreeNode.fire();
|
||||
});
|
||||
|
||||
test('refresh calls are throttled on elements and root', function (done) {
|
||||
target.onRefresh.event(actuals => {
|
||||
assert.equal(0, actuals.length);
|
||||
assert.equal(undefined, actuals);
|
||||
done();
|
||||
});
|
||||
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeData.fire('b');
|
||||
onDidChangeTreeData.fire();
|
||||
onDidChangeTreeData.fire('a');
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
onDidChangeTreeNode.fire(getNode('b'));
|
||||
onDidChangeTreeNode.fire();
|
||||
onDidChangeTreeNode.fire(getNode('a'));
|
||||
});
|
||||
|
||||
function aTreeDataProvider(): TreeDataProvider<string> {
|
||||
return <TreeDataProvider<string>>{
|
||||
getChildren: (element: string): string[] => {
|
||||
if (!element) {
|
||||
return ['a', 'b'];
|
||||
}
|
||||
if (element === 'a') {
|
||||
return ['aa', 'ab'];
|
||||
}
|
||||
if (element === 'b') {
|
||||
return ['ba', 'bb'];
|
||||
}
|
||||
return [];
|
||||
test('generate unique handles from labels by escaping them', () => {
|
||||
tree = {
|
||||
'a/0:b': {}
|
||||
};
|
||||
|
||||
onDidChangeTreeNode.fire();
|
||||
|
||||
return testObject.$getElements('testNodeTreeProvider')
|
||||
.then(elements => {
|
||||
assert.deepEqual(elements.map(e => e.handle), ['0/0:a//0:b']);
|
||||
});
|
||||
});
|
||||
|
||||
function removeUnsetKeys(obj: any): any {
|
||||
const result = {};
|
||||
for (const key of Object.keys(obj)) {
|
||||
if (obj[key] !== void 0) {
|
||||
result[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function aNodeTreeDataProvider(): TreeDataProvider<{ key: string }> {
|
||||
return {
|
||||
getChildren: (element: { key: string }): { key: string }[] => {
|
||||
return getChildren(element ? element.key : undefined).map(key => getNode(key));
|
||||
},
|
||||
getTreeItem: (element: string): TreeItem => {
|
||||
return <TreeItem>{
|
||||
label: element
|
||||
};
|
||||
getTreeItem: (element: { key: string }): TreeItem => {
|
||||
return getTreeItem(element.key);
|
||||
},
|
||||
onDidChangeTreeData: onDidChangeTreeData.event
|
||||
onDidChangeTreeData: onDidChangeTreeNode.event
|
||||
};
|
||||
}
|
||||
|
||||
function aStringTreeDataProvider(): TreeDataProvider<string> {
|
||||
return {
|
||||
getChildren: (element: string): string[] => {
|
||||
return getChildren(element);
|
||||
},
|
||||
getTreeItem: (element: string): TreeItem => {
|
||||
return getTreeItem(element);
|
||||
},
|
||||
onDidChangeTreeData: onDidChangeTreeKey.event
|
||||
};
|
||||
}
|
||||
|
||||
function getTreeElement(element): any {
|
||||
let parent = tree;
|
||||
for (let i = 0; i < element.length; i++) {
|
||||
parent = parent[element.substring(0, i + 1)];
|
||||
if (!parent) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
function getChildren(key: string): string[] {
|
||||
if (!key) {
|
||||
return Object.keys(tree);
|
||||
}
|
||||
let treeElement = getTreeElement(key);
|
||||
if (treeElement) {
|
||||
const children = Object.keys(treeElement);
|
||||
const collapsibleStateIndex = children.indexOf('collapsibleState');
|
||||
if (collapsibleStateIndex !== -1) {
|
||||
children.splice(collapsibleStateIndex, 1);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function getTreeItem(key: string): TreeItem {
|
||||
const treeElement = getTreeElement(key);
|
||||
return {
|
||||
label: labels[key] || key,
|
||||
collapsibleState: treeElement ? treeElement['collapsibleState'] : TreeItemCollapsibleState.Collapsed
|
||||
};
|
||||
}
|
||||
|
||||
function getNode(key: string): { key: string } {
|
||||
if (!nodes[key]) {
|
||||
nodes[key] = { key };
|
||||
}
|
||||
return nodes[key];
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -25,16 +25,13 @@ suite('ExtHostWorkspace', function () {
|
||||
}
|
||||
|
||||
test('asRelativePath', function () {
|
||||
|
||||
// const ws = new ExtHostWorkspace(new TestThreadService(), { id: 'foo', folders: [aWorkspaceFolderData(URI.file('/Coding/Applications/NewsWoWBot'), 0)], name: 'Test' });
|
||||
|
||||
// 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',
|
||||
// '/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart');
|
||||
|
||||
// assertAsRelativePath(ws, '', '');
|
||||
// assertAsRelativePath(ws, '/foo/bar', '/foo/bar');
|
||||
// assertAsRelativePath(ws, 'in/out', 'in/out');
|
||||
});
|
||||
|
||||
function aWorkspaceFolderData(uri: URI, index: number, name: string = ''): IWorkspaceFolderData {
|
||||
return {
|
||||
uri,
|
||||
index,
|
||||
name: name || basename(uri.path)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,11 +10,11 @@ import { MainThreadDocumentsAndEditors } from 'vs/workbench/api/electron-browser
|
||||
import { OneGetThreadService } from './testThreadService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { MockCodeEditorService } from 'vs/editor/test/common/mocks/mockCodeEditorService';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/testCodeEditorService';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { mockCodeEditor } from 'vs/editor/test/common/mocks/mockCodeEditor';
|
||||
import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import Event from 'vs/base/common/event';
|
||||
@@ -22,10 +22,9 @@ import Event from 'vs/base/common/event';
|
||||
suite('MainThreadDocumentsAndEditors', () => {
|
||||
|
||||
let modelService: ModelServiceImpl;
|
||||
let codeEditorService: MockCodeEditorService;
|
||||
let codeEditorService: TestCodeEditorService;
|
||||
let textFileService: ITextFileService;
|
||||
let workbenchEditorService: IWorkbenchEditorService;
|
||||
let documentAndEditor: MainThreadDocumentsAndEditors;
|
||||
let deltas: IDocumentsAndEditorsDelta[] = [];
|
||||
const hugeModelString = new Array(2 + (50 * 1024 * 1024)).join('-');
|
||||
|
||||
@@ -34,9 +33,9 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
const configService = new TestConfigurationService();
|
||||
configService.setUserConfiguration('editor', { 'detectIndentation': false });
|
||||
modelService = new ModelServiceImpl(null, configService);
|
||||
codeEditorService = new MockCodeEditorService();
|
||||
codeEditorService = new TestCodeEditorService();
|
||||
textFileService = new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; };
|
||||
isDirty() { return false; }
|
||||
models = <any>{
|
||||
onModelSaved: Event.None,
|
||||
onModelReverted: Event.None,
|
||||
@@ -52,7 +51,8 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
onEditorGroupMoved = Event.None;
|
||||
};
|
||||
|
||||
documentAndEditor = new MainThreadDocumentsAndEditors(
|
||||
/* tslint:disable */
|
||||
new MainThreadDocumentsAndEditors(
|
||||
OneGetThreadService(new class extends mock<ExtHostDocumentsAndEditorsShape>() {
|
||||
$acceptDocumentsAndEditorsDelta(delta) { deltas.push(delta); }
|
||||
}),
|
||||
@@ -65,8 +65,8 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
null,
|
||||
null,
|
||||
editorGroupService,
|
||||
null
|
||||
);
|
||||
/* tslint:enable */
|
||||
});
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
this.timeout(1000 * 60); // increase timeout for this one test
|
||||
|
||||
const model = modelService.createModel(hugeModelString, null, null);
|
||||
const editor = mockCodeEditor(null, { model, wordWrap: 'off', wordWrapMinified: false });
|
||||
const editor = createTestCodeEditor(model);
|
||||
|
||||
assert.equal(deltas.length, 1);
|
||||
deltas.length = 0;
|
||||
@@ -113,7 +113,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
});
|
||||
|
||||
test('ignore editor w/o model', () => {
|
||||
const editor = mockCodeEditor([], {});
|
||||
const editor = createTestCodeEditor(null);
|
||||
editor.setModel(null);
|
||||
codeEditorService.addCodeEditor(editor);
|
||||
assert.equal(deltas.length, 1);
|
||||
@@ -129,7 +129,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
deltas.length = 0;
|
||||
|
||||
const model = modelService.createModel('farboo', null, null);
|
||||
codeEditorService.addCodeEditor(mockCodeEditor(null, { model }));
|
||||
codeEditorService.addCodeEditor(createTestCodeEditor(model));
|
||||
|
||||
assert.equal(deltas.length, 2);
|
||||
const [first, second] = deltas;
|
||||
@@ -149,7 +149,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
test('editor with dispos-ed/-ing model', () => {
|
||||
modelService.createModel('foobar', null, null);
|
||||
const model = modelService.createModel('farboo', null, null);
|
||||
const editor = mockCodeEditor(null, { model });
|
||||
const editor = createTestCodeEditor(model);
|
||||
codeEditorService.addCodeEditor(editor);
|
||||
|
||||
// ignore things until now
|
||||
@@ -158,6 +158,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
modelService.destroyModel(model.uri);
|
||||
assert.equal(deltas.length, 1);
|
||||
const [first] = deltas;
|
||||
|
||||
assert.equal(first.newActiveEditor, null);
|
||||
assert.equal(first.removedEditors.length, 1);
|
||||
assert.equal(first.removedDocuments.length, 1);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { MainThreadDocumentsAndEditors } from 'vs/workbench/api/electron-browser
|
||||
import { OneGetThreadService, TestThreadService } from './testThreadService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { MockCodeEditorService } from 'vs/editor/test/common/mocks/mockCodeEditorService';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/testCodeEditorService';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ExtHostDocumentsAndEditorsShape, IWorkspaceResourceEdit, ExtHostContext, ExtHostDocumentsShape } from 'vs/workbench/api/node/extHost.protocol';
|
||||
@@ -34,9 +34,9 @@ suite('MainThreadEditors', () => {
|
||||
setup(() => {
|
||||
const configService = new TestConfigurationService();
|
||||
modelService = new ModelServiceImpl(null, configService);
|
||||
const codeEditorService = new MockCodeEditorService();
|
||||
const codeEditorService = new TestCodeEditorService();
|
||||
const textFileService = new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; };
|
||||
isDirty() { return false; }
|
||||
models = <any>{
|
||||
onModelSaved: Event.None,
|
||||
onModelReverted: Event.None,
|
||||
@@ -73,7 +73,6 @@ suite('MainThreadEditors', () => {
|
||||
null,
|
||||
null,
|
||||
editorGroupService,
|
||||
null
|
||||
);
|
||||
|
||||
editors = new MainThreadEditors(
|
||||
@@ -84,7 +83,6 @@ suite('MainThreadEditors', () => {
|
||||
editorGroupService,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
modelService
|
||||
);
|
||||
});
|
||||
|
||||
@@ -10,5 +10,5 @@ export interface Ctor<T> {
|
||||
}
|
||||
|
||||
export function mock<T>(): Ctor<T> {
|
||||
return <any>function () { };
|
||||
return function () { } as any;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions
|
||||
import 'vs/workbench/parts/search/electron-browser/search.contribution'; // load contributions
|
||||
import * as assert from 'assert';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
@@ -54,7 +54,7 @@ declare var __dirname: string;
|
||||
// git clone --separate-git-dir=testGit --no-checkout --single-branch https://chromium.googlesource.com/chromium/src testWorkspace
|
||||
// cd testWorkspace; git checkout 39a7f93d67f7
|
||||
// Run from repository root folder with (test.bat on Windows): ./scripts/test.sh --grep QuickOpen.performance --timeout 180000 --testWorkspace <path>
|
||||
suite('QuickOpen performance (integration)', () => {
|
||||
suite.skip('QuickOpen performance (integration)', () => {
|
||||
|
||||
test('Measure', () => {
|
||||
if (process.env['VSCODE_PID']) {
|
||||
@@ -168,7 +168,7 @@ class TestTelemetryService implements ITelemetryService {
|
||||
|
||||
public publicLog(eventName: string, data?: any): TPromise<void> {
|
||||
this.events.push({ name: eventName, data: data });
|
||||
return TPromise.as<void>(null);
|
||||
return TPromise.wrap<void>(null);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
@@ -178,7 +178,7 @@ class TestTelemetryService implements ITelemetryService {
|
||||
machineId: 'someValue.machineId'
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class TestExperimentService implements IExperimentService {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions
|
||||
import 'vs/workbench/parts/search/electron-browser/search.contribution'; // load contributions
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -41,7 +41,7 @@ declare var __dirname: string;
|
||||
// git clone --separate-git-dir=testGit --no-checkout --single-branch https://chromium.googlesource.com/chromium/src testWorkspace
|
||||
// cd testWorkspace; git checkout 39a7f93d67f7
|
||||
// Run from repository root folder with (test.bat on Windows): ./scripts/test-int-mocha.sh --grep TextSearch.performance --timeout 500000 --testWorkspace <path>
|
||||
suite('TextSearch performance (integration)', () => {
|
||||
suite.skip('TextSearch performance (integration)', () => {
|
||||
|
||||
test('Measure', () => {
|
||||
if (process.env['VSCODE_PID']) {
|
||||
@@ -156,14 +156,14 @@ class TestTelemetryService implements ITelemetryService {
|
||||
const event = { name: eventName, data: data };
|
||||
this.events.push(event);
|
||||
this.emitter.fire(event);
|
||||
return TPromise.as<void>(null);
|
||||
return TPromise.wrap<void>(null);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
return TPromise.as({
|
||||
return TPromise.wrap({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/workbench/parts/files/browser/files.contribution'; // load our contribution into the test
|
||||
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 { Promise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { EventEmitter } from 'vs/base/common/eventEmitter';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -21,7 +20,7 @@ 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 { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
|
||||
import { IPartService, Parts, Position as PartPosition, Dimension } from 'vs/workbench/services/part/common/partService';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IEditorInput, IEditorOptions, Position, Direction, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
@@ -46,7 +45,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { RawTextSource, IRawTextSource } from 'vs/editor/common/model/textSource';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
@@ -57,7 +56,7 @@ import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
|
||||
import { ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
|
||||
|
||||
@@ -71,7 +70,6 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private workspace: IWorkbenchWorkspace;
|
||||
private id: string;
|
||||
private options: any;
|
||||
|
||||
private _onDidChangeWorkspaceName: Emitter<void>;
|
||||
@@ -80,7 +78,6 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
|
||||
constructor(workspace: any = TestWorkspace, options: any = null) {
|
||||
this.workspace = workspace;
|
||||
this.id = generateUuid();
|
||||
this.options = options || Object.create(null);
|
||||
this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
|
||||
this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
|
||||
@@ -171,7 +168,6 @@ export class TestTextFileService extends TextFileService {
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
||||
@@ -181,7 +177,7 @@ export class TestTextFileService extends TextFileService {
|
||||
@IWindowsService windowsService: IWindowsService,
|
||||
@IHistoryService historyService: IHistoryService
|
||||
) {
|
||||
super(lifecycleService, contextService, configurationService, telemetryService, fileService, untitledEditorService, instantiationService, messageService, TestEnvironmentService, backupFileService, windowsService, historyService);
|
||||
super(lifecycleService, contextService, configurationService, fileService, untitledEditorService, instantiationService, messageService, TestEnvironmentService, backupFileService, windowsService, historyService);
|
||||
}
|
||||
|
||||
public setPromptPath(path: string): void {
|
||||
@@ -218,7 +214,7 @@ export class TestTextFileService extends TextFileService {
|
||||
});
|
||||
}
|
||||
|
||||
public promptForPath(defaultPath?: string): string {
|
||||
public promptForPath(defaultPath: string): string {
|
||||
return this.promptPath;
|
||||
}
|
||||
|
||||
@@ -265,7 +261,7 @@ export function workbenchInstantiationService(): IInstantiationService {
|
||||
choose: (severity, message, options, cancelId): TPromise<number> => {
|
||||
return TPromise.as(cancelId);
|
||||
}
|
||||
});
|
||||
} as IChoiceService);
|
||||
|
||||
return instantiationService;
|
||||
}
|
||||
@@ -332,11 +328,11 @@ export class TestMessageService implements IMessageService {
|
||||
// No-op
|
||||
}
|
||||
|
||||
public confirmSync(confirmation: IConfirmation): boolean {
|
||||
public confirm(confirmation: IConfirmation): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
|
||||
public confirmWithCheckbox(confirmation: IConfirmation): Promise<IConfirmationResult> {
|
||||
return TPromise.as({ confirmed: false });
|
||||
}
|
||||
}
|
||||
@@ -346,13 +342,13 @@ export class TestPartService implements IPartService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private _onTitleBarVisibilityChange = new Emitter<void>();
|
||||
private _onEditorLayout = new Emitter<void>();
|
||||
private _onEditorLayout = new Emitter<Dimension>();
|
||||
|
||||
public get onTitleBarVisibilityChange(): Event<void> {
|
||||
return this._onTitleBarVisibilityChange.event;
|
||||
}
|
||||
|
||||
public get onEditorLayout(): Event<void> {
|
||||
public get onEditorLayout(): Event<Dimension> {
|
||||
return this._onEditorLayout.event;
|
||||
}
|
||||
|
||||
@@ -362,19 +358,15 @@ export class TestPartService implements IPartService {
|
||||
return true;
|
||||
}
|
||||
|
||||
public joinCreation(): Promise {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public hasFocus(part): boolean {
|
||||
public hasFocus(part: Parts): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public isVisible(part): boolean {
|
||||
public isVisible(part: Parts): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
public getContainer(part): HTMLElement {
|
||||
public getContainer(part: Parts): HTMLElement {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -422,6 +414,10 @@ export class TestPartService implements IPartService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public setPanelPosition(position: PartPosition): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public addClass(clazz: string): void { }
|
||||
public removeClass(clazz: string): void { }
|
||||
public getWorkbenchElementId(): string { return ''; }
|
||||
@@ -431,14 +427,12 @@ export class TestPartService implements IPartService {
|
||||
public resizePart(part: Parts, sizeChange: number): void { }
|
||||
}
|
||||
|
||||
export class TestStorageService extends EventEmitter implements IStorageService {
|
||||
export class TestStorageService implements IStorageService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private storage: StorageService;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
let context = new TestContextService();
|
||||
this.storage = new StorageService(new InMemoryLocalStorage(), null, context.getWorkspace().id);
|
||||
}
|
||||
@@ -565,11 +559,6 @@ export class TestEditorGroupService implements IEditorGroupService {
|
||||
public pinEditor(arg1: any, input: IEditorInput): void {
|
||||
}
|
||||
|
||||
public unpinEditor(group: IEditorGroup, input: IEditorInput): void;
|
||||
public unpinEditor(position: Position, input: IEditorInput): void;
|
||||
public unpinEditor(arg1: any, input: IEditorInput): void {
|
||||
}
|
||||
|
||||
public moveEditor(input: IEditorInput, from: IEditorGroup, to: IEditorGroup, moveOptions?: IMoveOptions): void;
|
||||
public moveEditor(input: IEditorInput, from: Position, to: Position, moveOptions?: IMoveOptions): void;
|
||||
public moveEditor(input: IEditorInput, from: any, to: any, moveOptions?: IMoveOptions): void {
|
||||
@@ -603,11 +592,11 @@ export class TestEditorService implements IWorkbenchEditorService {
|
||||
this.mockLineNumber = 15;
|
||||
}
|
||||
|
||||
public openEditors(inputs): Promise {
|
||||
public openEditors(inputs: any[]): Promise {
|
||||
return TPromise.as([]);
|
||||
}
|
||||
|
||||
public replaceEditors(editors): TPromise<IEditor[]> {
|
||||
public replaceEditors(editors: any[]): TPromise<IEditor[]> {
|
||||
return TPromise.as([]);
|
||||
}
|
||||
|
||||
@@ -619,10 +608,6 @@ export class TestEditorService implements IWorkbenchEditorService {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public isVisible(input: IEditorInput, includeDiff: boolean): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getActiveEditor(): IEditor {
|
||||
this.callback('getActiveEditor');
|
||||
|
||||
@@ -801,6 +786,10 @@ export class TestFileService implements IFileService {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
canHandleResource(resource: URI): boolean {
|
||||
return resource.scheme === 'file';
|
||||
}
|
||||
|
||||
del(resource: URI, useTrash?: boolean): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
@@ -880,7 +869,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
public discardAllWorkspaceBackups(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export class TestWindowService implements IWindowService {
|
||||
|
||||
@@ -892,6 +881,10 @@ export class TestWindowService implements IWindowService {
|
||||
return TPromise.as(false);
|
||||
}
|
||||
|
||||
getConfiguration(): IWindowConfiguration {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
getCurrentWindowId(): number {
|
||||
return 0;
|
||||
}
|
||||
@@ -960,18 +953,6 @@ export class TestWindowService implements IWindowService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
isMaximized(): TPromise<boolean> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
maximizeWindow(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
unmaximizeWindow(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
onWindowTitleDoubleClick(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
@@ -980,19 +961,19 @@ export class TestWindowService implements IWindowService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
showMessageBoxSync(options: Electron.MessageBoxOptions): number {
|
||||
showMessageBox(options: Electron.MessageBoxOptions): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
showMessageBox(options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
|
||||
showMessageBoxWithCheckbox(options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
showSaveDialog(options: Electron.SaveDialogOptions, callback?: (fileName: string) => void): string {
|
||||
showSaveDialog(options: Electron.SaveDialogOptions): string {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
showOpenDialog(options: Electron.OpenDialogOptions, callback?: (fileNames: string[]) => void): string[] {
|
||||
showOpenDialog(options: Electron.OpenDialogOptions): string[] {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
@@ -1008,10 +989,12 @@ export class TestLifecycleService implements ILifecycleService {
|
||||
public phase: LifecyclePhase;
|
||||
public startupKind: StartupKind;
|
||||
|
||||
private _onDidChangePhase = new Emitter<LifecyclePhase>();
|
||||
private _onWillShutdown = new Emitter<ShutdownEvent>();
|
||||
private _onShutdown = new Emitter<ShutdownReason>();
|
||||
|
||||
when(): Thenable<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
public fireShutdown(reason = ShutdownReason.QUIT): void {
|
||||
this._onShutdown.fire(reason);
|
||||
@@ -1021,10 +1004,6 @@ export class TestLifecycleService implements ILifecycleService {
|
||||
this._onWillShutdown.fire(event);
|
||||
}
|
||||
|
||||
public get onDidChangePhase(): Event<LifecyclePhase> {
|
||||
return this._onDidChangePhase.event;
|
||||
}
|
||||
|
||||
public get onWillShutdown(): Event<ShutdownEvent> {
|
||||
return this._onWillShutdown.event;
|
||||
}
|
||||
@@ -1232,11 +1211,10 @@ export class TestTextResourceConfigurationService implements ITextResourceConfig
|
||||
return { dispose() { } };
|
||||
}
|
||||
|
||||
public getConfiguration(resource: URI, section?: string): any;
|
||||
public getConfiguration(resource: URI, position?: IPosition, section?: string): any;
|
||||
public getConfiguration(resource: any, position?: any, section?: any): any;
|
||||
public getConfiguration(resource: any, position?: any, section?: any): any {
|
||||
return this.configurationService.getConfiguration(section, { resource });
|
||||
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 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0);
|
||||
return this.configurationService.getValue(section, { resource });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1250,4 +1228,4 @@ export class TestHashService implements IHashService {
|
||||
|
||||
export function getRandomTestPath(tmpdir: string, ...segments: string[]): string {
|
||||
return paths.join(tmpdir, ...segments, generateUuid());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user