mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
test overriding Session.event
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user