File tree 1 file changed +37
-1
lines changed
crates/ide-diagnostics/src/handlers
1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ struct State {
30
30
impl State {
31
31
fn generate_new_name ( & mut self , name : & str ) -> ast:: Name {
32
32
let name = stdx:: to_camel_case ( name) ;
33
- let count = if let Some ( count) = self . names . get ( & name) {
33
+ let count = if let Some ( count) = self . names . get_mut ( & name) {
34
+ * count += 1 ;
34
35
* count
35
36
} else {
36
37
self . names . insert ( name. clone ( ) , 1 ) ;
@@ -257,6 +258,41 @@ mod tests {
257
258
) ;
258
259
}
259
260
261
+ #[ test]
262
+ fn naming ( ) {
263
+ check_fix (
264
+ r#"
265
+ {$0
266
+ "user": {
267
+ "address": {
268
+ "street": "Main St",
269
+ "house": 3
270
+ },
271
+
272
+ },
273
+ "another_user": {
274
+ "user": {
275
+ "address": {
276
+ "street": "Main St",
277
+ "house": 3
278
+ },
279
+
280
+ }
281
+ }
282
+ }
283
+ "# ,
284
+ r#"
285
+ struct Address1{ house: i64, street: String }
286
+ struct User1{ address: Address1, email: String }
287
+ struct AnotherUser1{ user: User1 }
288
+ struct Address2{ house: i64, street: String }
289
+ struct User2{ address: Address2, email: String }
290
+ struct Root1{ another_user: AnotherUser1, user: User2 }
291
+
292
+ "# ,
293
+ ) ;
294
+ }
295
+
260
296
#[ test]
261
297
fn arrays ( ) {
262
298
check_fix (
You can’t perform that action at this time.
0 commit comments