Skip to content

Commit

Permalink
feat(uml): add support for array
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 28, 2021
1 parent 3c44a52 commit 92ed559
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions plugins/coco_struct_analysis/src/plantuml_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ impl PlantUmlRender {
method.access, method.return_type, method.name
));

dep_map.insert(method.return_type.clone(), clazz.name.clone());
if method.pure_return_type.len() > 0 {
dep_map.insert(method.pure_return_type.clone(), clazz.name.clone());
} else {
dep_map.insert(method.return_type.clone(), clazz.name.clone());
}
}
}
methods
Expand All @@ -79,7 +83,11 @@ impl PlantUmlRender {
member.access, member.data_type, member.name
));

dep_map.insert(member.data_type.clone(), clazz.name.clone());
if member.data_type.len() > 0 {
dep_map.insert(member.data_type.clone(), clazz.name.clone());
} else {
dep_map.insert(member.data_type.clone(), clazz.name.clone());
}
}
}
members
Expand Down Expand Up @@ -165,4 +173,22 @@ mod tests {
str
);
}

#[test]
fn should_render_array() {
let mut classes = vec![];
let mut demo = ClassInfo::new("Demo");
let demo2 = ClassInfo::new("Demo2");

let mut method = MethodInfo::new("method", "-", "[]Demo2".to_string());
method.pure_return_type = "Demo2".to_string();
demo.methods.push(method);

classes.push(demo);
classes.push(demo2);

let str = PlantUmlRender::render(&classes);
assert_eq!(true, str.contains("Demo -- Demo2"));
assert_eq!(false, str.contains("Demo -- String"));
}
}

0 comments on commit 92ed559

Please sign in to comment.