Fixed friend class root namespace handling
This commit is contained in:
@@ -1384,7 +1384,7 @@ void translation_unit_visitor::process_friend(const cppast::cpp_friend &f,
|
||||
r.set_destination(name);
|
||||
}
|
||||
else if (f.entity()) {
|
||||
std::string name;
|
||||
std::string name = f.entity().value().name();
|
||||
|
||||
if (f.entity().value().kind() ==
|
||||
cppast::cpp_entity_kind::class_template_t) {
|
||||
@@ -1411,7 +1411,17 @@ void translation_unit_visitor::process_friend(const cppast::cpp_friend &f,
|
||||
cppast::is_templated(f.entity().value()),
|
||||
cppast::to_string(f.entity().value().kind()));
|
||||
|
||||
name = cx::util::full_name(ctx.get_namespace(), f.entity().value());
|
||||
const auto &maybe_definition =
|
||||
cppast::get_definition(ctx.entity_index(), f.entity().value());
|
||||
|
||||
if (maybe_definition.has_value()) {
|
||||
const auto &friend_class = maybe_definition.value();
|
||||
|
||||
auto entity_ns =
|
||||
common::model::namespace_{cx::util::ns(friend_class)};
|
||||
|
||||
name = cx::util::full_name(entity_ns, f.entity().value());
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx.diagram().should_include(ctx.get_namespace(), name))
|
||||
|
||||
@@ -4,6 +4,13 @@ class A {
|
||||
class AA {
|
||||
};
|
||||
|
||||
class AAA {
|
||||
};
|
||||
|
||||
template <typename T> class AAAA {
|
||||
T t;
|
||||
};
|
||||
|
||||
namespace ns1 {
|
||||
|
||||
class A {
|
||||
@@ -26,6 +33,9 @@ class D : public ns1::ns2::A {
|
||||
class E : public ::A {
|
||||
};
|
||||
|
||||
class AAA {
|
||||
};
|
||||
|
||||
class R {
|
||||
public:
|
||||
A *a;
|
||||
@@ -33,6 +43,10 @@ public:
|
||||
ns1::ns2::A *ns1_ns2_a;
|
||||
::A *root_a;
|
||||
|
||||
friend ::AAA;
|
||||
// TODO:
|
||||
// template<typename T> friend class ::AAAA;
|
||||
|
||||
void foo(::AA &aa) { (void)aa; }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -58,6 +58,12 @@ TEST_CASE("t00045", "[test-case][class]")
|
||||
|
||||
REQUIRE_THAT(puml, IsDependency(_A("ns1::ns2::R"), _A("AA")));
|
||||
|
||||
REQUIRE_THAT(puml, IsFriend<Public>(_A("ns1::ns2::R"), _A("AAA")));
|
||||
REQUIRE_THAT(
|
||||
puml, !IsFriend<Public>(_A("ns1::ns2::R"), _A("ns1::ns2::AAA")));
|
||||
// TODO:
|
||||
// REQUIRE_THAT(puml, IsFriend<Public>(_A("ns1::ns2::R"), _A("AAAA<T>")));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user