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

Add reload workspace command #5169

Merged
merged 1 commit into from
Jul 1, 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
6 changes: 3 additions & 3 deletions crates/rust-analyzer/src/lsp_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl GlobalState {
self.register_request(&req, request_received);

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::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
.on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))?
Expand Down
8 changes: 4 additions & 4 deletions docs/dev/lsp-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -504,4 +504,4 @@ Such actions on the client side are appended to a hover bottom as command links:
| TITLE _Action1_ | _Action2_ | <- second group
+-----------------------------+
...
```
```
8 changes: 4 additions & 4 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -815,7 +815,7 @@
"when": "inRustProject"
},
{
"command": "rust-analyzer.collectGarbage",
"command": "rust-analyzer.reloadWorkspace",
"when": "inRustProject"
},
{
Expand Down
4 changes: 2 additions & 2 deletions editors/code/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion editors/code/src/lsp_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as lc from "vscode-languageclient";

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 {
textDocument: lc.TextDocumentIdentifier;
Expand Down
2 changes: 1 addition & 1 deletion editors/code/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down