Skip to content

Commit 44bdfdf

Browse files
authored
Merge pull request #20412 from Hmikihiro/fix_generate_function_generate_by_indent_token
fix: generate function by indet token
2 parents 5248c89 + cfd4103 commit 44bdfdf

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

crates/ide-assists/src/handlers/generate_function.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl FunctionBuilder {
316316
let current_module = ctx.sema.scope(call.syntax())?.module();
317317
let visibility = calculate_necessary_visibility(current_module, target_module, ctx);
318318

319-
let fn_name = make::name(&name.text());
319+
let fn_name = make::name(name.ident_token()?.text());
320320
let mut necessary_generic_params = FxHashSet::default();
321321
necessary_generic_params.extend(receiver_ty.generic_params(ctx.db()));
322322
let params = fn_args(
@@ -3131,4 +3131,32 @@ fn main() {
31313131
"#,
31323132
)
31333133
}
3134+
3135+
#[test]
3136+
fn no_generate_method_by_keyword() {
3137+
check_assist_not_applicable(
3138+
generate_function,
3139+
r#"
3140+
fn main() {
3141+
s.super$0();
3142+
}
3143+
"#,
3144+
);
3145+
check_assist_not_applicable(
3146+
generate_function,
3147+
r#"
3148+
fn main() {
3149+
s.Self$0();
3150+
}
3151+
"#,
3152+
);
3153+
check_assist_not_applicable(
3154+
generate_function,
3155+
r#"
3156+
fn main() {
3157+
s.self$0();
3158+
}
3159+
"#,
3160+
);
3161+
}
31343162
}

0 commit comments

Comments
 (0)