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