Fixed class diagram test cases
This commit is contained in:
@@ -177,7 +177,7 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
||||
if (!m_model.should_include(r.type()))
|
||||
continue;
|
||||
|
||||
LOG_DBG("== Processing relationship {}",
|
||||
LOG_DBG("Processing relationship {}",
|
||||
plantuml_common::to_plantuml(r.type(), r.style()));
|
||||
|
||||
std::string destination;
|
||||
@@ -189,8 +189,6 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
||||
if (util::starts_with(destination, std::string{"::"}))
|
||||
destination = destination.substr(2, destination.size());
|
||||
|
||||
LOG_DBG("=== Destination is: {}", destination);
|
||||
|
||||
std::string puml_relation;
|
||||
if (!r.multiplicity_source().empty())
|
||||
puml_relation += "\"" + r.multiplicity_source() + "\" ";
|
||||
@@ -205,7 +203,7 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
||||
}
|
||||
}
|
||||
catch (error::uml_alias_missing &e) {
|
||||
LOG_DBG("=== Skipping {} relation from {} to {} due "
|
||||
LOG_DBG("Skipping {} relation from {} to {} due "
|
||||
"to: {}",
|
||||
plantuml_common::to_plantuml(r.type(), r.style()),
|
||||
c.full_name(), destination, e.what());
|
||||
@@ -268,14 +266,6 @@ void generator::generate_relationships(
|
||||
try {
|
||||
destination = r.destination();
|
||||
|
||||
// TODO: Refactor destination to a namespace qualified entity
|
||||
// name
|
||||
// if (util::starts_with(destination, std::string{"::"}))
|
||||
// destination = destination.substr(2,
|
||||
// destination.size());
|
||||
|
||||
LOG_DBG("=== Destination is: {}", destination);
|
||||
|
||||
std::string puml_relation;
|
||||
if (!r.multiplicity_source().empty())
|
||||
puml_relation += "\"" + r.multiplicity_source() + "\" ";
|
||||
|
||||
@@ -152,32 +152,45 @@ std::string template_parameter::to_string(
|
||||
return res;
|
||||
}
|
||||
|
||||
void template_parameter::find_nested_relationships(
|
||||
bool template_parameter::find_nested_relationships(
|
||||
std::vector<std::pair<int64_t, common::model::relationship_t>>
|
||||
&nested_relationships,
|
||||
common::model::relationship_t hint,
|
||||
std::function<bool(const std::string &full_name)> condition) const
|
||||
std::function<bool(const std::string &full_name)> should_include) const
|
||||
{
|
||||
bool added_aggregation_relationship{false};
|
||||
|
||||
// If this type argument should be included in the relationship
|
||||
// just add it and skip recursion (e.g. this is a user defined type)
|
||||
if (condition(name())) {
|
||||
if(id())
|
||||
if (should_include(name())) {
|
||||
if (id()) {
|
||||
nested_relationships.push_back({id().value(), hint});
|
||||
added_aggregation_relationship =
|
||||
(hint == common::model::relationship_t::kAggregation);
|
||||
}
|
||||
}
|
||||
// Otherwise (e.g. this is a std::shared_ptr) and we're actually
|
||||
// interested what is stored inside it
|
||||
else {
|
||||
for (const auto &template_argument : template_params()) {
|
||||
if (condition(template_argument.name()) && template_argument.id()) {
|
||||
if (should_include(template_argument.name()) &&
|
||||
template_argument.id()) {
|
||||
|
||||
nested_relationships.push_back(
|
||||
{template_argument.id().value(), hint});
|
||||
|
||||
added_aggregation_relationship =
|
||||
(hint == common::model::relationship_t::kAggregation);
|
||||
}
|
||||
else {
|
||||
template_argument.find_nested_relationships(
|
||||
nested_relationships, hint, condition);
|
||||
added_aggregation_relationship =
|
||||
template_argument.find_nested_relationships(
|
||||
nested_relationships, hint, should_include);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return added_aggregation_relationship;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,11 +90,11 @@ public:
|
||||
|
||||
void clear_params() { template_params_.clear(); }
|
||||
|
||||
void find_nested_relationships(
|
||||
bool find_nested_relationships(
|
||||
std::vector<std::pair<int64_t, common::model::relationship_t>>
|
||||
&nested_relationships,
|
||||
common::model::relationship_t hint,
|
||||
std::function<bool(const std::string &full_name)> condition) const;
|
||||
std::function<bool(const std::string &full_name)> should_include) const;
|
||||
|
||||
private:
|
||||
/// Represents the type of non-type template parameters
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -121,7 +121,8 @@ private:
|
||||
|
||||
void add_relationships(clanguml::class_diagram::model::class_ &c,
|
||||
const clanguml::class_diagram::model::class_member &field,
|
||||
const found_relationships_t &relationships);
|
||||
const found_relationships_t &relationships,
|
||||
bool break_on_first_aggregation = false);
|
||||
|
||||
void set_source_location(const clang::Decl &decl,
|
||||
clanguml::common::model::source_location &element);
|
||||
@@ -142,6 +143,14 @@ private:
|
||||
const std::set<std::string> &template_parameter_names,
|
||||
const clang::TemplateSpecializationType &template_instantiation_type);
|
||||
|
||||
void process_unexposed_template_specialization_parameters(
|
||||
const std::string &tspec, clanguml::class_diagram::model::template_parameter &tp,
|
||||
clanguml::class_diagram::model::class_ &c);
|
||||
|
||||
bool find_relationships_in_unexposed_template_params(
|
||||
const clanguml::class_diagram::model::template_parameter &ct,
|
||||
found_relationships_t &relationships);
|
||||
|
||||
template <typename ClangDecl>
|
||||
void process_comment(
|
||||
const ClangDecl &decl, clanguml::common::model::decorated_element &e)
|
||||
|
||||
@@ -146,17 +146,22 @@ void generator<C, D>::generate_config_layout_hints(std::ostream &ostr) const
|
||||
{
|
||||
using namespace clanguml::util;
|
||||
|
||||
// const auto &uns = m_config.using_namespace();
|
||||
const auto &uns = m_config.using_namespace();
|
||||
|
||||
// Generate layout hints
|
||||
for (const auto &[entity_name, hints] : m_config.layout()) {
|
||||
for (const auto &hint : hints) {
|
||||
std::stringstream hint_str;
|
||||
try {
|
||||
auto element_opt = m_model.get(
|
||||
m_config.using_namespace().relative(entity_name));
|
||||
auto hint_element_opt = m_model.get(
|
||||
m_config.using_namespace().relative(hint.entity));
|
||||
auto element_opt = m_model.get(entity_name);
|
||||
if (!element_opt)
|
||||
element_opt = m_model.get((uns | entity_name).to_string());
|
||||
|
||||
auto hint_element_opt = m_model.get(hint.entity);
|
||||
if (!hint_element_opt)
|
||||
hint_element_opt =
|
||||
m_model.get((uns | hint.entity).to_string());
|
||||
|
||||
if (!element_opt || !hint_element_opt)
|
||||
continue;
|
||||
hint_str << element_opt.value().get().alias() << " -[hidden]"
|
||||
|
||||
Reference in New Issue
Block a user