mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 9bc92b48d945144abb405b9e8df05e18accb9148
This commit is contained in:
@@ -58,7 +58,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
const editorGroupService = new TestEditorGroupsService();
|
||||
|
||||
const fileService = new class extends mock<IFileService>() {
|
||||
onAfterOperation = Event.None;
|
||||
onDidRunOperation = Event.None;
|
||||
};
|
||||
|
||||
new MainThreadDocumentsAndEditors(
|
||||
|
||||
@@ -40,6 +40,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
||||
|
||||
suite('MainThreadEditors', () => {
|
||||
|
||||
@@ -79,14 +80,17 @@ suite('MainThreadEditors', () => {
|
||||
services.set(IEditorGroupsService, new TestEditorGroupsService());
|
||||
services.set(ITextFileService, new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; }
|
||||
create(uri: URI, contents?: string, options?: any) {
|
||||
createdResources.add(uri);
|
||||
create(resource: URI) {
|
||||
createdResources.add(resource);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
delete(resource: URI) {
|
||||
deletedResources.add(resource);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
onDidChangeDirty: Event.None
|
||||
};
|
||||
});
|
||||
services.set(IWorkingCopyFileService, new class extends mock<IWorkingCopyFileService>() {
|
||||
move(source: URI, target: URI) {
|
||||
movedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
@@ -95,11 +99,10 @@ suite('MainThreadEditors', () => {
|
||||
copiedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
onDidChangeDirty: Event.None
|
||||
};
|
||||
delete(resource: URI) {
|
||||
deletedResources.add(resource);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
});
|
||||
services.set(ITextModelService, new class extends mock<ITextModelService>() {
|
||||
createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
|
||||
|
||||
@@ -64,6 +64,9 @@ class MyInputFactory implements IEditorInputFactory {
|
||||
}
|
||||
|
||||
class MyInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
getPreferredEditorId(ids: string[]) {
|
||||
return ids[1];
|
||||
}
|
||||
@@ -78,6 +81,9 @@ class MyInput extends EditorInput {
|
||||
}
|
||||
|
||||
class MyOtherInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
getTypeId(): string {
|
||||
return '';
|
||||
}
|
||||
@@ -256,7 +262,7 @@ suite('Workbench base editor', () => {
|
||||
}
|
||||
|
||||
class TestEditorInput extends EditorInput {
|
||||
constructor(private resource: URI, private id = 'testEditorInputForMementoTest') {
|
||||
constructor(public resource: URI, private id = 'testEditorInputForMementoTest') {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForMementoTest'; }
|
||||
@@ -265,10 +271,6 @@ suite('Workbench base editor', () => {
|
||||
matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
|
||||
getResource(): URI {
|
||||
return this.resource;
|
||||
}
|
||||
}
|
||||
|
||||
const rawMemento = Object.create(null);
|
||||
|
||||
@@ -20,7 +20,7 @@ class ServiceAccessor {
|
||||
|
||||
class FileEditorInput extends EditorInput {
|
||||
|
||||
constructor(private resource: URI) {
|
||||
constructor(public resource: URI) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -28,10 +28,6 @@ class FileEditorInput extends EditorInput {
|
||||
return 'editorResourceFileTest';
|
||||
}
|
||||
|
||||
getResource(): URI {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
resolve(): Promise<IEditorModel | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
@@ -58,18 +54,18 @@ suite('Workbench editor', () => {
|
||||
|
||||
const untitled = instantiationService.createInstance(UntitledTextEditorInput, service.create());
|
||||
|
||||
assert.equal(toResource(untitled)!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.getResource().toString());
|
||||
assert.equal(toResource(untitled)!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
|
||||
assert.ok(!toResource(untitled, { filterByScheme: Schemas.file }));
|
||||
|
||||
const file = new FileEditorInput(URI.file('/some/path.txt'));
|
||||
|
||||
assert.equal(toResource(file)!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { filterByScheme: Schemas.file })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file)!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { filterByScheme: Schemas.file })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
|
||||
assert.ok(!toResource(file, { filterByScheme: Schemas.untitled }));
|
||||
|
||||
const diffEditorInput = new DiffEditorInput('name', 'description', untitled, file);
|
||||
@@ -77,8 +73,8 @@ suite('Workbench editor', () => {
|
||||
assert.ok(!toResource(diffEditorInput));
|
||||
assert.ok(!toResource(diffEditorInput, { filterByScheme: Schemas.file }));
|
||||
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: Schemas.file })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -73,6 +73,9 @@ function groupListener(group: EditorGroup): GroupEvents {
|
||||
|
||||
let index = 0;
|
||||
class TestEditorInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
@@ -93,6 +96,9 @@ class TestEditorInput extends EditorInput {
|
||||
}
|
||||
|
||||
class NonSerializableTestEditorInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
@@ -106,7 +112,7 @@ class NonSerializableTestEditorInput extends EditorInput {
|
||||
|
||||
class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
|
||||
constructor(public id: string, private resource: URI) {
|
||||
constructor(public id: string, public resource: URI) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testFileEditorInputForGroups'; }
|
||||
@@ -114,7 +120,6 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
setEncoding(encoding: string) { }
|
||||
getEncoding() { return undefined; }
|
||||
setPreferredEncoding(encoding: string) { }
|
||||
getResource(): URI { return this.resource; }
|
||||
setForceOpenAsBinary(): void { }
|
||||
setMode(mode: string) { }
|
||||
setPreferredMode(mode: string) { }
|
||||
|
||||
@@ -8,6 +8,8 @@ import { EditorInput } from 'vs/workbench/common/editor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
|
||||
class MyEditorInput extends EditorInput {
|
||||
readonly resource = undefined;
|
||||
|
||||
getTypeId(): string { return ''; }
|
||||
resolve(): any { return null; }
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ suite('Editor - Range decorations', () => {
|
||||
model = aModel(URI.file('some_file'));
|
||||
codeEditor = createTestCodeEditor({ model: model });
|
||||
|
||||
instantiationService.stub(IEditorService, 'activeEditor', { getResource: () => { return codeEditor.getModel()!.uri; } });
|
||||
instantiationService.stub(IEditorService, 'activeEditor', { get resource() { return codeEditor.getModel()!.uri; } });
|
||||
instantiationService.stub(IEditorService, 'activeTextEditorWidget', codeEditor);
|
||||
|
||||
testObject = instantiationService.createInstance(RangeHighlightDecorations);
|
||||
|
||||
@@ -89,6 +89,8 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
||||
import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
|
||||
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
|
||||
import { Direction } from 'vs/base/browser/ui/grid/grid';
|
||||
import { IProgressService, IProgressOptions, IProgressWindowOptions, IProgressNotificationOptions, IProgressCompositeOptions, IProgress, IProgressStep, emptyProgress } from 'vs/platform/progress/common/progress';
|
||||
import { IWorkingCopyFileService, WorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
||||
|
||||
export import TestTextResourcePropertiesService = CommonWorkbenchTestServices.TestTextResourcePropertiesService;
|
||||
export import TestContextService = CommonWorkbenchTestServices.TestContextService;
|
||||
@@ -120,7 +122,6 @@ export class TestTextFileService extends BrowserTextFileService {
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
|
||||
@ITextModelService textModelService: ITextModelService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IRemotePathService remotePathService: IRemotePathService
|
||||
) {
|
||||
super(
|
||||
@@ -136,7 +137,6 @@ export class TestTextFileService extends BrowserTextFileService {
|
||||
filesConfigurationService,
|
||||
textModelService,
|
||||
codeEditorService,
|
||||
notificationService,
|
||||
remotePathService
|
||||
);
|
||||
}
|
||||
@@ -172,9 +172,11 @@ export const TestEnvironmentService = new BrowserWorkbenchEnvironmentService(Obj
|
||||
export function workbenchInstantiationService(overrides?: { textFileService?: (instantiationService: IInstantiationService) => ITextFileService }): ITestInstantiationService {
|
||||
const instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
|
||||
|
||||
instantiationService.stub(IWorkingCopyService, new TestWorkingCopyService());
|
||||
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
|
||||
const contextKeyService = <IContextKeyService>instantiationService.createInstance(MockContextKeyService);
|
||||
instantiationService.stub(IContextKeyService, contextKeyService);
|
||||
instantiationService.stub(IProgressService, new TestProgressService());
|
||||
const workspaceContextService = new TestContextService(TestWorkspace);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceContextService);
|
||||
const configService = new TestConfigurationService();
|
||||
@@ -200,6 +202,7 @@ export function workbenchInstantiationService(overrides?: { textFileService?: (i
|
||||
instantiationService.stub(IKeybindingService, new MockKeybindingService());
|
||||
instantiationService.stub(IDecorationsService, new TestDecorationsService());
|
||||
instantiationService.stub(IExtensionService, new TestExtensionService());
|
||||
instantiationService.stub(IWorkingCopyFileService, instantiationService.createInstance(WorkingCopyFileService));
|
||||
instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : <ITextFileService>instantiationService.createInstance(TestTextFileService));
|
||||
instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));
|
||||
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
|
||||
@@ -212,11 +215,23 @@ export function workbenchInstantiationService(overrides?: { textFileService?: (i
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
|
||||
instantiationService.stub(IViewletService, new TestViewletService());
|
||||
instantiationService.stub(IWorkingCopyService, new TestWorkingCopyService());
|
||||
|
||||
return instantiationService;
|
||||
}
|
||||
|
||||
export class TestProgressService implements IProgressService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
withProgress(
|
||||
options: IProgressOptions | IProgressWindowOptions | IProgressNotificationOptions | IProgressCompositeOptions,
|
||||
task: (progress: IProgress<IProgressStep>) => Promise<any>,
|
||||
onDidCancel?: ((choice?: number | undefined) => void) | undefined
|
||||
): Promise<any> {
|
||||
return task(emptyProgress);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestAccessibilityService implements IAccessibilityService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
@@ -588,8 +603,8 @@ export class TestFileService implements IFileService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _onFileChanges: Emitter<FileChangesEvent>;
|
||||
private readonly _onAfterOperation: Emitter<FileOperationEvent>;
|
||||
private readonly _onDidFilesChange = new Emitter<FileChangesEvent>();
|
||||
private readonly _onDidRunOperation = new Emitter<FileOperationEvent>();
|
||||
|
||||
readonly onWillActivateFileSystemProvider = Event.None;
|
||||
readonly onDidChangeFileSystemProviderCapabilities = Event.None;
|
||||
@@ -598,18 +613,13 @@ export class TestFileService implements IFileService {
|
||||
private content = 'Hello Html';
|
||||
private lastReadFileUri!: URI;
|
||||
|
||||
constructor() {
|
||||
this._onFileChanges = new Emitter<FileChangesEvent>();
|
||||
this._onAfterOperation = new Emitter<FileOperationEvent>();
|
||||
}
|
||||
|
||||
setContent(content: string): void { this.content = content; }
|
||||
getContent(): string { return this.content; }
|
||||
getLastReadFileUri(): URI { return this.lastReadFileUri; }
|
||||
get onFileChanges(): Event<FileChangesEvent> { return this._onFileChanges.event; }
|
||||
fireFileChanges(event: FileChangesEvent): void { this._onFileChanges.fire(event); }
|
||||
get onAfterOperation(): Event<FileOperationEvent> { return this._onAfterOperation.event; }
|
||||
fireAfterOperation(event: FileOperationEvent): void { this._onAfterOperation.fire(event); }
|
||||
get onDidFilesChange(): Event<FileChangesEvent> { return this._onDidFilesChange.event; }
|
||||
fireFileChanges(event: FileChangesEvent): void { this._onDidFilesChange.fire(event); }
|
||||
get onDidRunOperation(): Event<FileOperationEvent> { return this._onDidRunOperation.event; }
|
||||
fireAfterOperation(event: FileOperationEvent): void { this._onDidRunOperation.fire(event); }
|
||||
resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
|
||||
resolve(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
|
||||
resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
|
||||
|
||||
Reference in New Issue
Block a user