@@ -5,7 +5,7 @@ use syntax::{
5
5
6
6
use crate :: { AssistContext , AssistId , AssistKind , Assists } ;
7
7
8
- // Assist: convert_ufcs_to_method
8
+ // Assist: unqualify_method_call
9
9
//
10
10
// Transforms universal function call syntax into a method call.
11
11
//
@@ -22,7 +22,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
22
22
// }
23
23
// # mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
24
24
// ```
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 < ( ) > {
26
26
let call = ctx. find_node_at_offset :: < ast:: CallExpr > ( ) ?;
27
27
let ast:: Expr :: PathExpr ( path_expr) = call. expr ( ) ? else { return None } ;
28
28
let path = path_expr. path ( ) ?;
@@ -66,8 +66,8 @@ pub(crate) fn convert_ufcs_to_method(acc: &mut Assists, ctx: &AssistContext<'_>)
66
66
) ;
67
67
68
68
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" ,
71
71
call. syntax ( ) . text_range ( ) ,
72
72
|edit| {
73
73
edit. delete ( delete_path) ;
@@ -105,9 +105,9 @@ mod tests {
105
105
use super :: * ;
106
106
107
107
#[ test]
108
- fn ufcs2method_simple ( ) {
108
+ fn unqualify_method_call_simple ( ) {
109
109
check_assist (
110
- convert_ufcs_to_method ,
110
+ unqualify_method_call ,
111
111
r#"
112
112
struct S;
113
113
impl S { fn f(self, S: S) {} }
@@ -120,9 +120,9 @@ fn f() { S.f(S); }"#,
120
120
}
121
121
122
122
#[ test]
123
- fn ufcs2method_trait ( ) {
123
+ fn unqualify_method_call_trait ( ) {
124
124
check_assist (
125
- convert_ufcs_to_method ,
125
+ unqualify_method_call ,
126
126
r#"
127
127
//- minicore: add
128
128
fn f() { <u32 as core::ops::Add>::$0add(2, 2); }"# ,
@@ -131,7 +131,7 @@ fn f() { 2.add(2); }"#,
131
131
) ;
132
132
133
133
check_assist (
134
- convert_ufcs_to_method ,
134
+ unqualify_method_call ,
135
135
r#"
136
136
//- minicore: add
137
137
fn f() { core::ops::Add::$0add(2, 2); }"# ,
@@ -140,7 +140,7 @@ fn f() { 2.add(2); }"#,
140
140
) ;
141
141
142
142
check_assist (
143
- convert_ufcs_to_method ,
143
+ unqualify_method_call ,
144
144
r#"
145
145
//- minicore: add
146
146
use core::ops::Add;
@@ -152,9 +152,9 @@ fn f() { 2.add(2); }"#,
152
152
}
153
153
154
154
#[ test]
155
- fn ufcs2method_single_arg ( ) {
155
+ fn unqualify_method_call_single_arg ( ) {
156
156
check_assist (
157
- convert_ufcs_to_method ,
157
+ unqualify_method_call ,
158
158
r#"
159
159
struct S;
160
160
impl S { fn f(self) {} }
@@ -167,9 +167,9 @@ fn f() { 2.add(2); }"#,
167
167
}
168
168
169
169
#[ test]
170
- fn ufcs2method_parens ( ) {
170
+ fn unqualify_method_call_parens ( ) {
171
171
check_assist (
172
- convert_ufcs_to_method ,
172
+ unqualify_method_call ,
173
173
r#"
174
174
//- minicore: deref
175
175
struct S;
@@ -189,19 +189,19 @@ fn f() { (&S).deref(); }"#,
189
189
}
190
190
191
191
#[ test]
192
- fn ufcs2method_doesnt_apply_with_cursor_not_on_path ( ) {
192
+ fn unqualify_method_call_doesnt_apply_with_cursor_not_on_path ( ) {
193
193
check_assist_not_applicable (
194
- convert_ufcs_to_method ,
194
+ unqualify_method_call ,
195
195
r#"
196
196
//- minicore: add
197
197
fn f() { core::ops::Add::add(2,$0 2); }"# ,
198
198
) ;
199
199
}
200
200
201
201
#[ test]
202
- fn ufcs2method_doesnt_apply_with_no_self ( ) {
202
+ fn unqualify_method_call_doesnt_apply_with_no_self ( ) {
203
203
check_assist_not_applicable (
204
- convert_ufcs_to_method ,
204
+ unqualify_method_call ,
205
205
r#"
206
206
struct S;
207
207
impl S { fn assoc(S: S, S: S) {} }
0 commit comments