Skip to content

Commit dfd8a06

Browse files
committed
Always default to using JSON and do not format it
1 parent a0b557e commit dfd8a06

File tree

3 files changed

+7
-56
lines changed

3 files changed

+7
-56
lines changed

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ module Harness.LanguageService {
583583
// This host is just a proxy for the clientHost, it uses the client
584584
// host to answer server queries about files on disk
585585
var serverHost = new SessionServerHost(clientHost);
586-
var server = new ts.server.Session(serverHost, serverHost, /*useProtocol*/ true, /*prettyJSON*/ false);
586+
var server = new ts.server.Session(serverHost, serverHost);
587587

588588
// Fake the connection between the client and the server
589589
serverHost.writeMessage = client.onMessage.bind(client);

src/server/protocol.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ module ts.server {
157157
immediateId: any;
158158
changeSeq = 0;
159159

160-
constructor(private host: ServerHost, private logger: Logger, protected useProtocol: boolean, protected prettyJSON: boolean) {
160+
constructor(private host: ServerHost, private logger: Logger) {
161161
this.projectService = new ProjectService(host, logger);
162162
}
163163

@@ -178,13 +178,7 @@ module ts.server {
178178
}
179179

180180
send(msg: NodeJS._debugger.Message) {
181-
var json: string;
182-
if (this.prettyJSON) {
183-
json = JSON.stringify(msg, null, " ");
184-
}
185-
else {
186-
json = JSON.stringify(msg);
187-
}
181+
var json = JSON.stringify(msg);
188182
this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) +
189183
'\r\n\r\n' + json);
190184
}
@@ -229,32 +223,7 @@ module ts.server {
229223
}
230224

231225
output(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) {
232-
if (this.useProtocol) {
233-
this.response(info, cmdName, reqSeq, errorMsg);
234-
}
235-
else if (this.prettyJSON) {
236-
if (!errorMsg) {
237-
this.sendLineToClient(JSON.stringify(info, null, " ").trim());
238-
}
239-
else {
240-
this.sendLineToClient(JSON.stringify(errorMsg));
241-
}
242-
} else {
243-
if (!errorMsg) {
244-
var infoStr = JSON.stringify(info).trim();
245-
// [8 digits of length,infoStr] + '\n'
246-
var len = infoStr.length + paddedLength + 4;
247-
var lenStr = len.toString();
248-
var padLen = paddedLength - lenStr.length;
249-
for (var i = 0; i < padLen; i++) {
250-
lenStr = '0' + lenStr;
251-
}
252-
this.sendLineToClient("[" + lenStr + "," + infoStr + "]");
253-
}
254-
else {
255-
this.sendLineToClient(JSON.stringify("error: " + errorMsg));
256-
}
257-
}
226+
this.response(info, cmdName, reqSeq, errorMsg);
258227
}
259228

260229
semanticCheck(file: string, project: Project) {

src/server/server.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,8 @@ module ts.server {
7373
}
7474

7575
class IOSession extends Session {
76-
protocol: NodeJS._debugger.Protocol;
77-
78-
constructor(host: ServerHost, logger: ts.server.Logger, useProtocol: boolean, prettyJSON: boolean) {
79-
super(host, logger, useProtocol, prettyJSON);
80-
if (useProtocol) {
81-
this.initProtocol();
82-
}
83-
}
84-
85-
initProtocol() {
86-
this.protocol = new nodeproto.Protocol();
87-
// note: onResponse was named by nodejs authors; we are re-purposing the Protocol
88-
// class in this case so that it supports a server instead of a client
89-
this.protocol.onResponse = (pkt) => {
90-
this.handleRequest(pkt);
91-
};
92-
}
93-
94-
handleRequest(req: NodeJS._debugger.Packet) {
95-
this.projectService.log("Got JSON msg:\n" + req.raw);
76+
constructor(host: ServerHost, logger: ts.server.Logger) {
77+
super(host, logger);
9678
}
9779

9880
listen() {
@@ -114,5 +96,5 @@ module ts.server {
11496
var logger = new Logger(__dirname + "/.log" + process.pid.toString());
11597

11698
// Start listening
117-
new IOSession(ts.sys, logger, /* useProtocol */ true, /* prettyJSON */ false).listen();
99+
new IOSession(ts.sys, logger).listen();
118100
}

0 commit comments

Comments
 (0)