servicesTestUtils.ts 18.9 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

B
Benjamin Pasero 已提交
8
import 'vs/workbench/parts/files/browser/files.contribution'; // load our contribution into the test
E
Erich Gamma 已提交
9
import {Promise, TPromise} from 'vs/base/common/winjs.base';
10
import {TestInstantiationService} from 'vs/test/utils/instantiationTestUtils';
11 12
import {EventEmitter} from 'vs/base/common/eventEmitter';
import * as paths from 'vs/base/common/paths';
E
Erich Gamma 已提交
13
import URI from 'vs/base/common/uri';
14 15
import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {Storage, InMemoryLocalStorage} from 'vs/workbench/common/storage';
16
import {EditorInputEvent, IEditorGroup, ConfirmResult} from 'vs/workbench/common/editor';
17
import Event, {Emitter} from 'vs/base/common/event';
E
Erich Gamma 已提交
18
import Severity from 'vs/base/common/severity';
B
Benjamin Pasero 已提交
19
import {IConfigurationService, getConfigurationValue, IConfigurationValue} from 'vs/platform/configuration/common/configuration';
E
Erich Gamma 已提交
20
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
21 22
import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IPartService} from 'vs/workbench/services/part/common/partService';
B
Benjamin Pasero 已提交
23
import {IEditorInput, IEditorOptions, IEditorModel, Position, Direction, IEditor, IResourceInput, ITextEditorModel} from 'vs/platform/editor/common/editor';
E
Erich Gamma 已提交
24
import {IEventService} from 'vs/platform/event/common/event';
25
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
E
Erich Gamma 已提交
26
import {IMessageService, IConfirmation} from 'vs/platform/message/common/message';
27
import {IWorkspace, IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
28
import {ILifecycleService, ShutdownEvent} from 'vs/platform/lifecycle/common/lifecycle';
29
import {EditorStacksModel} from 'vs/workbench/common/editor/editorStacksModel';
B
Benjamin Pasero 已提交
30 31
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService';
32
import {IEditorGroupService, GroupArrangement} from 'vs/workbench/services/group/common/groupService';
B
renames  
Benjamin Pasero 已提交
33
import {TextFileService} from 'vs/workbench/parts/files/common/textFileService';
34
import {IFileService, IResolveContentOptions, IFileOperationResult} from 'vs/platform/files/common/files';
A
Alex Dima 已提交
35
import {IModelService} from 'vs/editor/common/services/modelService';
36
import {ModelServiceImpl} from 'vs/editor/common/services/modelServiceImpl';
37 38
import {IRawTextContent} from 'vs/workbench/parts/files/common/files';
import {RawText} from 'vs/editor/common/model/textModel';
B
Benjamin Pasero 已提交
39
import {parseArgs} from 'vs/platform/environment/node/argv';
40
import {EnvironmentService} from 'vs/platform/environment/node/environmentService';
41 42 43 44
import {IModeService} from 'vs/editor/common/services/modeService';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {ITextFileService} from 'vs/workbench/parts/files/common/files';
import {IHistoryService} from 'vs/workbench/services/history/common/history';
45
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
E
Erich Gamma 已提交
46 47 48 49

export const TestWorkspace: IWorkspace = {
	resource: URI.file('C:\\testWorkspace'),
	name: 'Test Workspace',
B
Benjamin Pasero 已提交
50
	uid: Date.now()
E
Erich Gamma 已提交
51 52
};

J
Joao Moreno 已提交
53
export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv), process.execPath);
54

55
export class TestContextService implements IWorkspaceContextService {
56
	public _serviceBrand: any;
E
Erich Gamma 已提交
57 58 59 60

	private workspace: any;
	private options: any;

61
	constructor(workspace: any = TestWorkspace, options: any = null) {
E
Erich Gamma 已提交
62
		this.workspace = workspace;
63
		this.options = options || Object.create(null);
E
Erich Gamma 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	}

	public getWorkspace(): IWorkspace {
		return this.workspace;
	}

	public getOptions() {
		return this.options;
	}

	public updateOptions() {

	}

	public isInsideWorkspace(resource: URI): boolean {
		if (resource && this.workspace) {
80
			return paths.isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath);
E
Erich Gamma 已提交
81 82 83 84 85 86
		}

		return false;
	}

	public toWorkspaceRelativePath(resource: URI): string {
87
		return paths.makePosixAbsolute(paths.normalize(resource.fsPath.substr('c:'.length)));
E
Erich Gamma 已提交
88 89 90
	}

	public toResource(workspaceRelativePath: string): URI {
91
		return URI.file(paths.join('C:\\', workspaceRelativePath));
E
Erich Gamma 已提交
92 93 94
	}
}

95 96 97
export class TestTextFileService extends TextFileService {
	private promptPath: string;
	private confirmResult: ConfirmResult;
98
	private resolveTextContentError: IFileOperationResult;
A
Alex Dima 已提交
99 100

	constructor(
101 102
		@ILifecycleService lifecycleService: ILifecycleService,
		@IWorkspaceContextService contextService: IWorkspaceContextService,
A
Alex Dima 已提交
103 104
		@IConfigurationService configurationService: IConfigurationService,
		@ITelemetryService telemetryService: ITelemetryService,
105
		@IWorkbenchEditorService editorService: IWorkbenchEditorService,
A
Alex Dima 已提交
106 107
		@IEditorGroupService editorGroupService: IEditorGroupService,
		@IFileService fileService: IFileService,
108 109
		@IUntitledEditorService untitledEditorService: IUntitledEditorService,
		@IInstantiationService instantiationService: IInstantiationService
A
Alex Dima 已提交
110
	) {
111
		super(lifecycleService, contextService, configurationService, telemetryService, editorGroupService, editorService, fileService, untitledEditorService, instantiationService);
A
Alex Dima 已提交
112
	}
113

114 115 116 117 118 119 120 121
	public setPromptPath(path: string): void {
		this.promptPath = path;
	}

	public setConfirmResult(result: ConfirmResult): void {
		this.confirmResult = result;
	}

122 123 124 125
	public setResolveTextContentErrorOnce(error: IFileOperationResult): void {
		this.resolveTextContentError = error;
	}

126
	public resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent> {
127 128 129 130 131 132 133
		if (this.resolveTextContentError) {
			const error = this.resolveTextContentError;
			this.resolveTextContentError = null;

			return TPromise.wrapError(error);
		}

134 135 136
		return this.fileService.resolveContent(resource, options).then((content) => {
			const raw = RawText.fromString(content.value, { defaultEOL: 1, detectIndentation: false, insertSpaces: false, tabSize: 4, trimAutoWhitespace: false });

137
			return <IRawTextContent>{
138
				resource: content.resource,
139 140 141 142 143 144 145
				name: content.name,
				mtime: content.mtime,
				etag: content.etag,
				mime: content.mime,
				encoding: content.encoding,
				value: raw,
				valueLogicalHash: null
146 147 148
			};
		});
	}
149 150 151 152 153 154 155 156

	public promptForPath(defaultPath?: string): string {
		return this.promptPath;
	}

	public confirmSave(resources?: URI[]): ConfirmResult {
		return this.confirmResult;
	}
A
Alex Dima 已提交
157 158
}

159
export function workbenchInstantiationService(): IInstantiationService {
160
	let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
161 162 163 164 165 166 167 168 169 170 171 172 173 174
	instantiationService.stub(IEventService, new TestEventService());
	instantiationService.stub(IWorkspaceContextService, new TestContextService(TestWorkspace));
	instantiationService.stub(IConfigurationService, new TestConfigurationService());
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
	instantiationService.stub(IStorageService, new TestStorageService());
	instantiationService.stub(IWorkbenchEditorService, new TestEditorService(function () { }));
	instantiationService.stub(IPartService, new TestPartService());
	instantiationService.stub(IEditorGroupService, new TestEditorGroupService());
	instantiationService.stub(IModeService);
	instantiationService.stub(IHistoryService, 'getHistory', []);
	instantiationService.stub(IModelService, createMockModelService(instantiationService));
	instantiationService.stub(IFileService, TestFileService);
	instantiationService.stub(ITelemetryService, NullTelemetryService);
	instantiationService.stub(IMessageService, new TestMessageService());
B
Benjamin Pasero 已提交
175
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
176
	instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
177 178 179 180

	return instantiationService;
}

E
Erich Gamma 已提交
181
export class TestMessageService implements IMessageService {
182
	public _serviceBrand: any;
E
Erich Gamma 已提交
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208

	private counter: number;

	constructor() {
		this.counter = 0;
	}

	public show(sev: Severity, message: any): () => void {
		this.counter++;

		return null;
	}

	public getCounter() {
		return this.counter;
	}

	public hideAll(): void {
		// No-op
	}

	public confirm(confirmation: IConfirmation): boolean {
		return false;
	}
}

209
export class TestPartService implements IPartService {
210
	public _serviceBrand: any;
E
Erich Gamma 已提交
211 212 213 214 215 216 217 218

	public layout(): void { }

	public isCreated(): boolean {
		return true;
	}

	public joinCreation(): Promise {
A
Alex Dima 已提交
219
		return TPromise.as(null);
E
Erich Gamma 已提交
220 221 222 223 224 225 226 227 228 229
	}

	public hasFocus(part): boolean {
		return false;
	}

	public isVisible(part): boolean {
		return true;
	}

230 231 232 233 234 235
	public isStatusBarHidden(): boolean {
		return false;
	}

	public setStatusBarHidden(hidden: boolean): void { }

E
Erich Gamma 已提交
236 237 238 239 240 241
	public isSideBarHidden(): boolean {
		return false;
	}

	public setSideBarHidden(hidden: boolean): void { }

I
isidor 已提交
242
	public isPanelHidden(): boolean {
I
isidor 已提交
243 244 245
		return false;
	}

I
isidor 已提交
246
	public setPanelHidden(hidden: boolean): void { }
I
isidor 已提交
247

E
Erich Gamma 已提交
248 249 250 251 252 253 254
	public getSideBarPosition() {
		return 0;
	}

	public setSideBarPosition(position): void { }
	public addClass(clazz: string): void { }
	public removeClass(clazz: string): void { }
255
	public getWorkbenchElementId(): string { return ''; }
E
Erich Gamma 已提交
256 257
}

258
export class TestEventService extends EventEmitter implements IEventService {
259
	public _serviceBrand: any;
E
Erich Gamma 已提交
260 261
}

262
export class TestStorageService extends EventEmitter implements IStorageService {
263
	public _serviceBrand: any;
E
Erich Gamma 已提交
264

265
	private storage: Storage;
E
Erich Gamma 已提交
266 267 268 269 270

	constructor() {
		super();

		let context = new TestContextService();
271
		this.storage = new Storage(new InMemoryLocalStorage(), null, context);
E
Erich Gamma 已提交
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
	}

	store(key: string, value: any, scope: StorageScope = StorageScope.GLOBAL): void {
		this.storage.store(key, value, scope);
	}

	swap(key: string, valueA: any, valueB: any, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: any): void {
		this.storage.swap(key, valueA, valueB, scope, defaultValue);
	}

	remove(key: string, scope: StorageScope = StorageScope.GLOBAL): void {
		this.storage.remove(key, scope);
	}

	get(key: string, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: string): string {
		return this.storage.get(key, scope, defaultValue);
	}

	getInteger(key: string, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: number): number {
		return this.storage.getInteger(key, scope, defaultValue);
	}

	getBoolean(key: string, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: boolean): boolean {
		return this.storage.getBoolean(key, scope, defaultValue);
	}
}

299
export class TestEditorGroupService implements IEditorGroupService {
300
	public _serviceBrand: any;
301 302

	private stacksModel: EditorStacksModel;
303 304 305 306

	private _onEditorsChanged: Emitter<void>;
	private _onEditorOpening: Emitter<EditorInputEvent>;
	private _onEditorOpenFail: Emitter<IEditorInput>;
307
	private _onEditorsMoved: Emitter<void>;
308 309

	constructor(callback?: (method: string) => void) {
310
		this._onEditorsMoved = new Emitter<void>();
311 312 313 314
		this._onEditorsChanged = new Emitter<void>();
		this._onEditorOpening = new Emitter<EditorInputEvent>();
		this._onEditorOpenFail = new Emitter<IEditorInput>();

315 316 317
		let services = new ServiceCollection();

		services.set(IStorageService, new TestStorageService());
318
		services.set(IConfigurationService, new TestConfigurationService());
319
		services.set(IWorkspaceContextService, new TestContextService());
320 321 322 323 324
		const lifecycle = new TestLifecycleService();
		services.set(ILifecycleService, lifecycle);

		let inst = new InstantiationService(services);

325
		this.stacksModel = inst.createInstance(EditorStacksModel, true);
326 327
	}

328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
	public fireChange(): void {
		this._onEditorsChanged.fire();
	}

	public get onEditorsChanged(): Event<void> {
		return this._onEditorsChanged.event;
	}

	public get onEditorOpening(): Event<EditorInputEvent> {
		return this._onEditorOpening.event;
	}

	public get onEditorOpenFail(): Event<IEditorInput> {
		return this._onEditorOpenFail.event;
	}

344 345 346 347
	public get onEditorsMoved(): Event<void> {
		return this._onEditorsMoved.event;
	}

348 349 350
	public focusGroup(group: IEditorGroup): void;
	public focusGroup(position: Position): void;
	public focusGroup(arg1: any): void {
351 352 353

	}

354 355 356
	public activateGroup(group: IEditorGroup): void;
	public activateGroup(position: Position): void;
	public activateGroup(arg1: any): void {
357 358 359

	}

360 361 362
	public moveGroup(from: IEditorGroup, to: IEditorGroup): void;
	public moveGroup(from: Position, to: Position): void;
	public moveGroup(arg1: any, arg2: any): void {
363 364 365 366 367 368 369

	}

	public arrangeGroups(arrangement: GroupArrangement): void {

	}

370 371 372
	public pinEditor(group: IEditorGroup, input: IEditorInput): void;
	public pinEditor(position: Position, input: IEditorInput): void;
	public pinEditor(arg1: any, input: IEditorInput): void {
373 374
	}

375 376 377
	public unpinEditor(group: IEditorGroup, input: IEditorInput): void;
	public unpinEditor(position: Position, input: IEditorInput): void;
	public unpinEditor(arg1: any, input: IEditorInput): void {
378 379
	}

380 381 382
	public moveEditor(input: IEditorInput, from: IEditorGroup, to: IEditorGroup, index?: number): void;
	public moveEditor(input: IEditorInput, from: Position, to: Position, index?: number): void;
	public moveEditor(input: IEditorInput, from: any, to: any, index?: number): void {
383 384 385 386 387 388 389
	}

	public getStacksModel(): EditorStacksModel {
		return this.stacksModel;
	}
}

390
export class TestEditorService implements IWorkbenchEditorService {
391
	public _serviceBrand: any;
E
Erich Gamma 已提交
392

B
Benjamin Pasero 已提交
393 394 395
	public activeEditorInput: IEditorInput;
	public activeEditorOptions: IEditorOptions;
	public activeEditorPosition: Position;
E
Erich Gamma 已提交
396 397 398 399 400

	private callback: (method: string) => void;

	constructor(callback?: (method: string) => void) {
		this.callback = callback || ((s: string) => { });
B
Benjamin Pasero 已提交
401 402
	}

B
Benjamin Pasero 已提交
403
	public openEditors(inputs): Promise {
A
Alex Dima 已提交
404
		return TPromise.as([]);
E
Erich Gamma 已提交
405 406
	}

407 408 409 410
	public replaceEditors(editors): TPromise<IEditor[]> {
		return TPromise.as([]);
	}

411 412 413 414
	public closeEditors(position: Position, except?: IEditorInput, direction?: Direction): TPromise<void> {
		return TPromise.as(null);
	}

415
	public closeAllEditors(except?: Position): TPromise<void> {
A
Alex Dima 已提交
416
		return TPromise.as(null);
E
Erich Gamma 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
	}

	public isVisible(input: IEditorInput, includeDiff: boolean): boolean {
		return false;
	}

	public getActiveEditor(): IEditor {
		this.callback('getActiveEditor');

		return null;
	}

	public getActiveEditorInput(): IEditorInput {
		this.callback('getActiveEditorInput');

B
Benjamin Pasero 已提交
432
		return this.activeEditorInput;
E
Erich Gamma 已提交
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
	}

	public getVisibleEditors(): IEditor[] {
		this.callback('getVisibleEditors');

		return [];
	}

	public openEditor(input: any, options?: any, position?: any): Promise {
		this.callback('openEditor');

		this.activeEditorInput = input;
		this.activeEditorOptions = options;
		this.activeEditorPosition = position;

A
Alex Dima 已提交
448
		return TPromise.as(null);
E
Erich Gamma 已提交
449 450 451 452 453 454 455 456 457 458
	}

	public resolveEditorModel(input: IEditorInput, refresh?: boolean): TPromise<IEditorModel>;
	public resolveEditorModel(input: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel>;
	public resolveEditorModel(input: any, refresh?: boolean): Promise {
		this.callback('resolveEditorModel');

		return input.resolve(refresh);
	}

459
	public closeEditor(position: Position, input: IEditorInput): TPromise<void> {
E
Erich Gamma 已提交
460 461 462 463 464
		this.callback('closeEditor');

		return TPromise.as(null);
	}

465
	public createInput(input: IResourceInput): TPromise<IEditorInput> {
A
Alex Dima 已提交
466
		return TPromise.as(null);
E
Erich Gamma 已提交
467 468 469
	}
}

470
export class TestQuickOpenService implements IQuickOpenService {
471
	public _serviceBrand: any;
E
Erich Gamma 已提交
472 473 474

	private callback: (prefix: string) => void;

475
	constructor(callback?: (prefix: string) => void) {
E
Erich Gamma 已提交
476 477 478
		this.callback = callback;
	}

479
	pick(arg: any, options?: any, token?: any): Promise {
A
Alex Dima 已提交
480
		return TPromise.as(null);
E
Erich Gamma 已提交
481 482
	}

483
	input(options?: any, token?: any): Promise {
A
Alex Dima 已提交
484
		return TPromise.as(null);
E
Erich Gamma 已提交
485 486
	}

487 488
	accept(): void {
	}
J
Joao Moreno 已提交
489

490 491 492 493
	focus(): void {
	}

	close(): void {
494 495
	}

B
Benjamin Pasero 已提交
496
	show(prefix?: string, options?: any): Promise {
B
tslint  
Benjamin Pasero 已提交
497 498 499
		if (this.callback) {
			this.callback(prefix);
		}
E
Erich Gamma 已提交
500

A
Alex Dima 已提交
501
		return TPromise.as(true);
E
Erich Gamma 已提交
502 503
	}

504
	get onShow(): Event<void> {
E
Erich Gamma 已提交
505 506 507
		return null;
	}

508
	get onHide(): Event<void> {
E
Erich Gamma 已提交
509 510 511
		return null;
	}

B
Benjamin Pasero 已提交
512 513
	public dispose() { }
	public quickNavigate(): void { }
E
Erich Gamma 已提交
514 515 516
}

export const TestFileService = {
B
Benjamin Pasero 已提交
517
	resolveContent: function (resource) {
A
Alex Dima 已提交
518
		return TPromise.as({
E
Erich Gamma 已提交
519 520 521 522
			resource: resource,
			value: 'Hello Html',
			etag: 'index.txt',
			mime: 'text/plain',
B
Benjamin Pasero 已提交
523
			encoding: 'utf8',
B
Benjamin Pasero 已提交
524 525 526 527 528 529 530 531 532 533 534 535
			mtime: Date.now(),
			name: paths.basename(resource.fsPath)
		});
	},

	resolveFile: function (resource) {
		return TPromise.as({
			resource: resource,
			etag: Date.now(),
			mime: 'text/plain',
			encoding: 'utf8',
			mtime: Date.now(),
536
			name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
537 538 539
		});
	},

A
Alex Dima 已提交
540 541 542 543
	resolveStreamContent: function (resource) {
		return TPromise.as({
			resource: resource,
			value: {
544
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
545 546 547 548 549 550 551 552 553 554 555
					if (event === 'data') {
						callback('Hello Html');
					}
					if (event === 'end') {
						callback();
					}
				}
			},
			etag: 'index.txt',
			mime: 'text/plain',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
556
			mtime: Date.now(),
557
			name: paths.basename(resource.fsPath)
A
Alex Dima 已提交
558 559 560
		});
	},

B
Benjamin Pasero 已提交
561
	updateContent: function (res) {
562
		return TPromise.timeout(1).then(() => {
E
Erich Gamma 已提交
563 564 565 566
			return {
				resource: res,
				etag: 'index.txt',
				mime: 'text/plain',
B
Benjamin Pasero 已提交
567
				encoding: 'utf8',
B
Benjamin Pasero 已提交
568
				mtime: Date.now(),
569
				name: paths.basename(res.fsPath)
E
Erich Gamma 已提交
570 571 572
			};
		});
	}
B
linting  
Benjamin Pasero 已提交
573
};
574

575
export class TestConfigurationService extends EventEmitter implements IConfigurationService {
576
	public _serviceBrand: any;
577

578 579
	private configuration = Object.create(null);

580
	public reloadConfiguration<T>(section?: string): TPromise<T> {
581 582 583
		return TPromise.as(this.getConfiguration());
	}

584
	public getConfiguration(): any {
585
		return this.configuration;
586 587
	}

B
Benjamin Pasero 已提交
588
	public setUserConfiguration(key: any, value: any): Thenable<void> {
589
		this.configuration[key] = value;
B
Benjamin Pasero 已提交
590 591
		return TPromise.as(null);
	}
592 593 594 595

	public onDidUpdateConfiguration() {
		return { dispose() { } };
	}
B
Benjamin Pasero 已提交
596 597 598 599 600 601 602 603

	public lookup<C>(key: string): IConfigurationValue<C> {
		return {
			value: getConfigurationValue<C>(this.getConfiguration(), key),
			default: getConfigurationValue<C>(this.getConfiguration(), key),
			user: getConfigurationValue<C>(this.getConfiguration(), key)
		};
	}
604 605 606 607
}

export class TestLifecycleService implements ILifecycleService {

608
	public _serviceBrand: any;
609

610 611
	public willShutdown: boolean;
	
612 613 614 615 616 617 618 619 620 621
	private _onWillShutdown = new Emitter<ShutdownEvent>();
	private _onShutdown = new Emitter<void>();

	constructor() {
	}

	public fireShutdown(): void {
		this._onShutdown.fire();
	}

622 623 624 625
	public fireWillShutdown(event: ShutdownEvent): void {
		this._onWillShutdown.fire(event);
	}

626 627 628 629 630 631 632
	public get onWillShutdown(): Event<ShutdownEvent> {
		return this._onWillShutdown.event;
	}

	public get onShutdown(): Event<void> {
		return this._onShutdown.event;
	}
633 634 635 636 637
}

export function createMockModelService(instantiationService: TestInstantiationService): IModelService {
	instantiationService.stub(IConfigurationService, new TestConfigurationService());
	return instantiationService.createInstance(ModelServiceImpl);
E
Erich Gamma 已提交
638
}