aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-19 08:06:48 +0000
committerGitHub <[email protected]>2020-03-19 08:06:48 +0000
commitaca3c3086ee99f5770a60970e20af640c895d42a (patch)
tree2f0b3233cc4728436ba5e47a6e91e7df33585d43 /editors/code/src/ctx.ts
parent55336722b3662cbdcc9e1b92a3e27ed0442d2452 (diff)
parentfb6e655de8a44c65275ad45a27bf5bd684670ba0 (diff)
Merge #3629
3629: Alternative aproach to plugin auto update r=matklad a=matklad This is very much WIP (as in, I haven't run this once), but I like the result so far. cc @Veetaha The primary focus here on simplification: * local simplification of data structures and control-flow: using union of strings instead of an enum, using unwrapped GitHub API responses * global simplification of control flow: all logic is now in `main.ts`, implemented as linear functions without abstractions. This is stateful side-effective code, so arguments from [Carmack](http://number-none.com/blow/john_carmack_on_inlined_code.html) very much apply. We need all user interractions, all mutations, and all network requests to happen in a single file. * as a side-effect of condensing everything to functions, we can get rid of various enums. The enums were basically a reified control flow: ``` enum E { A, B } fn foo() -> E { if cond { E::A } else { E::B } } fn bar(e: E) { match e { E::A => do_a(), E::B => do_b(), } } ==>> fn all() { if cond { do_a() } else { do_b() } } ``` * simplification of model: we don't need to reinstall on settings update, we can just ask the user to reload, we don't need to handle nightly=>stable fallback, we can ask the user to reinstall extension, (todo) we don't need to parse out the date from the version, we can use build id for nightly and for stable we can write the info directly into package.json. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index c929ab063..84c170ea8 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -4,21 +4,20 @@ import * as lc from 'vscode-languageclient';
4import { Config } from './config'; 4import { Config } from './config';
5import { createClient } from './client'; 5import { createClient } from './client';
6import { isRustEditor, RustEditor } from './util'; 6import { isRustEditor, RustEditor } from './util';
7import { PersistentState } from './persistent_state';
8 7
9export class Ctx { 8export class Ctx {
10 private constructor( 9 private constructor(
11 readonly config: Config, 10 readonly config: Config,
12 readonly state: PersistentState,
13 private readonly extCtx: vscode.ExtensionContext, 11 private readonly extCtx: vscode.ExtensionContext,
14 readonly client: lc.LanguageClient 12 readonly client: lc.LanguageClient,
13 readonly serverPath: string,
15 ) { 14 ) {
16 15
17 } 16 }
18 17
19 static async create(config: Config, state: PersistentState, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> { 18 static async create(config: Config, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
20 const client = await createClient(config, serverPath); 19 const client = await createClient(config, serverPath);
21 const res = new Ctx(config, state, extCtx, client); 20 const res = new Ctx(config, extCtx, client, serverPath);
22 res.pushCleanup(client.start()); 21 res.pushCleanup(client.start());
23 await client.onReady(); 22 await client.onReady();
24 return res; 23 return res;