From c9f878962a7c9d1c33d5834a1dce2106c9286699 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 1 Jul 2020 14:57:59 +0200 Subject: Add reload workspace command --- crates/rust-analyzer/src/lsp_ext.rs | 6 +++--- crates/rust-analyzer/src/main_loop.rs | 2 +- docs/dev/lsp-extensions.md | 8 ++++---- editors/code/package.json | 8 ++++---- editors/code/src/commands.ts | 4 ++-- editors/code/src/lsp_ext.ts | 2 +- editors/code/src/main.ts | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 1befe678c..82207bbb8 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -14,12 +14,12 @@ impl Request for AnalyzerStatus { const METHOD: &'static str = "rust-analyzer/analyzerStatus"; } -pub enum CollectGarbage {} +pub enum ReloadWorkspace {} -impl Request for CollectGarbage { +impl Request for ReloadWorkspace { type Params = (); type Result = (); - const METHOD: &'static str = "rust-analyzer/collectGarbage"; + const METHOD: &'static str = "rust-analyzer/reloadWorkspace"; } pub enum SyntaxTree {} diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 2ce1441b6..e3d49d24d 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -276,7 +276,7 @@ impl GlobalState { self.register_request(&req, request_received); RequestDispatcher { req: Some(req), global_state: self } - .on_sync::(|s, ()| Ok(s.analysis_host.collect_garbage()))? + .on_sync::(|s, ()| Ok(s.reload()))? .on_sync::(|s, p| handlers::handle_join_lines(s.snapshot(), p))? .on_sync::(|s, p| handlers::handle_on_enter(s.snapshot(), p))? .on_sync::(|_, ()| Ok(()))? diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index a0847dad3..c0afb16d3 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -389,15 +389,15 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look Returns internal status message, mostly for debugging purposes. -## Collect Garbage +## Reload Workspace -**Method:** `rust-analyzer/collectGarbage` +**Method:** `rust-analyzer/reloadWorkspace` **Request:** `null` **Response:** `null` -Frees some caches. For internal use, and is mostly broken at the moment. +Reloads project information (that is, re-executes `cargo metadata`). ## Syntax Tree @@ -504,4 +504,4 @@ Such actions on the client side are appended to a hover bottom as command links: | TITLE _Action1_ | _Action2_ | <- second group +-----------------------------+ ... -``` \ No newline at end of file +``` diff --git a/editors/code/package.json b/editors/code/package.json index fcb101fc6..af0a5c851 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -61,7 +61,7 @@ "activationEvents": [ "onLanguage:rust", "onCommand:rust-analyzer.analyzerStatus", - "onCommand:rust-analyzer.collectGarbage", + "onCommand:rust-analyzer.reloadWorkspace", "workspaceContains:**/Cargo.toml" ], "main": "./out/src/main", @@ -143,8 +143,8 @@ "category": "Rust Analyzer" }, { - "command": "rust-analyzer.collectGarbage", - "title": "Run garbage collection", + "command": "rust-analyzer.reloadWorkspace", + "title": "Reload workspace", "category": "Rust Analyzer" }, { @@ -815,7 +815,7 @@ "when": "inRustProject" }, { - "command": "rust-analyzer.collectGarbage", + "command": "rust-analyzer.reloadWorkspace", "when": "inRustProject" }, { diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 0e78f5101..19a9c2a0d 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -330,8 +330,8 @@ export function expandMacro(ctx: Ctx): Cmd { }; } -export function collectGarbage(ctx: Ctx): Cmd { - return async () => ctx.client.sendRequest(ra.collectGarbage, null); +export function reloadWorkspace(ctx: Ctx): Cmd { + return async () => ctx.client.sendRequest(ra.reloadWorkspace, null); } export function showReferences(ctx: Ctx): Cmd { diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index fdb99956b..981b6f40e 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -6,7 +6,7 @@ import * as lc from "vscode-languageclient"; export const analyzerStatus = new lc.RequestType("rust-analyzer/analyzerStatus"); -export const collectGarbage = new lc.RequestType("rust-analyzer/collectGarbage"); +export const reloadWorkspace = new lc.RequestType("rust-analyzer/reloadWorkspace"); export interface SyntaxTreeParams { textDocument: lc.TextDocumentIdentifier; diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 5ceab8b44..2982b9cbf 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -88,7 +88,7 @@ export async function activate(context: vscode.ExtensionContext) { }); ctx.registerCommand('analyzerStatus', commands.analyzerStatus); - ctx.registerCommand('collectGarbage', commands.collectGarbage); + ctx.registerCommand('reloadWorkspace', commands.reloadWorkspace); ctx.registerCommand('matchingBrace', commands.matchingBrace); ctx.registerCommand('joinLines', commands.joinLines); ctx.registerCommand('parentModule', commands.parentModule); -- cgit v1.2.3