aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/tests.rs
Commit message (Collapse)AuthorAgeFilesLines
* Make more common assist easier to uesAleksey Kladov2021-02-221-38/+67
|
* handle return, break and continue when extracting functionVladyslav Katasonov2021-02-131-1/+4
|
* Merge #7617bors[bot]2021-02-101-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7617: Add getter/setter assists r=Veykril a=yoshuawuyts This patch makes progress towards the design outlined in https://github.com/rust-analyzer/rust-analyzer/issues/5943, and includes a small refactor which closes https://github.com/rust-analyzer/rust-analyzer/issues/7607. All together this patch does 4 things: - Adds a `generate_getter` assist. - Adds a `generate_getter_mut` assist. - Adds a `generate_setter` assist. - Moves the `generate_impl_text` function from `generate_new` into `utils` (which closes #7607). ## Design Notes I've chosen to follow the [Rust API guidelines on getters](https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter) as closely as possible. This deliberately leaves "builder pattern"-style setters out of scope. Also, similar to https://github.com/rust-analyzer/rust-analyzer/pull/7570 this assist generates doc comments. I think this should work well in most cases, and for the few where it doesn't it's probably easily edited. This makes it slightly less correct than the #7570 implementation, but I think this is still useful enough to include for many of the same reasons. The reason why this PR contains 3 assists, rather than 1, is because each of them is so similar to the others that it felt more noisy to do them separately than all at once. The amount of code added does not necessarily reflect that, but hope that still makes sense. ## Examples **Input** ```rust struct Person { name: String, // <- cursor on "name" } ``` **generate getter** ```rust struct Person { name: String, } impl Person { /// Get a reference to the person's name. fn name(&self) -> &String { &self.name } } ``` **generate mut getter** ```rust struct Person { name: String, } impl Person { /// Get a mutable reference to the person's name. fn name_mut(&mut self) -> &mut String { &mut self.name } } ``` **generate setter** ```rust struct Person { name: String, } impl Person { /// Set the person's name. fn set_name(&mut self, name: String) { self.name = name; } } ``` Co-authored-by: Yoshua Wuyts <[email protected]>
| * Add getter/setter assistsYoshua Wuyts2021-02-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Finish implementing `generate_setter` assists Make `generate_impl_text` util generic generate getter methods Fix getter / setter naming It's now in-line with the Rust API naming guidelines: https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter apply clippy Improve examples
* | Add #[track_caller] to assist testsYoshua Wuyts2021-02-091-0/+4
|/
* Share import_assets and related entitiesKirill Bulatov2021-01-161-4/+5
|
* Phase out SourceFileEdits in favour of a plain HashMapLukas Wirth2021-01-141-14/+11
|
* Group file source edits by FileIdLukas Wirth2021-01-141-11/+8
|
* Change <|> to $0 - RebaseKevaundray Wedderburn2021-01-071-3/+3
|
* Align config's API with usageAleksey Kladov2021-01-061-12/+26
| | | | The config now is mostly immutable, optimize for that.
* Simplify assists resolution APIAleksey Kladov2020-12-261-25/+23
| | | | | | Assist vs UnresolvedAssist split doesn't really pull its weight. This is especially bad if we want to include `Assist` as a field of diagnostics, where we'd have to make the thing generic.
* Fix assist test logicDaiki Ihara2020-12-211-2/+6
|
* Add initial_contents field for CreateFileDaiki Ihara2020-12-211-36/+16
|
* Add handling file_system_edit in test assistsDaiki Ihara2020-12-211-12/+48
|
* Support multi-file assist testsAleksey Kladov2020-11-091-6/+19
|
* Re-export base_db from ide_dbIgor Aleksanov2020-10-241-1/+1
|
* Add ability to specify ResolvedAssist by labelvlakreeh2020-09-291-5/+22
|
* Rename ra_assists -> assistsAleksey Kladov2020-08-131-0/+179