From c1f4ecefbc71092608ad15dbc2c88de5bf27a48c Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Fri, 26 Feb 2021 23:22:16 +0100 Subject: [PATCH] Fixed class visitor continuation after inner class --- src/uml/class_diagram_visitor.h | 1 + src/util/util.h | 6 +++++- tests/t00004/.clanguml | 4 ++-- tests/t00004/t00004.cc | 4 +++- tests/test_cases.cc | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/uml/class_diagram_visitor.h b/src/uml/class_diagram_visitor.h index 8afe693f..7edce05c 100644 --- a/src/uml/class_diagram_visitor.h +++ b/src/uml/class_diagram_visitor.h @@ -186,6 +186,7 @@ static enum CXChildVisitResult class_visitor( ctx->ctx->d.classes.emplace_back(std::move(c)); }); + ret = CXChildVisit_Continue; break; case CXCursor_EnumDecl: if (!config.should_include(cursor.fully_qualified())) { diff --git a/src/util/util.h b/src/util/util.h index 3a5ab466..449f7811 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -50,7 +50,11 @@ std::vector split(std::string str, std::string delimiter) std::string ns_relative( const std::vector &namespaces, const std::string &n) { - for (const auto &ns : namespaces) { + std::vector namespaces_sorted{namespaces}; + + std::sort(namespaces_sorted.rbegin(), namespaces_sorted.rend()); + + for (const auto &ns : namespaces_sorted) { if (ns.empty()) continue; diff --git a/tests/t00004/.clanguml b/tests/t00004/.clanguml index 57824ca7..e7dba572 100644 --- a/tests/t00004/.clanguml +++ b/tests/t00004/.clanguml @@ -6,9 +6,9 @@ diagrams: glob: - ../../tests/t00004/t00004.cc using_namespace: - - clanguml::t00004::A::AA - - clanguml::t00004::A - clanguml::t00004 + - clanguml::t00004::A + - clanguml::t00004::A::AA include: namespaces: - clanguml::t00004 diff --git a/tests/t00004/t00004.cc b/tests/t00004/t00004.cc index b3a8d4d3..22be0004 100644 --- a/tests/t00004/t00004.cc +++ b/tests/t00004/t00004.cc @@ -3,6 +3,8 @@ namespace t00004 { class A { public: + void foo() const {} + class AA { public: enum class Lights { Green, Yellow, Red }; @@ -11,7 +13,7 @@ public: }; }; - void foo() const {} + void foo2() const {} }; } } diff --git a/tests/test_cases.cc b/tests/test_cases.cc index 066cd4ff..bba9dc6f 100644 --- a/tests/test_cases.cc +++ b/tests/test_cases.cc @@ -258,6 +258,8 @@ TEST_CASE("Test t00004", "[unit-test]") REQUIRE_THAT(puml, Contains("A +-- AA")); REQUIRE_THAT(puml, Contains("AA +-- AAA")); REQUIRE_THAT(puml, Contains("AA +-- Lights")); + REQUIRE_THAT(puml, Contains("+ foo() const")); + REQUIRE_THAT(puml, Contains("+ foo2() const")); save_puml( "./" + config.output_directory + "/" + diagram->name + ".puml", puml);