aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers
Commit message (Collapse)AuthorAgeFilesLines
* use simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. ↵Matthias Krüger2021-03-171-2/+2
| | | | (clippy::bind_instead_of_map)
* don't clone types that are copy (clippy::clone_on_copy)Matthias Krüger2021-03-171-5/+2
|
* Move more boundsAleksey Kladov2021-03-161-26/+10
| | | | changelog: skip
* Upgrade rowanAleksey Kladov2021-03-169-62/+34
| | | | Notably, new rowan comes with support for mutable syntax trees.
* 7709: Added the check for return type of len function.Chetan Khilosiya2021-03-151-9/+26
|
* 7709: Updated the implementation.Chetan Khilosiya2021-03-151-37/+67
| | | | | The get function from impl method is updated. and now same method used to get len and is_empty function.
* 7709: Added the assist to generate is_empty functionChetan Khilosiya2021-03-151-0/+225
| | | | | the assist will be shown when the len function is implemented. is_empty internally uses len function.
* Allow applying De Morgan's law to multiple terms at onceJake Goulding2021-03-121-11/+76
|
* Merge #7956bors[bot]2021-03-121-0/+248
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7956: Add assist to convert for_each into for loops r=Veykril a=SaiintBrisson This PR resolves #7821. Adds an assist to that converts an `Iterator::for_each` into a for loop: ```rust fn main() { let vec = vec![(1, 2), (2, 3), (3, 4)]; x.iter().for_each(|(x, y)| { println!("x: {}, y: {}", x, y); }) } ``` becomes ```rust fn main() { let vec = vec![(1, 2), (2, 3), (3, 4)]; for (x, y) in x.iter() { println!("x: {}, y: {}", x, y); }); } ``` Co-authored-by: Luiz Carlos Mourão Paes de Carvalho <[email protected]> Co-authored-by: Luiz Carlos <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
| * Fix convert_iter_for_each_to_for doctestLukas Wirth2021-03-121-11/+45
| |
| * fix: generated test fixtureLuiz Carlos Mourão Paes de Carvalho2021-03-121-2/+2
| |
| * fix: replace doc-comments with normal commentsLuiz Carlos2021-03-121-20/+20
| | | | | | Co-authored-by: Lukas Wirth <[email protected]>
| * refactor: refactored and reduced assist codeLuiz Carlos Mourão Paes de Carvalho2021-03-121-36/+21
| |
| * fix: remove semicolonLuiz Carlos Mourão Paes de Carvalho2021-03-101-29/+56
| |
| * fix: code formattingLuiz Carlos Mourão Paes de Carvalho2021-03-101-10/+20
| |
| * fix: tests should work for convert_iter_for_each_to_forLuiz Carlos Mourão Paes de Carvalho2021-03-101-11/+44
| |
| * refactor: create block expressions and for loops using makeLuiz Carlos Mourão Paes de Carvalho2021-03-101-29/+50
| |
| * feat: add assist to conver for_each into for loopsLuiz Carlos Mourão Paes de Carvalho2021-03-101-0/+138
| |
* | fix: add semicolon after type ascriptionConrad Ludgate2021-03-111-3/+30
| |
* | Fix labels for single import assistsKirill Bulatov2021-03-102-20/+12
|/
* Merge #7873 #7933bors[bot]2021-03-093-71/+54
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7873: Consider unresolved qualifiers during flyimport r=matklad a=SomeoneToIgnore Closes https://github.com/rust-analyzer/rust-analyzer/issues/7679 Takes unresolved qualifiers into account, providing better completions (or none, if the path is resolved or do not match). Does not handle cases when both path qualifier and some trait has to be imported: there are many extra issues with those (such as overlapping imports, for instance) that will require large diffs to address. Also does not do a fuzzy search on qualifier, that requires some adjustments in `import_map` for better queries and changes to the default replace range which also seems relatively big to include here. ![qualifier_completion](https://user-images.githubusercontent.com/2690773/110040808-0af8dc00-7d4c-11eb-83db-65af94e843bb.gif) 7933: Improve compilation speed r=matklad a=matklad bors r+ 🤖 Co-authored-by: Kirill Bulatov <[email protected]> Co-authored-by: Aleksey Kladov <[email protected]>
| * Add rustdocs and use better namesKirill Bulatov2021-03-082-10/+12
| |
| * Less lifetines: derive SemanticsScope in placeKirill Bulatov2021-03-082-20/+15
| |
| * Enforce the located imports' orderKirill Bulatov2021-03-082-2/+2
| |
| * Work towards better import labelsKirill Bulatov2021-03-083-19/+26
| |
| * Do not propose already imported importsKirill Bulatov2021-03-081-1/+3
| |
| * Properly handle turbofishes in qualifiersKirill Bulatov2021-03-082-2/+2
| |
| * Return more data about located importsKirill Bulatov2021-03-082-9/+18
| |
| * Draft the qualifier import resolutionKirill Bulatov2021-03-081-3/+6
| |
| * Test and initial refactoringKirill Bulatov2021-03-082-37/+2
| |
* | Merge #7898bors[bot]2021-03-081-6/+67
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7898: generate_function assist: infer return type r=JoshMcguigan a=JoshMcguigan This PR makes two changes to the generate function assist: 1. Attempt to infer an appropriate return type for the generated function 2. If a return type is inferred, and that return type is not unit, don't render the snippet ```rust fn main() { let x: u32 = foo$0(); // ^^^ trigger the assist to generate this function } // BEFORE fn foo() ${0:-> ()} { todo!() } // AFTER (only change 1) fn foo() ${0:-> u32} { todo!() } // AFTER (change 1 and 2, note the lack of snippet around the return type) fn foo() -> u32 { todo!() } ``` These changes are made as two commits, in case we want to omit change 2. I personally feel like it is a nice change, but I could understand there being some opposition. #### Pros of change 2 If we are able to infer a return type, and especially if that return type is not the unit type, the return type is almost as likely to be correct as the argument names/types. I think this becomes even more true as people learn how this feature works. #### Cons of change 2 We could never be as confident about the return type as we are about the function argument types, so it is more likely a user will want to change that. Plus it is a confusing UX to sometimes have the cursor highlight the return type after triggering this assist and sometimes not have that happen. #### Why omit unit type? The assumption is that if we infer the return type as unit, it is likely just because of the current structure of the code rather than that actually being the desired return type. However, this is obviously just a heuristic and will sometimes be wrong. But being wrong here just means falling back to the exact behavior that existed before this PR. Co-authored-by: Josh Mcguigan <[email protected]>
| * generate_function assist don't render snippet if ret type inferredJosh Mcguigan2021-03-081-26/+47
| |
| * generate_function assist infer return typeJosh Mcguigan2021-03-061-3/+43
| |
* | Use upstream cov-markLaurențiu Nicola2021-03-0823-150/+109
| |
* | Hygiene is an internal implementation detail of the compilerAleksey Kladov2021-03-082-4/+6
| |
* | Merge #7889bors[bot]2021-03-073-4/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | 7889: Make group imports configurable r=lnicola a=asv1 Co-authored-by: asv <[email protected]>
| * | Make group imports configurableasv2021-03-073-4/+3
| | |
* | | Merge #7896bors[bot]2021-03-061-59/+77
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7896: Only replace quotes in replace_string_with_char assist r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
| * | | Only replace quotes in replace_string_with_char assistLukas Wirth2021-03-061-59/+77
| | | |
* | | | Merge #7800bors[bot]2021-03-061-0/+374
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | 7800: [WIP] 7708: Initial implementation of generate Default assist. r=Veykril a=chetankhilosiya The Generate Default impl from new function. Co-authored-by: Chetan Khilosiya <[email protected]>
| * | | 7708: rust ideomatic code fixes.Chetan Khilosiya2021-03-061-9/+11
| | | |
| * | | 7708: handle both FamousDefs fixture and plain code.Chetan Khilosiya2021-03-061-8/+18
| | | | | | | | | | | | | | | | Also fix typo in example.
| * | | 7708: Added the updated implementation of is_default_implemented.Chetan Khilosiya2021-03-061-33/+31
| | | | | | | | | | | | | | | | The implementation uses hir create to find the implemented trait.
| * | | 7708: Added the logic to check is default impl is already present.Chetan Khilosiya2021-03-061-18/+97
| | | | | | | | | | | | | | | | Also added test cases for code present within module.
| * | | 7708: Updated generate default fn logic.Chetan Khilosiya2021-03-061-22/+48
| | | |
| * | | 7708: Added the work for review comments.Chetan Khilosiya2021-03-061-31/+60
| | | | | | | | | | | | | | | | Also added 1 test case to test multiple struct blocks are present.
| * | | 7708: Fixed many documentaion example issues.Chetan Khilosiya2021-03-061-6/+6
| | | |
| * | | 7708: Format code through rust-analyzer formatter.Chetan Khilosiya2021-03-061-35/+44
| | | |
| * | | 7708: Initial implementation of generate Default assist.Chetan Khilosiya2021-03-061-0/+221
| | |/ | |/| | | | | | | The Generate Default impl from new function.
* | | Merge #7865bors[bot]2021-03-061-1/+37
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | 7865: preserve escape sequences when replacing string with char r=Veykril a=jDomantas Currently it replaces escape sequence with the actual value, which is very wrong for `"\n"`. Co-authored-by: Domantas Jadenkus <[email protected]>