Fixed handling of nested and anonymous classes
This commit is contained in:
@@ -52,6 +52,13 @@ void generator::generate_link(
|
||||
ostr << "]]]";
|
||||
}
|
||||
|
||||
std::string generator::render_name(std::string name) const
|
||||
{
|
||||
util::replace_all(name, "##", "::");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void generator::generate_alias(const class_ &c, std::ostream &ostr) const
|
||||
{
|
||||
std::string class_type{"class"};
|
||||
@@ -64,10 +71,9 @@ void generator::generate_alias(const class_ &c, std::ostream &ostr) const
|
||||
else
|
||||
full_name = c.full_name();
|
||||
|
||||
if (full_name.empty())
|
||||
full_name = "<<anonymous>>";
|
||||
assert(!full_name.empty());
|
||||
|
||||
ostr << class_type << " \"" << full_name;
|
||||
ostr << class_type << " \"" << render_name(full_name);
|
||||
|
||||
ostr << "\" as " << c.alias() << '\n';
|
||||
|
||||
@@ -82,7 +88,7 @@ void generator::generate_alias(const enum_ &e, std::ostream &ostr) const
|
||||
<< " \"" << e.name();
|
||||
else
|
||||
ostr << "enum"
|
||||
<< " \"" << e.full_name();
|
||||
<< " \"" << render_name(e.full_name());
|
||||
|
||||
ostr << "\" as " << e.alias() << '\n';
|
||||
|
||||
@@ -225,7 +231,7 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
||||
ostr << "{static} ";
|
||||
|
||||
ostr << plantuml_common::to_plantuml(m.access()) << m.name() << " : "
|
||||
<< uns.relative(m.type());
|
||||
<< render_name(uns.relative(m.type()));
|
||||
|
||||
if (m_config.generate_links) {
|
||||
generate_link(ostr, m);
|
||||
|
||||
@@ -76,6 +76,9 @@ public:
|
||||
void generate_relationships(const package &p, std::ostream &ostr) const;
|
||||
|
||||
void generate(std::ostream &ostr) const override;
|
||||
|
||||
private:
|
||||
std::string render_name(std::string name) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -146,7 +146,8 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
|
||||
std::string qualified_name = common::get_qualified_name(*enm);
|
||||
namespace_ ns{qualified_name};
|
||||
ns.pop_back();
|
||||
e.set_name(enm->getNameAsString());
|
||||
|
||||
e.set_name(common::get_tag_name(*enm));
|
||||
e.set_namespace(ns);
|
||||
e.set_id(common::to_id(*enm));
|
||||
set_ast_local_id(enm->getID(), e.id());
|
||||
@@ -358,7 +359,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
forward_declarations_.erase(id);
|
||||
|
||||
if (diagram_.should_include(class_model)) {
|
||||
LOG_DBG("Adding class {} with id {}", class_model.full_name(),
|
||||
LOG_DBG("Adding class {} with id {}", class_model.full_name(false),
|
||||
class_model.id());
|
||||
|
||||
diagram_.add_class(std::move(c_ptr));
|
||||
@@ -387,7 +388,8 @@ std::unique_ptr<class_> translation_unit_visitor::create_class_declaration(
|
||||
|
||||
namespace_ ns{qualified_name};
|
||||
ns.pop_back();
|
||||
c.set_name(cls->getNameAsString());
|
||||
|
||||
c.set_name(common::get_tag_name(*cls));
|
||||
c.set_namespace(ns);
|
||||
c.set_id(common::to_id(*cls));
|
||||
|
||||
@@ -415,6 +417,7 @@ void translation_unit_visitor::process_class_declaration(
|
||||
|
||||
if (cls.getParent()->isRecord()) {
|
||||
process_record_containment(cls, c);
|
||||
c.nested(true);
|
||||
}
|
||||
|
||||
c.complete(true);
|
||||
@@ -1809,10 +1812,6 @@ void translation_unit_visitor::process_field(
|
||||
common::to_string(field_type, field_declaration.getASTContext());
|
||||
// The field name
|
||||
const auto field_name = field_declaration.getNameAsString();
|
||||
// If for any reason clang reports the type as empty string, make sure
|
||||
// it has some default name
|
||||
if (type_name.empty())
|
||||
type_name = "<<anonymous>>";
|
||||
|
||||
class_member field{
|
||||
detail::access_specifier_to_access_t(field_declaration.getAccess()),
|
||||
|
||||
Reference in New Issue
Block a user