Take server arguments object

Makes it more difficult to mistaktenly reverse which server is which
This commit is contained in:
Matt Bierner
2020-02-06 11:34:25 -08:00
parent c8516dd7e8
commit aca46ac4a5
2 changed files with 13 additions and 7 deletions

View File

@@ -298,21 +298,26 @@ export class ProcessBasedTsServer extends Disposable implements ITypeScriptServe
export class SyntaxRoutingTsServer extends Disposable implements ITypeScriptServer {
private readonly syntaxServer: ITypeScriptServer;
private readonly semanticServer: ITypeScriptServer;
public constructor(
private readonly syntaxServer: ITypeScriptServer,
private readonly semanticServer: ITypeScriptServer,
servers: { syntax: ITypeScriptServer, semantic: ITypeScriptServer },
private readonly _delegate: TsServerDelegate,
) {
super();
this._register(syntaxServer.onEvent(e => this._onEvent.fire(e)));
this._register(semanticServer.onEvent(e => this._onEvent.fire(e)));
this.syntaxServer = servers.syntax;
this.semanticServer = servers.semantic;
this._register(semanticServer.onExit(e => {
this._register(this.syntaxServer.onEvent(e => this._onEvent.fire(e)));
this._register(this.semanticServer.onEvent(e => this._onEvent.fire(e)));
this._register(this.semanticServer.onExit(e => {
this._onExit.fire(e);
this.syntaxServer.kill();
}));
this._register(semanticServer.onError(e => this._onError.fire(e)));
this._register(this.semanticServer.onError(e => this._onError.fire(e)));
}
private readonly _onEvent = this._register(new vscode.EventEmitter<Proto.Event>());
@@ -425,6 +430,7 @@ export class SyntaxRoutingTsServer extends Disposable implements ITypeScriptServ
}
}
namespace RequestState {
export const enum Type { Unresolved, Resolved, Errored }

View File

@@ -41,7 +41,7 @@ export class TypeScriptServerSpawner {
if (this.shouldUseSeparateSyntaxServer(version, configuration)) {
const syntaxServer = this.spawnTsServer('syntax', version, configuration, pluginManager);
const semanticServer = this.spawnTsServer('semantic', version, configuration, pluginManager);
return new SyntaxRoutingTsServer(syntaxServer, semanticServer, delegate);
return new SyntaxRoutingTsServer({ syntax: syntaxServer, semantic: semanticServer }, delegate);
}
return this.spawnTsServer('main', version, configuration, pluginManager);