Fix StatusNotification

This commit is contained in:
vsrs 2020-08-17 14:56:27 +03:00
parent b050937c10
commit 1eed036a6e
5 changed files with 22 additions and 5 deletions

View file

@ -237,8 +237,13 @@ pub enum Status {
Invalid, Invalid,
} }
#[derive(Deserialize, Serialize)]
pub struct StatusParams {
pub status: Status,
}
impl Notification for StatusNotification { impl Notification for StatusNotification {
type Params = Status; type Params = StatusParams;
const METHOD: &'static str = "rust-analyzer/status"; const METHOD: &'static str = "rust-analyzer/status";
} }

View file

@ -14,6 +14,7 @@ use crate::{
lsp_ext, lsp_ext,
main_loop::Task, main_loop::Task,
}; };
use lsp_ext::StatusParams;
impl GlobalState { impl GlobalState {
pub(crate) fn update_configuration(&mut self, config: Config) { pub(crate) fn update_configuration(&mut self, config: Config) {
@ -86,7 +87,9 @@ impl GlobalState {
Status::Invalid => lsp_ext::Status::Invalid, Status::Invalid => lsp_ext::Status::Invalid,
Status::NeedsReload => lsp_ext::Status::NeedsReload, Status::NeedsReload => lsp_ext::Status::NeedsReload,
}; };
self.send_notification::<lsp_ext::StatusNotification>(lsp_status); self.send_notification::<lsp_ext::StatusNotification>(StatusParams {
status: lsp_status,
});
} }
} }
pub(crate) fn fetch_workspaces(&mut self) { pub(crate) fn fetch_workspaces(&mut self) {

View file

@ -412,7 +412,13 @@ Reloads project information (that is, re-executes `cargo metadata`).
**Method:** `rust-analyzer/status` **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. This notification is sent from server to client.
The client can use it to display persistent status to the user (in modline). The client can use it to display persistent status to the user (in modline).

View file

@ -36,7 +36,7 @@ export class Ctx {
res.pushCleanup(client.start()); res.pushCleanup(client.start());
await client.onReady(); await client.onReady();
client.onNotification(ra.status, (status) => res.setStatus(status)); client.onNotification(ra.status, (params) => res.setStatus(params.status));
return res; return res;
} }

View file

@ -8,7 +8,10 @@ export const analyzerStatus = new lc.RequestType<null, string, void>("rust-analy
export const memoryUsage = new lc.RequestType<null, string, void>("rust-analyzer/memoryUsage"); export const memoryUsage = new lc.RequestType<null, string, void>("rust-analyzer/memoryUsage");
export type Status = "loading" | "ready" | "invalid" | "needsReload"; export type Status = "loading" | "ready" | "invalid" | "needsReload";
export const status = new lc.NotificationType<Status>("rust-analyzer/status"); export interface StatusParams {
status: Status;
}
export const status = new lc.NotificationType<StatusParams>("rust-analyzer/status");
export const reloadWorkspace = new lc.RequestType<null, null, void>("rust-analyzer/reloadWorkspace"); export const reloadWorkspace = new lc.RequestType<null, null, void>("rust-analyzer/reloadWorkspace");