Skip to content

Commit 7390fe0

Browse files
committed
Feedback form pr #3513
1 parent 8554791 commit 7390fe0

File tree

6 files changed

+18
-37
lines changed

6 files changed

+18
-37
lines changed

Jakefile.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ var serverSources = [
100100
"editorServices.ts",
101101
"protocol.d.ts",
102102
"session.ts",
103-
"nodeimpl.ts",
104103
"server.ts"
105104
].map(function (f) {
106105
return path.join(serverDirectory, f);
@@ -112,7 +111,7 @@ var languageServiceLibrarySources = [
112111
"session.ts"
113112
].map(function (f) {
114113
return path.join(serverDirectory, f);
115-
});
114+
}).concat(servicesSources);
116115

117116
var harnessSources = [
118117
"harness.ts",
@@ -146,7 +145,6 @@ var harnessSources = [
146145
"protocol.d.ts",
147146
"session.ts",
148147
"client.ts",
149-
"nodeimpl.ts",
150148
"editorServices.ts",
151149
].map(function (f) {
152150
return path.join(serverDirectory, f);
@@ -383,7 +381,7 @@ var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
383381
compileFile(
384382
lsslFile,
385383
languageServiceLibrarySources,
386-
[builtLocalDirectory, copyright].concat(serverSources).concat(languageServiceLibrarySources),
384+
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
387385
/*prefixes*/ [copyright],
388386
/*useBuiltCompiler*/ true,
389387
/*noOutFile*/ false,

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, new ts.server.NodeEnvironment(), serverHost);
586+
var server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost);
587587

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

src/server/editorServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ module ts.server {
12621262
versions: LineIndexSnapshot[] = [];
12631263
minVersion = 0; // no versions earlier than min version will maintain change history
12641264
private currentVersion = 0;
1265-
private host: System;
1265+
private host: ServerHost;
12661266

12671267
static changeNumberThreshold = 8;
12681268
static changeLengthThreshold = 256;

src/server/nodeimpl.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/server/server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ module ts.server {
173173
}
174174

175175
class IOSession extends Session {
176-
constructor(host: ServerHost, env: NodeEnvironment, logger: ts.server.Logger) {
177-
super(host, env, logger);
176+
constructor(host: ServerHost, logger: ts.server.Logger) {
177+
super(host, Buffer.byteLength, process.hrtime, logger);
178178
}
179179

180180
exit() {
@@ -265,7 +265,7 @@ module ts.server {
265265
}
266266

267267
};
268-
var ioSession = new IOSession(ts.sys, new NodeEnvironment(), logger);
268+
var ioSession = new IOSession(ts.sys, logger);
269269
process.on('uncaughtException', function(err: Error) {
270270
ioSession.logError(err, "unknown");
271271
});

src/server/session.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,6 @@ module ts.server {
107107

108108
export interface ServerHost extends ts.System {
109109
}
110-
111-
export interface Environment {
112-
byteLength: (buf: string, encoding?: string) => number;
113-
hrtime: (start?: number[]) => number[]; //array of seconds, nanoseconds
114-
}
115-
116-
export interface Message {
117-
type: string,
118-
seq: number
119-
}
120-
121-
export interface Event extends Message {
122-
event: string;
123-
body?: any;
124-
}
125110

126111
export class Session {
127112
projectService: ProjectService;
@@ -132,7 +117,12 @@ module ts.server {
132117
immediateId: any;
133118
changeSeq = 0;
134119

135-
constructor(private host: ServerHost, private environment: Environment, private logger: Logger) {
120+
constructor(
121+
private host: ServerHost,
122+
private byteLength: (buf: string, encoding?: string) => number,
123+
private hrtime: (start?: number[]) => number[],
124+
private logger: Logger
125+
) {
136126
this.projectService =
137127
new ProjectService(host, logger, (eventName,project,fileName) => {
138128
this.handleEvent(eventName, project, fileName);
@@ -163,17 +153,17 @@ module ts.server {
163153
this.host.write(line + this.host.newLine);
164154
}
165155

166-
send(msg: Message) {
156+
send(msg: protocol.Message) {
167157
var json = JSON.stringify(msg);
168158
if (this.logger.isVerbose()) {
169159
this.logger.info(msg.type + ": " + json);
170160
}
171-
this.sendLineToClient('Content-Length: ' + (1 + this.environment.byteLength(json, 'utf8')) +
161+
this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) +
172162
'\r\n\r\n' + json);
173163
}
174164

175165
event(info: any, eventName: string) {
176-
var ev: Event = {
166+
var ev: protocol.Event = {
177167
seq: 0,
178168
type: "event",
179169
event: eventName,
@@ -852,7 +842,7 @@ module ts.server {
852842
onMessage(message: string) {
853843
if (this.logger.isVerbose()) {
854844
this.logger.info("request: " + message);
855-
var start = this.environment.hrtime();
845+
var start = this.hrtime();
856846
}
857847
try {
858848
var request = <protocol.Request>JSON.parse(message);
@@ -994,7 +984,7 @@ module ts.server {
994984
}
995985

996986
if (this.logger.isVerbose()) {
997-
var elapsed = this.environment.hrtime(start);
987+
var elapsed = this.hrtime(start);
998988
var seconds = elapsed[0]
999989
var nanoseconds = elapsed[1];
1000990
var elapsedMs = ((1e9 * seconds) + nanoseconds)/1000000.0;

0 commit comments

Comments
 (0)