mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Separate persistent mutable state from config
That way, we clearly see which things are not change, and we also clearly see which things are persistent.
This commit is contained in:
parent
2e9b6320e6
commit
ae662617a2
7 changed files with 80 additions and 65 deletions
|
@ -4,19 +4,21 @@ import * as lc from 'vscode-languageclient';
|
|||
import { Config } from './config';
|
||||
import { createClient } from './client';
|
||||
import { isRustEditor, RustEditor } from './util';
|
||||
import { PersistentState } from './persistent_state';
|
||||
|
||||
export class Ctx {
|
||||
private constructor(
|
||||
readonly config: Config,
|
||||
readonly state: PersistentState,
|
||||
private readonly extCtx: vscode.ExtensionContext,
|
||||
readonly client: lc.LanguageClient
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
static async create(config: Config, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
|
||||
static async create(config: Config, state: PersistentState, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
|
||||
const client = await createClient(config, serverPath);
|
||||
const res = new Ctx(config, extCtx, client);
|
||||
const res = new Ctx(config, state, extCtx, client);
|
||||
res.pushCleanup(client.start());
|
||||
await client.onReady();
|
||||
return res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue