From 1eed036a6e68aee6128d099e3a8f2c06a90b846b Mon Sep 17 00:00:00 2001 From: vsrs Date: Mon, 17 Aug 2020 14:56:27 +0300 Subject: Fix StatusNotification --- crates/rust-analyzer/src/lsp_ext.rs | 7 ++++++- crates/rust-analyzer/src/reload.rs | 5 ++++- docs/dev/lsp-extensions.md | 8 +++++++- editors/code/src/ctx.ts | 2 +- editors/code/src/lsp_ext.ts | 5 ++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 3976b6529..e1a28b1b4 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -237,8 +237,13 @@ pub enum Status { Invalid, } +#[derive(Deserialize, Serialize)] +pub struct StatusParams { + pub status: Status, +} + impl Notification for StatusNotification { - type Params = Status; + type Params = StatusParams; const METHOD: &'static str = "rust-analyzer/status"; } diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 1907f2f13..b70efcb4d 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -14,6 +14,7 @@ use crate::{ lsp_ext, main_loop::Task, }; +use lsp_ext::StatusParams; impl GlobalState { pub(crate) fn update_configuration(&mut self, config: Config) { @@ -86,7 +87,9 @@ impl GlobalState { Status::Invalid => lsp_ext::Status::Invalid, Status::NeedsReload => lsp_ext::Status::NeedsReload, }; - self.send_notification::(lsp_status); + self.send_notification::(StatusParams { + status: lsp_status, + }); } } pub(crate) fn fetch_workspaces(&mut self) { diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 1be01fd88..2e3133449 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -412,7 +412,13 @@ Reloads project information (that is, re-executes `cargo metadata`). **Method:** `rust-analyzer/status` -**Notification:** `"loading" | "ready" | "invalid" | "needsReload"` +**Notification:** + +```typescript +interface StatusParams { + status: "loading" | "ready" | "invalid" | "needsReload", +} +``` This notification is sent from server to client. The client can use it to display persistent status to the user (in modline). diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 6e767babf..543f7e02e 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -36,7 +36,7 @@ export class Ctx { res.pushCleanup(client.start()); await client.onReady(); - client.onNotification(ra.status, (status) => res.setStatus(status)); + client.onNotification(ra.status, (params) => res.setStatus(params.status)); return res; } diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 494d51c83..8663737a6 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -8,7 +8,10 @@ export const analyzerStatus = new lc.RequestType("rust-analy export const memoryUsage = new lc.RequestType("rust-analyzer/memoryUsage"); export type Status = "loading" | "ready" | "invalid" | "needsReload"; -export const status = new lc.NotificationType("rust-analyzer/status"); +export interface StatusParams { + status: Status; +} +export const status = new lc.NotificationType("rust-analyzer/status"); export const reloadWorkspace = new lc.RequestType("rust-analyzer/reloadWorkspace"); -- cgit v1.2.3