Skip to content

Commit 9f991d3

Browse files
committed
cleanup
1 parent 0d3002c commit 9f991d3

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

src/server/editorServices.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace ts.server {
1616
export const ProjectInfoTelemetryEvent = "projectInfo";
1717
// tslint:enable variable-name
1818

19-
// TODO: make these inherit from protocol.Event?
2019
export interface ProjectsUpdatedInBackgroundEvent {
2120
eventName: typeof ProjectsUpdatedInBackgroundEvent;
2221
data: { openFiles: string[]; };

src/server/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ namespace ts.server {
292292
if (this.installerPidReported) {
293293
return;
294294
}
295-
if (this.installer && this.eventSender) {
295+
if (this.eventSender && this.installer) {
296296
this.eventSender.event({ pid: this.installer.pid }, "typingsInstallerPid");
297297
this.installerPidReported = true;
298298
}
@@ -332,10 +332,10 @@ namespace ts.server {
332332
if (match) {
333333
// if port is specified - use port + 1
334334
// otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1
335-
// const currentPort = match[2] !== undefined
336-
// ? +match[2]
337-
// : match[1].charAt(0) === "d" ? 5858 : 9229;
338-
// execArgv.push(`--${match[1]}=${currentPort + 1}`);
335+
const currentPort = match[2] !== undefined
336+
? +match[2]
337+
: match[1].charAt(0) === "d" ? 5858 : 9229;
338+
execArgv.push(`--${match[1]}=${currentPort + 1}`);
339339
break;
340340
}
341341
}

src/server/session.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,13 @@ namespace ts.server {
315315
else if (this.eventPort) {
316316
const s = net.connect({ port: this.eventPort }, () => {
317317
this.eventSocket = s;
318-
this.clearSocketEventQueue();
318+
if (this.socketEventQueue) {
319+
// flush queue.
320+
for (const event of this.socketEventQueue) {
321+
this.writeToEventSocket(event.info, event.eventName);
322+
}
323+
this.socketEventQueue = undefined;
324+
}
319325
});
320326

321327
this.event = function <T>(info: T, eventName: string) {
@@ -374,13 +380,6 @@ namespace ts.server {
374380
this.gcTimer = new GcTimer(this.host, /*delay*/ 7000, this.logger);
375381
}
376382

377-
private clearSocketEventQueue() {
378-
for (const event of this.socketEventQueue) {
379-
this.writeToEventSocket(event.info, event.eventName);
380-
}
381-
this.socketEventQueue = undefined;
382-
}
383-
384383
private writeToEventSocket(info: any, eventName: string): void {
385384
this.eventSocket.write(formatMessage({ seq: 0, type: "event", event: eventName, body: info }, this.logger, Buffer.byteLength, this.host.newLine), "utf8");
386385
}
@@ -451,9 +450,11 @@ namespace ts.server {
451450
}
452451

453452
public send(msg: protocol.Message) {
454-
if (msg.type === "event") {
455-
Debug.assert(this.canUseEvents);
456-
Debug.assert(!this.eventPort);
453+
if (msg.type === "event" && !this.canUseEvents) {
454+
if (this.logger.hasLevel(LogLevel.verbose)) {
455+
this.logger.info(`Session does not support events: ignored event: ${JSON.stringify(msg)}`);
456+
}
457+
return;
457458
}
458459
this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine));
459460
}

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6947,7 +6947,6 @@ declare namespace ts.server {
69476947
readonly event: EventSender["event"];
69486948
private socketEventQueue;
69496949
constructor(opts: SessionOptions);
6950-
private clearSocketEventQueue();
69516950
private writeToEventSocket(info, eventName);
69526951
private sendRequestCompletedEvent(requestId);
69536952
private defaultEventHandler(event);

0 commit comments

Comments
 (0)