mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Add reload workspace command
This commit is contained in:
parent
ec8b4dca02
commit
c9f878962a
7 changed files with 16 additions and 16 deletions
|
@ -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 {}
|
||||||
|
|
|
@ -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(()))?
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue