test overriding Session.event

This commit is contained in:
Arthur Ozga
2017-11-17 19:48:57 -08:00
parent 890820b528
commit d2cc4f15be
3 changed files with 70 additions and 72 deletions

View File

@@ -573,7 +573,7 @@ namespace ts.server {
}
private writeToEventSocket(body: any, eventName: string): void {
this.eventSocket.write(formatMessage({ seq: 0, type: "event", event: eventName, body }, this.logger, this.byteLength, this.host.newLine), "utf8");
this.eventSocket.write(formatMessage(toEvent(body, eventName), this.logger, this.byteLength, this.host.newLine), "utf8");
}
exit() {

View File

@@ -245,6 +245,16 @@ namespace ts.server {
event: Event;
}
/** @internal */
export function toEvent(eventName: string, body: {}): protocol.Event {
return {
seq: 0,
type: "event",
event: eventName,
body
};
}
export interface SessionOptions {
host: ServerHost;
cancellationToken: ServerCancellationToken;
@@ -400,13 +410,7 @@ namespace ts.server {
}
public event<T>(body: T, eventName: string): void {
const ev: protocol.Event = {
seq: 0,
type: "event",
event: eventName,
body
};
this.send(ev);
this.send(toEvent(eventName, body));
}
// For backwards-compatibility only.