mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Add lsp command for rebuilding proc macros
This commit is contained in:
parent
d154ea88f9
commit
e9fb2ffe45
7 changed files with 27 additions and 1 deletions
|
@ -52,6 +52,14 @@ pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> Result<
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn handle_proc_macros_reload(state: &mut GlobalState, _: ()) -> Result<()> {
|
||||
state.proc_macro_clients.clear();
|
||||
state.proc_macro_changed = false;
|
||||
|
||||
state.fetch_build_data_queue.request_op("reload proc macros request".to_string());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn handle_cancel_flycheck(state: &mut GlobalState, _: ()) -> Result<()> {
|
||||
let _p = profile::span("handle_stop_flycheck");
|
||||
state.flycheck.iter().for_each(|flycheck| flycheck.cancel());
|
||||
|
|
|
@ -51,6 +51,14 @@ impl Request for ReloadWorkspace {
|
|||
const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
|
||||
}
|
||||
|
||||
pub enum ReloadProcMacros {}
|
||||
|
||||
impl Request for ReloadProcMacros {
|
||||
type Params = ();
|
||||
type Result = ();
|
||||
const METHOD: &'static str = "rust-analyzer/reloadProcMacros";
|
||||
}
|
||||
|
||||
pub enum SyntaxTree {}
|
||||
|
||||
impl Request for SyntaxTree {
|
||||
|
|
|
@ -633,6 +633,7 @@ impl GlobalState {
|
|||
|
||||
dispatcher
|
||||
.on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)
|
||||
.on_sync_mut::<lsp_ext::ReloadProcMacros>(handlers::handle_proc_macros_reload)
|
||||
.on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)
|
||||
.on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)
|
||||
.on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)
|
||||
|
|
|
@ -749,6 +749,10 @@ export function reloadWorkspace(ctx: CtxInit): Cmd {
|
|||
return async () => ctx.client.sendRequest(ra.reloadWorkspace);
|
||||
}
|
||||
|
||||
export function reloadProcMacros(ctx: CtxInit): Cmd {
|
||||
return async () => ctx.client.sendRequest(ra.reloadProcMacros);
|
||||
}
|
||||
|
||||
export function addProject(ctx: CtxInit): Cmd {
|
||||
return async () => {
|
||||
const discoverProjectCommand = ctx.config.discoverProjectCommand;
|
||||
|
|
|
@ -378,10 +378,13 @@ export class Ctx {
|
|||
if (statusBar.tooltip.value) {
|
||||
statusBar.tooltip.appendText("\n\n");
|
||||
}
|
||||
statusBar.tooltip.appendMarkdown("\n\n[Open logs](command:rust-analyzer.openLogs)");
|
||||
statusBar.tooltip.appendMarkdown(
|
||||
"\n\n[Reload Workspace](command:rust-analyzer.reloadWorkspace)"
|
||||
);
|
||||
statusBar.tooltip.appendMarkdown("\n\n[Open logs](command:rust-analyzer.openLogs)");
|
||||
statusBar.tooltip.appendMarkdown(
|
||||
"\n\n[Rebuild Proc Macros](command:rust-analyzer.reloadProcMacros)"
|
||||
);
|
||||
statusBar.tooltip.appendMarkdown("\n\n[Restart server](command:rust-analyzer.startServer)");
|
||||
statusBar.tooltip.appendMarkdown("\n\n[Stop server](command:rust-analyzer.stopServer)");
|
||||
if (!status.quiescent) icon = "$(sync~spin) ";
|
||||
|
|
|
@ -43,6 +43,7 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
|
|||
"rust-analyzer/relatedTests"
|
||||
);
|
||||
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
|
||||
export const reloadProcMacros = new lc.RequestType0<null, void>("rust-analyzer/reloadProcMacros");
|
||||
|
||||
export const runFlycheck = new lc.NotificationType<{
|
||||
textDocument: lc.TextDocumentIdentifier | null;
|
||||
|
|
|
@ -153,6 +153,7 @@ function createCommands(): Record<string, CommandFactory> {
|
|||
memoryUsage: { enabled: commands.memoryUsage },
|
||||
shuffleCrateGraph: { enabled: commands.shuffleCrateGraph },
|
||||
reloadWorkspace: { enabled: commands.reloadWorkspace },
|
||||
reloadProcMacros: { enabled: commands.reloadProcMacros },
|
||||
addProject: { enabled: commands.addProject },
|
||||
matchingBrace: { enabled: commands.matchingBrace },
|
||||
joinLines: { enabled: commands.joinLines },
|
||||
|
|
Loading…
Reference in a new issue