Added package diagram namespace alias test case

This commit is contained in:
Bartek Kryza
2022-01-28 21:58:54 +01:00
parent 4de6d2a3ac
commit 4c51268869
11 changed files with 247 additions and 32 deletions

View File

@@ -21,6 +21,7 @@
#include <cppast/cpp_class.hpp>
#include <cppast/cpp_entity_kind.hpp>
#include <cppast/cpp_namespace.hpp>
#include <cppast/cpp_template.hpp>
#include <spdlog/spdlog.h>
@@ -92,6 +93,27 @@ std::string ns(const cppast::cpp_entity &e)
return fmt::format("{}", fmt::join(res, "::"));
}
type_safe::optional_ref<const cppast::cpp_namespace> entity_ns(
const cppast::cpp_entity &e)
{
std::vector<std::string> res{};
if (e.kind() == cppast::cpp_entity_kind::namespace_t)
return type_safe::optional_ref<const cppast::cpp_namespace>(
static_cast<const cppast::cpp_namespace &>(e));
auto it = e.parent();
while (it) {
if (it.value().kind() == cppast::cpp_entity_kind::namespace_t) {
return type_safe::optional_ref<const cppast::cpp_namespace>(
static_cast<const cppast::cpp_namespace &>(it.value()));
}
it = it.value().parent();
}
return {};
}
bool is_inside_class(const cppast::cpp_entity &e)
{
auto it = e.parent();