rust-analyzer/crates
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
..
base_db internal: add integrated test for token censoring 2021-10-10 16:52:21 +03:00
cfg internal: update expect 2021-10-09 17:17:16 +03:00
flycheck Remove unnecessary unused attribute 2021-10-11 14:42:18 +02:00
hir Add basic support for delegation 2021-10-13 18:05:09 +02:00
hir_def internal: add integrated test for token censoring 2021-10-10 16:52:21 +03:00
hir_expand Merge #10514 2021-10-10 18:09:13 +00:00
hir_ty internal: update expect 2021-10-09 17:17:16 +03:00
ide Merge #10538 2021-10-14 11:50:14 +00:00
ide_assists Merge #10539 2021-10-14 18:16:17 +00:00
ide_completion Saw a FIXME comment and decided to fix it. 2021-10-12 11:52:31 -04:00
ide_db resolve ControlFlow ourself instead of hard coding. 2021-10-13 21:19:41 +08:00
ide_diagnostics Merge #10504 2021-10-10 07:17:52 +00:00
ide_ssr internal: update expect 2021-10-09 17:17:16 +03:00
limit internal: add API to check what are the max limits in practice 2021-07-31 18:26:43 +03:00
mbe internal: clean up code duplication 2021-10-10 21:08:10 +03:00
parser Support let...else 2021-10-07 17:06:24 +02:00
paths Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
proc_macro_api Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
proc_macro_srv internal: update expect 2021-10-09 17:17:16 +03:00
proc_macro_test cargo_metadata 0.14 2021-07-09 11:01:55 -04:00
profile Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
project_model Merge #10503 2021-10-14 11:42:53 +00:00
rust-analyzer Merge #10517 2021-10-14 11:57:16 +00:00
sourcegen Add semicolons for consistency 2021-10-03 23:39:43 +11:00
stdx Kill the child process before waiting in streaming_output 2021-10-14 13:53:25 +02:00
syntax Enable delegation generation for complex types 2021-10-14 13:23:46 +02:00
test_utils internal: move tests 2021-10-10 12:39:58 +03:00
text_edit Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
toolchain minor: drop dummy authors field 2021-07-05 14:19:41 +03:00
tt Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
vfs Merge #10423 2021-10-12 18:35:03 +00:00
vfs-notify Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00