提交 8c2d3b40 编写于 作者: J Joao Moreno

add connection context to IPC

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