blob: 8581667b4e35d9ea3b0da8142de6b15f6e23e36a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient';
import { Server } from './server';
export class Ctx {
private extCtx: vscode.ExtensionContext
constructor(extCtx: vscode.ExtensionContext) {
this.extCtx = extCtx
}
get client(): lc.LanguageClient {
return Server.client
}
registerCommand(
name: string,
factory: (ctx: Ctx) => () => Promise<vscode.TextEditor>,
) {
const fullName = `rust-analyzer.${name}`
const cmd = factory(this);
const d = vscode.commands.registerCommand(fullName, cmd);
this.pushCleanup(d);
}
pushCleanup(d: { dispose(): any }) {
this.extCtx.subscriptions.push(d)
}
}
|