Skip to content

Commit 3f94ad3

Browse files
bors[bot]matklad
andauthored
Merge #5169
5169: Add reload workspace command r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents e080c19 + c9f8789 commit 3f94ad3

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

crates/rust-analyzer/src/lsp_ext.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ impl Request for AnalyzerStatus {
1414
const METHOD: &'static str = "rust-analyzer/analyzerStatus";
1515
}
1616

17-
pub enum CollectGarbage {}
17+
pub enum ReloadWorkspace {}
1818

19-
impl Request for CollectGarbage {
19+
impl Request for ReloadWorkspace {
2020
type Params = ();
2121
type Result = ();
22-
const METHOD: &'static str = "rust-analyzer/collectGarbage";
22+
const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
2323
}
2424

2525
pub enum SyntaxTree {}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl GlobalState {
276276
self.register_request(&req, request_received);
277277

278278
RequestDispatcher { req: Some(req), global_state: self }
279-
.on_sync::<lsp_ext::CollectGarbage>(|s, ()| Ok(s.analysis_host.collect_garbage()))?
279+
.on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.reload()))?
280280
.on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
281281
.on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
282282
.on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))?

docs/dev/lsp-extensions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,15 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look
389389

390390
Returns internal status message, mostly for debugging purposes.
391391

392-
## Collect Garbage
392+
## Reload Workspace
393393

394-
**Method:** `rust-analyzer/collectGarbage`
394+
**Method:** `rust-analyzer/reloadWorkspace`
395395

396396
**Request:** `null`
397397

398398
**Response:** `null`
399399

400-
Frees some caches. For internal use, and is mostly broken at the moment.
400+
Reloads project information (that is, re-executes `cargo metadata`).
401401

402402
## Syntax Tree
403403

@@ -504,4 +504,4 @@ Such actions on the client side are appended to a hover bottom as command links:
504504
| TITLE _Action1_ | _Action2_ | <- second group
505505
+-----------------------------+
506506
...
507-
```
507+
```

editors/code/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"activationEvents": [
6262
"onLanguage:rust",
6363
"onCommand:rust-analyzer.analyzerStatus",
64-
"onCommand:rust-analyzer.collectGarbage",
64+
"onCommand:rust-analyzer.reloadWorkspace",
6565
"workspaceContains:**/Cargo.toml"
6666
],
6767
"main": "./out/src/main",
@@ -143,8 +143,8 @@
143143
"category": "Rust Analyzer"
144144
},
145145
{
146-
"command": "rust-analyzer.collectGarbage",
147-
"title": "Run garbage collection",
146+
"command": "rust-analyzer.reloadWorkspace",
147+
"title": "Reload workspace",
148148
"category": "Rust Analyzer"
149149
},
150150
{
@@ -815,7 +815,7 @@
815815
"when": "inRustProject"
816816
},
817817
{
818-
"command": "rust-analyzer.collectGarbage",
818+
"command": "rust-analyzer.reloadWorkspace",
819819
"when": "inRustProject"
820820
},
821821
{

editors/code/src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ export function expandMacro(ctx: Ctx): Cmd {
330330
};
331331
}
332332

333-
export function collectGarbage(ctx: Ctx): Cmd {
334-
return async () => ctx.client.sendRequest(ra.collectGarbage, null);
333+
export function reloadWorkspace(ctx: Ctx): Cmd {
334+
return async () => ctx.client.sendRequest(ra.reloadWorkspace, null);
335335
}
336336

337337
export function showReferences(ctx: Ctx): Cmd {

editors/code/src/lsp_ext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as lc from "vscode-languageclient";
66

77
export const analyzerStatus = new lc.RequestType<null, string, void>("rust-analyzer/analyzerStatus");
88

9-
export const collectGarbage = new lc.RequestType<null, null, void>("rust-analyzer/collectGarbage");
9+
export const reloadWorkspace = new lc.RequestType<null, null, void>("rust-analyzer/reloadWorkspace");
1010

1111
export interface SyntaxTreeParams {
1212
textDocument: lc.TextDocumentIdentifier;

editors/code/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export async function activate(context: vscode.ExtensionContext) {
8888
});
8989

9090
ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
91-
ctx.registerCommand('collectGarbage', commands.collectGarbage);
91+
ctx.registerCommand('reloadWorkspace', commands.reloadWorkspace);
9292
ctx.registerCommand('matchingBrace', commands.matchingBrace);
9393
ctx.registerCommand('joinLines', commands.joinLines);
9494
ctx.registerCommand('parentModule', commands.parentModule);

0 commit comments

Comments
 (0)