mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
Speed up resolving "Generate delegate method" assist (part 1)
Fix #19322 Sometimes there are 185 "Generate delegate" assists with the same assist_id and asssist_kind. This commit introduces and additional differentiator: assist_subtype. Therefore, when the LSP client sends an assist resolve request, rust-analyzer only need to compute edits for a single assist instead of 185.
This commit is contained in:
parent
dab1329f35
commit
7aa70a86d1
5 changed files with 30 additions and 10 deletions
|
|
@ -92,19 +92,18 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'
|
|||
});
|
||||
}
|
||||
methods.sort_by(|(a, _), (b, _)| a.cmp(b));
|
||||
for (name, method) in methods {
|
||||
for (index, (name, method)) in methods.into_iter().enumerate() {
|
||||
let adt = ast::Adt::Struct(strukt.clone());
|
||||
let name = name.display(ctx.db(), current_edition).to_string();
|
||||
// if `find_struct_impl` returns None, that means that a function named `name` already exists.
|
||||
let Some(impl_def) = find_struct_impl(ctx, &adt, std::slice::from_ref(&name)) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let field = make::ext::field_from_idents(["self", &field_name])?;
|
||||
|
||||
acc.add_group(
|
||||
&GroupLabel("Generate delegate methods…".to_owned()),
|
||||
AssistId("generate_delegate_methods", AssistKind::Generate),
|
||||
AssistId("generate_delegate_methods", AssistKind::Generate, Some(index)),
|
||||
format!("Generate delegate for `{field_name}.{name}()`",),
|
||||
target,
|
||||
|edit| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue