mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
add test with multiple names
This commit is contained in:
parent
ce18438cfd
commit
029c7108e0
1 changed files with 37 additions and 1 deletions
|
@ -30,7 +30,8 @@ struct State {
|
||||||
impl State {
|
impl State {
|
||||||
fn generate_new_name(&mut self, name: &str) -> ast::Name {
|
fn generate_new_name(&mut self, name: &str) -> ast::Name {
|
||||||
let name = stdx::to_camel_case(name);
|
let name = stdx::to_camel_case(name);
|
||||||
let count = if let Some(count) = self.names.get(&name) {
|
let count = if let Some(count) = self.names.get_mut(&name) {
|
||||||
|
*count += 1;
|
||||||
*count
|
*count
|
||||||
} else {
|
} else {
|
||||||
self.names.insert(name.clone(), 1);
|
self.names.insert(name.clone(), 1);
|
||||||
|
@ -257,6 +258,41 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn naming() {
|
||||||
|
check_fix(
|
||||||
|
r#"
|
||||||
|
{$0
|
||||||
|
"user": {
|
||||||
|
"address": {
|
||||||
|
"street": "Main St",
|
||||||
|
"house": 3
|
||||||
|
},
|
||||||
|
"email": "example@example.com"
|
||||||
|
},
|
||||||
|
"another_user": {
|
||||||
|
"user": {
|
||||||
|
"address": {
|
||||||
|
"street": "Main St",
|
||||||
|
"house": 3
|
||||||
|
},
|
||||||
|
"email": "example@example.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct Address1{ house: i64, street: String }
|
||||||
|
struct User1{ address: Address1, email: String }
|
||||||
|
struct AnotherUser1{ user: User1 }
|
||||||
|
struct Address2{ house: i64, street: String }
|
||||||
|
struct User2{ address: Address2, email: String }
|
||||||
|
struct Root1{ another_user: AnotherUser1, user: User2 }
|
||||||
|
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn arrays() {
|
fn arrays() {
|
||||||
check_fix(
|
check_fix(
|
||||||
|
|
Loading…
Reference in a new issue