Ensure class methods and fields are only added once
This commit is contained in:
@@ -184,6 +184,9 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
|
||||
if (source_manager_.isInSystemHeader(cls->getSourceRange().getBegin()))
|
||||
return true;
|
||||
|
||||
if (!diagram().should_include(cls->getQualifiedNameAsString()))
|
||||
return true;
|
||||
|
||||
LOG_DBG("= Visiting template specialization declaration {} at {}",
|
||||
cls->getQualifiedNameAsString(),
|
||||
cls->getLocation().printToString(source_manager_));
|
||||
@@ -227,6 +230,9 @@ bool translation_unit_visitor::VisitTypeAliasTemplateDecl(
|
||||
if (source_manager_.isInSystemHeader(cls->getSourceRange().getBegin()))
|
||||
return true;
|
||||
|
||||
if (!diagram().should_include(cls->getQualifiedNameAsString()))
|
||||
return true;
|
||||
|
||||
LOG_DBG("= Visiting template type alias declaration {} at {}",
|
||||
cls->getQualifiedNameAsString(),
|
||||
cls->getLocation().printToString(source_manager_));
|
||||
@@ -262,6 +268,9 @@ bool translation_unit_visitor::VisitClassTemplateDecl(
|
||||
if (source_manager_.isInSystemHeader(cls->getSourceRange().getBegin()))
|
||||
return true;
|
||||
|
||||
if (!diagram().should_include(cls->getQualifiedNameAsString()))
|
||||
return true;
|
||||
|
||||
LOG_DBG("= Visiting class template declaration {} at {}",
|
||||
cls->getQualifiedNameAsString(),
|
||||
cls->getLocation().printToString(source_manager_));
|
||||
@@ -337,7 +346,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
? *diagram().get_class(cls_id).get()
|
||||
: *c_ptr;
|
||||
|
||||
if (cls->isCompleteDefinition())
|
||||
if (cls->isCompleteDefinition() && !class_model.complete())
|
||||
process_class_declaration(*cls, class_model);
|
||||
|
||||
auto id = class_model.id();
|
||||
@@ -407,6 +416,8 @@ void translation_unit_visitor::process_class_declaration(
|
||||
if (cls.getParent()->isRecord()) {
|
||||
process_record_containment(cls, c);
|
||||
}
|
||||
|
||||
c.complete(true);
|
||||
}
|
||||
|
||||
bool translation_unit_visitor::process_template_parameters(
|
||||
|
||||
@@ -28,6 +28,7 @@ std::atomic_uint64_t diagram_element::m_nextId = 1;
|
||||
|
||||
diagram_element::diagram_element()
|
||||
: id_{0}
|
||||
, complete_{false}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -83,6 +84,10 @@ inja::json diagram_element::context() const
|
||||
return ctx;
|
||||
}
|
||||
|
||||
bool diagram_element::complete() const { return complete_; }
|
||||
|
||||
void diagram_element::complete(bool completed) { complete_ = completed; }
|
||||
|
||||
bool operator==(const diagram_element &l, const diagram_element &r)
|
||||
{
|
||||
return l.id() == r.id();
|
||||
|
||||
@@ -65,11 +65,17 @@ public:
|
||||
|
||||
virtual inja::json context() const;
|
||||
|
||||
bool complete() const;
|
||||
|
||||
void complete(bool completed);
|
||||
|
||||
private:
|
||||
id_t id_;
|
||||
std::string name_;
|
||||
std::vector<relationship> relationships_;
|
||||
|
||||
bool complete_;
|
||||
|
||||
static std::atomic_uint64_t m_nextId;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user