Fixed type aliases handling
This commit is contained in:
@@ -1069,8 +1069,6 @@ void translation_unit_visitor::process_class_bases(
|
||||
|
||||
cp.set_name(name_and_ns.to_string());
|
||||
|
||||
base.getType().dump();
|
||||
|
||||
if (const auto *tsp =
|
||||
base.getType()->getAs<clang::TemplateSpecializationType>();
|
||||
tsp != nullptr) {
|
||||
@@ -2227,9 +2225,8 @@ void translation_unit_visitor::find_instantiation_relationships(
|
||||
common::model::template_element &template_instantiation_base,
|
||||
const std::string &full_name, common::id_t templated_decl_id)
|
||||
{
|
||||
class_diagram::model::class_ &template_instantiation =
|
||||
dynamic_cast<class_diagram::model::class_ &>(
|
||||
template_instantiation_base);
|
||||
auto &template_instantiation = dynamic_cast<class_diagram::model::class_ &>(
|
||||
template_instantiation_base);
|
||||
|
||||
// First try to find the best match for this template in partially
|
||||
// specialized templates
|
||||
|
||||
@@ -932,14 +932,12 @@ bool is_struct(const clang::NamedDecl *decl)
|
||||
if (decl == nullptr)
|
||||
return false;
|
||||
|
||||
if (const clang::CXXRecordDecl *record =
|
||||
clang::dyn_cast<clang::CXXRecordDecl>(decl);
|
||||
if (const auto *record = clang::dyn_cast<clang::CXXRecordDecl>(decl);
|
||||
record) {
|
||||
return record->isStruct();
|
||||
}
|
||||
|
||||
if (const clang::TagDecl *tag = clang::dyn_cast<clang::TagDecl>(decl);
|
||||
tag) {
|
||||
if (const auto *tag = clang::dyn_cast<clang::TagDecl>(decl); tag) {
|
||||
return tag->isStruct();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class template_element : public element, public template_trait {
|
||||
public:
|
||||
using element::element;
|
||||
|
||||
virtual ~template_element() = default;
|
||||
~template_element() override = default;
|
||||
|
||||
/**
|
||||
* Whether or not the class is a template.
|
||||
@@ -76,4 +76,4 @@ private:
|
||||
bool is_template_{false};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace clanguml::common::model
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
namespace clanguml::common::visitor {
|
||||
|
||||
// using class_diagram::model::class_;
|
||||
using common::model::namespace_;
|
||||
using common::model::relationship_t;
|
||||
using common::model::template_parameter;
|
||||
@@ -540,4 +539,4 @@ private:
|
||||
on_argument_base_found_t on_argument_base_found_;
|
||||
};
|
||||
|
||||
} // namespace clanguml::class_diagram::visitor
|
||||
} // namespace clanguml::common::visitor
|
||||
@@ -226,8 +226,15 @@ std::string inheritable_diagram_options::simplify_template_type(
|
||||
type_aliases_longer_first_t aliases;
|
||||
aliases.insert(type_aliases().begin(), type_aliases().end());
|
||||
|
||||
for (const auto &[pattern, replacement] : aliases) {
|
||||
util::replace_all(full_name, pattern, replacement);
|
||||
bool matched{true};
|
||||
while (matched) {
|
||||
auto matched_in_iteration{false};
|
||||
for (const auto &[pattern, replacement] : aliases) {
|
||||
matched_in_iteration =
|
||||
util::replace_all(full_name, pattern, replacement) ||
|
||||
matched_in_iteration;
|
||||
}
|
||||
matched = matched_in_iteration;
|
||||
}
|
||||
|
||||
return full_name;
|
||||
|
||||
@@ -458,8 +458,18 @@ struct relationship_hint_t {
|
||||
using relationship_hints_t = std::map<std::string, relationship_hint_t>;
|
||||
|
||||
using type_aliases_t = std::map<std::string, std::string>;
|
||||
|
||||
struct type_aliases_longer_first_comparator {
|
||||
bool operator()(const std::string &a, const std::string &b) const
|
||||
{
|
||||
if (a.size() == b.size())
|
||||
return a > b;
|
||||
|
||||
return a.size() > b.size();
|
||||
}
|
||||
};
|
||||
using type_aliases_longer_first_t =
|
||||
std::map<std::string, std::string, std::greater<>>;
|
||||
std::map<std::string, std::string, type_aliases_longer_first_comparator>;
|
||||
|
||||
enum class location_t { marker, fileline, function };
|
||||
|
||||
|
||||
@@ -378,10 +378,13 @@ void generator::generate_participant(
|
||||
|
||||
print_debug(class_participant, ostr);
|
||||
|
||||
auto participant_name =
|
||||
config().using_namespace().relative(config().simplify_template_type(
|
||||
class_participant.full_name(false)));
|
||||
common::ensure_lambda_type_is_relative(config(), participant_name);
|
||||
|
||||
ostr << indent(1) << "participant " << class_participant.alias()
|
||||
<< " as "
|
||||
<< render_participant_name(config().using_namespace().relative(
|
||||
class_participant.full_name(false)));
|
||||
<< " as " << render_participant_name(participant_name);
|
||||
|
||||
ostr << '\n';
|
||||
|
||||
@@ -418,9 +421,12 @@ void generator::generate_participant(
|
||||
else {
|
||||
print_debug(participant, ostr);
|
||||
|
||||
auto participant_name = config().using_namespace().relative(
|
||||
config().simplify_template_type(participant.full_name(false)));
|
||||
common::ensure_lambda_type_is_relative(config(), participant_name);
|
||||
|
||||
ostr << indent(1) << "participant " << participant.alias() << " as "
|
||||
<< config().using_namespace().relative(
|
||||
participant.full_name(false));
|
||||
<< render_participant_name(participant_name);
|
||||
ostr << '\n';
|
||||
|
||||
generated_participants_.emplace(participant_id);
|
||||
|
||||
@@ -370,10 +370,13 @@ void generator::generate_participant(
|
||||
|
||||
print_debug(class_participant, ostr);
|
||||
|
||||
ostr << "participant \""
|
||||
<< render_name(config().using_namespace().relative(
|
||||
class_participant.full_name(false)))
|
||||
<< "\" as " << class_participant.alias();
|
||||
auto participant_name =
|
||||
config().using_namespace().relative(config().simplify_template_type(
|
||||
class_participant.full_name(false)));
|
||||
common::ensure_lambda_type_is_relative(config(), participant_name);
|
||||
|
||||
ostr << "participant \"" << render_name(participant_name) << "\" as "
|
||||
<< class_participant.alias();
|
||||
|
||||
if (config().generate_links) {
|
||||
common_generator<diagram_config, diagram_model>::generate_link(
|
||||
@@ -416,10 +419,12 @@ void generator::generate_participant(
|
||||
else {
|
||||
print_debug(participant, ostr);
|
||||
|
||||
ostr << "participant \""
|
||||
<< config().using_namespace().relative(
|
||||
participant.full_name(false))
|
||||
<< "\" as " << participant.alias();
|
||||
auto participant_name = config().using_namespace().relative(
|
||||
config().simplify_template_type(participant.full_name(false)));
|
||||
common::ensure_lambda_type_is_relative(config(), participant_name);
|
||||
|
||||
ostr << "participant \"" << render_name(participant_name) << "\" as "
|
||||
<< participant.alias();
|
||||
|
||||
if (config().generate_links) {
|
||||
common_generator<diagram_config, diagram_model>::generate_link(
|
||||
|
||||
@@ -164,7 +164,7 @@ template <typename T, typename S>
|
||||
std::unique_ptr<T> unique_pointer_cast(std::unique_ptr<S> &&p) noexcept
|
||||
{
|
||||
if (T *const converted = dynamic_cast<T *>(p.get())) {
|
||||
p.release();
|
||||
p.release(); // NOLINT
|
||||
return std::unique_ptr<T>{converted};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user