Add reload workspace command
This commit is contained in:
parent
ec8b4dca02
commit
c9f878962a
@ -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 {}
|
||||
|
@ -276,7 +276,7 @@ fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()>
|
||||
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(()))?
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
},
|
||||
{
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user