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(-) (limited to 'crates/ra_assists/src/assists') 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