Skip to content

Commit 029c710

Browse files
committed
add test with multiple names
1 parent ce18438 commit 029c710

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

crates/ide-diagnostics/src/handlers/json_is_not_rust.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ struct State {
3030
impl State {
3131
fn generate_new_name(&mut self, name: &str) -> ast::Name {
3232
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;
3435
*count
3536
} else {
3637
self.names.insert(name.clone(), 1);
@@ -257,6 +258,41 @@ mod tests {
257258
);
258259
}
259260

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+
"email": "[email protected]"
272+
},
273+
"another_user": {
274+
"user": {
275+
"address": {
276+
"street": "Main St",
277+
"house": 3
278+
},
279+
"email": "[email protected]"
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+
260296
#[test]
261297
fn arrays() {
262298
check_fix(

0 commit comments

Comments
 (0)