/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event } from 'vs/base/common/event'; import { ILocalizationsService, LanguageType } from 'vs/platform/localizations/common/localizations'; import { ISharedProcessService } from 'vs/platform/sharedProcess/node/sharedProcessService'; export class LocalizationsChannel implements IServerChannel { onDidLanguagesChange: Event; constructor(private service: ILocalizationsService) { this.onDidLanguagesChange = Event.buffer(service.onDidLanguagesChange, true); } listen(_, event: string): Event { switch (event) { case 'onDidLanguagesChange': return this.onDidLanguagesChange; } throw new Error(`Event not found: ${event}`); } call(_, command: string, arg?: any): Promise { switch (command) { case 'getLanguageIds': return this.service.getLanguageIds(arg); } throw new Error(`Call not found: ${command}`); } } export class LocalizationsChannelClient implements ILocalizationsService { _serviceBrand: any; private channel: IChannel; constructor(@ISharedProcessService sharedProcessService: ISharedProcessService) { this.channel = sharedProcessService.getChannel('localizations'); } get onDidLanguagesChange(): Event { return this.channel.listen('onDidLanguagesChange'); } getLanguageIds(type?: LanguageType): Promise { return this.channel.call('getLanguageIds', type); } }