Fixed handling of nested and anonymous classes

This commit is contained in:
Bartek Kryza
2022-09-04 18:12:54 +02:00
parent 4d4eb02e57
commit d887353c24
11 changed files with 102 additions and 20 deletions

View File

@@ -22,6 +22,7 @@
#include <clang/AST/RecursiveASTVisitor.h>
#include <deque>
#include <filesystem>
#include <string>
@@ -30,12 +31,23 @@ class NamespaceDecl;
}
namespace clanguml::common {
std::string get_tag_name(const clang::TagDecl &declaration);
template <typename T> std::string get_qualified_name(const T &declaration)
{
auto qualified_name = declaration.getQualifiedNameAsString();
util::replace_all(qualified_name, "(anonymous namespace)", "");
util::replace_all(qualified_name, "::::", "::");
if constexpr (std::is_base_of_v<clang::TagDecl, T>) {
auto base_name = get_tag_name(declaration);
model::namespace_ ns{qualified_name};
ns.pop_back();
ns = ns | base_name;
return ns.to_string();
}
return qualified_name;
}