mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +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';
|
import { createClient } from './client';
|
||||||
|
|
||||||
export class Ctx {
|
export class Ctx {
|
||||||
readonly config: Config;
|
private constructor(
|
||||||
// Because we have "reload server" action, various listeners **will** face a
|
readonly config: Config,
|
||||||
// situation where the client is not ready yet, and should be prepared to
|
private readonly extCtx: vscode.ExtensionContext,
|
||||||
// deal with it.
|
readonly client: lc.LanguageClient
|
||||||
//
|
) {
|
||||||
// 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;
|
|
||||||
|
|
||||||
static async create(config: Config, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
|
static async create(config: Config, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
|
||||||
const client = await createClient(config, serverPath);
|
const client = await createClient(config, serverPath);
|
||||||
|
@ -25,12 +21,6 @@ export class Ctx {
|
||||||
return res;
|
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 {
|
get activeRustEditor(): vscode.TextEditor | undefined {
|
||||||
const editor = vscode.window.activeTextEditor;
|
const editor = vscode.window.activeTextEditor;
|
||||||
return editor && editor.document.languageId === 'rust'
|
return editor && editor.document.languageId === 'rust'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue