diff --git a/src/vs/base/parts/ipc/common/ipc.ts b/src/vs/base/parts/ipc/common/ipc.ts index 25a8dd109f7..e2f574e0b60 100644 --- a/src/vs/base/parts/ipc/common/ipc.ts +++ b/src/vs/base/parts/ipc/common/ipc.ts @@ -6,9 +6,8 @@ 'use strict'; import { Promise, TPromise } from 'vs/base/common/winjs.base'; -import { assign } from 'vs/base/common/objects'; import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; -import { Emitter } from 'vs/base/common/event'; +import Event, { Emitter } from 'vs/base/common/event'; enum RequestType { Common, @@ -18,7 +17,7 @@ enum RequestType { interface IRawRequest { id: number; type: RequestType; - serviceName?: string; + channelName?: string; name?: string; args?: any[]; } @@ -52,56 +51,37 @@ export interface IMessagePassingProtocol { onMessage(callback: (response: any) => void): void; } -export interface IServiceCtor { - new? (): T; - new? (arg0: any): T; - new? (a0: any, a1: any): T; - new? (a0: any, a1: any, a2: any): T; - new? (a0: any, a1: any, a2: any, a3: any): T; - new? (a0: any, a1: any, a2: any, a3: any, a4: any): T; - prototype: any; -} - -enum ServiceState { +enum State { Uninitialized, Idle } -export interface IServiceMap { - [name: string]: any; +export interface IChannel { + call(command: string, ...args: any[]): TPromise; +} + +export interface IServer { + registerChannel(channelName: string, channel: IChannel): void; } export interface IClient { - getService(serviceName: string, serviceCtor: IServiceCtor): TService; -} - -const ServiceEventProperty = '$__SERVICE_EVENT'; - -/** - * Use this as a property decorator. - */ -export function ServiceEvent(target: T, key: string): void { - target[key] = { [ServiceEventProperty]: true }; -} - -export function isServiceEvent(target: any): boolean { - return target[ServiceEventProperty]; + getChannel(channelName: string): T; } export class Server { - private services: IServiceMap; + private channels: { [name: string]: IChannel }; private activeRequests: { [id: number]: IDisposable; }; constructor(private protocol: IMessagePassingProtocol) { - this.services = Object.create(null); + this.channels = Object.create(null); this.activeRequests = Object.create(null); this.protocol.onMessage(r => this.onMessage(r)); this.protocol.send( { type: ResponseType.Initialize }); } - registerService(serviceName: string, service: TService): void { - this.services[serviceName] = service; + registerChannel(channelName: string, channel: IChannel): void { + this.channels[channelName] = channel; } private onMessage(request: IRawRequest): void { @@ -117,42 +97,15 @@ export class Server { } private onCommonRequest(request: IRawRequest): void { - const service = this.services[request.serviceName]; - const servicePrototype = service.constructor.prototype; - const prototypeMethod = servicePrototype && servicePrototype[request.name]; - const isEvent = prototypeMethod && prototypeMethod[ServiceEventProperty]; - const method = service[request.name]; + const channel = this.channels[request.channelName]; let promise: Promise; - if (isEvent) { - let disposable: IDisposable; - - promise = new Promise( - (c, e, p) => disposable = method.call(service, p), - () => disposable.dispose() - ); - } else { - if (!method) { - promise = Promise.wrapError(new Error(`${ request.name } is not a valid method on ${ request.serviceName }`)); - } else { - try { - promise = method.call(service, ...request.args); - } catch (err) { - promise = Promise.wrapError(err); - } - } - - if (!Promise.is(promise)) { - const message = `'${ request.name }' did not return a promise`; - console.warn(message); - promise = Promise.wrapError(new Error(message)); - } + try { + promise = channel.call(request.name, ...request.args); + } catch (err) { + promise = Promise.wrapError(err); } - this.onPromiseRequest(promise, request); - } - - private onPromiseRequest(promise: Promise, request: IRawRequest): void { const id = request.id; const requestPromise = promise.then(data => { @@ -197,57 +150,36 @@ export class Server { export class Client implements IClient { - private state: ServiceState; + private state: State; private bufferedRequests: IRequest[]; private handlers: { [id: number]: IHandler; }; private lastRequestId: number; constructor(private protocol: IMessagePassingProtocol) { - this.state = ServiceState.Uninitialized; + this.state = State.Uninitialized; this.bufferedRequests = []; this.handlers = Object.create(null); this.lastRequestId = 0; this.protocol.onMessage(r => this.onMessage(r)); } - getService(serviceName: string, serviceCtor: IServiceCtor): TService { - const props = Object.keys(serviceCtor.prototype) - .filter(key => key !== 'constructor'); - - return props.reduce((service, key) => { - if (serviceCtor.prototype[key][ServiceEventProperty]) { - let promise: Promise; - - const emitter = new Emitter({ - onFirstListenerAdd: () => { - promise = this.request(serviceName, key) - .then(null, null, event => emitter.fire(event)); - }, - onLastListenerRemove: () => { - promise.cancel(); - promise = null; - } - }); - - return assign(service, { [key]: emitter.event }); - } - - return assign(service, { [key]: (...args) => this.request(serviceName, key, ...args) }); - }, {}); + getChannel(channelName: string): T { + const call = (command, args) => this.request(channelName, command, ...args); + return { call } as T; } - private request(serviceName: string, name: string, ...args: any[]): Promise { + protected request(channelName: string, name: string, ...args: any[]): Promise { const request = { raw: { id: this.lastRequestId++, type: RequestType.Common, - serviceName, + channelName, name, args } }; - if (this.state === ServiceState.Uninitialized) { + if (this.state === State.Uninitialized) { return this.bufferRequest(request); } @@ -302,7 +234,7 @@ export class Client implements IClient { }, () => { request.flush = null; - if (this.state !== ServiceState.Uninitialized) { + if (this.state !== State.Uninitialized) { if (flushedRequest) { flushedRequest.cancel(); flushedRequest = null; @@ -322,8 +254,8 @@ export class Client implements IClient { } private onMessage(response: IRawResponse): void { - if (this.state === ServiceState.Uninitialized && response.type === ResponseType.Initialize) { - this.state = ServiceState.Idle; + if (this.state === State.Uninitialized && response.type === ResponseType.Initialize) { + this.state = State.Idle; this.bufferedRequests.forEach(r => r.flush && r.flush()); this.bufferedRequests = null; return; @@ -345,48 +277,77 @@ export class Client implements IClient { } /** - * Useful when the service itself is needed right away but the client - * is wrapped within a promise. + * Useful when the channel itself is needed right away but the client is wrapped within a promise. */ -export function getService(clientPromise: TPromise, serviceName: string, serviceCtor: IServiceCtor): TService { - let _servicePromise: TPromise; - let servicePromise = () => { - if (!_servicePromise) { - _servicePromise = clientPromise.then(client => client.getService(serviceName, serviceCtor)); +export function getChannel(clientPromise: TPromise, channelName: string): T { + let _channelPromise: TPromise; + + const channelPromise = () => { + if (!_channelPromise) { + _channelPromise = clientPromise.then(client => client.getChannel(channelName)); } - return _servicePromise; + return _channelPromise; }; - return Object.keys(serviceCtor.prototype) - .filter(key => key !== 'constructor') - .reduce((result, key) => { - if (isServiceEvent(serviceCtor.prototype[key])) { - let promise: TPromise; - let disposable: IDisposable; + const call = (command, args) => channelPromise().then(c => c.call(command, ...args)); + return { call } as T; - const emitter = new Emitter({ - onFirstListenerAdd: () => { - promise = servicePromise().then(service => { - disposable = service[key](e => emitter.fire(e)); - }); - }, - onLastListenerRemove: () => { - if (disposable) { - disposable.dispose(); - disposable = null; - } - promise.cancel(); - promise = null; - } - }); - return assign(result, { [key]: emitter.event }); - } + // return Object.keys(serviceCtor.prototype) + // .filter(key => key !== 'constructor') + // .reduce((result, key) => { + // if (isServiceEvent(serviceCtor.prototype[key])) { + // let promise: TPromise; + // let disposable: IDisposable; - return assign(result, { - [key]: (...args) => { - return servicePromise().then(service => service[key](...args)); - } - }); - }, {} as TService); + // const emitter = new Emitter({ + // onFirstListenerAdd: () => { + // promise = channelPromise().then(service => { + // disposable = service[key](e => emitter.fire(e)); + // }); + // }, + // onLastListenerRemove: () => { + // if (disposable) { + // disposable.dispose(); + // disposable = null; + // } + // promise.cancel(); + // promise = null; + // } + // }); + + // return assign(result, { [key]: emitter.event }); + // } + + // return assign(result, { + // [key]: (...args) => { + // return channelPromise().then(service => service[key](...args)); + // } + // }); + // }, {} as T); +} + +export function eventToCall(event: Event): TPromise { + let disposable: IDisposable; + + return new Promise( + (c, e, p) => disposable = event(p), + () => disposable.dispose() + ); +} + +export function eventFromCall(channel: IChannel, name: string): Event { + let promise: Promise; + + const emitter = new Emitter({ + onFirstListenerAdd: () => { + promise = channel.call(name).then(null, err => null, e => emitter.fire(e)); + }, + onLastListenerRemove: () => { + promise.cancel(); + promise = null; + } + }); + + return emitter.event; } \ No newline at end of file diff --git a/src/vs/base/parts/ipc/node/ipc.cp.ts b/src/vs/base/parts/ipc/node/ipc.cp.ts index 46e1aea0c7f..2de4bd6b792 100644 --- a/src/vs/base/parts/ipc/node/ipc.cp.ts +++ b/src/vs/base/parts/ipc/node/ipc.cp.ts @@ -8,7 +8,7 @@ import { IDisposable } from 'vs/base/common/lifecycle'; import { Promise} from 'vs/base/common/winjs.base'; import { Delayer } from 'vs/base/common/async'; import { clone, assign } from 'vs/base/common/objects'; -import { IServiceCtor, Server as IPCServer, Client as IPCClient, IServiceMap } from 'vs/base/parts/ipc/common/ipc'; +import { Server as IPCServer, Client as IPCClient, IClient, IChannel } from 'vs/base/parts/ipc/common/ipc'; export class Server extends IPCServer { constructor() { @@ -21,7 +21,7 @@ export class Server extends IPCServer { } } -export interface IServiceOptions { +export interface IIPCOptions { /** * A descriptive name for the server this connection is to. Used in logging. @@ -29,7 +29,7 @@ export interface IServiceOptions { serverName: string; /** - * Time in millies before killing the service process. The next request after killing will start it again. + * Time in millies before killing the ipc process. The next request after killing will start it again. */ timeout?:number; @@ -39,7 +39,7 @@ export interface IServiceOptions { args?:string[]; /** - * Environment key-value pairs to be passed to the process that gets spawned for the service. + * Environment key-value pairs to be passed to the process that gets spawned for the ipc. */ env?:any; @@ -54,43 +54,41 @@ export interface IServiceOptions { debugBrk?:number; } -export class Client implements IDisposable { +export class Client implements IClient, IDisposable { private disposeDelayer: Delayer; private activeRequests: Promise[]; private child: ChildProcess; private _client: IPCClient; - private services: IServiceMap; + private channels: { [name: string]: IChannel }; - constructor(private modulePath: string, private options: IServiceOptions) { - const timeout = options && options.timeout ? options.timeout : Number.MAX_VALUE; + constructor(private modulePath: string, private options: IIPCOptions) { + const timeout = options && options.timeout ? options.timeout : 60000; this.disposeDelayer = new Delayer(timeout); this.activeRequests = []; this.child = null; this._client = null; - this.services = Object.create(null); + this.channels = Object.create(null); } - getService(serviceName: string, serviceCtor: IServiceCtor): TService { - return Object.keys(serviceCtor.prototype) - .filter(key => key !== 'constructor') - .reduce((service, key) => assign(service, { [key]: (...args) => this.request(serviceName, serviceCtor, key, ...args) }), {}); + getChannel(channelName: string): T { + const call = (command, args) => this.request(channelName, command, ...args); + return { call } as T; } - protected request(serviceName: string, serviceCtor: IServiceCtor, name: string, ...args: any[]): Promise { + protected request(channelName: string, name: string, ...args: any[]): Promise { this.disposeDelayer.cancel(); - let service = this.services[serviceName]; - - if (!service) { - service = this.services[serviceName] = this.client.getService(serviceName, serviceCtor); - } - - const request: Promise = service[name].apply(service, args); + const channel = this.channels[channelName] || (this.channels[channelName] = this.client.getChannel(channelName)); + const request: Promise = channel.call(name, args); // Progress doesn't propagate across 'then', we need to create a promise wrapper const result = new Promise((c, e, p) => { request.then(c, e, p).done(() => { + if (!this.activeRequests) { + return; + } + this.activeRequests.splice(this.activeRequests.indexOf(result), 1); this.disposeDelayer.trigger(() => this.disposeClient()); }); @@ -129,7 +127,7 @@ export class Client implements IDisposable { // Handle console logs specially if (msg && msg.type === '__$console') { - let args = ['%c[Service Library: ' + this.options.serverName + ']', 'color: darkgreen']; + let args = ['%c[IPC Library: ' + this.options.serverName + ']', 'color: darkgreen']; try { const parsed = JSON.parse(msg.arguments); args = args.concat(Object.getOwnPropertyNames(parsed).map(o => parsed[o])); @@ -151,7 +149,7 @@ export class Client implements IDisposable { const onExit = () => this.disposeClient(); process.once('exit', onExit); - this.child.on('error', err => console.warn('Service "' + this.options.serverName + '" errored with ' + err)); + this.child.on('error', err => console.warn('IPC "' + this.options.serverName + '" errored with ' + err)); this.child.on('exit', (code: any, signal: any) => { process.removeListener('exit', onExit); @@ -162,7 +160,7 @@ export class Client implements IDisposable { } if (code && signal !== 'SIGTERM') { - console.warn('Service "' + this.options.serverName + '" crashed with exit code ' + code); + console.warn('IPC "' + this.options.serverName + '" crashed with exit code ' + code); this.disposeDelayer.cancel(); this.disposeClient(); } @@ -177,7 +175,7 @@ export class Client implements IDisposable { this.child.kill(); this.child = null; this._client = null; - this.services = Object.create(null); + this.channels = Object.create(null); } } diff --git a/src/vs/base/parts/ipc/node/ipc.net.ts b/src/vs/base/parts/ipc/node/ipc.net.ts index a5c4a2a72e7..90b2abac6f0 100644 --- a/src/vs/base/parts/ipc/node/ipc.net.ts +++ b/src/vs/base/parts/ipc/node/ipc.net.ts @@ -9,7 +9,7 @@ import { Socket, Server as NetServer, createConnection, createServer } from 'net import { TPromise } from 'vs/base/common/winjs.base'; import { IDisposable } from 'vs/base/common/lifecycle'; import Event, { Emitter } from 'vs/base/common/event'; -import { Server as IPCServer, Client as IPCClient, IServiceCtor, IServiceMap, IMessagePassingProtocol, IClient } from 'vs/base/parts/ipc/common/ipc'; +import { Server as IPCServer, Client as IPCClient, IMessagePassingProtocol, IServer, IClient, IChannel } from 'vs/base/parts/ipc/common/ipc'; function bufferIndexOf(buffer: Buffer, value: number, start = 0) { while (start < buffer.length && buffer[start] !== value) { @@ -64,35 +64,35 @@ class Protocol implements IMessagePassingProtocol { } } -export class Server implements IDisposable { +export class Server implements IServer, IDisposable { - private services: IServiceMap; + private channels: { [name: string]: IChannel }; constructor(private server: NetServer) { - this.services = Object.create(null); + this.channels = Object.create(null); this.server.on('connection', (socket: Socket) => { const ipcServer = new IPCServer(new Protocol(socket)); - Object.keys(this.services) - .forEach(name => ipcServer.registerService(name, this.services[name])); + Object.keys(this.channels) + .forEach(name => ipcServer.registerChannel(name, this.channels[name])); socket.once('close', () => ipcServer.dispose()); }); } - registerService(serviceName: string, service: TService) { - this.services[serviceName] = service; + registerChannel(channelName: string, channel: IChannel): void { + this.channels[channelName] = channel; } dispose(): void { - this.services = null; + this.channels = null; this.server.close(); this.server = null; } } -export class Client implements IDisposable, IClient { +export class Client implements IClient, IDisposable { private ipcClient: IPCClient; private _onClose = new Emitter(); @@ -103,8 +103,8 @@ export class Client implements IDisposable, IClient { socket.once('close', () => this._onClose.fire()); } - getService(serviceName: string, serviceCtor: IServiceCtor): TService { - return this.ipcClient.getService(serviceName, serviceCtor); + getChannel(channelName: string): T { + return this.ipcClient.getChannel(channelName) as T; } dispose(): void { diff --git a/src/vs/base/parts/ipc/test/node/ipc.test.ts b/src/vs/base/parts/ipc/test/node/ipc.test.ts index 1cf610b0a31..3c2fcdf5974 100644 --- a/src/vs/base/parts/ipc/test/node/ipc.test.ts +++ b/src/vs/base/parts/ipc/test/node/ipc.test.ts @@ -6,54 +6,115 @@ 'use strict'; import * as assert from 'assert'; +import { TPromise } from 'vs/base/common/winjs.base'; import { Client } from 'vs/base/parts/ipc/node/ipc.cp'; import uri from 'vs/base/common/uri'; +import { always } from 'vs/base/common/async'; import { isPromiseCanceledError } from 'vs/base/common/errors'; -import { TestService } from './testService'; +import { ITestChannel, TestService } from './testService'; -function createService() { - const server = new Client( - uri.parse(require.toUrl('bootstrap')).fsPath, - { - serverName: 'TestServer', - env: { AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true } - } - ); - - return server.getService('TestService', TestService); +function createClient(): Client { + return new Client(uri.parse(require.toUrl('bootstrap')).fsPath, { + serverName: 'TestServer', + env: { AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true } + }); } -suite('Service', () => { +suite('IPC', () => { + suite('child process', () => { - test('createService', function (done: () => void) { - if (process.env['VSCODE_PID']) { - return done(); // TODO@Ben find out why test fails when run from within VS Code - } + test('createChannel', () => { + if (process.env['VSCODE_PID']) { + return; // TODO@Ben find out why test fails when run from within VS Code + } - const testService = createService(); - const res = testService.pong('ping'); + const client = createClient(); + const channel = client.getChannel('test'); + const service = new TestService(channel); - res.then(r => { - assert.equal(r.incoming, 'ping'); - assert.equal(r.outgoing, 'pong'); - done(); + const result = service.pong('ping').then(r => { + assert.equal(r.incoming, 'ping'); + assert.equal(r.outgoing, 'pong'); + }); + + return always(result, () => client.dispose()); }); - }); - test('cancellation', function (done: () => void) { - const testService = createService(); - const res = testService.cancelMe(); + test('cancellation', () => { + if (process.env['VSCODE_PID']) { + return; // TODO@Ben find out why test fails when run from within VS Code + } - setTimeout(() => { - res.cancel(); - }, 50); + const client = createClient(); + const channel = client.getChannel('test'); + const service = new TestService(channel); + const res = service.cancelMe(); - res.then(r => { - assert.fail('Unexpected'); - done(); - }, (error) => { - assert.ok(isPromiseCanceledError(error)); - done(); + setTimeout(() => res.cancel(), 50); + + const result = res.then( + () => assert.fail('Unexpected'), + err => assert.ok(err && isPromiseCanceledError(err)) + ); + + return always(result, () => client.dispose()); + }); + + test('events', () => { + if (process.env['VSCODE_PID']) { + return; // TODO@Ben find out why test fails when run from within VS Code + } + + const client = createClient(); + const channel = client.getChannel('test'); + const service = new TestService(channel); + + const event = new TPromise((c, e) => { + service.onMarco(({ answer }) => { + try { + assert.equal(answer, 'polo'); + c(null); + } catch (err) { + e(err); + } + }); + }); + + const request = service.marco(); + const result = TPromise.join([request, event]); + + return always(result, () => client.dispose()); + }); + + test('event dispose', () => { + if (process.env['VSCODE_PID']) { + return; // TODO@Ben find out why test fails when run from within VS Code + } + + const client = createClient(); + const channel = client.getChannel('test'); + const service = new TestService(channel); + + let count = 0; + const disposable = service.onMarco(() => count++); + + const result = service.marco().then(answer => { + assert.equal(answer, 'polo'); + assert.equal(count, 1); + + return service.marco().then(answer => { + assert.equal(answer, 'polo'); + assert.equal(count, 2); + disposable.dispose(); + + return service.marco().then(answer => { + assert.equal(answer, 'polo'); + assert.equal(count, 2); + }); + }); + }); + + return always(result, () => client.dispose()); }); }); }); \ No newline at end of file diff --git a/src/vs/base/parts/ipc/test/node/testApp.ts b/src/vs/base/parts/ipc/test/node/testApp.ts index 24e6ab11029..56ea7a03260 100644 --- a/src/vs/base/parts/ipc/test/node/testApp.ts +++ b/src/vs/base/parts/ipc/test/node/testApp.ts @@ -5,7 +5,7 @@ 'use strict'; import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; -import { TestService } from './testService'; +import { TestChannel } from './testService'; const server = new Server(); -server.registerService('TestService', new TestService()); \ No newline at end of file +server.registerChannel('test', new TestChannel()); \ No newline at end of file diff --git a/src/vs/base/parts/ipc/test/node/testService.ts b/src/vs/base/parts/ipc/test/node/testService.ts index 9f9ecfb9534..306bbc4c273 100644 --- a/src/vs/base/parts/ipc/test/node/testService.ts +++ b/src/vs/base/parts/ipc/test/node/testService.ts @@ -5,8 +5,46 @@ 'use strict'; import { TPromise } from 'vs/base/common/winjs.base'; +import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc'; +import Event, { Emitter } from 'vs/base/common/event'; -export class TestService { +interface IMarcoPoloEvent { + answer: string; +} + +export interface ITestService { + onMarco: Event; + marco(): TPromise; + pong(ping:string): TPromise<{ incoming:string, outgoing:string }>; + cancelMe(): TPromise; +} + +export interface ITestChannel extends IChannel { + call(command: 'marco'): TPromise; + call(command: 'pong', ping: string): TPromise; + call(command: 'cancelMe'): TPromise; + call(command: string, ...args: any[]): TPromise; +} + +export class TestChannel implements ITestService, ITestChannel { + + private _onMarco = new Emitter(); + onMarco: Event = this._onMarco.event; + + call(command: string, ...args: any[]): TPromise { + switch (command) { + case 'pong': return this.pong(args[0]); + case 'cancelMe': return this.cancelMe(); + case 'marco': return this.marco(); + case 'event:marco': return eventToCall(this.onMarco); + default: return TPromise.wrapError(new Error('command not found')); + } + } + + marco(): TPromise { + this._onMarco.fire({ answer: 'polo' }); + return TPromise.as('polo'); + } pong(ping:string): TPromise<{ incoming:string, outgoing:string }> { return TPromise.as({ incoming: ping, outgoing: 'pong' }); @@ -15,4 +53,26 @@ export class TestService { cancelMe(): TPromise { return TPromise.timeout(100).then(() => true); } +} + +export class TestService implements ITestService { + + private _onMarco: Event; + get onMarco(): Event { return this._onMarco; }; + + constructor(private channel: ITestChannel) { + this._onMarco = eventFromCall(channel, 'event:marco'); + } + + marco(): TPromise { + return this.channel.call('marco'); + } + + pong(ping:string): TPromise<{ incoming:string, outgoing:string }> { + return this.channel.call('pong', ping); + } + + cancelMe(): TPromise { + return this.channel.call('cancelMe'); + } } \ No newline at end of file diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 9ff8a4e7584..8f940272723 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -87,7 +87,7 @@ import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/servic import {CrashReporter} from 'vs/workbench/electron-browser/crashReporter'; import {IThemeService} from 'vs/workbench/services/themes/common/themeService'; import {ThemeService} from 'vs/workbench/services/themes/electron-browser/themeService'; -import {getService} from 'vs/base/parts/ipc/common/ipc'; +import {getChannel} from 'vs/base/parts/ipc/common/ipc'; import {connect} from 'vs/base/parts/ipc/node/ipc.net'; import {IExtensionsService} from 'vs/workbench/parts/extensions/common/extensions'; import {ExtensionsService} from 'vs/workbench/parts/extensions/node/extensionsService'; @@ -180,7 +180,7 @@ export class WorkbenchShell { }); }, errors.onUnexpectedError); - serviceCollection.set(IExtensionsService, getService(sharedProcessClientPromise, 'ExtensionService', ExtensionsService)); + serviceCollection.set(IExtensionsService, getChannel(sharedProcessClientPromise, 'ExtensionService', ExtensionsService)); // Workbench this.workbench = instantiationService.createInstance(Workbench, workbenchContainer.getHTMLElement(), this.workspace, this.configuration, this.options, serviceCollection); diff --git a/src/vs/workbench/electron-main/main.ts b/src/vs/workbench/electron-main/main.ts index 2c1183e16b8..dd5004eb671 100644 --- a/src/vs/workbench/electron-main/main.ts +++ b/src/vs/workbench/electron-main/main.ts @@ -238,7 +238,7 @@ function setupIPC(): TPromise { env.log('Sending env to running instance...'); - const service = client.getService('LaunchService', LaunchService); + const service = client.getChannel('LaunchService', LaunchService); return service.start(env.cliArgs, process.env) .then(() => client.dispose()) diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index b7ae90e6c44..d3ce58163ba 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -66,7 +66,7 @@ export function createServices(remoteCom: IMainProcessExtHostIPC, initData: IIni services.set(ITelemetryService, telemetryService); services.set(IThreadService, threadService); services.set(IExtensionService, new ExtHostExtensionService(threadService, telemetryService)); - services.set(IExtensionsService, sharedProcessClient.getService('ExtensionService', ExtensionsService)); // Connect to shared process services + services.set(IExtensionsService, sharedProcessClient.getChannel('ExtensionService', ExtensionsService)); // Connect to shared process services let instantiationService = new InstantiationService(services); threadService.setInstantiationService(instantiationService); diff --git a/src/vs/workbench/parts/git/electron-browser/electronGitService.ts b/src/vs/workbench/parts/git/electron-browser/electronGitService.ts index 1f3a82d2797..9993ddb2806 100644 --- a/src/vs/workbench/parts/git/electron-browser/electronGitService.ts +++ b/src/vs/workbench/parts/git/electron-browser/electronGitService.ts @@ -139,7 +139,7 @@ function createNativeRawGitService(workspaceRoot: string, path: string, defaultE } ); - return client.getService('GitService', RawGitService); + return client.getChannel('GitService', RawGitService); }, () => new UnavailableRawGitService()); } diff --git a/src/vs/workbench/parts/git/electron-browser/gitApp.ts b/src/vs/workbench/parts/git/electron-browser/gitApp.ts index 6028b27af05..efc49494e86 100644 --- a/src/vs/workbench/parts/git/electron-browser/gitApp.ts +++ b/src/vs/workbench/parts/git/electron-browser/gitApp.ts @@ -58,4 +58,4 @@ class IPCRawGitService extends DelayedRawGitService { } const server = new Server(); -server.registerService('GitService', new IPCRawGitService(process.argv[2], process.argv[3], process.argv[4], process.argv[5], process.argv[6])); \ No newline at end of file +server.registerChannel('GitService', new IPCRawGitService(process.argv[2], process.argv[3], process.argv[4], process.argv[5], process.argv[6])); \ No newline at end of file diff --git a/src/vs/workbench/parts/git/electron-main/askpass.ts b/src/vs/workbench/parts/git/electron-main/askpass.ts index 35951c7e635..1167b8a85f0 100644 --- a/src/vs/workbench/parts/git/electron-main/askpass.ts +++ b/src/vs/workbench/parts/git/electron-main/askpass.ts @@ -49,7 +49,7 @@ function main(argv: string[]): void { connect(process.env['VSCODE_IPC_HOOK']) .then(client => { - const service = client.getService('GitAskpassService', GitAskpassServiceStub); + const service = client.getChannel('GitAskpassService', GitAskpassServiceStub); return service.askpass(id, host, process.env['MONACO_GIT_COMMAND']).then(result => { if (result) { diff --git a/src/vs/workbench/services/files/node/watcher/unix/watcherApp.ts b/src/vs/workbench/services/files/node/watcher/unix/watcherApp.ts index d8cc1415522..75faa701a08 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/watcherApp.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/watcherApp.ts @@ -8,4 +8,4 @@ import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import {ChokidarWatcherService} from 'vs/workbench/services/files/node/watcher/unix/chokidarWatcherService'; const server = new Server(); -server.registerService('WatcherService', new ChokidarWatcherService()); \ No newline at end of file +server.registerChannel('WatcherService', new ChokidarWatcherService()); \ No newline at end of file diff --git a/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts b/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts index 9ffe52d6f1f..066ce50872d 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts @@ -55,7 +55,7 @@ export class FileWatcher { } ); - const service = client.getService('WatcherService', WatcherService); + const service = client.getChannel('WatcherService', WatcherService); // Start watching service.watch({ basePath: this.basePath, ignored: this.ignored, verboseLogging: this.verboseLogging }).then(null, (err) => { diff --git a/src/vs/workbench/services/search/node/searchApp.ts b/src/vs/workbench/services/search/node/searchApp.ts index ada389fb902..9aadbbdf63a 100644 --- a/src/vs/workbench/services/search/node/searchApp.ts +++ b/src/vs/workbench/services/search/node/searchApp.ts @@ -9,4 +9,4 @@ import {Server} from 'vs/base/parts/ipc/node/ipc.cp'; import {SearchService} from 'vs/workbench/services/search/node/rawSearchService'; const server = new Server(); -server.registerService('SearchService', new SearchService()); \ No newline at end of file +server.registerChannel('SearchService', new SearchService()); \ No newline at end of file diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index fc89f478c91..ddbb25b72ae 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -204,7 +204,7 @@ class DiskSearch { } ); - this.raw = client.getService('SearchService', RawSearchService); + this.raw = client.getChannel('SearchService', RawSearchService); } public search(query: ISearchQuery): PPromise {