Fix casing
This commit is contained in:
parent
4cb82c334d
commit
e04661e495
crates/ra_assists/src
assists
add_custom_impl.rsadd_explicit_type.rsadd_missing_impl_members.rsadd_new.rsapply_demorgan.rschange_visibility.rsearly_return.rsfill_match_arms.rsflip_binexpr.rsflip_comma.rsflip_trait_bound.rsinline_local_variable.rsintroduce_variable.rsinvert_if.rsmerge_match_arms.rsmove_bounds.rsmove_guard.rsraw_string.rsreplace_if_let_with_match.rssplit_import.rs
lib.rs@ -50,7 +50,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
|
||||
let start_offset = annotated.syntax().parent()?.text_range().end();
|
||||
|
||||
let label =
|
||||
format!("Add Custom impl '{}' for '{}'", trait_token.text().as_str(), annotated_name);
|
||||
format!("Add custom impl '{}' for '{}'", trait_token.text().as_str(), annotated_name);
|
||||
|
||||
ctx.add_assist(AssistId("add_custom_impl"), label, |edit| {
|
||||
edit.target(attr.syntax().text_range());
|
||||
|
@ -49,7 +49,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx<impl HirDatabase>) -> Option<Assi
|
||||
|
||||
ctx.add_assist(
|
||||
AssistId("add_explicit_type"),
|
||||
format!("Insert Explicit Type '{}'", ty.display(db)),
|
||||
format!("Insert explicit type '{}'", ty.display(db)),
|
||||
|edit| {
|
||||
edit.target(pat_range);
|
||||
edit.insert(name_range.end(), format!(": {}", ty.display(db)));
|
||||
|
@ -48,7 +48,7 @@ pub(crate) fn add_missing_impl_members(ctx: AssistCtx<impl HirDatabase>) -> 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<impl HirDatabase>) -> O
|
||||
ctx,
|
||||
AddMissingImplMembersMode::DefaultMethodsOnly,
|
||||
"add_impl_default_members",
|
||||
"Implement Default Members",
|
||||
"Implement default members",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ pub(crate) fn add_new(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
// 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);
|
||||
|
@ -39,7 +39,7 @@ pub(crate) fn apply_demorgan(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist>
|
||||
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()));
|
||||
|
@ -57,7 +57,7 @@ fn add_vis(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
(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<impl HirDatabase>, 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());
|
||||
|
@ -95,7 +95,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> 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 => {
|
||||
|
@ -57,7 +57,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
|
||||
|
||||
let db = ctx.db;
|
||||
|
||||
ctx.add_assist(AssistId("fill_match_arms"), "Fill Match Arms", |edit| {
|
||||
ctx.add_assist(AssistId("fill_match_arms"), "Fill match arms", |edit| {
|
||||
let indent_level = IndentLevel::from_node(match_arm_list.syntax());
|
||||
|
||||
let new_arm_list = {
|
||||
|
@ -34,7 +34,7 @@ pub(crate) fn flip_binexpr(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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);
|
||||
|
@ -29,7 +29,7 @@ pub(crate) fn flip_comma(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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());
|
||||
|
@ -33,7 +33,7 @@ pub(crate) fn flip_trait_bound(ctx: AssistCtx<impl HirDatabase>) -> Option<Assis
|
||||
non_trivia_sibling(plus.clone().into(), Direction::Next)?,
|
||||
);
|
||||
|
||||
ctx.add_assist(AssistId("flip_trait_bound"), "Flip Trait Bounds", |edit| {
|
||||
ctx.add_assist(AssistId("flip_trait_bound"), "Flip trait bounds", |edit| {
|
||||
edit.target(plus.text_range());
|
||||
edit.replace(before.text_range(), after.to_string());
|
||||
edit.replace(after.text_range(), before.to_string());
|
||||
|
@ -93,7 +93,7 @@ pub(crate) fn inline_local_varialbe(ctx: AssistCtx<impl HirDatabase>) -> 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) {
|
||||
|
@ -43,7 +43,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Ass
|
||||
if indent.kind() != WHITESPACE {
|
||||
return None;
|
||||
}
|
||||
ctx.add_assist(AssistId("introduce_variable"), "Extract into Variable", move |edit| {
|
||||
ctx.add_assist(AssistId("introduce_variable"), "Extract into variable", move |edit| {
|
||||
let mut buf = String::new();
|
||||
|
||||
let cursor_offset = if wrap_in_block {
|
||||
|
@ -41,7 +41,7 @@ pub(crate) fn invert_if(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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());
|
||||
|
@ -52,7 +52,7 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assis
|
||||
|
||||
let cursor_to_end = current_arm.syntax().text_range().end() - ctx.frange.range.start();
|
||||
|
||||
ctx.add_assist(AssistId("merge_match_arms"), "Merge Match Arms", |edit| {
|
||||
ctx.add_assist(AssistId("merge_match_arms"), "Merge match arms", |edit| {
|
||||
fn contains_placeholder(a: &MatchArm) -> bool {
|
||||
a.pats().any(|x| match x {
|
||||
ra_syntax::ast::Pat::PlaceholderPat(..) => true,
|
||||
|
@ -46,7 +46,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx<impl HirDatabase>) -> 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())
|
||||
|
@ -41,7 +41,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx<impl HirDatabase>) -> 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<impl HirDatabase>) ->
|
||||
|
||||
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();
|
||||
|
@ -25,7 +25,7 @@ use crate::{Assist, AssistCtx, AssistId};
|
||||
pub(crate) fn make_raw_string(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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<impl HirDatabase>) -> Option<Assist
|
||||
pub(crate) fn make_usual_string(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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<impl HirDatabase>) -> Option<Assi
|
||||
// ```
|
||||
pub(crate) fn add_hash(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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<impl HirDatabase>) -> Option<Assist> {
|
||||
// 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('\"') {
|
||||
|
@ -42,7 +42,7 @@ pub(crate) fn replace_if_let_with_match(ctx: AssistCtx<impl HirDatabase>) -> 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);
|
||||
|
@ -32,7 +32,7 @@ pub(crate) fn split_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
|
||||
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, "}");
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user