mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
vscode: post refactor HintsUpdater (simplify create() -> constructor call)
This commit is contained in:
parent
61a4ea2532
commit
65cecff316
1 changed files with 10 additions and 16 deletions
|
@ -13,7 +13,7 @@ export function activateInlayHints(ctx: Ctx) {
|
||||||
if (!ctx.config.displayInlayHints) {
|
if (!ctx.config.displayInlayHints) {
|
||||||
return this.dispose();
|
return this.dispose();
|
||||||
}
|
}
|
||||||
if (!this.updater) this.updater = HintsUpdater.create(ctx);
|
if (!this.updater) this.updater = new HintsUpdater(ctx);
|
||||||
},
|
},
|
||||||
dispose() {
|
dispose() {
|
||||||
this.updater?.dispose();
|
this.updater?.dispose();
|
||||||
|
@ -67,25 +67,21 @@ class HintsUpdater implements Disposable {
|
||||||
private sourceFiles = new Map<string, RustSourceFile>(); // map Uri -> RustSourceFile
|
private sourceFiles = new Map<string, RustSourceFile>(); // map Uri -> RustSourceFile
|
||||||
private readonly disposables: Disposable[] = [];
|
private readonly disposables: Disposable[] = [];
|
||||||
|
|
||||||
private constructor(private readonly ctx: Ctx) { }
|
constructor(private readonly ctx: Ctx) {
|
||||||
|
|
||||||
static create(ctx: Ctx) {
|
|
||||||
const self = new HintsUpdater(ctx);
|
|
||||||
|
|
||||||
vscode.window.onDidChangeVisibleTextEditors(
|
vscode.window.onDidChangeVisibleTextEditors(
|
||||||
self.onDidChangeVisibleTextEditors,
|
this.onDidChangeVisibleTextEditors,
|
||||||
self,
|
this,
|
||||||
self.disposables
|
this.disposables
|
||||||
);
|
);
|
||||||
|
|
||||||
vscode.workspace.onDidChangeTextDocument(
|
vscode.workspace.onDidChangeTextDocument(
|
||||||
self.onDidChangeTextDocument,
|
this.onDidChangeTextDocument,
|
||||||
self,
|
this,
|
||||||
self.disposables
|
this.disposables
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set up initial cache shape
|
// Set up initial cache shape
|
||||||
ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set(
|
ctx.visibleRustEditors.forEach(editor => this.sourceFiles.set(
|
||||||
editor.document.uri.toString(),
|
editor.document.uri.toString(),
|
||||||
{
|
{
|
||||||
document: editor.document,
|
document: editor.document,
|
||||||
|
@ -94,9 +90,7 @@ class HintsUpdater implements Disposable {
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
self.syncCacheAndRenderHints();
|
this.syncCacheAndRenderHints();
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
|
Loading…
Reference in a new issue