Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StatusNotification #5782

Merged
merged 1 commit into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/rust-analyzer/src/lsp_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
5 changes: 4 additions & 1 deletion crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -86,7 +87,9 @@ impl GlobalState {
Status::Invalid => lsp_ext::Status::Invalid,
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) {
Expand Down
8 changes: 7 additions & 1 deletion docs/dev/lsp-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion editors/code/src/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion editors/code/src/lsp_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 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");

Expand Down