Skip to content

Commit

Permalink
Delete IoSessionOptions
Browse files Browse the repository at this point in the history
Many of the options were unused because the values were being accessed
directly from the enclosing scope.
  • Loading branch information
amcasey committed Mar 15, 2018
1 parent c5eb4ea commit 0f3e9bb
Showing 1 changed file with 14 additions and 52 deletions.
66 changes: 14 additions & 52 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@
/// <reference path="session.ts" />

namespace ts.server {
interface IoSessionOptions {
host: ServerHost;
cancellationToken: ServerCancellationToken;
canUseEvents: boolean;
/**
* If defined, specifies the socket used to send events to the client.
* Otherwise, events are sent through the host.
*/
eventPort?: number;
useSingleInferredProject: boolean;
useInferredProjectPerProjectRoot: boolean;
disableAutomaticTypingAcquisition: boolean;
globalTypingsCacheLocation: string;
logger: Logger;
typingSafeListLocation: string;
typesMapLocation: string | undefined;
npmLocation: string | undefined;
telemetryEnabled: boolean;
globalPlugins: ReadonlyArray<string>;
pluginProbeLocations: ReadonlyArray<string>;
allowLocalPluginLoads: boolean;
}

const childProcess: {
fork(modulePath: string, args: string[], options?: { execArgv: string[], env?: MapLike<string> }): NodeChildProcess;
execFileSync(file: string, args: string[], options: { stdio: "ignore", env: MapLike<string> }): string | Buffer;
Expand Down Expand Up @@ -500,14 +477,16 @@ namespace ts.server {
}

class IOSession extends Session {
private eventPort: number;
/**
* If defined, specifies the socket used to send events to the client.
* Otherwise, events are sent through the host.
*/
private eventPort: number | undefined;
private eventSocket: NodeSocket | undefined;
private socketEventQueue: { body: any, eventName: string }[] | undefined;
private constructed: boolean | undefined;

constructor(options: IoSessionOptions) {
const { host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options;

constructor() {
const event: Event | undefined = (body: object, eventName: string) => {
if (this.constructed) {
this.event(body, eventName);
Expand All @@ -521,9 +500,11 @@ namespace ts.server {
}
};

const host = sys;

const typingsInstaller = disableAutomaticTypingAcquisition
? undefined
: new NodeTypingsInstaller(telemetryEnabled, logger, host, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, event);
: new NodeTypingsInstaller(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, event);

super({
host,
Expand All @@ -534,11 +515,11 @@ namespace ts.server {
byteLength: Buffer.byteLength,
hrtime: process.hrtime,
logger,
canUseEvents,
canUseEvents: eventPort !== undefined,
suppressProjectEvents,
globalPlugins: options.globalPlugins,
pluginProbeLocations: options.pluginProbeLocations,
allowLocalPluginLoads: options.allowLocalPluginLoads
globalPlugins,
pluginProbeLocations,
allowLocalPluginLoads
});

this.eventPort = eventPort;
Expand Down Expand Up @@ -954,31 +935,12 @@ namespace ts.server {
const suppressProjectEvents = hasArgument("--suppressProjectEvents");
const telemetryEnabled = hasArgument(Arguments.EnableTelemetry);

const options: IoSessionOptions = {
host: sys,
cancellationToken,
eventPort,
canUseEvents: true,
useSingleInferredProject,
useInferredProjectPerProjectRoot,
disableAutomaticTypingAcquisition,
globalTypingsCacheLocation: getGlobalTypingsCacheLocation(),
typingSafeListLocation,
typesMapLocation,
npmLocation,
telemetryEnabled,
logger,
globalPlugins,
pluginProbeLocations,
allowLocalPluginLoads
};

logger.info(`Starting TS Server`);
logger.info(`Version: ${version}`);
logger.info(`Arguments: ${process.argv.join(" ")}`);
logger.info(`Platform: ${os.platform()} NodeVersion: ${nodeVersion} CaseSensitive: ${sys.useCaseSensitiveFileNames}`);

const ioSession = new IOSession(options);
const ioSession = new IOSession();
process.on("uncaughtException", err => {
ioSession.logError(err, "unknown");
});
Expand Down

0 comments on commit 0f3e9bb

Please sign in to comment.