Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(messaging): Create container in its own method to easier subclassing #8008

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/core/src/node/messaging/messaging-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as url from 'url';
import * as net from 'net';
import * as http from 'http';
import * as https from 'https';
import { injectable, inject, named, postConstruct, interfaces } from 'inversify';
import { injectable, inject, named, postConstruct, interfaces, Container } from 'inversify';
import { MessageConnection } from 'vscode-jsonrpc';
import { createWebSocketConnection } from 'vscode-ws-jsonrpc/lib/socket/connection';
import { IConnection } from 'vscode-ws-jsonrpc/lib/server/connection';
Expand Down Expand Up @@ -173,9 +173,14 @@ export class MessagingContribution implements BackendApplicationContribution, Me
});
}

protected getConnectionChannelHandlers(socket: ws): MessagingContribution.ConnectionHandlers<WebSocketChannel> {
const connectionContainer = this.container.createChild();
protected createSocketContainer(socket: ws): Container {
const connectionContainer: Container = this.container.createChild() as Container;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) ts should be able infer types here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is what I was thinking as well but without the as Container I've

src/node/messaging/messaging-contribution.ts(182,15): error TS2740: Type 'Container' is missing the following properties from type 'Container': _middleware, _bindingDictionary, _snapshots, _metadataReader, and 5 more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, looks good to merge

connectionContainer.bind(ws).toConstantValue(socket);
return connectionContainer;
}

protected getConnectionChannelHandlers(socket: ws): MessagingContribution.ConnectionHandlers<WebSocketChannel> {
const connectionContainer = this.createSocketContainer(socket);
bindContributionProvider(connectionContainer, ConnectionHandler);
connectionContainer.load(...this.connectionModules.getContributions());
const connectionChannelHandlers = new MessagingContribution.ConnectionHandlers(this.channelHandlers);
Expand Down