Generate enums as aliases

This commit is contained in:
Bartek Kryza
2021-05-22 14:10:50 +02:00
parent 6cd1abcd38
commit e1c6da5f2e
4 changed files with 60 additions and 7 deletions

View File

@@ -175,9 +175,9 @@ public:
void add_relationship(class_relationship &&cr)
{
if (cr.destination.empty() || type_aliases.count(cr.destination) == 0) {
if (cr.destination.empty()) {
LOG_WARN(
"Skipping relationship '{}' - {} - '{}' due to missing alias",
"Skipping relationship '{}' - {} - '{}' due empty destination",
cr.destination, to_string(cr.type), usr);
return;
}
@@ -240,6 +240,18 @@ struct enum_ : public element {
{
return l.name == r.name;
}
std::string full_name(
const std::vector<std::string> &using_namespaces) const
{
using namespace clanguml::util;
std::ostringstream ostr;
ostr << ns_relative(using_namespaces, name);
return ostr.str();
}
};
struct diagram {
@@ -289,6 +301,12 @@ struct diagram {
}
}
for (const auto &e : enums) {
if (e.full_name(using_namespaces) == full_name) {
return e.alias();
}
}
throw error::uml_alias_missing(
fmt::format("Missing alias for {}", full_name));
}