Add reload workspace command

This commit is contained in:
Aleksey Kladov 2020-07-01 14:57:59 +02:00
parent ec8b4dca02
commit c9f878962a
7 changed files with 16 additions and 16 deletions

View file

@ -14,12 +14,12 @@ impl Request for AnalyzerStatus {
const METHOD: &'static str = "rust-analyzer/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 Params = ();
type Result = (); type Result = ();
const METHOD: &'static str = "rust-analyzer/collectGarbage"; const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
} }
pub enum SyntaxTree {} pub enum SyntaxTree {}

View file

@ -276,7 +276,7 @@ impl GlobalState {
self.register_request(&req, request_received); self.register_request(&req, request_received);
RequestDispatcher { req: Some(req), global_state: self } RequestDispatcher { req: Some(req), global_state: self }
.on_sync::<lsp_ext::CollectGarbage>(|s, ()| Ok(s.analysis_host.collect_garbage()))? .on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.reload()))?
.on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))? .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
.on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))? .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
.on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))? .on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))?

View file

@ -389,15 +389,15 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look
Returns internal status message, mostly for debugging purposes. Returns internal status message, mostly for debugging purposes.
## Collect Garbage ## Reload Workspace
**Method:** `rust-analyzer/collectGarbage` **Method:** `rust-analyzer/reloadWorkspace`
**Request:** `null` **Request:** `null`
**Response:** `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 ## 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 | TITLE _Action1_ | _Action2_ | <- second group
+-----------------------------+ +-----------------------------+
... ...
``` ```

View file

@ -61,7 +61,7 @@
"activationEvents": [ "activationEvents": [
"onLanguage:rust", "onLanguage:rust",
"onCommand:rust-analyzer.analyzerStatus", "onCommand:rust-analyzer.analyzerStatus",
"onCommand:rust-analyzer.collectGarbage", "onCommand:rust-analyzer.reloadWorkspace",
"workspaceContains:**/Cargo.toml" "workspaceContains:**/Cargo.toml"
], ],
"main": "./out/src/main", "main": "./out/src/main",
@ -143,8 +143,8 @@
"category": "Rust Analyzer" "category": "Rust Analyzer"
}, },
{ {
"command": "rust-analyzer.collectGarbage", "command": "rust-analyzer.reloadWorkspace",
"title": "Run garbage collection", "title": "Reload workspace",
"category": "Rust Analyzer" "category": "Rust Analyzer"
}, },
{ {
@ -815,7 +815,7 @@
"when": "inRustProject" "when": "inRustProject"
}, },
{ {
"command": "rust-analyzer.collectGarbage", "command": "rust-analyzer.reloadWorkspace",
"when": "inRustProject" "when": "inRustProject"
}, },
{ {

View file

@ -330,8 +330,8 @@ export function expandMacro(ctx: Ctx): Cmd {
}; };
} }
export function collectGarbage(ctx: Ctx): Cmd { export function reloadWorkspace(ctx: Ctx): Cmd {
return async () => ctx.client.sendRequest(ra.collectGarbage, null); return async () => ctx.client.sendRequest(ra.reloadWorkspace, null);
} }
export function showReferences(ctx: Ctx): Cmd { export function showReferences(ctx: Ctx): Cmd {

View file

@ -6,7 +6,7 @@ import * as lc from "vscode-languageclient";
export const analyzerStatus = new lc.RequestType<null, string, void>("rust-analyzer/analyzerStatus"); export const analyzerStatus = new lc.RequestType<null, string, void>("rust-analyzer/analyzerStatus");
export const collectGarbage = new lc.RequestType<null, null, void>("rust-analyzer/collectGarbage"); export const reloadWorkspace = new lc.RequestType<null, null, void>("rust-analyzer/reloadWorkspace");
export interface SyntaxTreeParams { export interface SyntaxTreeParams {
textDocument: lc.TextDocumentIdentifier; textDocument: lc.TextDocumentIdentifier;

View file

@ -88,7 +88,7 @@ export async function activate(context: vscode.ExtensionContext) {
}); });
ctx.registerCommand('analyzerStatus', commands.analyzerStatus); ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
ctx.registerCommand('collectGarbage', commands.collectGarbage); ctx.registerCommand('reloadWorkspace', commands.reloadWorkspace);
ctx.registerCommand('matchingBrace', commands.matchingBrace); ctx.registerCommand('matchingBrace', commands.matchingBrace);
ctx.registerCommand('joinLines', commands.joinLines); ctx.registerCommand('joinLines', commands.joinLines);
ctx.registerCommand('parentModule', commands.parentModule); ctx.registerCommand('parentModule', commands.parentModule);