Fixed root namespace handling

This commit is contained in:
Bartek Kryza
2022-06-18 17:48:57 +02:00
parent bb689db81a
commit c82002e8ee
9 changed files with 55 additions and 24 deletions

View File

@@ -184,6 +184,11 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
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;
@@ -263,6 +268,11 @@ 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;
@@ -402,7 +412,7 @@ void generator::generate(const package &p, std::ostream &ostr) const
// Don't generate packages from namespaces filtered out by
// using_namespace
if (!uns.starts_with(p.full_name(false))) {
if (!uns.starts_with({p.full_name(false)})) {
ostr << "package [" << p.name() << "] ";
ostr << "as " << p.alias();
@@ -440,7 +450,7 @@ void generator::generate(const package &p, std::ostream &ostr) const
if (m_config.generate_packages()) {
// Don't generate packages from namespaces filtered out by
// using_namespace
if (!uns.starts_with(p.full_name(false))) {
if (!uns.starts_with({p.full_name(false)})) {
ostr << "}" << '\n';
}
}

View File

@@ -594,12 +594,12 @@ void translation_unit_visitor::process_class_bases(
{
for (auto &base : cls.bases()) {
class_parent cp;
auto base_ns = common::model::namespace_{
cx::util::ns(base.type(), ctx.entity_index())};
auto ns = cx::util::ns(base.type(), ctx.entity_index());
common::model::namespace_ base_ns;
if(!ns.empty())
base_ns = common::model::namespace_{ns};
base_ns = base_ns | common::model::namespace_{base.name()}.name();
cp.set_name(
// base_ns.relative_to(ctx.config().using_namespace()).to_string());
base_ns.to_string());
cp.set_name(base_ns.to_string());
cp.is_virtual(base.is_virtual());
switch (base.access_specifier()) {
@@ -758,7 +758,7 @@ bool translation_unit_visitor::process_field_with_template_instantiation(
auto [decorator_rtype, decorator_rmult] = member.get_relationship();
if (decorator_rtype != relationship_t::kNone) {
rr.set_type(decorator_rtype);
auto mult = util::split(decorator_rmult, ":");
auto mult = util::split(decorator_rmult, ":", false);
if (mult.size() == 2) {
rr.set_multiplicity_source(mult[0]);
rr.set_multiplicity_destination(mult[1]);
@@ -811,6 +811,8 @@ bool translation_unit_visitor::add_nested_template_relationships(
template_argument.find_nested_relationships(nested_relationships,
relationship_type,
[&d = ctx.diagram()](const std::string &full_name) {
if(full_name.empty())
return false;
auto [ns, name] = cx::util::split_ns(full_name);
return d.should_include(ns, name);
});
@@ -823,7 +825,7 @@ bool translation_unit_visitor::add_nested_template_relationships(
nested_relationship.set_style(m.style_spec());
if (decorator_rtype != relationship_t::kNone) {
nested_relationship.set_type(decorator_rtype);
auto mult = util::split(decorator_rmult, ":");
auto mult = util::split(decorator_rmult, ":", false);
if (mult.size() == 2) {
nested_relationship.set_multiplicity_source(mult[0]);
nested_relationship.set_multiplicity_destination(mult[1]);
@@ -914,7 +916,7 @@ void translation_unit_visitor::process_field(
auto [decorator_rtype, decorator_rmult] = m.get_relationship();
if (decorator_rtype != relationship_t::kNone) {
r.set_type(decorator_rtype);
auto mult = util::split(decorator_rmult, ":");
auto mult = util::split(decorator_rmult, ":", false);
if (mult.size() == 2) {
r.set_multiplicity_source(mult[0]);
r.set_multiplicity_destination(mult[1]);