rust-analyzer/crates/ide_assists/src/handlers
bors[bot] e52d47a3b8
Merge #10539
10539: Add "generate delegate methods" assist r=Veykril a=yoshuawuyts

_Co-authored with `@rylev_.`

This patch adds a new assist: "generate delegate method" which creates a method that calls to a method defined on an inner field. Delegation is common when authoring newtypes, and having IDE support for this is the best way we can make this easier to author in Rust, bar adding language-level support for it. Thanks!

Closes #5944.

## Example

__before__
```rust
struct Age(u8);
impl Age {
    fn age(&self) -> u8 {
        self.0
    }
}

struct Person {
    ag$0e: Age,
}
```

__after__
```rust
struct Age(u8);
impl Age {
    fn age(&self) -> u8 {
        self.0
    }
}

struct Person {
    age: Age,
}

impl Person {
    $0fn age(&self) -> u8 {
        self.age.age()
    }
}
```

Co-authored-by: Ryan Levick <me@ryanlevick.com>
Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-10-14 18:16:17 +00:00
..
add_explicit_type.rs Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
add_lifetime_to_type.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
add_missing_impl_members.rs implement feedback from review 2021-08-10 12:21:48 +02:00
add_missing_match_arms.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
add_return_type.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
add_turbo_fish.rs internal: remove needless distinction between a carte and its root mod 2021-07-11 14:55:24 +03:00
apply_demorgan.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
auto_import.rs Deduplicate imports for qualify_path 2021-09-01 21:51:28 +02:00
change_visibility.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
convert_bool_then.rs Parenthesize expressions in if_to_bool_then assist where required 2021-10-01 12:19:01 +02:00
convert_comment_block.rs internal: prevent possible bugs when adding magical comments 2021-09-13 13:43:13 +03:00
convert_integer_literal.rs 7526: Rename crate assists to ide_assists. 2021-02-23 00:59:16 +05:30
convert_into_to_from.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
convert_iter_for_each_to_for.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
convert_to_guarded_return.rs internal: more reasonable grammar for blocks 2021-09-26 19:16:09 +03:00
convert_tuple_struct_to_named_struct.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
convert_while_to_loop.rs Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
destructure_tuple_binding.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
expand_glob_import.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
extract_function.rs Merge #10309 2021-10-14 10:47:11 +00:00
extract_struct_from_enum_variant.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
extract_type_alias.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
extract_variable.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
fix_visibility.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
flip_binexpr.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
flip_comma.rs internal: don't use #[should_panic] for tests 2021-04-13 12:21:59 +03:00
flip_trait_bound.rs Upgrade rowan 2021-03-16 16:10:49 +03:00
generate_constant.rs cleanup 2021-10-06 10:14:12 +08:00
generate_default_from_enum_variant.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_default_from_new.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_delegate_methods.rs fix ret type in generic 2021-10-14 18:38:52 +02:00
generate_deref.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_derive.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_enum_is_method.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_enum_projection_method.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_from_impl_for_enum.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_function.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
generate_getter.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_impl.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_is_empty_from_len.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_new.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_setter.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
inline_call.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
inline_local_variable.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
introduce_named_generic.rs Rename some assists 2021-09-21 00:54:09 +02:00
introduce_named_lifetime.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
invert_if.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
merge_imports.rs Don't compare ast::Visibility by stringifying 2021-05-20 17:45:59 +02:00
merge_match_arms.rs Fix assists assuming comma belonging to MATCH_ARM_LIST 2021-07-30 16:01:26 +02:00
move_bounds.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
move_from_mod_rs.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
move_guard.rs Merge iter_for_each_to_for and for_to_iter_for_each assists modules 2021-09-21 10:34:11 +02:00
move_module_to_file.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
move_to_mod_rs.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
pull_assignment_up.rs Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
qualify_path.rs Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
raw_string.rs Simplify 2021-09-13 18:50:19 +02:00
remove_dbg.rs internal: more reasonable grammar for blocks 2021-09-26 19:16:09 +03:00
remove_mut.rs 7526: Rename crate assists to ide_assists. 2021-02-23 00:59:16 +05:30
remove_unused_param.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
reorder_fields.rs Allow several samples in "// Assist:" comments. 2021-08-02 19:49:36 +03:00
reorder_impl.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
replace_derive_with_manual_impl.rs Simplify generated PartialOrd code 2021-10-12 17:44:57 +02:00
replace_if_let_with_match.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
replace_let_with_if_let.rs Expose HasSource::source through Semantics with caching behaviour 2021-10-07 15:00:14 +02:00
replace_qualified_name_with_use.rs Simplify 2021-09-13 18:50:19 +02:00
replace_string_with_char.rs Add replace_char_with_string assist 2021-07-30 16:46:06 +02:00
replace_try_expr_with_match.rs fix tests 2021-10-06 20:45:18 +02:00
sort_items.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
split_import.rs Don't classify NameRef paths inside attribute TokenTrees 2021-06-30 21:51:28 +02:00
toggle_ignore.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
unmerge_use.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
unwrap_block.rs internal: more reasonable grammar for blocks 2021-09-26 19:16:09 +03:00
wrap_return_type_in_result.rs Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00