Skip to content

Commit c782353

Browse files
committed
Rename assist: convert_ufcs_to_method => unqualify_method_call
1 parent 44c84a8 commit c782353

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

crates/ide-assists/src/handlers/convert_ufcs_to_method.rs renamed to crates/ide-assists/src/handlers/unqualify_method_call.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use syntax::{
55

66
use crate::{AssistContext, AssistId, AssistKind, Assists};
77

8-
// Assist: convert_ufcs_to_method
8+
// Assist: unqualify_method_call
99
//
1010
// Transforms universal function call syntax into a method call.
1111
//
@@ -22,7 +22,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
2222
// }
2323
// # mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
2424
// ```
25-
pub(crate) fn convert_ufcs_to_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
25+
pub(crate) fn unqualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
2626
let call = ctx.find_node_at_offset::<ast::CallExpr>()?;
2727
let ast::Expr::PathExpr(path_expr) = call.expr()? else { return None };
2828
let path = path_expr.path()?;
@@ -66,8 +66,8 @@ pub(crate) fn convert_ufcs_to_method(acc: &mut Assists, ctx: &AssistContext<'_>)
6666
);
6767

6868
acc.add(
69-
AssistId("convert_ufcs_to_method", AssistKind::RefactorRewrite),
70-
"Convert UFCS to a method call",
69+
AssistId("unqualify_method_call", AssistKind::RefactorRewrite),
70+
"Unqualify method call",
7171
call.syntax().text_range(),
7272
|edit| {
7373
edit.delete(delete_path);
@@ -105,9 +105,9 @@ mod tests {
105105
use super::*;
106106

107107
#[test]
108-
fn ufcs2method_simple() {
108+
fn unqualify_method_call_simple() {
109109
check_assist(
110-
convert_ufcs_to_method,
110+
unqualify_method_call,
111111
r#"
112112
struct S;
113113
impl S { fn f(self, S: S) {} }
@@ -120,9 +120,9 @@ fn f() { S.f(S); }"#,
120120
}
121121

122122
#[test]
123-
fn ufcs2method_trait() {
123+
fn unqualify_method_call_trait() {
124124
check_assist(
125-
convert_ufcs_to_method,
125+
unqualify_method_call,
126126
r#"
127127
//- minicore: add
128128
fn f() { <u32 as core::ops::Add>::$0add(2, 2); }"#,
@@ -131,7 +131,7 @@ fn f() { 2.add(2); }"#,
131131
);
132132

133133
check_assist(
134-
convert_ufcs_to_method,
134+
unqualify_method_call,
135135
r#"
136136
//- minicore: add
137137
fn f() { core::ops::Add::$0add(2, 2); }"#,
@@ -140,7 +140,7 @@ fn f() { 2.add(2); }"#,
140140
);
141141

142142
check_assist(
143-
convert_ufcs_to_method,
143+
unqualify_method_call,
144144
r#"
145145
//- minicore: add
146146
use core::ops::Add;
@@ -152,9 +152,9 @@ fn f() { 2.add(2); }"#,
152152
}
153153

154154
#[test]
155-
fn ufcs2method_single_arg() {
155+
fn unqualify_method_call_single_arg() {
156156
check_assist(
157-
convert_ufcs_to_method,
157+
unqualify_method_call,
158158
r#"
159159
struct S;
160160
impl S { fn f(self) {} }
@@ -167,9 +167,9 @@ fn f() { 2.add(2); }"#,
167167
}
168168

169169
#[test]
170-
fn ufcs2method_parens() {
170+
fn unqualify_method_call_parens() {
171171
check_assist(
172-
convert_ufcs_to_method,
172+
unqualify_method_call,
173173
r#"
174174
//- minicore: deref
175175
struct S;
@@ -189,19 +189,19 @@ fn f() { (&S).deref(); }"#,
189189
}
190190

191191
#[test]
192-
fn ufcs2method_doesnt_apply_with_cursor_not_on_path() {
192+
fn unqualify_method_call_doesnt_apply_with_cursor_not_on_path() {
193193
check_assist_not_applicable(
194-
convert_ufcs_to_method,
194+
unqualify_method_call,
195195
r#"
196196
//- minicore: add
197197
fn f() { core::ops::Add::add(2,$0 2); }"#,
198198
);
199199
}
200200

201201
#[test]
202-
fn ufcs2method_doesnt_apply_with_no_self() {
202+
fn unqualify_method_call_doesnt_apply_with_no_self() {
203203
check_assist_not_applicable(
204-
convert_ufcs_to_method,
204+
unqualify_method_call,
205205
r#"
206206
struct S;
207207
impl S { fn assoc(S: S, S: S) {} }

crates/ide-assists/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ mod handlers {
126126
mod convert_to_guarded_return;
127127
mod convert_two_arm_bool_match_to_matches_macro;
128128
mod convert_while_to_loop;
129-
mod convert_ufcs_to_method;
130129
mod destructure_tuple_binding;
131130
mod expand_glob_import;
132131
mod extract_expressions_from_format_string;
@@ -202,6 +201,7 @@ mod handlers {
202201
mod unnecessary_async;
203202
mod unwrap_block;
204203
mod unwrap_result_return_type;
204+
mod unqualify_method_call;
205205
mod wrap_return_type_in_result;
206206

207207
pub(crate) fn all() -> &'static [Handler] {
@@ -219,7 +219,6 @@ mod handlers {
219219
convert_bool_then::convert_bool_then_to_if,
220220
convert_bool_then::convert_if_to_bool_then,
221221
convert_comment_block::convert_comment_block,
222-
convert_ufcs_to_method::convert_ufcs_to_method,
223222
convert_integer_literal::convert_integer_literal,
224223
convert_into_to_from::convert_into_to_from,
225224
convert_iter_for_each_to_for::convert_iter_for_each_to_for,
@@ -308,6 +307,7 @@ mod handlers {
308307
unwrap_block::unwrap_block,
309308
unwrap_result_return_type::unwrap_result_return_type,
310309
unwrap_tuple::unwrap_tuple,
310+
unqualify_method_call::unqualify_method_call,
311311
wrap_return_type_in_result::wrap_return_type_in_result,
312312
// These are manually sorted for better priorities. By default,
313313
// priority is determined by the size of the target range (smaller

crates/ide-assists/src/tests/generated.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -554,25 +554,6 @@ fn main() {
554554
)
555555
}
556556

557-
#[test]
558-
fn doctest_convert_ufcs_to_method() {
559-
check_doc_test(
560-
"convert_ufcs_to_method",
561-
r#####"
562-
fn main() {
563-
std::ops::Add::add$0(1, 2);
564-
}
565-
mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
566-
"#####,
567-
r#####"
568-
fn main() {
569-
1.add(2);
570-
}
571-
mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
572-
"#####,
573-
)
574-
}
575-
576557
#[test]
577558
fn doctest_convert_while_to_loop() {
578559
check_doc_test(
@@ -2552,6 +2533,25 @@ pub async fn bar() { foo() }
25522533
)
25532534
}
25542535

2536+
#[test]
2537+
fn doctest_unqualify_method_call() {
2538+
check_doc_test(
2539+
"unqualify_method_call",
2540+
r#####"
2541+
fn main() {
2542+
std::ops::Add::add$0(1, 2);
2543+
}
2544+
mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
2545+
"#####,
2546+
r#####"
2547+
fn main() {
2548+
1.add(2);
2549+
}
2550+
mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
2551+
"#####,
2552+
)
2553+
}
2554+
25552555
#[test]
25562556
fn doctest_unwrap_block() {
25572557
check_doc_test(

0 commit comments

Comments
 (0)