File tree 1 file changed +76
-6
lines changed
crates/ide-completion/src/completions/item_list
1 file changed +76
-6
lines changed Original file line number Diff line number Diff line change @@ -236,9 +236,7 @@ fn get_transformed_assoc_item(
236
236
) ;
237
237
238
238
transform. apply ( assoc_item. syntax ( ) ) ;
239
- if let ast:: AssocItem :: Fn ( func) = & assoc_item {
240
- func. remove_attrs_and_docs ( ) ;
241
- }
239
+ assoc_item. remove_attrs_and_docs ( ) ;
242
240
Some ( assoc_item)
243
241
}
244
242
@@ -335,7 +333,6 @@ fn add_const_impl(
335
333
}
336
334
337
335
fn make_const_compl_syntax ( const_ : & ast:: Const , needs_whitespace : bool ) -> String {
338
- const_. remove_attrs_and_docs ( ) ;
339
336
let const_ = if needs_whitespace {
340
337
insert_whitespace_into_node:: insert_ws_into ( const_. syntax ( ) . clone ( ) )
341
338
} else {
@@ -359,8 +356,6 @@ fn make_const_compl_syntax(const_: &ast::Const, needs_whitespace: bool) -> Strin
359
356
}
360
357
361
358
fn function_declaration ( node : & ast:: Fn , needs_whitespace : bool ) -> String {
362
- node. remove_attrs_and_docs ( ) ;
363
-
364
359
let node = if needs_whitespace {
365
360
insert_whitespace_into_node:: insert_ws_into ( node. syntax ( ) . clone ( ) )
366
361
} else {
@@ -1209,6 +1204,81 @@ trait Tr<'b> {
1209
1204
impl<'b> Tr<'b> for () {
1210
1205
type Ty<'a: 'b, T: Copy, const C: usize> = $0;
1211
1206
}
1207
+ "# ,
1208
+ ) ;
1209
+ }
1210
+
1211
+ #[ test]
1212
+ fn strips_comments ( ) {
1213
+ check_edit (
1214
+ "fn func" ,
1215
+ r#"
1216
+ trait Tr {
1217
+ /// docs
1218
+ #[attr]
1219
+ fn func();
1220
+ }
1221
+ impl Tr for () {
1222
+ $0
1223
+ }
1224
+ "# ,
1225
+ r#"
1226
+ trait Tr {
1227
+ /// docs
1228
+ #[attr]
1229
+ fn func();
1230
+ }
1231
+ impl Tr for () {
1232
+ fn func() {
1233
+ $0
1234
+ }
1235
+ }
1236
+ "# ,
1237
+ ) ;
1238
+ check_edit (
1239
+ "const C" ,
1240
+ r#"
1241
+ trait Tr {
1242
+ /// docs
1243
+ #[attr]
1244
+ const C: usize;
1245
+ }
1246
+ impl Tr for () {
1247
+ $0
1248
+ }
1249
+ "# ,
1250
+ r#"
1251
+ trait Tr {
1252
+ /// docs
1253
+ #[attr]
1254
+ const C: usize;
1255
+ }
1256
+ impl Tr for () {
1257
+ const C: usize = $0;
1258
+ }
1259
+ "# ,
1260
+ ) ;
1261
+ check_edit (
1262
+ "type Item" ,
1263
+ r#"
1264
+ trait Tr {
1265
+ /// docs
1266
+ #[attr]
1267
+ type Item;
1268
+ }
1269
+ impl Tr for () {
1270
+ $0
1271
+ }
1272
+ "# ,
1273
+ r#"
1274
+ trait Tr {
1275
+ /// docs
1276
+ #[attr]
1277
+ type Item;
1278
+ }
1279
+ impl Tr for () {
1280
+ type Item = $0;
1281
+ }
1212
1282
"# ,
1213
1283
) ;
1214
1284
}
You can’t perform that action at this time.
0 commit comments