Simplify ctor

This commit is contained in:
Aleksey Kladov 2020-02-17 14:21:50 +01:00
parent 7dccfd9183
commit 3c12cd49ec

View file

@ -5,17 +5,13 @@ import { Config } from './config';
import { createClient } from './client';
export class Ctx {
readonly config: Config;
// Because we have "reload server" action, various listeners **will** face a
// situation where the client is not ready yet, and should be prepared to
// deal with it.
//
// Ideally, this should be replaced with async getter though.
// FIXME: this actually needs syncronization of some kind (check how
// vscode deals with `deactivate()` call when extension has some work scheduled
// on the event loop to get a better picture of what we can do here)
client: lc.LanguageClient;
private extCtx: vscode.ExtensionContext;
private constructor(
readonly config: Config,
private readonly extCtx: vscode.ExtensionContext,
readonly client: lc.LanguageClient
) {
}
static async create(config: Config, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
const client = await createClient(config, serverPath);
@ -25,12 +21,6 @@ export class Ctx {
return res;
}
private constructor(config: Config, extCtx: vscode.ExtensionContext, client: lc.LanguageClient) {
this.config = config;
this.extCtx = extCtx;
this.client = client
}
get activeRustEditor(): vscode.TextEditor | undefined {
const editor = vscode.window.activeTextEditor;
return editor && editor.document.languageId === 'rust'