Skip to content

Commit

Permalink
rename TheiaMessageConnection
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Grant <[email protected]>
  • Loading branch information
Colin Grant committed Nov 22, 2021
1 parent 1bb724b commit 7bea6ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/common/messaging/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import * as rpc from 'vscode-languageserver-protocol';
import { TheiaMessageConnection } from './theia-message-connection';
import { RPCMessageRelay } from './theia-message-connection';
import { Disposable } from '../disposable';

/**
Expand Down Expand Up @@ -64,9 +64,9 @@ export namespace Channel {
return rpc.createMessageConnection(reader, writer, logger, options);
}

export function createTheiaMessageConnection(channel: Channel<string>, onDispose: () => void = () => { }): TheiaMessageConnection {
export function createTheiaMessageConnection(channel: Channel<string>, onDispose: () => void = () => { }): RPCMessageRelay {
const reader = new MessageReader(channel);
const writer = new MessageWriter(channel);
return TheiaMessageConnection.create(reader, writer, onDispose);
return RPCMessageRelay.create(reader, writer, onDispose);
}
}
10 changes: 5 additions & 5 deletions packages/core/src/common/messaging/theia-message-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ import { Disposable, DisposableCollection } from '../../common';
* This is close to `vscode_jsonrpc.MessageConnection` but without all the JSON-RPC
* specific methods such as `sendRequest`, `sendNotification`, etc.
*/
export interface TheiaMessageConnection extends Disposable {
export interface RPCMessageRelay extends Disposable {
readonly reader: MessageReader;
readonly writer: MessageWriter;
forward(to: TheiaMessageConnection, map?: (message: Message) => Message): void;
forward(to: RPCMessageRelay, map?: (message: Message) => Message): void;
onClose(callback: () => void): Disposable;
}

export namespace TheiaMessageConnection {
export function create(reader: MessageReader, writer: MessageWriter, onDispose: () => void): TheiaMessageConnection {
export namespace RPCMessageRelay {
export function create(reader: MessageReader, writer: MessageWriter, onDispose: () => void): RPCMessageRelay {
const disposeOnClose = new DisposableCollection();
reader.onClose(() => disposeOnClose.dispose());
writer.onClose(() => disposeOnClose.dispose());
return {
reader,
writer,
forward(to: TheiaMessageConnection, map?: (message: Message) => Message): void {
forward(to: RPCMessageRelay, map?: (message: Message) => Message): void {
reader.listen(data => {
if (map) {
data = map(data);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/node/messaging/messaging-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as http from 'http';
import * as https from 'https';
import { injectable, inject, named, postConstruct, interfaces, Container } from 'inversify';
import { MessageConnection } from 'vscode-languageserver-protocol';
import { TheiaMessageConnection } from '../../common/messaging';
import { RPCMessageRelay } from '../../common/messaging';
import { Channel } from '../../common/messaging/channel';
import { ContributionProvider, ConnectionHandler, bindContributionProvider } from '../../common';
import { WebSocketChannel } from '../../common/messaging/web-socket-channel';
Expand Down Expand Up @@ -79,7 +79,7 @@ export class MessagingContribution implements BackendApplicationContribution, Me
});
}

forward(spec: string, callback: (params: MessagingService.PathParams, connection: TheiaMessageConnection) => void): void {
forward(spec: string, callback: (params: MessagingService.PathParams, connection: RPCMessageRelay) => void): void {
this.wsChannel(spec, (params, channel) => {
const jsonRpcConnection = Channel.createTheiaMessageConnection(channel, () => channel.close());
const webSocketChannelConnection = WebSocketChannelConnection.create(jsonRpcConnection, channel);
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/node/messaging/messaging-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as ws from 'ws';
import { MessageConnection } from 'vscode-languageserver-protocol';
import { TheiaMessageConnection } from '../../common/messaging';
import { RPCMessageRelay } from '../../common/messaging';
import { WebSocketChannel } from '../../common/messaging/web-socket-channel';

export interface MessagingService {
Expand All @@ -29,7 +29,7 @@ export interface MessagingService {
* Accept a raw JSON-RPC connection on the given path.
* A path supports the route syntax: https://github.com/rcs/route-parser#what-can-i-use-in-my-routes.
*/
forward(path: string, callback: (params: MessagingService.PathParams, connection: TheiaMessageConnection) => void): void;
forward(path: string, callback: (params: MessagingService.PathParams, connection: RPCMessageRelay) => void): void;
/**
* Accept a web socket channel on the given path.
* A path supports the route syntax: https://github.com/rcs/route-parser#what-can-i-use-in-my-routes.
Expand Down Expand Up @@ -57,17 +57,17 @@ export namespace MessagingService {
}
}

export interface WebSocketChannelConnection extends TheiaMessageConnection {
export interface WebSocketChannelConnection extends RPCMessageRelay {
channel: WebSocketChannel;
}
export namespace WebSocketChannelConnection {
export function is(connection: TheiaMessageConnection): connection is WebSocketChannelConnection {
export function is(connection: RPCMessageRelay): connection is WebSocketChannelConnection {
return (connection as WebSocketChannelConnection).channel instanceof WebSocketChannel;
}
/**
* Mutate `connection` to become a `WebSocketChannelConnection`.
*/
export function create(connection: TheiaMessageConnection, channel: WebSocketChannel): WebSocketChannelConnection {
export function create(connection: RPCMessageRelay, channel: WebSocketChannel): WebSocketChannelConnection {
const result = connection as WebSocketChannelConnection;
result.channel = channel;
return result;
Expand Down

0 comments on commit 7bea6ab

Please sign in to comment.