Fixed rendering of methods in template class specializations
This commit is contained in:
@@ -1269,8 +1269,16 @@ void translation_unit_visitor::process_method(
|
||||
|
||||
ensure_lambda_type_is_relative(method_return_type);
|
||||
|
||||
auto method_name = mf.getNameAsString();
|
||||
if (mf.isTemplated()) {
|
||||
// Sometimes in template specializations method names contain the
|
||||
// template parameters for some reason - drop them
|
||||
// Is there a better way to do this?
|
||||
method_name = method_name.substr(0, method_name.find('<'));
|
||||
}
|
||||
|
||||
class_method method{common::access_specifier_to_access_t(mf.getAccess()),
|
||||
util::trim(mf.getNameAsString()), method_return_type};
|
||||
util::trim(method_name), method_return_type};
|
||||
|
||||
method.is_pure_virtual(mf.isPure());
|
||||
method.is_virtual(mf.isVirtual());
|
||||
@@ -1302,18 +1310,20 @@ void translation_unit_visitor::process_method(
|
||||
unaliased_type = unaliased_type->getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
if (unaliased_type != nullptr) {
|
||||
auto template_specialization_ptr = tbuilder().build(
|
||||
unaliased_type->getTemplateName().getAsTemplateDecl(),
|
||||
*unaliased_type, &c);
|
||||
|
||||
if (diagram().should_include(
|
||||
template_specialization_ptr->full_name(false))) {
|
||||
relationships.emplace_back(
|
||||
template_specialization_ptr->id(), relationship_t::kDependency);
|
||||
relationships.emplace_back(template_specialization_ptr->id(),
|
||||
relationship_t::kDependency);
|
||||
|
||||
diagram().add_class(std::move(template_specialization_ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
find_relationships(
|
||||
mf.getReturnType(), relationships, relationship_t::kDependency);
|
||||
|
||||
@@ -161,7 +161,7 @@ std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx,
|
||||
clanguml::util::replace_all(result, ", ", ",");
|
||||
clanguml::util::replace_all(result, "> >", ">>");
|
||||
|
||||
// Get rid of 'type-parameter-X-Y' ugliness
|
||||
// Try to get rid of 'type-parameter-X-Y' ugliness
|
||||
if (result.find("type-parameter-") != std::string::npos) {
|
||||
util::apply_if_not_null(
|
||||
common::dereference(type)->getAs<clang::TypedefType>(),
|
||||
|
||||
@@ -15,6 +15,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template <typename CastTo> CastTo *get_signal() { return (CastTo *)signal; }
|
||||
|
||||
private:
|
||||
signal_t *signal;
|
||||
};
|
||||
|
||||
@@ -35,6 +35,8 @@ TEST_CASE("t00044", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, !Contains("type-parameter-"));
|
||||
|
||||
REQUIRE_THAT(puml, IsClassTemplate("sink", "T"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("signal_handler", "T,A"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user