From 70cba0fe0fe3583deb19709a61768695b83d3ea9 Mon Sep 17 00:00:00 2001 From: Emil Lauridsen Date: Wed, 15 Jan 2020 11:47:56 +0100 Subject: Use types from vscode-langaugeclient --- editors/code/src/status_display.ts | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'editors/code/src/status_display.ts') diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts index 371a2f3bb..c75fddf9d 100644 --- a/editors/code/src/status_display.ts +++ b/editors/code/src/status_display.ts @@ -1,5 +1,7 @@ import * as vscode from 'vscode'; +import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd } from 'vscode-languageclient'; + import { Ctx } from './ctx'; const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; @@ -8,7 +10,7 @@ export function activateStatusDisplay(ctx: Ctx) { const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command); ctx.pushCleanup(statusDisplay); ctx.onDidRestart(client => { - client.onNotification('$/progress', params => statusDisplay.handleProgressNotification(params)); + client.onProgress(WorkDoneProgress.type, 'rustAnalyzer/cargoWatcher', params => statusDisplay.handleProgressNotification(params)); }); } @@ -63,20 +65,15 @@ class StatusDisplay implements vscode.Disposable { this.statusBarItem.dispose(); } - handleProgressNotification(params: ProgressParams) { - const { token, value } = params; - if (token !== 'rustAnalyzer/cargoWatcher') { - return; - } - - switch (value.kind) { + handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) { + switch (params.kind) { case 'begin': this.show(); break; case 'report': - if (value.message) { - this.packageName = value.message; + if (params.message) { + this.packageName = params.message; } break; @@ -90,22 +87,3 @@ class StatusDisplay implements vscode.Disposable { return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; } } - -// FIXME: Replace this once vscode-languageclient is updated to LSP 3.15 -interface ProgressParams { - token: string; - value: WorkDoneProgress; -} - -enum WorkDoneProgressKind { - Begin = 'begin', - Report = 'report', - End = 'end', -} - -interface WorkDoneProgress { - kind: WorkDoneProgressKind; - message?: string; - cancelable?: boolean; - percentage?: string; -} -- cgit v1.2.3