Added friend relationship to class templates
This commit is contained in:
@@ -209,21 +209,24 @@ static enum CXChildVisitResult friend_class_visitor(
|
|||||||
cx::cursor cursor{std::move(cx_cursor)};
|
cx::cursor cursor{std::move(cx_cursor)};
|
||||||
cx::cursor parent{std::move(cx_parent)};
|
cx::cursor parent{std::move(cx_parent)};
|
||||||
|
|
||||||
spdlog::info("Visiting friend class declaration{}: {} - {}:{}",
|
spdlog::info("Visiting friend class declaration {}: {} - {}:{}",
|
||||||
ctx->element.name, cursor.spelling(), cursor.kind());
|
ctx->element.name, cursor.spelling(), cursor.kind(),
|
||||||
|
cursor.referenced());
|
||||||
|
|
||||||
enum CXChildVisitResult ret = CXChildVisit_Break;
|
enum CXChildVisitResult ret = CXChildVisit_Break;
|
||||||
switch (cursor.kind()) {
|
switch (cursor.kind()) {
|
||||||
|
case CXCursor_TemplateRef:
|
||||||
|
case CXCursor_ClassTemplate:
|
||||||
case CXCursor_TypeRef: {
|
case CXCursor_TypeRef: {
|
||||||
|
spdlog::info("Analyzing friend declaration: {}, {}", cursor,
|
||||||
|
cursor.specialized_cursor_template());
|
||||||
|
|
||||||
if (!ctx->ctx->config.should_include(
|
if (!ctx->ctx->config.should_include(
|
||||||
cursor.referenced().fully_qualified())) {
|
cursor.referenced().fully_qualified())) {
|
||||||
ret = CXChildVisit_Continue;
|
ret = CXChildVisit_Continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdlog::info("Adding friend declaration: {}, {}", cursor,
|
|
||||||
cursor.referenced());
|
|
||||||
|
|
||||||
class_relationship r;
|
class_relationship r;
|
||||||
r.type = relationship_t::kFriendship;
|
r.type = relationship_t::kFriendship;
|
||||||
r.label = "<<friend>>";
|
r.label = "<<friend>>";
|
||||||
|
|||||||
@@ -8,11 +8,17 @@ namespace t00011 {
|
|||||||
|
|
||||||
class B;
|
class B;
|
||||||
|
|
||||||
|
template <typename T> class D {
|
||||||
|
T value;
|
||||||
|
};
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
private:
|
private:
|
||||||
void foo() {}
|
void foo() {}
|
||||||
friend class B;
|
friend class B;
|
||||||
friend class external::C;
|
friend class external::C;
|
||||||
|
template <typename T> friend class D;
|
||||||
|
// TODO: Add friend for a template specialization
|
||||||
};
|
};
|
||||||
|
|
||||||
class B {
|
class B {
|
||||||
|
|||||||
@@ -46,8 +46,10 @@ TEST_CASE("Test t00011", "[unit-test]")
|
|||||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||||
REQUIRE_THAT(puml, IsClass(_A("A")));
|
REQUIRE_THAT(puml, IsClass(_A("A")));
|
||||||
REQUIRE_THAT(puml, IsClass(_A("B")));
|
REQUIRE_THAT(puml, IsClass(_A("B")));
|
||||||
|
REQUIRE_THAT(puml, IsClass(_A("D<T>")));
|
||||||
|
|
||||||
REQUIRE_THAT(puml, IsFriend(_A("A"), _A("B")));
|
REQUIRE_THAT(puml, IsFriend(_A("A"), _A("B")));
|
||||||
|
REQUIRE_THAT(puml, IsFriend(_A("A"), _A("D<T>")));
|
||||||
|
|
||||||
save_puml(
|
save_puml(
|
||||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||||
|
|||||||
Reference in New Issue
Block a user