diff --git a/src/vs/base/parts/ipc/node/ipc.cp.ts b/src/vs/base/parts/ipc/node/ipc.cp.ts index 0d0f2c00166..678415bd34a 100644 --- a/src/vs/base/parts/ipc/node/ipc.cp.ts +++ b/src/vs/base/parts/ipc/node/ipc.cp.ts @@ -19,8 +19,8 @@ import * as errors from 'vs/base/common/errors'; * We should move all implementations to use named ipc.net, so we stop depending on cp.fork. */ -export class Server extends IPCServer { - constructor() { +export class Server extends IPCServer { + constructor(ctx: TContext) { super({ send: r => { try { @@ -30,7 +30,7 @@ export class Server extends IPCServer { } catch (e) { /* not much to do */ } }, onMessage: fromNodeEventEmitter(process, 'message', msg => Buffer.from(msg, 'base64')) - }); + }, ctx); process.once('disconnect', () => this.dispose()); } diff --git a/src/vs/base/parts/ipc/node/ipc.ts b/src/vs/base/parts/ipc/node/ipc.ts index 4884131c174..50fc50bbf62 100644 --- a/src/vs/base/parts/ipc/node/ipc.ts +++ b/src/vs/base/parts/ipc/node/ipc.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IDisposable, toDisposable, combinedDisposable } from 'vs/base/common/lifecycle'; -import { Event, Emitter, once, filterEvent, toPromise, Relay } from 'vs/base/common/event'; +import { Event, Emitter, once, toPromise, Relay } from 'vs/base/common/event'; import { always, CancelablePromise, createCancelablePromise, timeout } from 'vs/base/common/async'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import * as errors from 'vs/base/common/errors'; @@ -62,12 +62,22 @@ export interface IChannel { listen(event: string, arg?: any): Event; } +/** + * An `IServerChannel` is the couter part to `IChannel`, + * on the server-side. You should implement this interface + * if you'd like to handle remote promises or events. + */ +export interface IServerChannel { + call(ctx: TContext, command: string, arg?: any, cancellationToken?: CancellationToken): Thenable; + listen(ctx: TContext, event: string, arg?: any): Event; +} + /** * An `IChannelServer` hosts a collection of channels. You are * able to register channels onto it, provided a channel name. */ -export interface IChannelServer { - registerChannel(channelName: string, channel: IChannel): void; +export interface IChannelServer { + registerChannel(channelName: string, channel: IServerChannel): void; } /** @@ -78,14 +88,23 @@ export interface IChannelClient { getChannel(channelName: string): T; } +export interface Client { + readonly ctx: TContext; +} + +export interface IConnectionHub { + readonly connections: Connection[]; + readonly onDidChangeConnections: Event>; +} + /** * An `IClientRouter` is responsible for routing calls to specific * channels, in scenarios in which there are multiple possible * channels (each from a separate client) to pick from. */ -export interface IClientRouter { - routeCall(clientIds: string[], command: string, arg?: any, cancellationToken?: CancellationToken): Thenable; - routeEvent(clientIds: string[], event: string, arg?: any): Thenable; +export interface IClientRouter { + routeCall(hub: IConnectionHub, command: string, arg?: any, cancellationToken?: CancellationToken): Thenable>; + routeEvent(hub: IConnectionHub, event: string, arg?: any): Thenable>; } /** @@ -95,8 +114,8 @@ export interface IClientRouter { * the same channel. You'll need to pass in an `IClientRouter` in * order to pick the right one. */ -export interface IRoutingChannelClient { - getChannel(channelName: string, router: IClientRouter): T; +export interface IRoutingChannelClient { + getChannel(channelName: string, router: IClientRouter): T; } interface IReader { @@ -207,18 +226,18 @@ function deserialize(reader: IReader): any { } } -export class ChannelServer implements IChannelServer, IDisposable { +export class ChannelServer implements IChannelServer, IDisposable { - private channels = new Map(); + private channels = new Map>(); private activeRequests = new Map(); private protocolListener: IDisposable | null; - constructor(private protocol: IMessagePassingProtocol) { + constructor(private protocol: IMessagePassingProtocol, private ctx: TContext) { this.protocolListener = this.protocol.onMessage(msg => this.onRawMessage(msg)); this.sendResponse({ type: ResponseType.Initialize }); } - registerChannel(channelName: string, channel: IChannel): void { + registerChannel(channelName: string, channel: IServerChannel): void { this.channels.set(channelName, channel); } @@ -274,7 +293,7 @@ export class ChannelServer implements IChannelServer, IDisposable { let promise: Thenable; try { - promise = channel.call(request.name, request.arg, cancellationTokenSource.token); + promise = channel.call(this.ctx, request.name, request.arg, cancellationTokenSource.token); } catch (err) { promise = Promise.reject(err); } @@ -308,7 +327,7 @@ export class ChannelServer implements IChannelServer, IDisposable { const channel = this.channels.get(request.channelName); const id = request.id; - const event = channel.listen(request.name, request.arg); + const event = channel.listen(this.ctx, request.name, request.arg); const disposable = event(data => this.sendResponse({ id, data, type: ResponseType.EventFire })); this.activeRequests.set(request.id, disposable); @@ -543,6 +562,10 @@ export interface ClientConnectionEvent { onDidClientDisconnect: Event; } +interface Connection extends Client { + readonly channelClient: ChannelClient; +} + /** * An `IPCServer` is both a channel server and a routing channel * client. @@ -551,15 +574,17 @@ export interface ClientConnectionEvent { * and the `IPCClient` classes to get IPC implementations * for your protocol. */ -export class IPCServer implements IChannelServer, IRoutingChannelClient, IDisposable { +export class IPCServer implements IChannelServer, IRoutingChannelClient, IConnectionHub, IDisposable { - private channels = new Map(); - private channelClients = new Map(); - private onClientAdded = new Emitter(); + private channels = new Map>(); + private _connections = new Set>(); - private get clientKeys(): string[] { - const result: string[] = []; - this.channelClients.forEach((_, key) => result.push(key)); + private _onDidChangeConnections = new Emitter>(); + readonly onDidChangeConnections: Event> = this._onDidChangeConnections.event; + + get connections(): Connection[] { + const result: Connection[] = []; + this._connections.forEach(ctx => result.push(ctx)); return result; } @@ -567,46 +592,42 @@ export class IPCServer implements IChannelServer, IRoutingChannelClient, IDispos onDidClientConnect(({ protocol, onDidClientDisconnect }) => { const onFirstMessage = once(protocol.onMessage); - onFirstMessage(rawId => { - const channelServer = new ChannelServer(protocol); + onFirstMessage(msg => { + const reader = new BufferReader(msg); + const ctx = deserialize(reader) as TContext; + + const channelServer = new ChannelServer(protocol, ctx); const channelClient = new ChannelClient(protocol); this.channels.forEach((channel, name) => channelServer.registerChannel(name, channel)); - const id = rawId.toString(); - - if (this.channelClients.has(id)) { - console.warn(`IPC client with id '${id}' is already registered.`); - } - - this.channelClients.set(id, channelClient); - this.onClientAdded.fire(id); + const connection: Connection = { channelClient, ctx }; + this._connections.add(connection); + this._onDidChangeConnections.fire(connection); onDidClientDisconnect(() => { channelServer.dispose(); channelClient.dispose(); - this.channelClients.delete(id); + this._connections.delete(connection); }); }); }); } - getChannel(channelName: string, router: IClientRouter): T { + getChannel(channelName: string, router: IClientRouter): T { const that = this; return { call(command: string, arg?: any, cancellationToken?: CancellationToken) { - const channelPromise = router.routeCall(that.clientKeys, command, arg) - .then(id => that.getClient(id)) - .then(client => client.getChannel(channelName)); + const channelPromise = router.routeCall(that, command, arg) + .then(connection => (connection as Connection).channelClient.getChannel(channelName)); return getDelayedChannel(channelPromise) .call(command, arg, cancellationToken); }, listen(event: string, arg: any) { - const channelPromise = router.routeEvent(that.clientKeys, event, arg) - .then(id => that.getClient(id)) - .then(client => client.getChannel(channelName)); + const channelPromise = router.routeEvent(that, event, arg) + .then(connection => (connection as Connection).channelClient.getChannel(channelName)); return getDelayedChannel(channelPromise) .listen(event, arg); @@ -614,31 +635,14 @@ export class IPCServer implements IChannelServer, IRoutingChannelClient, IDispos } as T; } - registerChannel(channelName: string, channel: IChannel): void { + registerChannel(channelName: string, channel: IServerChannel): void { this.channels.set(channelName, channel); } - private getClient(clientId: string): Thenable { - if (!clientId) { - return Promise.reject(new Error('Client id should be provided')); - } - - const client = this.channelClients.get(clientId); - - if (client) { - return Promise.resolve(client); - } - - return new Promise(c => { - const onClient = once(filterEvent(this.onClientAdded.event, id => id === clientId)); - onClient(() => c(this.channelClients.get(clientId))); - }); - } - dispose(): void { this.channels.clear(); - this.channelClients.clear(); - this.onClientAdded.dispose(); + this._connections.clear(); + this._onDidChangeConnections.dispose(); } } @@ -649,22 +653,25 @@ export class IPCServer implements IChannelServer, IRoutingChannelClient, IDispos * and the `IPCClient` classes to get IPC implementations * for your protocol. */ -export class IPCClient implements IChannelClient, IChannelServer, IDisposable { +export class IPCClient implements IChannelClient, IChannelServer, IDisposable { private channelClient: ChannelClient; - private channelServer: ChannelServer; + private channelServer: ChannelServer; + + constructor(protocol: IMessagePassingProtocol, ctx: TContext) { + const writer = new BufferWriter(); + serialize(writer, ctx); + protocol.send(writer.buffer); - constructor(protocol: IMessagePassingProtocol, id: string) { - protocol.send(Buffer.from(id)); this.channelClient = new ChannelClient(protocol); - this.channelServer = new ChannelServer(protocol); + this.channelServer = new ChannelServer(protocol, ctx); } getChannel(channelName: string): T { return this.channelClient.getChannel(channelName) as T; } - registerChannel(channelName: string, channel: IChannel): void { + registerChannel(channelName: string, channel: IServerChannel): void { this.channelServer.registerChannel(channelName, channel); } @@ -716,3 +723,27 @@ export function getNextTickChannel(channel: T): T { } } as T; } + +export class StaticRouter implements IClientRouter { + + constructor(private fn: (ctx: TContext) => boolean | Thenable) { } + + routeCall(hub: IConnectionHub): Thenable> { + return this.route(hub); + } + + routeEvent(hub: IConnectionHub): Thenable> { + return this.route(hub); + } + + private async route(hub: IConnectionHub): Promise> { + for (const connection of hub.connections) { + if (await Promise.resolve(this.fn(connection.ctx))) { + return Promise.resolve(connection); + } + } + + await toPromise(hub.onDidChangeConnections); + return await this.route(hub); + } +} \ No newline at end of file diff --git a/src/vs/base/parts/ipc/test/node/ipc.cp.test.ts b/src/vs/base/parts/ipc/test/node/ipc.cp.test.ts index 6aa818040b6..9f5e08b10d1 100644 --- a/src/vs/base/parts/ipc/test/node/ipc.cp.test.ts +++ b/src/vs/base/parts/ipc/test/node/ipc.cp.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import { Client } from 'vs/base/parts/ipc/node/ipc.cp'; import { always } from 'vs/base/common/async'; -import { ITestChannel, TestServiceClient } from './testService'; +import { TestServiceClient } from './testService'; import { getPathFromAmdModule } from 'vs/base/common/amd'; function createClient(): Client { @@ -19,7 +19,7 @@ function createClient(): Client { suite('IPC, Child Process', () => { test('createChannel', () => { const client = createClient(); - const channel = client.getChannel('test'); + const channel = client.getChannel('test'); const service = new TestServiceClient(channel); const result = service.pong('ping').then(r => { @@ -32,7 +32,7 @@ suite('IPC, Child Process', () => { test('events', () => { const client = createClient(); - const channel = client.getChannel('test'); + const channel = client.getChannel('test'); const service = new TestServiceClient(channel); const event = new Promise((c, e) => { @@ -54,7 +54,7 @@ suite('IPC, Child Process', () => { test('event dispose', () => { const client = createClient(); - const channel = client.getChannel('test'); + const channel = client.getChannel('test'); const service = new TestServiceClient(channel); let count = 0; 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 d35b0da140f..03810849fc7 100644 --- a/src/vs/base/parts/ipc/test/node/ipc.test.ts +++ b/src/vs/base/parts/ipc/test/node/ipc.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; -import { IMessagePassingProtocol, IPCServer, ClientConnectionEvent, IPCClient, IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IMessagePassingProtocol, IPCServer, ClientConnectionEvent, IPCClient, IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Emitter, toPromise, Event } from 'vs/base/common/event'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { canceled } from 'vs/base/common/errors'; @@ -54,7 +54,7 @@ function createProtocolPair(): [IMessagePassingProtocol, IMessagePassingProtocol return [one, other]; } -class TestIPCClient extends IPCClient { +class TestIPCClient extends IPCClient { private _onDidDisconnect = new Emitter(); readonly onDidDisconnect = this._onDidDisconnect.event; @@ -69,7 +69,7 @@ class TestIPCClient extends IPCClient { } } -class TestIPCServer extends IPCServer { +class TestIPCServer extends IPCServer { private onDidClientConnect: Emitter; @@ -79,7 +79,7 @@ class TestIPCServer extends IPCServer { this.onDidClientConnect = onDidClientConnect; } - createConnection(id: string): IPCClient { + createConnection(id: string): IPCClient { const [pc, ps] = createProtocolPair(); const client = new TestIPCClient(pc, id); @@ -138,23 +138,11 @@ class TestService implements ITestService { } } -interface ITestChannel extends IChannel { - call(command: 'marco'): Thenable; - call(command: 'error'): Thenable; - call(command: 'neverComplete'): Thenable; - call(command: 'neverCompleteCT', arg: undefined, cancellationToken: CancellationToken): Thenable; - call(command: 'buffersLength', arg: [Buffer, Buffer]): Thenable; - call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable; - - listen(event: 'pong'): Event; - listen(event: string, arg?: any): Event; -} - -class TestChannel implements ITestChannel { +class TestChannel implements IServerChannel { constructor(private service: ITestService) { } - call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable { + call(_, command: string, arg?: any, cancellationToken?: CancellationToken): Thenable { switch (command) { case 'marco': return this.service.marco(); case 'error': return this.service.error(arg); @@ -165,7 +153,7 @@ class TestChannel implements ITestChannel { } } - listen(event: string, arg?: any): Event { + listen(_, event: string, arg?: any): Event { switch (event) { case 'pong': return this.service.pong; default: throw new Error('not implemented'); @@ -179,7 +167,7 @@ class TestChannelClient implements ITestService { return this.channel.listen('pong'); } - constructor(private channel: ITestChannel) { } + constructor(private channel: IChannel) { } marco(): Thenable { return this.channel.call('marco'); diff --git a/src/vs/base/parts/ipc/test/node/testApp.ts b/src/vs/base/parts/ipc/test/node/testApp.ts index 0bdfaec73f4..905bf3cf92c 100644 --- a/src/vs/base/parts/ipc/test/node/testApp.ts +++ b/src/vs/base/parts/ipc/test/node/testApp.ts @@ -6,6 +6,6 @@ import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import { TestChannel, TestService } from './testService'; -const server = new Server(); +const server = new Server('test'); const service = new TestService(); server.registerChannel('test', new TestChannel(service)); \ 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 c673014e447..241402397d4 100644 --- a/src/vs/base/parts/ipc/test/node/testService.ts +++ b/src/vs/base/parts/ipc/test/node/testService.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event, Emitter } from 'vs/base/common/event'; import { timeout } from 'vs/base/common/async'; @@ -37,21 +37,11 @@ export class TestService implements ITestService { } } -export interface ITestChannel extends IChannel { - listen(event: 'marco'): Event; - listen(event: string, arg?: any): Event; - - call(command: 'marco'): Thenable; - call(command: 'pong', ping: string): Thenable; - call(command: 'cancelMe'): Thenable; - call(command: string, ...args: any[]): Thenable; -} - -export class TestChannel implements ITestChannel { +export class TestChannel implements IServerChannel { constructor(private testService: ITestService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { switch (event) { case 'marco': return this.testService.onMarco; } @@ -59,12 +49,12 @@ export class TestChannel implements ITestChannel { throw new Error('Event not found'); } - call(command: string, ...args: any[]): Thenable { + call(_, command: string, ...args: any[]): Thenable { switch (command) { case 'pong': return this.testService.pong(args[0]); case 'cancelMe': return this.testService.cancelMe(); case 'marco': return this.testService.marco(); - default: return Promise.reject(new Error('command not found')); + default: return Promise.reject(new Error(`command not found: ${command}`)); } } } @@ -73,7 +63,7 @@ export class TestServiceClient implements ITestService { get onMarco(): Event { return this.channel.listen('marco'); } - constructor(private channel: ITestChannel) { } + constructor(private channel: IChannel) { } marco(): Thenable { return this.channel.call('marco'); diff --git a/src/vs/code/electron-browser/issue/issueReporterMain.ts b/src/vs/code/electron-browser/issue/issueReporterMain.ts index 1d46130f930..5cb0d8887f3 100644 --- a/src/vs/code/electron-browser/issue/issueReporterMain.ts +++ b/src/vs/code/electron-browser/issue/issueReporterMain.ts @@ -24,7 +24,7 @@ import { IWindowConfiguration, IWindowsService } from 'vs/platform/windows/commo import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform/telemetry/common/telemetryUtils'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; -import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; +import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties'; @@ -283,7 +283,7 @@ export class IssueReporter extends Disposable { const instantiationService = new InstantiationService(serviceCollection, true); if (!this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) { - const channel = getDelayedChannel(sharedProcess.then(c => c.getChannel('telemetryAppender'))); + const channel = getDelayedChannel(sharedProcess.then(c => c.getChannel('telemetryAppender'))); const appender = combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(logService)); const commonProperties = resolveCommonProperties(product.commit, pkg.version, configuration.machineId, this.environmentService.installSourcePath); const piiPaths = [this.environmentService.appRoot, this.environmentService.extensionsPath]; diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index 80b226f75a3..e2a5b65a496 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -46,6 +46,7 @@ import { IDownloadService } from 'vs/platform/download/common/download'; import { RemoteAuthorityResolverService } from 'vs/platform/remote/node/remoteAuthorityResolverService'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { RemoteAuthorityResolverChannel } from 'vs/platform/remote/node/remoteAuthorityResolverChannel'; +import { StaticRouter } from 'vs/base/parts/ipc/node/ipc'; export interface ISharedProcessConfiguration { readonly machineId: string; @@ -75,8 +76,9 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I disposables.push(server); const environmentService = new EnvironmentService(initData.args, process.execPath); - const mainRoute = () => TPromise.as('main'); - const logLevelClient = new LogLevelSetterChannelClient(server.getChannel('loglevel', { routeCall: mainRoute, routeEvent: mainRoute })); + + const mainRouter = new StaticRouter(ctx => ctx === 'main'); + const logLevelClient = new LogLevelSetterChannelClient(server.getChannel('loglevel', mainRouter)); const logService = new FollowerLogService(logLevelClient, createSpdLogService('sharedprocess', initData.logLevel, environmentService.logsPath)); disposables.push(logService); @@ -88,14 +90,13 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I services.set(IRequestService, new SyncDescriptor(RequestService)); services.set(IDownloadService, new SyncDescriptor(DownloadService)); - const windowsChannel = server.getChannel('windows', { routeCall: mainRoute, routeEvent: mainRoute }); + const windowsChannel = server.getChannel('windows', mainRouter); const windowsService = new WindowsChannelClient(windowsChannel); services.set(IWindowsService, windowsService); const activeWindowManager = new ActiveWindowManager(windowsService); - const route = () => activeWindowManager.getActiveClientId(); - - const dialogChannel = server.getChannel('dialog', { routeCall: route, routeEvent: route }); + const activeWindowRouter = new StaticRouter(ctx => activeWindowManager.getActiveClientId().then(id => ctx === id)); + const dialogChannel = server.getChannel('dialog', activeWindowRouter); services.set(IDialogService, new DialogChannelClient(dialogChannel)); const instantiationService = new InstantiationService(services); diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 2690ee96114..96a7e5f9f12 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -29,10 +29,10 @@ import { IURLService } from 'vs/platform/url/common/url'; import { URLHandlerChannelClient, URLServiceChannel } from 'vs/platform/url/node/urlIpc'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform/telemetry/common/telemetryUtils'; -import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; +import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties'; -import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc'; +import { getDelayedChannel, StaticRouter } from 'vs/base/parts/ipc/node/ipc'; import product from 'vs/platform/node/product'; import pkg from 'vs/platform/node/package'; import { ProxyAuthHandler } from 'vs/code/electron-main/auth'; @@ -70,8 +70,8 @@ import { nativeSep, join } from 'vs/base/common/paths'; import { homedir } from 'os'; import { localize } from 'vs/nls'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; -import { IRemoteAuthorityResolverChannel, RemoteAuthorityResolverChannelClient } from 'vs/platform/remote/node/remoteAuthorityResolverChannel'; -import { IRemoteAgentFileSystemChannel, REMOTE_FILE_SYSTEM_CHANNEL_NAME } from 'vs/platform/remote/node/remoteAgentFileSystemChannel'; +import { RemoteAuthorityResolverChannelClient } from 'vs/platform/remote/node/remoteAuthorityResolverChannel'; +import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from 'vs/platform/remote/node/remoteAgentFileSystemChannel'; import { ResolvedAuthority } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { SnapUpdateService } from 'vs/platform/update/electron-main/updateService.snap'; @@ -210,7 +210,7 @@ export class CodeApplication { activeConnection = connectionPool.get(uri.authority); } else { if (this.sharedProcessClient) { - const remoteAuthorityResolverChannel = getDelayedChannel(this.sharedProcessClient.then(c => c.getChannel('remoteAuthorityResolver'))); + const remoteAuthorityResolverChannel = getDelayedChannel(this.sharedProcessClient.then(c => c.getChannel('remoteAuthorityResolver'))); const remoteAuthorityResolverChannelClient = new RemoteAuthorityResolverChannelClient(remoteAuthorityResolverChannel); activeConnection = new ActiveConnection(uri.authority, remoteAuthorityResolverChannelClient.resolveAuthority(uri.authority)); connectionPool.set(uri.authority, activeConnection); @@ -219,8 +219,10 @@ export class CodeApplication { try { const rawClient = await activeConnection.getClient(); if (connectionPool.has(uri.authority)) { // not disposed in the meantime - const channel = rawClient.getChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME); - const fileContents = await channel.call('readFile', [uri.authority, uri]); + const channel = rawClient.getChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME); + + // TODO@alex don't use call directly, wrap it around a `RemoteExtensionsFileSystemProvider` + const fileContents = await channel.call('readFile', [uri.authority, uri]); callback(Buffer.from(fileContents)); } else { callback(null); @@ -510,7 +512,7 @@ export class CodeApplication { // Telemtry if (!this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) { - const channel = getDelayedChannel(this.sharedProcessClient.then(c => c.getChannel('telemetryAppender'))); + const channel = getDelayedChannel(this.sharedProcessClient.then(c => c.getChannel('telemetryAppender'))); const appender = combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(this.logService)); const commonProperties = resolveCommonProperties(product.commit, pkg.version, machineId, this.environmentService.installSourcePath); const piiPaths = [this.environmentService.appRoot, this.environmentService.extensionsPath]; @@ -573,8 +575,8 @@ export class CodeApplication { // Create a URL handler which forwards to the last active window const activeWindowManager = new ActiveWindowManager(windowsService); - const route = () => activeWindowManager.getActiveClientId(); - const urlHandlerChannel = this.electronIpcServer.getChannel('urlHandler', { routeCall: route, routeEvent: route }); + const activeWindowRouter = new StaticRouter(ctx => activeWindowManager.getActiveClientId().then(id => ctx === id)); + const urlHandlerChannel = this.electronIpcServer.getChannel('urlHandler', activeWindowRouter); const multiplexURLHandler = new URLHandlerChannelClient(urlHandlerChannel); // On Mac, Code can be running without any open windows, so we must create a window to handle urls, diff --git a/src/vs/code/electron-main/logUploader.ts b/src/vs/code/electron-main/logUploader.ts index 7bc22e237a4..ed1a038a81b 100644 --- a/src/vs/code/electron-main/logUploader.ts +++ b/src/vs/code/electron-main/logUploader.ts @@ -9,12 +9,12 @@ import * as fs from 'fs'; import * as path from 'path'; import { localize } from 'vs/nls'; -import { ILaunchChannel } from 'vs/platform/launch/electron-main/launchService'; import product from 'vs/platform/node/product'; import { IRequestService } from 'vs/platform/request/node/request'; import { IRequestContext } from 'vs/base/node/request'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { CancellationToken } from 'vs/base/common/cancellation'; +import { ILaunchService } from 'vs/platform/launch/electron-main/launchService'; interface PostResult { readonly blob_id: string; @@ -32,7 +32,7 @@ class Endpoint { } export async function uploadLogs( - channel: ILaunchChannel, + launchService: ILaunchService, requestService: IRequestService, environmentService: IEnvironmentService ): Promise { @@ -42,7 +42,7 @@ export async function uploadLogs( return; } - const logsPath = await channel.call('get-logs-path', null); + const logsPath = await launchService.getLogsPath(); if (await promptUserToConfirmLogUpload(logsPath, environmentService)) { console.log(localize('beginUploading', 'Uploading...')); diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index d777186c48f..767670d355f 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -15,7 +15,7 @@ import { validatePaths } from 'vs/code/node/paths'; import { LifecycleService, ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain'; import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net'; import { TPromise } from 'vs/base/common/winjs.base'; -import { ILaunchChannel, LaunchChannelClient } from 'vs/platform/launch/electron-main/launchService'; +import { LaunchChannelClient } from 'vs/platform/launch/electron-main/launchService'; import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { InstantiationService } from 'vs/platform/instantiation/node/instantiationService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; @@ -196,7 +196,7 @@ function setupIPC(accessor: ServicesAccessor): Thenable { }, 10000); } - const channel = client.getChannel('launch'); + const channel = client.getChannel('launch'); const service = new LaunchChannelClient(channel); // Process Info @@ -208,7 +208,7 @@ function setupIPC(accessor: ServicesAccessor): Thenable { // Log uploader if (typeof environmentService.args['upload-logs'] !== 'undefined') { - return uploadLogs(channel, requestService, environmentService) + return uploadLogs(service, requestService, environmentService) .then(() => Promise.reject(new ExpectedError())); } diff --git a/src/vs/platform/dialogs/node/dialogIpc.ts b/src/vs/platform/dialogs/node/dialogIpc.ts index 07be979e3b3..c4011630aaa 100644 --- a/src/vs/platform/dialogs/node/dialogIpc.ts +++ b/src/vs/platform/dialogs/node/dialogIpc.ts @@ -4,26 +4,20 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs'; import Severity from 'vs/base/common/severity'; import { Event } from 'vs/base/common/event'; -export interface IDialogChannel extends IChannel { - call(command: 'show'): Thenable; - call(command: 'confirm'): Thenable; - call(command: string, arg?: any): Thenable; -} - -export class DialogChannel implements IDialogChannel { +export class DialogChannel implements IServerChannel { constructor(@IDialogService private dialogService: IDialogService) { } - listen(event: string): Event { - throw new Error('No event found'); + listen(_, event: string): Event { + throw new Error(`Event not found: ${event}`); } - call(command: string, args?: any[]): Thenable { + call(_, command: string, args?: any[]): Thenable { switch (command) { case 'show': return this.dialogService.show(args![0], args![1], args![2]); case 'confirm': return this.dialogService.confirm(args![0]); @@ -36,7 +30,7 @@ export class DialogChannelClient implements IDialogService { _serviceBrand: any; - constructor(private channel: IDialogChannel) { } + constructor(private channel: IChannel) { } show(severity: Severity, message: string, options: string[]): TPromise { return TPromise.wrap(this.channel.call('show', [severity, message, options])); diff --git a/src/vs/platform/download/node/downloadIpc.ts b/src/vs/platform/download/node/downloadIpc.ts index 75cf0a204d5..dab6733be58 100644 --- a/src/vs/platform/download/node/downloadIpc.ts +++ b/src/vs/platform/download/node/downloadIpc.ts @@ -7,7 +7,7 @@ import { URI } from 'vs/base/common/uri'; import * as path from 'path'; import * as fs from 'fs'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event, Emitter, buffer } from 'vs/base/common/event'; import { IDownloadService } from 'vs/platform/download/common/download'; import { mkdirp } from 'vs/base/node/pfs'; @@ -24,24 +24,20 @@ export function upload(uri: URI): Event { return stream.event; } -export interface IDownloadServiceChannel extends IChannel { - listen(event: 'upload', uri: URI): Event; - listen(event: string, arg?: any): Event; -} - -export class DownloadServiceChannel implements IDownloadServiceChannel { +export class DownloadServiceChannel implements IServerChannel { constructor() { } - listen(event: string, arg?: any): Event { + listen(_, event: string, arg?: any): Event { switch (event) { case 'upload': return buffer(upload(URI.revive(arg))); } - throw new Error(`Call not found: ${event}`); + + throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): TPromise { - throw new Error('No calls'); + call(_, command: string): TPromise { + throw new Error(`Call not found: ${command}`); } } @@ -49,7 +45,7 @@ export class DownloadServiceChannelClient implements IDownloadService { _serviceBrand: any; - constructor(private channel: IDownloadServiceChannel, private uriTransformer: IURITransformer) { } + constructor(private channel: IChannel, private uriTransformer: IURITransformer) { } download(from: URI, to: string): Promise { from = this.uriTransformer.transformOutgoing(from); diff --git a/src/vs/platform/driver/electron-main/driver.ts b/src/vs/platform/driver/electron-main/driver.ts index 56a9f6dac98..b5cfae7f8e1 100644 --- a/src/vs/platform/driver/electron-main/driver.ts +++ b/src/vs/platform/driver/electron-main/driver.ts @@ -4,12 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IDriver, DriverChannel, IElement, IWindowDriverChannel, WindowDriverChannelClient, IWindowDriverRegistry, WindowDriverRegistryChannel, IWindowDriver, IDriverOptions } from 'vs/platform/driver/node/driver'; +import { IDriver, DriverChannel, IElement, WindowDriverChannelClient, IWindowDriverRegistry, WindowDriverRegistryChannel, IWindowDriver, IDriverOptions } from 'vs/platform/driver/node/driver'; import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows'; import { serve as serveNet } from 'vs/base/parts/ipc/node/ipc.net'; import { combinedDisposable, IDisposable } from 'vs/base/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IPCServer, IClientRouter } from 'vs/base/parts/ipc/node/ipc'; +import { IPCServer, StaticRouter } from 'vs/base/parts/ipc/node/ipc'; import { SimpleKeybinding, KeyCode } from 'vs/base/common/keyCodes'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; import { OS } from 'vs/base/common/platform'; @@ -19,19 +19,6 @@ import { ScanCodeBinding } from 'vs/base/common/scanCode'; import { KeybindingParser } from 'vs/base/common/keybindingParser'; import { timeout } from 'vs/base/common/async'; -class WindowRouter implements IClientRouter { - - constructor(private windowId: number) { } - - routeCall(): TPromise { - return TPromise.as(`window:${this.windowId}`); - } - - routeEvent(): TPromise { - return TPromise.as(`window:${this.windowId}`); - } -} - function isSilentKeyCode(keyCode: KeyCode) { return keyCode < KeyCode.KEY_0; } @@ -196,8 +183,9 @@ export class Driver implements IDriver, IWindowDriverRegistry { private getWindowDriver(windowId: number): TPromise { return this.whenUnfrozen(windowId).then(() => { - const router = new WindowRouter(windowId); - const windowDriverChannel = this.windowServer.getChannel('windowDriver', router); + const id = `window:${windowId}`; + const router = new StaticRouter(ctx => ctx === id); + const windowDriverChannel = this.windowServer.getChannel('windowDriver', router); return new WindowDriverChannelClient(windowDriverChannel); }); } diff --git a/src/vs/platform/driver/node/driver.ts b/src/vs/platform/driver/node/driver.ts index 9ac264e01f4..2337f164adc 100644 --- a/src/vs/platform/driver/node/driver.ts +++ b/src/vs/platform/driver/node/driver.ts @@ -6,7 +6,7 @@ import { connect as connectNet, Client } from 'vs/base/parts/ipc/node/ipc.net'; import { TPromise } from 'vs/base/common/winjs.base'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event } from 'vs/base/common/event'; export const ID = 'driverService'; @@ -44,32 +44,15 @@ export interface IDriver { } //*END -export interface IDriverChannel extends IChannel { - call(command: 'getWindowIds'): Thenable; - call(command: 'capturePage'): Thenable; - call(command: 'reloadWindow', arg: number): Thenable; - call(command: 'dispatchKeybinding', arg: [number, string]): Thenable; - call(command: 'click', arg: [number, string, number | undefined, number | undefined]): Thenable; - call(command: 'doubleClick', arg: [number, string]): Thenable; - call(command: 'setValue', arg: [number, string, string]): Thenable; - call(command: 'getTitle', arg: [number]): Thenable; - call(command: 'isActiveElement', arg: [number, string]): Thenable; - call(command: 'getElements', arg: [number, string, boolean]): Thenable; - call(command: 'typeInEditor', arg: [number, string, string]): Thenable; - call(command: 'getTerminalBuffer', arg: [number, string]): Thenable; - call(command: 'writeInTerminal', arg: [number, string, string]): Thenable; - call(command: string, arg: any): Thenable; -} - -export class DriverChannel implements IDriverChannel { +export class DriverChannel implements IServerChannel { constructor(private driver: IDriver) { } - listen(event: string): Event { + listen(_, event: string): Event { throw new Error('No event found'); } - call(command: string, arg?: any): TPromise { + call(_, command: string, arg?: any): TPromise { switch (command) { case 'getWindowIds': return this.driver.getWindowIds(); case 'capturePage': return this.driver.capturePage(arg); @@ -94,7 +77,7 @@ export class DriverChannelClient implements IDriver { _serviceBrand: any; - constructor(private channel: IDriverChannel) { } + constructor(private channel: IChannel) { } getWindowIds(): TPromise { return TPromise.wrap(this.channel.call('getWindowIds')); @@ -158,21 +141,15 @@ export interface IWindowDriverRegistry { reloadWindowDriver(windowId: number): TPromise; } -export interface IWindowDriverRegistryChannel extends IChannel { - call(command: 'registerWindowDriver', arg: number): Thenable; - call(command: 'reloadWindowDriver', arg: number): Thenable; - call(command: string, arg: any): Thenable; -} - -export class WindowDriverRegistryChannel implements IWindowDriverRegistryChannel { +export class WindowDriverRegistryChannel implements IServerChannel { constructor(private registry: IWindowDriverRegistry) { } - listen(event: string): Event { - throw new Error('No event found'); + listen(_, event: string): Event { + throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'registerWindowDriver': return this.registry.registerWindowDriver(arg); case 'reloadWindowDriver': return this.registry.reloadWindowDriver(arg); @@ -186,7 +163,7 @@ export class WindowDriverRegistryChannelClient implements IWindowDriverRegistry _serviceBrand: any; - constructor(private channel: IWindowDriverRegistryChannel) { } + constructor(private channel: IChannel) { } registerWindowDriver(windowId: number): TPromise { return TPromise.wrap(this.channel.call('registerWindowDriver', windowId)); @@ -209,28 +186,15 @@ export interface IWindowDriver { writeInTerminal(selector: string, text: string): TPromise; } -export interface IWindowDriverChannel extends IChannel { - call(command: 'click', arg: [string, number | undefined, number | undefined]): Thenable; - call(command: 'doubleClick', arg: string): Thenable; - call(command: 'setValue', arg: [string, string]): Thenable; - call(command: 'getTitle'): Thenable; - call(command: 'isActiveElement', arg: string): Thenable; - call(command: 'getElements', arg: [string, boolean]): Thenable; - call(command: 'typeInEditor', arg: [string, string]): Thenable; - call(command: 'getTerminalBuffer', arg: string): Thenable; - call(command: 'writeInTerminal', arg: [string, string]): Thenable; - call(command: string, arg: any): Thenable; -} - -export class WindowDriverChannel implements IWindowDriverChannel { +export class WindowDriverChannel implements IServerChannel { constructor(private driver: IWindowDriver) { } - listen(event: string): Event { - throw new Error('No event found'); + listen(_, event: string): Event { + throw new Error(`No event found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'click': return this.driver.click(arg[0], arg[1], arg[2]); case 'doubleClick': return this.driver.doubleClick(arg); @@ -251,7 +215,7 @@ export class WindowDriverChannelClient implements IWindowDriver { _serviceBrand: any; - constructor(private channel: IWindowDriverChannel) { } + constructor(private channel: IChannel) { } click(selector: string, xoffset?: number, yoffset?: number): TPromise { return TPromise.wrap(this.channel.call('click', [selector, xoffset, yoffset])); diff --git a/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts b/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts index 0bce6d8d03c..3d31fdf08d6 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts @@ -3,30 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IExtensionManagementService, ILocalExtension, InstallExtensionEvent, DidInstallExtensionEvent, IGalleryExtension, LocalExtensionType, DidUninstallExtensionEvent, IExtensionIdentifier, IGalleryMetadata, IReportedExtension } from '../common/extensionManagement'; import { Event, buffer, mapEvent } from 'vs/base/common/event'; import { URI } from 'vs/base/common/uri'; import { IURITransformer } from 'vs/base/common/uriIpc'; -export interface IExtensionManagementChannel extends IChannel { - listen(event: 'onInstallExtension'): Event; - listen(event: 'onDidInstallExtension'): Event; - listen(event: 'onUninstallExtension'): Event; - listen(event: 'onDidUninstallExtension'): Event; - - call(command: 'zip', args: [ILocalExtension]): Thenable; - call(command: 'unzip', args: [URI, LocalExtensionType]): Thenable; - call(command: 'install', args: [URI]): Thenable; - call(command: 'installFromGallery', args: [IGalleryExtension]): Thenable; - call(command: 'uninstall', args: [ILocalExtension, boolean]): Thenable; - call(command: 'reinstallFromGallery', args: [ILocalExtension]): Thenable; - call(command: 'getInstalled', args: [LocalExtensionType | null]): Thenable; - call(command: 'getExtensionsReport'): Thenable; - call(command: 'updateMetadata', args: [ILocalExtension, IGalleryMetadata]): Thenable; -} - -export class ExtensionManagementChannel implements IExtensionManagementChannel { +export class ExtensionManagementChannel implements IServerChannel { onInstallExtension: Event; onDidInstallExtension: Event; @@ -40,7 +23,7 @@ export class ExtensionManagementChannel implements IExtensionManagementChannel { this.onDidUninstallExtension = buffer(service.onDidUninstallExtension, true); } - listen(event: string): Event { + listen(_, event: string): Event { switch (event) { case 'onInstallExtension': return this.onInstallExtension; case 'onDidInstallExtension': return this.onDidInstallExtension; @@ -51,7 +34,7 @@ export class ExtensionManagementChannel implements IExtensionManagementChannel { throw new Error('Invalid listen'); } - call(command: string, args?: any): Thenable { + call(_, command: string, args?: any): Thenable { switch (command) { case 'zip': return this.service.zip(this._transform(args[0])); case 'unzip': return this.service.unzip(URI.revive(args[0]), args[1]); @@ -76,15 +59,15 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer _serviceBrand: any; - constructor(private channel: IExtensionManagementChannel, private uriTransformer: IURITransformer) { } + constructor(private channel: IChannel, private uriTransformer: IURITransformer) { } get onInstallExtension(): Event { return this.channel.listen('onInstallExtension'); } - get onDidInstallExtension(): Event { return mapEvent(this.channel.listen('onDidInstallExtension'), i => ({ ...i, local: this._transformIncoming(i.local) })); } + get onDidInstallExtension(): Event { return mapEvent(this.channel.listen('onDidInstallExtension'), i => ({ ...i, local: this._transformIncoming(i.local) })); } get onUninstallExtension(): Event { return this.channel.listen('onUninstallExtension'); } get onDidUninstallExtension(): Event { return this.channel.listen('onDidUninstallExtension'); } zip(extension: ILocalExtension): Promise { - return Promise.resolve(this.channel.call('zip', [this._transformOutgoing(extension)]).then(result => URI.revive(this.uriTransformer.transformIncoming(result)))); + return Promise.resolve(this.channel.call('zip', [this._transformOutgoing(extension)]).then(result => URI.revive(this.uriTransformer.transformIncoming(result)))); } unzip(zipLocation: URI, type: LocalExtensionType): Promise { @@ -108,12 +91,12 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer } getInstalled(type: LocalExtensionType | null = null): Promise { - return Promise.resolve(this.channel.call('getInstalled', [type])) + return Promise.resolve(this.channel.call('getInstalled', [type])) .then(extensions => extensions.map(extension => this._transformIncoming(extension))); } updateMetadata(local: ILocalExtension, metadata: IGalleryMetadata): Promise { - return Promise.resolve(this.channel.call('updateMetadata', [this._transformOutgoing(local), metadata])) + return Promise.resolve(this.channel.call('updateMetadata', [this._transformOutgoing(local), metadata])) .then(extension => this._transformIncoming(extension)); } diff --git a/src/vs/platform/issue/common/issue.ts b/src/vs/platform/issue/common/issue.ts index 774a737636e..1d8f9d66284 100644 --- a/src/vs/platform/issue/common/issue.ts +++ b/src/vs/platform/issue/common/issue.ts @@ -87,6 +87,6 @@ export interface ProcessExplorerData extends WindowData { export interface IIssueService { _serviceBrand: any; - openReporter(data: IssueReporterData): Promise; - openProcessExplorer(data: ProcessExplorerData): Promise; + openReporter(data: IssueReporterData): Thenable; + openProcessExplorer(data: ProcessExplorerData): Thenable; } diff --git a/src/vs/platform/issue/node/issueIpc.ts b/src/vs/platform/issue/node/issueIpc.ts index 604c527ac29..c6b2ad7e786 100644 --- a/src/vs/platform/issue/node/issueIpc.ts +++ b/src/vs/platform/issue/node/issueIpc.ts @@ -3,25 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IIssueService, IssueReporterData, ProcessExplorerData } from '../common/issue'; import { Event } from 'vs/base/common/event'; -export interface IIssueChannel extends IChannel { - call(command: 'openIssueReporter', arg: IssueReporterData): Promise; - call(command: 'getStatusInfo'): Promise; - call(command: string, arg?: any): Promise; -} - -export class IssueChannel implements IIssueChannel { +export class IssueChannel implements IServerChannel { constructor(private service: IIssueService) { } - listen(event: string): Event { + listen(_, event: string): Event { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Promise { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'openIssueReporter': return this.service.openReporter(arg); @@ -37,13 +31,13 @@ export class IssueChannelClient implements IIssueService { _serviceBrand: any; - constructor(private channel: IIssueChannel) { } + constructor(private channel: IChannel) { } - openReporter(data: IssueReporterData): Promise { + openReporter(data: IssueReporterData): Thenable { return this.channel.call('openIssueReporter', data); } - openProcessExplorer(data: ProcessExplorerData): Promise { + openProcessExplorer(data: ProcessExplorerData): Thenable { return this.channel.call('openProcessExplorer', data); } } \ No newline at end of file diff --git a/src/vs/platform/launch/electron-main/launchService.ts b/src/vs/platform/launch/electron-main/launchService.ts index ae7227a277b..ebc0c2ee496 100644 --- a/src/vs/platform/launch/electron-main/launchService.ts +++ b/src/vs/platform/launch/electron-main/launchService.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { ILogService } from 'vs/platform/log/common/log'; import { IURLService } from 'vs/platform/url/common/url'; import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform'; @@ -67,23 +67,15 @@ export interface ILaunchService { getLogsPath(): TPromise; } -export interface ILaunchChannel extends IChannel { - call(command: 'start', arg: IStartArguments): TPromise; - call(command: 'get-main-process-id', arg: null): TPromise; - call(command: 'get-main-process-info', arg: null): TPromise; - call(command: 'get-logs-path', arg: null): TPromise; - call(command: string, arg: any): TPromise; -} - -export class LaunchChannel implements ILaunchChannel { +export class LaunchChannel implements IServerChannel { constructor(private service: ILaunchService) { } - listen(event: string): Event { - throw new Error('No event found'); + listen(_, event: string): Event { + throw new Error(`Event not found: ${event}`); } - call(command: string, arg: any): TPromise { + call(_, command: string, arg: any): TPromise { switch (command) { case 'start': const { args, userEnv } = arg as IStartArguments; @@ -107,7 +99,7 @@ export class LaunchChannelClient implements ILaunchService { _serviceBrand: any; - constructor(private channel: ILaunchChannel) { } + constructor(private channel: IChannel) { } start(args: ParsedArgs, userEnv: IProcessEnvironment): TPromise { return this.channel.call('start', { args, userEnv }); diff --git a/src/vs/platform/localizations/node/localizationsIpc.ts b/src/vs/platform/localizations/node/localizationsIpc.ts index 38330e3cdb9..e4f968b3fbb 100644 --- a/src/vs/platform/localizations/node/localizationsIpc.ts +++ b/src/vs/platform/localizations/node/localizationsIpc.ts @@ -3,19 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event, buffer } from 'vs/base/common/event'; import { ILocalizationsService, LanguageType } from 'vs/platform/localizations/common/localizations'; -export interface ILocalizationsChannel extends IChannel { - listen(event: 'onDidLanguagesChange'): Event; - listen(event: string, arg?: any): Event; - - call(command: 'getLanguageIds'): Thenable; - call(command: string, arg?: any): Thenable; -} - -export class LocalizationsChannel implements ILocalizationsChannel { +export class LocalizationsChannel implements IServerChannel { onDidLanguagesChange: Event; @@ -23,7 +15,7 @@ export class LocalizationsChannel implements ILocalizationsChannel { this.onDidLanguagesChange = buffer(service.onDidLanguagesChange, true); } - listen(event: string): Event { + listen(_, event: string): Event { switch (event) { case 'onDidLanguagesChange': return this.onDidLanguagesChange; } @@ -31,7 +23,7 @@ export class LocalizationsChannel implements ILocalizationsChannel { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'getLanguageIds': return this.service.getLanguageIds(arg); } @@ -44,7 +36,7 @@ export class LocalizationsChannelClient implements ILocalizationsService { _serviceBrand: any; - constructor(private channel: ILocalizationsChannel) { } + constructor(private channel: IChannel) { } get onDidLanguagesChange(): Event { return this.channel.listen('onDidLanguagesChange'); } diff --git a/src/vs/platform/log/node/logIpc.ts b/src/vs/platform/log/node/logIpc.ts index b9a342222e4..9e655ee69a6 100644 --- a/src/vs/platform/log/node/logIpc.ts +++ b/src/vs/platform/log/node/logIpc.ts @@ -3,19 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { LogLevel, ILogService, DelegatedLogService } from 'vs/platform/log/common/log'; import { Event, buffer } from 'vs/base/common/event'; -export interface ILogLevelSetterChannel extends IChannel { - listen(event: 'onDidChangeLogLevel'): Event; - listen(event: string, arg?: any): Event; - - call(command: 'setLevel', logLevel: LogLevel): void; - call(command: string, arg?: any): Thenable; -} - -export class LogLevelSetterChannel implements ILogLevelSetterChannel { +export class LogLevelSetterChannel implements IServerChannel { onDidChangeLogLevel: Event; @@ -23,7 +15,7 @@ export class LogLevelSetterChannel implements ILogLevelSetterChannel { this.onDidChangeLogLevel = buffer(service.onDidChangeLogLevel, true); } - listen(event: string): Event { + listen(_, event: string): Event { switch (event) { case 'onDidChangeLogLevel': return this.onDidChangeLogLevel; } @@ -31,7 +23,7 @@ export class LogLevelSetterChannel implements ILogLevelSetterChannel { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'setLevel': this.service.setLevel(arg); } @@ -42,7 +34,7 @@ export class LogLevelSetterChannel implements ILogLevelSetterChannel { export class LogLevelSetterChannelClient { - constructor(private channel: ILogLevelSetterChannel) { } + constructor(private channel: IChannel) { } get onDidChangeLogLevel(): Event { return this.channel.listen('onDidChangeLogLevel'); diff --git a/src/vs/platform/menubar/node/menubarIpc.ts b/src/vs/platform/menubar/node/menubarIpc.ts index 7d6b0c4d844..a5315dbb973 100644 --- a/src/vs/platform/menubar/node/menubarIpc.ts +++ b/src/vs/platform/menubar/node/menubarIpc.ts @@ -2,25 +2,20 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { TPromise } from 'vs/base/common/winjs.base'; import { IMenubarService, IMenubarData } from 'vs/platform/menubar/common/menubar'; import { Event } from 'vs/base/common/event'; -export interface IMenubarChannel extends IChannel { - call(command: 'updateMenubar', arg: [number, IMenubarData]): TPromise; - call(command: string, arg?: any): TPromise; -} - -export class MenubarChannel implements IMenubarChannel { +export class MenubarChannel implements IServerChannel { constructor(private service: IMenubarService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): TPromise { + call(_, command: string, arg?: any): TPromise { switch (command) { case 'updateMenubar': return this.service.updateMenubar(arg[0], arg[1]); } @@ -33,7 +28,7 @@ export class MenubarChannelClient implements IMenubarService { _serviceBrand: any; - constructor(private channel: IMenubarChannel) { } + constructor(private channel: IChannel) { } updateMenubar(windowId: number, menuData: IMenubarData): TPromise { return this.channel.call('updateMenubar', [windowId, menuData]); diff --git a/src/vs/platform/remote/node/remoteAgentFileSystemChannel.ts b/src/vs/platform/remote/node/remoteAgentFileSystemChannel.ts index 13cf3c40da3..e207427a624 100644 --- a/src/vs/platform/remote/node/remoteAgentFileSystemChannel.ts +++ b/src/vs/platform/remote/node/remoteAgentFileSystemChannel.ts @@ -17,27 +17,11 @@ export interface IFileChangeDto { type: FileChangeType; } -export interface IRemoteAgentFileSystemChannel extends IChannel { - call(command: 'stat', arg: [string, UriComponents]): Thenable; - call(command: 'readdir', arg: [string, UriComponents]): Thenable<[string, FileType][]>; - call(command: 'readFile', arg: [string, UriComponents]): Thenable; - call(command: 'writeFile', arg: [string, UriComponents, /*base64*/string, FileWriteOptions]): Thenable; - call(command: 'rename', arg: [string, UriComponents, UriComponents, FileOverwriteOptions]): Thenable; - call(command: 'copy', arg: [string, UriComponents, UriComponents, FileOverwriteOptions]): Thenable; - call(command: 'mkdir', arg: [string, UriComponents]): Thenable; - call(command: 'delete', arg: [string, UriComponents, FileDeleteOptions]): Thenable; - call(command: 'watch', arg: [string, string, number, UriComponents, IWatchOptions]): void; - call(command: 'unwatch', arg: [string, number]): void; - call(command: 'keepWatching', arg: [string]): void; - - listen(event: 'filechange', arg: [string, string]): Event; -} - export class RemoteExtensionsFileSystemProvider extends Disposable implements IFileSystemProvider { private readonly _session: string; private readonly _remoteAuthority: string; - private readonly _channel: IRemoteAgentFileSystemChannel; + private readonly _channel: IChannel; private readonly _onDidChange = this._register(new Emitter()); readonly onDidChangeFile: Event = this._onDidChange.event; @@ -45,7 +29,7 @@ export class RemoteExtensionsFileSystemProvider extends Disposable implements IF constructor( remoteAuthority: string, - channel: IRemoteAgentFileSystemChannel, + channel: IChannel, isCaseSensitive: boolean ) { super(); diff --git a/src/vs/platform/remote/node/remoteAuthorityResolverChannel.ts b/src/vs/platform/remote/node/remoteAuthorityResolverChannel.ts index f55f55c43e5..3f62707c52c 100644 --- a/src/vs/platform/remote/node/remoteAuthorityResolverChannel.ts +++ b/src/vs/platform/remote/node/remoteAuthorityResolverChannel.ts @@ -3,21 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event, buffer } from 'vs/base/common/event'; import { ResolvedAuthority, IResolvingProgressEvent, IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; -import { CancellationToken } from 'vs/base/common/cancellation'; -export interface IRemoteAuthorityResolverChannel extends IChannel { - listen(event: 'onResolvingProgress'): Event; - listen(event: string, arg?: any): Event; - - call(command: 'resolveAuthority', args: [string]): Thenable; - call(command: 'getLabel', args: [string]): Thenable; - call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable; -} - -export class RemoteAuthorityResolverChannel implements IRemoteAuthorityResolverChannel { +export class RemoteAuthorityResolverChannel implements IServerChannel { onResolvingProgress: Event; @@ -25,7 +15,7 @@ export class RemoteAuthorityResolverChannel implements IRemoteAuthorityResolverC this.onResolvingProgress = buffer(service.onResolvingProgress, true); } - listen(event: string): Event { + listen(_, event: string): Event { switch (event) { case 'onResolvingProgress': return this.onResolvingProgress; } @@ -33,7 +23,7 @@ export class RemoteAuthorityResolverChannel implements IRemoteAuthorityResolverC throw new Error('Invalid listen'); } - call(command: string, args?: any): Thenable { + call(_, command: string, args?: any): Thenable { switch (command) { case 'resolveAuthority': return this.service.resolveAuthority(args[0]); case 'getLabel': return this.service.getLabel(args[0]); @@ -50,7 +40,7 @@ export class RemoteAuthorityResolverChannelClient implements IRemoteAuthorityRes private _resolveAuthorityCache: { [authority: string]: Thenable; }; get onResolvingProgress(): Event { return buffer(this.channel.listen('onResolvingProgress'), true); } - constructor(private channel: IRemoteAuthorityResolverChannel) { + constructor(private channel: IChannel) { this._resolveAuthorityCache = Object.create(null); } diff --git a/src/vs/platform/telemetry/node/telemetryIpc.ts b/src/vs/platform/telemetry/node/telemetryIpc.ts index 7952f069535..a99e372fa31 100644 --- a/src/vs/platform/telemetry/node/telemetryIpc.ts +++ b/src/vs/platform/telemetry/node/telemetryIpc.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils'; import { Event } from 'vs/base/common/event'; @@ -12,20 +12,15 @@ export interface ITelemetryLog { data?: any; } -export interface ITelemetryAppenderChannel extends IChannel { - call(command: 'log', data: ITelemetryLog): Thenable; - call(command: string, arg: any): Thenable; -} - -export class TelemetryAppenderChannel implements ITelemetryAppenderChannel { +export class TelemetryAppenderChannel implements IServerChannel { constructor(private appender: ITelemetryAppender) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { throw new Error(`Event not found: ${event}`); } - call(command: string, { eventName, data }: ITelemetryLog): Thenable { + call(_, command: string, { eventName, data }: ITelemetryLog): Thenable { this.appender.log(eventName, data); return Promise.resolve(null); } @@ -33,7 +28,7 @@ export class TelemetryAppenderChannel implements ITelemetryAppenderChannel { export class TelemetryAppenderClient implements ITelemetryAppender { - constructor(private channel: ITelemetryAppenderChannel) { } + constructor(private channel: IChannel) { } log(eventName: string, data?: any): any { this.channel.call('log', { eventName, data }) diff --git a/src/vs/platform/update/node/updateIpc.ts b/src/vs/platform/update/node/updateIpc.ts index 24b7d3c731b..7c01e2a791f 100644 --- a/src/vs/platform/update/node/updateIpc.ts +++ b/src/vs/platform/update/node/updateIpc.ts @@ -4,28 +4,15 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Event, Emitter } from 'vs/base/common/event'; import { IUpdateService, State } from 'vs/platform/update/common/update'; -export interface IUpdateChannel extends IChannel { - listen(event: 'onStateChange'): Event; - listen(command: string, arg?: any): Event; - - call(command: 'checkForUpdates', arg: any): TPromise; - call(command: 'downloadUpdate'): TPromise; - call(command: 'applyUpdate'): TPromise; - call(command: 'quitAndInstall'): TPromise; - call(command: '_getInitialState'): TPromise; - call(command: 'isLatestVersion'): TPromise; - call(command: string, arg?: any): TPromise; -} - -export class UpdateChannel implements IUpdateChannel { +export class UpdateChannel implements IServerChannel { constructor(private service: IUpdateService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { switch (event) { case 'onStateChange': return this.service.onStateChange; } @@ -33,7 +20,7 @@ export class UpdateChannel implements IUpdateChannel { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): TPromise { + call(_, command: string, arg?: any): TPromise { switch (command) { case 'checkForUpdates': return this.service.checkForUpdates(arg); case 'downloadUpdate': return this.service.downloadUpdate(); @@ -57,17 +44,17 @@ export class UpdateChannelClient implements IUpdateService { private _state: State = State.Uninitialized; get state(): State { return this._state; } - constructor(private channel: IUpdateChannel) { + constructor(private channel: IChannel) { // always set this._state as the state changes this.onStateChange(state => this._state = state); - channel.call('_getInitialState').then(state => { + channel.call('_getInitialState').then(state => { // fire initial state this._onStateChange.fire(state); // fire subsequent states as they come in from remote - this.channel.listen('onStateChange')(state => this._onStateChange.fire(state)); + this.channel.listen('onStateChange')(state => this._onStateChange.fire(state)); }); } diff --git a/src/vs/platform/url/node/urlIpc.ts b/src/vs/platform/url/node/urlIpc.ts index c723fc94adc..40e14de4b9b 100644 --- a/src/vs/platform/url/node/urlIpc.ts +++ b/src/vs/platform/url/node/urlIpc.ts @@ -3,26 +3,21 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { URI } from 'vs/base/common/uri'; import { IDisposable } from 'vs/base/common/lifecycle'; import { Event } from 'vs/base/common/event'; import { IURLService, IURLHandler } from 'vs/platform/url/common/url'; -export interface IURLServiceChannel extends IChannel { - call(command: 'open', url: string): Thenable; - call(command: string, arg?: any): Thenable; -} - -export class URLServiceChannel implements IURLServiceChannel { +export class URLServiceChannel implements IServerChannel { constructor(private service: IURLService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'open': return this.service.open(URI.revive(arg)); } @@ -46,20 +41,15 @@ export class URLServiceChannelClient implements IURLService { } } -export interface IURLHandlerChannel extends IChannel { - call(command: 'handleURL', arg: any): Thenable; - call(command: string, arg?: any): Thenable; -} - -export class URLHandlerChannel implements IURLHandlerChannel { +export class URLHandlerChannel implements IServerChannel { constructor(private handler: IURLHandler) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'handleURL': return this.handler.handleURL(URI.revive(arg)); } diff --git a/src/vs/platform/windows/node/windowsIpc.ts b/src/vs/platform/windows/node/windowsIpc.ts index 580df050d5f..033a993802a 100644 --- a/src/vs/platform/windows/node/windowsIpc.ts +++ b/src/vs/platform/windows/node/windowsIpc.ts @@ -5,78 +5,15 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { Event, buffer } from 'vs/base/common/event'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows'; import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; -import { URI, UriComponents } from 'vs/base/common/uri'; +import { URI } from 'vs/base/common/uri'; import { ParsedArgs } from 'vs/platform/environment/common/environment'; -export interface IWindowsChannel extends IChannel { - listen(event: 'onWindowOpen'): Event; - listen(event: 'onWindowFocus'): Event; - listen(event: 'onWindowBlur'): Event; - listen(event: 'onWindowMaximize'): Event; - listen(event: 'onWindowUnmaximize'): Event; - listen(event: 'onRecentlyOpenedChange'): Event; - listen(event: string, arg?: any): Event; - - call(command: 'pickFileFolderAndOpen', arg: INativeOpenDialogOptions): Thenable; - call(command: 'pickFileAndOpen', arg: INativeOpenDialogOptions): Thenable; - call(command: 'pickFolderAndOpen', arg: INativeOpenDialogOptions): Thenable; - call(command: 'pickWorkspaceAndOpen', arg: INativeOpenDialogOptions): Thenable; - call(command: 'showMessageBox', arg: [number, MessageBoxOptions]): Thenable; - call(command: 'showSaveDialog', arg: [number, SaveDialogOptions]): Thenable; - call(command: 'showOpenDialog', arg: [number, OpenDialogOptions]): Thenable; - call(command: 'reloadWindow', arg: [number, ParsedArgs | undefined]): Thenable; - call(command: 'openDevTools', arg: [number, IDevToolsOptions | undefined]): Thenable; - call(command: 'toggleDevTools', arg: number): Thenable; - call(command: 'closeWorkspace', arg: number): Thenable; - call(command: 'enterWorkspace', arg: [number, string]): Thenable; - call(command: 'createAndEnterWorkspace', arg: [number, IWorkspaceFolderCreationData[] | undefined, string | undefined]): Thenable; - call(command: 'saveAndEnterWorkspace', arg: [number, string]): Thenable; - call(command: 'toggleFullScreen', arg: number): Thenable; - call(command: 'setRepresentedFilename', arg: [number, string]): Thenable; - call(command: 'addRecentlyOpened', arg: UriComponents[]): Thenable; - call(command: 'removeFromRecentlyOpened', arg: (IWorkspaceIdentifier | UriComponents | string)[]): Thenable; - call(command: 'clearRecentlyOpened'): Thenable; - call(command: 'getRecentlyOpened', arg: number): Thenable; - call(command: 'newWindowTab'): Thenable; - call(command: 'showPreviousWindowTab'): Thenable; - call(command: 'showNextWindowTab'): Thenable; - call(command: 'moveWindowTabToNewWindow'): Thenable; - call(command: 'mergeAllWindowTabs'): Thenable; - call(command: 'toggleWindowTabsBar'): Thenable; - call(command: 'updateTouchBar', arg: [number, ISerializableCommandAction[][]]): Thenable; - call(command: 'focusWindow', arg: number): Thenable; - call(command: 'closeWindow', arg: number): Thenable; - call(command: 'isFocused', arg: number): Thenable; - call(command: 'isMaximized', arg: number): Thenable; - call(command: 'maximizeWindow', arg: number): Thenable; - call(command: 'unmaximizeWindow', arg: number): Thenable; - call(command: 'minimizeWindow', arg: number): Thenable; - call(command: 'onWindowTitleDoubleClick', arg: number): Thenable; - call(command: 'setDocumentEdited', arg: [number, boolean]): Thenable; - call(command: 'quit'): Thenable; - call(command: 'openWindow', arg: [number, URI[], { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs } | undefined]): Thenable; - call(command: 'openNewWindow', arg?: INewWindowOptions): Thenable; - call(command: 'showWindow', arg: number): Thenable; - call(command: 'getWindows'): Thenable<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>; - call(command: 'getWindowCount'): Thenable; - call(command: 'relaunch', arg: [{ addArgs?: string[], removeArgs?: string[] }]): Thenable; - call(command: 'whenSharedProcessReady'): Thenable; - call(command: 'toggleSharedProcess'): Thenable; - call(command: 'log', arg: [string, string[]]): Thenable; - call(command: 'showItemInFolder', arg: string): Thenable; - call(command: 'getActiveWindowId'): Thenable; - call(command: 'openExternal', arg: string): Thenable; - call(command: 'startCrashReporter', arg: CrashReporterStartOptions): Thenable; - call(command: 'openAboutDialog'): Thenable; - call(command: 'resolveProxy', arg: [number, string]): Thenable; -} - -export class WindowsChannel implements IWindowsChannel { +export class WindowsChannel implements IServerChannel { private onWindowOpen: Event; private onWindowFocus: Event; @@ -94,7 +31,7 @@ export class WindowsChannel implements IWindowsChannel { this.onRecentlyOpenedChange = buffer(service.onRecentlyOpenedChange, true); } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { switch (event) { case 'onWindowOpen': return this.onWindowOpen; case 'onWindowFocus': return this.onWindowFocus; @@ -107,7 +44,7 @@ export class WindowsChannel implements IWindowsChannel { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'pickFileFolderAndOpen': return this.service.pickFileFolderAndOpen(arg); case 'pickFileAndOpen': return this.service.pickFileAndOpen(arg); @@ -190,7 +127,7 @@ export class WindowsChannelClient implements IWindowsService { _serviceBrand: any; - constructor(private channel: IWindowsChannel) { } + constructor(private channel: IChannel) { } get onWindowOpen(): Event { return this.channel.listen('onWindowOpen'); } get onWindowFocus(): Event { return this.channel.listen('onWindowFocus'); } @@ -276,7 +213,7 @@ export class WindowsChannelClient implements IWindowsService { } getRecentlyOpened(windowId: number): TPromise { - return TPromise.wrap(this.channel.call('getRecentlyOpened', windowId)) + return TPromise.wrap(this.channel.call('getRecentlyOpened', windowId)) .then(recentlyOpened => { recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace)); recentlyOpened.files = recentlyOpened.files.map(URI.revive); @@ -373,7 +310,7 @@ export class WindowsChannelClient implements IWindowsService { } getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { - return TPromise.wrap(this.channel.call('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; })); + return TPromise.wrap(this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; })); } getWindowCount(): TPromise { diff --git a/src/vs/platform/workspaces/node/workspacesIpc.ts b/src/vs/platform/workspaces/node/workspacesIpc.ts index 2b9bd3bf815..333407eff5c 100644 --- a/src/vs/platform/workspaces/node/workspacesIpc.ts +++ b/src/vs/platform/workspaces/node/workspacesIpc.ts @@ -4,25 +4,20 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces'; import { URI } from 'vs/base/common/uri'; import { Event } from 'vs/base/common/event'; -export interface IWorkspacesChannel extends IChannel { - call(command: 'createWorkspace', arg: [IWorkspaceFolderCreationData[]]): Thenable; - call(command: string, arg?: any): Thenable; -} - -export class WorkspacesChannel implements IWorkspacesChannel { +export class WorkspacesChannel implements IServerChannel { constructor(private service: IWorkspacesMainService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string): Event { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): Thenable { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'createWorkspace': { const rawFolders: IWorkspaceFolderCreationData[] = arg; @@ -48,7 +43,7 @@ export class WorkspacesChannelClient implements IWorkspacesService { _serviceBrand: any; - constructor(private channel: IWorkspacesChannel) { } + constructor(private channel: IChannel) { } createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise { return TPromise.wrap(this.channel.call('createWorkspace', folders)); diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 27bf7dbb337..359f095b2af 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -17,7 +17,7 @@ import pkg from 'vs/platform/node/package'; import { Workbench, IWorkbenchStartedInfo } from 'vs/workbench/electron-browser/workbench'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService, configurationTelemetry, combinedAppender, LogAppender } from 'vs/platform/telemetry/common/telemetryUtils'; -import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; +import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry'; import { ElectronWindow } from 'vs/workbench/electron-browser/window'; @@ -56,7 +56,7 @@ import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/serv import { ICrashReporterService, NullCrashReporterService, CrashReporterService } from 'vs/workbench/services/crashReporter/electron-browser/crashReporterService'; import { getDelayedChannel, IPCClient } from 'vs/base/parts/ipc/node/ipc'; import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net'; -import { IExtensionManagementChannel, ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/node/extensionManagementIpc'; +import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/node/extensionManagementIpc'; import { IExtensionManagementService, IExtensionEnablementService, IExtensionManagementServerService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionEnablementService'; import { BareFontInfo } from 'vs/editor/common/config/fontInfo'; @@ -78,7 +78,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { DelegatingStorageService } from 'vs/platform/storage/node/storageService'; import { Event, Emitter } from 'vs/base/common/event'; import { WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme'; -import { ILocalizationsChannel, LocalizationsChannelClient } from 'vs/platform/localizations/node/localizationsIpc'; +import { LocalizationsChannelClient } from 'vs/platform/localizations/node/localizationsIpc'; import { ILocalizationsService } from 'vs/platform/localizations/common/localizations'; import { IWorkbenchIssueService } from 'vs/workbench/services/issue/common/issue'; import { WorkbenchIssueService } from 'vs/workbench/services/issue/electron-browser/workbenchIssueService'; @@ -105,7 +105,7 @@ import { runWhenIdle } from 'vs/base/common/async'; import { TextResourcePropertiesService } from 'vs/workbench/services/textfile/electron-browser/textResourcePropertiesService'; import { MulitExtensionManagementService } from 'vs/platform/extensionManagement/node/multiExtensionManagement'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; -import { RemoteAuthorityResolverChannelClient, IRemoteAuthorityResolverChannel } from 'vs/platform/remote/node/remoteAuthorityResolverChannel'; +import { RemoteAuthorityResolverChannelClient } from 'vs/platform/remote/node/remoteAuthorityResolverChannel'; /** * Services that we require for the Shell @@ -419,7 +419,7 @@ export class WorkbenchShell extends Disposable { // Telemetry if (!this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) { - const channel = getDelayedChannel(sharedProcess.then(c => c.getChannel('telemetryAppender'))); + const channel = getDelayedChannel(sharedProcess.then(c => c.getChannel('telemetryAppender'))); const config: ITelemetryServiceConfig = { appender: combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(this.logService)), commonProperties: resolveWorkbenchCommonProperties(this.storageService, product.commit, pkg.version, this.configuration.machineId, this.environmentService.installSourcePath), @@ -456,7 +456,7 @@ export class WorkbenchShell extends Disposable { serviceCollection.set(IDownloadService, new SyncDescriptor(DownloadService)); serviceCollection.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService)); - const remoteAuthorityResolverChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('remoteAuthorityResolver'))); + const remoteAuthorityResolverChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('remoteAuthorityResolver'))); const remoteAuthorityResolverService = new RemoteAuthorityResolverChannelClient(remoteAuthorityResolverChannel); serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService); @@ -470,7 +470,7 @@ export class WorkbenchShell extends Disposable { remoteAgentConnection.registerChannel('loglevel', new LogLevelSetterChannel(this.logService)); } - const extensionManagementChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('extensions'))); + const extensionManagementChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('extensions'))); const extensionManagementChannelClient = new ExtensionManagementChannelClient(extensionManagementChannel, DefaultURITransformer); serviceCollection.set(IExtensionManagementServerService, new SyncDescriptor(ExtensionManagementServerService, [extensionManagementChannelClient])); serviceCollection.set(IExtensionManagementService, new SyncDescriptor(MulitExtensionManagementService)); @@ -513,7 +513,7 @@ export class WorkbenchShell extends Disposable { serviceCollection.set(IIntegrityService, new SyncDescriptor(IntegrityServiceImpl)); - const localizationsChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('localizations'))); + const localizationsChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('localizations'))); serviceCollection.set(ILocalizationsService, new SyncDescriptor(LocalizationsChannelClient, [localizationsChannel])); return [instantiationService, serviceCollection]; diff --git a/src/vs/workbench/parts/debug/node/telemetryApp.ts b/src/vs/workbench/parts/debug/node/telemetryApp.ts index 490dc714fcc..affab685550 100644 --- a/src/vs/workbench/parts/debug/node/telemetryApp.ts +++ b/src/vs/workbench/parts/debug/node/telemetryApp.ts @@ -11,5 +11,5 @@ const appender = new AppInsightsAppender(process.argv[2], JSON.parse(process.arg process.once('exit', () => appender.dispose()); const channel = new TelemetryAppenderChannel(appender); -const server = new Server(); +const server = new Server('telemetry'); server.registerChannel('telemetryAppender', channel); diff --git a/src/vs/workbench/services/files/node/watcher/nsfw/watcherApp.ts b/src/vs/workbench/services/files/node/watcher/nsfw/watcherApp.ts index b16b7d8dcbd..49c892fb588 100644 --- a/src/vs/workbench/services/files/node/watcher/nsfw/watcherApp.ts +++ b/src/vs/workbench/services/files/node/watcher/nsfw/watcherApp.ts @@ -7,7 +7,7 @@ import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import { WatcherChannel } from 'vs/workbench/services/files/node/watcher/nsfw/watcherIpc'; import { NsfwWatcherService } from 'vs/workbench/services/files/node/watcher/nsfw/nsfwWatcherService'; -const server = new Server(); +const server = new Server('watcher'); const service = new NsfwWatcherService(); const channel = new WatcherChannel(service); server.registerChannel('watcher', channel); \ No newline at end of file diff --git a/src/vs/workbench/services/files/node/watcher/nsfw/watcherIpc.ts b/src/vs/workbench/services/files/node/watcher/nsfw/watcherIpc.ts index 2ed86714ba9..e57440b636e 100644 --- a/src/vs/workbench/services/files/node/watcher/nsfw/watcherIpc.ts +++ b/src/vs/workbench/services/files/node/watcher/nsfw/watcherIpc.ts @@ -4,26 +4,16 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWatcherRequest, IWatcherService, IWatcherOptions, IWatchError } from './watcher'; import { Event } from 'vs/base/common/event'; import { IRawFileChange } from 'vs/workbench/services/files/node/watcher/common'; -export interface IWatcherChannel extends IChannel { - listen(event: 'watch', verboseLogging: boolean): Event; - listen(event: string, arg?: any): Event; - - call(command: 'setRoots', request: IWatcherRequest[]): TPromise; - call(command: 'setVerboseLogging', enable: boolean): TPromise; - call(command: 'stop'): TPromise; - call(command: string, arg?: any): TPromise; -} - -export class WatcherChannel implements IWatcherChannel { +export class WatcherChannel implements IServerChannel { constructor(private service: IWatcherService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string, arg?: any): Event { switch (event) { case 'watch': return this.service.watch(arg); } @@ -31,7 +21,7 @@ export class WatcherChannel implements IWatcherChannel { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): TPromise { + call(_, command: string, arg?: any): TPromise { switch (command) { case 'setRoots': return this.service.setRoots(arg); case 'setVerboseLogging': return this.service.setVerboseLogging(arg); @@ -44,7 +34,7 @@ export class WatcherChannel implements IWatcherChannel { export class WatcherChannelClient implements IWatcherService { - constructor(private channel: IWatcherChannel) { } + constructor(private channel: IChannel) { } watch(options: IWatcherOptions): Event { return this.channel.listen('watch', options); diff --git a/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts b/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts index f41fa26c915..bd201a3867a 100644 --- a/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts @@ -6,7 +6,7 @@ import { getNextTickChannel } from 'vs/base/parts/ipc/node/ipc'; import { Client } from 'vs/base/parts/ipc/node/ipc.cp'; import { toFileChangesEvent, IRawFileChange } from 'vs/workbench/services/files/node/watcher/common'; -import { IWatcherChannel, WatcherChannelClient } from 'vs/workbench/services/files/node/watcher/nsfw/watcherIpc'; +import { WatcherChannelClient } from 'vs/workbench/services/files/node/watcher/nsfw/watcherIpc'; import { FileChangesEvent, IFilesConfiguration } from 'vs/platform/files/common/files'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -65,7 +65,7 @@ export class FileWatcher { }, null, this.toDispose); // Initialize watcher - const channel = getNextTickChannel(client.getChannel('watcher')); + const channel = getNextTickChannel(client.getChannel('watcher')); this.service = new WatcherChannelClient(channel); const options = { verboseLogging: this.verboseLogging }; 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 b79e9870583..01473fb5c88 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/watcherApp.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/watcherApp.ts @@ -7,7 +7,7 @@ import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import { WatcherChannel } from 'vs/workbench/services/files/node/watcher/unix/watcherIpc'; import { ChokidarWatcherService } from 'vs/workbench/services/files/node/watcher/unix/chokidarWatcherService'; -const server = new Server(); +const server = new Server('watcher'); const service = new ChokidarWatcherService(); const channel = new WatcherChannel(service); server.registerChannel('watcher', channel); \ No newline at end of file diff --git a/src/vs/workbench/services/files/node/watcher/unix/watcherIpc.ts b/src/vs/workbench/services/files/node/watcher/unix/watcherIpc.ts index 2ed86714ba9..e57440b636e 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/watcherIpc.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/watcherIpc.ts @@ -4,26 +4,16 @@ *--------------------------------------------------------------------------------------------*/ import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWatcherRequest, IWatcherService, IWatcherOptions, IWatchError } from './watcher'; import { Event } from 'vs/base/common/event'; import { IRawFileChange } from 'vs/workbench/services/files/node/watcher/common'; -export interface IWatcherChannel extends IChannel { - listen(event: 'watch', verboseLogging: boolean): Event; - listen(event: string, arg?: any): Event; - - call(command: 'setRoots', request: IWatcherRequest[]): TPromise; - call(command: 'setVerboseLogging', enable: boolean): TPromise; - call(command: 'stop'): TPromise; - call(command: string, arg?: any): TPromise; -} - -export class WatcherChannel implements IWatcherChannel { +export class WatcherChannel implements IServerChannel { constructor(private service: IWatcherService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string, arg?: any): Event { switch (event) { case 'watch': return this.service.watch(arg); } @@ -31,7 +21,7 @@ export class WatcherChannel implements IWatcherChannel { throw new Error(`Event not found: ${event}`); } - call(command: string, arg?: any): TPromise { + call(_, command: string, arg?: any): TPromise { switch (command) { case 'setRoots': return this.service.setRoots(arg); case 'setVerboseLogging': return this.service.setVerboseLogging(arg); @@ -44,7 +34,7 @@ export class WatcherChannel implements IWatcherChannel { export class WatcherChannelClient implements IWatcherService { - constructor(private channel: IWatcherChannel) { } + constructor(private channel: IChannel) { } watch(options: IWatcherOptions): Event { return this.channel.listen('watch', options); 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 d06d203c7a0..7c52f216585 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts @@ -6,7 +6,7 @@ import { getNextTickChannel } from 'vs/base/parts/ipc/node/ipc'; import { Client } from 'vs/base/parts/ipc/node/ipc.cp'; import { toFileChangesEvent, IRawFileChange } from 'vs/workbench/services/files/node/watcher/common'; -import { IWatcherChannel, WatcherChannelClient } from 'vs/workbench/services/files/node/watcher/unix/watcherIpc'; +import { WatcherChannelClient } from 'vs/workbench/services/files/node/watcher/unix/watcherIpc'; import { FileChangesEvent, IFilesConfiguration } from 'vs/platform/files/common/files'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; @@ -67,7 +67,7 @@ export class FileWatcher { } }, null, this.toDispose); - const channel = getNextTickChannel(client.getChannel('watcher')); + const channel = getNextTickChannel(client.getChannel('watcher')); this.service = new WatcherChannelClient(channel); const options = { verboseLogging: this.verboseLogging }; diff --git a/src/vs/workbench/services/issue/electron-browser/workbenchIssueService.ts b/src/vs/workbench/services/issue/electron-browser/workbenchIssueService.ts index 6fc02a2fe80..a0a07804c19 100644 --- a/src/vs/workbench/services/issue/electron-browser/workbenchIssueService.ts +++ b/src/vs/workbench/services/issue/electron-browser/workbenchIssueService.ts @@ -57,7 +57,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService { }); } - openProcessExplorer(): Promise { + openProcessExplorer(): Thenable { const theme = this.themeService.getTheme(); const data: ProcessExplorerData = { pid: this.windowService.getConfiguration().mainPid, diff --git a/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts b/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts index 0ea561e86f8..c8a70709057 100644 --- a/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts +++ b/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts @@ -5,7 +5,7 @@ import { localize } from 'vs/nls'; import { Disposable } from 'vs/base/common/lifecycle'; -import { IChannel, getDelayedChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, getDelayedChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { Client } from 'vs/base/parts/ipc/node/ipc.net'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -70,7 +70,7 @@ class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection return getDelayedChannel(this._getOrCreateConnection().then(c => c.getChannel(channelName))); } - registerChannel(channelName: string, channel: T): void { + registerChannel(channelName: string, channel: T): void { this._getOrCreateConnection().then(client => client.registerChannel(channelName, channel)); } diff --git a/src/vs/workbench/services/remote/node/remoteAgentEnvironmentChannel.ts b/src/vs/workbench/services/remote/node/remoteAgentEnvironmentChannel.ts index 4ce538b0a36..1db9073cae3 100644 --- a/src/vs/workbench/services/remote/node/remoteAgentEnvironmentChannel.ts +++ b/src/vs/workbench/services/remote/node/remoteAgentEnvironmentChannel.ts @@ -20,17 +20,12 @@ export interface IRemoteAgentEnvironmentDTO { os: OperatingSystem; } -export interface IRemoteAgentEnvironmentChannel extends IChannel { - call(command: 'getEnvironmentData', args: [string, string]): Promise; - call(command: string, arg?: any): Promise; -} - export class RemoteExtensionEnvironmentChannelClient { - constructor(private channel: IRemoteAgentEnvironmentChannel) { } + constructor(private channel: IChannel) { } - getEnvironmentData(remoteAuthority: string, extensionDevelopmentPath?: URI): Promise { - return this.channel.call('getEnvironmentData', [remoteAuthority, extensionDevelopmentPath]) + getEnvironmentData(remoteAuthority: string, extensionDevelopmentPath?: URI): Thenable { + return this.channel.call('getEnvironmentData', [remoteAuthority, extensionDevelopmentPath]) .then((data: IRemoteAgentEnvironmentDTO): IRemoteAgentEnvironment => { return { pid: data.pid, diff --git a/src/vs/workbench/services/remote/node/remoteAgentService.ts b/src/vs/workbench/services/remote/node/remoteAgentService.ts index 479ce0d7d3f..3a4042cc4a7 100644 --- a/src/vs/workbench/services/remote/node/remoteAgentService.ts +++ b/src/vs/workbench/services/remote/node/remoteAgentService.ts @@ -5,7 +5,7 @@ import { OperatingSystem } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; @@ -36,5 +36,5 @@ export interface IRemoteAgentConnection { getEnvironment(): Thenable; getChannel(channelName: string): T; - registerChannel(channelName: string, channel: T); + registerChannel(channelName: string, channel: T); } diff --git a/src/vs/workbench/services/search/node/legacy/textSearchWorkerProvider.ts b/src/vs/workbench/services/search/node/legacy/textSearchWorkerProvider.ts index 617bd4ed0c4..ac848db101e 100644 --- a/src/vs/workbench/services/search/node/legacy/textSearchWorkerProvider.ts +++ b/src/vs/workbench/services/search/node/legacy/textSearchWorkerProvider.ts @@ -8,7 +8,7 @@ import * as os from 'os'; import * as ipc from 'vs/base/parts/ipc/node/ipc'; import { Client } from 'vs/base/parts/ipc/node/ipc.cp'; -import { ISearchWorker, ISearchWorkerChannel, SearchWorkerChannelClient } from './worker/searchWorkerIpc'; +import { ISearchWorker, SearchWorkerChannelClient } from './worker/searchWorkerIpc'; import { getPathFromAmdModule } from 'vs/base/common/amd'; export interface ITextSearchWorkerProvider { @@ -42,7 +42,7 @@ export class TextSearchWorkerProvider implements ITextSearchWorkerProvider { useQueue: true }); - const channel = ipc.getNextTickChannel(client.getChannel('searchWorker')); + const channel = ipc.getNextTickChannel(client.getChannel('searchWorker')); const channelClient = new SearchWorkerChannelClient(channel); this.workers.push(channelClient); diff --git a/src/vs/workbench/services/search/node/legacy/worker/searchWorkerApp.ts b/src/vs/workbench/services/search/node/legacy/worker/searchWorkerApp.ts index da7c64e7b39..3abda129ab4 100644 --- a/src/vs/workbench/services/search/node/legacy/worker/searchWorkerApp.ts +++ b/src/vs/workbench/services/search/node/legacy/worker/searchWorkerApp.ts @@ -7,7 +7,7 @@ import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import { SearchWorkerChannel } from './searchWorkerIpc'; import { SearchWorker } from './searchWorker'; -const server = new Server(); +const server = new Server('searchWorker'); const worker = new SearchWorker(); const channel = new SearchWorkerChannel(worker); server.registerChannel('searchWorker', channel); diff --git a/src/vs/workbench/services/search/node/legacy/worker/searchWorkerIpc.ts b/src/vs/workbench/services/search/node/legacy/worker/searchWorkerIpc.ts index d082554ea2f..1a8fb436fd6 100644 --- a/src/vs/workbench/services/search/node/legacy/worker/searchWorkerIpc.ts +++ b/src/vs/workbench/services/search/node/legacy/worker/searchWorkerIpc.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IPatternInfo, ITextSearchPreviewOptions } from 'vs/platform/search/common/search'; import { SearchWorker } from './searchWorker'; import { Event } from 'vs/base/common/event'; @@ -24,27 +24,20 @@ export interface ISearchWorkerSearchResult { } export interface ISearchWorker { - initialize(): Promise; - search(args: ISearchWorkerSearchArgs): Promise; - cancel(): Promise; + initialize(): Thenable; + search(args: ISearchWorkerSearchArgs): Thenable; + cancel(): Thenable; } -export interface ISearchWorkerChannel extends IChannel { - call(command: 'initialize'): Promise; - call(command: 'search', args: ISearchWorkerSearchArgs): Promise; - call(command: 'cancel'): Promise; - call(command: string, arg?: any): Promise; -} - -export class SearchWorkerChannel implements ISearchWorkerChannel { +export class SearchWorkerChannel implements IServerChannel { constructor(private worker: SearchWorker) { } - listen(event: string, arg?: any): Event { + listen(): Event { throw new Error('No events'); } - call(command: string, arg?: any): Promise { + call(_, command: string, arg?: any): Promise { switch (command) { case 'initialize': return this.worker.initialize(); case 'search': return this.worker.search(arg); @@ -55,17 +48,17 @@ export class SearchWorkerChannel implements ISearchWorkerChannel { } export class SearchWorkerChannelClient implements ISearchWorker { - constructor(private channel: ISearchWorkerChannel) { } + constructor(private channel: IChannel) { } - initialize(): Promise { + initialize(): Thenable { return this.channel.call('initialize'); } - search(args: ISearchWorkerSearchArgs): Promise { + search(args: ISearchWorkerSearchArgs): Thenable { return this.channel.call('search', args); } - cancel(): Promise { + cancel(): Thenable { return this.channel.call('cancel'); } } diff --git a/src/vs/workbench/services/search/node/search.ts b/src/vs/workbench/services/search/node/search.ts index 965d5c0a6bf..631a515b463 100644 --- a/src/vs/workbench/services/search/node/search.ts +++ b/src/vs/workbench/services/search/node/search.ts @@ -16,7 +16,7 @@ export interface ITelemetryEvent { export interface IRawSearchService { fileSearch(search: IRawFileQuery): Event; textSearch(search: IRawTextQuery): Event; - clearCache(cacheKey: string): Promise; + clearCache(cacheKey: string): Thenable; } export interface IRawFileMatch { diff --git a/src/vs/workbench/services/search/node/searchApp.ts b/src/vs/workbench/services/search/node/searchApp.ts index d4a163cc74c..37b8a367d2d 100644 --- a/src/vs/workbench/services/search/node/searchApp.ts +++ b/src/vs/workbench/services/search/node/searchApp.ts @@ -7,7 +7,7 @@ import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import { SearchChannel } from './searchIpc'; import { SearchService } from './rawSearchService'; -const server = new Server(); +const server = new Server('search'); const service = new SearchService(); const channel = new SearchChannel(service); server.registerChannel('search', channel); \ No newline at end of file diff --git a/src/vs/workbench/services/search/node/searchIpc.ts b/src/vs/workbench/services/search/node/searchIpc.ts index 618f2f8c82c..484aea61897 100644 --- a/src/vs/workbench/services/search/node/searchIpc.ts +++ b/src/vs/workbench/services/search/node/searchIpc.ts @@ -4,22 +4,15 @@ *--------------------------------------------------------------------------------------------*/ import { Event } from 'vs/base/common/event'; -import { IChannel } from 'vs/base/parts/ipc/node/ipc'; +import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IRawFileQuery, IRawTextQuery } from 'vs/platform/search/common/search'; import { IRawSearchService, ISerializedSearchComplete, ISerializedSearchProgressItem } from './search'; -export interface ISearchChannel extends IChannel { - listen(event: 'fileSearch', search: IRawFileQuery): Event; - listen(event: 'textSearch', search: IRawTextQuery): Event; - call(command: 'clearCache', cacheKey: string): Promise; - call(command: string, arg: any): Promise; -} - -export class SearchChannel implements ISearchChannel { +export class SearchChannel implements IServerChannel { constructor(private service: IRawSearchService) { } - listen(event: string, arg?: any): Event { + listen(_, event: string, arg?: any): Event { switch (event) { case 'fileSearch': return this.service.fileSearch(arg); case 'textSearch': return this.service.textSearch(arg); @@ -27,7 +20,7 @@ export class SearchChannel implements ISearchChannel { throw new Error('Event not found'); } - call(command: string, arg?: any): Promise { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'clearCache': return this.service.clearCache(arg); } @@ -37,7 +30,7 @@ export class SearchChannel implements ISearchChannel { export class SearchChannelClient implements IRawSearchService { - constructor(private channel: ISearchChannel) { } + constructor(private channel: IChannel) { } fileSearch(search: IRawFileQuery): Event { return this.channel.listen('fileSearch', search); @@ -47,7 +40,7 @@ export class SearchChannelClient implements IRawSearchService { return this.channel.listen('textSearch', search); } - clearCache(cacheKey: string): Promise { + clearCache(cacheKey: string): Thenable { return this.channel.call('clearCache', cacheKey); } } \ 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 207fed068ad..5c59f4866a2 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -29,7 +29,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten import { addContextToEditorMatches, editorMatchesToTextSearchResults } from 'vs/workbench/services/search/common/searchHelpers'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IRawSearchService, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, isSerializedSearchComplete, isSerializedSearchSuccess } from './search'; -import { ISearchChannel, SearchChannelClient } from './searchIpc'; +import { SearchChannelClient } from './searchIpc'; export class SearchService extends Disposable implements ISearchService { public _serviceBrand: any; @@ -477,7 +477,7 @@ export class DiskSearch implements ISearchResultProvider { getPathFromAmdModule(require, 'bootstrap-fork'), opts); - const channel = getNextTickChannel(client.getChannel('search')); + const channel = getNextTickChannel(client.getChannel('search')); this.raw = new SearchChannelClient(channel); }