Refactored should_include in class diagram visitor
This commit is contained in:
@@ -556,7 +556,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
|||||||
if (source_manager().isInSystemHeader(cls->getSourceRange().getBegin()))
|
if (source_manager().isInSystemHeader(cls->getSourceRange().getBegin()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!diagram().should_include(cls->getQualifiedNameAsString()))
|
if (!should_include(cls))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
LOG_DBG("= Visiting class declaration {} at {}",
|
LOG_DBG("= Visiting class declaration {} at {}",
|
||||||
@@ -628,15 +628,13 @@ translation_unit_visitor::create_concept_declaration(clang::ConceptDecl *cpt)
|
|||||||
{
|
{
|
||||||
assert(cpt != nullptr);
|
assert(cpt != nullptr);
|
||||||
|
|
||||||
|
if (!should_include(cpt))
|
||||||
|
return {};
|
||||||
|
|
||||||
auto concept_ptr{
|
auto concept_ptr{
|
||||||
std::make_unique<model::concept_>(config_.using_namespace())};
|
std::make_unique<model::concept_>(config_.using_namespace())};
|
||||||
auto &concept_model = *concept_ptr;
|
auto &concept_model = *concept_ptr;
|
||||||
|
|
||||||
auto qualified_name = cpt->getQualifiedNameAsString();
|
|
||||||
|
|
||||||
if (!diagram().should_include(qualified_name))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
auto ns = common::get_template_namespace(*cpt);
|
auto ns = common::get_template_namespace(*cpt);
|
||||||
|
|
||||||
concept_model.set_name(cpt->getNameAsString());
|
concept_model.set_name(cpt->getNameAsString());
|
||||||
@@ -659,14 +657,12 @@ std::unique_ptr<class_> translation_unit_visitor::create_record_declaration(
|
|||||||
{
|
{
|
||||||
assert(rec != nullptr);
|
assert(rec != nullptr);
|
||||||
|
|
||||||
|
if (!should_include(rec))
|
||||||
|
return {};
|
||||||
|
|
||||||
auto record_ptr{std::make_unique<class_>(config_.using_namespace())};
|
auto record_ptr{std::make_unique<class_>(config_.using_namespace())};
|
||||||
auto &record = *record_ptr;
|
auto &record = *record_ptr;
|
||||||
|
|
||||||
auto qualified_name = rec->getQualifiedNameAsString();
|
|
||||||
|
|
||||||
if (!diagram().should_include(qualified_name))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
process_record_parent(rec, record, namespace_{});
|
process_record_parent(rec, record, namespace_{});
|
||||||
|
|
||||||
if (!record.is_nested()) {
|
if (!record.is_nested()) {
|
||||||
@@ -695,15 +691,12 @@ std::unique_ptr<class_> translation_unit_visitor::create_class_declaration(
|
|||||||
{
|
{
|
||||||
assert(cls != nullptr);
|
assert(cls != nullptr);
|
||||||
|
|
||||||
|
if (!should_include(cls))
|
||||||
|
return {};
|
||||||
|
|
||||||
auto c_ptr{std::make_unique<class_>(config_.using_namespace())};
|
auto c_ptr{std::make_unique<class_>(config_.using_namespace())};
|
||||||
auto &c = *c_ptr;
|
auto &c = *c_ptr;
|
||||||
|
|
||||||
// TODO: refactor to method get_qualified_name()
|
|
||||||
auto qualified_name = cls->getQualifiedNameAsString();
|
|
||||||
|
|
||||||
if (!diagram().should_include(qualified_name))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
auto ns{common::get_tag_namespace(*cls)};
|
auto ns{common::get_tag_namespace(*cls)};
|
||||||
|
|
||||||
process_record_parent(cls, c, ns);
|
process_record_parent(cls, c, ns);
|
||||||
@@ -846,8 +839,7 @@ bool translation_unit_visitor::process_template_parameters(
|
|||||||
ct.set_concept_constraint(
|
ct.set_concept_constraint(
|
||||||
named_concept->getQualifiedNameAsString());
|
named_concept->getQualifiedNameAsString());
|
||||||
if (templated_element &&
|
if (templated_element &&
|
||||||
diagram().should_include(
|
should_include(named_concept)) {
|
||||||
named_concept->getQualifiedNameAsString())) {
|
|
||||||
templated_element.value().add_relationship(
|
templated_element.value().add_relationship(
|
||||||
{relationship_t::kConstraint,
|
{relationship_t::kConstraint,
|
||||||
get_ast_local_id(named_concept->getID())
|
get_ast_local_id(named_concept->getID())
|
||||||
@@ -1139,9 +1131,7 @@ void translation_unit_visitor::process_friend(
|
|||||||
// TODO: handle template friend
|
// TODO: handle template friend
|
||||||
}
|
}
|
||||||
else if (friend_type->getAs<clang::RecordType>() != nullptr) {
|
else if (friend_type->getAs<clang::RecordType>() != nullptr) {
|
||||||
const auto friend_type_name =
|
if (should_include(friend_type->getAsRecordDecl())) {
|
||||||
friend_type->getAsRecordDecl()->getQualifiedNameAsString();
|
|
||||||
if (diagram().should_include(friend_type_name)) {
|
|
||||||
relationship r{relationship_t::kFriendship,
|
relationship r{relationship_t::kFriendship,
|
||||||
common::to_id(*friend_type->getAsRecordDecl()),
|
common::to_id(*friend_type->getAsRecordDecl()),
|
||||||
common::access_specifier_to_access_t(f.getAccess()),
|
common::access_specifier_to_access_t(f.getAccess()),
|
||||||
@@ -1269,10 +1259,7 @@ void translation_unit_visitor::
|
|||||||
const auto &template_specialization_model =
|
const auto &template_specialization_model =
|
||||||
diagram().classes().back();
|
diagram().classes().back();
|
||||||
|
|
||||||
const auto template_field_decl_name =
|
if (should_include(deduced_auto_decl)) {
|
||||||
deduced_auto_decl->getQualifiedNameAsString();
|
|
||||||
|
|
||||||
if (diagram().should_include(template_field_decl_name)) {
|
|
||||||
relationship r{relationship_t::kDependency,
|
relationship r{relationship_t::kDependency,
|
||||||
template_specialization_model.get().id()};
|
template_specialization_model.get().id()};
|
||||||
|
|
||||||
@@ -1524,33 +1511,30 @@ void translation_unit_visitor::
|
|||||||
const std::set<std::string> & /*template_parameter_names*/,
|
const std::set<std::string> & /*template_parameter_names*/,
|
||||||
const clang::TemplateSpecializationType &template_instantiation_type)
|
const clang::TemplateSpecializationType &template_instantiation_type)
|
||||||
{
|
{
|
||||||
const auto template_field_decl_name =
|
if (!should_include(
|
||||||
template_instantiation_type.getTemplateName()
|
template_instantiation_type.getTemplateName().getAsTemplateDecl()))
|
||||||
.getAsTemplateDecl()
|
return;
|
||||||
->getQualifiedNameAsString();
|
|
||||||
|
|
||||||
auto template_specialization_ptr =
|
auto template_specialization_ptr =
|
||||||
build_template_instantiation(template_instantiation_type);
|
build_template_instantiation(template_instantiation_type);
|
||||||
|
|
||||||
if (diagram().should_include(template_field_decl_name)) {
|
if (template_instantiation_type.isDependentType()) {
|
||||||
if (template_instantiation_type.isDependentType()) {
|
if (template_specialization_ptr) {
|
||||||
if (template_specialization_ptr) {
|
relationship r{
|
||||||
relationship r{relationship_t::kDependency,
|
relationship_t::kDependency, template_specialization_ptr->id()};
|
||||||
template_specialization_ptr->id()};
|
|
||||||
|
|
||||||
c.add_relationship(std::move(r));
|
c.add_relationship(std::move(r));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
if (template_specialization_ptr) {
|
else {
|
||||||
relationship r{relationship_t::kDependency,
|
if (template_specialization_ptr) {
|
||||||
template_specialization_ptr->id()};
|
relationship r{
|
||||||
|
relationship_t::kDependency, template_specialization_ptr->id()};
|
||||||
|
|
||||||
if (!diagram().has_element(template_specialization_ptr->id()))
|
if (!diagram().has_element(template_specialization_ptr->id()))
|
||||||
diagram().add_class(std::move(template_specialization_ptr));
|
diagram().add_class(std::move(template_specialization_ptr));
|
||||||
|
|
||||||
c.add_relationship(std::move(r));
|
c.add_relationship(std::move(r));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user