From 4cb82c334d98d7eb608d076fda95923647d61043 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Tue, 14 Jan 2020 11:49:14 -0500 Subject: More UI friendly labels --- crates/ra_assists/src/assists/add_derive.rs | 2 +- crates/ra_assists/src/assists/add_explicit_type.rs | 12 ++++++++---- crates/ra_assists/src/assists/add_impl.rs | 2 +- crates/ra_assists/src/assists/add_import.rs | 2 +- .../ra_assists/src/assists/add_missing_impl_members.rs | 4 ++-- crates/ra_assists/src/assists/add_new.rs | 2 +- crates/ra_assists/src/assists/apply_demorgan.rs | 2 +- crates/ra_assists/src/assists/change_visibility.rs | 18 +++++++++++------- crates/ra_assists/src/assists/early_return.rs | 2 +- crates/ra_assists/src/assists/fill_match_arms.rs | 2 +- crates/ra_assists/src/assists/flip_binexpr.rs | 2 +- crates/ra_assists/src/assists/flip_comma.rs | 2 +- crates/ra_assists/src/assists/flip_trait_bound.rs | 2 +- crates/ra_assists/src/assists/inline_local_variable.rs | 2 +- crates/ra_assists/src/assists/introduce_variable.rs | 2 +- crates/ra_assists/src/assists/invert_if.rs | 2 +- crates/ra_assists/src/assists/merge_match_arms.rs | 2 +- crates/ra_assists/src/assists/move_bounds.rs | 2 +- crates/ra_assists/src/assists/move_guard.rs | 2 +- crates/ra_assists/src/assists/raw_string.rs | 6 +++--- crates/ra_assists/src/assists/remove_dbg.rs | 2 +- .../src/assists/replace_if_let_with_match.rs | 2 +- crates/ra_assists/src/assists/split_import.rs | 2 +- 23 files changed, 43 insertions(+), 35 deletions(-) diff --git a/crates/ra_assists/src/assists/add_derive.rs b/crates/ra_assists/src/assists/add_derive.rs index 764b17bd8..6d9af3905 100644 --- a/crates/ra_assists/src/assists/add_derive.rs +++ b/crates/ra_assists/src/assists/add_derive.rs @@ -28,7 +28,7 @@ use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn add_derive(ctx: AssistCtx) -> Option { let nominal = ctx.find_node_at_offset::()?; let node_start = derive_insertion_offset(&nominal)?; - ctx.add_assist(AssistId("add_derive"), "add `#[derive]`", |edit| { + ctx.add_assist(AssistId("add_derive"), "Add `#[derive]`", |edit| { let derive_attr = nominal .attrs() .filter_map(|x| x.as_simple_call()) diff --git a/crates/ra_assists/src/assists/add_explicit_type.rs b/crates/ra_assists/src/assists/add_explicit_type.rs index 2c602a79e..b63ca50d0 100644 --- a/crates/ra_assists/src/assists/add_explicit_type.rs +++ b/crates/ra_assists/src/assists/add_explicit_type.rs @@ -47,10 +47,14 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option) -> Option { let nominal = ctx.find_node_at_offset::()?; let name = nominal.name()?; - ctx.add_assist(AssistId("add_impl"), "add impl", |edit| { + ctx.add_assist(AssistId("add_impl"), format!("Implement {}", name.text().as_str()), |edit| { edit.target(nominal.syntax().text_range()); let type_params = nominal.type_param_list(); let start_offset = nominal.syntax().text_range().end(); diff --git a/crates/ra_assists/src/assists/add_import.rs b/crates/ra_assists/src/assists/add_import.rs index b8752cbad..bf6cfe865 100644 --- a/crates/ra_assists/src/assists/add_import.rs +++ b/crates/ra_assists/src/assists/add_import.rs @@ -72,7 +72,7 @@ pub(crate) fn add_import(ctx: AssistCtx) -> Option { } }; - ctx.add_assist(AssistId("add_import"), format!("import {}", fmt_segments(&segments)), |edit| { + ctx.add_assist(AssistId("add_import"), format!("Import {}", fmt_segments(&segments)), |edit| { apply_auto_import(&position, &path, &segments, edit.text_edit_builder()); }) } diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs index bf1136193..89a1d58b8 100644 --- a/crates/ra_assists/src/assists/add_missing_impl_members.rs +++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs @@ -48,7 +48,7 @@ pub(crate) fn add_missing_impl_members(ctx: AssistCtx) -> Opti ctx, AddMissingImplMembersMode::NoDefaultMethods, "add_impl_missing_members", - "add missing impl members", + "Implement Missing Members", ) } @@ -89,7 +89,7 @@ pub(crate) fn add_missing_default_members(ctx: AssistCtx) -> O ctx, AddMissingImplMembersMode::DefaultMethodsOnly, "add_impl_default_members", - "add impl default members", + "Implement Default Members", ) } diff --git a/crates/ra_assists/src/assists/add_new.rs b/crates/ra_assists/src/assists/add_new.rs index b2f946fac..9102c2325 100644 --- a/crates/ra_assists/src/assists/add_new.rs +++ b/crates/ra_assists/src/assists/add_new.rs @@ -43,7 +43,7 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { // Return early if we've found an existing new fn let impl_block = find_struct_impl(&ctx, &strukt)?; - ctx.add_assist(AssistId("add_new"), "add new fn", |edit| { + ctx.add_assist(AssistId("add_new"), "Add Default Constructor", |edit| { edit.target(strukt.syntax().text_range()); let mut buf = String::with_capacity(512); diff --git a/crates/ra_assists/src/assists/apply_demorgan.rs b/crates/ra_assists/src/assists/apply_demorgan.rs index 7c57c0560..95585d831 100644 --- a/crates/ra_assists/src/assists/apply_demorgan.rs +++ b/crates/ra_assists/src/assists/apply_demorgan.rs @@ -39,7 +39,7 @@ pub(crate) fn apply_demorgan(ctx: AssistCtx) -> Option let not_lhs = invert_boolean_expression(&lhs)?; let not_rhs = invert_boolean_expression(&rhs)?; - ctx.add_assist(AssistId("apply_demorgan"), "apply demorgan's law", |edit| { + ctx.add_assist(AssistId("apply_demorgan"), "Apply Demorgan's Law", |edit| { edit.target(op_range); edit.replace(op_range, opposite_op); edit.replace(lhs_range, format!("!({}", not_lhs.syntax().text())); diff --git a/crates/ra_assists/src/assists/change_visibility.rs b/crates/ra_assists/src/assists/change_visibility.rs index 132c9dc1d..a51277040 100644 --- a/crates/ra_assists/src/assists/change_visibility.rs +++ b/crates/ra_assists/src/assists/change_visibility.rs @@ -57,7 +57,7 @@ fn add_vis(ctx: AssistCtx) -> Option { (vis_offset(field.syntax()), ident.text_range()) }; - ctx.add_assist(AssistId("change_visibility"), "make pub(crate)", |edit| { + ctx.add_assist(AssistId("change_visibility"), "Change Visibility to pub(crate)", |edit| { edit.target(target); edit.insert(offset, "pub(crate) "); edit.set_cursor(offset); @@ -77,14 +77,18 @@ fn vis_offset(node: &SyntaxNode) -> TextUnit { fn change_vis(ctx: AssistCtx, vis: ast::Visibility) -> Option { if vis.syntax().text() == "pub" { - return ctx.add_assist(AssistId("change_visibility"), "change to pub(crate)", |edit| { - edit.target(vis.syntax().text_range()); - edit.replace(vis.syntax().text_range(), "pub(crate)"); - edit.set_cursor(vis.syntax().text_range().start()) - }); + return ctx.add_assist( + AssistId("change_visibility"), + "Change Visibility to pub(crate)", + |edit| { + edit.target(vis.syntax().text_range()); + edit.replace(vis.syntax().text_range(), "pub(crate)"); + edit.set_cursor(vis.syntax().text_range().start()) + }, + ); } if vis.syntax().text() == "pub(crate)" { - return ctx.add_assist(AssistId("change_visibility"), "change to pub", |edit| { + return ctx.add_assist(AssistId("change_visibility"), "Change Visibility to pub", |edit| { edit.target(vis.syntax().text_range()); edit.replace(vis.syntax().text_range(), "pub"); edit.set_cursor(vis.syntax().text_range().start()); diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index 023917aca..6b6319959 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs @@ -95,7 +95,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Opt then_block.syntax().last_child_or_token().filter(|t| t.kind() == R_CURLY)?; let cursor_position = ctx.frange.range.start(); - ctx.add_assist(AssistId("convert_to_guarded_return"), "convert to guarded return", |edit| { + ctx.add_assist(AssistId("convert_to_guarded_return"), "Convert to Guarded Return", |edit| { let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); let new_block = match if_let_pat { None => { diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs index 99d80998c..90ddfc3d0 100644 --- a/crates/ra_assists/src/assists/fill_match_arms.rs +++ b/crates/ra_assists/src/assists/fill_match_arms.rs @@ -57,7 +57,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx) -> Option) -> Option { return None; } - ctx.add_assist(AssistId("flip_binexpr"), "flip binary expression", |edit| { + ctx.add_assist(AssistId("flip_binexpr"), "Flip Binary Expression", |edit| { edit.target(op_range); if let FlipAction::FlipAndReplaceOp(new_op) = action { edit.replace(op_range, new_op); diff --git a/crates/ra_assists/src/assists/flip_comma.rs b/crates/ra_assists/src/assists/flip_comma.rs index 9be1c1dc6..b274681b3 100644 --- a/crates/ra_assists/src/assists/flip_comma.rs +++ b/crates/ra_assists/src/assists/flip_comma.rs @@ -29,7 +29,7 @@ pub(crate) fn flip_comma(ctx: AssistCtx) -> Option { return None; } - ctx.add_assist(AssistId("flip_comma"), "flip comma", |edit| { + ctx.add_assist(AssistId("flip_comma"), "Flip Comma", |edit| { edit.target(comma.text_range()); edit.replace(prev.text_range(), next.to_string()); edit.replace(next.text_range(), prev.to_string()); diff --git a/crates/ra_assists/src/assists/flip_trait_bound.rs b/crates/ra_assists/src/assists/flip_trait_bound.rs index 6017b39dd..b691c9509 100644 --- a/crates/ra_assists/src/assists/flip_trait_bound.rs +++ b/crates/ra_assists/src/assists/flip_trait_bound.rs @@ -33,7 +33,7 @@ pub(crate) fn flip_trait_bound(ctx: AssistCtx) -> Option) -> Option< ctx.add_assist( AssistId("inline_local_variable"), - "inline local variable", + "Inline Variable", move |edit: &mut AssistBuilder| { edit.delete(delete_range); for (desc, should_wrap) in refs.iter().zip(wrap_in_parens) { diff --git a/crates/ra_assists/src/assists/introduce_variable.rs b/crates/ra_assists/src/assists/introduce_variable.rs index 0623d4475..7ac79d910 100644 --- a/crates/ra_assists/src/assists/introduce_variable.rs +++ b/crates/ra_assists/src/assists/introduce_variable.rs @@ -43,7 +43,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option) -> Option { let else_node = else_block.syntax(); let else_range = else_node.text_range(); let then_range = then_node.text_range(); - return ctx.add_assist(AssistId("invert_if"), "invert if branches", |edit| { + return ctx.add_assist(AssistId("invert_if"), "Invert If", |edit| { edit.target(if_range); edit.replace(cond_range, flip_cond.syntax().text()); edit.replace(else_range, then_node.text()); diff --git a/crates/ra_assists/src/assists/merge_match_arms.rs b/crates/ra_assists/src/assists/merge_match_arms.rs index e9f2cae91..6406e1feb 100644 --- a/crates/ra_assists/src/assists/merge_match_arms.rs +++ b/crates/ra_assists/src/assists/merge_match_arms.rs @@ -52,7 +52,7 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option bool { a.pats().any(|x| match x { ra_syntax::ast::Pat::PlaceholderPat(..) => true, diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs index 3145d7625..6e6c1d67d 100644 --- a/crates/ra_assists/src/assists/move_bounds.rs +++ b/crates/ra_assists/src/assists/move_bounds.rs @@ -46,7 +46,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> O _ => return None, }; - ctx.add_assist(AssistId("move_bounds_to_where_clause"), "move_bounds_to_where_clause", |edit| { + ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to Where Clause", |edit| { let new_params = type_param_list .type_params() .filter(|it| it.type_bound_list().is_some()) diff --git a/crates/ra_assists/src/assists/move_guard.rs b/crates/ra_assists/src/assists/move_guard.rs index b49ec6172..59ba9e3f3 100644 --- a/crates/ra_assists/src/assists/move_guard.rs +++ b/crates/ra_assists/src/assists/move_guard.rs @@ -41,7 +41,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option let arm_expr = match_arm.expr()?; let buf = format!("if {} {{ {} }}", guard_conditions.syntax().text(), arm_expr.syntax().text()); - ctx.add_assist(AssistId("move_guard_to_arm_body"), "move guard to arm body", |edit| { + ctx.add_assist(AssistId("move_guard_to_arm_body"), "Move Guard to Arm Body", |edit| { edit.target(guard.syntax().text_range()); let offseting_amount = match space_before_guard.and_then(|it| it.into_token()) { Some(tok) => { diff --git a/crates/ra_assists/src/assists/raw_string.rs b/crates/ra_assists/src/assists/raw_string.rs index 93912a470..3583b636a 100644 --- a/crates/ra_assists/src/assists/raw_string.rs +++ b/crates/ra_assists/src/assists/raw_string.rs @@ -25,7 +25,7 @@ use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn make_raw_string(ctx: AssistCtx) -> Option { let token = ctx.find_token_at_offset(STRING).and_then(ast::String::cast)?; let value = token.value()?; - ctx.add_assist(AssistId("make_raw_string"), "make raw string", |edit| { + ctx.add_assist(AssistId("make_raw_string"), "Rewrite as Raw String", |edit| { edit.target(token.syntax().text_range()); let max_hash_streak = count_hashes(&value); let mut hashes = String::with_capacity(max_hash_streak + 1); @@ -54,7 +54,7 @@ pub(crate) fn make_raw_string(ctx: AssistCtx) -> Option) -> Option { let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?; let value = token.value()?; - ctx.add_assist(AssistId("make_usual_string"), "make usual string", |edit| { + ctx.add_assist(AssistId("make_usual_string"), "Rewrite as Regular String", |edit| { edit.target(token.syntax().text_range()); // parse inside string to escape `"` let escaped = value.escape_default().to_string(); @@ -79,7 +79,7 @@ pub(crate) fn make_usual_string(ctx: AssistCtx) -> Option) -> Option { let token = ctx.find_token_at_offset(RAW_STRING)?; - ctx.add_assist(AssistId("add_hash"), "add hash to raw string", |edit| { + ctx.add_assist(AssistId("add_hash"), "Add # to Raw String", |edit| { edit.target(token.text_range()); edit.insert(token.text_range().start() + TextUnit::of_char('r'), "#"); edit.insert(token.text_range().end(), "#"); diff --git a/crates/ra_assists/src/assists/remove_dbg.rs b/crates/ra_assists/src/assists/remove_dbg.rs index aedf8747f..cf211ab84 100644 --- a/crates/ra_assists/src/assists/remove_dbg.rs +++ b/crates/ra_assists/src/assists/remove_dbg.rs @@ -58,7 +58,7 @@ pub(crate) fn remove_dbg(ctx: AssistCtx) -> Option { text.slice(without_parens).to_string() }; - ctx.add_assist(AssistId("remove_dbg"), "remove dbg!()", |edit| { + ctx.add_assist(AssistId("remove_dbg"), "Remove dbg!()", |edit| { edit.target(macro_call.syntax().text_range()); edit.replace(macro_range, macro_content); edit.set_cursor(cursor_pos); diff --git a/crates/ra_assists/src/assists/replace_if_let_with_match.rs b/crates/ra_assists/src/assists/replace_if_let_with_match.rs index 3272801ff..dacbf8758 100644 --- a/crates/ra_assists/src/assists/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/assists/replace_if_let_with_match.rs @@ -42,7 +42,7 @@ pub(crate) fn replace_if_let_with_match(ctx: AssistCtx) -> Opt ast::ElseBranch::IfExpr(_) => return None, }; - ctx.add_assist(AssistId("replace_if_let_with_match"), "replace with match", |edit| { + ctx.add_assist(AssistId("replace_if_let_with_match"), "Replace with Match", |edit| { let match_expr = build_match_expr(expr, pat, then_block, else_block); edit.target(if_expr.syntax().text_range()); edit.replace_node_and_indent(if_expr.syntax(), match_expr); diff --git a/crates/ra_assists/src/assists/split_import.rs b/crates/ra_assists/src/assists/split_import.rs index 5f8d6b0be..d36df069a 100644 --- a/crates/ra_assists/src/assists/split_import.rs +++ b/crates/ra_assists/src/assists/split_import.rs @@ -32,7 +32,7 @@ pub(crate) fn split_import(ctx: AssistCtx) -> Option { None => top_path.syntax().text_range().end(), }; - ctx.add_assist(AssistId("split_import"), "split import", |edit| { + ctx.add_assist(AssistId("split_import"), "Split Import", |edit| { edit.target(colon_colon.text_range()); edit.insert(l_curly, "{"); edit.insert(r_curly, "}"); -- cgit v1.2.3 From e04661e495cde89827d768788f123eafdbd43911 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Tue, 14 Jan 2020 12:32:26 -0500 Subject: Fix casing --- crates/ra_assists/src/assists/add_custom_impl.rs | 2 +- crates/ra_assists/src/assists/add_explicit_type.rs | 2 +- crates/ra_assists/src/assists/add_missing_impl_members.rs | 4 ++-- crates/ra_assists/src/assists/add_new.rs | 2 +- crates/ra_assists/src/assists/apply_demorgan.rs | 2 +- crates/ra_assists/src/assists/change_visibility.rs | 4 ++-- crates/ra_assists/src/assists/early_return.rs | 2 +- crates/ra_assists/src/assists/fill_match_arms.rs | 2 +- crates/ra_assists/src/assists/flip_binexpr.rs | 2 +- crates/ra_assists/src/assists/flip_comma.rs | 2 +- crates/ra_assists/src/assists/flip_trait_bound.rs | 2 +- crates/ra_assists/src/assists/inline_local_variable.rs | 2 +- crates/ra_assists/src/assists/introduce_variable.rs | 2 +- crates/ra_assists/src/assists/invert_if.rs | 2 +- crates/ra_assists/src/assists/merge_match_arms.rs | 2 +- crates/ra_assists/src/assists/move_bounds.rs | 2 +- crates/ra_assists/src/assists/move_guard.rs | 4 ++-- crates/ra_assists/src/assists/raw_string.rs | 8 ++++---- crates/ra_assists/src/assists/replace_if_let_with_match.rs | 2 +- crates/ra_assists/src/assists/split_import.rs | 2 +- crates/ra_assists/src/lib.rs | 11 +++++++---- 21 files changed, 33 insertions(+), 30 deletions(-) diff --git a/crates/ra_assists/src/assists/add_custom_impl.rs b/crates/ra_assists/src/assists/add_custom_impl.rs index 52e8c693d..f91034967 100644 --- a/crates/ra_assists/src/assists/add_custom_impl.rs +++ b/crates/ra_assists/src/assists/add_custom_impl.rs @@ -50,7 +50,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option) -> Option) -> Opti ctx, AddMissingImplMembersMode::NoDefaultMethods, "add_impl_missing_members", - "Implement Missing Members", + "Implement missing members", ) } @@ -89,7 +89,7 @@ pub(crate) fn add_missing_default_members(ctx: AssistCtx) -> O ctx, AddMissingImplMembersMode::DefaultMethodsOnly, "add_impl_default_members", - "Implement Default Members", + "Implement default members", ) } diff --git a/crates/ra_assists/src/assists/add_new.rs b/crates/ra_assists/src/assists/add_new.rs index 9102c2325..d148d6e73 100644 --- a/crates/ra_assists/src/assists/add_new.rs +++ b/crates/ra_assists/src/assists/add_new.rs @@ -43,7 +43,7 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { // Return early if we've found an existing new fn let impl_block = find_struct_impl(&ctx, &strukt)?; - ctx.add_assist(AssistId("add_new"), "Add Default Constructor", |edit| { + ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| { edit.target(strukt.syntax().text_range()); let mut buf = String::with_capacity(512); diff --git a/crates/ra_assists/src/assists/apply_demorgan.rs b/crates/ra_assists/src/assists/apply_demorgan.rs index 95585d831..666dce4e6 100644 --- a/crates/ra_assists/src/assists/apply_demorgan.rs +++ b/crates/ra_assists/src/assists/apply_demorgan.rs @@ -39,7 +39,7 @@ pub(crate) fn apply_demorgan(ctx: AssistCtx) -> Option let not_lhs = invert_boolean_expression(&lhs)?; let not_rhs = invert_boolean_expression(&rhs)?; - ctx.add_assist(AssistId("apply_demorgan"), "Apply Demorgan's Law", |edit| { + ctx.add_assist(AssistId("apply_demorgan"), "Apply De Morgan's law", |edit| { edit.target(op_range); edit.replace(op_range, opposite_op); edit.replace(lhs_range, format!("!({}", not_lhs.syntax().text())); diff --git a/crates/ra_assists/src/assists/change_visibility.rs b/crates/ra_assists/src/assists/change_visibility.rs index a51277040..fd766bb46 100644 --- a/crates/ra_assists/src/assists/change_visibility.rs +++ b/crates/ra_assists/src/assists/change_visibility.rs @@ -57,7 +57,7 @@ fn add_vis(ctx: AssistCtx) -> Option { (vis_offset(field.syntax()), ident.text_range()) }; - ctx.add_assist(AssistId("change_visibility"), "Change Visibility to pub(crate)", |edit| { + ctx.add_assist(AssistId("change_visibility"), "Change visibility to pub(crate)", |edit| { edit.target(target); edit.insert(offset, "pub(crate) "); edit.set_cursor(offset); @@ -88,7 +88,7 @@ fn change_vis(ctx: AssistCtx, vis: ast::Visibility) -> Option< ); } if vis.syntax().text() == "pub(crate)" { - return ctx.add_assist(AssistId("change_visibility"), "Change Visibility to pub", |edit| { + return ctx.add_assist(AssistId("change_visibility"), "Change visibility to pub", |edit| { edit.target(vis.syntax().text_range()); edit.replace(vis.syntax().text_range(), "pub"); edit.set_cursor(vis.syntax().text_range().start()); diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index 6b6319959..487ee9eef 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs @@ -95,7 +95,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Opt then_block.syntax().last_child_or_token().filter(|t| t.kind() == R_CURLY)?; let cursor_position = ctx.frange.range.start(); - ctx.add_assist(AssistId("convert_to_guarded_return"), "Convert to Guarded Return", |edit| { + ctx.add_assist(AssistId("convert_to_guarded_return"), "Convert to guarded return", |edit| { let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); let new_block = match if_let_pat { None => { diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs index 90ddfc3d0..01758d23a 100644 --- a/crates/ra_assists/src/assists/fill_match_arms.rs +++ b/crates/ra_assists/src/assists/fill_match_arms.rs @@ -57,7 +57,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx) -> Option) -> Option { return None; } - ctx.add_assist(AssistId("flip_binexpr"), "Flip Binary Expression", |edit| { + ctx.add_assist(AssistId("flip_binexpr"), "Flip binary expression", |edit| { edit.target(op_range); if let FlipAction::FlipAndReplaceOp(new_op) = action { edit.replace(op_range, new_op); diff --git a/crates/ra_assists/src/assists/flip_comma.rs b/crates/ra_assists/src/assists/flip_comma.rs index b274681b3..dd0c405ed 100644 --- a/crates/ra_assists/src/assists/flip_comma.rs +++ b/crates/ra_assists/src/assists/flip_comma.rs @@ -29,7 +29,7 @@ pub(crate) fn flip_comma(ctx: AssistCtx) -> Option { return None; } - ctx.add_assist(AssistId("flip_comma"), "Flip Comma", |edit| { + ctx.add_assist(AssistId("flip_comma"), "Flip comma", |edit| { edit.target(comma.text_range()); edit.replace(prev.text_range(), next.to_string()); edit.replace(next.text_range(), prev.to_string()); diff --git a/crates/ra_assists/src/assists/flip_trait_bound.rs b/crates/ra_assists/src/assists/flip_trait_bound.rs index b691c9509..50b3fa492 100644 --- a/crates/ra_assists/src/assists/flip_trait_bound.rs +++ b/crates/ra_assists/src/assists/flip_trait_bound.rs @@ -33,7 +33,7 @@ pub(crate) fn flip_trait_bound(ctx: AssistCtx) -> Option) -> Option< ctx.add_assist( AssistId("inline_local_variable"), - "Inline Variable", + "Inline variable", move |edit: &mut AssistBuilder| { edit.delete(delete_range); for (desc, should_wrap) in refs.iter().zip(wrap_in_parens) { diff --git a/crates/ra_assists/src/assists/introduce_variable.rs b/crates/ra_assists/src/assists/introduce_variable.rs index 7ac79d910..19e211e0f 100644 --- a/crates/ra_assists/src/assists/introduce_variable.rs +++ b/crates/ra_assists/src/assists/introduce_variable.rs @@ -43,7 +43,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option) -> Option { let else_node = else_block.syntax(); let else_range = else_node.text_range(); let then_range = then_node.text_range(); - return ctx.add_assist(AssistId("invert_if"), "Invert If", |edit| { + return ctx.add_assist(AssistId("invert_if"), "Invert if", |edit| { edit.target(if_range); edit.replace(cond_range, flip_cond.syntax().text()); edit.replace(else_range, then_node.text()); diff --git a/crates/ra_assists/src/assists/merge_match_arms.rs b/crates/ra_assists/src/assists/merge_match_arms.rs index 6406e1feb..aca391155 100644 --- a/crates/ra_assists/src/assists/merge_match_arms.rs +++ b/crates/ra_assists/src/assists/merge_match_arms.rs @@ -52,7 +52,7 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option bool { a.pats().any(|x| match x { ra_syntax::ast::Pat::PlaceholderPat(..) => true, diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs index 6e6c1d67d..355adddc3 100644 --- a/crates/ra_assists/src/assists/move_bounds.rs +++ b/crates/ra_assists/src/assists/move_bounds.rs @@ -46,7 +46,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> O _ => return None, }; - ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to Where Clause", |edit| { + ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to where clause", |edit| { let new_params = type_param_list .type_params() .filter(|it| it.type_bound_list().is_some()) diff --git a/crates/ra_assists/src/assists/move_guard.rs b/crates/ra_assists/src/assists/move_guard.rs index 59ba9e3f3..41a31e677 100644 --- a/crates/ra_assists/src/assists/move_guard.rs +++ b/crates/ra_assists/src/assists/move_guard.rs @@ -41,7 +41,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option let arm_expr = match_arm.expr()?; let buf = format!("if {} {{ {} }}", guard_conditions.syntax().text(), arm_expr.syntax().text()); - ctx.add_assist(AssistId("move_guard_to_arm_body"), "Move Guard to Arm Body", |edit| { + ctx.add_assist(AssistId("move_guard_to_arm_body"), "Move guard to arm body", |edit| { edit.target(guard.syntax().text_range()); let offseting_amount = match space_before_guard.and_then(|it| it.into_token()) { Some(tok) => { @@ -111,7 +111,7 @@ pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx) -> ctx.add_assist( AssistId("move_arm_cond_to_match_guard"), - "move condition to match guard", + "Move condition to match guard", |edit| { edit.target(if_expr.syntax().text_range()); let then_only_expr = then_block.block().and_then(|it| it.statements().next()).is_none(); diff --git a/crates/ra_assists/src/assists/raw_string.rs b/crates/ra_assists/src/assists/raw_string.rs index 3583b636a..e79c51673 100644 --- a/crates/ra_assists/src/assists/raw_string.rs +++ b/crates/ra_assists/src/assists/raw_string.rs @@ -25,7 +25,7 @@ use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn make_raw_string(ctx: AssistCtx) -> Option { let token = ctx.find_token_at_offset(STRING).and_then(ast::String::cast)?; let value = token.value()?; - ctx.add_assist(AssistId("make_raw_string"), "Rewrite as Raw String", |edit| { + ctx.add_assist(AssistId("make_raw_string"), "Rewrite as raw string", |edit| { edit.target(token.syntax().text_range()); let max_hash_streak = count_hashes(&value); let mut hashes = String::with_capacity(max_hash_streak + 1); @@ -54,7 +54,7 @@ pub(crate) fn make_raw_string(ctx: AssistCtx) -> Option) -> Option { let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?; let value = token.value()?; - ctx.add_assist(AssistId("make_usual_string"), "Rewrite as Regular String", |edit| { + ctx.add_assist(AssistId("make_usual_string"), "Rewrite as regular string", |edit| { edit.target(token.syntax().text_range()); // parse inside string to escape `"` let escaped = value.escape_default().to_string(); @@ -79,7 +79,7 @@ pub(crate) fn make_usual_string(ctx: AssistCtx) -> Option) -> Option { let token = ctx.find_token_at_offset(RAW_STRING)?; - ctx.add_assist(AssistId("add_hash"), "Add # to Raw String", |edit| { + ctx.add_assist(AssistId("add_hash"), "Add # to raw string", |edit| { edit.target(token.text_range()); edit.insert(token.text_range().start() + TextUnit::of_char('r'), "#"); edit.insert(token.text_range().end(), "#"); @@ -108,7 +108,7 @@ pub(crate) fn remove_hash(ctx: AssistCtx) -> Option { // no hash to remove return None; } - ctx.add_assist(AssistId("remove_hash"), "remove hash from raw string", |edit| { + ctx.add_assist(AssistId("remove_hash"), "Remove hash from raw string", |edit| { edit.target(token.text_range()); let result = &text[2..text.len() - 1]; let result = if result.starts_with('\"') { diff --git a/crates/ra_assists/src/assists/replace_if_let_with_match.rs b/crates/ra_assists/src/assists/replace_if_let_with_match.rs index dacbf8758..c9b62e5ff 100644 --- a/crates/ra_assists/src/assists/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/assists/replace_if_let_with_match.rs @@ -42,7 +42,7 @@ pub(crate) fn replace_if_let_with_match(ctx: AssistCtx) -> Opt ast::ElseBranch::IfExpr(_) => return None, }; - ctx.add_assist(AssistId("replace_if_let_with_match"), "Replace with Match", |edit| { + ctx.add_assist(AssistId("replace_if_let_with_match"), "Replace with match", |edit| { let match_expr = build_match_expr(expr, pat, then_block, else_block); edit.target(if_expr.syntax().text_range()); edit.replace_node_and_indent(if_expr.syntax(), match_expr); diff --git a/crates/ra_assists/src/assists/split_import.rs b/crates/ra_assists/src/assists/split_import.rs index d36df069a..6038c4858 100644 --- a/crates/ra_assists/src/assists/split_import.rs +++ b/crates/ra_assists/src/assists/split_import.rs @@ -32,7 +32,7 @@ pub(crate) fn split_import(ctx: AssistCtx) -> Option { None => top_path.syntax().text_range().end(), }; - ctx.add_assist(AssistId("split_import"), "Split Import", |edit| { + ctx.add_assist(AssistId("split_import"), "Split import", |edit| { edit.target(colon_colon.text_range()); edit.insert(l_curly, "{"); edit.insert(r_curly, "}"); diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 712ff6f6a..150b34ac7 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -292,8 +292,11 @@ mod tests { let assists = super::assists(&db, frange); let mut assists = assists.iter(); - assert_eq!(assists.next().expect("expected assist").0.label, "make pub(crate)"); - assert_eq!(assists.next().expect("expected assist").0.label, "add `#[derive]`"); + assert_eq!( + assists.next().expect("expected assist").0.label, + "Change visibility to pub(crate)" + ); + assert_eq!(assists.next().expect("expected assist").0.label, "Add `#[derive]`"); } #[test] @@ -312,7 +315,7 @@ mod tests { let assists = super::assists(&db, frange); let mut assists = assists.iter(); - assert_eq!(assists.next().expect("expected assist").0.label, "introduce variable"); - assert_eq!(assists.next().expect("expected assist").0.label, "replace with match"); + assert_eq!(assists.next().expect("expected assist").0.label, "Extract into variable"); + assert_eq!(assists.next().expect("expected assist").0.label, "Replace with match"); } } -- cgit v1.2.3 From 9042bb7892db6b41ef09952e35cbd167c1a2d924 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Tue, 14 Jan 2020 12:32:39 -0500 Subject: Assert that first letter is capitalized --- crates/ra_assists/src/assist_ctx.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index 28152f724..dc3ab440b 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs @@ -84,6 +84,12 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> { f: impl FnOnce(&mut AssistBuilder), ) -> Option { let label = AssistLabel { label: label.into(), id }; + assert_eq!( + label.label.chars().nth(0).and_then(|c| Some(c.is_uppercase())), + Some(true), + "First character should be uppercase" + ); + let assist = if self.should_compute_edit { let action = { let mut edit = AssistBuilder::default(); -- cgit v1.2.3 From 864434137a3ed17f2a96981780bf7d522e57fd4b Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Tue, 14 Jan 2020 13:15:41 -0500 Subject: unwrap --- crates/ra_assists/src/assist_ctx.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index dc3ab440b..1b626faaa 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs @@ -85,8 +85,8 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> { ) -> Option { let label = AssistLabel { label: label.into(), id }; assert_eq!( - label.label.chars().nth(0).and_then(|c| Some(c.is_uppercase())), - Some(true), + label.label.chars().nth(0).and_then(|c| Some(c.is_uppercase())).unwrap(), + true, "First character should be uppercase" ); -- cgit v1.2.3