}
if let Some(impl_) = impl_parent {
- let node_to_be_removed;
-
// Remove complete impl block if it has only one child (as such it will be empty
// after deleting that child)
- if impl_child_count == 1 {
- node_to_be_removed = impl_.syntax()
+ let node_to_be_removed = if impl_child_count == 1 {
+ impl_.syntax()
} else {
//Remove selected node
- node_to_be_removed = &node;
- }
+ &node
+ };
builder.delete(node_to_be_removed.text_range());
// Remove preceding indentation from node
record_field_parents.into_iter().for_each(|x| {
x.1.descendants().filter_map(ast::RecordField::cast).for_each(|desc| {
- let is_record_field_present = record_fields
- .clone()
- .into_iter()
- .find(|x| x.to_string() == desc.to_string())
- .is_some();
+ let is_record_field_present =
+ record_fields.clone().into_iter().any(|x| x.to_string() == desc.to_string());
if is_record_field_present {
replacements.push((desc.visibility(), desc.syntax().clone()));
}
let mut exists_inside_sel = false;
let mut exists_outside_sel = false;
usage_res.clone().into_iter().for_each(|x| {
- let mut non_use_nodes_itr = (&x.1).into_iter().filter_map(|x| {
+ let mut non_use_nodes_itr = (&x.1).iter().filter_map(|x| {
if find_node_at_range::<ast::Use>(file.syntax(), x.range).is_none() {
let path_opt = find_node_at_range::<ast::Path>(file.syntax(), x.range);
return path_opt;
if non_use_nodes_itr
.clone()
- .find(|x| !selection_range.contains_range(x.syntax().text_range()))
- .is_some()
+ .any(|x| !selection_range.contains_range(x.syntax().text_range()))
{
exists_outside_sel = true;
}
- if non_use_nodes_itr
- .find(|x| selection_range.contains_range(x.syntax().text_range()))
- .is_some()
- {
+ if non_use_nodes_itr.any(|x| selection_range.contains_range(x.syntax().text_range())) {
exists_inside_sel = true;
}
});
let file_id = x.0;
let mut use_opt: Option<ast::Use> = None;
if file_id == curr_file_id {
- (&x.1).into_iter().for_each(|x| {
+ (&x.1).iter().for_each(|x| {
let node_opt: Option<ast::Use> = find_node_at_range(file.syntax(), x.range);
if let Some(node) = node_opt {
use_opt = Some(node);
}
Definition::Function(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =
}
Definition::Adt(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =
}
Definition::Variant(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =
}
Definition::Const(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =
}
Definition::Static(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =
}
Definition::Trait(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =
}
Definition::TypeAlias(x) => {
if let Some(source) = x.source(ctx.db()) {
- let have_same_parent;
- if let Some(ast_module) = &curr_parent_module {
- have_same_parent =
- compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
+ let have_same_parent = if let Some(ast_module) = &curr_parent_module {
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some()
} else {
let source_file_id = source.file_id.original_file(ctx.db());
- have_same_parent = source_file_id == curr_file_id;
- }
+ source_file_id == curr_file_id
+ };
if have_same_parent {
source_exists_outside_sel_in_same_mod =