mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Simplify ctor
This commit is contained in:
parent
7dccfd9183
commit
3c12cd49ec
1 changed files with 7 additions and 17 deletions
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue