From 021b3da6721df7eaad2eb87024d2b0da28d60ade Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 25 May 2020 11:10:31 +0200 Subject: Flatten simple commands --- editors/code/src/commands/analyzer_status.ts | 51 ---------------------------- 1 file changed, 51 deletions(-) delete mode 100644 editors/code/src/commands/analyzer_status.ts (limited to 'editors/code/src/commands/analyzer_status.ts') diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts deleted file mode 100644 index 09daa3402..000000000 --- a/editors/code/src/commands/analyzer_status.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as vscode from 'vscode'; - -import * as ra from '../rust-analyzer-api'; -import { Ctx, Cmd } from '../ctx'; - -// Shows status of rust-analyzer (for debugging) -export function analyzerStatus(ctx: Ctx): Cmd { - let poller: NodeJS.Timer | undefined = undefined; - const tdcp = new TextDocumentContentProvider(ctx); - - ctx.pushCleanup( - vscode.workspace.registerTextDocumentContentProvider( - 'rust-analyzer-status', - tdcp, - ), - ); - - ctx.pushCleanup({ - dispose() { - if (poller !== undefined) { - clearInterval(poller); - } - }, - }); - - return async () => { - if (poller === undefined) { - poller = setInterval(() => tdcp.eventEmitter.fire(tdcp.uri), 1000); - } - const document = await vscode.workspace.openTextDocument(tdcp.uri); - return vscode.window.showTextDocument(document, vscode.ViewColumn.Two, true); - }; -} - -class TextDocumentContentProvider implements vscode.TextDocumentContentProvider { - readonly uri = vscode.Uri.parse('rust-analyzer-status://status'); - readonly eventEmitter = new vscode.EventEmitter(); - - constructor(private readonly ctx: Ctx) { - } - - provideTextDocumentContent(_uri: vscode.Uri): vscode.ProviderResult { - if (!vscode.window.activeTextEditor) return ''; - - return this.ctx.client.sendRequest(ra.analyzerStatus, null); - } - - get onDidChange(): vscode.Event { - return this.eventEmitter.event; - } -} -- cgit v1.2.3