aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/tests
Commit message (Collapse)AuthorAgeFilesLines
* Add getter/setter assistsYoshua Wuyts2021-02-091-0/+71
| | | | | | | | | | | | | | | | 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
*-. Merge #7570 #7571bors[bot]2021-02-051-0/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7570: Add doc gen to the `generate_enum_match_method` assist r=yoshuawuyts a=yoshuawuyts Implements a small extension to https://github.com/rust-analyzer/rust-analyzer/pull/7562, generating default comments. I wasn't sure if this would fit the goals of Rust-Analyzer, so I chose to split it into a separate PR. This is especially useful when writing code in a codebase which uses `#![warn(missing_docs)]` lint, as many production-grade libraries do. The comments we're generating here are similar to the ones found on [`Option::is_some`](https://doc.rust-lang.org/std/option/enum.Option.html#method.is_some) and [`Result::is_err`](https://doc.rust-lang.org/std/result/enum.Result.html#method.is_err). I briefly considered only generating these for `pub` types, but they seem small and unobtrusive enough that they're probably useful in the general case. Thanks! ## Example __input__ ```rust pub(crate) enum Variant { Undefined, Minor, // cursor here Major, } ``` __output__ ```rust pub(crate) enum Variant { Undefined, Minor, Major, } impl Variant { /// Returns `true` if the variant is [`Minor`]. pub(crate) fn is_minor(&self) -> bool { matches!(self, Self::Minor) } } ``` ## Future Directions This opens up the path to adding an assist for generating these comments on existing `is_` methods. This would make it both easy to document new code, and update existing code with documentation. 7571: Cleanup decl_check r=Veykril a=Veykril bors r+ Co-authored-by: Yoshua Wuyts <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
| * | Add doc gen to the `generate_enum_match_method` assistYoshua Wuyts2021-02-051-0/+1
| | |
* | | Merge #7562bors[bot]2021-02-051-0/+27
|\| | | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7562: add `generate_enum_match` assist r=matklad a=yoshuawuyts This adds a `generate_enum_match` assist, which generates `is_` variants for enums (e.g. `Option::{is_none,is_some}` in std). This is my first attempt at contributing to Rust-Analyzer, so I'm not sure if I've gotten everything right. Thanks! ## Example **Input** ```rust pub(crate) enum Variant { Undefined, Minor, // cursor here Major, } ``` **Output** ```rust pub(crate) enum Variant { Undefined, Minor, Major, } impl Variant { pub(crate) fn is_minor(&self) -> bool { matches!(self, Self::Minor) } } ``` ## Future Directions I made this as a stepping stone for some of the more involved refactors (e.g. #5944). I'm not sure yet how to create, use, and test `window.showQuickPick`-based asssists in RA. But once that's possible, it'd probably be nice to be able to generate match methods in bulk through the quickpick UI rather than one-by-one: ``` [x] Select enum members to generate methods for. (3 selected) [ OK ] --------------------------------------------------------------------------- [x] Undefined [x] Minor [x] Major ``` Co-authored-by: Yoshua Wuyts <[email protected]> Co-authored-by: Yoshua Wuyts <[email protected]>
| * add `generate-enum-match` assistYoshua Wuyts2021-02-051-0/+27
| |
* | initial version of extract function assistVladyslav Katasonov2021-02-031-0/+27
|/ | | | | | | | there are a few currently limitations: * no modifications of function body * does not handle mutability and references * no method support * may produce incorrect results
* Add assist: add lifetime to type #7200Benjamin Coenen2021-01-211-2/+2
| | | | Signed-off-by: Benjamin Coenen <[email protected]>
* Add assist: add lifetime to type #7200Benjamin Coenen2021-01-171-0/+19
| | | | Signed-off-by: Benjamin Coenen <[email protected]>
* Add Unmerge Use assistunexge2021-01-151-0/+14
|
* Sort impls by trait definitionFisher Darling2021-01-131-0/+35
| | | | Closes #6110
* Change <|> to $0 - RebaseKevaundray Wedderburn2021-01-071-56/+56
|
* Better target for move moduleAleksey Kladov2021-01-061-15/+15
|
* Created an inline-function assist (fixes #6863)Michael-F-Bryan2021-01-041-0/+23
|
* rename exrtract_assignment -> pullAleksey Kladov2021-01-041-29/+29
| | | | | | | Vertical code motions are conventionally called "pull up" / "push down". "extract" is used for introducing new names.
* Add extract-assignment assistJesse Bakker2021-01-021-0/+29
|
* Fix type typo in add_missing_impl_members docLukas Wirth2020-12-251-7/+9
|
* Add extract_module_to_file assistDaiki Ihara2020-12-211-0/+15
|
* generate default implementation for an enum from an enum variant #6860Benjamin Coenen2020-12-141-0/+27
| | | | Signed-off-by: Benjamin Coenen <[email protected]>
* Add replace_match_with_if_let assistLukas Wirth2020-12-051-0/+28
|
* Minor cleanupAleksey Kladov2020-11-301-20/+20
|
* Add **Ignore Test** assistAleksey Kladov2020-11-171-0/+20
|
* More consistent namingAleksey Kladov2020-11-091-13/+13
|
* More consistent namingAleksey Kladov2020-11-091-19/+23
|
* Add infer_function_return_type assistLukas Wirth2020-11-061-0/+13
|
* Merge #6256bors[bot]2020-10-201-0/+17
|\ | | | | | | | | | | | | | | | | 6256: Assist: replace string with char r=bnjjj a=bnjjj close #6252 Co-authored-by: Benjamin Coenen <[email protected]> Co-authored-by: Coenen Benjamin <[email protected]>
| * Assist: replace string with charBenjamin Coenen2020-10-201-0/+17
| | | | | | | | Signed-off-by: Benjamin Coenen <[email protected]>
* | Properly qualify trait methods in qualify_path assistLukas Wirth2020-10-151-0/+19
|/
* when generating new function, focus on return type instead of bodyBenjamin Coenen2020-10-081-2/+2
| | | | Signed-off-by: Benjamin Coenen <[email protected]>
* Add convert integer literal assistvlakreeh2020-09-291-0/+13
|
* Remove unnecessary commaAleksei Sidorov2020-09-041-1/+1
|
* Fix testsAleksei Sidorov2020-09-041-2/+2
|
* Update codegenAleksei Sidorov2020-09-041-0/+13
|
* **Remove Unused Parameter** refactoringAleksey Kladov2020-08-191-0/+21
|
* update generated testsjDomantas2020-08-171-2/+1
|
* Rename ra_assists -> assistsAleksey Kladov2020-08-131-0/+892