cleanup
This commit is contained in:
parent
7228dbadca
commit
3fde682bcf
@ -39,9 +39,6 @@ pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext) -> Optio
|
|||||||
let module = scope.module()?;
|
let module = scope.module()?;
|
||||||
let type_name = ty.original().display_source_code(ctx.db(), module.into()).ok()?;
|
let type_name = ty.original().display_source_code(ctx.db(), module.into()).ok()?;
|
||||||
let indent = IndentLevel::from_node(statement.syntax());
|
let indent = IndentLevel::from_node(statement.syntax());
|
||||||
if !arg_list.syntax().text_range().contains_range(constant_token.syntax().text_range()) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if constant_token.to_string().chars().any(|it| !(it.is_uppercase() || it == '_')) {
|
if constant_token.to_string().chars().any(|it| !(it.is_uppercase() || it == '_')) {
|
||||||
cov_mark::hit!(not_constant_name);
|
cov_mark::hit!(not_constant_name);
|
||||||
return None;
|
return None;
|
||||||
@ -51,20 +48,14 @@ pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext) -> Optio
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let target = statement.syntax().parent()?.text_range();
|
let target = statement.syntax().parent()?.text_range();
|
||||||
let statement_syntax = statement.syntax().clone_for_update();
|
|
||||||
acc.add(
|
acc.add(
|
||||||
AssistId("generate_constant", AssistKind::QuickFix),
|
AssistId("generate_constant", AssistKind::QuickFix),
|
||||||
"Generate constant",
|
"Generate constant",
|
||||||
target,
|
target,
|
||||||
|builder| {
|
|builder| {
|
||||||
builder.insert(
|
builder.insert(
|
||||||
statement.syntax().text_range.start(),
|
statement.syntax().text_range().start(),
|
||||||
format!(
|
format!("const {}: {} = $0;\n{}", constant_token, type_name, indent),
|
||||||
"const {}: {} = $0;\n{}",
|
|
||||||
constant_token,
|
|
||||||
type_name,
|
|
||||||
indent
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user