rust/crates/ide_assists/src/handlers
bors[bot] 7409880a07
Merge #11061
11061: Support "move if to guard" for if else chains r=weirane a=weirane

The idea is to first parse the if else chain into a vector of `(Condition, BlockExpr)`s until we reach an iflet branch, an else branch, or the end (the tail). Then add the match arms with guard for the vector, and add the tail with no if guard.

Because the whole original match arm is replaced and the generated code doesn't have redundent commas, I removed redundent commas in some test cases.

Closes #11033.

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-03 17:59:00 +00:00
..
add_explicit_type.rs Allow adding partially resolved types 2022-01-03 01:34:33 +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 fix: insert whitespaces into assoc items for assist when macro generated 2021-12-13 16:35:32 +01:00
add_missing_match_arms.rs adjust test case and stop deleting newline 2021-11-14 20:56:28 +09:00
add_return_type.rs refactor(assist/add_return_type): avoid threading needs_whitespace 2021-12-02 10:46:07 -08:00
add_turbo_fish.rs Avoid collect_vec from itertools 2022-01-02 12:06:14 +02: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 Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01: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 Fix some clippy lints 2021-12-17 17:46:20 +02:00
convert_integer_literal.rs
convert_into_to_from.rs Fix some clippy lints 2021-12-17 17:46:20 +02:00
convert_iter_for_each_to_for.rs Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01: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 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
convert_while_to_loop.rs fix: defer condition construction 2021-12-04 04:50:06 +09:00
destructure_tuple_binding.rs Avoid collect_vec from itertools 2022-01-02 12:06:14 +02:00
expand_glob_import.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
extract_function.rs Bump deps 2021-12-07 13:15:14 +02:00
extract_module.rs Replace folds with for loops 2022-01-02 12:05:35 +02:00
extract_struct_from_enum_variant.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
extract_type_alias.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
extract_variable.rs fix: fix extract_variable not working on macro_call 2021-10-25 21:46:44 +02:00
fix_visibility.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01: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 minor: fixup generate assist priorities 2021-12-13 16:42:21 +01: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_documentation_template.rs Fix some clippy lints 2021-12-17 17:46:20 +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 Replace folds with for loops 2022-01-02 12:05:35 +02:00
generate_getter.rs Don't say "a reference to" for Copy types 2021-12-19 17:28:31 -08:00
generate_impl.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
generate_is_empty_from_len.rs Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01: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 fix: check inline left of binary_expression 2021-11-21 01:48:04 +09:00
inline_local_variable.rs fix: Fix inline local assist not working in let stmt initializer 2021-12-21 14:03:59 +01: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 Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05: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 Don't add pattern if there is a catch all afterwards 2022-01-03 09:38:45 -08: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
number_representation.rs Fix typo in reformat number assist label 2021-12-21 09:45:20 +02:00
promote_local_to_const.rs Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
pull_assignment_up.rs Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
qualify_method_call.rs apply code review suggestions 2021-10-21 23:42:14 -07:00
qualify_path.rs Fix some clippy lints 2021-12-17 17:46:20 +02:00
raw_string.rs Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
remove_dbg.rs dead code 2021-12-28 19:13:30 +03:00
remove_mut.rs
remove_unused_param.rs internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01: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 Merge #11000 2021-12-13 15:43:12 +00:00
replace_if_let_with_match.rs Fix replace_match_with_if_let removing blocks with modifiers 2022-01-03 14:07:34 +01: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 match_ast! takes a pattern to allow underscore usage 2021-12-14 12:44:31 +01: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 Use array IntoIter 2021-10-22 09:23:29 +03:00
replace_turbofish_with_explicit_type.rs fixup! rustfmt 2021-10-27 10:58:31 -07:00
sort_items.rs Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
split_import.rs Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
toggle_ignore.rs Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
unmerge_use.rs Bump deps 2021-12-07 13:15:14 +02:00
unwrap_block.rs fix unwrap_block by removing double trimming 2021-12-18 23:19:53 +01:00
unwrap_result_return_type.rs fix(assist): delete trailing whitespaces 2021-10-19 14:54:29 +02: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