Merge #11001
11001: minor: fixup generate assist priorities r=Veykril a=Veykril Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10996 bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
e1f3982a5f
@ -47,18 +47,18 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext)
|
||||
let strukt_name = strukt.name()?;
|
||||
let current_module = ctx.sema.scope(strukt.syntax()).module()?;
|
||||
|
||||
let (field_name, field_ty) = match ctx.find_node_at_offset::<ast::RecordField>() {
|
||||
let (field_name, field_ty, target) = match ctx.find_node_at_offset::<ast::RecordField>() {
|
||||
Some(field) => {
|
||||
let field_name = field.name()?;
|
||||
let field_ty = field.ty()?;
|
||||
(format!("{}", field_name), field_ty)
|
||||
(format!("{}", field_name), field_ty, field.syntax().text_range())
|
||||
}
|
||||
None => {
|
||||
let field = ctx.find_node_at_offset::<ast::TupleField>()?;
|
||||
let field_list = ctx.find_node_at_offset::<ast::TupleFieldList>()?;
|
||||
let field_list_index = field_list.fields().position(|it| it == field)?;
|
||||
let field_ty = field.ty()?;
|
||||
(format!("{}", field_list_index), field_ty)
|
||||
(format!("{}", field_list_index), field_ty, field.syntax().text_range())
|
||||
}
|
||||
};
|
||||
|
||||
@ -74,7 +74,6 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext)
|
||||
Option::<()>::None
|
||||
});
|
||||
|
||||
let target = field_ty.syntax().text_range();
|
||||
for method in methods {
|
||||
let adt = ast::Adt::Struct(strukt.clone());
|
||||
let name = method.name(ctx.db()).to_string();
|
||||
|
@ -217,8 +217,6 @@ pub(crate) fn all() -> &'static [Handler] {
|
||||
generate_constant::generate_constant,
|
||||
generate_default_from_enum_variant::generate_default_from_enum_variant,
|
||||
generate_default_from_new::generate_default_from_new,
|
||||
generate_delegate_methods::generate_delegate_methods,
|
||||
generate_deref::generate_deref,
|
||||
generate_derive::generate_derive,
|
||||
generate_documentation_template::generate_documentation_template,
|
||||
generate_enum_is_method::generate_enum_is_method,
|
||||
@ -287,6 +285,8 @@ pub(crate) fn all() -> &'static [Handler] {
|
||||
generate_getter::generate_getter,
|
||||
generate_getter::generate_getter_mut,
|
||||
generate_setter::generate_setter,
|
||||
generate_delegate_methods::generate_delegate_methods,
|
||||
generate_deref::generate_deref,
|
||||
// Are you sure you want to add new assist here, and not to the
|
||||
// sorted list above?
|
||||
]
|
||||
|
@ -222,10 +222,10 @@ fn assist_order_field_struct() {
|
||||
let mut assists = assists.iter();
|
||||
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Change visibility to pub(crate)");
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Generate `Deref` impl using `bar`");
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Generate a getter method");
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Generate a mut getter method");
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Generate a setter method");
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Generate `Deref` impl using `bar`");
|
||||
assert_eq!(assists.next().expect("expected assist").label, "Add `#[derive]`");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user