]> git.lizzy.rs Git - rust.git/commitdiff
Use types from vscode-langaugeclient
authorEmil Lauridsen <mine809@gmail.com>
Wed, 15 Jan 2020 10:47:56 +0000 (11:47 +0100)
committerEmil Lauridsen <mine809@gmail.com>
Wed, 15 Jan 2020 11:04:35 +0000 (12:04 +0100)
editors/code/rollup.config.js
editors/code/src/inlay_hints.ts
editors/code/src/status_display.ts

index 14fb9e085c519e9e1acf7141d45e2660316dbf64..de6a3b2b7ed14ef28f4d8c642ebf0f0422522727 100644 (file)
@@ -13,7 +13,7 @@ export default {
         commonjs({
             namedExports: {
                 // squelch missing import warnings
-                'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes']
+                'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes', 'WorkDoneProgress', 'WorkDoneProgressBegin', 'WorkDoneProgressReport', 'WorkDoneProgressEnd']
             }
         })
     ],
index c4206cf5b27a674d5114b924e45d4e75417fc896..6357e44f1ef3dcf4896d43011586afd428c3c968 100644 (file)
@@ -42,7 +42,7 @@ const parameterHintDecorationType = vscode.window.createTextEditorDecorationType
     before: {
         color: new vscode.ThemeColor('rust_analyzer.inlayHint'),
     }
-})
+});
 
 class HintsUpdater {
     private pending: Map<string, vscode.CancellationTokenSource> = new Map();
index 371a2f3bb01c8921562480e740981ea8f664ed4a..c75fddf9d749987a1031cfd85b278802c482ca8f 100644 (file)
@@ -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;
-}