mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from master
This commit is contained in:
68
src/vs/platform/url/node/urlIpc.ts
Normal file
68
src/vs/platform/url/node/urlIpc.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
|
||||
export class URLServiceChannel implements IServerChannel {
|
||||
|
||||
constructor(private service: IURLService) { }
|
||||
|
||||
listen<T>(_, event: string): Event<T> {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_, command: string, arg?: any): Thenable<any> {
|
||||
switch (command) {
|
||||
case 'open': return this.service.open(URI.revive(arg));
|
||||
}
|
||||
|
||||
throw new Error(`Call not found: ${command}`);
|
||||
}
|
||||
}
|
||||
|
||||
export class URLServiceChannelClient implements IURLService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
open(url: URI): Thenable<boolean> {
|
||||
return this.channel.call('open', url.toJSON());
|
||||
}
|
||||
|
||||
registerHandler(handler: IURLHandler): IDisposable {
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
export class URLHandlerChannel implements IServerChannel {
|
||||
|
||||
constructor(private handler: IURLHandler) { }
|
||||
|
||||
listen<T>(_, event: string): Event<T> {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_, command: string, arg?: any): Thenable<any> {
|
||||
switch (command) {
|
||||
case 'handleURL': return this.handler.handleURL(URI.revive(arg));
|
||||
}
|
||||
|
||||
throw new Error(`Call not found: ${command}`);
|
||||
}
|
||||
}
|
||||
|
||||
export class URLHandlerChannelClient implements IURLHandler {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
handleURL(uri: URI): Thenable<boolean> {
|
||||
return this.channel.call('handleURL', uri.toJSON());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user