mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Preliminary implementation of lazy CodeAssits
This commit is contained in:
parent
61e8f39219
commit
57cd936c52
13 changed files with 218 additions and 88 deletions
|
@ -343,10 +343,25 @@ export function showReferences(ctx: Ctx): Cmd {
|
|||
}
|
||||
|
||||
export function applyActionGroup(_ctx: Ctx): Cmd {
|
||||
return async (actions: { label: string; edit: vscode.WorkspaceEdit }[]) => {
|
||||
return async (actions: { label: string; arguments: ra.ResolveCodeActionParams }[]) => {
|
||||
const selectedAction = await vscode.window.showQuickPick(actions);
|
||||
if (!selectedAction) return;
|
||||
await applySnippetWorkspaceEdit(selectedAction.edit);
|
||||
vscode.commands.executeCommand(
|
||||
'rust-analyzer.resolveCodeAction',
|
||||
selectedAction.arguments,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveCodeAction(ctx: Ctx): Cmd {
|
||||
const client = ctx.client;
|
||||
return async (params: ra.ResolveCodeActionParams) => {
|
||||
const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, params);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const edit = client.protocol2CodeConverter.asWorkspaceEdit(item);
|
||||
await applySnippetWorkspaceEdit(edit);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue